kamotive_ui 1.2.29 → 2.3.26

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 (59) hide show
  1. package/dist/Icons/IconAttach/IconAttach.js +1 -1
  2. package/dist/Icons/IconBulletlist/IconBulletlist.js +32 -43
  3. package/dist/Icons/IconCancel/IconCancel.d.ts +9 -0
  4. package/dist/Icons/IconCancel/IconCancel.js +27 -0
  5. package/dist/Icons/IconClose/IconClose.js +2 -4
  6. package/dist/Icons/IconDelete/IconDelete.d.ts +2 -0
  7. package/dist/Icons/IconDelete/IconDelete.js +3 -3
  8. package/dist/Icons/IconExpand/IconExpand.d.ts +7 -0
  9. package/dist/Icons/IconExpand/IconExpand.js +5 -0
  10. package/dist/Icons/IconFile/IconFile.d.ts +1 -0
  11. package/dist/Icons/IconFile/IconFile.js +3 -2
  12. package/dist/Icons/IconFileDefault/IconFileDefault.js +1 -1
  13. package/dist/Icons/IconFilter/IconFilter.d.ts +7 -0
  14. package/dist/Icons/IconFilter/IconFilter.js +5 -0
  15. package/dist/Icons/IconPencil/IconPencil.d.ts +4 -1
  16. package/dist/Icons/IconPencil/IconPencil.js +2 -2
  17. package/dist/Icons/IconPencilCancel/IconPencilCancel.d.ts +10 -0
  18. package/dist/Icons/IconPencilCancel/IconPencilCancel.js +8 -0
  19. package/dist/Icons/IconSearch/IconSearch.d.ts +7 -0
  20. package/dist/Icons/IconSearch/IconSearch.js +7 -0
  21. package/dist/Icons/IconSubmit/IconSubmit.d.ts +2 -0
  22. package/dist/Icons/IconSubmit/IconSubmit.js +1 -1
  23. package/dist/Icons/index.d.ts +4 -0
  24. package/dist/Icons/index.js +4 -0
  25. package/dist/components/AttachedFilesPreview/AttachedFilesPreview.d.ts +9 -6
  26. package/dist/components/AttachedFilesPreview/AttachedFilesPreview.js +21 -60
  27. package/dist/components/AttachedFilesPreview/AttachedFilesPreview.module.css +29 -17
  28. package/dist/components/Button/Button.js +17 -42
  29. package/dist/components/ColorPicker/ColorPicker.js +1 -1
  30. package/dist/components/Comment/Comment.js +18 -20
  31. package/dist/components/Comment/Comment.module.css +9 -3
  32. package/dist/components/Dialog/Dialog.js +9 -2
  33. package/dist/components/Dialog/Dialog.module.css +23 -0
  34. package/dist/components/Dropdown/Dropdown.d.ts +10 -10
  35. package/dist/components/Dropdown/Dropdown.js +305 -150
  36. package/dist/components/Dropdown/Dropdown.module.css +201 -42
  37. package/dist/components/FileAttach/FileAttach.d.ts +3 -3
  38. package/dist/components/FileAttach/FileAttach.js +8 -5
  39. package/dist/components/FileItem/FileItem.js +14 -10
  40. package/dist/components/FileItem/FileItem.module.css +13 -1
  41. package/dist/components/FileListAttached/FileListAtta/321/201hed.js +1 -1
  42. package/dist/components/FileLoader/FileLoader.d.ts +3 -3
  43. package/dist/components/FileLoader/FileLoader.js +74 -34
  44. package/dist/components/IconButton/IconButton.d.ts +1 -1
  45. package/dist/components/IconButton/IconButton.js +4 -4
  46. package/dist/components/IconButton/IconButton.module.css +1 -0
  47. package/dist/components/Input/Input.module.css +3 -1
  48. package/dist/components/TableFilterSidebar/TableFilterSidebar.d.ts +3 -0
  49. package/dist/components/TableFilterSidebar/TableFilterSidebar.js +39 -0
  50. package/dist/components/TableFilterSidebar/TableFilterSidebar.module.css +52 -0
  51. package/dist/components/TextEditor/TextEditor.d.ts +1 -0
  52. package/dist/components/TextEditor/TextEditor.js +274 -112
  53. package/dist/components/TextEditor/TextEditor.module.css +33 -7
  54. package/dist/components/Tooltip/Tooltip.js +11 -1
  55. package/dist/components/Tooltip/Tooltip.module.css +2 -1
  56. package/dist/index.d.ts +2 -1
  57. package/dist/index.js +1 -0
  58. package/dist/types/index.d.ts +135 -45
  59. package/package.json +2 -2
@@ -1,14 +1,21 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import styles from './Button.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { Typography } from '../Typography/Typography';
5
5
  /**
6
6
  * Компонент Button представляет собой кнопку, которую можно настроить с помощью различных параметров (размер, иконки, стили, состояние).
7
7
  */
8
- export const Button = ({ label, variant = 'fill', size = 'md', style, condition, icon, disabled = false, onClick, children, error, color, name, type = 'button', form }) => {
9
- const [buttonStyle, setButtonStyle] = useState('');
10
- const [buttonCondition, setButtonCondition] = useState(condition);
11
- const buttonClasses = classNames(styles['button'], styles[`button--${size}`], styles[`button--${buttonStyle}`], {
8
+ export const Button = ({ label, variant = 'fill', size = 'md', mode, style, condition, icon, disabled = false, onClick, children, error, color, name, type = 'button', form }) => {
9
+ const btnIcon = icon || typeof children === 'object' && children;
10
+ let modeStyle = 'text';
11
+ if (mode) {
12
+ modeStyle = mode;
13
+ }
14
+ else if (btnIcon && variant !== 'link') {
15
+ modeStyle = (!label && !children) ? 'icon' : 'default';
16
+ }
17
+ const buttonCondition = error ? 'error' : (condition || 'default');
18
+ const buttonClasses = classNames(styles['button'], styles[`button--${size}`], styles[`button--${modeStyle}`], {
12
19
  [styles[`button--${variant}-${buttonCondition}`]]: buttonCondition && !color,
13
20
  [styles[`button--${variant}-custom`]]: color && !error
14
21
  });
@@ -48,51 +55,19 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
48
55
  return '#FFFFFF';
49
56
  }
50
57
  };
51
- const btnIcon = icon || typeof children === 'object' && children;
52
- useEffect(() => {
53
- if (!buttonStyle && style) {
54
- setButtonStyle(style);
55
- }
56
- else {
57
- if (btnIcon && variant !== 'link') {
58
- if (!label && !(typeof children === 'string' && children)) {
59
- setButtonStyle('icon');
60
- }
61
- else {
62
- setButtonStyle('default');
63
- }
64
- }
65
- else {
66
- setButtonStyle('text');
67
- }
68
- }
69
- }, [style, btnIcon, label, children]);
70
- useEffect(() => {
71
- if (!condition) {
72
- if (error) {
73
- setButtonCondition('error');
74
- }
75
- else {
76
- setButtonCondition('default');
77
- }
78
- }
79
- else {
80
- error ? setButtonCondition('error') : setButtonCondition(condition);
81
- }
82
- }, [condition, error]);
83
58
  const iconColorStyle = iconColorFn();
84
- if (!buttonStyle) {
59
+ if (!modeStyle) {
85
60
  return (React.createElement("button", { className: buttonClasses },
86
61
  React.createElement(Typography, { variant: "Body1" }, "\u041A\u043D\u043E\u043F\u043A\u0430")));
87
62
  }
88
- return (React.createElement("button", { className: buttonClasses, style: color && !error ? {
63
+ return (React.createElement("button", { className: buttonClasses, style: Object.assign(Object.assign({}, style), (color && !error ? {
89
64
  '--button-color': color,
90
65
  '--button-hover-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 90%, black)` : `color-mix(in srgb, ${color} 10%, transparent)`,
91
66
  '--button-active-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, black)` : `color-mix(in srgb, ${color} 20%, transparent)`,
92
67
  '--button-disabled-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 10%, transparent)`,
93
68
  '--button-disabled-textColor': variant === 'fill' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 50%, transparent)`,
94
- } : {}, onClick: onClick, disabled: disabled, "aria-disabled": disabled, type: type, name: name ? name : label ? `button-${label}` : 'button', form: form },
95
- btnIcon && (buttonStyle === 'icon' || buttonStyle === 'default') && (() => {
69
+ } : {})), onClick: (e) => onClick === null || onClick === void 0 ? void 0 : onClick(e), disabled: disabled, "aria-disabled": disabled, type: type, name: name ? name : label ? `button-${label}` : 'button', form: form },
70
+ btnIcon && (modeStyle === 'icon' || modeStyle === 'default') && (() => {
96
71
  var _a;
97
72
  const iconElement = btnIcon;
98
73
  const defaultStrokeWidth = size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0';
@@ -101,5 +76,5 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
101
76
  strokeWidth: (_a = iconElement.props.strokeWidth) !== null && _a !== void 0 ? _a : defaultStrokeWidth,
102
77
  });
103
78
  })(),
104
- (buttonStyle === 'text' || buttonStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
79
+ (modeStyle === 'text' || modeStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
105
80
  };
@@ -129,7 +129,7 @@ export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsH
129
129
  setIsColorChanged(true);
130
130
  setColorValue(newColor);
131
131
  setSelectedColor(newColor);
132
- onColorChange(newColor);
132
+ onColorChange === null || onColorChange === void 0 ? void 0 : onColorChange(newColor);
133
133
  };
134
134
  return (React.createElement("div", { className: (mainColor || recentColors) && styles.colorPickerWrapper, ref: divRef },
135
135
  mainColor && (React.createElement("div", { className: mainColorClasses, style: {
@@ -1,18 +1,16 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styles from './Comment.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { Typography } from '../Typography/Typography';
5
5
  import { TextEditor } from '../TextEditor/TextEditor';
6
6
  import { AttachedFilesPreview } from '../AttachedFilesPreview/AttachedFilesPreview';
7
- import { IconAccount, IconDeleteFilled, IconPencilFilled } from '../../Icons';
7
+ import { IconAccount, IconDelete, IconPencil, IconPencilCancel } 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, }) => {
10
- const [commentText, setCommentText] = useState(value || '');
9
+ export const Comment = ({ comment, avatar, creationDate, canAttachFiles = true, canEdit = false, isEdit = false, error = false, setError, helperText, onSubmit, onDelete, onEdit, onDownload, canDeleteFile, onFileDelete, maxFileCount, maxFileSize, lng = 'ru', style, className, }) => {
10
+ var _a, _b, _c, _d;
11
11
  const [isEditMode, setIsEditMode] = useState(isEdit);
12
- const [attachedFiles, setAttachedFiles] = useState(files);
13
12
  const [imageError, setImageError] = useState(false);
14
13
  const wrapperClassess = classNames(styles['wrapper--input'], className, {
15
- [styles['wrapper--input-label']]: label,
16
14
  [styles['wrapper--input-helperText']]: error,
17
15
  });
18
16
  const inputClassess = classNames(styles.input, styles['readOnly']);
@@ -21,34 +19,34 @@ export const Comment = ({ id, value, style, className, username, avatar, creatio
21
19
  setIsEditMode((prev) => !prev);
22
20
  };
23
21
  const handleDeleteClick = () => {
24
- onDelete === null || onDelete === void 0 ? void 0 : onDelete(id);
22
+ onDelete === null || onDelete === void 0 ? void 0 : onDelete(comment);
25
23
  };
26
24
  const handleSubmit = (value, files) => {
25
+ var _a;
27
26
  if (onSubmit) {
28
- onSubmit(value, files);
27
+ onSubmit(value, files, (_a = comment === null || comment === void 0 ? void 0 : comment.id) !== null && _a !== void 0 ? _a : '');
29
28
  }
30
- setCommentText(value);
31
- setAttachedFiles(files);
32
29
  setIsEditMode((prev) => !prev);
33
30
  };
34
- const handleChange = (value, files) => {
35
- if (onChange) {
36
- onChange(value, files);
37
- }
31
+ const handleCancel = () => {
32
+ setIsEditMode((prev) => !prev);
38
33
  };
34
+ useEffect(() => {
35
+ onEdit === null || onEdit === void 0 ? void 0 : onEdit(isEditMode);
36
+ }, [isEditMode]);
39
37
  return (React.createElement("div", { className: wrapperClassess, style: style },
40
38
  React.createElement("div", { style: { display: 'flex', justifyContent: 'space-between' } },
41
39
  React.createElement("div", { className: styles.labelWrapper },
42
40
  React.createElement("div", { className: styles.flexBox }, avatar && !imageError ? (React.createElement("img", { src: avatar, alt: "Avatar", className: styles.avatar, onError: () => setImageError(true) })) : (React.createElement("div", { className: `${styles.avatar} ${styles.avatarIcon} ${styles.flexBox}` },
43
41
  React.createElement(IconAccount, null)))),
44
42
  React.createElement("div", { className: styles.infoWrapper },
45
- React.createElement(Typography, { variant: "Body2-Medium", className: labelClasses }, username),
43
+ React.createElement(Typography, { variant: "Body2-Medium", className: labelClasses }, (_b = (_a = comment === null || comment === void 0 ? void 0 : comment.authorUser) === null || _a === void 0 ? void 0 : _a.fullName) !== null && _b !== void 0 ? _b : ''),
46
44
  React.createElement(Typography, { variant: "Caption", className: styles.label, style: { color: '#8E8E93' } }, creationDate))),
47
45
  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 })),
52
- React.createElement("div", { id: id, className: inputClassess, dangerouslySetInnerHTML: { __html: commentText || '' } }))),
46
+ React.createElement(IconButton, { icon: isEditMode ? React.createElement(IconPencilCancel, { width: '14', height: '14' }) : React.createElement(IconPencil, { width: '14', height: '14' }), title: isEditMode ? lng === 'ru' ? 'Закрыть редактирование' : 'Close edit' : lng === 'ru' ? 'Редактировать' : 'Edit', onClick: handleEditClick, style: { width: '30px', height: '30px', padding: '5px' }, color: "var(--icons-grey)" }),
47
+ React.createElement(IconButton, { icon: React.createElement(IconDelete, { width: '14', height: '14', strokeWidth: '0.5' }), title: lng === 'ru' ? 'Удалить' : 'Delete', onClick: handleDeleteClick, size: "sm", style: { width: '30px', height: '30px', padding: '5px' }, color: "var(--icons-grey)" })))),
48
+ isEditMode ? (React.createElement(TextEditor, { defaultValue: (_c = comment === null || comment === void 0 ? void 0 : comment.text) !== null && _c !== void 0 ? _c : '', attachedFiles: comment.attachFiles, onSubmit: handleSubmit, onCancel: handleCancel, onDelete: onFileDelete, error: error, setError: setError, helperText: helperText, isEditMode: isEditMode, canAttachFiles: canAttachFiles, maxFileCount: maxFileCount, maxFileSize: maxFileSize, lng: lng })) : (React.createElement("div", { className: styles.commentWrapper },
49
+ comment.attachFiles && ((_d = comment.attachFiles) === null || _d === void 0 ? void 0 : _d.length) > 0 && (React.createElement(AttachedFilesPreview, { files: comment.attachFiles, onDownload: onDownload, allowDelete: canDeleteFile, onDelete: onFileDelete, className: styles.attachedFilesContainer, maxFileCount: maxFileCount, lng: lng })),
50
+ React.createElement("div", { id: `comment-${comment.id}`, className: inputClassess, dangerouslySetInnerHTML: { __html: comment.text || '' } }))),
53
51
  error && helperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText) }, helperText))));
54
52
  };
@@ -5,6 +5,9 @@
5
5
 
6
6
  .wrapper--input-label {
7
7
  margin-top: 20px;
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 10px;
8
11
  }
9
12
 
10
13
  .wrapper--input-helperText {
@@ -25,11 +28,13 @@
25
28
  .iconsWrapper {
26
29
  display: flex;
27
30
  flex-direction: row;
28
- gap: 15px;
31
+ padding-right: 12px;
29
32
  }
30
33
 
31
34
  .commentWrapper {
32
35
  padding-left: 33px;
36
+ width: 100%;
37
+ box-sizing: border-box;
33
38
  }
34
39
 
35
40
  .avatar {
@@ -144,7 +149,8 @@
144
149
  .attachedFilesContainer {
145
150
  margin-top: 5px;
146
151
  display: flex;
147
- flex-direction: row;
152
+ flex-direction: column;
148
153
  overflow-x: auto;
149
- gap: 12px;
154
+ max-height: 25vh;
155
+ overflow: scroll;
150
156
  }
@@ -1,10 +1,17 @@
1
1
  import React from 'react';
2
2
  import styles from './Dialog.module.css';
3
3
  import classNames from 'classnames';
4
- export const Dialog = ({ open, maxWidth = 'md', children, style, className, overlay = true, fullWidth = false }) => {
4
+ import { Spinner } from '../Spinner/Spinner';
5
+ import { IconButton } from '../IconButton/IconButton';
6
+ import { IconClose } from '../../Icons/IconClose/IconClose';
7
+ export const Dialog = ({ open, onClose, maxWidth = 'md', children, style, className, overlay = true, fullWidth = false, isLoading = false }) => {
5
8
  const isMaxWidthInPx = typeof maxWidth === 'string' && !isNaN(Number(maxWidth.replace('px', '')));
6
9
  return (React.createElement(React.Fragment, null,
7
10
  open && overlay && React.createElement("div", { className: styles.dialogOverlay }),
8
- React.createElement("dialog", { open: open, className: classNames(styles['dialog'], !isMaxWidthInPx && styles[`maxWidth--${maxWidth}`], className), style: Object.assign(Object.assign({}, style), { maxWidth: isMaxWidthInPx ? maxWidth : '', width: fullWidth ? '100%' : '' }) },
11
+ React.createElement("dialog", { open: open, className: classNames(styles['dialog'], !isMaxWidthInPx && styles[`maxWidth--${maxWidth}`], isLoading && styles['dialogLoading'], className), style: Object.assign(Object.assign({}, style), { maxWidth: isMaxWidthInPx ? maxWidth : '', width: fullWidth ? '100%' : '' }) },
12
+ onClose && (React.createElement("div", { className: styles.closeButtonWrapper },
13
+ React.createElement(IconButton, { onClick: onClose, icon: React.createElement(IconClose, null), color: "var(--icons-grey)", size: "lg" }))),
14
+ isLoading && React.createElement("div", { className: styles['loader'] },
15
+ React.createElement(Spinner, null)),
9
16
  React.createElement("div", { className: styles['content'] }, children))));
10
17
  };
@@ -24,6 +24,7 @@
24
24
  display: flex;
25
25
  flex-direction: column;
26
26
  gap: 1rem;
27
+ min-height: 0;
27
28
  }
28
29
 
29
30
  .maxWidth--xs {
@@ -44,4 +45,26 @@
44
45
 
45
46
  .maxWidth--xl {
46
47
  max-width: 800px;
48
+ }
49
+
50
+ .loader {
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ right: 0;
55
+ bottom: 0;
56
+ background-color: rgba(255, 255, 255, 0.5);
57
+ z-index: 10;
58
+ display: flex;
59
+ justify-content: center;
60
+ align-items: center;
61
+ border-radius: 15px;
62
+
63
+ }
64
+
65
+ .closeButtonWrapper{
66
+ position: absolute;
67
+ top: 15px;
68
+ right: 15px;
69
+ z-index: 20;
47
70
  }
@@ -1,19 +1,19 @@
1
- import React, { FC } from 'react';
2
- import { DropdownProps, TOptions } from '../../types';
1
+ import React from 'react';
2
+ import { DropdownProps, BaseOptions } from '../../types';
3
3
  /**
4
4
  * Компонент Dropdown позволяет пользователям выбирать однин вариант из выпадающего меню
5
5
  */
6
- export interface DropdownListItemProps {
7
- item: TOptions | null;
8
- getOptionLabel?: (option: TOptions) => string;
6
+ export interface DropdownListItemProps<T extends BaseOptions> {
7
+ item: T | null;
8
+ getOptionLabel?: (option: T) => string;
9
9
  size: 'md' | 'lg';
10
- selectedItem: TOptions | null;
11
- variant?: 'icons' | 'text';
12
- onChange: (event: React.MouseEvent<HTMLElement>, item: TOptions | null) => void;
10
+ selectedItem: T | null | T[];
11
+ variant?: 'icons' | 'text' | 'filter';
12
+ onChange: (event: React.MouseEvent<HTMLElement>, item: T | null) => void;
13
13
  isActive?: boolean;
14
14
  activeIndex?: number;
15
15
  index?: number;
16
16
  isChild?: boolean;
17
17
  }
18
- export declare const DropdownListItem: FC<DropdownListItemProps>;
19
- export declare const Dropdown: FC<DropdownProps>;
18
+ export declare const DropdownListItem: <T extends BaseOptions>({ item, getOptionLabel, size, selectedItem, variant, onChange, isActive, activeIndex, index, isChild, }: DropdownListItemProps<T>) => React.JSX.Element;
19
+ export declare const Dropdown: <T extends BaseOptions>({ options, id, label, placeholder, required, value, defaultValue, onChange, showLoadMore, loadMore, getOptionLabel, variant, size, style, className, isLeftLabel, isDivider, disabled, readOnly, isOpened, error, helperText, onOpen, onClick, onBlur, onFocus, onClose, clearable, enableAutocomplete, onSearch, isLoadMoreLoading, isSearchLoading, noOptionsText, lng, multiple, limitTags, }: DropdownProps<T>) => React.JSX.Element;