mimir-ui-kit 1.27.7 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,62 +1,62 @@
1
- # Mimir-ui
2
-
3
- ## Установка и запуск проекта
4
-
5
- 1. Установите зависимости:
6
- ```bash
7
- npm install
8
- ```
9
- 2. Запуск storybook
10
- ```bash
11
- npm run storybook
12
- ```
13
-
14
- ## Сборка проекта
15
-
16
- 1. Скрипт для сборки
17
- ```bash
18
- npm run build
19
- ```
20
-
21
- ## Создание нового компонента
22
-
23
- ```bash
24
- npm run create-component <ComponentName>
25
- ```
26
-
27
- ## Поднятие версии для публикации на npm
28
-
29
- Для поднятия версии пакета перед публикацией на npm используем следующие скрипты:
30
-
31
- 1. `patch`: Этот скрипт увеличивает версию пакета на один патч (например, с версии 1.0.0 до 1.0.1). Он автоматически обновляет версию в файле package.json и создает коммит с обновленной версией.
32
-
33
- ```bash
34
- npm version patch
35
- ```
36
-
37
- 2. `minor`: Этот скрипт увеличивает версию пакета на один минорный уровень (например, с версии 1.0.0 до 1.1.0). Также обновляет версию в package.json и создает коммит.
38
- ```bash
39
- npm version minor
40
- ```
41
- 3. `major`: Этот скрипт увеличивает версию пакета на один мажорный уровень (например, с версии 1.0.0 до 2.0.0). Он также обновляет версию в package.json и создает коммит.
42
- ```bash
43
- npm version major
44
- ```
45
-
46
- ## Публикация на npm
47
-
48
- 1. Скрипт для публикации на npm:
49
- ```bash
50
- npm publish
51
- ```
52
-
53
- ## Ручная Генерация иконок
54
-
55
- 1. Экспортируем с фигмы иконку.
56
- 2. Добавляем ее в папку svgs.
57
- 3. Запускаем скрипт:
58
- ```bash
59
- npm run icons
60
- ```
61
- 4. Смотрим в папку `icons/components`
62
- 5. Готово.
1
+ # Mimir-ui
2
+
3
+ ## Установка и запуск проекта
4
+
5
+ 1. Установите зависимости:
6
+ ```bash
7
+ npm install
8
+ ```
9
+ 2. Запуск storybook
10
+ ```bash
11
+ npm run storybook
12
+ ```
13
+
14
+ ## Сборка проекта
15
+
16
+ 1. Скрипт для сборки
17
+ ```bash
18
+ npm run build
19
+ ```
20
+
21
+ ## Создание нового компонента
22
+
23
+ ```bash
24
+ npm run create-component <ComponentName>
25
+ ```
26
+
27
+ ## Поднятие версии для публикации на npm
28
+
29
+ Для поднятия версии пакета перед публикацией на npm используем следующие скрипты:
30
+
31
+ 1. `patch`: Этот скрипт увеличивает версию пакета на один патч (например, с версии 1.0.0 до 1.0.1). Он автоматически обновляет версию в файле package.json и создает коммит с обновленной версией.
32
+
33
+ ```bash
34
+ npm version patch
35
+ ```
36
+
37
+ 2. `minor`: Этот скрипт увеличивает версию пакета на один минорный уровень (например, с версии 1.0.0 до 1.1.0). Также обновляет версию в package.json и создает коммит.
38
+ ```bash
39
+ npm version minor
40
+ ```
41
+ 3. `major`: Этот скрипт увеличивает версию пакета на один мажорный уровень (например, с версии 1.0.0 до 2.0.0). Он также обновляет версию в package.json и создает коммит.
42
+ ```bash
43
+ npm version major
44
+ ```
45
+
46
+ ## Публикация на npm
47
+
48
+ 1. Скрипт для публикации на npm:
49
+ ```bash
50
+ npm publish
51
+ ```
52
+
53
+ ## Ручная Генерация иконок
54
+
55
+ 1. Экспортируем с фигмы иконку.
56
+ 2. Добавляем ее в папку svgs.
57
+ 3. Запускаем скрипт:
58
+ ```bash
59
+ npm run icons
60
+ ```
61
+ 4. Смотрим в папку `icons/components`
62
+ 5. Готово.
@@ -1 +1 @@
1
- ._accordion_11qul_2{padding-bottom:var(--accordion-space);border-bottom:1px solid var(--black-20)}._accordion_11qul_2 svg path{fill:var(--white)}._accordion_11qul_2._is-link_11qul_9{border:none}._header_11qul_13{display:flex;gap:var(--space-m);align-items:flex-start;justify-content:space-between;width:100%;font-weight:var(--font-weight-text-medium);font-family:var(--font-montserrat);text-align:left;border:none;cursor:pointer}._title_11qul_26{font-size:var(--accordion-text-size)}._title-uppercase_11qul_29{text-transform:uppercase}._icon_11qul_33{transition:transform .3s ease-in-out}._icon-container_11qul_36{display:flex;align-items:center;justify-content:center;transition:background-color .3s ease-in-out}._circle_11qul_43{min-width:var(--accordion-icon-circle-width);min-height:var(--accordion-icon-circle-height);background-color:var(--black-80);border-radius:50%}._square_11qul_50{min-width:var(--accordion-icon-square-width);min-height:var(--accordion-icon-square-height);background-color:var(--white);border-radius:var(--control-radius)}._square_11qul_50 svg path{fill:var(--black-100)}._panel_11qul_60{margin-top:var(--accordion-panel-space)}._panel_11qul_60._is-link_11qul_9{margin-top:var(--space-xs)}._open_11qul_67{background-color:var(--sapphire-100)}._open_11qul_67 svg{transform:rotate(-180deg)}._open_11qul_67._circle_11qul_43{background-color:var(--sapphire-100)}._open_11qul_67._square_11qul_50{background-color:var(--black-80)}._open_11qul_67._square_11qul_50 svg path{fill:var(--white)}._link-open_11qul_83{transform:rotate(-180deg)}._m_11qul_87{--accordion-space: var(--space-xl);--accordion-text-size: var(--size-text-xl2);--accordion-icon-circle-width: var(--accordion-icon-circle-size-m);--accordion-icon-circle-height: var(--accordion-icon-circle-size-m);--accordion-icon-square-width: var(--accordion-icon-square-size-m);--accordion-icon-square-height: var(--accordion-icon-square-size-m);--accordion-panel-space: var(--space-xl)}._s_11qul_50{--accordion-space: var(--space-m);--accordion-text-size: var(--size-text-l);--accordion-icon-circle-width: var(--accordion-icon-circle-size-s);--accordion-icon-circle-height: var(--accordion-icon-circle-size-s);--accordion-icon-square-width: var(--accordion-icon-square-size-s);--accordion-icon-square-height: var(--accordion-icon-square-size-s);--accordion-panel-space: var(--space-m)}
1
+ ._accordion_2if29_2{padding-bottom:var(--accordion-space);border-bottom:1px solid var(--black-20)}._accordion_2if29_2 svg path{fill:var(--white)}._accordion_2if29_2._is-link_2if29_9{border:none}._header_2if29_13{display:flex;gap:var(--space-m);align-items:flex-start;justify-content:space-between;width:100%;font-weight:var(--font-weight-text-medium);font-family:var(--font-montserrat);text-align:left;border:none;cursor:pointer}._title_2if29_26{font-size:var(--accordion-text-size)}._title-uppercase_2if29_29{text-transform:uppercase}._icon_2if29_33{transition:transform .3s ease-in-out}._icon-container_2if29_36{display:flex;align-items:center;justify-content:center;transition:background-color .3s ease-in-out}._circle_2if29_43{min-width:var(--accordion-icon-circle-width);min-height:var(--accordion-icon-circle-height);background-color:var(--black-80);border-radius:50%}._square_2if29_50{min-width:var(--accordion-icon-square-width);min-height:var(--accordion-icon-square-height);background-color:var(--white);border-radius:var(--control-radius)}._square_2if29_50 svg path{fill:var(--black-100)}._panel_2if29_60{margin-top:var(--accordion-panel-space)}._panel_2if29_60._is-link_2if29_9{margin-top:var(--space-xs)}._open_2if29_67{background-color:var(--sapphire-100)}._open_2if29_67 svg{transform:rotate(-180deg)}._open_2if29_67._circle_2if29_43{background-color:var(--sapphire-100)}._open_2if29_67._square_2if29_50{background-color:var(--black-80)}._open_2if29_67._square_2if29_50 svg path{fill:var(--white)}._link-open_2if29_83{transform:rotate(-180deg)}._m_2if29_87{--accordion-space: var(--space-xl);--accordion-text-size: var(--size-text-xl2);--accordion-icon-circle-width: var(--accordion-icon-circle-size-m);--accordion-icon-circle-height: var(--accordion-icon-circle-size-m);--accordion-icon-square-width: var(--accordion-icon-square-size-m);--accordion-icon-square-height: var(--accordion-icon-square-size-m);--accordion-panel-space: var(--space-xl)}._s_2if29_50{--accordion-space: var(--space-m);--accordion-text-size: var(--size-text-l);--accordion-icon-circle-width: var(--accordion-icon-circle-size-s);--accordion-icon-circle-height: var(--accordion-icon-circle-size-s);--accordion-icon-square-width: var(--accordion-icon-square-size-s);--accordion-icon-square-height: var(--accordion-icon-square-size-s);--accordion-panel-space: var(--space-m)}._wrapper-button_2if29_107{width:100%}
@@ -119,31 +119,32 @@ function Re(e2, n) {
119
119
  return React__default.createElement(s$1, null, React__default.createElement(H.Provider, { value: t2.panelId }, H$1({ mergeRefs: f, ourProps: g, theirProps: d, slot: D2, defaultTag: Se, features: be, visible: p, name: "Disclosure.Panel" })));
120
120
  }
121
121
  let Ae = W(me), Ce = W(ge), Ie = W(Re), We = Object.assign(Ae, { Button: Ce, Panel: Ie });
122
- const accordion = "_accordion_11qul_2";
123
- const header = "_header_11qul_13";
124
- const title = "_title_11qul_26";
125
- const icon = "_icon_11qul_33";
126
- const circle = "_circle_11qul_43";
127
- const square = "_square_11qul_50";
128
- const panel = "_panel_11qul_60";
129
- const open = "_open_11qul_67";
130
- const m = "_m_11qul_87";
131
- const s = "_s_11qul_50";
122
+ const accordion = "_accordion_2if29_2";
123
+ const header = "_header_2if29_13";
124
+ const title = "_title_2if29_26";
125
+ const icon = "_icon_2if29_33";
126
+ const circle = "_circle_2if29_43";
127
+ const square = "_square_2if29_50";
128
+ const panel = "_panel_2if29_60";
129
+ const open = "_open_2if29_67";
130
+ const m = "_m_2if29_87";
131
+ const s = "_s_2if29_50";
132
132
  const cls = {
133
133
  accordion,
134
- "is-link": "_is-link_11qul_9",
134
+ "is-link": "_is-link_2if29_9",
135
135
  header,
136
136
  title,
137
- "title-uppercase": "_title-uppercase_11qul_29",
137
+ "title-uppercase": "_title-uppercase_2if29_29",
138
138
  icon,
139
- "icon-container": "_icon-container_11qul_36",
139
+ "icon-container": "_icon-container_2if29_36",
140
140
  circle,
141
141
  square,
142
142
  panel,
143
143
  open,
144
- "link-open": "_link-open_11qul_83",
144
+ "link-open": "_link-open_2if29_83",
145
145
  m,
146
- s
146
+ s,
147
+ "wrapper-button": "_wrapper-button_2if29_107"
147
148
  };
148
149
  const Accordion = forwardRef(
149
150
  ({
@@ -168,6 +169,9 @@ const Accordion = forwardRef(
168
169
  const linkClasses = {
169
170
  [cls["is-link"]]: isLink
170
171
  };
172
+ const toggleAccordion = () => {
173
+ setIsOpen(!isOpen);
174
+ };
171
175
  const renderButton = (open2) => {
172
176
  const getIconName = () => {
173
177
  if (iconType === EAccordionIconType.DROPDOWN) {
@@ -211,7 +215,7 @@ const Accordion = forwardRef(
211
215
  {
212
216
  className: classNames(
213
217
  cls["icon-container"],
214
- open2 && cls.open,
218
+ open2,
215
219
  cls[buttonStyle],
216
220
  classNameIconButton
217
221
  ),
@@ -235,34 +239,29 @@ const Accordion = forwardRef(
235
239
  linkClasses,
236
240
  classNameAccordion
237
241
  ),
238
- children: /* @__PURE__ */ jsx(We, { ref, children: ({ open: open2 }) => {
239
- if (open2 !== isOpen) {
240
- setIsOpen(open2);
241
- }
242
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
243
- /* @__PURE__ */ jsx(
244
- Ce,
245
- {
246
- as: isLink ? Fragment : EAccordionButtonType.BUTTON,
247
- className: classNames({
248
- [cls.header]: !isLink
249
- }),
250
- children: renderButton(open2)
251
- }
252
- ),
253
- /* @__PURE__ */ jsx(
254
- Ie,
255
- {
256
- className: classNames(
257
- cls.panel,
258
- classNameContent,
259
- linkClasses
260
- ),
261
- children: /* @__PURE__ */ jsx(AccordionItem, { size, children })
262
- }
263
- )
264
- ] });
265
- } })
242
+ children: /* @__PURE__ */ jsxs(We, { ref, children: [
243
+ /* @__PURE__ */ jsx("div", { className: cls["wrapper-button"], onClick: toggleAccordion, children: /* @__PURE__ */ jsx(
244
+ Ce,
245
+ {
246
+ as: isLink ? Fragment : EAccordionButtonType.BUTTON,
247
+ className: classNames({
248
+ [cls.header]: !isLink
249
+ }),
250
+ children: renderButton()
251
+ }
252
+ ) }),
253
+ isOpen && /* @__PURE__ */ jsx(
254
+ Ie,
255
+ {
256
+ className: classNames(
257
+ cls.panel,
258
+ classNameContent,
259
+ linkClasses
260
+ ),
261
+ children: /* @__PURE__ */ jsx(AccordionItem, { size, children })
262
+ }
263
+ )
264
+ ] })
266
265
  }
267
266
  ),
268
267
  (subtitleNode || onlyOpenSubtitleNode) && /* @__PURE__ */ jsxs("div", { className: classNameSubtitleContainer, children: [
@@ -47,7 +47,6 @@ const Steps = forwardRef(
47
47
  classNameIconStep,
48
48
  ...otherProps
49
49
  } = props;
50
- console.log("quantity", quantity);
51
50
  const idPrefix = useId();
52
51
  const [step2, setStep] = useState(current);
53
52
  const [hoveredStep, setHoveredStep] = useState(null);
@@ -59,11 +58,9 @@ const Steps = forwardRef(
59
58
  useEffect(() => {
60
59
  if (fillByActualZone) {
61
60
  const zone = zones.find((zone2) => zone2.to >= (step2 || 0));
62
- if (zone) {
63
- setCurrentColor(zone.color);
64
- }
61
+ zone && setCurrentColor(zone.color);
65
62
  }
66
- }, []);
63
+ }, [fillByActualZone, step2, zones]);
67
64
  const handleClick = (idx) => {
68
65
  const clickedStep = idx + DIFF_BETWEEN_STEP_AND_INDEX;
69
66
  stepWasChangedRef.current = true;
@@ -117,6 +114,7 @@ const Steps = forwardRef(
117
114
  return /* @__PURE__ */ jsx(
118
115
  "button",
119
116
  {
117
+ type: "button",
120
118
  style: {
121
119
  backgroundColor: resizable2 ? color !== null ? color : void 0 : void 0,
122
120
  color: color !== null ? color : void 0,
@@ -0,0 +1,3 @@
1
+ import { TUniversalUploader } from './types';
2
+
3
+ export declare const UniversalUploader: import('react').ForwardRefExoticComponent<TUniversalUploader & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,120 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { forwardRef, useState, useEffect } from "react";
4
+ import { imageTypes } from "./constants.js";
5
+ import { ListFiles } from "../ListFiles/ListFiles.js";
6
+ import { ListPhotos } from "../ListPhotos/ListPhotos.js";
7
+ import { imageFileTypes } from "../Uploader/constants.js";
8
+ import { Uploader } from "../Uploader/Uploader.js";
9
+ import '../../assets/UploaderPhotos.css';const cls = {
10
+ "upload-file-wrapper": "_upload-file-wrapper_2zki8_2"
11
+ };
12
+ const UniversalUploader = forwardRef(
13
+ (props, ref) => {
14
+ const {
15
+ type,
16
+ filesType,
17
+ arrayName,
18
+ maxSize,
19
+ onChange,
20
+ value,
21
+ maxFiles,
22
+ titleUploader
23
+ } = props;
24
+ const [items, setItems] = useState(
25
+ value || []
26
+ );
27
+ const isMaxFilesReached = items.length >= maxFiles;
28
+ useEffect(() => {
29
+ if (value) {
30
+ setItems(value);
31
+ }
32
+ }, [value]);
33
+ const isImageFile = (file) => {
34
+ var _a;
35
+ if (!file) return false;
36
+ if (file instanceof File) {
37
+ return imageTypes.includes(file.type);
38
+ }
39
+ if ("file" in file && file.file instanceof File) {
40
+ return imageTypes.includes(file.file.type);
41
+ }
42
+ if ("url" in file && typeof file.url === "string") {
43
+ if (file.url.startsWith("blob:")) {
44
+ return typeof file.type === "string" && imageTypes.includes(file.type);
45
+ }
46
+ const extension = (_a = file.url.split(".").pop()) == null ? void 0 : _a.toLowerCase();
47
+ return imageFileTypes.includes(extension);
48
+ }
49
+ return false;
50
+ };
51
+ const onChangeValue = (e) => {
52
+ const newItems = e.value.map((el) => {
53
+ if (isImageFile(el.file)) {
54
+ return {
55
+ id: el.id,
56
+ url: URL.createObjectURL(el.file),
57
+ type: el.file.type,
58
+ name: el.file.name,
59
+ size: el.file.size
60
+ };
61
+ } else {
62
+ return {
63
+ id: el.id,
64
+ url: "",
65
+ size: el.file.size,
66
+ name: el.file.name,
67
+ type: el.file.type
68
+ };
69
+ }
70
+ });
71
+ setItems((prev) => [...prev, ...newItems]);
72
+ onChange == null ? void 0 : onChange({ type: "add", data: e.value });
73
+ };
74
+ const onDelete = (deleteId) => {
75
+ setItems((prev) => prev.filter((item) => item.id !== deleteId));
76
+ onChange == null ? void 0 : onChange({ type: "delete", data: deleteId });
77
+ };
78
+ return /* @__PURE__ */ jsxs(
79
+ "div",
80
+ {
81
+ className: classNames(
82
+ cls["upload-file-wrapper"],
83
+ isMaxFilesReached && cls.disabled
84
+ ),
85
+ children: [
86
+ /* @__PURE__ */ jsx(
87
+ Uploader,
88
+ {
89
+ filesType,
90
+ arrayName,
91
+ maxSize,
92
+ onChangeValue,
93
+ ref,
94
+ maxFiles,
95
+ isDisabled: isMaxFilesReached,
96
+ titleUploader
97
+ }
98
+ ),
99
+ (type === "files" || type === "all") && /* @__PURE__ */ jsx(
100
+ ListFiles,
101
+ {
102
+ value: items.filter((item) => !isImageFile(item)),
103
+ onChange: (j) => onDelete(j.deleteId)
104
+ }
105
+ ),
106
+ (type === "photos" || type === "all") && /* @__PURE__ */ jsx(
107
+ ListPhotos,
108
+ {
109
+ value: items.filter((item) => isImageFile(item)),
110
+ onChange: (j) => onDelete(j.deleteId)
111
+ }
112
+ )
113
+ ]
114
+ }
115
+ );
116
+ }
117
+ );
118
+ export {
119
+ UniversalUploader
120
+ };
@@ -0,0 +1,6 @@
1
+ export declare enum EUploaderType {
2
+ FILES = "files",
3
+ PHOTOS = "photos",
4
+ ALL = "all"
5
+ }
6
+ export declare const imageTypes: string[];
@@ -0,0 +1,18 @@
1
+ var EUploaderType = /* @__PURE__ */ ((EUploaderType2) => {
2
+ EUploaderType2["FILES"] = "files";
3
+ EUploaderType2["PHOTOS"] = "photos";
4
+ EUploaderType2["ALL"] = "all";
5
+ return EUploaderType2;
6
+ })(EUploaderType || {});
7
+ const imageTypes = [
8
+ "image/jpg",
9
+ "image/jpeg",
10
+ "image/png",
11
+ "image/gif",
12
+ "image/tiff",
13
+ "image/heic"
14
+ ];
15
+ export {
16
+ EUploaderType,
17
+ imageTypes
18
+ };
@@ -0,0 +1,3 @@
1
+ export { UniversalUploader } from './UniversalUploader';
2
+ export type { TUniversalUploader, TOnChangeUpdate, TPhotoWithType, TFileWithType } from './types';
3
+ export { EUploaderType } from './constants';
@@ -0,0 +1,6 @@
1
+ import { UniversalUploader } from "./UniversalUploader.js";
2
+ import { EUploaderType } from "./constants.js";
3
+ export {
4
+ EUploaderType,
5
+ UniversalUploader
6
+ };
@@ -0,0 +1,26 @@
1
+ import { TFilesDetail } from '../ListFiles/ListFiles';
2
+ import { TPhotosDetail } from '../ListPhotos/ListPhotos';
3
+ import { TFileItem } from '../Uploader';
4
+ import { imageTypesArr } from '../Uploader/constants';
5
+
6
+ export type TUniversalUploader = {
7
+ type: 'files' | 'photos' | 'all';
8
+ filesType: imageTypesArr[];
9
+ arrayName: string;
10
+ maxSize: number;
11
+ onChange: (j: TOnChangeUpdate) => void;
12
+ value?: TFilesDetail[] | TPhotosDetail[];
13
+ maxFiles: number;
14
+ titleUploader?: string;
15
+ disabled?: boolean;
16
+ };
17
+ export type TOnChangeUpdate = {
18
+ type: string;
19
+ data: TFileItem[] | number;
20
+ };
21
+ export type TFileWithType = TFilesDetail & {
22
+ type?: string;
23
+ };
24
+ export type TPhotoWithType = TPhotosDetail & {
25
+ type?: string;
26
+ };
@@ -4,7 +4,7 @@ import { imageTypesArr } from './constants';
4
4
  export type TUploader = {
5
5
  /**
6
6
  * Массив разрешенных типов файлов для настройки валидации
7
- * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'doc' | 'xls' | 'pdf' | 'docx' | 'txt' | 'xlsx'
7
+ * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'heic' | 'doc' | 'xls' | 'pdf' | 'docx' | 'txt' | 'xlsx'
8
8
  */
9
9
  filesType: imageTypesArr[];
10
10
  /**
@@ -13,6 +13,7 @@ const MIME = {
13
13
  png: "image/png",
14
14
  tiff: "image/tiff",
15
15
  gif: "image/gif",
16
+ heic: "image/heic",
16
17
  webp: "image/webp",
17
18
  doc: "application/msword",
18
19
  docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@@ -21,10 +22,22 @@ const MIME = {
21
22
  txt: "text/plain",
22
23
  xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
23
24
  };
24
- const filesTyps = ["jpeg", "jpg", "png", "tiff", "gif"];
25
- const generateId = (min, max) => {
26
- return Math.round(Math.random() * (max - min) + min);
25
+ const filesTyps = [
26
+ "jpeg",
27
+ "jpg",
28
+ "png",
29
+ "tiff",
30
+ "gif",
31
+ "heic"
32
+ ];
33
+ const createIdGenerator = () => {
34
+ let id = 0;
35
+ return () => {
36
+ id = (id + 1) % Number.MAX_SAFE_INTEGER;
37
+ return id;
38
+ };
27
39
  };
40
+ const generateId = createIdGenerator();
28
41
  const Uploader = forwardRef(
29
42
  (props, ref) => {
30
43
  const {
@@ -32,20 +45,32 @@ const Uploader = forwardRef(
32
45
  onChangeValue,
33
46
  arrayName,
34
47
  maxSize = 15,
48
+ maxFiles,
35
49
  isDisabled,
36
50
  titleUploader = "Или перетащите сюда"
37
51
  } = props;
38
52
  const uploaderRef = useRef(null);
53
+ const inputRef = useRef(null);
39
54
  const idImg = useId();
55
+ const getFileType = (file) => {
56
+ var _a;
57
+ if (file.type) return file.type;
58
+ const extension = (_a = file.name.split(".").pop()) == null ? void 0 : _a.toLowerCase();
59
+ if (extension === "heic") return "image/heic";
60
+ return "";
61
+ };
40
62
  const onChange = (e) => {
41
63
  if (e.target.files && e.target.files[0]) {
42
- const list = [];
43
- Array.from(e.target.files).forEach((el) => {
44
- if (filesType.map((name) => MIME[name]).includes(el.type) && el.size / 1024 ** 2 <= maxSize) {
45
- list.push({ file: el, id: generateId(1, 100) });
46
- }
47
- });
64
+ const list = Array.from(e.target.files).filter((el) => {
65
+ const fileType = getFileType(el);
66
+ const isValidType = filesType.map((name) => MIME[name]).includes(fileType);
67
+ const isValidSize = el.size / 1024 ** 2 <= maxSize;
68
+ return isValidType && isValidSize;
69
+ }).slice(0, maxFiles).map((el) => ({ file: el, id: generateId() }));
48
70
  onChangeValue({ arrayName, value: list });
71
+ if (inputRef.current) {
72
+ inputRef.current.value = "";
73
+ }
49
74
  }
50
75
  };
51
76
  const onOpen = () => {
@@ -56,6 +81,7 @@ const Uploader = forwardRef(
56
81
  /* @__PURE__ */ jsx(
57
82
  "input",
58
83
  {
84
+ ref: inputRef,
59
85
  type: "file",
60
86
  className: cls["upload-file-input"],
61
87
  "aria-label": "Upload",
@@ -1,5 +1,8 @@
1
- export type imageTypesArr = 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'doc' | 'xls' | 'pdf' | 'docx' | 'txt' | 'xlsx';
1
+ export type imageTypesArr = 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'heic' | 'doc' | 'xls' | 'pdf' | 'docx' | 'txt' | 'xlsx';
2
+ export declare const imageFileTypes: imageTypesArr[];
3
+ export declare const AllFileTypes: imageTypesArr[];
2
4
  export declare const TypeFilesArray: {
3
5
  images: imageTypesArr[];
4
6
  docs: imageTypesArr[];
7
+ all: imageTypesArr[];
5
8
  };
@@ -1,4 +1,11 @@
1
- const imageFileTypes = ["jpeg", "jpg", "png", "tiff", "gif"];
1
+ const imageFileTypes = [
2
+ "jpeg",
3
+ "jpg",
4
+ "png",
5
+ "tiff",
6
+ "gif",
7
+ "heic"
8
+ ];
2
9
  const docsFileTypes = [
3
10
  "doc",
4
11
  "xls",
@@ -7,10 +14,27 @@ const docsFileTypes = [
7
14
  "txt",
8
15
  "xlsx"
9
16
  ];
17
+ const AllFileTypes = [
18
+ "jpeg",
19
+ "jpg",
20
+ "png",
21
+ "tiff",
22
+ "gif",
23
+ "heic",
24
+ "doc",
25
+ "xls",
26
+ "pdf",
27
+ "docx",
28
+ "txt",
29
+ "xlsx"
30
+ ];
10
31
  const TypeFilesArray = {
11
32
  images: imageFileTypes,
12
- docs: docsFileTypes
33
+ docs: docsFileTypes,
34
+ all: AllFileTypes
13
35
  };
14
36
  export {
15
- TypeFilesArray
37
+ AllFileTypes,
38
+ TypeFilesArray,
39
+ imageFileTypes
16
40
  };
@@ -1,2 +1,3 @@
1
1
  export { Uploader } from './Uploader';
2
2
  export type { TUploader, TFileItem, TUploadValue } from './Uploader';
3
+ export { imageFileTypes } from './constants.ts';
@@ -1,4 +1,6 @@
1
1
  import { Uploader } from "./Uploader.js";
2
+ import { imageFileTypes } from "./constants.js";
2
3
  export {
3
- Uploader
4
+ Uploader,
5
+ imageFileTypes
4
6
  };
@@ -5,7 +5,7 @@ import { TFileItem } from '../Uploader/Uploader';
5
5
  export type TUploaderFiles = {
6
6
  /**
7
7
  * Массив разрешенных типов файлов для настройки валидации
8
- * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'doc' | 'xls' | 'pdf' |'docx' | 'txt'
8
+ * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'heic' | 'doc' | 'xls' | 'pdf' |'docx' | 'txt'
9
9
  */
10
10
  filesType: imageTypesArr[];
11
11
  /**
@@ -5,7 +5,7 @@ import { TFileItem } from '../Uploader/Uploader';
5
5
  export type TUploaderPhotos = {
6
6
  /**
7
7
  * Массив разрешенных типов файлов для настройки валидации
8
- * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'doc' | 'xls' | 'pdf' |'docx' | 'txt'
8
+ * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'heic' | 'doc' | 'xls' | 'pdf' |'docx' | 'txt'
9
9
  */
10
10
  filesType: imageTypesArr[];
11
11
  /**
@@ -42,3 +42,5 @@ export { NotificationBadge } from './NotificationBadge';
42
42
  export type { TNotificationBadgeProps } from './NotificationBadge';
43
43
  export { ENotificationBadgeSize } from './NotificationBadge';
44
44
  export { Chip, EChipSize, EChipVariant } from './Chip';
45
+ export { UniversalUploader, EUploaderType } from './UniversalUploader';
46
+ export type { TUniversalUploader, TOnChangeUpdate, TPhotoWithType, TFileWithType } from './UniversalUploader';
@@ -43,6 +43,8 @@ import { NotificationBadge } from "./NotificationBadge/NotificationBadge.js";
43
43
  import { ENotificationBadgeSize } from "./NotificationBadge/constants.js";
44
44
  import { Chip } from "./Chip/Chip.js";
45
45
  import { EChipSize, EChipVariant } from "./Chip/constants.js";
46
+ import { UniversalUploader } from "./UniversalUploader/UniversalUploader.js";
47
+ import { EUploaderType } from "./UniversalUploader/constants.js";
46
48
  export {
47
49
  Accordion,
48
50
  AccordionItem,
@@ -75,6 +77,7 @@ export {
75
77
  ETagType,
76
78
  EToastPosition,
77
79
  EToastVariant,
80
+ EUploaderType,
78
81
  EVoteSize,
79
82
  AppImage as Image,
80
83
  I as Input,
@@ -95,6 +98,7 @@ export {
95
98
  TextArea,
96
99
  Timer,
97
100
  ToastProvider,
101
+ UniversalUploader,
98
102
  Uploader,
99
103
  UploaderPhotos,
100
104
  Vote,
@@ -13,7 +13,7 @@ const PersonalManager32px = (props) => {
13
13
  /* @__PURE__ */ jsx(
14
14
  "path",
15
15
  {
16
- "fill-rule": "evenodd",
16
+ fillRule: "evenodd",
17
17
  clipRule: "evenodd",
18
18
  d: "M12.3627 11.7881C12.4759 11.7881 12.5677 11.8799 12.5677 11.9931V16.2677C12.5796 16.2931 12.5973 16.3305 12.6205 16.3781C12.6676 16.4748 12.7373 16.6135 12.8273 16.7801C13.0074 17.1139 13.2674 17.5576 13.5878 18.0002C13.9089 18.4438 14.2856 18.8792 14.6974 19.2019C15.1102 19.5253 15.5421 19.7232 15.9784 19.7232C16.4147 19.7232 16.8466 19.5253 17.2594 19.2019C17.6712 18.8792 18.0479 18.4438 18.369 18.0002C18.6893 17.5576 18.9494 17.1139 19.1295 16.7801C19.2195 16.6135 19.2892 16.4748 19.3363 16.3781C19.3595 16.3305 19.3772 16.2931 19.389 16.2677V11.9931C19.389 11.8799 19.4808 11.7881 19.5941 11.7881C19.7073 11.7881 19.7991 11.8799 19.7991 11.9931V16.3563L19.7812 16.3963L19.5941 16.3125C19.7812 16.3963 19.7812 16.3962 19.7812 16.3963L19.7807 16.3973L19.7797 16.3996L19.7758 16.4081C19.7739 16.4124 19.7714 16.4178 19.7684 16.4244C19.7662 16.429 19.7638 16.4341 19.7612 16.4398C19.7484 16.4672 19.7295 16.5071 19.7049 16.5577C19.6557 16.6588 19.5833 16.8026 19.4903 16.9749C19.3046 17.319 19.0351 17.7792 18.7012 18.2406C18.368 18.7008 17.9656 19.1694 17.5123 19.5246C17.0599 19.8791 16.5406 20.1332 15.9784 20.1332C15.4162 20.1332 14.8969 19.8791 14.4445 19.5246C13.9912 19.1694 13.5888 18.7008 13.2556 18.2406C12.9216 17.7792 12.6522 17.319 12.4664 16.9749C12.3734 16.8026 12.3011 16.6588 12.2519 16.5577C12.2272 16.5071 12.2084 16.4672 12.1956 16.4398C12.1892 16.426 12.1843 16.4154 12.1809 16.4081L12.1771 16.3996L12.1761 16.3973L12.1758 16.3966C12.1757 16.3966 12.1756 16.3963 12.3627 16.3125L12.1756 16.3963L12.1577 16.3563V11.9931C12.1577 11.8799 12.2495 11.7881 12.3627 11.7881Z",
19
19
  fill: "#4D4D4D"
@@ -22,7 +22,7 @@ const PersonalManager32px = (props) => {
22
22
  /* @__PURE__ */ jsx(
23
23
  "path",
24
24
  {
25
- "fill-rule": "evenodd",
25
+ fillRule: "evenodd",
26
26
  clipRule: "evenodd",
27
27
  d: "M10.262 10.9373C10.262 7.72731 12.8655 5.12842 16.0708 5.12842C19.2808 5.12842 21.8797 7.73192 21.8797 10.9373V12.3756H21.4697V10.9373C21.4697 7.95816 19.0541 5.53844 16.0708 5.53844C13.0917 5.53844 10.672 7.95397 10.672 10.9373V12.3756H10.262V10.9373Z",
28
28
  fill: "#4D4D4D"
@@ -31,7 +31,7 @@ const PersonalManager32px = (props) => {
31
31
  /* @__PURE__ */ jsx(
32
32
  "path",
33
33
  {
34
- "fill-rule": "evenodd",
34
+ fillRule: "evenodd",
35
35
  clipRule: "evenodd",
36
36
  d: "M21.6725 23.3494L18.1099 21.8232L18.2713 21.4463L21.8342 22.9726C22.7063 23.3476 23.2998 24.1647 23.3962 25.0964H23.41V26.8718H9.58862V25.0964H9.60245C9.69881 24.1647 10.2921 23.3477 11.1642 22.9727L14.7273 21.4463L14.8888 21.8232L11.3262 23.3494C11.3261 23.3494 11.3262 23.3494 11.3262 23.3494C10.5217 23.6954 9.99864 24.4879 9.99864 25.3648V26.4617H23V25.3648C23 24.488 22.477 23.6954 21.6725 23.3494C21.6726 23.3494 21.6724 23.3494 21.6725 23.3494Z",
37
37
  fill: "#4D4D4D"
@@ -40,7 +40,7 @@ const PersonalManager32px = (props) => {
40
40
  /* @__PURE__ */ jsx(
41
41
  "path",
42
42
  {
43
- "fill-rule": "evenodd",
43
+ fillRule: "evenodd",
44
44
  clipRule: "evenodd",
45
45
  d: "M13.1572 8.49894C13.4332 8.38495 13.7126 8.33496 13.9195 8.33496C14.2567 8.33496 14.5856 8.43028 14.9034 8.56512C15.2191 8.69901 15.5369 8.87776 15.85 9.05389L15.8542 9.05627C16.6172 9.48657 17.4254 9.94046 18.3973 9.94046C18.874 9.94046 19.1914 9.81595 19.4295 9.64597C19.6743 9.47117 19.8469 9.24116 20.0274 8.99831C20.0949 8.90743 20.2233 8.88851 20.3142 8.95604C20.4051 9.02357 20.424 9.15199 20.3565 9.24287L20.3494 9.25241C20.1751 9.48702 19.9686 9.76482 19.6677 9.97967C19.356 10.2023 18.9542 10.3505 18.3973 10.3505C17.3141 10.3505 16.4233 9.84802 15.6783 9.42778C15.6699 9.42306 15.6615 9.41834 15.6532 9.41363C15.3343 9.23425 15.0355 9.06652 14.7433 8.94259C14.452 8.81901 14.1805 8.74498 13.9195 8.74498C13.77 8.74498 13.5436 8.78296 13.3137 8.87791C13.0848 8.97246 12.8669 9.11746 12.717 9.32069C12.5404 9.56493 12.4846 9.87771 12.5834 10.2766C12.6106 10.3865 12.5435 10.4976 12.4336 10.5248C12.3237 10.552 12.2126 10.485 12.1854 10.3751C12.0642 9.88573 12.1227 9.44214 12.3855 9.07947L12.3864 9.0782C12.5928 8.79791 12.8805 8.61322 13.1572 8.49894Z",
46
46
  fill: "#4D4D4D"
@@ -56,7 +56,7 @@ const PersonalManager32px = (props) => {
56
56
  /* @__PURE__ */ jsx(
57
57
  "path",
58
58
  {
59
- "fill-rule": "evenodd",
59
+ fillRule: "evenodd",
60
60
  clipRule: "evenodd",
61
61
  d: "M9.32483 12.1901C8.65291 12.2893 8.13281 12.8687 8.13281 13.5721V15.877C8.13281 16.6451 8.75633 17.274 9.52984 17.274H10.6762V12.1707H9.32483V12.1901ZM9.73485 12.5807V12.5851H9.52984C8.98718 12.5851 8.54283 13.026 8.54283 13.5721V15.877C8.54283 16.4196 8.98377 16.864 9.52984 16.864H10.2661V12.5807H9.73485Z",
62
62
  fill: "#4D4D4D"
@@ -72,7 +72,7 @@ const PersonalManager32px = (props) => {
72
72
  /* @__PURE__ */ jsx(
73
73
  "path",
74
74
  {
75
- "fill-rule": "evenodd",
75
+ fillRule: "evenodd",
76
76
  clipRule: "evenodd",
77
77
  d: "M22.8207 17.2501C23.4926 17.1509 24.0127 16.5715 24.0127 15.8681V13.5632C24.0127 12.7951 23.3892 12.1662 22.6156 12.1662H21.4693V17.2695H22.8207V17.2501ZM22.4106 16.8595V16.8551H22.6156C23.1583 16.8551 23.6027 16.4142 23.6027 15.8681V13.5632C23.6027 13.0206 23.1617 12.5762 22.6156 12.5762H21.8794V16.8595H22.4106Z",
78
78
  fill: "#4D4D4D"
@@ -88,7 +88,7 @@ const PersonalManager32px = (props) => {
88
88
  /* @__PURE__ */ jsx(
89
89
  "path",
90
90
  {
91
- "fill-rule": "evenodd",
91
+ fillRule: "evenodd",
92
92
  clipRule: "evenodd",
93
93
  d: "M16.49 19.6642C16.49 19.1551 16.9029 18.7422 17.412 18.7422H18.1861C18.6952 18.7422 19.1081 19.1551 19.1081 19.6642C19.1081 20.1733 18.6952 20.5862 18.1861 20.5862H17.412C16.9029 20.5862 16.49 20.1733 16.49 19.6642ZM17.412 19.1522C17.1293 19.1522 16.9 19.3815 16.9 19.6642C16.9 19.9468 17.1293 20.1761 17.412 20.1761H18.1861C18.4688 20.1761 18.6981 19.9468 18.6981 19.6642C18.6981 19.3815 18.4688 19.1522 18.1861 19.1522H17.412Z",
94
94
  fill: "#4D4D4D"
@@ -97,7 +97,7 @@ const PersonalManager32px = (props) => {
97
97
  /* @__PURE__ */ jsx(
98
98
  "path",
99
99
  {
100
- "fill-rule": "evenodd",
100
+ fillRule: "evenodd",
101
101
  clipRule: "evenodd",
102
102
  d: "M21.884 16.7214V17.2845C21.884 18.7305 20.7146 19.8999 19.2686 19.8999H18.7056V19.4899H19.2686C20.4881 19.4899 21.474 18.504 21.474 17.2845V16.7214H21.884Z",
103
103
  fill: "#4D4D4D"
package/dist/index.js CHANGED
@@ -43,6 +43,8 @@ import { NotificationBadge } from "./components/NotificationBadge/NotificationBa
43
43
  import { ENotificationBadgeSize } from "./components/NotificationBadge/constants.js";
44
44
  import { Chip } from "./components/Chip/Chip.js";
45
45
  import { EChipSize, EChipVariant } from "./components/Chip/constants.js";
46
+ import { UniversalUploader } from "./components/UniversalUploader/UniversalUploader.js";
47
+ import { EUploaderType } from "./components/UniversalUploader/constants.js";
46
48
  import { useMediaQuery } from "./hooks/useMediaQuery/useMediaQuery.js";
47
49
  import { EMediaQuery, EMinMediaQuery } from "./hooks/useMediaQuery/constants.js";
48
50
  import { useLockBodyScroll } from "./hooks/useLockBodyScroll/useLockBodyScroll.js";
@@ -88,6 +90,7 @@ import './assets/index.css';export {
88
90
  ETagType,
89
91
  EToastPosition,
90
92
  EToastVariant,
93
+ EUploaderType,
91
94
  EVoteSize,
92
95
  Icon,
93
96
  AppImage as Image,
@@ -109,6 +112,7 @@ import './assets/index.css';export {
109
112
  TextArea,
110
113
  Timer,
111
114
  ToastProvider,
115
+ UniversalUploader,
112
116
  Uploader,
113
117
  UploaderPhotos,
114
118
  Vote,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.27.7",
4
+ "version": "1.28.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {