kamotive_ui 1.2.17 → 1.2.20

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.
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ export declare const IconEmail: FC<{
3
+ color?: string;
4
+ htmlColor?: string;
5
+ strokeWidth?: string;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const IconEmail = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
3
+ return (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color },
4
+ React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', d: "M5,5H18C19.66,5 21,6.34 21,8V17C21,18.66 19.66,20 18,20H5C3.34,20 2,18.66 2,17V8C2,6.34 3.34,5 5,5M5,6C4.5,6 4.06,6.17 3.72,6.47L11.5,11.5L19.28,6.47C18.94,6.17 18.5,6 18,6H5M11.5,12.71L3.13,7.28C3.05,7.5 3,7.75 3,8V17C3,18.1 3.9,19 5,19H18C19.1,19 20,18.1 20,17V8C20,7.75 19.95,7.5 19.87,7.28L11.5,12.71Z" })));
5
+ };
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ export declare const IconEye10: FC<{
3
+ color?: string;
4
+ htmlColor?: string;
5
+ strokeWidth?: string;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const IconEye10 = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
3
+ return (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color },
4
+ React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', d: "M11.5,18C15.5,18 18.96,15.78 20.74,12.5C18.96,9.22 15.5,7 11.5,7C7.5,7 4.04,9.22 2.26,12.5C4.04,15.78 7.5,18 11.5,18M11.5,6C16.06,6 20,8.65 21.86,12.5C20,16.35 16.06,19 11.5,19C6.94,19 3,16.35 1.14,12.5C3,8.65 6.94,6 11.5,6M11.5,8C14,8 16,10 16,12.5C16,15 14,17 11.5,17C9,17 7,15 7,12.5C7,10 9,8 11.5,8M11.5,9C9.57,9 8,10.57 8,12.5C8,14.43 9.57,16 11.5,16C13.43,16 15,14.43 15,12.5C15,10.57 13.43,9 11.5,9Z" })));
5
+ };
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ export declare const IconLocation: FC<{
3
+ color?: string;
4
+ htmlColor?: string;
5
+ strokeWidth?: string;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const IconLocation = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
3
+ return (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color },
4
+ React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', d: "M11.5,7C12.88,7 14,8.12 14,9.5C14,10.88 12.88,12 11.5,12C10.12,12 9,10.88 9,9.5C9,8.12 10.12,7 11.5,7M11.5,8C10.67,8 10,8.67 10,9.5C10,10.33 10.67,11 11.5,11C12.33,11 13,10.33 13,9.5C13,8.67 12.33,8 11.5,8M6.8,12.36L11.5,20.09L16.2,12.36V12.36C16.71,11.5 17,10.55 17,9.5C17,6.46 14.54,4 11.5,4C8.46,4 6,6.46 6,9.5C6,10.55 6.29,11.5 6.8,12.36V12.36M17.05,12.88L11.5,22L5.95,12.88V12.88C5.35,11.89 5,10.74 5,9.5C5,5.91 7.91,3 11.5,3C15.09,3 18,5.91 18,9.5C18,10.74 17.65,11.89 17.05,12.88V12.88Z" })));
5
+ };
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ export declare const IconPencil: FC<{
3
+ color?: string;
4
+ htmlColor?: string;
5
+ strokeWidth?: string;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const IconPencil = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
3
+ return (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color },
4
+ React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', d: "M19.71,8.04L17.37,10.37L13.62,6.62L15.96,4.29C16.35,3.9 17,3.9 17.37,4.29L19.71,6.63C20.1,7 20.1,7.65 19.71,8.04M3,17.25L13.06,7.18L16.81,10.93L6.75,21H3V17.25M16.62,5.04L15.08,6.58L17.42,8.92L18.96,7.38L16.62,5.04M15.36,11L13,8.64L4,17.66V20H6.34L15.36,11Z" })));
5
+ };
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ export declare const IconPhone: FC<{
3
+ color?: string;
4
+ htmlColor?: string;
5
+ strokeWidth?: string;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const IconPhone = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
3
+ return (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color },
4
+ React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', d: "M19.5,22C20.33,22 21,21.33 21,20.5V17C21,16.17 20.33,15.5 19.5,15.5C18.33,15.5 17.18,15.32 16.08,14.95C15.55,14.78 14.97,14.92 14.56,15.32L13.12,16.76C10.64,15.41 8.57,13.34 7.23,10.87L8.66,9.44C9.07,9.05 9.22,8.47 9.04,7.91C8.68,6.82 8.5,5.67 8.5,4.5C8.5,3.67 7.83,3 7,3H3.5C2.67,3 2,3.67 2,4.5C2,14.15 9.85,22 19.5,22M3.5,4H7C7.28,4 7.5,4.22 7.5,4.5C7.5,5.78 7.7,7.03 8.09,8.22C8.14,8.36 8.13,8.56 7.97,8.72L6,10.68C7.65,13.91 10.07,16.33 13.31,18L15.26,16.03C15.4,15.89 15.59,15.85 15.77,15.9C16.97,16.3 18.22,16.5 19.5,16.5C19.78,16.5 20,16.72 20,17V20.5C20,20.78 19.78,21 19.5,21C10.4,21 3,13.6 3,4.5C3,4.22 3.22,4 3.5,4Z" })));
5
+ };
@@ -20,3 +20,8 @@ export { IconFile } from './IconFile/IconFile';
20
20
  export { IconUpload } from './IconUpload/IconUpload';
21
21
  export { IconDownload } from './IconDownload/IconDownload';
22
22
  export { IconAdd } from './IconAdd/IconAdd';
23
+ export { IconPhone } from './IconPhone/IconPhone';
24
+ export { IconLocation } from './IconLocation/IconLocation';
25
+ export { IconEmail } from './IconEmail/IconEmail';
26
+ export { IconEye10 } from './IconEye/IconEye10';
27
+ export { IconPencil } from './IconPencil/IconPencil';
@@ -20,3 +20,8 @@ export { IconFile } from './IconFile/IconFile';
20
20
  export { IconUpload } from './IconUpload/IconUpload';
21
21
  export { IconDownload } from './IconDownload/IconDownload';
22
22
  export { IconAdd } from './IconAdd/IconAdd';
23
+ export { IconPhone } from './IconPhone/IconPhone';
24
+ export { IconLocation } from './IconLocation/IconLocation';
25
+ export { IconEmail } from './IconEmail/IconEmail';
26
+ export { IconEye10 } from './IconEye/IconEye10';
27
+ export { IconPencil } from './IconPencil/IconPencil';
@@ -7,11 +7,11 @@ export const FileAttach = ({ filesList = [], maxFileSize = 2, maxFileCount = 10,
7
7
  'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
8
8
  'application/pdf': ['.pdf'],
9
9
  'application/msword': ['.doc', '.docx'],
10
- }, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, }) => {
10
+ }, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, fileValidator, }) => {
11
11
  const fileAttachClasses = classNames(styles['fileAttach'], className, {
12
12
  [styles[`fileAttach_position_${position}`]]: position,
13
13
  });
14
14
  return (React.createElement("div", { className: fileAttachClasses, style: style },
15
- React.createElement(FileLoader, { maxFileSize: maxFileSize, maxFileCount: maxFileCount, acceptedFormats: acceptedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, canAdd: canAdd, lng: lng }),
15
+ React.createElement(FileLoader, { maxFileSize: maxFileSize, maxFileCount: maxFileCount, acceptedFormats: acceptedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, filesList: filesList, canAdd: canAdd, lng: lng, fileValidator: fileValidator }),
16
16
  React.createElement(FileListAttaсhed, { filesList: filesList, onDelete: onDelete, onDownload: onDownload, canDelete: canDelete, canDownload: canDownload, lng: lng })));
17
17
  };
@@ -9,12 +9,12 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
9
9
  'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
10
10
  'application/pdf': ['.pdf'],
11
11
  'application/msword': ['.doc', '.docx'],
12
- }, addedFiles, setAddedFiles, canAdd = true, lng = 'ru', className, style, }) => {
12
+ }, addedFiles, setAddedFiles, filesList = [], canAdd = true, lng = 'ru', className, style, fileValidator }) => {
13
13
  const [isLoadingFiles, setIsLoadingFiles] = useState(false);
14
14
  const [loadingFilesNames, setLoadingFilesNames] = useState([]);
15
15
  const [errorFiles, setErrorFiles] = useState([]);
16
16
  const [addedFilesFormated, setAddedFilesFormatted] = useState([]);
17
- const fileValidator = (file) => {
17
+ const fileValidatorInner = (file) => {
18
18
  if (file.size > maxFileSize * 1024 * 1024 * 1024) {
19
19
  return {
20
20
  code: 'name-too-large',
@@ -23,6 +23,14 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
23
23
  : `Maximum file size ${maxFileSize.toFixed(0)} GB`,
24
24
  };
25
25
  }
26
+ // Проверка на дубликаты в filesList
27
+ if (filesList.find((existingFile) => existingFile.filename === file.name)) {
28
+ return {
29
+ code: 'repeating-file-name',
30
+ message: lng === 'ru' || lng.includes('ru') ? `Файл уже существует в списке прикрепленных файлов` : `File already exists in the list of attached files`,
31
+ };
32
+ }
33
+ // Проверка на дубликаты в addedFiles
26
34
  if (addedFiles.find((addedFile) => addedFile.name === file.name)) {
27
35
  return {
28
36
  code: 'repeating-file-name',
@@ -35,6 +43,12 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
35
43
  message: lng === 'ru' || lng.includes('ru') ? `Максимальное количество файлов ${maxFileCount}` : `Maximum number of files ${maxFileCount}`,
36
44
  };
37
45
  }
46
+ if (fileValidator) {
47
+ const customValidationResult = fileValidator(file);
48
+ if (customValidationResult) {
49
+ return customValidationResult;
50
+ }
51
+ }
38
52
  return null;
39
53
  };
40
54
  const { getRootProps, getInputProps } = useDropzone({
@@ -98,7 +112,7 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
98
112
  setErrorFiles([...errorFiles, ...formattedRejections]);
99
113
  }
100
114
  },
101
- validator: fileValidator,
115
+ validator: fileValidatorInner,
102
116
  accept: acceptedFormats,
103
117
  maxFiles: maxFileCount,
104
118
  disabled: !canAdd,
@@ -127,6 +141,11 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
127
141
  }
128
142
  return formats.join(', ');
129
143
  };
144
+ useEffect(() => {
145
+ if (addedFiles.length === 0) {
146
+ setAddedFilesFormatted([]);
147
+ }
148
+ }, [addedFiles]);
130
149
  useEffect(() => {
131
150
  if (loadingFilesNames.length === 0 && isLoadingFiles) {
132
151
  setIsLoadingFiles(false);
@@ -19,7 +19,6 @@
19
19
  border: 1px dashed var(--blue-main);
20
20
  border-radius: 15px;
21
21
  cursor: pointer;
22
- margin-right: 10px;
23
22
  }
24
23
 
25
24
  .dropzone:hover {
@@ -40,7 +39,7 @@
40
39
  flex: 1;
41
40
  max-height: 100%;
42
41
  overflow-y: auto;
43
- padding-right: 10px;
42
+ /* padding-right: 10px; */
44
43
  margin-top: 10px;
45
44
  }
46
45
  /* Стилизация скроллбара для WebKit (Chrome, Safari, новые версии Edge) */
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { ChangeEventHandler, CSSProperties, ReactNode } from 'react';
3
3
  import { ETypographyVariants } from '../components/Typography/enums';
4
- import { Accept } from 'react-dropzone/.';
4
+ import { Accept, FileError } from 'react-dropzone/.';
5
5
  /** @internal */
6
6
  export interface BreadcrumbProps {
7
7
  /** Обработчик клика */
@@ -396,6 +396,8 @@ export interface FileAttachProps {
396
396
  className?: string;
397
397
  /** Стили передаваемые напрямую */
398
398
  style?: React.CSSProperties;
399
+ /** Функция валидации файла */
400
+ fileValidator?: (file: File) => FileError | FileError[] | null;
399
401
  }
400
402
  export interface FileListAttaсhedProps {
401
403
  /** Список прикрепленных файлов */
@@ -452,12 +454,16 @@ export interface FileLoaderProps {
452
454
  setAddedFiles: (addedFiles: File[]) => void;
453
455
  /**Разрешени на добавление файлов*/
454
456
  canAdd?: boolean;
457
+ /** Список прикрепленных файлов */
458
+ filesList?: TAttachments[] | [] | undefined;
455
459
  /** Язык */
456
460
  lng?: string;
457
461
  /** Дополнительный класс */
458
462
  className?: string;
459
463
  /** Стили передаваемые напрямую */
460
464
  style?: React.CSSProperties;
465
+ /** Функция валидации файла */
466
+ fileValidator?: (file: File) => FileError | FileError[] | null;
461
467
  }
462
468
  export interface DialogProps {
463
469
  /** Флаг открытия окна */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kamotive_ui",
3
- "version": "1.2.17",
3
+ "version": "1.2.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [