kamotive_ui 1.2.2 → 1.2.4

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 (70) hide show
  1. package/dist/Icons/IconClose/IconClose10.d.ts +2 -1
  2. package/dist/Icons/IconClose/IconClose10.js +2 -2
  3. package/dist/Icons/IconFile/IconFile.d.ts +6 -0
  4. package/dist/Icons/IconFile/IconFile.js +5 -0
  5. package/dist/Icons/IconUpload/IconUpload.d.ts +6 -0
  6. package/dist/Icons/IconUpload/IconUpload.js +5 -0
  7. package/dist/Icons/index.d.ts +2 -0
  8. package/dist/Icons/index.js +2 -0
  9. package/dist/colors.css +5 -1
  10. package/dist/components/Button/Button.d.ts +1 -1
  11. package/dist/components/Button/Button.js +87 -35
  12. package/dist/components/Button/Button.module.css +101 -49
  13. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  14. package/dist/components/Checkbox/Checkbox.js +5 -3
  15. package/dist/components/Checkbox/Checkbox.module.css +0 -11
  16. package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
  17. package/dist/components/ColorPicker/ColorPicker.js +89 -44
  18. package/dist/components/ColorPicker/ColorPicker.module.css +25 -42
  19. package/dist/components/Dropdown/Dropdown.d.ts +12 -8
  20. package/dist/components/Dropdown/Dropdown.js +239 -77
  21. package/dist/components/Dropdown/Dropdown.module.css +152 -89
  22. package/dist/components/FileAttach/FileAttach.d.ts +3 -0
  23. package/dist/components/FileAttach/FileAttach.js +79 -0
  24. package/dist/components/FileAttach/FileAttach.module.css +36 -0
  25. package/dist/components/Input/Input.d.ts +1 -1
  26. package/dist/components/Input/Input.js +36 -25
  27. package/dist/components/Input/Input.module.css +92 -45
  28. package/dist/components/Loader/Loader.d.ts +3 -0
  29. package/dist/components/Loader/Loader.js +18 -0
  30. package/dist/components/Loader/Loader.module.css +75 -0
  31. package/dist/components/ProgressBar/ProgressBar.d.ts +1 -1
  32. package/dist/components/ProgressBar/ProgressBar.js +5 -4
  33. package/dist/components/ProgressBar/ProgressBar.module.css +4 -11
  34. package/dist/components/ProgressLoader/ProgressLoader.d.ts +1 -1
  35. package/dist/components/ProgressLoader/ProgressLoader.js +3 -2
  36. package/dist/components/ProgressLoader/ProgressLoader.module.css +2 -11
  37. package/dist/components/RadioButton/RadioButton.d.ts +1 -1
  38. package/dist/components/RadioButton/RadioButton.js +5 -3
  39. package/dist/components/RadioButton/RadioButton.module.css +2 -15
  40. package/dist/components/SettingTag/SettingTag.d.ts +1 -1
  41. package/dist/components/SettingTag/SettingTag.js +7 -6
  42. package/dist/components/SettingTag/SettingTag.module.css +0 -9
  43. package/dist/components/Snackbar/Snackbar.d.ts +1 -1
  44. package/dist/components/Snackbar/Snackbar.js +3 -2
  45. package/dist/components/Snackbar/Snackbar.module.css +1 -9
  46. package/dist/components/Spinner/Spinner.d.ts +3 -0
  47. package/dist/components/Spinner/Spinner.js +30 -0
  48. package/dist/components/Spinner/Spinner.module.css +20 -0
  49. package/dist/components/Tab/Tab.d.ts +1 -1
  50. package/dist/components/Tab/Tab.js +7 -4
  51. package/dist/components/Tab/Tab.module.css +4 -17
  52. package/dist/components/Tabs/Tabs.d.ts +1 -1
  53. package/dist/components/Tabs/Tabs.js +2 -1
  54. package/dist/components/Tabs/Tabs.module.css +0 -6
  55. package/dist/components/Tag/Tag.d.ts +1 -1
  56. package/dist/components/Tag/Tag.js +74 -13
  57. package/dist/components/Tag/Tag.module.css +89 -74
  58. package/dist/components/ToggleButton/ToggleButton.d.ts +1 -1
  59. package/dist/components/ToggleButton/ToggleButton.js +6 -4
  60. package/dist/components/ToggleButton/ToggleButton.module.css +0 -5
  61. package/dist/components/Typography/Typography.d.ts +1 -1
  62. package/dist/components/Typography/Typography.js +3 -2
  63. package/dist/components/Typography/Typography.module.css +8 -13
  64. package/dist/components/Typography/enums.d.ts +2 -0
  65. package/dist/components/Typography/enums.js +2 -0
  66. package/dist/index.d.ts +11 -7
  67. package/dist/index.js +10 -7
  68. package/dist/types/index.d.ts +310 -0
  69. package/dist/types/index.js +1 -0
  70. package/package.json +4 -2
@@ -5,10 +5,61 @@ import { Chrome } from '@uiw/react-color';
5
5
  import EditableInput from '@uiw/react-color-editable-input';
6
6
  import { GithubPlacement } from '@uiw/react-color-github';
7
7
  import { IconColorPicker10 } from '../../Icons';
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
+ };
8
59
  /**
9
60
  * Компонент ColorPicker представляет собой элемент управления для выбора цвета.
10
61
  */
11
- 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, }) => {
12
63
  const [colorValue, setColorValue] = useState(mainColor);
13
64
  const [selectedColor, setSelectedColor] = useState(color);
14
65
  const [isColorChanged, setIsColorChanged] = useState(false);
@@ -16,6 +67,26 @@ export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsH
16
67
  const [popoverPosition, setPopoverPosition] = useState('bottom');
17
68
  const circleRef = useRef(null);
18
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
+ }, []);
19
90
  useEffect(() => {
20
91
  // Обработчик клика вне компонента развертывания выбора цвета
21
92
  const handleClickOutside = (event) => {
@@ -50,63 +121,37 @@ export const ColorPicker = ({ color = '#ffffff', mainColor, recentColors, setIsH
50
121
  !autoOpen && document.removeEventListener('mousedown', handleClickOutside);
51
122
  };
52
123
  }, [isOpen]);
53
- const mainColorClasses = classNames(styles['circle'], {
54
- 'mainColor': mainColor,
55
- });
56
- const colorCircleDefaultClasses = classNames(styles['circle'], {
57
- 'colorCircleDefault': color === '#ffffff' && !isColorChanged || isColorChanged && selectedColor !== colorValue
58
- });
59
- const popoverClassess = classNames(styles['popover'], {
60
- [`popover--${popoverPosition}`]: true,
61
- });
62
- // Функция для преобразования HEXA в HEX
63
- const hexaToHex = (hexa = 'fff') => {
64
- const cleanHex = hexa.replace('#', '');
65
- if (cleanHex.length >= 8) {
66
- return `#${cleanHex.slice(0, 6)}`;
67
- }
68
- if (cleanHex.length === 6) {
69
- return `#${cleanHex}`;
70
- }
71
- if (cleanHex.length === 3) {
72
- return `#${cleanHex[0]}${cleanHex[0]}${cleanHex[1]}${cleanHex[1]}${cleanHex[2]}${cleanHex[2]}`;
73
- }
74
- if (cleanHex.length < 6) {
75
- return `#${cleanHex + '0'.repeat(6 - cleanHex.length)}`;
76
- }
77
- return '#ffffff';
78
- };
124
+ useEffect(() => {
125
+ setSelectedColor(colorValue || color);
126
+ }, [colorValue]);
79
127
  const colorChangeHandler = (color) => {
80
128
  const newColor = typeof color === 'string' ? color : color.hexa;
81
129
  setIsColorChanged(true);
82
130
  setColorValue(newColor);
83
131
  setSelectedColor(newColor);
84
- onChange === null || onChange === void 0 ? void 0 : onChange(newColor);
132
+ onColorChange(newColor);
85
133
  };
86
- useEffect(() => {
87
- setSelectedColor(color);
88
- }, [color]);
89
- return (React.createElement("div", { className: (mainColor || recentColors) ? 'colorPickerWrapper' : '', onMouseLeave: () => setIsHovered && setIsHovered(false) },
90
- 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: {
91
136
  width: `${width}px`,
92
137
  height: `${height}px`,
93
138
  backgroundColor: (colorValue === null || colorValue === void 0 ? void 0 : colorValue.startsWith('#')) ? colorValue : `var(--${colorValue})`,
94
- }, onClick: () => setIsHovered && setIsHovered(false) }),
95
- recentColors && recentColors.map((color, index) => (React.createElement("div", { key: index, className: "circle", style: {
96
- width: `${width}px`,
97
- height: `${height}px`,
98
- backgroundColor: color.startsWith('#') ? color : `var(--${color})`,
99
- }, onClick: () => colorChangeHandler(color) }))),
100
- React.createElement("div", { className: "colorPicker" },
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) }))),
146
+ React.createElement("div", { className: styles.colorPicker },
101
147
  React.createElement("div", { ref: circleRef, className: colorCircleDefaultClasses, onClick: () => setIsOpen(!isOpen), style: {
102
148
  width: `${width}px`,
103
149
  height: `${height}px`,
104
- backgroundColor: selectedColor.startsWith('#') ? selectedColor : `var(--${selectedColor})`,
105
150
  } }),
106
151
  isOpen && (React.createElement("div", { ref: popoverRef, className: popoverClassess },
107
- isOpen && React.createElement(IconColorPicker10, { className: "colorPickerIcon", htmlColor: 'var(--white)' }),
108
- React.createElement(Chrome, { color: selectedColor, placement: GithubPlacement.Right, onChange: colorChangeHandler, className: "customChrome", showEyeDropper: false }),
109
- React.createElement("div", { className: "hex", style: { padding: '0 10px 0 20px' } },
152
+ isOpen && React.createElement(IconColorPicker10, { className: styles.colorPickerIcon, htmlColor: 'var(--white)' }),
153
+ React.createElement(Chrome, { color: selectedColor, placement: GithubPlacement.Right, onChange: colorChangeHandler, className: styles.customChrome, showEyeDropper: false }),
154
+ React.createElement("div", { className: styles.hex, style: { padding: '0 10px 0 20px' } },
110
155
  React.createElement(EditableInput, { value: hexaToHex(selectedColor), style: { width: 68, alignItems: 'flex-start' }, onChange: (e, color) => {
111
156
  const formattedColor = hexaToHex(color.toString());
112
157
  colorChangeHandler(formattedColor);
@@ -1,9 +1,3 @@
1
- .story--wrapper-colorpicker {
2
- background-color: var(--white);
3
- padding: 30px;
4
- border-radius: 10px;
5
- width: 900px;
6
- }
7
1
 
8
2
  .colorPicker {
9
3
  -webkit-appearance: none;
@@ -13,11 +7,6 @@
13
7
  position: relative;
14
8
  cursor: pointer;
15
9
  padding: 0;
16
- font-family: 'Raleway';
17
- font-style: normal;
18
- font-weight: 400;
19
- line-height: 16.5px;
20
- font-size: 16px;
21
10
  }
22
11
 
23
12
  .colorPicker:hover{
@@ -25,13 +14,8 @@
25
14
  background-color: var(--white);
26
15
  border-radius: 50%;
27
16
  padding: 0;
28
- font-family: 'Raleway';
29
- font-style: normal;
30
- font-weight: 400;
31
- line-height: 16.5px;
32
- font-size: 16px;
33
-
34
17
  }
18
+
35
19
  .colorPicker--defaultColor{
36
20
  background: conic-gradient(
37
21
  rgba(255, 59, 48) 0deg,
@@ -143,7 +127,7 @@
143
127
  z-index: 100;
144
128
  }
145
129
 
146
- .w-color-swatch{
130
+ :global(.w-color-swatch){
147
131
  padding: 10px !important;
148
132
  border-radius: 10px !important;
149
133
  width: fit-content !important;
@@ -154,73 +138,72 @@
154
138
  --github-border: 0px !important;
155
139
  }
156
140
 
157
- .w-color-swatch > div:nth-child(1),
158
- .w-color-swatch > div:nth-child(2){
141
+ :global(.w-color-swatch) > div:nth-child(1),
142
+ :global(.w-color-swatch) > div:nth-child(2){
159
143
  display: none !important;
160
144
  }
161
- .w-color-swatch > div:nth-child(3) {
145
+ :global(.w-color-swatch) > div:nth-child(3) {
162
146
  width: 195px !important;
163
147
  height: 195px !important;
164
148
  border-radius: 10px !important;
165
149
  }
166
150
 
167
- .w-color-swatch > div:nth-child(4){
151
+ :global(.w-color-swatch) > div:nth-child(4){
168
152
  gap: 15px !important;
169
153
  padding: 10px 0 !important;
170
154
  /* width: 80%; */
171
155
  }
172
- .w-color-swatch > div:nth-child(5){
156
+ :global(.w-color-swatch) > div:nth-child(5){
173
157
  padding: 0 !important;
174
158
 
175
159
  }
176
- .w-color-swatch > div:nth-child(5) > div:nth-child(2){
160
+ :global(.w-color-swatch) > div:nth-child(5) > div:nth-child(2){
177
161
  display: none !important;
178
162
  /* width: 80%; */
179
163
  }
180
164
  /* Для всех инпутов в пикере */
181
- .w-color-chrome .w-color-editable-input input {
165
+ :global(.w-color-chrome) :global(.w-color-editable-input) input {
182
166
  font-family: 'Raleway' !important;
183
167
  font-style: normal !important;
184
168
  font-weight: 400 !important;
185
169
  line-height: 14px !important;
186
170
  font-size: 12px !important;
187
171
  margin: 0 !important;
188
- }
189
- .w-color-editable-input{
172
+ }
173
+ :global(.w-color-editable-input){
190
174
  margin: 0 !important;
191
175
  max-width: 30px !important;
192
176
  flex-direction: column-reverse !important;
193
177
  --editable-input-box-shadow : none !important;
194
178
  }
195
- .w-color-editable-input-rgba{
179
+ :global(.w-color-editable-input-rgba){
196
180
  justify-content: end !important;
197
181
  }
198
182
 
199
- .w-color-editable-input > span {
183
+ :global(.w-color-editable-input) > span {
200
184
  padding-top: 0 !important;
201
185
  }
202
- .w-color-editable-input:nth-child(1)> input{
186
+ :global(.w-color-editable-input:nth-child(1))> input{
203
187
  border-radius: 10px 0 0 10px !important;
204
- border: 1px solid var(--grey-light) !important;
188
+ border: 1px solid var(--grey-light) !important;
205
189
  }
206
- .w-color-editable-input:nth-child(2)> input{
190
+ :global(.w-color-editable-input:nth-child(2))> input{
207
191
  border-radius: 0 0 0 0px !important;
208
192
  border: 1px solid var(--grey-light) !important;
209
193
  border-left: none !important;
210
194
  }
211
- .w-color-editable-input:nth-child(3)> input{
195
+ :global(.w-color-editable-input:nth-child(3))> input{
212
196
  border-radius: 0 0 0 0px !important;
213
-
214
197
  border: 1px solid var(--grey-light) !important;
215
198
  border-left: none !important;
216
199
  }
217
- .w-color-editable-input:nth-child(4)> input{
200
+ :global(.w-color-editable-input:nth-child(4))> input{
218
201
  border-radius: 0px 10px 10px 0px !important;
219
202
  border: 1px solid var(--grey-light) !important;
220
203
  border-left: none !important;
221
204
  }
222
205
  /* Для лейблов */
223
- .w-color-chrome-fields.w-color-editable-input label {
206
+ :global(.w-color-chrome-fields) :global(.w-color-editable-input) label {
224
207
  font-family: 'Raleway' !important;
225
208
  font-style: normal !important;
226
209
  font-weight: 400 !important;
@@ -228,19 +211,19 @@ border-left: none !important;
228
211
  font-size: 16px !important;
229
212
  }
230
213
 
231
- .w-color-alpha-horizontal > div.w-color-interactive{
214
+ :global(.w-color-alpha-horizontal > div.w-color-interactive){
232
215
  border-radius: 8px !important;
233
216
  }
234
- .w-color-alpha-horizontal:first-of-type > div:first-child{
217
+ :global(.w-color-alpha-horizontal:first-of-type > div:first-child){
235
218
  border-radius: 50px !important;
236
219
  }
237
- .w-color-alpha-horizontal:nth-of-type(2) > div:first-child{
220
+ :global(.w-color-alpha-horizontal:nth-of-type(2) > div:first-child){
238
221
  border-radius: 50px !important;
239
222
  }
240
223
 
241
224
  .colorPickerIcon {
242
225
  position: absolute;
243
- top: 68%;
226
+ top: 69%;
244
227
  left: 8px;
245
228
  z-index: 200;
246
229
  padding: 10px;
@@ -251,10 +234,10 @@ border-left: none !important;
251
234
  bottom: 20px;
252
235
  left: -10px;
253
236
  }
254
- .hex .w-color-editable-input{
237
+ .hex :global(.w-color-editable-input){
255
238
  border-radius: 10px !important;
256
239
  }
257
- .hex > .w-color-editable-input > input {
240
+ .hex > :global(.w-color-editable-input) > input {
258
241
  /* padding: 0 !important; */
259
242
  font-size: 12px !important;
260
243
  font-family: 'Raleway' !important;
@@ -1,14 +1,18 @@
1
- import { FC } from 'react';
2
- import { DropdownProps } from 'kamotive_ui';
1
+ import React, { FC } from 'react';
2
+ import { DropdownProps, TOptions } from '../../types';
3
3
  /**
4
4
  * Компонент Dropdown позволяет пользователям выбирать однин вариант из выпадающего меню
5
- */
5
+ */
6
6
  export interface DropdownListItemProps {
7
- item: DropdownProps['items'][number];
8
- size: 'sm' | 'md' | 'lg';
9
- selectedItem: DropdownProps['items'][number] | null | string | number;
10
- style?: 'default' | 'text';
11
- onChange: (value: DropdownProps['items'][number]) => void;
7
+ item: TOptions | null;
8
+ getOptionLabel?: ((option: TOptions) => string);
9
+ size: 'md' | 'lg';
10
+ selectedItem: TOptions | null;
11
+ style?: 'icons' | 'text';
12
+ onChange: (event: React.MouseEvent<HTMLElement>, item: TOptions | null) => void;
13
+ isActive?: boolean;
14
+ activeIndex?: number;
15
+ index?: number;
12
16
  }
13
17
  export declare const DropdownListItem: FC<DropdownListItemProps>;
14
18
  export declare const Dropdown: FC<DropdownProps>;