mimir-ui-kit 1.15.1 → 1.16.0

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.
Files changed (60) hide show
  1. package/dist/Input-BFFPzelg.js +228 -0
  2. package/dist/{ProgressBar-BekX41HR.js → ProgressBar-CwLwhaeM.js} +23 -23
  3. package/dist/assets/Input.css +1 -1
  4. package/dist/assets/ListPhotos.css +1 -1
  5. package/dist/assets/OtpInput.css +1 -1
  6. package/dist/assets/ProgressBar2.css +1 -1
  7. package/dist/assets/SelectSearch.css +1 -1
  8. package/dist/assets/TextArea.css +1 -0
  9. package/dist/assets/UploaderPhotos.css +1 -1
  10. package/dist/assets/index.css +1 -1
  11. package/dist/components/DatePicker/DatePicker.d.ts +1 -9
  12. package/dist/components/DatePicker/DatePicker.js +1 -1
  13. package/dist/components/Input/Input.d.ts +11 -27
  14. package/dist/components/Input/Input.js +9 -120
  15. package/dist/components/Input/index.d.ts +1 -1
  16. package/dist/components/Input/index.js +2 -2
  17. package/dist/components/Input/types.d.ts +11 -0
  18. package/dist/components/InputPassword/InputPassword.d.ts +1 -9
  19. package/dist/components/InputPassword/InputPassword.js +1 -1
  20. package/dist/components/InputPhoneNumber/InputPhoneNumber.d.ts +1 -9
  21. package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
  22. package/dist/components/ListPhotos/ListPhotos.js +1 -1
  23. package/dist/components/OtpInput/OtpInput.js +5 -5
  24. package/dist/components/SelectSearch/SelectSearch.d.ts +0 -7
  25. package/dist/components/SelectSearch/SelectSearch.js +3802 -640
  26. package/dist/components/SelectSearch/index.d.ts +1 -1
  27. package/dist/components/SelectSearch/types.d.ts +16 -11
  28. package/dist/components/TextArea/TextArea.d.ts +5 -0
  29. package/dist/components/TextArea/TextArea.js +209 -0
  30. package/dist/components/TextArea/hooks.d.ts +1 -0
  31. package/dist/components/TextArea/hooks.js +13 -0
  32. package/dist/components/TextArea/index.d.ts +1 -0
  33. package/dist/components/TextArea/index.js +4 -0
  34. package/dist/components/TextArea/types.d.ts +3 -0
  35. package/dist/components/TextArea/types.js +1 -0
  36. package/dist/components/Toasts/ProgressBar.js +1 -1
  37. package/dist/components/Toasts/Toast.js +1 -1
  38. package/dist/components/Toasts/ToastList.js +1 -1
  39. package/dist/components/Toasts/ToastsProvider.js +1 -1
  40. package/dist/components/Uploader/Uploader.d.ts +10 -1
  41. package/dist/components/Uploader/Uploader.js +62 -56
  42. package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +10 -1
  43. package/dist/components/UploaderPhotos/UploaderPhotos.js +50 -34
  44. package/dist/components/index.d.ts +3 -3
  45. package/dist/components/index.js +4 -4
  46. package/dist/hooks/index.d.ts +1 -0
  47. package/dist/hooks/index.js +2 -0
  48. package/dist/hooks/useMergeRefs/index.d.ts +1 -0
  49. package/dist/hooks/useMergeRefs/index.js +4 -0
  50. package/dist/hooks/useMergeRefs/useMergeRefs.d.ts +4 -0
  51. package/dist/hooks/useMergeRefs/useMergeRefs.js +28 -0
  52. package/dist/icons/components/12px/Close12px.js +1 -1
  53. package/dist/index.js +6 -4
  54. package/package.json +2 -3
  55. package/dist/SelectSearchOption-snHM9uZX.js +0 -3796
  56. package/dist/assets/SelectSearchOption.css +0 -1
  57. package/dist/components/SelectSearchOption/SelectSearchOption.d.ts +0 -10
  58. package/dist/components/SelectSearchOption/SelectSearchOption.js +0 -8
  59. package/dist/components/SelectSearchOption/index.d.ts +0 -2
  60. 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
  };
@@ -0,0 +1,5 @@
1
+ import { TTextAreaProps } from './types';
2
+ import { TAdditionalProps } from '../Input';
3
+
4
+ export type TProps = TAdditionalProps & TTextAreaProps;
5
+ export declare const TextArea: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<TAdditionalProps & TTextAreaProps & import('react').RefAttributes<HTMLTextAreaElement>>>;
@@ -0,0 +1,209 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { memo, forwardRef, useState, useRef, useEffect } from "react";
4
+ import { useAutoResizeTextArea } from "./hooks.js";
5
+ import { useMergeRefs } from "../../hooks/useMergeRefs/useMergeRefs.js";
6
+ import { Icon } from "../../icons/Icon.js";
7
+ import { Button } from "../Button/Button.js";
8
+ import { c as cls } from "../../Input-BFFPzelg.js";
9
+ import { EInputVariant } from "../Input/constants.js";
10
+ import '../../assets/TextArea.css';const textarea = "_textarea_46c4k_2";
11
+ const s = "_s_46c4k_6";
12
+ const m = "_m_46c4k_11";
13
+ const l = "_l_46c4k_16";
14
+ const textareaCls = {
15
+ textarea,
16
+ s,
17
+ m,
18
+ l,
19
+ "has-label": "_has-label_46c4k_21"
20
+ };
21
+ const renderAddon = (addon) => {
22
+ var _a, _b;
23
+ if (!addon) {
24
+ return null;
25
+ }
26
+ switch (addon.addonType) {
27
+ case "icon": {
28
+ const is16px = (_a = addon.addonContent) == null ? void 0 : _a.includes("16px");
29
+ const is24px = (_b = addon.addonContent) == null ? void 0 : _b.includes("24px");
30
+ return /* @__PURE__ */ jsx(
31
+ Icon,
32
+ {
33
+ style: {
34
+ ["--icon-size"]: classNames({
35
+ "16px": is16px,
36
+ "24px": is24px
37
+ })
38
+ },
39
+ className: cls["addon-icon"],
40
+ iconName: addon.addonContent
41
+ }
42
+ );
43
+ }
44
+ case "text": {
45
+ return addon.addonContent;
46
+ }
47
+ default: {
48
+ return null;
49
+ }
50
+ }
51
+ };
52
+ const TextArea = memo(
53
+ forwardRef(
54
+ (props, ref) => {
55
+ const {
56
+ value,
57
+ className,
58
+ wrapperClassName,
59
+ variant = EInputVariant.DefaultGray,
60
+ autofocus,
61
+ readonly,
62
+ id,
63
+ onFocus,
64
+ onBlur,
65
+ label,
66
+ withClearButton,
67
+ disabled,
68
+ rightAddon,
69
+ leftAddon,
70
+ size = "m",
71
+ ...otherProps
72
+ } = props;
73
+ const [isFocused, setIsFocused] = useState(autofocus);
74
+ const [withValue, setWithValue] = useState(!!value);
75
+ const inputRef = useRef(null);
76
+ const mergedInputRef = useMergeRefs(inputRef, ref);
77
+ useEffect(() => {
78
+ if (autofocus) {
79
+ setIsFocused(true);
80
+ }
81
+ }, [autofocus]);
82
+ const handleResize = useAutoResizeTextArea(inputRef.current);
83
+ const handleBlur = (event) => {
84
+ const currentValue = event.currentTarget.value;
85
+ onBlur == null ? void 0 : onBlur(event);
86
+ if (currentValue) {
87
+ return;
88
+ }
89
+ setIsFocused(false);
90
+ };
91
+ const handleFocus = (event) => {
92
+ if (readonly) {
93
+ return;
94
+ }
95
+ setIsFocused(true);
96
+ onFocus == null ? void 0 : onFocus(event);
97
+ };
98
+ const handleClear = () => {
99
+ if (inputRef == null ? void 0 : inputRef.current) {
100
+ inputRef.current.value = "";
101
+ inputRef.current.focus();
102
+ setWithValue(false);
103
+ handleResize();
104
+ }
105
+ };
106
+ const handleChange = (event) => {
107
+ var _a;
108
+ const targetValue = event.target.value;
109
+ setWithValue(!!targetValue);
110
+ handleResize();
111
+ (_a = otherProps == null ? void 0 : otherProps.onChange) == null ? void 0 : _a.call(otherProps, event);
112
+ };
113
+ const currentLeftAddon = renderAddon(leftAddon);
114
+ const currentRightAddon = renderAddon(rightAddon);
115
+ const mods = {
116
+ [cls.readonly]: disabled || readonly,
117
+ [cls.focused]: isFocused || withValue,
118
+ [cls.disabled]: disabled || readonly,
119
+ [cls["has-left-slot"]]: !!currentLeftAddon,
120
+ [cls["has-right-slot"]]: !!currentRightAddon,
121
+ [textareaCls["has-label"]]: !!label
122
+ };
123
+ const labelClassNames = classNames(
124
+ cls.label,
125
+ {
126
+ [cls["active-label"]]: isFocused || value,
127
+ [cls.disabled]: disabled || readonly,
128
+ [cls["has-left-slot"]]: !!currentLeftAddon
129
+ },
130
+ className,
131
+ cls[size]
132
+ );
133
+ const inputClassNames = classNames(
134
+ textareaCls.textarea,
135
+ cls.input,
136
+ mods,
137
+ className,
138
+ [cls[variant], textareaCls[size], cls[size]]
139
+ );
140
+ return /* @__PURE__ */ jsxs(
141
+ "div",
142
+ {
143
+ className: classNames(
144
+ cls["input-wrapper"],
145
+ cls[variant],
146
+ textareaCls[size],
147
+ cls[size],
148
+ { [cls.focused]: isFocused || withValue },
149
+ wrapperClassName
150
+ ),
151
+ children: [
152
+ label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: labelClassNames, children: label }),
153
+ currentLeftAddon && /* @__PURE__ */ jsx(
154
+ "span",
155
+ {
156
+ className: classNames(cls["left-slot"], {
157
+ [cls.focused]: isFocused,
158
+ [cls["has-label"]]: !!label
159
+ }),
160
+ children: currentLeftAddon
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsx(
164
+ "textarea",
165
+ {
166
+ ref: mergedInputRef,
167
+ id,
168
+ className: inputClassNames,
169
+ onFocus: handleFocus,
170
+ onBlur: handleBlur,
171
+ readOnly: readonly,
172
+ value,
173
+ onChange: handleChange,
174
+ ...otherProps
175
+ }
176
+ ),
177
+ currentRightAddon && /* @__PURE__ */ jsx(
178
+ "span",
179
+ {
180
+ className: classNames(cls["right-slot"], {
181
+ [cls.focused]: isFocused,
182
+ [cls["has-label"]]: !!label
183
+ }),
184
+ children: currentRightAddon
185
+ }
186
+ ),
187
+ withClearButton && withValue && /* @__PURE__ */ jsx(
188
+ Button,
189
+ {
190
+ tabIndex: -1,
191
+ className: cls.clear,
192
+ isIconButton: true,
193
+ iconName: "Close16px",
194
+ size: "m-s",
195
+ clear: true,
196
+ variant: "secondary-gray",
197
+ onClick: handleClear
198
+ }
199
+ )
200
+ ]
201
+ }
202
+ );
203
+ }
204
+ )
205
+ );
206
+ TextArea.displayName = "TextArea";
207
+ export {
208
+ TextArea
209
+ };
@@ -0,0 +1 @@
1
+ export declare const useAutoResizeTextArea: (textArea: HTMLTextAreaElement | null) => () => void;
@@ -0,0 +1,13 @@
1
+ import { useCallback } from "react";
2
+ const useAutoResizeTextArea = (textArea) => {
3
+ return useCallback(() => {
4
+ if (textArea) {
5
+ textArea.style.height = "var(--textarea-height)";
6
+ const scrollHeight = textArea.scrollHeight;
7
+ textArea.style.height = `${scrollHeight}px`;
8
+ }
9
+ }, [textArea]);
10
+ };
11
+ export {
12
+ useAutoResizeTextArea
13
+ };
@@ -0,0 +1 @@
1
+ export { TextArea, type TProps as TTextAreaProps } from './TextArea';
@@ -0,0 +1,4 @@
1
+ import { TextArea } from "./TextArea.js";
2
+ export {
3
+ TextArea
4
+ };
@@ -0,0 +1,3 @@
1
+ import { TextareaHTMLAttributes } from 'react';
2
+
3
+ export type TTextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'readOnly' | 'size' | 'placeholder'>;
@@ -0,0 +1 @@
1
+
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
2
2
  import "../../index-CweZ_OcN.js";
3
3
  import "react";
4
4
  import "./constants.js";
5
- import { P } from "../../ProgressBar-BekX41HR.js";
5
+ import { P } from "../../ProgressBar-CwLwhaeM.js";
6
6
  export {
7
7
  P as ProgressBar
8
8
  };
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
3
  import { memo, useRef } from "react";
4
4
  import { ANIMATION_VARIABLES_MAP, EToastPosition, EToastVariant, DEFAULT_TOAST_DURATION } from "./constants.js";
5
- import { c as cls, P as ProgressBar } from "../../ProgressBar-BekX41HR.js";
5
+ import { c as cls, P as ProgressBar } from "../../ProgressBar-CwLwhaeM.js";
6
6
  import { useTimer } from "../../hooks/useTimer/index.js";
7
7
  import { Button } from "../Button/Button.js";
8
8
  const Toast = memo(
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
3
  import { memo, useRef, useCallback, useEffect } from "react";
4
4
  import { EToastPosition } from "./constants.js";
5
- import { c as cls } from "../../ProgressBar-BekX41HR.js";
5
+ import { c as cls } from "../../ProgressBar-CwLwhaeM.js";
6
6
  import { Toast } from "./Toast.js";
7
7
  const ToastList = memo(
8
8
  ({ toasts, position = EToastPosition.TOP_RIGHT, onToastRemove }) => {
@@ -3,7 +3,7 @@ import { useReducer, useCallback, useMemo } from "react";
3
3
  import { EToastVariant } from "./constants.js";
4
4
  import { ToastContext } from "./hooks.js";
5
5
  import { reducer, initialState, actionCreators } from "./store.js";
6
- import { c as cls } from "../../ProgressBar-BekX41HR.js";
6
+ import { c as cls } from "../../ProgressBar-CwLwhaeM.js";
7
7
  import { ToastList } from "./ToastList.js";
8
8
  const ToastProvider = ({ children }) => {
9
9
  const [toasts, dispatch] = useReducer(reducer, initialState);
@@ -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
  };
@@ -1,6 +1,8 @@
1
1
  export { Button, EButtonForm, EButtonSize, EButtonVariantDefault, EButtonVariantRound, EButtonVariantOutline, type TButtonProps } from './Button';
2
2
  export { Input, EInputSize, EInputVariant } from './Input';
3
3
  export type { TInputProps, TSize, TVariant } from './Input';
4
+ export { TextArea } from './TextArea';
5
+ export type { TTextAreaProps } from './TextArea';
4
6
  export { InputPassword } from './InputPassword';
5
7
  export type { TInputPasswordProps } from './InputPassword';
6
8
  export { InputPhoneNumber, getMaskedInputPhoneValue, getUnmaskedInputValue } from './InputPhoneNumber';
@@ -20,9 +22,7 @@ export { EDrawerPosition } from './Drawer';
20
22
  export { Steps, EStepsPrimaryColor, EStepsSecondaryColor, EStepsSize, type TCommonStepsProps } from './Steps';
21
23
  export { Vote, EVoteSize, type TCommonVoteProps } from './Vote';
22
24
  export { SelectSearch, ESelectSearchSize } from './SelectSearch';
23
- export type { TSelectSearchProps } from './SelectSearch';
24
- export { SelectSearchOption } from './SelectSearchOption';
25
- export type { SelectSearchOptionProps } from './SelectSearchOption';
25
+ export type { TSelectSearchProps, TSelectOption } from './SelectSearch';
26
26
  export { Switch } from './Switch';
27
27
  export type { TSwitchProps } from './Switch';
28
28
  export { Tag, ETagSize, ETagType } from './Tag';