kamotive_ui 1.2.0 → 1.2.2
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/ChevronDown/ChevronDown10.d.ts +6 -0
- package/dist/Icons/ChevronDown/ChevronDown10.js +5 -0
- package/dist/Icons/ChevronUp/ChevronUp10.d.ts +6 -0
- package/dist/Icons/ChevronUp/ChevronUp10.js +5 -0
- package/dist/Icons/IconAccount/IconAccount10.d.ts +6 -0
- package/dist/Icons/IconAccount/IconAccount10.js +5 -0
- package/dist/Icons/IconAlarm/IconAlarm10.d.ts +6 -0
- package/dist/Icons/IconAlarm/IconAlarm10.js +5 -0
- package/dist/Icons/IconBank/IconBank10.d.ts +6 -0
- package/dist/Icons/IconBank/IconBank10.js +5 -0
- package/dist/Icons/IconBell/IconBell10.d.ts +6 -0
- package/dist/Icons/IconBell/IconBell10.js +5 -0
- package/dist/Icons/IconBriefcase/IconBriefcase10.d.ts +6 -0
- package/dist/Icons/IconBriefcase/IconBriefcase10.js +5 -0
- package/dist/Icons/IconCalendar/IconCalendar10.d.ts +6 -0
- package/dist/Icons/IconCalendar/IconCalendar10.js +5 -0
- package/dist/Icons/IconCheck/IconCheck10.d.ts +6 -0
- package/dist/Icons/IconCheck/IconCheck10.js +5 -0
- package/dist/Icons/IconClose/IconClose10.d.ts +6 -0
- package/dist/Icons/IconClose/IconClose10.js +5 -0
- package/dist/Icons/IconColorPicker/IconColorPicker10.d.ts +7 -0
- package/dist/Icons/IconColorPicker/IconColorPicker10.js +5 -0
- package/dist/Icons/IconError/IconError10.d.ts +6 -0
- package/dist/Icons/IconError/IconError10.js +5 -0
- package/dist/Icons/IconEyeOff/IconEyeOff10.d.ts +6 -0
- package/dist/Icons/IconEyeOff/IconEyeOff10.js +5 -0
- package/dist/Icons/IconInfo/IconInfo10.d.ts +6 -0
- package/dist/Icons/IconInfo/IconInfo10.js +5 -0
- package/dist/Icons/IconSuccess/IconSuccess10.d.ts +6 -0
- package/dist/Icons/IconSuccess/IconSuccess10.js +5 -0
- package/dist/Icons/IconWarning/IconWarning10.d.ts +6 -0
- package/dist/Icons/IconWarning/IconWarning10.js +5 -0
- package/dist/Icons/index.d.ts +16 -0
- package/dist/Icons/index.js +16 -0
- package/dist/Intro/Welcome.d.ts +2 -0
- package/dist/Intro/Welcome.js +7 -0
- package/dist/Intro/Welcome.module.css +19 -0
- package/dist/colors.css +78 -0
- package/dist/components/Button/Button.d.ts +6 -0
- package/dist/components/Button/Button.js +49 -0
- package/dist/components/Button/Button.module.css +343 -0
- package/dist/components/Checkbox/Checkbox.d.ts +3 -0
- package/dist/components/Checkbox/Checkbox.js +13 -0
- package/dist/components/Checkbox/Checkbox.module.css +78 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +7 -0
- package/dist/components/ColorPicker/ColorPicker.js +115 -0
- package/dist/components/ColorPicker/ColorPicker.module.css +266 -0
- package/dist/components/Dropdown/Dropdown.d.ts +14 -0
- package/dist/components/Dropdown/Dropdown.js +114 -0
- package/dist/components/Dropdown/Dropdown.module.css +207 -0
- package/dist/components/Input/Input.d.ts +6 -0
- package/dist/components/Input/Input.js +37 -0
- package/dist/components/Input/Input.module.css +176 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +6 -0
- package/dist/components/ProgressBar/ProgressBar.js +41 -0
- package/dist/components/ProgressBar/ProgressBar.module.css +56 -0
- package/dist/components/ProgressLoader/ProgressLoader.d.ts +3 -0
- package/dist/components/ProgressLoader/ProgressLoader.js +71 -0
- package/dist/components/ProgressLoader/ProgressLoader.module.css +26 -0
- package/dist/components/RadioButton/RadioButton.d.ts +3 -0
- package/dist/components/RadioButton/RadioButton.js +13 -0
- package/dist/components/RadioButton/RadioButton.module.css +80 -0
- package/dist/components/SettingTag/SettingTag.d.ts +3 -0
- package/dist/components/SettingTag/SettingTag.js +15 -0
- package/dist/components/SettingTag/SettingTag.module.css +16 -0
- package/dist/components/Snackbar/Snackbar.d.ts +26 -0
- package/dist/components/Snackbar/Snackbar.js +55 -0
- package/dist/components/Snackbar/Snackbar.module.css +61 -0
- package/dist/components/Snackbar/enums.d.ts +9 -0
- package/dist/components/Snackbar/enums.js +10 -0
- package/dist/components/Tab/Tab.d.ts +3 -0
- package/dist/components/Tab/Tab.js +14 -0
- package/dist/components/Tab/Tab.module.css +45 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -0
- package/dist/components/Tabs/Tabs.js +19 -0
- package/dist/components/Tabs/Tabs.module.css +55 -0
- package/dist/components/Tag/Tag.d.ts +3 -0
- package/dist/components/Tag/Tag.js +23 -0
- package/dist/components/Tag/Tag.module.css +145 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +3 -0
- package/dist/components/ToggleButton/ToggleButton.js +13 -0
- package/dist/components/ToggleButton/ToggleButton.module.css +75 -0
- package/dist/components/Typography/Typography.d.ts +6 -0
- package/dist/components/Typography/Typography.js +25 -0
- package/dist/components/Typography/Typography.module.css +264 -0
- package/dist/components/Typography/enums.d.ts +24 -0
- package/dist/components/Typography/enums.js +25 -0
- package/dist/fonts.css +35 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
.story--wrapper-colorpicker {
|
|
2
|
+
background-color: var(--white);
|
|
3
|
+
padding: 30px;
|
|
4
|
+
border-radius: 10px;
|
|
5
|
+
width: 900px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.colorPicker {
|
|
9
|
+
-webkit-appearance: none;
|
|
10
|
+
appearance: none;
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
border: none;
|
|
13
|
+
position: relative;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
padding: 0;
|
|
16
|
+
font-family: 'Raleway';
|
|
17
|
+
font-style: normal;
|
|
18
|
+
font-weight: 400;
|
|
19
|
+
line-height: 16.5px;
|
|
20
|
+
font-size: 16px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.colorPicker:hover{
|
|
24
|
+
box-shadow: 0px 0px 2.9px rgba(0, 0, 0, 0.1);
|
|
25
|
+
background-color: var(--white);
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
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
|
+
}
|
|
35
|
+
.colorPicker--defaultColor{
|
|
36
|
+
background: conic-gradient(
|
|
37
|
+
rgba(255, 59, 48) 0deg,
|
|
38
|
+
rgb(255, 59, 48) 35deg,
|
|
39
|
+
rgb(255, 204, 0) 70deg,
|
|
40
|
+
rgba(255, 255, 56) 105deg,
|
|
41
|
+
rgba(52, 199, 89) 140deg,
|
|
42
|
+
rgb(49, 255, 49) 185deg,
|
|
43
|
+
rgb(48, 176, 199) 210deg,
|
|
44
|
+
rgb(0, 122, 255) 245deg,
|
|
45
|
+
rgb(88, 86, 214) 290deg,
|
|
46
|
+
rgba(175, 82, 222) 325deg,
|
|
47
|
+
rgba(255, 59, 48) 360deg
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
/* .colorPicker--default::before {
|
|
51
|
+
content: '';
|
|
52
|
+
position: absolute;
|
|
53
|
+
border-radius: 50%;
|
|
54
|
+
top: 50%;
|
|
55
|
+
left: 50%;
|
|
56
|
+
transform: translate(-50%, -50%);
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 100%;
|
|
59
|
+
background: conic-gradient(
|
|
60
|
+
rgba(255, 59, 48) 0deg,
|
|
61
|
+
rgb(255, 59, 48) 35deg,
|
|
62
|
+
rgb(255, 204, 0) 70deg,
|
|
63
|
+
rgba(255, 255, 56) 105deg,
|
|
64
|
+
rgba(52, 199, 89) 140deg,
|
|
65
|
+
rgb(49, 255, 49) 185deg,
|
|
66
|
+
rgb(48, 176, 199) 210deg,
|
|
67
|
+
rgb(0, 122, 255) 245deg,
|
|
68
|
+
rgb(88, 86, 214) 290deg,
|
|
69
|
+
rgba(175, 82, 222) 325deg,
|
|
70
|
+
rgba(255, 59, 48) 360deg
|
|
71
|
+
);
|
|
72
|
+
} */
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/* Обертка для всех цветов */
|
|
77
|
+
.colorPickerWrapper {
|
|
78
|
+
display: flex;
|
|
79
|
+
gap: 5px;
|
|
80
|
+
width: fit-content;
|
|
81
|
+
align-items: center;
|
|
82
|
+
border-radius: 6px;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
box-shadow: 0px 0px 2.9px rgba(0, 0, 0, 0.1);
|
|
85
|
+
background-color: var(--white);
|
|
86
|
+
padding: 5px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/* Обертка для каждого цвета */
|
|
91
|
+
.circle {
|
|
92
|
+
border-radius: 50%;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
transition: transform 0.2s ease;
|
|
95
|
+
position: relative;
|
|
96
|
+
/* margin: 3px; */
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/* Заданный основной цвет */
|
|
101
|
+
.mainColor {
|
|
102
|
+
position: relative;
|
|
103
|
+
margin-right: 5px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.mainColor::after {
|
|
107
|
+
content: '';
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 50%;
|
|
110
|
+
right: -6px;
|
|
111
|
+
transform: translateY(-50%);
|
|
112
|
+
width: 1px;
|
|
113
|
+
height: 20px;
|
|
114
|
+
background-color: var(--grey-light);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Обертка для выбора цветов */
|
|
118
|
+
.colorPicker{
|
|
119
|
+
position: relative;
|
|
120
|
+
display: inline-block;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Радужный цветовой круг для незаданного цвета */
|
|
124
|
+
.colorCircleDefault {
|
|
125
|
+
background: conic-gradient(
|
|
126
|
+
rgba(255, 59, 48) 0deg,
|
|
127
|
+
rgb(255, 59, 48) 35deg,
|
|
128
|
+
rgb(255, 204, 0) 70deg,
|
|
129
|
+
rgba(255, 255, 56) 105deg,
|
|
130
|
+
rgba(52, 199, 89) 140deg,
|
|
131
|
+
rgb(49, 255, 49) 185deg,
|
|
132
|
+
rgb(48, 176, 199) 210deg,
|
|
133
|
+
rgb(0, 122, 255) 245deg,
|
|
134
|
+
rgb(88, 86, 214) 290deg,
|
|
135
|
+
rgba(175, 82, 222) 325deg,
|
|
136
|
+
rgba(255, 59, 48) 360deg
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
/* Обертка для выпадающего списка цветов */
|
|
140
|
+
.popover {
|
|
141
|
+
position: absolute;
|
|
142
|
+
left: 0;
|
|
143
|
+
z-index: 100;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.w-color-swatch{
|
|
147
|
+
padding: 10px !important;
|
|
148
|
+
border-radius: 10px !important;
|
|
149
|
+
width: fit-content !important;
|
|
150
|
+
height: fit-content !important;
|
|
151
|
+
margin: 10px 0 !important;
|
|
152
|
+
position: relative;
|
|
153
|
+
box-shadow: 0px 0px 32px rgba(0, 0, 0, 0.2) !important;
|
|
154
|
+
--github-border: 0px !important;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.w-color-swatch > div:nth-child(1),
|
|
158
|
+
.w-color-swatch > div:nth-child(2){
|
|
159
|
+
display: none !important;
|
|
160
|
+
}
|
|
161
|
+
.w-color-swatch > div:nth-child(3) {
|
|
162
|
+
width: 195px !important;
|
|
163
|
+
height: 195px !important;
|
|
164
|
+
border-radius: 10px !important;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.w-color-swatch > div:nth-child(4){
|
|
168
|
+
gap: 15px !important;
|
|
169
|
+
padding: 10px 0 !important;
|
|
170
|
+
/* width: 80%; */
|
|
171
|
+
}
|
|
172
|
+
.w-color-swatch > div:nth-child(5){
|
|
173
|
+
padding: 0 !important;
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
.w-color-swatch > div:nth-child(5) > div:nth-child(2){
|
|
177
|
+
display: none !important;
|
|
178
|
+
/* width: 80%; */
|
|
179
|
+
}
|
|
180
|
+
/* Для всех инпутов в пикере */
|
|
181
|
+
.w-color-chrome .w-color-editable-input input {
|
|
182
|
+
font-family: 'Raleway' !important;
|
|
183
|
+
font-style: normal !important;
|
|
184
|
+
font-weight: 400 !important;
|
|
185
|
+
line-height: 14px !important;
|
|
186
|
+
font-size: 12px !important;
|
|
187
|
+
margin: 0 !important;
|
|
188
|
+
}
|
|
189
|
+
.w-color-editable-input{
|
|
190
|
+
margin: 0 !important;
|
|
191
|
+
max-width: 30px !important;
|
|
192
|
+
flex-direction: column-reverse !important;
|
|
193
|
+
--editable-input-box-shadow : none !important;
|
|
194
|
+
}
|
|
195
|
+
.w-color-editable-input-rgba{
|
|
196
|
+
justify-content: end !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.w-color-editable-input > span {
|
|
200
|
+
padding-top: 0 !important;
|
|
201
|
+
}
|
|
202
|
+
.w-color-editable-input:nth-child(1)> input{
|
|
203
|
+
border-radius: 10px 0 0 10px !important;
|
|
204
|
+
border: 1px solid var(--grey-light) !important;
|
|
205
|
+
}
|
|
206
|
+
.w-color-editable-input:nth-child(2)> input{
|
|
207
|
+
border-radius: 0 0 0 0px !important;
|
|
208
|
+
border: 1px solid var(--grey-light) !important;
|
|
209
|
+
border-left: none !important;
|
|
210
|
+
}
|
|
211
|
+
.w-color-editable-input:nth-child(3)> input{
|
|
212
|
+
border-radius: 0 0 0 0px !important;
|
|
213
|
+
|
|
214
|
+
border: 1px solid var(--grey-light) !important;
|
|
215
|
+
border-left: none !important;
|
|
216
|
+
}
|
|
217
|
+
.w-color-editable-input:nth-child(4)> input{
|
|
218
|
+
border-radius: 0px 10px 10px 0px !important;
|
|
219
|
+
border: 1px solid var(--grey-light) !important;
|
|
220
|
+
border-left: none !important;
|
|
221
|
+
}
|
|
222
|
+
/* Для лейблов */
|
|
223
|
+
.w-color-chrome-fields.w-color-editable-input label {
|
|
224
|
+
font-family: 'Raleway' !important;
|
|
225
|
+
font-style: normal !important;
|
|
226
|
+
font-weight: 400 !important;
|
|
227
|
+
line-height: 16.5px !important;
|
|
228
|
+
font-size: 16px !important;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.w-color-alpha-horizontal > div.w-color-interactive{
|
|
232
|
+
border-radius: 8px !important;
|
|
233
|
+
}
|
|
234
|
+
.w-color-alpha-horizontal:first-of-type > div:first-child{
|
|
235
|
+
border-radius: 50px !important;
|
|
236
|
+
}
|
|
237
|
+
.w-color-alpha-horizontal:nth-of-type(2) > div:first-child{
|
|
238
|
+
border-radius: 50px !important;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.colorPickerIcon {
|
|
242
|
+
position: absolute;
|
|
243
|
+
top: 68%;
|
|
244
|
+
left: 8px;
|
|
245
|
+
z-index: 200;
|
|
246
|
+
padding: 10px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.hex{
|
|
250
|
+
position: absolute;
|
|
251
|
+
bottom: 20px;
|
|
252
|
+
left: -10px;
|
|
253
|
+
}
|
|
254
|
+
.hex .w-color-editable-input{
|
|
255
|
+
border-radius: 10px !important;
|
|
256
|
+
}
|
|
257
|
+
.hex > .w-color-editable-input > input {
|
|
258
|
+
/* padding: 0 !important; */
|
|
259
|
+
font-size: 12px !important;
|
|
260
|
+
font-family: 'Raleway' !important;
|
|
261
|
+
padding: 5px !important;
|
|
262
|
+
width: 70px !important;
|
|
263
|
+
height: 45px !important;
|
|
264
|
+
border-radius: 10px !important;
|
|
265
|
+
text-align: center !important;
|
|
266
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DropdownProps } from 'kamotive_ui';
|
|
3
|
+
/**
|
|
4
|
+
* Компонент Dropdown позволяет пользователям выбирать однин вариант из выпадающего меню
|
|
5
|
+
*/
|
|
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;
|
|
12
|
+
}
|
|
13
|
+
export declare const DropdownListItem: FC<DropdownListItemProps>;
|
|
14
|
+
export declare const Dropdown: FC<DropdownProps>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import styles from './Dropdown.module.css';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { ChevronDown10 } from '../../Icons/ChevronDown/ChevronDown10';
|
|
5
|
+
import { ChevronUp10 } from '../../Icons/ChevronUp/ChevronUp10';
|
|
6
|
+
import { IconCheck10 } from '../../Icons/IconCheck/IconCheck10';
|
|
7
|
+
export const DropdownListItem = ({ item, size = 'md', selectedItem, style, onChange }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const handleItemClick = (item, disabled) => {
|
|
10
|
+
if (!disabled) {
|
|
11
|
+
onChange(item);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const itemClassess = classNames(styles[`item-block`], styles[`button--${size}`], { 'item-block--selected': (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === (item === null || item === void 0 ? void 0 : item.value) || (typeof selectedItem === 'string' || typeof selectedItem === 'number') && selectedItem === item }, { 'item-block--disabled': item === null || item === void 0 ? void 0 : item.disabled });
|
|
15
|
+
const itemBlock = classNames(styles[`item-block`], styles[`item-block-${style}`], { [`item-block-${style}--selected`]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === item.value }, { 'item-block--disabled': item.disabled });
|
|
16
|
+
return (React.createElement("div", { className: styles[`item--container`] },
|
|
17
|
+
React.createElement("div", { className: styles[itemClassess], onClick: () => handleItemClick(item, item.disabled) },
|
|
18
|
+
React.createElement("div", { className: itemBlock },
|
|
19
|
+
style === 'default' && item.icon && React.cloneElement(item.icon, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0' }),
|
|
20
|
+
React.createElement("div", { className: styles["item"] },
|
|
21
|
+
React.createElement("span", null, (item === null || item === void 0 ? void 0 : item.value) || item)),
|
|
22
|
+
(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === item.value && React.createElement(IconCheck10, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0', htmlColor: '#0D99FF' })),
|
|
23
|
+
item.isDivider && React.createElement("div", { className: styles["divider"] })),
|
|
24
|
+
(item === null || item === void 0 ? void 0 : item.children) && (React.createElement("div", { className: styles["nestedMenu"] }, (_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child, index) => (React.createElement(DropdownListItem, { key: index, item: child, size: size, selectedItem: selectedItem, onChange: onChange })))))));
|
|
25
|
+
};
|
|
26
|
+
export const Dropdown = ({ id, name, label, size = 'md', disabled, className, defaultValue, items, isOpened = false, style = 'default', readOnly = false, isLeftLabel = false }) => {
|
|
27
|
+
const [isOpen, setIsOpen] = useState(isOpened);
|
|
28
|
+
const [selectedItem, setSelectedItem] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
|
|
29
|
+
const containerRef = useRef(null);
|
|
30
|
+
const [containerWidth, setContainerWidth] = useState(undefined);
|
|
31
|
+
const icon = !isOpen ? React.createElement(ChevronDown10, null) : React.createElement(ChevronUp10, null);
|
|
32
|
+
const handleToggle = () => {
|
|
33
|
+
setIsOpen(prev => !prev);
|
|
34
|
+
};
|
|
35
|
+
const onChange = (item) => {
|
|
36
|
+
if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) !== item.value) {
|
|
37
|
+
setSelectedItem(item);
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
setSelectedItem(null);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const wrapperClassess = classNames(styles[`dropdown--container`], {
|
|
45
|
+
'wrapper--left': isLeftLabel,
|
|
46
|
+
});
|
|
47
|
+
const buttonClassess = classNames(styles['button'], className, styles[`button--${size}`], { 'button-item--selected': (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) && !disabled }, { 'button--readOnly': readOnly }, { 'button--disabled': disabled });
|
|
48
|
+
const dropdownClassess = classNames(styles['dropdown'], className, {
|
|
49
|
+
'dropdown--disabled': disabled,
|
|
50
|
+
});
|
|
51
|
+
const labelClasses = classNames(styles['label'], { 'label--default': !isLeftLabel,
|
|
52
|
+
'label--left': isLeftLabel,
|
|
53
|
+
});
|
|
54
|
+
const checkItem = (item) => {
|
|
55
|
+
if (typeof item === 'object') {
|
|
56
|
+
if (item.value) {
|
|
57
|
+
return item;
|
|
58
|
+
}
|
|
59
|
+
else if (item.name && !item.value) {
|
|
60
|
+
return Object.assign(Object.assign({}, item), { value: name });
|
|
61
|
+
}
|
|
62
|
+
else if (item.description && !item.value) {
|
|
63
|
+
return Object.assign(Object.assign({}, item), { value: item.description });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const keys = Object.keys(item);
|
|
67
|
+
if (keys.length) {
|
|
68
|
+
const firstValue = item[keys[0]];
|
|
69
|
+
return Object.assign(Object.assign({}, item), { value: firstValue });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (typeof item === 'string' || typeof item === 'number') {
|
|
74
|
+
return { value: item };
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const getDropdownMenu = () => {
|
|
81
|
+
// const menu = withPortal ? (
|
|
82
|
+
// ReactDOM.createPortal(<DropdownMenu withPortal >{children}</DropdownMenu>, portalContainer)
|
|
83
|
+
// ) : <DropdownMenu>{children}</DropdownMenu>
|
|
84
|
+
const menu = isOpen && React.createElement("div", { className: styles[dropdownClassess] }, items === null || items === void 0 ? void 0 : items.map((item, index) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const modifiedItem = checkItem(item);
|
|
87
|
+
return (React.createElement(DropdownListItem, { key: (_a = item === null || item === void 0 ? void 0 : item.key) !== null && _a !== void 0 ? _a : index, item: modifiedItem, size: size, selectedItem: selectedItem, style: style, onChange: onChange }));
|
|
88
|
+
}));
|
|
89
|
+
return isOpen ? menu : null;
|
|
90
|
+
};
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (containerRef.current) {
|
|
93
|
+
const textWidth = Math.max(name === null || name === void 0 ? void 0 : name.length, (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value.length) || 0);
|
|
94
|
+
let newWidth;
|
|
95
|
+
if (textWidth === (name === null || name === void 0 ? void 0 : name.length)) {
|
|
96
|
+
const inPixel = size === 'sm' ? 11 : size === 'md' ? 12 : 14;
|
|
97
|
+
newWidth = selectedItem ? textWidth * inPixel : textWidth * inPixel;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const inPixel = size === 'sm' ? 9 : size === 'md' ? 10 : 12;
|
|
101
|
+
newWidth = textWidth * inPixel;
|
|
102
|
+
}
|
|
103
|
+
setContainerWidth(newWidth);
|
|
104
|
+
}
|
|
105
|
+
}, [selectedItem, name, isOpen, size]);
|
|
106
|
+
return (React.createElement("div", { className: styles[wrapperClassess], ref: containerRef, style: { width: containerWidth ? `${containerWidth}px` : 'auto' } },
|
|
107
|
+
selectedItem && label && (React.createElement("label", { className: labelClasses, htmlFor: id }, label)),
|
|
108
|
+
React.createElement("button", { className: buttonClassess, onClick: readOnly ? undefined : handleToggle, disabled: disabled },
|
|
109
|
+
React.createElement("div", { className: style === 'default' && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) ? styles[`button--default--item-selected`] : '' },
|
|
110
|
+
style === 'default' && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) && React.cloneElement(selectedItem.icon, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0' }),
|
|
111
|
+
selectedItem ? selectedItem.value : name),
|
|
112
|
+
icon && React.cloneElement(icon, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0' })),
|
|
113
|
+
getDropdownMenu()));
|
|
114
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
.story--wrapper-dropdown {
|
|
2
|
+
background-color: var(--white);
|
|
3
|
+
padding: 30px;
|
|
4
|
+
border-radius: 10px;
|
|
5
|
+
width: 900px;
|
|
6
|
+
}
|
|
7
|
+
.option--wrapper{
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
}
|
|
12
|
+
.option--icon{
|
|
13
|
+
margin-left: 8px;
|
|
14
|
+
}
|
|
15
|
+
.dropdown--container{
|
|
16
|
+
font-family: 'Raleway';
|
|
17
|
+
font-style: normal;
|
|
18
|
+
font-weight: 400;
|
|
19
|
+
line-height: 16.5px;
|
|
20
|
+
display: inline-block;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
.wrapper--left {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
gap: 20px;
|
|
27
|
+
align-items: center;
|
|
28
|
+
flex-wrap: nowrap;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.button {
|
|
32
|
+
font-family: 'Raleway';
|
|
33
|
+
font-style: normal;
|
|
34
|
+
font-weight: 400;
|
|
35
|
+
line-height: 16.5px;
|
|
36
|
+
|
|
37
|
+
border-radius: 10px;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
/* padding: 0.5em 1em; */
|
|
40
|
+
padding: 10px 15px;
|
|
41
|
+
transition: all 0.3s ease;
|
|
42
|
+
width: 100%;
|
|
43
|
+
/* background-color: var(--white); */
|
|
44
|
+
background-color: transparent;
|
|
45
|
+
color: rgba(60, 60, 67, 0.6);
|
|
46
|
+
border: 1px solid var(--grey-light);
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: 10px;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
min-width: fit-content;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
.button:hover{
|
|
55
|
+
border: 1px solid #0d9aff00;
|
|
56
|
+
box-shadow: 0px 0px 2px var(--blue-main);
|
|
57
|
+
}
|
|
58
|
+
.button:focus,
|
|
59
|
+
.button:active{
|
|
60
|
+
border-color: var(--blue-main);
|
|
61
|
+
box-shadow: none;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
.button--disabled{
|
|
65
|
+
background-color: rgba(120, 120, 128, 0.08);
|
|
66
|
+
border: 1px solid #0d9aff00;
|
|
67
|
+
color: rgba(60, 60, 67, 0.3);
|
|
68
|
+
}
|
|
69
|
+
.button--readOnly{
|
|
70
|
+
background-color: rgba(120, 120, 128, 0.08);
|
|
71
|
+
border: 1px solid #0d9aff00;
|
|
72
|
+
color: var(--text-dark);
|
|
73
|
+
}
|
|
74
|
+
.button--disabled:hover,
|
|
75
|
+
.button--disabled:focus,
|
|
76
|
+
.button--disabled:active,
|
|
77
|
+
.button--readOnly:hover,
|
|
78
|
+
.button--readOnly:focus,
|
|
79
|
+
.button--readOnly:active{
|
|
80
|
+
box-shadow: none;
|
|
81
|
+
border: 1px solid #0d9aff00;
|
|
82
|
+
}
|
|
83
|
+
.button--default--item-selected{
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 10px;
|
|
87
|
+
}
|
|
88
|
+
.button-item--selected{
|
|
89
|
+
color: var(--text-dark);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Размеры кнопок */
|
|
93
|
+
.button--sm {
|
|
94
|
+
/* font-size: 0.8rem; */
|
|
95
|
+
font-size: 12px;
|
|
96
|
+
}
|
|
97
|
+
.button--md {
|
|
98
|
+
/* font-size: 1rem; */
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
}
|
|
101
|
+
.button--lg {
|
|
102
|
+
/* font-size: 1.2rem; */
|
|
103
|
+
font-size: 16px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dropdown{
|
|
107
|
+
position: absolute;
|
|
108
|
+
display: flex;
|
|
109
|
+
margin-top: 5px;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
align-items: flex-start;
|
|
112
|
+
padding: 10px 0px;
|
|
113
|
+
max-height: 175px;
|
|
114
|
+
width: 100%;
|
|
115
|
+
background: #FFFFFF;
|
|
116
|
+
box-shadow: 0px 0px 32px rgba(0, 0, 0, 0.2);
|
|
117
|
+
border-radius: 12px;
|
|
118
|
+
overflow-y: auto;
|
|
119
|
+
z-index: 1000;
|
|
120
|
+
overflow-x: hidden;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.item--container {
|
|
124
|
+
padding: 0.5em 0.5em;
|
|
125
|
+
width: 87%;
|
|
126
|
+
margin: auto;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.item--container:hover{
|
|
130
|
+
background-color: rgba(120, 120, 128, 0.08);
|
|
131
|
+
border-radius: 5px;
|
|
132
|
+
width: 87%;
|
|
133
|
+
margin: auto;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
.item-block {
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
color: var(--text-grey);
|
|
140
|
+
transition: background-color 0.2s ease;
|
|
141
|
+
}
|
|
142
|
+
.item-block--disabled {
|
|
143
|
+
color: var(--text-light);
|
|
144
|
+
cursor: not-allowed ;
|
|
145
|
+
}
|
|
146
|
+
.item-block-default,
|
|
147
|
+
.item-block-text {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: auto 1fr;
|
|
150
|
+
justify-content: flex-start;
|
|
151
|
+
align-items: center;
|
|
152
|
+
gap:10px;
|
|
153
|
+
}
|
|
154
|
+
.item-block-default--selected {
|
|
155
|
+
display: grid;
|
|
156
|
+
grid-template-columns: auto 1fr 20px;
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
align-items: center;
|
|
159
|
+
overflow-x: hidden;
|
|
160
|
+
text-overflow: ellipsis;
|
|
161
|
+
white-space: nowrap;
|
|
162
|
+
gap: 10px;
|
|
163
|
+
color: var(--text-dark);
|
|
164
|
+
}
|
|
165
|
+
.item-block-text--selected{
|
|
166
|
+
display: grid;
|
|
167
|
+
grid-template-columns: auto auto;
|
|
168
|
+
justify-content: space-between;
|
|
169
|
+
align-items: center;
|
|
170
|
+
overflow-x: hidden;
|
|
171
|
+
text-overflow: ellipsis;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
gap: 10px;
|
|
174
|
+
color: var(--text-dark);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
.item {
|
|
179
|
+
overflow: hidden;
|
|
180
|
+
text-overflow: ellipsis;
|
|
181
|
+
white-space: nowrap;
|
|
182
|
+
max-width: 100%
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.label {
|
|
186
|
+
line-height: 14px;
|
|
187
|
+
font-weight: 400;
|
|
188
|
+
transition: 0.3ms ease-out;
|
|
189
|
+
/* color: var(--text-grey); */
|
|
190
|
+
}
|
|
191
|
+
.label--default {
|
|
192
|
+
font-size: 12px;
|
|
193
|
+
position: absolute;
|
|
194
|
+
top: -20px;
|
|
195
|
+
cursor: text;
|
|
196
|
+
white-space: nowrap;
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
text-overflow: ellipsis;
|
|
199
|
+
max-width: calc(100% - 32px);
|
|
200
|
+
color: var(--text-grey);
|
|
201
|
+
}
|
|
202
|
+
.label--left {
|
|
203
|
+
font-size: 13px;
|
|
204
|
+
color: var(--text-dark);
|
|
205
|
+
min-width: fit-content;
|
|
206
|
+
}
|
|
207
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './Input.module.css';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
/**
|
|
5
|
+
* Компонент Input для создания текстовых полей ввода различных стилей и размеров.
|
|
6
|
+
*/
|
|
7
|
+
export const Input = ({ id, className, value, label, placeholder, size = 'md', onChange, icon, hasError = false, helperText, disabled = false, readOnly = false, isLeftLabel = false, multiline = false, resize = false, }) => {
|
|
8
|
+
const handleChange = (e) => {
|
|
9
|
+
if (onChange) {
|
|
10
|
+
onChange(e);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const wrapperClassess = classNames(styles['wrapper'], {
|
|
14
|
+
'wrapper--left': isLeftLabel,
|
|
15
|
+
});
|
|
16
|
+
const inputWrapperClassess = classNames(styles['wrapper--input']);
|
|
17
|
+
const inputClassess = classNames(styles['inputText'], size, className, {
|
|
18
|
+
'input--error': hasError,
|
|
19
|
+
'readOnly': readOnly,
|
|
20
|
+
'input--withIcon': icon,
|
|
21
|
+
'textarea': multiline,
|
|
22
|
+
'resize': resize,
|
|
23
|
+
});
|
|
24
|
+
const labelClasses = classNames(styles['label'], {
|
|
25
|
+
'label--default': !isLeftLabel,
|
|
26
|
+
'label--left': isLeftLabel,
|
|
27
|
+
});
|
|
28
|
+
const iconClassess = classNames(styles['icon'], {
|
|
29
|
+
'input--withIcon': multiline,
|
|
30
|
+
});
|
|
31
|
+
return (React.createElement("div", { className: wrapperClassess },
|
|
32
|
+
((value && !isLeftLabel) || isLeftLabel) && (React.createElement("label", { className: labelClasses, htmlFor: id }, label)),
|
|
33
|
+
React.createElement("div", { className: inputWrapperClassess },
|
|
34
|
+
icon && React.createElement("div", { className: iconClassess }, icon),
|
|
35
|
+
multiline ? (React.createElement("textarea", { id: id, className: inputClassess, value: value, placeholder: placeholder, onChange: handleChange, disabled: disabled })) : (React.createElement("input", { id: id, className: inputClassess, value: value, placeholder: placeholder, onChange: handleChange, disabled: disabled, readOnly: readOnly }))),
|
|
36
|
+
hasError && helperText && React.createElement("div", { className: "helperText" }, helperText)));
|
|
37
|
+
};
|