kamotive_ui 1.2.3 → 1.2.5
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/IconFile/IconFile.d.ts +6 -0
- package/dist/Icons/IconFile/IconFile.js +5 -0
- package/dist/Icons/IconUpload/IconUpload.d.ts +6 -0
- package/dist/Icons/IconUpload/IconUpload.js +5 -0
- package/dist/Icons/index.d.ts +2 -0
- package/dist/Icons/index.js +2 -0
- package/dist/colors.css +5 -1
- package/dist/components/Button/Button.js +86 -31
- package/dist/components/Button/Button.module.css +101 -38
- package/dist/components/ColorPicker/ColorPicker.js +84 -40
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.js +22 -13
- package/dist/components/FileAttach/FileAttach.d.ts +3 -0
- package/dist/components/FileAttach/FileAttach.js +80 -0
- package/dist/components/FileAttach/FileAttach.module.css +36 -0
- package/dist/components/Input/Input.js +16 -6
- package/dist/components/Loader/Loader.d.ts +3 -0
- package/dist/components/Loader/Loader.js +18 -0
- package/dist/components/Loader/Loader.module.css +75 -0
- package/dist/components/ProgressBar/ProgressBar.js +1 -1
- package/dist/components/SettingTag/SettingTag.js +6 -6
- package/dist/components/Spinner/Spinner.d.ts +3 -0
- package/dist/components/Spinner/Spinner.js +30 -0
- package/dist/components/Spinner/Spinner.module.css +20 -0
- package/dist/components/Tag/Tag.js +72 -12
- package/dist/components/Tag/Tag.module.css +21 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -0
- package/dist/types/index.d.ts +64 -7
- package/package.json +3 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const IconFile = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
|
|
3
|
+
return (React.createElement("svg", { width: "25", height: "30", fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", className: color },
|
|
4
|
+
React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', strokeLinejoin: "round", d: "M14,11C12.34,11 11,9.66 11,8V4H7C5.9,4 5,4.9 5,6V19C5,20.1 5.9,21 7,21H16C17.1,21 18,20.1 18,19V11H14M12,8C12,9.1 12.9,10 14,10H17.59L12,4.41V8M7,3H12L19,10V19C19,20.66 17.66,22 16,22H7C5.34,22 4,20.66 4,19V6C4,4.34 5.34,3 7,3Z" })));
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const IconUpload = ({ color = 'inherit', htmlColor, strokeWidth, }) => {
|
|
3
|
+
return (React.createElement("svg", { width: "45", height: "45", fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", className: color },
|
|
4
|
+
React.createElement("path", { fill: htmlColor || 'currentColor', stroke: htmlColor || 'currentColor', strokeWidth: strokeWidth || '0', strokeLinejoin: "round", d: "M5.5,20C2.46,20 0,17.54 0,14.5C0,11.46 2.46,9 5.5,9C6.5,6.65 8.8,5 11.5,5C14.93,5 17.74,7.66 18,11.03L18.5,11C21,11 23,13 23,15.5C23,18 21,20 18.5,20H5.5M5.5,10C3,10 1,12 1,14.5C1,17 3,19 5.5,19H18.5C20.43,19 22,17.43 22,15.5C22,13.57 20.43,12 18.5,12C17.94,12 17.4,12.13 16.93,12.37L17,11.5C17,8.46 14.54,6 11.5,6C8.96,6 6.83,7.72 6.19,10.05L5.5,10M12,17V11.75L14.25,14L15,13.34L11.5,9.84L8,13.34L8.75,14L11,11.75V17H12Z" })));
|
|
5
|
+
};
|
package/dist/Icons/index.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export { IconWarning10 } from './IconWarning/IconWarning10';
|
|
|
14
14
|
export { IconError10 } from './IconError/IconError10';
|
|
15
15
|
export { IconClose10 } from './IconClose/IconClose10';
|
|
16
16
|
export { IconColorPicker10 } from './IconColorPicker/IconColorPicker10';
|
|
17
|
+
export { IconFile } from './IconFile/IconFile';
|
|
18
|
+
export { IconUpload } from './IconUpload/IconUpload';
|
package/dist/Icons/index.js
CHANGED
|
@@ -14,3 +14,5 @@ export { IconWarning10 } from './IconWarning/IconWarning10';
|
|
|
14
14
|
export { IconError10 } from './IconError/IconError10';
|
|
15
15
|
export { IconClose10 } from './IconClose/IconClose10';
|
|
16
16
|
export { IconColorPicker10 } from './IconColorPicker/IconColorPicker10';
|
|
17
|
+
export { IconFile } from './IconFile/IconFile';
|
|
18
|
+
export { IconUpload } from './IconUpload/IconUpload';
|
package/dist/colors.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--white: #ffffff;
|
|
3
3
|
|
|
4
|
-
--grey-medium: #
|
|
4
|
+
--grey-medium: #aeaeb2;
|
|
5
5
|
--grey-light: #e5e5ea;
|
|
6
6
|
--grey-extraLight: #f2f2f7;
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
--text-dark: #2a3336;
|
|
11
11
|
--text-btn: #6f6f6f;
|
|
12
12
|
--text-btn-light: #9ca0a7;
|
|
13
|
+
--icons-grey: #828286;
|
|
13
14
|
--icons-medium: #5a5d61;
|
|
14
15
|
--icons-light: #dce4f0;
|
|
15
16
|
--icons-active: #bfd0eb;
|
|
@@ -32,6 +33,9 @@
|
|
|
32
33
|
--info-main: #f2f2f7;
|
|
33
34
|
--info-secondary: #e5e5ea;
|
|
34
35
|
|
|
36
|
+
--fills-active: #eef8ff;
|
|
37
|
+
--fills-disabled: #f5f5f5;
|
|
38
|
+
|
|
35
39
|
--info-dark: rgb(209, 209, 214);
|
|
36
40
|
|
|
37
41
|
--green:#34c759;
|
|
@@ -1,46 +1,101 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } 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
|
|
9
|
-
const
|
|
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}`], {
|
|
12
|
+
[styles[`button--${variant}-${buttonCondition}`]]: buttonCondition && !color,
|
|
13
|
+
[styles[`button--${variant}-custom`]]: color && !error
|
|
14
|
+
});
|
|
10
15
|
const iconColorFn = () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if (buttonCondition && !color) {
|
|
17
|
+
switch (buttonCondition) {
|
|
18
|
+
case 'default':
|
|
19
|
+
if (variant === 'outline') {
|
|
20
|
+
return disabled ? '#8dc6ef' : '#0d99ff';
|
|
21
|
+
}
|
|
22
|
+
return '#FFFFFF';
|
|
23
|
+
case 'error':
|
|
24
|
+
if (variant === 'outline') {
|
|
25
|
+
return disabled ? '#ff8d87' : '#ff3b30';
|
|
26
|
+
}
|
|
27
|
+
return '#FFFFFF';
|
|
28
|
+
case 'success':
|
|
29
|
+
if (variant === 'outline') {
|
|
30
|
+
return disabled ? '#8ac99a' : '#34c759';
|
|
31
|
+
}
|
|
32
|
+
return '#FFFFFF';
|
|
33
|
+
case 'warning':
|
|
34
|
+
if (variant === 'outline') {
|
|
35
|
+
return disabled ? '#ffb44a' : '#ff9500';
|
|
36
|
+
}
|
|
37
|
+
return '#FFFFFF';
|
|
38
|
+
case 'info':
|
|
39
|
+
return disabled ? 'var(--gray-disabled)' : '#6F6F6F';
|
|
40
|
+
default:
|
|
41
|
+
return '#FFFFFF';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (color && !error) {
|
|
45
|
+
if (variant === 'outline') {
|
|
46
|
+
return disabled ? `color-mix(in srgb, ${color} 50%, white)` : color;
|
|
47
|
+
}
|
|
48
|
+
return '#FFFFFF';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
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');
|
|
25
60
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (variant === 'outline') {
|
|
29
|
-
return disabled ? '#ffb44a' : '#ff9500';
|
|
61
|
+
else {
|
|
62
|
+
setButtonStyle('default');
|
|
30
63
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return disabled ? 'var(--blue-disabled)' : '#FFFFFF';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
setButtonStyle('text');
|
|
67
|
+
}
|
|
36
68
|
}
|
|
37
|
-
};
|
|
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]);
|
|
38
83
|
const iconColorStyle = iconColorFn();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
React.
|
|
84
|
+
if (!buttonStyle) {
|
|
85
|
+
return React.createElement("button", { className: buttonClasses },
|
|
86
|
+
React.createElement(Typography, { variant: 'Body2' }, "\u041A\u043D\u043E\u043F\u043A\u0430"));
|
|
87
|
+
}
|
|
88
|
+
return (React.createElement("button", { className: buttonClasses, style: color && !error ? {
|
|
89
|
+
'--button-color': color,
|
|
90
|
+
'--button-hover-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 90%, black)` : `color-mix(in srgb, ${color} 10%, transparent)`,
|
|
91
|
+
'--button-active-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, black)` : `color-mix(in srgb, ${color} 20%, transparent)`,
|
|
92
|
+
'--button-disabled-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 10%, transparent)`,
|
|
93
|
+
'--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') &&
|
|
96
|
+
React.cloneElement(btnIcon, {
|
|
42
97
|
htmlColor: iconColorStyle,
|
|
43
98
|
strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
|
|
44
99
|
}),
|
|
45
|
-
React.createElement(Typography, { variant: 'Body2' }, label)));
|
|
100
|
+
(buttonStyle === 'text' || buttonStyle === 'default') && React.createElement(Typography, { variant: 'Body2' }, label ? label : (typeof children === 'string' && children))));
|
|
46
101
|
};
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
.button {
|
|
2
2
|
border-radius: 10px;
|
|
3
|
-
padding: 5px 10px;
|
|
4
3
|
cursor: pointer;
|
|
5
|
-
padding: 0.5em 1.5em;
|
|
6
4
|
width: fit-content;
|
|
7
|
-
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/* Общие стили для всех типов кнопок */
|
|
10
|
+
.button--default,
|
|
11
|
+
.button--text,
|
|
12
|
+
.button--icon {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
padding: calc(0.5em - 1px) calc(0.7em - 1px);
|
|
17
|
+
height: 2.5em;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
vertical-align: middle;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.button--default {
|
|
23
|
+
gap: 5px;
|
|
8
24
|
}
|
|
9
25
|
|
|
10
26
|
/* Стили для дефолтных кнопок */
|
|
@@ -12,111 +28,169 @@
|
|
|
12
28
|
.button--fill-default {
|
|
13
29
|
background-color: var(--blue-main);
|
|
14
30
|
color: var(--white);
|
|
15
|
-
border:
|
|
31
|
+
border: 1px solid transparent;
|
|
16
32
|
}
|
|
17
33
|
.button--fill-default:hover {
|
|
18
34
|
background-color: var(--blue-secondary);
|
|
19
35
|
color: var(--white);
|
|
20
|
-
border: none;
|
|
21
36
|
}
|
|
22
37
|
.button--fill-default:active {
|
|
23
38
|
background-color: var(--blue-dark);
|
|
24
39
|
color: var(--white);
|
|
25
|
-
border: none;
|
|
26
40
|
}
|
|
27
41
|
.button--fill-default:disabled {
|
|
28
42
|
background-color: var(--blue-disabled);
|
|
29
43
|
color: var(--white);
|
|
30
|
-
border: none;
|
|
31
44
|
cursor: not-allowed;
|
|
32
45
|
}
|
|
33
46
|
/* ошибка */
|
|
34
47
|
.button--fill-error {
|
|
35
48
|
background-color: var(--error-main);
|
|
36
49
|
color: var(--white);
|
|
37
|
-
border:
|
|
50
|
+
border: 1px solid transparent;
|
|
51
|
+
|
|
38
52
|
}
|
|
39
53
|
.button--fill-error:hover {
|
|
40
54
|
background-color: var(--error-secondary);
|
|
41
55
|
color: var(--white);
|
|
42
|
-
border: none;
|
|
43
56
|
}
|
|
44
57
|
.button--fill-error:active {
|
|
45
58
|
background-color: var(--error-dark);
|
|
46
59
|
color: var(--white);
|
|
47
|
-
border: none;
|
|
48
60
|
}
|
|
49
61
|
.button--fill-error:disabled {
|
|
50
62
|
background-color: var(--error-disabled);
|
|
51
63
|
color: var(--white);
|
|
52
|
-
border: none;
|
|
53
64
|
cursor: not-allowed;
|
|
54
65
|
}
|
|
55
66
|
/* success */
|
|
56
67
|
.button--fill-success {
|
|
57
68
|
background-color: var(--success-main);
|
|
58
69
|
color: var(--white);
|
|
59
|
-
border:
|
|
70
|
+
border: 1px solid transparent;
|
|
60
71
|
}
|
|
61
72
|
.button--fill-success:hover {
|
|
62
73
|
background-color: var(--success-secondary);
|
|
63
74
|
color: var(--white);
|
|
64
|
-
border: none;
|
|
65
75
|
}
|
|
66
76
|
.button--fill-success:active {
|
|
67
77
|
background-color: var(--success-dark);
|
|
68
78
|
color: var(--white);
|
|
69
|
-
border: none;
|
|
70
79
|
}
|
|
71
80
|
.button--fill-success:disabled {
|
|
72
81
|
background-color: var(--success-disabled);
|
|
73
82
|
color: var(--white);
|
|
74
|
-
border: none;
|
|
75
83
|
cursor: not-allowed;
|
|
76
84
|
}
|
|
77
85
|
/* warning */
|
|
78
86
|
.button--fill-warning {
|
|
79
87
|
background-color: var(--warning-main);
|
|
80
88
|
color: var(--white);
|
|
81
|
-
border:
|
|
89
|
+
border: 1px solid transparent;
|
|
82
90
|
}
|
|
83
91
|
.button--fill-warning:hover {
|
|
84
92
|
background-color: var(--warning-secondary);
|
|
85
93
|
color: var(--white);
|
|
86
|
-
border: none;
|
|
87
94
|
}
|
|
88
95
|
.button--fill-warning:active {
|
|
89
96
|
background-color: var(--warning-dark);
|
|
90
97
|
color: var(--white);
|
|
91
|
-
border: none;
|
|
92
98
|
}
|
|
93
99
|
.button--fill-warning:disabled {
|
|
94
100
|
background-color: var(--warning-disabled);
|
|
95
101
|
color: var(--white);
|
|
96
|
-
border: none;
|
|
97
102
|
cursor: not-allowed;
|
|
98
103
|
}
|
|
99
104
|
/* info */
|
|
100
105
|
.button--fill-info {
|
|
101
106
|
background-color: var(--info-main);
|
|
102
107
|
color: var(--text-btn);
|
|
103
|
-
border:
|
|
108
|
+
border: 1px solid transparent;
|
|
104
109
|
}
|
|
105
110
|
.button--fill-info:hover {
|
|
106
111
|
background-color: var(--info-secondary);
|
|
107
112
|
color: var(--text-btn);
|
|
108
|
-
border: none;
|
|
109
113
|
}
|
|
110
114
|
.button--fill-info:active {
|
|
111
115
|
background-color: var(--info-dark);
|
|
112
116
|
color: var(--text-btn);
|
|
113
|
-
border: none;
|
|
114
117
|
}
|
|
115
118
|
.button--fill-info:disabled {
|
|
116
119
|
background-color: var(--info-main);
|
|
117
120
|
color: var(--text-btn-light);
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/*--Для пользовательского цвета--*/
|
|
125
|
+
.button--fill-custom {
|
|
126
|
+
background-color: var(--button-color);
|
|
127
|
+
color: var(--white);
|
|
128
|
+
border: 1px solid transparent;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.button--fill-custom:hover {
|
|
132
|
+
background-color: var(--button-hover-color);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.button--fill-custom:active {
|
|
136
|
+
background-color: var(--button-active-color);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.button--fill-custom:disabled {
|
|
140
|
+
background-color: var(--button-disabled-color);
|
|
141
|
+
cursor: not-allowed;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.button--outline-custom {
|
|
145
|
+
background-color: transparent;
|
|
146
|
+
color: var(--button-color);
|
|
147
|
+
border: 1px solid var(--button-color);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.button--outline-custom:hover {
|
|
151
|
+
background-color: var(--button-hover-color);
|
|
152
|
+
color: var(--button-color);
|
|
153
|
+
border: 1px solid var(--button-color);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.button--outline-custom:active {
|
|
157
|
+
background-color: var(--button-active-color);
|
|
158
|
+
color: var(--button-color);
|
|
159
|
+
border: 1px solid var(--button-color);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.button--outline-custom:disabled {
|
|
163
|
+
background-color: var(--button-disabled-color);
|
|
164
|
+
color: var(--button-disabled-textColor);
|
|
165
|
+
border: 1px solid var(--button-disabled-textColor);
|
|
166
|
+
cursor: not-allowed;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.button--link-custom {
|
|
170
|
+
background-color: rgba(255, 255, 255, 0);
|
|
171
|
+
color: var(--button-color);
|
|
172
|
+
border: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.button--link-custom:hover {
|
|
176
|
+
background-color: rgba(255, 255, 255, 0);
|
|
177
|
+
color: var(--button-hover-color);
|
|
178
|
+
border: none;
|
|
179
|
+
text-decoration: underline;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.button--link-custom:active {
|
|
183
|
+
background-color: rgba(255, 255, 255, 0);
|
|
184
|
+
color: var(--button-active-color);
|
|
185
|
+
border: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.button--link-custom:disabled {
|
|
189
|
+
background-color: rgba(255, 255, 255, 0);
|
|
190
|
+
color: var(--button-disabled-color);
|
|
118
191
|
border: none;
|
|
119
192
|
cursor: not-allowed;
|
|
193
|
+
text-decoration: none;
|
|
120
194
|
}
|
|
121
195
|
|
|
122
196
|
/* Стили для outline кнопок */
|
|
@@ -245,6 +319,7 @@
|
|
|
245
319
|
border: none;
|
|
246
320
|
background-color: rgba(255, 255, 255, 0);
|
|
247
321
|
cursor: not-allowed;
|
|
322
|
+
text-decoration: none;
|
|
248
323
|
}
|
|
249
324
|
.button--link-error {
|
|
250
325
|
color: var(--error-main);
|
|
@@ -273,6 +348,7 @@
|
|
|
273
348
|
border: none;
|
|
274
349
|
background-color: rgba(255, 255, 255, 0);
|
|
275
350
|
cursor: not-allowed;
|
|
351
|
+
text-decoration: none;
|
|
276
352
|
}
|
|
277
353
|
.button--link-warning {
|
|
278
354
|
color: var(--warning-main);
|
|
@@ -287,6 +363,7 @@
|
|
|
287
363
|
border: none;
|
|
288
364
|
background-color: rgba(255, 255, 255, 0);
|
|
289
365
|
cursor: not-allowed;
|
|
366
|
+
text-decoration: none;
|
|
290
367
|
}
|
|
291
368
|
.button--link-info {
|
|
292
369
|
color: var(--text-btn);
|
|
@@ -301,32 +378,18 @@
|
|
|
301
378
|
border: none;
|
|
302
379
|
background-color: rgba(255, 255, 255, 0);
|
|
303
380
|
cursor: not-allowed;
|
|
381
|
+
text-decoration: none;
|
|
304
382
|
}
|
|
305
383
|
|
|
306
384
|
/* Размеры кнопок */
|
|
307
385
|
.button--sm {
|
|
308
|
-
/* font-size: 0.8rem; */
|
|
309
386
|
font-size: 12px;
|
|
310
387
|
}
|
|
311
388
|
.button--md {
|
|
312
|
-
/* font-size: 1rem; */
|
|
313
389
|
font-size: 14px;
|
|
314
390
|
}
|
|
315
391
|
.button--lg {
|
|
316
|
-
/* font-size: 1.2rem; */
|
|
317
392
|
font-size: 16px;
|
|
318
393
|
}
|
|
319
394
|
|
|
320
|
-
|
|
321
|
-
.button--default {
|
|
322
|
-
display: flex;
|
|
323
|
-
align-items: center;
|
|
324
|
-
gap: 5px;
|
|
325
|
-
padding: 0.5em 1em 0.5em 0.7em;
|
|
326
|
-
}
|
|
327
|
-
.button--text {
|
|
328
|
-
padding: 0.5em 1em;
|
|
329
|
-
}
|
|
330
|
-
.button--icon {
|
|
331
|
-
padding: 0.5em 0.7em;
|
|
332
|
-
}
|
|
395
|
+
|
|
@@ -6,10 +6,60 @@ import EditableInput from '@uiw/react-color-editable-input';
|
|
|
6
6
|
import { GithubPlacement } from '@uiw/react-color-github';
|
|
7
7
|
import { IconColorPicker10 } from '../../Icons';
|
|
8
8
|
;
|
|
9
|
+
// Функция для преобразования HEXA в HEX
|
|
10
|
+
const hexaToHex = (hexa = 'fff') => {
|
|
11
|
+
const cleanHex = hexa.replace('#', '');
|
|
12
|
+
if (cleanHex.length >= 8) {
|
|
13
|
+
return `#${cleanHex.slice(0, 6)}`;
|
|
14
|
+
}
|
|
15
|
+
if (cleanHex.length === 6) {
|
|
16
|
+
return `#${cleanHex}`;
|
|
17
|
+
}
|
|
18
|
+
if (cleanHex.length === 3) {
|
|
19
|
+
return `#${cleanHex[0]}${cleanHex[0]}${cleanHex[1]}${cleanHex[1]}${cleanHex[2]}${cleanHex[2]}`;
|
|
20
|
+
}
|
|
21
|
+
if (cleanHex.length < 6) {
|
|
22
|
+
return `#${cleanHex + '0'.repeat(6 - cleanHex.length)}`;
|
|
23
|
+
}
|
|
24
|
+
return '#ffffff';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Функция-обертка. Вызывает функцию-колбэк через заданный промежуток времени после того, как мышь покинет область
|
|
28
|
+
* @param callback функция-колбэк
|
|
29
|
+
* @param delay время в мс, через которое будет вызвана функция
|
|
30
|
+
*/
|
|
31
|
+
const mouseLeaveTimer = (callback, delay) => {
|
|
32
|
+
let timer = null;
|
|
33
|
+
function wrapper(element) {
|
|
34
|
+
const handleMouseLeave = () => {
|
|
35
|
+
timer = setTimeout(() => {
|
|
36
|
+
callback();
|
|
37
|
+
timer = null;
|
|
38
|
+
}, delay);
|
|
39
|
+
};
|
|
40
|
+
const handleMouseEnter = () => {
|
|
41
|
+
if (timer) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
timer = null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
element.addEventListener('mouseleave', handleMouseLeave);
|
|
47
|
+
element.addEventListener('mouseenter', handleMouseEnter);
|
|
48
|
+
// функция очистки
|
|
49
|
+
return function cleanup() {
|
|
50
|
+
element.removeEventListener('mouseleave', handleMouseLeave);
|
|
51
|
+
element.removeEventListener('mouseenter', handleMouseEnter);
|
|
52
|
+
if (timer) {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return wrapper;
|
|
58
|
+
};
|
|
9
59
|
/**
|
|
10
60
|
* Компонент ColorPicker представляет собой элемент управления для выбора цвета.
|
|
11
61
|
*/
|
|
12
|
-
export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsHovered, width = 10, height = 10, autoOpen = false, onChange, }) => {
|
|
62
|
+
export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsHovered, width = 10, height = 10, autoOpen = false, onChange, onColorChange, }) => {
|
|
13
63
|
const [colorValue, setColorValue] = useState(mainColor);
|
|
14
64
|
const [selectedColor, setSelectedColor] = useState(color);
|
|
15
65
|
const [isColorChanged, setIsColorChanged] = useState(false);
|
|
@@ -17,6 +67,26 @@ export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsH
|
|
|
17
67
|
const [popoverPosition, setPopoverPosition] = useState('bottom');
|
|
18
68
|
const circleRef = useRef(null);
|
|
19
69
|
const popoverRef = useRef(null);
|
|
70
|
+
const divRef = useRef(null);
|
|
71
|
+
const mainColorClasses = classNames(styles.circle, {
|
|
72
|
+
[styles['mainColor']]: mainColor,
|
|
73
|
+
});
|
|
74
|
+
const colorCircleDefaultClasses = classNames(styles.circle, styles.colorCircleDefault);
|
|
75
|
+
const popoverClassess = classNames(styles['popover'], {
|
|
76
|
+
[styles[`popover--${popoverPosition}`]]: true,
|
|
77
|
+
});
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!divRef.current)
|
|
80
|
+
return;
|
|
81
|
+
const setTimer = mouseLeaveTimer(() => {
|
|
82
|
+
setIsHovered(false);
|
|
83
|
+
if (onChange) {
|
|
84
|
+
onChange(colorValue || color);
|
|
85
|
+
}
|
|
86
|
+
}, 800);
|
|
87
|
+
const cleanup = setTimer(divRef.current);
|
|
88
|
+
return cleanup;
|
|
89
|
+
}, []);
|
|
20
90
|
useEffect(() => {
|
|
21
91
|
// Обработчик клика вне компонента развертывания выбора цвета
|
|
22
92
|
const handleClickOutside = (event) => {
|
|
@@ -51,58 +121,32 @@ export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsH
|
|
|
51
121
|
!autoOpen && document.removeEventListener('mousedown', handleClickOutside);
|
|
52
122
|
};
|
|
53
123
|
}, [isOpen]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
const colorCircleDefaultClasses = classNames(styles.circle, {
|
|
58
|
-
[styles.colorCircleDefault]: color === '#ffffff' && !isColorChanged || isColorChanged && selectedColor !== colorValue
|
|
59
|
-
});
|
|
60
|
-
const popoverClassess = classNames(styles['popover'], {
|
|
61
|
-
[styles[`popover--${popoverPosition}`]]: true,
|
|
62
|
-
});
|
|
63
|
-
// Функция для преобразования HEXA в HEX
|
|
64
|
-
const hexaToHex = (hexa = 'fff') => {
|
|
65
|
-
const cleanHex = hexa.replace('#', '');
|
|
66
|
-
if (cleanHex.length >= 8) {
|
|
67
|
-
return `#${cleanHex.slice(0, 6)}`;
|
|
68
|
-
}
|
|
69
|
-
if (cleanHex.length === 6) {
|
|
70
|
-
return `#${cleanHex}`;
|
|
71
|
-
}
|
|
72
|
-
if (cleanHex.length === 3) {
|
|
73
|
-
return `#${cleanHex[0]}${cleanHex[0]}${cleanHex[1]}${cleanHex[1]}${cleanHex[2]}${cleanHex[2]}`;
|
|
74
|
-
}
|
|
75
|
-
if (cleanHex.length < 6) {
|
|
76
|
-
return `#${cleanHex + '0'.repeat(6 - cleanHex.length)}`;
|
|
77
|
-
}
|
|
78
|
-
return '#ffffff';
|
|
79
|
-
};
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
setSelectedColor(colorValue || color);
|
|
126
|
+
}, [colorValue]);
|
|
80
127
|
const colorChangeHandler = (color) => {
|
|
81
128
|
const newColor = typeof color === 'string' ? color : color.hexa;
|
|
82
129
|
setIsColorChanged(true);
|
|
83
130
|
setColorValue(newColor);
|
|
84
131
|
setSelectedColor(newColor);
|
|
85
|
-
|
|
132
|
+
onColorChange(newColor);
|
|
86
133
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, [color]);
|
|
90
|
-
return (React.createElement("div", { className: (mainColor || recentColors) && styles.colorPickerWrapper, onMouseLeave: () => setIsHovered && setIsHovered(false) },
|
|
91
|
-
mainColor && React.createElement("div", { className: mainColorClasses, style: {
|
|
134
|
+
return (React.createElement("div", { className: (mainColor || recentColors) && styles.colorPickerWrapper, ref: divRef },
|
|
135
|
+
mainColor && (React.createElement("div", { className: mainColorClasses, style: {
|
|
92
136
|
width: `${width}px`,
|
|
93
137
|
height: `${height}px`,
|
|
94
138
|
backgroundColor: (colorValue === null || colorValue === void 0 ? void 0 : colorValue.startsWith('#')) ? colorValue : `var(--${colorValue})`,
|
|
95
|
-
}
|
|
96
|
-
recentColors &&
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
139
|
+
} })),
|
|
140
|
+
recentColors &&
|
|
141
|
+
recentColors.map((color, index) => (React.createElement("div", { key: index, className: styles.circle, style: {
|
|
142
|
+
width: `${width}px`,
|
|
143
|
+
height: `${height}px`,
|
|
144
|
+
backgroundColor: color.startsWith('#') ? color : `var(--${color})`,
|
|
145
|
+
}, onClick: () => colorChangeHandler(color) }))),
|
|
101
146
|
React.createElement("div", { className: styles.colorPicker },
|
|
102
147
|
React.createElement("div", { ref: circleRef, className: colorCircleDefaultClasses, onClick: () => setIsOpen(!isOpen), style: {
|
|
103
148
|
width: `${width}px`,
|
|
104
149
|
height: `${height}px`,
|
|
105
|
-
backgroundColor: selectedColor.startsWith('#') ? selectedColor : `var(--${selectedColor})`,
|
|
106
150
|
} }),
|
|
107
151
|
isOpen && (React.createElement("div", { ref: popoverRef, className: popoverClassess },
|
|
108
152
|
isOpen && React.createElement(IconColorPicker10, { className: styles.colorPickerIcon, htmlColor: 'var(--white)' }),
|
|
@@ -8,7 +8,7 @@ export interface DropdownListItemProps {
|
|
|
8
8
|
getOptionLabel?: ((option: TOptions) => string);
|
|
9
9
|
size: 'md' | 'lg';
|
|
10
10
|
selectedItem: TOptions | null;
|
|
11
|
-
|
|
11
|
+
variant?: 'icons' | 'text';
|
|
12
12
|
onChange: (event: React.MouseEvent<HTMLElement>, item: TOptions | null) => void;
|
|
13
13
|
isActive?: boolean;
|
|
14
14
|
activeIndex?: number;
|