kamotive_ui 1.2.1 → 1.2.3

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/ChevronDown/ChevronDown10.js +1 -2
  2. package/dist/Icons/ChevronUp/ChevronUp10.js +1 -2
  3. package/dist/Icons/IconAccount/IconAccount10.js +1 -2
  4. package/dist/Icons/IconAlarm/IconAlarm10.js +1 -2
  5. package/dist/Icons/IconBank/IconBank10.js +1 -2
  6. package/dist/Icons/IconBell/IconBell10.js +1 -2
  7. package/dist/Icons/IconBriefcase/IconBriefcase10.js +1 -2
  8. package/dist/Icons/IconCalendar/IconCalendar10.js +1 -2
  9. package/dist/Icons/IconCheck/IconCheck10.js +1 -2
  10. package/dist/Icons/IconClose/IconClose10.d.ts +2 -1
  11. package/dist/Icons/IconClose/IconClose10.js +2 -3
  12. package/dist/Icons/IconColorPicker/IconColorPicker10.js +1 -2
  13. package/dist/Icons/IconError/IconError10.js +1 -2
  14. package/dist/Icons/IconEyeOff/IconEyeOff10.js +1 -2
  15. package/dist/Icons/IconInfo/IconInfo10.js +1 -2
  16. package/dist/Icons/IconSuccess/IconSuccess10.js +1 -2
  17. package/dist/Icons/IconWarning/IconWarning10.js +1 -2
  18. package/dist/components/Button/Button.d.ts +1 -1
  19. package/dist/components/Button/Button.js +4 -7
  20. package/dist/components/Button/Button.module.css +12 -26
  21. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  22. package/dist/components/Checkbox/Checkbox.js +3 -1
  23. package/dist/components/Checkbox/Checkbox.module.css +3 -13
  24. package/dist/components/ColorPicker/ColorPicker.d.ts +4 -34
  25. package/dist/components/ColorPicker/ColorPicker.js +5 -2
  26. package/dist/components/ColorPicker/ColorPicker.module.css +8 -31
  27. package/dist/components/Dropdown/Dropdown.d.ts +12 -8
  28. package/dist/components/Dropdown/Dropdown.js +230 -46
  29. package/dist/components/Dropdown/Dropdown.module.css +152 -89
  30. package/dist/components/Input/Input.d.ts +1 -1
  31. package/dist/components/Input/Input.js +18 -17
  32. package/dist/components/Input/Input.module.css +91 -44
  33. package/dist/components/ProgressBar/ProgressBar.d.ts +1 -1
  34. package/dist/components/ProgressBar/ProgressBar.js +6 -5
  35. package/dist/components/ProgressBar/ProgressBar.module.css +22 -22
  36. package/dist/components/ProgressLoader/ProgressLoader.d.ts +1 -1
  37. package/dist/components/ProgressLoader/ProgressLoader.js +5 -4
  38. package/dist/components/ProgressLoader/ProgressLoader.module.css +1 -10
  39. package/dist/components/RadioButton/RadioButton.d.ts +1 -1
  40. package/dist/components/RadioButton/RadioButton.js +3 -1
  41. package/dist/components/RadioButton/RadioButton.module.css +2 -15
  42. package/dist/components/SettingTag/SettingTag.d.ts +1 -1
  43. package/dist/components/SettingTag/SettingTag.js +2 -1
  44. package/dist/components/SettingTag/SettingTag.module.css +7 -0
  45. package/dist/components/Snackbar/Snackbar.d.ts +2 -8
  46. package/dist/components/Snackbar/Snackbar.js +3 -2
  47. package/dist/components/Snackbar/Snackbar.module.css +5 -4
  48. package/dist/components/Tab/Tab.d.ts +1 -1
  49. package/dist/components/Tab/Tab.js +7 -4
  50. package/dist/components/Tab/Tab.module.css +32 -0
  51. package/dist/components/Tabs/Tabs.d.ts +1 -1
  52. package/dist/components/Tabs/Tabs.js +2 -2
  53. package/dist/components/Tabs/Tabs.module.css +1 -6
  54. package/dist/components/Tag/Tag.d.ts +1 -1
  55. package/dist/components/Tag/Tag.js +1 -0
  56. package/dist/components/Tag/Tag.module.css +87 -94
  57. package/dist/components/ToggleButton/ToggleButton.d.ts +1 -1
  58. package/dist/components/ToggleButton/ToggleButton.js +5 -3
  59. package/dist/components/ToggleButton/ToggleButton.module.css +9 -14
  60. package/dist/components/Typography/Typography.d.ts +1 -1
  61. package/dist/components/Typography/Typography.js +4 -2
  62. package/dist/components/Typography/Typography.module.css +8 -13
  63. package/dist/components/Typography/enums.d.ts +2 -0
  64. package/dist/components/Typography/enums.js +2 -0
  65. package/dist/index.d.ts +9 -6
  66. package/dist/index.js +8 -6
  67. package/dist/types/index.d.ts +261 -0
  68. package/dist/types/index.js +1 -0
  69. package/package.json +2 -1
  70. package/dist/Icons/Icons.module.css +0 -4
@@ -1,83 +1,267 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import styles from './Dropdown.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { ChevronDown10 } from '../../Icons/ChevronDown/ChevronDown10';
5
5
  import { ChevronUp10 } from '../../Icons/ChevronUp/ChevronUp10';
6
+ import { IconClose10 } from '../../Icons/IconClose/IconClose10';
6
7
  import { IconCheck10 } from '../../Icons/IconCheck/IconCheck10';
7
- export const DropdownListItem = ({ item, size = 'md', selectedItem, style, onChange }) => {
8
- const handleItemClick = (item, disabled) => {
9
- if (!disabled) {
10
- onChange(item);
8
+ ;
9
+ import { Typography } from '../Typography/Typography';
10
+ function checkItem(item, getOptionLabel, disabled, isDivider) {
11
+ if (typeof item === 'object' && item !== null) {
12
+ //проверка на вложенные объекты с таким же типом
13
+ Object.keys(item).forEach((key) => {
14
+ const value = item[key];
15
+ if (typeof value === 'object' && value !== null && !React.isValidElement(value)) {
16
+ const nestedItem = checkItem(value, getOptionLabel, disabled, isDivider);
17
+ if (nestedItem) {
18
+ if (!item.children) {
19
+ item.children = [];
20
+ }
21
+ item.children.push(nestedItem);
22
+ delete item[key];
23
+ }
24
+ }
25
+ });
26
+ // проверка на наличие пользовательского поля для вывода(передаваемой функции getOptionLabel)
27
+ if (getOptionLabel) {
28
+ return Object.assign(Object.assign({}, item), { value: getOptionLabel(item), disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false });
11
29
  }
12
- };
13
- const itemClassess = classNames(styles[`item-block`], styles[`button--${size}`], { [styles['item-block--selected']]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === item.value }, { [styles['item-block--disabled']]: item.disabled });
14
- const itemBlock = classNames(styles[`item-block`], styles[`item-block-${style}`], { [styles[`item-block-${style}--selected`]]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === item.value }, { [styles[`item-block--disabled`]]: item.disabled });
15
- return (React.createElement("div", { className: styles[`item--container`] },
16
- React.createElement("div", { className: itemClassess, onClick: () => handleItemClick(item, item.disabled) },
30
+ if ('value' in item) {
31
+ return Object.assign(Object.assign({}, item), { disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false });
32
+ }
33
+ else if ('name' in item && !('value' in item)) {
34
+ return Object.assign(Object.assign({}, item), { value: item.name, disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false });
35
+ }
36
+ else if ('description' in item && !('value' in item)) {
37
+ return Object.assign(Object.assign({}, item), { value: item.description, disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false });
38
+ }
39
+ else {
40
+ const keys = Object.keys(item);
41
+ if (keys.length) {
42
+ const firstValue = item[keys[0]];
43
+ return Object.assign(Object.assign({}, item), { value: firstValue, disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false });
44
+ }
45
+ }
46
+ }
47
+ else if (typeof item === 'string' || typeof item === 'number') {
48
+ return { value: item, disabled: disabled !== null && disabled !== void 0 ? disabled : false, isDivider: isDivider !== null && isDivider !== void 0 ? isDivider : false };
49
+ }
50
+ else {
51
+ return null;
52
+ }
53
+ }
54
+ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedItem, style, onChange, isActive, activeIndex, index, }) => {
55
+ var _a;
56
+ const handleItemClick = useCallback((event) => {
57
+ event.preventDefault();
58
+ event.stopPropagation();
59
+ if (!(item === null || item === void 0 ? void 0 : item.disabled)) {
60
+ onChange(event, item);
61
+ }
62
+ }, [item, onChange]);
63
+ const itemContainerClasses = classNames(styles[`item--container`], { [styles['item--container--active']]: isActive });
64
+ const itemClassess = classNames(styles[`item-block`], styles[`button--${size}`], {
65
+ [styles['item-block--disabled']]: item === null || item === void 0 ? void 0 : item.disabled,
66
+ [styles['item-block--active']]: isActive,
67
+ });
68
+ const itemBlock = classNames(styles[`item-block`], styles[`item-block-${style}`], { [styles[`item-block-${style}--selected`]]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === (item === null || item === void 0 ? void 0 : item.value) }, { [styles['item-block--disabled']]: item === null || item === void 0 ? void 0 : item.disabled });
69
+ return (React.createElement("div", { className: itemContainerClasses, onClick: handleItemClick },
70
+ React.createElement("div", { className: itemClassess },
17
71
  React.createElement("div", { className: itemBlock },
18
- style === 'default' && item.icon && React.cloneElement(item.icon, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0' }),
72
+ style === 'icons' &&
73
+ (item === null || item === void 0 ? void 0 : item.icon) &&
74
+ React.cloneElement(item.icon, {
75
+ strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
76
+ }),
19
77
  React.createElement("div", { className: styles.item },
20
- React.createElement("span", null, item.value)),
21
- (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' })),
22
- item.isDivider && React.createElement("div", { className: styles.divider })),
23
- item.children && (React.createElement("div", { className: styles.nestedMenu }, item.children.map(child => (React.createElement(DropdownListItem, { key: child.key, item: child, size: size, selectedItem: selectedItem, onChange: onChange })))))));
78
+ React.createElement("span", null, item === null || item === void 0 ? void 0 : item.value)),
79
+ (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === (item === null || item === void 0 ? void 0 : item.value) && (React.createElement(IconCheck10, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0', htmlColor: "#0D99FF" }))),
80
+ (item === null || item === void 0 ? void 0 : item.isDivider) && React.createElement("div", { className: styles.divider })),
81
+ (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, childIndex) => {
82
+ var _a;
83
+ return (React.createElement(DropdownListItem, { key: (_a = child === null || child === void 0 ? void 0 : child.key) !== null && _a !== void 0 ? _a : childIndex, item: child, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, onChange: onChange, isActive: activeIndex === index, activeIndex: activeIndex, index: childIndex }));
84
+ })))));
24
85
  };
25
- export const Dropdown = ({ id, name, label, size = 'md', disabled, className, defaultValue, items, isOpened = false, style = 'default', readOnly = false, isLeftLabel = false }) => {
86
+ export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOptionLabel, value, defaultValue, style = 'text', className, disabled = false, readOnly = false, isOpened = false, noOptionsText = 'Нет вариатов для выбора', isLeftLabel = false, error = false, helperText, onChange, onClose, clearable = true, required = false, isDivider = false, }) => {
26
87
  const [isOpen, setIsOpen] = useState(isOpened);
27
- const [selectedItem, setSelectedItem] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
88
+ const [modifiedOptions, setModifiedOptions] = useState([]);
89
+ const [selectedItem, setSelectedItem] = useState(null);
90
+ const [errorInput, setErrorInput] = useState(error);
91
+ const [errorInputHelperText, setErrorInputHelperText] = useState(helperText);
92
+ const [activeIndex, setActiveIndex] = useState(-1);
28
93
  const containerRef = useRef(null);
29
94
  const [containerWidth, setContainerWidth] = useState(undefined);
30
- const icon = !isOpen ? React.createElement(ChevronDown10, null) : React.createElement(ChevronUp10, null);
31
- const handleToggle = () => {
32
- setIsOpen(prev => !prev);
95
+ const handleToggle = (event) => {
96
+ setIsOpen((prev) => !prev);
97
+ if (isOpen) {
98
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
99
+ }
33
100
  };
34
- const onChange = (item) => {
35
- if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) !== item.value) {
101
+ const onChangeHandler = (event, item) => {
102
+ event.preventDefault();
103
+ event.stopPropagation();
104
+ const newEvent = Object.assign(Object.assign({}, event), { currentTarget: Object.assign(Object.assign({}, event.currentTarget), { value: item }) });
105
+ if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) !== (item === null || item === void 0 ? void 0 : item.value)) {
36
106
  setSelectedItem(item);
37
107
  setIsOpen(false);
108
+ onChange === null || onChange === void 0 ? void 0 : onChange(newEvent, item);
109
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
110
+ }
111
+ if (item) {
112
+ setErrorInput(false);
38
113
  }
39
114
  else {
40
- setSelectedItem(null);
115
+ setErrorInput(true);
41
116
  }
42
117
  };
43
- const wrapperClassess = classNames(styles[`dropdown--container`], {
44
- [styles['wrapper--left']]: isLeftLabel,
118
+ //для выбора опции из списка с клавиатуры
119
+ const handleKeyDown = (event) => {
120
+ if (!isOpen) {
121
+ if (event.key === 'Enter' || event.key === 'ArrowDown') {
122
+ event.preventDefault();
123
+ event.stopPropagation();
124
+ setIsOpen(true);
125
+ setActiveIndex(0);
126
+ }
127
+ return;
128
+ }
129
+ switch (event.key) {
130
+ case 'ArrowDown':
131
+ event.preventDefault();
132
+ modifiedOptions && setActiveIndex((prev) => (prev < modifiedOptions.length - 1 ? prev + 1 : prev));
133
+ break;
134
+ case 'ArrowUp':
135
+ event.preventDefault();
136
+ setActiveIndex((prev) => (prev > 0 ? prev - 1 : prev));
137
+ break;
138
+ case 'Enter':
139
+ event.preventDefault();
140
+ if (activeIndex >= 0) {
141
+ const selectedOption = modifiedOptions && modifiedOptions[activeIndex];
142
+ onChangeHandler(event, selectedOption);
143
+ setIsOpen(false);
144
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
145
+ setActiveIndex(-1);
146
+ }
147
+ break;
148
+ case 'Escape':
149
+ setIsOpen(false);
150
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
151
+ setActiveIndex(-1);
152
+ break;
153
+ }
154
+ };
155
+ //для сброса выбранного значения
156
+ const handleReset = (event) => {
157
+ const startValue = defaultValue
158
+ ? checkItem(defaultValue)
159
+ : null;
160
+ setSelectedItem(startValue !== null && startValue !== void 0 ? startValue : null);
161
+ setIsOpen(false);
162
+ onChange === null || onChange === void 0 ? void 0 : onChange(event, startValue !== null && startValue !== void 0 ? startValue : null);
163
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
164
+ setActiveIndex(-1);
165
+ if (required) {
166
+ setErrorInput(true);
167
+ setErrorInputHelperText(helperText !== null && helperText !== void 0 ? helperText : 'Поле обязательно для заполнения');
168
+ }
169
+ };
170
+ const wrapperClassess = classNames({
171
+ [styles['dropdown--container']]: !isLeftLabel,
172
+ [styles['dropdown--container-left']]: isLeftLabel,
173
+ [styles['dropdown--container-label']]: label && !isLeftLabel && !required,
174
+ [styles['dropdown--container-helperText']]: errorInput,
175
+ });
176
+ const buttonClassess = classNames(styles.button, className, styles[`button--${size}`], {
177
+ [styles['button-item--selected']]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) && !disabled,
178
+ [styles['button--readOnly']]: readOnly,
179
+ [styles['button--disabled']]: disabled,
180
+ [styles['button--error']]: errorInput,
45
181
  });
46
- const buttonClassess = classNames(styles.button, className, styles[`button--${size}`], { [styles['button-item--selected']]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) && !disabled }, { [styles['button--readOnly']]: readOnly }, { [styles['button--disabled']]: disabled });
47
182
  const dropdownClassess = classNames(styles.dropdown, className, {
48
183
  [styles['dropdown--disabled']]: disabled,
49
184
  });
50
- const labelClasses = classNames(styles.label, { [styles['label--default']]: !isLeftLabel,
185
+ const labelClasses = classNames(styles.label, styles[size], {
186
+ [styles['label--default']]: !isLeftLabel,
51
187
  [styles['label--left']]: isLeftLabel,
188
+ [styles['label--required']]: required,
189
+ });
190
+ const selectedItemClassess = classNames({
191
+ [styles['item-selected']]: selectedItem,
192
+ [styles['item-placeholder']]: !selectedItem && (placeholder !== null && placeholder !== void 0 ? placeholder : label),
193
+ [styles['button--icons--item-selected']]: style === 'icons' && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon),
52
194
  });
53
195
  const getDropdownMenu = () => {
54
- // const menu = withPortal ? (
55
- // ReactDOM.createPortal(<DropdownMenu withPortal >{children}</DropdownMenu>, portalContainer)
56
- // ) : <DropdownMenu>{children}</DropdownMenu>
57
- const menu = isOpen && React.createElement("div", { className: dropdownClassess }, items.map(item => (React.createElement(DropdownListItem, { key: item.key, item: item, size: size, selectedItem: selectedItem, style: style, onChange: onChange }))));
196
+ const menu = isOpen && (React.createElement("div", { className: dropdownClassess }, modifiedOptions && modifiedOptions.length > 0 ? (modifiedOptions.map((modifiedOption, index) => {
197
+ var _a;
198
+ return (React.createElement(DropdownListItem, { key: (_a = modifiedOption === null || modifiedOption === void 0 ? void 0 : modifiedOption.key) !== null && _a !== void 0 ? _a : index, item: modifiedOption, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, style: style, onChange: onChangeHandler, isActive: activeIndex === index, activeIndex: activeIndex, index: index }));
199
+ })) : (React.createElement("div", { className: styles['no-options'] }, noOptionsText))));
58
200
  return isOpen ? menu : null;
59
201
  };
60
202
  useEffect(() => {
203
+ var _a, _b, _c;
204
+ const handleClickOutside = (event) => {
205
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
206
+ setIsOpen(false);
207
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
208
+ }
209
+ };
61
210
  if (containerRef.current) {
62
- const textWidth = Math.max(name.length, (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value.length) || 0);
211
+ const text = (_a = label !== null && label !== void 0 ? label : placeholder) !== null && _a !== void 0 ? _a : '';
63
212
  let newWidth;
64
- if (textWidth === name.length) {
65
- const inPixel = size === 'sm' ? 11 : size === 'md' ? 12 : 14;
66
- newWidth = selectedItem ? textWidth * inPixel : textWidth * inPixel;
213
+ if (!isLeftLabel) {
214
+ const textWidth = Math.max((text || '').length, (((_b = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === null || _b === void 0 ? void 0 : _b.toString()) || '').length);
215
+ const inPixel = size === 'lg' ? 11 : 9;
216
+ newWidth = textWidth * inPixel;
67
217
  }
68
218
  else {
69
- const inPixel = size === 'sm' ? 9 : size === 'md' ? 10 : 12;
70
- newWidth = textWidth * inPixel;
219
+ const inPixel = size === 'lg' ? 11 : 9;
220
+ const selectedValue = ((_c = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) === null || _c === void 0 ? void 0 : _c.toString()) || '';
221
+ newWidth = (text.length + selectedValue.length) * inPixel + 40;
71
222
  }
72
223
  setContainerWidth(newWidth);
73
224
  }
74
- }, [selectedItem, name, isOpen, size]);
75
- return (React.createElement("div", { className: wrapperClassess, ref: containerRef, style: { width: containerWidth ? `${containerWidth}px` : 'auto' } },
76
- selectedItem && label && (React.createElement("label", { className: labelClasses, htmlFor: id }, label)),
77
- React.createElement("button", { className: buttonClassess, onClick: readOnly ? undefined : handleToggle, disabled: disabled },
78
- React.createElement("div", { className: style === 'default' && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) ? styles[`button--default--item-selected`] : '' },
79
- 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' }),
80
- selectedItem ? selectedItem.value : name),
81
- icon && React.cloneElement(icon, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0' })),
82
- getDropdownMenu()));
225
+ document.addEventListener('mousedown', handleClickOutside);
226
+ return () => {
227
+ document.removeEventListener('mousedown', handleClickOutside);
228
+ };
229
+ }, [selectedItem, label, isOpen, size, placeholder, onClose, isLeftLabel]);
230
+ useEffect(() => {
231
+ if (options) {
232
+ const modifiedOptions = options.map((option, index) => {
233
+ const modifiedOption = checkItem === null || checkItem === void 0 ? void 0 : checkItem(option, getOptionLabel, disabled, isDivider);
234
+ if (modifiedOption && modifiedOption.value === (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value)) {
235
+ setActiveIndex(index);
236
+ }
237
+ return modifiedOption;
238
+ });
239
+ setModifiedOptions(modifiedOptions);
240
+ }
241
+ }, [options]);
242
+ useEffect(() => {
243
+ if (value || defaultValue) {
244
+ const startValue = value
245
+ ? checkItem(value)
246
+ : defaultValue
247
+ ? checkItem(defaultValue)
248
+ : null;
249
+ setSelectedItem(startValue !== null && startValue !== void 0 ? startValue : null);
250
+ }
251
+ }, [value, defaultValue, checkItem]);
252
+ return (React.createElement("div", { id: id, className: wrapperClassess, ref: containerRef, style: { width: isLeftLabel && containerWidth ? `${containerWidth}px` : '100%' } },
253
+ label && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, label)),
254
+ React.createElement("button", { className: buttonClassess, onClick: readOnly ? undefined : handleToggle, disabled: disabled, tabIndex: 0, onKeyDown: handleKeyDown },
255
+ React.createElement("div", { className: selectedItemClassess },
256
+ style === 'icons' &&
257
+ (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) &&
258
+ React.cloneElement(selectedItem.icon, {
259
+ strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
260
+ }),
261
+ selectedItem ? selectedItem.value : (placeholder !== null && placeholder !== void 0 ? placeholder : label)),
262
+ clearable && !readOnly && !disabled && selectedItem && (React.createElement("div", { className: styles.resetButton },
263
+ React.createElement(IconClose10, { strokeWidth: "0.2", htmlColor: "var(--text-light)", onClick: handleReset }))),
264
+ React.createElement("div", { className: styles.dropdownIcon }, !isOpen ? (React.createElement(ChevronDown10, { strokeWidth: size === 'lg' ? '0.5' : '0.3' })) : (React.createElement(ChevronUp10, { strokeWidth: size === 'lg' ? '0.5' : '0.3' }))),
265
+ getDropdownMenu()),
266
+ errorInput && errorInputHelperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText, styles[size]) }, helperText !== null && helperText !== void 0 ? helperText : errorInputHelperText))));
83
267
  };
@@ -1,72 +1,69 @@
1
- .story--wrapper {
2
- background-color: var(--white);
3
- padding: 30px;
4
- border-radius: 10px;
5
- width: 900px;
1
+ .dropdown--container {
2
+ position: relative;
3
+ width: 100%;
4
+ max-width: 260px;
6
5
  }
7
- .option--wrapper{
6
+ .dropdown--container-left {
8
7
  display: flex;
8
+ gap: 20px;
9
9
  align-items: center;
10
- justify-content: space-between;
10
+ flex-wrap: nowrap;
11
+ width: fit-content;
12
+ max-width: none;
11
13
  }
12
- .option--icon{
13
- margin-left: 8px;
14
+ .dropdown--container-label {
15
+ margin-top: 20px;
14
16
  }
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;
17
+ .dropdown--container-helperText {
18
+ margin-bottom: 15px;
22
19
  }
23
- .wrapper--left {
20
+
21
+ .option--wrapper {
24
22
  display: flex;
25
- flex-direction: row;
26
- gap: 20px;
27
23
  align-items: center;
28
- flex-wrap: nowrap;
24
+ justify-content: space-between;
25
+ }
26
+
27
+ .option--icon {
28
+ margin-left: 8px;
29
29
  }
30
30
 
31
31
  .button {
32
- font-family: 'Raleway';
32
+ font-family: var(--font-family-main);
33
33
  font-style: normal;
34
34
  font-weight: 400;
35
35
  line-height: 16.5px;
36
-
37
36
  border-radius: 10px;
38
37
  cursor: pointer;
39
- /* padding: 0.5em 1em; */
40
38
  padding: 10px 15px;
41
39
  transition: all 0.3s ease;
42
- width: 100%;
43
- /* background-color: var(--white); */
44
40
  background-color: transparent;
45
- color: rgba(60, 60, 67, 0.6);
41
+ color: var(--text-dark);
46
42
  border: 1px solid var(--grey-light);
43
+ /* mix-blend-mode: multiply; */
47
44
  display: flex;
48
45
  align-items: center;
49
- gap: 10px;
46
+ gap: 20px;
50
47
  justify-content: space-between;
51
- min-width: fit-content;
52
-
48
+ /* min-width: fit-content; */
49
+ position: relative;
50
+ width: 100%;
53
51
  }
54
- .button:hover{
52
+ .button:hover {
55
53
  border: 1px solid #0d9aff00;
56
54
  box-shadow: 0px 0px 2px var(--blue-main);
57
55
  }
58
56
  .button:focus,
59
- .button:active{
57
+ .button:active {
60
58
  border-color: var(--blue-main);
61
59
  box-shadow: none;
62
-
63
60
  }
64
- .button--disabled{
61
+ .button--disabled {
65
62
  background-color: rgba(120, 120, 128, 0.08);
66
63
  border: 1px solid #0d9aff00;
67
64
  color: rgba(60, 60, 67, 0.3);
68
65
  }
69
- .button--readOnly{
66
+ .button--readOnly {
70
67
  background-color: rgba(120, 120, 128, 0.08);
71
68
  border: 1px solid #0d9aff00;
72
69
  color: var(--text-dark);
@@ -76,48 +73,74 @@
76
73
  .button--disabled:active,
77
74
  .button--readOnly:hover,
78
75
  .button--readOnly:focus,
79
- .button--readOnly:active{
76
+ .button--readOnly:active {
80
77
  box-shadow: none;
81
78
  border: 1px solid #0d9aff00;
82
79
  }
83
- .button--default--item-selected{
80
+ .button--error {
81
+ border-color: var(--error-main);
82
+ color: var(--error-main);
83
+ }
84
+ .button--icons--item-selected {
84
85
  display: flex;
85
86
  align-items: center;
86
87
  gap: 10px;
87
88
  }
88
- .button-item--selected{
89
+ .button-item--selected {
89
90
  color: var(--text-dark);
90
91
  }
91
92
 
92
93
  /* Размеры кнопок */
93
- .button--sm {
94
- /* font-size: 0.8rem; */
95
- font-size: 12px;
96
- }
97
94
  .button--md {
98
- /* font-size: 1rem; */
99
- font-size: 14px;
95
+ font-size: 12px;
100
96
  }
101
97
  .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;
98
+ font-size: 14px;
99
+ }
100
+ .button:focus-visible {
101
+ outline: none;
102
+ }
103
+
104
+ .resetButton,
105
+ .dropdownIcon {
106
+ position: absolute;
107
+ background: none;
108
+ border: none;
109
+ cursor: pointer;
110
+ padding: 4px;
111
+ display: flex;
112
+ align-items: center;
113
+ }
114
+
115
+ .resetButton{
116
+ right: 35px;
117
+ }
118
+ .dropdownIcon{
119
+ right: 5px;
120
+ }
121
+ .resetButton:hover,
122
+ .dropdownIcon:hover {
123
+ background-color: rgba(120, 120, 128, 0.08);
124
+ border-radius: 50%;
125
+ }
126
+
127
+ .dropdown {
128
+ position: absolute;
129
+ top: 40px;
130
+ left: 0;
131
+ display: flex;
132
+ margin-top: 5px;
133
+ flex-direction: column;
134
+ align-items: flex-start;
135
+ padding: 10px 0px;
136
+ max-height: 175px;
137
+ width: 100%;
138
+ background: #ffffff;
139
+ box-shadow: 0px 0px 32px rgba(0, 0, 0, 0.2);
140
+ border-radius: 12px;
141
+ overflow-y: auto;
142
+ z-index: 1000;
143
+ overflow-x: hidden;
121
144
  }
122
145
 
123
146
  .item--container {
@@ -126,13 +149,12 @@ overflow-x: hidden;
126
149
  margin: auto;
127
150
  }
128
151
 
129
- .item--container:hover{
152
+ .item--container:hover,
153
+ .item--container--active {
130
154
  background-color: rgba(120, 120, 128, 0.08);
131
155
  border-radius: 5px;
132
- width: 87%;
133
156
  margin: auto;
134
- }
135
-
157
+ }
136
158
 
137
159
  .item-block {
138
160
  cursor: pointer;
@@ -141,30 +163,19 @@ overflow-x: hidden;
141
163
  }
142
164
  .item-block--disabled {
143
165
  color: var(--text-light);
144
- cursor: not-allowed ;
166
+ cursor: not-allowed;
145
167
  }
146
- .item-block-default,
168
+ .item-block-icons,
147
169
  .item-block-text {
148
170
  display: grid;
149
171
  grid-template-columns: auto 1fr;
150
172
  justify-content: flex-start;
151
173
  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
174
  gap: 10px;
163
- color: var(--text-dark);
164
175
  }
165
- .item-block-text--selected{
176
+ .item-block-icons--selected {
166
177
  display: grid;
167
- grid-template-columns: auto auto;
178
+ grid-template-columns: auto 1fr 20px;
168
179
  justify-content: space-between;
169
180
  align-items: center;
170
181
  overflow-x: hidden;
@@ -174,24 +185,21 @@ overflow-x: hidden;
174
185
  color: var(--text-dark);
175
186
  }
176
187
 
177
-
178
- .item {
188
+ .item {
179
189
  overflow: hidden;
180
190
  text-overflow: ellipsis;
181
191
  white-space: nowrap;
182
- max-width: 100%
192
+ max-width: 100%;
193
+ justify-self: self-start;
183
194
  }
184
195
 
185
196
  .label {
186
- line-height: 14px;
187
- font-weight: 400;
188
197
  transition: 0.3ms ease-out;
189
198
  /* color: var(--text-grey); */
190
199
  }
191
200
  .label--default {
192
- font-size: 12px;
193
201
  position: absolute;
194
- top: -20px;
202
+ top: -18px;
195
203
  cursor: text;
196
204
  white-space: nowrap;
197
205
  overflow: hidden;
@@ -199,9 +207,64 @@ overflow-x: hidden;
199
207
  max-width: calc(100% - 32px);
200
208
  color: var(--text-grey);
201
209
  }
210
+ .label--default.lg {
211
+ font-size: 12px;
212
+ }
213
+ .label--default.md {
214
+ font-size: 10px;
215
+ }
216
+
202
217
  .label--left {
203
- font-size: 13px;
204
218
  color: var(--text-dark);
205
219
  min-width: fit-content;
206
220
  }
221
+ .label--left.lg {
222
+ font-size: 14px;
223
+ }
224
+ .label--left.md {
225
+ font-size: 12px;
226
+ }
227
+ /* Стили для обязательного поля */
228
+ .label--default.label--required {
229
+ position: relative;
230
+ top: 0;
231
+ }
232
+ .label--required::after {
233
+ content: '*';
234
+ color: var(--error-main);
235
+ position: absolute;
236
+ margin-left: 2px;
237
+ top: 2px;
238
+ font-size: 22px;
239
+ }
240
+
241
+ .item-selected {
242
+ color: var(--text-dark);
243
+ white-space: nowrap;
244
+ overflow: hidden;
245
+ text-overflow: ellipsis;
246
+ }
247
+
248
+ .item-placeholder {
249
+ color: var(--text-grey);
250
+ transition: 0.3ms ease-out;
251
+ }
207
252
 
253
+ .helperText.md {
254
+ font-size: 10px;
255
+ }
256
+
257
+ .helperText.lg {
258
+ font-size: 12px;
259
+ }
260
+ .helperText {
261
+ position: absolute;
262
+ left: 0px;
263
+ bottom: -17px;
264
+ cursor: text;
265
+ transition: 0.3ms ease-out;
266
+ white-space: nowrap;
267
+ overflow: hidden;
268
+ text-overflow: ellipsis;
269
+ color: var(--error-main);
270
+ }