kamotive_ui 1.2.29 → 1.12.25
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.
- package/dist/Icons/IconAttach/IconAttach.js +1 -1
- package/dist/Icons/IconExpand/IconExpand.d.ts +7 -0
- package/dist/Icons/IconExpand/IconExpand.js +5 -0
- package/dist/Icons/IconFilter/IconFilter.d.ts +7 -0
- package/dist/Icons/IconFilter/IconFilter.js +5 -0
- package/dist/Icons/IconSearch/IconSearch.d.ts +7 -0
- package/dist/Icons/IconSearch/IconSearch.js +7 -0
- package/dist/Icons/index.d.ts +2 -0
- package/dist/Icons/index.js +2 -0
- package/dist/components/AttachedFilesPreview/AttachedFilesPreview.d.ts +3 -1
- package/dist/components/AttachedFilesPreview/AttachedFilesPreview.js +9 -6
- package/dist/components/Comment/Comment.js +5 -5
- package/dist/components/Comment/Comment.module.css +1 -1
- package/dist/components/Dropdown/Dropdown.js +14 -8
- package/dist/components/Dropdown/Dropdown.module.css +13 -0
- package/dist/components/FileItem/FileItem.js +2 -2
- package/dist/components/FileListAttached/FileListAtta/321/201hed.js +1 -1
- package/dist/components/FileLoader/FileLoader.d.ts +3 -3
- package/dist/components/FileLoader/FileLoader.js +42 -13
- package/dist/components/IconButton/IconButton.module.css +1 -0
- package/dist/components/TextEditor/TextEditor.js +3 -2
- package/dist/types/index.d.ts +16 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export const IconAttach = ({ color = 'inherit', htmlColor, strokeWidth, onClick, style }) => {
|
|
3
3
|
return (React.createElement("svg", { width: "11", height: "13", viewBox: "0 0 11 13", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: color, onClick: onClick, style: style },
|
|
4
|
-
React.createElement("path", { d: "M6.37877 4.15256L2.88551 7.64632C2.63416 7.9059 2.49642 8.25544 2.50202 8.61952C2.50761 8.9836 2.65609 9.33302 2.91541 9.59238C3.17473 9.85173 3.5241 10.0002 3.88813 10.0058C4.25215 10.0114 4.60165 9.87367 4.86118 9.62229L9.44315 5.04607C9.66417 4.83039 9.83953 4.57234 9.95906 4.28687C10.0786 4.0014 10.1399 3.6942 10.1395 3.38306C10.139 3.07192 10.0768 2.76304 9.95651 2.47432C9.83618 2.1856 9.66009 1.92279 9.43845 1.70113C9.21682 1.47946 8.95405 1.30335 8.66537 1.18299C8.3767 1.06264 8.06786 1.00044 7.75676 1C7.44567 0.999565 7.13851 1.0609 6.85308 1.18044C6.56765 1.29999 6.30964 1.47537 6.094 1.69642L1.48439 6.30669C1.1725 6.6096 0.924855 6.9724 0.755862 7.374C0.58687 7.7756 0.499896 8.208 0.5 8.64604C0.500104 9.08408 0.587283 9.51903 0.756467 9.92561C0.925651 10.3322 1.17347 10.7023 1.4855 11.0144C1.79754 11.3264 2.16757 11.5743 2.57409 11.7435C2.98061 11.9127 3.4155 11.9999 3.85348 12C4.29146 12.0001 4.72379 11.9131 5.12533 11.7441C5.52688 11.5751 5.88963 11.3274 6.19249 11.0155L10.5 6.70734", stroke: htmlColor || "#
|
|
4
|
+
React.createElement("path", { d: "M6.37877 4.15256L2.88551 7.64632C2.63416 7.9059 2.49642 8.25544 2.50202 8.61952C2.50761 8.9836 2.65609 9.33302 2.91541 9.59238C3.17473 9.85173 3.5241 10.0002 3.88813 10.0058C4.25215 10.0114 4.60165 9.87367 4.86118 9.62229L9.44315 5.04607C9.66417 4.83039 9.83953 4.57234 9.95906 4.28687C10.0786 4.0014 10.1399 3.6942 10.1395 3.38306C10.139 3.07192 10.0768 2.76304 9.95651 2.47432C9.83618 2.1856 9.66009 1.92279 9.43845 1.70113C9.21682 1.47946 8.95405 1.30335 8.66537 1.18299C8.3767 1.06264 8.06786 1.00044 7.75676 1C7.44567 0.999565 7.13851 1.0609 6.85308 1.18044C6.56765 1.29999 6.30964 1.47537 6.094 1.69642L1.48439 6.30669C1.1725 6.6096 0.924855 6.9724 0.755862 7.374C0.58687 7.7756 0.499896 8.208 0.5 8.64604C0.500104 9.08408 0.587283 9.51903 0.756467 9.92561C0.925651 10.3322 1.17347 10.7023 1.4855 11.0144C1.79754 11.3264 2.16757 11.5743 2.57409 11.7435C2.98061 11.9127 3.4155 11.9999 3.85348 12C4.29146 12.0001 4.72379 11.9131 5.12533 11.7441C5.52688 11.5751 5.88963 11.3274 6.19249 11.0155L10.5 6.70734", stroke: htmlColor || "#828286", strokeMiterlimit: "10", strokeLinecap: "round", strokeWidth: strokeWidth || '2' })));
|
|
5
5
|
};
|
|
6
6
|
export const IconAttachToString = (color = 'inherit', htmlColor, strokeWidth, onClick, style) => {
|
|
7
7
|
return `<svg
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const IconExpand = ({ color = 'inherit', htmlColor, strokeWidth = '0.4', style }) => {
|
|
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, style: style },
|
|
4
|
+
React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', style: { strokeWidth: strokeWidth }, d: "M1.88575 15.6C2.20403 15.6 2.50925 15.7263 2.73429 15.9514C2.95932 16.1764 3.08575 16.4816 3.08575 16.8V20.4H6.68575C7.00403 20.4 7.30925 20.5263 7.53429 20.7514C7.75932 20.9764 7.88575 21.2816 7.88575 21.6C7.88575 21.9183 7.75932 22.2236 7.53429 22.4486C7.30925 22.6736 7.00403 22.8 6.68575 22.8H3.08575C2.44489 22.8 1.83025 22.5471 1.37015 22.0969C0.91004 21.6468 0.65718 21.0322 0.65718 20.4V16.8C0.65718 16.4816 0.78361 16.1764 1.00865 15.9514C1.23368 15.7263 1.5389 15.6 1.88575 15.6ZM21.0858 15.6C21.3797 15.6001 21.6634 15.7079 21.883 15.9032C22.1026 16.0984 22.2431 16.3677 22.2773 16.6596L22.2858 16.8V20.4C22.2859 21.0053 22.0572 21.5885 21.6456 22.0325C21.2339 22.4765 20.6695 22.7486 20.0658 22.7939L19.8858 22.8H16.2858C15.9799 22.7997 15.6857 22.681 15.4633 22.4726C15.2408 22.2641 15.1071 21.9756 15.0886 21.6702C15.0701 21.3649 15.1677 21.0643 15.3669 20.8298C15.566 20.5953 15.8416 20.4444 16.1453 20.4084L16.2858 20.4H19.8858V16.8C19.8858 16.4816 20.0122 16.1764 20.2373 15.9514C20.4623 15.7263 20.7675 15.6 21.0858 15.6ZM19.8858 1.2C20.4911 1.19972 21.0743 1.42841 21.5183 1.84011C21.9623 2.25181 22.2344 2.81613 22.2797 3.41991L22.2858 3.6V7.2C22.2854 7.50591 22.1667 7.80008 21.9583 8.02253C21.7498 8.24498 21.4613 8.37861 21.156 8.39708C20.8506 8.41555 20.55 8.31795 20.3155 8.11881C20.081 7.91966 19.9301 7.64404 19.8941 7.34031L19.8858 7.2V3.6H16.2858C15.9799 3.59957 15.6857 3.48084 15.4633 3.27241C15.2408 3.06397 15.1071 2.77542 15.0886 2.47006C15.0701 2.16471 15.1677 1.86409 15.3669 1.62959C15.566 1.39509 15.8416 1.24421 16.1453 1.20831L16.2858 1.2H19.8858ZM6.68575 1.2C6.98166 1.20043 7.27583 1.31916 7.49828 1.52759C7.72073 1.73603 7.85436 2.02458 7.87283 2.32994C7.89129 2.63529 7.7937 2.93591 7.59455 3.17041C7.39541 3.40491 7.11979 3.55579 6.81606 3.59169L6.68575 3.6H3.08575V7.2C3.08532 7.50591 2.96659 7.80008 2.75816 8.02253C2.54972 8.24498 2.26117 8.37861 1.95581 8.39708C1.65046 8.41555 1.34984 8.31795 1.11534 8.11881C0.880839 7.91966 0.729957 7.64404 0.694057 7.34031L0.68575 7.2V3.6C0.685473 2.99468 0.914162 2.41152 1.32586 1.96753C1.73756 1.52354 2.30188 1.25147 2.90566 1.20617L3.08575 1.2H6.68575Z" })));
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const IconFilter = ({ color = 'inherit', htmlColor, strokeWidth = 0.75, style, }) => {
|
|
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, style: style },
|
|
4
|
+
React.createElement("path", { fill: htmlColor || '#828286', stroke: htmlColor || '#828286', strokeWidth: strokeWidth, d: "M14.2759 22C14.0461 21.9998 13.8208 21.9326 13.6244 21.8054L9.43096 19.2462C8.95914 18.9574 8.5686 18.5617 8.29696 18.0946C8.02532 17.6275 7.88178 17.0896 7.88014 16.5425V12.1076C7.88094 11.7401 7.75604 11.3816 7.52292 11.0824L1.66799 3.55524C1.53128 3.37006 1.4497 3.14797 1.43225 2.91732C1.4148 2.68668 1.46216 2.45583 1.56911 2.2538C1.67606 2.05178 1.83843 1.88663 2.03832 1.77527C2.23822 1.66393 2.46784 1.61387 2.70188 1.61429H20.7258C20.96 1.61326 21.19 1.66297 21.39 1.77423C21.5902 1.88549 21.7528 2.05084 21.8598 2.25321C21.967 2.45558 22.0142 2.68671 21.9966 2.91745C21.9788 3.14819 21.8968 3.37015 21.7596 3.55524L15.9047 11.0824C15.6712 11.3815 15.5458 11.7401 15.5463 12.1076V21.1214C15.5459 21.4439 15.4121 21.7534 15.174 21.9865C14.9359 22.2196 14.613 22.3419 14.2759 22ZM2.70188 2.87051L8.54676 10.4076C8.93412 10.9079 9.14104 11.5005 9.1379 12.1076V16.5414C9.13836 16.8611 9.22512 17.1761 9.38974 17.4555C9.55436 17.7349 9.79126 17.9694 10.0775 18.1292L14.2709 20.6879L14.2885 12.1064C14.2857 11.4992 14.4931 10.9066 14.8809 10.4067L20.7346 2.89818L2.70188 2.87051Z" })));
|
|
5
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const IconSearch = ({ color = 'inherit', htmlColor, strokeWidth = 0.5, style, }) => {
|
|
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, style: style },
|
|
4
|
+
React.createElement("g", { fill: "none", fillRule: "evenodd" },
|
|
5
|
+
React.createElement("path", { d: "m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z" }),
|
|
6
|
+
React.createElement("path", { fill: htmlColor || '#828286', strokeWidth: strokeWidth, stroke: htmlColor || '#828286', d: "M10.5 2a8.5 8.5 0 1 0 5.262 15.176l3.652 3.652a1 1 0 0 0 1.414-1.414l-3.652-3.652A8.5 8.5 0 0 0 10.5 2M4 10.5a6.5 6.5 0 1 1 13 0a6.5 6.5 0 0 1-13 0" }))));
|
|
7
|
+
};
|
package/dist/Icons/index.d.ts
CHANGED
|
@@ -47,3 +47,5 @@ export { IconPencilFilled } from './IconPencilFilled/IconPencilFilled';
|
|
|
47
47
|
export { IconDeleteFilled } from './IconDeleteFilled/IconDeleteFilled';
|
|
48
48
|
export { IconShare } from './IconShare/IconShare';
|
|
49
49
|
export { IconMultiselect } from './IconMultiselect/IconMultiselect';
|
|
50
|
+
export { IconSearch } from './IconSearch/IconSearch';
|
|
51
|
+
export { IconFilter } from './IconFilter/IconFilter';
|
package/dist/Icons/index.js
CHANGED
|
@@ -47,3 +47,5 @@ export { IconPencilFilled } from './IconPencilFilled/IconPencilFilled';
|
|
|
47
47
|
export { IconDeleteFilled } from './IconDeleteFilled/IconDeleteFilled';
|
|
48
48
|
export { IconShare } from './IconShare/IconShare';
|
|
49
49
|
export { IconMultiselect } from './IconMultiselect/IconMultiselect';
|
|
50
|
+
export { IconSearch } from './IconSearch/IconSearch';
|
|
51
|
+
export { IconFilter } from './IconFilter/IconFilter';
|
|
@@ -3,9 +3,10 @@ export interface FilePreview {
|
|
|
3
3
|
file: File;
|
|
4
4
|
id: string;
|
|
5
5
|
preview?: string;
|
|
6
|
+
lng: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const getFileIcon: (file: File) => React.JSX.Element;
|
|
8
|
-
export declare const formatFileSize: (bytes?: number) => string;
|
|
9
|
+
export declare const formatFileSize: (bytes?: number, lng?: string) => string;
|
|
9
10
|
interface AttachedFilesProps {
|
|
10
11
|
files: FilePreview[];
|
|
11
12
|
onDelete?: (id: string) => void;
|
|
@@ -14,6 +15,7 @@ interface AttachedFilesProps {
|
|
|
14
15
|
className?: string;
|
|
15
16
|
isEdit?: boolean;
|
|
16
17
|
allowDownload?: boolean;
|
|
18
|
+
lng: string;
|
|
17
19
|
}
|
|
18
20
|
export declare const AttachedFilesPreview: React.FC<AttachedFilesProps>;
|
|
19
21
|
export {};
|
|
@@ -31,15 +31,18 @@ export const getFileIcon = (file) => {
|
|
|
31
31
|
return React.createElement(IconFileDefault, null);
|
|
32
32
|
};
|
|
33
33
|
// Функция для форматирования размера файла
|
|
34
|
-
export const formatFileSize = (bytes) => {
|
|
35
|
-
if (!bytes || bytes === 0)
|
|
36
|
-
return '0 Bytes';
|
|
34
|
+
export const formatFileSize = (bytes, lng) => {
|
|
35
|
+
if (!bytes || bytes === 0) {
|
|
36
|
+
return lng === 'ru' || (lng === null || lng === void 0 ? void 0 : lng.includes('ru')) ? '0 Байт' : '0 Bytes';
|
|
37
|
+
}
|
|
37
38
|
const k = 1024;
|
|
38
|
-
const
|
|
39
|
+
const sizesEn = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
40
|
+
const sizesRu = ['Байт', 'КБ', 'МБ', 'ГБ', 'ТБ'];
|
|
39
41
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
42
|
+
const sizes = lng === 'ru' || (lng === null || lng === void 0 ? void 0 : lng.includes('ru')) ? sizesRu : sizesEn;
|
|
40
43
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
41
44
|
};
|
|
42
|
-
export const AttachedFilesPreview = ({ files, onDelete, onDownload, style, className, isEdit, allowDownload = true, }) => {
|
|
45
|
+
export const AttachedFilesPreview = ({ files, onDelete, onDownload, style, className, isEdit, allowDownload = true, lng, }) => {
|
|
43
46
|
const handleDelete = (event, id) => {
|
|
44
47
|
event.stopPropagation();
|
|
45
48
|
if (onDelete) {
|
|
@@ -65,5 +68,5 @@ export const AttachedFilesPreview = ({ files, onDelete, onDownload, style, class
|
|
|
65
68
|
React.createElement("div", { onClick: allowDownload ? () => handleDownload(file.file) : undefined, className: styles.filePreview },
|
|
66
69
|
file.preview ? (React.createElement("img", { src: file.preview, alt: file.file.name, className: styles.previewImage })) : (React.createElement("div", { className: styles.previewImage }, getFileIcon(file.file))),
|
|
67
70
|
isEdit && (React.createElement("button", { className: styles.removeFileButton, onClick: (event) => handleDelete(event, file.id) }, "\u2715")),
|
|
68
|
-
React.createElement("div", { className: styles.fileSize }, formatFileSize(file.file.size))))))));
|
|
71
|
+
React.createElement("div", { className: styles.fileSize }, formatFileSize(file.file.size, lng))))))));
|
|
69
72
|
};
|
|
@@ -6,7 +6,7 @@ import { TextEditor } from '../TextEditor/TextEditor';
|
|
|
6
6
|
import { AttachedFilesPreview } from '../AttachedFilesPreview/AttachedFilesPreview';
|
|
7
7
|
import { IconAccount, IconDeleteFilled, IconPencilFilled } from '../../Icons';
|
|
8
8
|
import { IconButton } from '../IconButton/IconButton';
|
|
9
|
-
export const Comment = ({ id, value, style, className, username, avatar, creationDate, canAttachFiles = false, files = [], canEdit = false, isEdit = false, label, error = false, helperText, onChange, onSubmit, onDelete, }) => {
|
|
9
|
+
export const Comment = ({ id, value, style, className, username, avatar, creationDate, canAttachFiles = false, files = [], canEdit = false, isEdit = false, label, error = false, helperText, onChange, onSubmit, onDelete, lng = 'ru', }) => {
|
|
10
10
|
const [commentText, setCommentText] = useState(value || '');
|
|
11
11
|
const [isEditMode, setIsEditMode] = useState(isEdit);
|
|
12
12
|
const [attachedFiles, setAttachedFiles] = useState(files);
|
|
@@ -45,10 +45,10 @@ export const Comment = ({ id, value, style, className, username, avatar, creatio
|
|
|
45
45
|
React.createElement(Typography, { variant: "Body2-Medium", className: labelClasses }, username),
|
|
46
46
|
React.createElement(Typography, { variant: "Caption", className: styles.label, style: { color: '#8E8E93' } }, creationDate))),
|
|
47
47
|
canEdit && (React.createElement("div", { className: styles.iconsWrapper },
|
|
48
|
-
React.createElement(IconButton, { icon: React.createElement(IconPencilFilled, null), onClick: handleEditClick, size: "sm", style: { aspectRatio: 0 } }),
|
|
49
|
-
React.createElement(IconButton, { icon: React.createElement(IconDeleteFilled, null), onClick: handleDeleteClick, size: "sm", style: { aspectRatio: 0 } })))),
|
|
50
|
-
isEditMode ? (React.createElement(TextEditor, { defaultValue: commentText, onSubmit: handleSubmit, onChange: handleChange, error: error, helperText: helperText, files: attachedFiles, canAttachFiles: canAttachFiles })) : (React.createElement("div", { className: styles.commentWrapper },
|
|
51
|
-
attachedFiles.length > 0 && (React.createElement(AttachedFilesPreview, { files: attachedFiles, className: styles.attachedFilesContainer })),
|
|
48
|
+
React.createElement(IconButton, { icon: React.createElement(IconPencilFilled, null), onClick: handleEditClick, size: "sm", style: { aspectRatio: 0, width: '30px', height: '30px' } }),
|
|
49
|
+
React.createElement(IconButton, { icon: React.createElement(IconDeleteFilled, null), onClick: handleDeleteClick, size: "sm", style: { aspectRatio: 0, width: '30px', height: '30px' } })))),
|
|
50
|
+
isEditMode ? (React.createElement(TextEditor, { defaultValue: commentText, onSubmit: handleSubmit, onChange: handleChange, error: error, helperText: helperText, files: attachedFiles, canAttachFiles: canAttachFiles, lng: lng })) : (React.createElement("div", { className: styles.commentWrapper },
|
|
51
|
+
attachedFiles.length > 0 && (React.createElement(AttachedFilesPreview, { files: attachedFiles, className: styles.attachedFilesContainer, lng: lng })),
|
|
52
52
|
React.createElement("div", { id: id, className: inputClassess, dangerouslySetInnerHTML: { __html: commentText || '' } }))),
|
|
53
53
|
error && helperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText) }, helperText))));
|
|
54
54
|
};
|
|
@@ -168,11 +168,11 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
168
168
|
(item === null || item === void 0 ? void 0 : item.isDivider) && React.createElement("div", { className: styles.divider })),
|
|
169
169
|
hasChildren && (React.createElement("div", { className: styles.nestedMenu }, (_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child, childIndex) => {
|
|
170
170
|
var _a;
|
|
171
|
-
return (React.createElement(DropdownListItem, { key: (_a = child === null || child === void 0 ? void 0 : child.
|
|
171
|
+
return (React.createElement(DropdownListItem, { key: (_a = child === null || child === void 0 ? void 0 : child.id) !== null && _a !== void 0 ? _a : `${index}-${childIndex}`, item: child, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, onChange: onChange, isActive: false, activeIndex: activeIndex, index: childIndex, isChild: true }));
|
|
172
172
|
})))));
|
|
173
173
|
return showTooltip ? (React.createElement(Tooltip, { label: ((_b = getComparisonValue(item, getOptionLabel)) === null || _b === void 0 ? void 0 : _b.toString()) || '', position: "bottom-left" }, itemContent)) : (itemContent);
|
|
174
174
|
};
|
|
175
|
-
export const Dropdown = ({ options, id, label, placeholder, required = false, value, defaultValue, onChange, getOptionLabel, variant = 'text', size = 'lg', style, className, isLeftLabel = false, isDivider = false, disabled = false, readOnly = false, isOpened = false, error = false, helperText, onClick, onBlur, onFocus, onClose, clearable = true, enableAutocomplete = false, noOptionsText = 'Нет вариантов для выбора', lng = 'ru', }) => {
|
|
175
|
+
export const Dropdown = ({ options, id, label, placeholder, required = false, value, defaultValue, onChange, showLoadMore = false, loadMore, getOptionLabel, variant = 'text', size = 'lg', style, className, isLeftLabel = false, isDivider = false, disabled = false, readOnly = false, isOpened = false, error = false, helperText, onClick, onBlur, onFocus, onClose, clearable = true, enableAutocomplete = false, noOptionsText = 'Нет вариантов для выбора', lng = 'ru', }) => {
|
|
176
176
|
const [isOpen, setIsOpen] = useState(isOpened);
|
|
177
177
|
const [modifiedOptions, setModifiedOptions] = useState([]);
|
|
178
178
|
const [selectedItem, setSelectedItem] = useState(null);
|
|
@@ -373,12 +373,18 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
373
373
|
};
|
|
374
374
|
const getDropdownMenu = () => {
|
|
375
375
|
const optionsToRender = enableAutocomplete && searchValue ? filteredOptions : modifiedOptions;
|
|
376
|
-
const menu = isOpen && (React.createElement("div", { className: dropdownClassess },
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
376
|
+
const menu = isOpen && (React.createElement("div", { className: dropdownClassess },
|
|
377
|
+
optionsToRender && optionsToRender.length > 0 ? (optionsToRender.map((optionsToRender, index) => {
|
|
378
|
+
var _a;
|
|
379
|
+
return (React.createElement(DropdownListItem, { key: (_a = optionsToRender === null || optionsToRender === void 0 ? void 0 : optionsToRender.id) !== null && _a !== void 0 ? _a : index, item: optionsToRender, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, variant: variant, onChange: onChangeHandler, isActive: activeIndex === index, activeIndex: activeIndex, index: index }));
|
|
380
|
+
})) : (React.createElement("div", { className: `${styles['item-container']} ${styles['item-block']}`, style: { paddingLeft: '15px' } }, lng === 'ru' || lng.includes('ru')
|
|
381
|
+
? noOptionsText || 'Нет вариантов для выбора'
|
|
382
|
+
: noOptionsText || 'No options to select')),
|
|
383
|
+
showLoadMore && loadMore && React.createElement("div", { className: styles[`loadMore`], onClick: (e) => {
|
|
384
|
+
e.stopPropagation();
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
loadMore();
|
|
387
|
+
} }, 'Загрузить еще')));
|
|
382
388
|
return isOpen ? menu : null;
|
|
383
389
|
};
|
|
384
390
|
useEffect(() => {
|
|
@@ -337,3 +337,16 @@
|
|
|
337
337
|
grid-template-columns: 1fr 20px;
|
|
338
338
|
justify-content: space-between;
|
|
339
339
|
}
|
|
340
|
+
/* Кнопка Загрузить еще */
|
|
341
|
+
.loadMore {
|
|
342
|
+
/* align-self: flex-end; */
|
|
343
|
+
padding: 6px;
|
|
344
|
+
margin-left: 10px;
|
|
345
|
+
font-size: 12px;
|
|
346
|
+
color: var(--blue-secondary);
|
|
347
|
+
cursor: pointer;
|
|
348
|
+
|
|
349
|
+
}
|
|
350
|
+
.loadMore:hover {
|
|
351
|
+
color: var(--blue-dark);
|
|
352
|
+
}
|
|
@@ -7,7 +7,7 @@ import { IconClose, IconDownload, IconFile } from '../../Icons';
|
|
|
7
7
|
import { Tooltip } from '../Tooltip/Tooltip';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { formatFileSize } from '../AttachedFilesPreview/AttachedFilesPreview';
|
|
10
|
-
export const FileItem = ({ file, loading = false, error = '', onDownload, onDelete, canDelete = true, canDownload = true, style, isAddedFile, isRejectedFile, progressBarWidth }) => {
|
|
10
|
+
export const FileItem = ({ file, loading = false, error = '', onDownload, onDelete, canDelete = true, canDownload = true, style, isAddedFile, isRejectedFile, progressBarWidth, lng }) => {
|
|
11
11
|
const [isLoadingFinished, setIsLoadingFinished] = useState(false);
|
|
12
12
|
const [animationDuration, setAnimationDuration] = useState(0);
|
|
13
13
|
const [maxLength, setMaxLength] = useState(30);
|
|
@@ -103,7 +103,7 @@ export const FileItem = ({ file, loading = false, error = '', onDownload, onDele
|
|
|
103
103
|
React.createElement("div", { className: styles['fileItemName'], ref: fileNameRef },
|
|
104
104
|
file.filename.length > maxLength ? (React.createElement(Tooltip, { label: file.filename, position: "bottom-center", displayDelay: 300 },
|
|
105
105
|
React.createElement(Typography, { variant: "Body1", color: "var(--text-dark)" }, croppedName(file.filename)))) : (React.createElement(Typography, { variant: "Body1", color: "var(--text-dark)" }, croppedName(file.filename))),
|
|
106
|
-
file.size !== 0 && (React.createElement(Typography, { variant: "Caption", color: "var(--grey-medium)" }, formatFileSize(file.size))))),
|
|
106
|
+
file.size !== 0 && (React.createElement(Typography, { variant: "Caption", color: "var(--grey-medium)" }, formatFileSize(file.size, lng))))),
|
|
107
107
|
React.createElement("div", { className: styles['fileItemActions'] },
|
|
108
108
|
!(isAddedFile || isRejectedFile) && canDownload && (React.createElement(IconButton, { className: styles.fileIcon, icon: React.createElement(IconDownload, null), onClick: (e) => handleDownloadClick(e, file), color: "var(--icons-grey)", size: "sm" })),
|
|
109
109
|
canDelete && (React.createElement(IconButton, { className: styles.fileIcon, icon: React.createElement(IconClose, null), onClick: (e) => handleDeleteClick(e, file.id || ''), color: "var(--icons-grey)", size: "sm" })))),
|
|
@@ -10,5 +10,5 @@ export const FileListAttaсhed = ({ filesList, onDelete, onDownload, canDelete,
|
|
|
10
10
|
return (React.createElement("div", { className: classNames(styles['fileList'], className), style: style },
|
|
11
11
|
isInfoShown &&
|
|
12
12
|
(lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'] }, `Прикрепленные файлы (${filesList.length})`)) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'] }, `Attached files (${filesList.length})`))),
|
|
13
|
-
React.createElement("div", { className: styles['fileListFiles'] }, filesList.map((file) => (React.createElement(FileItem, { key: file.id, file: file, onDownload: onDownload, onDelete: onDelete, canDelete: canDelete, canDownload: canDownload }))))));
|
|
13
|
+
React.createElement("div", { className: styles['fileListFiles'] }, filesList.map((file) => (React.createElement(FileItem, { key: file.id, file: file, onDownload: onDownload, onDelete: onDelete, canDelete: canDelete, canDownload: canDownload, lng: lng }))))));
|
|
14
14
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FileLoaderProps } from '../../types';
|
|
3
|
-
export declare const FileLoader:
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileLoaderHandle, FileLoaderProps } from '../../types';
|
|
3
|
+
export declare const FileLoader: React.ForwardRefExoticComponent<FileLoaderProps & React.RefAttributes<FileLoaderHandle>>;
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
2
2
|
import { useDropzone } from 'react-dropzone';
|
|
3
3
|
import styles from './FileLoader.module.css';
|
|
4
4
|
import { Typography } from '../Typography/Typography';
|
|
5
5
|
import { IconUpload } from '../../Icons';
|
|
6
6
|
import { FileItem } from '../FileItem/FileItem';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
-
export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats = {
|
|
8
|
+
export const FileLoader = forwardRef(({ maxFileSize = 2, maxFileCount = 10, acceptedFormats = {
|
|
9
9
|
'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
|
|
10
10
|
'application/pdf': ['.pdf'],
|
|
11
|
-
'application/msword': ['.doc', '.docx'],
|
|
12
|
-
}, addedFiles, setAddedFiles, filesList = [], canAdd = true, lng = 'ru', className, style, fileValidator, progressBarWidth }) => {
|
|
11
|
+
'application/msword': ['.doc', '.docx', '.log', '.syslog', '.txt'],
|
|
12
|
+
}, rejectedFormats, addedFiles, setAddedFiles, filesList = [], canAdd = true, lng = 'ru', className, style, fileValidator, progressBarWidth }, ref) => {
|
|
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
|
+
useImperativeHandle(ref, () => ({
|
|
18
|
+
clearErrorFiles: () => {
|
|
19
|
+
setErrorFiles([]);
|
|
20
|
+
},
|
|
21
|
+
clearAllFiles: () => {
|
|
22
|
+
setErrorFiles([]);
|
|
23
|
+
setAddedFiles([]);
|
|
24
|
+
setAddedFilesFormatted([]);
|
|
25
|
+
setLoadingFilesNames([]);
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
17
28
|
const fileValidatorInner = (file) => {
|
|
18
29
|
if (file.size > maxFileSize * 1024 * 1024 * 1024) {
|
|
19
30
|
return {
|
|
@@ -43,7 +54,7 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
|
|
|
43
54
|
message: lng === 'ru' || lng.includes('ru') ? `Максимальное количество файлов ${maxFileCount}` : `Maximum number of files ${maxFileCount}`,
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
if (acceptedFormats) {
|
|
57
|
+
if (acceptedFormats && !rejectedFormats) {
|
|
47
58
|
const acceptedExtensions = Object.values(acceptedFormats)
|
|
48
59
|
.reduce((acc, val) => acc.concat(val), []);
|
|
49
60
|
const fileParts = file.name.split('.');
|
|
@@ -59,6 +70,22 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
|
|
|
59
70
|
};
|
|
60
71
|
}
|
|
61
72
|
}
|
|
73
|
+
if (rejectedFormats) {
|
|
74
|
+
const rejectedExtensions = Object.values(rejectedFormats)
|
|
75
|
+
.reduce((acc, val) => acc.concat(val), []);
|
|
76
|
+
const fileParts = file.name.split('.');
|
|
77
|
+
const fileExtension = fileParts.length > 1
|
|
78
|
+
? `.${fileParts.pop().toLowerCase()}`
|
|
79
|
+
: '';
|
|
80
|
+
if (rejectedExtensions.includes(fileExtension)) {
|
|
81
|
+
return {
|
|
82
|
+
code: 'file-invalid-type',
|
|
83
|
+
message: lng === 'ru' || lng.includes('ru')
|
|
84
|
+
? `Файл не должен быть одного из следующих типов: ${getAcceptedFormatsString(rejectedFormats)}`
|
|
85
|
+
: `File must not be one of: ${getAcceptedFormatsString(rejectedFormats)}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
62
89
|
if (fileValidator) {
|
|
63
90
|
const customValidationResult = fileValidator(file);
|
|
64
91
|
if (customValidationResult) {
|
|
@@ -141,21 +168,23 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
|
|
|
141
168
|
setLoadingFilesNames(loadingFilesNames.filter((id) => id !== id));
|
|
142
169
|
};
|
|
143
170
|
const acceptedFileItems = addedFilesFormated.map((file) => {
|
|
144
|
-
return (React.createElement(FileItem, { key: file.id, file: file, loading: loadingFilesNames.includes(file.filename), onDelete: handleDeleteFiles, isAddedFile: true, progressBarWidth: progressBarWidth }));
|
|
171
|
+
return (React.createElement(FileItem, { key: file.id, file: file, loading: loadingFilesNames.includes(file.filename), onDelete: handleDeleteFiles, isAddedFile: true, progressBarWidth: progressBarWidth, lng: lng }));
|
|
145
172
|
});
|
|
146
173
|
const handleDeleteRejectedFile = (id) => {
|
|
147
174
|
setErrorFiles(errorFiles.filter((rejection) => rejection.file.id !== id));
|
|
148
175
|
};
|
|
149
|
-
const fileRejectionItems = errorFiles.map(({ file, errors }) => (React.createElement(FileItem, { key: file.id, file: file, error: errors[0].message, onDelete: handleDeleteRejectedFile, isRejectedFile: true })));
|
|
176
|
+
const fileRejectionItems = errorFiles.map(({ file, errors }) => (React.createElement(FileItem, { key: file.id, file: file, error: errors[0].message, onDelete: handleDeleteRejectedFile, isRejectedFile: true, lng: lng })));
|
|
150
177
|
// Функция для получения всех доступных форматов в виде строки
|
|
151
178
|
const getAcceptedFormatsString = (acceptedFormats) => {
|
|
152
|
-
const
|
|
179
|
+
const uniqueFormats = new Set();
|
|
153
180
|
for (const key in acceptedFormats) {
|
|
154
181
|
if (acceptedFormats.hasOwnProperty(key)) {
|
|
155
|
-
|
|
182
|
+
acceptedFormats[key].forEach((format) => {
|
|
183
|
+
uniqueFormats.add(format.replace('.', ''));
|
|
184
|
+
});
|
|
156
185
|
}
|
|
157
186
|
}
|
|
158
|
-
return
|
|
187
|
+
return Array.from(uniqueFormats).join(', ');
|
|
159
188
|
};
|
|
160
189
|
useEffect(() => {
|
|
161
190
|
if (addedFiles.length === 0) {
|
|
@@ -189,9 +218,9 @@ export const FileLoader = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
|
|
|
189
218
|
React.createElement("br", null)))),
|
|
190
219
|
maxFileCount &&
|
|
191
220
|
(lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2", color: "var(--grey-medium)" }, `За раз можно загрузить ${maxFileCount} ${maxFileCount > 1 ? `файлов` : `файл`}`)) : (React.createElement(Typography, { variant: "Body2", color: "var(--grey-medium)" }, `You can upload ${maxFileCount} ${maxFileCount > 1 ? `files` : `file`}`))))),
|
|
192
|
-
acceptedFormats &&
|
|
193
|
-
|
|
221
|
+
acceptedFormats && !rejectedFormats && (React.createElement(Typography, { variant: "Body2", color: "var(--grey-medium)" }, `${lng === 'ru' || lng.includes('ru') ? 'Поддерживаемые форматы:' : 'Supported formats:'} ${getAcceptedFormatsString(acceptedFormats)}`)),
|
|
222
|
+
rejectedFormats && (React.createElement(Typography, { variant: "Body2", color: "var(--grey-medium)" }, `${lng === 'ru' || lng.includes('ru') ? 'Неподдерживаемые форматы:' : 'Unsupported formats:'} ${getAcceptedFormatsString(rejectedFormats)}`)),
|
|
194
223
|
(addedFiles === null || addedFiles === void 0 ? void 0 : addedFiles.length) > 0 || (errorFiles === null || errorFiles === void 0 ? void 0 : errorFiles.length) > 0 ? (React.createElement("div", { className: styles['addedFiles'] },
|
|
195
224
|
acceptedFileItems,
|
|
196
225
|
fileRejectionItems)) : lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' } }, "\u0424\u0430\u0439\u043B\u044B \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B")) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' } }, "Files not added"))));
|
|
197
|
-
};
|
|
226
|
+
});
|
|
@@ -23,7 +23,7 @@ const getElementFromRange = (range) => {
|
|
|
23
23
|
const container = range.commonAncestorContainer;
|
|
24
24
|
return container.nodeType === Node.TEXT_NODE ? container.parentElement : container;
|
|
25
25
|
};
|
|
26
|
-
export const TextEditor = ({ label, onSubmit, onChange, defaultValue, error, helperText, canAttachFiles = false, files, required, className, isButtonDisabled, }) => {
|
|
26
|
+
export const TextEditor = ({ label, onSubmit, onChange, defaultValue, error, helperText, canAttachFiles = false, files, required, className, isButtonDisabled, lng = 'ru', }) => {
|
|
27
27
|
const editorRef = useRef(null);
|
|
28
28
|
const uploaderRef = useRef(null);
|
|
29
29
|
const submitButtonRef = useRef(null);
|
|
@@ -293,6 +293,7 @@ export const TextEditor = ({ label, onSubmit, onChange, defaultValue, error, hel
|
|
|
293
293
|
file,
|
|
294
294
|
id: `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
295
295
|
preview: file.type.startsWith('image/') ? URL.createObjectURL(file) : undefined,
|
|
296
|
+
lng,
|
|
296
297
|
}));
|
|
297
298
|
setAttachedFiles((prev) => [...prev, ...newAttachedFiles]);
|
|
298
299
|
event.target.value = '';
|
|
@@ -535,7 +536,7 @@ export const TextEditor = ({ label, onSubmit, onChange, defaultValue, error, hel
|
|
|
535
536
|
return (React.createElement("div", { className: wrapperClassess },
|
|
536
537
|
label && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, label)),
|
|
537
538
|
React.createElement("div", { className: inputClassess },
|
|
538
|
-
attachedFiles.length > 0 && (React.createElement(AttachedFilesPreview, { files: attachedFiles, onDelete: (id) => removeAttachedFile(id), className: styles.attachedFilesContainer, isEdit: true })),
|
|
539
|
+
attachedFiles.length > 0 && (React.createElement(AttachedFilesPreview, { files: attachedFiles, onDelete: (id) => removeAttachedFile(id), className: styles.attachedFilesContainer, isEdit: true, lng: lng })),
|
|
539
540
|
React.createElement("div", { ref: editorRef }),
|
|
540
541
|
canAttachFiles && (React.createElement("input", { ref: uploaderRef, type: "file", style: { display: 'none' }, multiple: true, onChange: handleUploadFiles, accept: ACCEPTED_FILE_TYPES }))),
|
|
541
542
|
error && helperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText) }, helperText))));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -186,6 +186,10 @@ export interface DropdownProps {
|
|
|
186
186
|
defaultValue?: string | number | TOptions | null;
|
|
187
187
|
/** Callback, который будет вызван при изменении значения */
|
|
188
188
|
onChange?: (event: any, value: string | number | TOptions | null) => void;
|
|
189
|
+
/** Флаг, является ли выпадающий список пагинированным */
|
|
190
|
+
showLoadMore?: boolean;
|
|
191
|
+
/** Функция для загрузки списка при пагинированных данных */
|
|
192
|
+
loadMore?: () => void;
|
|
189
193
|
/** Функция для получения текста опции */
|
|
190
194
|
getOptionLabel?: (option: TOptions) => string;
|
|
191
195
|
/** Вариaнты выпадающего списка(текст + иконка, текст)' */
|
|
@@ -453,6 +457,8 @@ export interface FileItemProps {
|
|
|
453
457
|
isRejectedFile?: boolean;
|
|
454
458
|
/** Ширина прогресс бара */
|
|
455
459
|
progressBarWidth?: string;
|
|
460
|
+
/** Язык интерфейса для типов данных*/
|
|
461
|
+
lng?: string;
|
|
456
462
|
}
|
|
457
463
|
export interface FileLoaderProps {
|
|
458
464
|
/** Максимальный размер файла */
|
|
@@ -461,6 +467,8 @@ export interface FileLoaderProps {
|
|
|
461
467
|
maxFileCount?: number;
|
|
462
468
|
/**Поддерживаемые форматы файлов */
|
|
463
469
|
acceptedFormats?: Accept;
|
|
470
|
+
/** Неподдерживаемые форматы файлов */
|
|
471
|
+
rejectedFormats?: Accept;
|
|
464
472
|
/**Добавленные файлы */
|
|
465
473
|
addedFiles: File[];
|
|
466
474
|
/**Сосотояние для добавления файлов */
|
|
@@ -480,6 +488,10 @@ export interface FileLoaderProps {
|
|
|
480
488
|
/** Ширина прогресс бара */
|
|
481
489
|
progressBarWidth?: string;
|
|
482
490
|
}
|
|
491
|
+
export interface FileLoaderHandle {
|
|
492
|
+
clearErrorFiles: () => void;
|
|
493
|
+
clearAllFiles: () => void;
|
|
494
|
+
}
|
|
483
495
|
export interface DialogProps {
|
|
484
496
|
/** Флаг открытия окна */
|
|
485
497
|
open: boolean;
|
|
@@ -606,6 +618,8 @@ export interface TextEditorProps {
|
|
|
606
618
|
required?: boolean;
|
|
607
619
|
className?: string;
|
|
608
620
|
isButtonDisabled?: boolean;
|
|
621
|
+
/** Язык */
|
|
622
|
+
lng?: string;
|
|
609
623
|
}
|
|
610
624
|
export interface CommentProps {
|
|
611
625
|
/** Идентификатор элемента */
|
|
@@ -635,6 +649,8 @@ export interface CommentProps {
|
|
|
635
649
|
onChange?: (value: string, files: FilePreview[]) => void;
|
|
636
650
|
onSubmit?: (value: string, files: FilePreview[]) => void;
|
|
637
651
|
onDelete?: (id: string) => void;
|
|
652
|
+
/** Язык */
|
|
653
|
+
lng?: string;
|
|
638
654
|
}
|
|
639
655
|
export interface LinkProps {
|
|
640
656
|
/**Гипертекстовая ссылка */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kamotive_ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.25",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"react": "^18.3.1",
|
|
28
28
|
"react-datepicker": "^8.2.1",
|
|
29
29
|
"react-dom": "^18.3.1",
|
|
30
|
-
"react-dropzone": "^14.3.
|
|
30
|
+
"react-dropzone": "^14.3.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@chromatic-com/storybook": "^3.2.2",
|