mimir-ui-kit 1.15.1 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/assets/ListPhotos.css +1 -1
- package/dist/assets/SelectSearch.css +1 -1
- package/dist/assets/UploaderPhotos.css +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/components/ListPhotos/ListPhotos.js +1 -1
- package/dist/components/SelectSearch/SelectSearch.d.ts +0 -7
- package/dist/components/SelectSearch/SelectSearch.js +3801 -639
- package/dist/components/SelectSearch/index.d.ts +1 -1
- package/dist/components/SelectSearch/types.d.ts +16 -11
- package/dist/components/Uploader/Uploader.d.ts +10 -1
- package/dist/components/Uploader/Uploader.js +62 -56
- package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +10 -1
- package/dist/components/UploaderPhotos/UploaderPhotos.js +50 -34
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.js +0 -2
- package/dist/index.js +0 -2
- package/package.json +1 -1
- package/dist/SelectSearchOption-snHM9uZX.js +0 -3796
- package/dist/assets/SelectSearchOption.css +0 -1
- package/dist/components/SelectSearchOption/SelectSearchOption.d.ts +0 -10
- package/dist/components/SelectSearchOption/SelectSearchOption.js +0 -8
- package/dist/components/SelectSearchOption/index.d.ts +0 -2
- package/dist/components/SelectSearchOption/index.js +0 -4
@@ -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?:
|
14
|
+
value?: TSelectOption | null;
|
9
15
|
/**
|
10
16
|
* Функция обратного вызова при изменении выбранного значения.
|
11
17
|
*/
|
12
|
-
onChange?: (value:
|
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
|
};
|
@@ -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
|
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 {
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
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
|
-
|
56
|
+
"input",
|
69
57
|
{
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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__ */
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
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 {
|
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-
|
7
|
+
"upload-file__wrapper": "_upload-file__wrapper_17bcu_2"
|
7
8
|
};
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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';
|
package/dist/components/index.js
CHANGED
@@ -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,
|
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";
|
@@ -84,7 +83,6 @@ import './assets/index.css';export {
|
|
84
83
|
Pagination,
|
85
84
|
RadioGroup,
|
86
85
|
SelectSearch,
|
87
|
-
S as SelectSearchOption,
|
88
86
|
Slider,
|
89
87
|
Steps,
|
90
88
|
Switch,
|