kamotive_ui 1.2.4 → 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.
|
@@ -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;
|
|
@@ -51,7 +51,7 @@ function checkItem(item, getOptionLabel, disabled, isDivider) {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedItem,
|
|
54
|
+
export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedItem, variant, onChange, isActive, activeIndex, index, }) => {
|
|
55
55
|
var _a;
|
|
56
56
|
const handleItemClick = useCallback((event) => {
|
|
57
57
|
event.preventDefault();
|
|
@@ -65,11 +65,11 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
65
65
|
[styles['item-block--disabled']]: item === null || item === void 0 ? void 0 : item.disabled,
|
|
66
66
|
[styles['item-block--active']]: isActive,
|
|
67
67
|
});
|
|
68
|
-
const itemBlock = classNames(styles[`item-block`], styles[`item-block-${
|
|
68
|
+
const itemBlock = classNames(styles[`item-block`], styles[`item-block-${variant}`], { [styles[`item-block-${variant}--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
69
|
return (React.createElement("div", { className: itemContainerClasses, onClick: handleItemClick },
|
|
70
70
|
React.createElement("div", { className: itemClassess },
|
|
71
71
|
React.createElement("div", { className: itemBlock },
|
|
72
|
-
|
|
72
|
+
variant === 'icons' &&
|
|
73
73
|
(item === null || item === void 0 ? void 0 : item.icon) &&
|
|
74
74
|
React.cloneElement(item.icon, {
|
|
75
75
|
strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
|
|
@@ -83,7 +83,7 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
83
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
84
|
})))));
|
|
85
85
|
};
|
|
86
|
-
export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOptionLabel, value, defaultValue,
|
|
86
|
+
export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOptionLabel, value, defaultValue, variant = 'text', style, className, disabled = false, readOnly = false, isOpened = false, noOptionsText = 'Нет вариатов для выбора', isLeftLabel = false, error = false, helperText, onChange, onClose, clearable = true, required = false, isDivider = false, }) => {
|
|
87
87
|
var _a;
|
|
88
88
|
const [isOpen, setIsOpen] = useState(isOpened);
|
|
89
89
|
const [modifiedOptions, setModifiedOptions] = useState([]);
|
|
@@ -170,13 +170,13 @@ export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOpti
|
|
|
170
170
|
setErrorInputHelperText(helperText !== null && helperText !== void 0 ? helperText : 'Поле обязательно для заполнения');
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
const wrapperClassess = classNames({
|
|
173
|
+
const wrapperClassess = classNames(className, {
|
|
174
174
|
[styles['dropdown--container']]: !isLeftLabel,
|
|
175
175
|
[styles['dropdown--container-left']]: isLeftLabel,
|
|
176
176
|
[styles['dropdown--container-label']]: label && !isLeftLabel && !required,
|
|
177
177
|
[styles['dropdown--container-helperText']]: errorInput,
|
|
178
178
|
});
|
|
179
|
-
const buttonClassess = classNames(styles.button,
|
|
179
|
+
const buttonClassess = classNames(styles.button, styles[`button--${size}`], {
|
|
180
180
|
[styles['button-item--selected']]: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value) && !disabled,
|
|
181
181
|
[styles['button--readOnly']]: readOnly,
|
|
182
182
|
[styles['button--disabled']]: disabled,
|
|
@@ -193,12 +193,12 @@ export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOpti
|
|
|
193
193
|
const selectedItemClassess = classNames({
|
|
194
194
|
[styles['item-selected']]: selectedItem,
|
|
195
195
|
[styles['item-placeholder']]: !selectedItem && ((placeholder !== null && placeholder !== void 0 ? placeholder : label) || (!placeholder && !label)),
|
|
196
|
-
[styles['button--icons--item-selected']]:
|
|
196
|
+
[styles['button--icons--item-selected']]: variant === 'icons' && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon),
|
|
197
197
|
});
|
|
198
198
|
const getDropdownMenu = () => {
|
|
199
199
|
const menu = isOpen && (React.createElement("div", { className: dropdownClassess }, modifiedOptions && modifiedOptions.length > 0 ? (modifiedOptions.map((modifiedOption, index) => {
|
|
200
200
|
var _a;
|
|
201
|
-
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,
|
|
201
|
+
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, variant: variant, onChange: onChangeHandler, isActive: activeIndex === index, activeIndex: activeIndex, index: index }));
|
|
202
202
|
})) : (React.createElement("div", { className: styles['no-options'] }, noOptionsText))));
|
|
203
203
|
return isOpen ? menu : null;
|
|
204
204
|
};
|
|
@@ -258,11 +258,11 @@ export const Dropdown = ({ id, label, placeholder, size = 'lg', options, getOpti
|
|
|
258
258
|
useEffect(() => {
|
|
259
259
|
setErrorInput(error);
|
|
260
260
|
}, [error]);
|
|
261
|
-
return (React.createElement("div", { id: id, className: wrapperClassess, ref: containerRef, style: { width: isLeftLabel && containerWidth ? `${containerWidth}px` : '100%' } },
|
|
261
|
+
return (React.createElement("div", { id: id, className: wrapperClassess, ref: containerRef, style: style ? style : { width: isLeftLabel && containerWidth ? `${containerWidth}px` : '100%' } },
|
|
262
262
|
label && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, label)),
|
|
263
263
|
React.createElement("button", { className: buttonClassess, onClick: readOnly ? undefined : handleToggle, disabled: disabled, tabIndex: 0, onKeyDown: handleKeyDown },
|
|
264
264
|
React.createElement("div", { className: selectedItemClassess },
|
|
265
|
-
|
|
265
|
+
variant === 'icons' &&
|
|
266
266
|
(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) &&
|
|
267
267
|
React.cloneElement(selectedItem.icon, {
|
|
268
268
|
strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
|
|
@@ -4,11 +4,12 @@ import styles from './FileAttach.module.css';
|
|
|
4
4
|
import { Typography } from '../Typography/Typography';
|
|
5
5
|
import { IconUpload } from '../../Icons';
|
|
6
6
|
import { Loader } from '../Loader/Loader';
|
|
7
|
+
import classNames from 'classnames';
|
|
7
8
|
export const FileAttach = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats = {
|
|
8
9
|
'image/*': ['.png', '.gif', '.jpeg', '.jpg'],
|
|
9
10
|
'application/pdf': ['.pdf'],
|
|
10
11
|
'application/msword': ['.doc', '.docx'],
|
|
11
|
-
}, addedFiles, setAddedFiles, disabled = false, }) => {
|
|
12
|
+
}, addedFiles, setAddedFiles, disabled = false, className, style, }) => {
|
|
12
13
|
const [errorFiles, setErrorFiles] = useState([]);
|
|
13
14
|
const fileValidator = (file) => {
|
|
14
15
|
if (file.size > maxFileSize * 1024 * 1024 * 1024) {
|
|
@@ -59,7 +60,7 @@ export const FileAttach = ({ maxFileSize = 2, maxFileCount = 10, acceptedFormats
|
|
|
59
60
|
}
|
|
60
61
|
return formats.join(', ');
|
|
61
62
|
};
|
|
62
|
-
return (React.createElement("section", { className: styles['fileAttach'] },
|
|
63
|
+
return (React.createElement("section", { className: classNames(styles['fileAttach'], className), style: style },
|
|
63
64
|
React.createElement("div", Object.assign({}, getRootProps({ className: `${styles['dropzone']} ${disabled ? styles['disabled'] : ''}` })),
|
|
64
65
|
React.createElement("input", Object.assign({}, getInputProps())),
|
|
65
66
|
React.createElement(IconUpload, { htmlColor: disabled ? 'var(--grey-medium)' : 'var(--icons-grey)' }),
|
|
@@ -6,7 +6,7 @@ import { Typography } from '../Typography/Typography';
|
|
|
6
6
|
/**
|
|
7
7
|
* Компонент Input для создания текстовых полей ввода различных стилей и размеров.
|
|
8
8
|
*/
|
|
9
|
-
export const Input = ({ id, label, placeholder, size = 'lg', value, className, multiline = false, rows = 4, resize = false, disabled = false, readOnly = false, isLeftLabel = false, icon, error = false, helperText, onChange, required = false, }) => {
|
|
9
|
+
export const Input = ({ id, label, placeholder, size = 'lg', value, style, className, multiline = false, rows = 4, resize = false, disabled = false, readOnly = false, isLeftLabel = false, icon, error = false, helperText, onChange, required = false, }) => {
|
|
10
10
|
const [inputLabel, setInputLabel] = useState(label);
|
|
11
11
|
const handleChange = (event) => {
|
|
12
12
|
event.stopPropagation();
|
|
@@ -21,12 +21,12 @@ export const Input = ({ id, label, placeholder, size = 'lg', value, className, m
|
|
|
21
21
|
setInputLabel('');
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
const wrapperClassess = classNames(styles['wrapper--input'], {
|
|
24
|
+
const wrapperClassess = classNames(styles['wrapper--input'], className, {
|
|
25
25
|
[styles['wrapper--left']]: isLeftLabel,
|
|
26
26
|
[styles['wrapper--input-label']]: label && !isLeftLabel && !required,
|
|
27
27
|
[styles['wrapper--input-helperText']]: error,
|
|
28
28
|
});
|
|
29
|
-
const inputClassess = classNames(styles.input, styles[size],
|
|
29
|
+
const inputClassess = classNames(styles.input, styles[size], {
|
|
30
30
|
[styles['input--error']]: error,
|
|
31
31
|
[styles['readOnly']]: readOnly,
|
|
32
32
|
[styles['input--withIcon']]: icon,
|
|
@@ -40,7 +40,7 @@ export const Input = ({ id, label, placeholder, size = 'lg', value, className, m
|
|
|
40
40
|
[styles['label--left']]: isLeftLabel,
|
|
41
41
|
[styles['label--required']]: required,
|
|
42
42
|
});
|
|
43
|
-
return (React.createElement("div", { className: wrapperClassess },
|
|
43
|
+
return (React.createElement("div", { className: wrapperClassess, style: style },
|
|
44
44
|
inputLabel && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, inputLabel)),
|
|
45
45
|
icon && React.createElement("div", { className: styles.icon }, icon),
|
|
46
46
|
multiline ? (React.createElement("textarea", { id: id, className: inputClassess, value: value, placeholder: placeholder, onChange: handleChange, disabled: disabled, style: { height: `${rows * 20}px` } })) : (React.createElement("input", { id: id, className: inputClassess, value: value, placeholder: placeholder, onChange: handleChange, disabled: disabled, readOnly: readOnly })),
|
package/dist/types/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface InputProps {
|
|
|
45
45
|
size?: 'sm' | 'md' | 'lg';
|
|
46
46
|
/** Знчение */
|
|
47
47
|
value?: string;
|
|
48
|
+
/** Стили передаваемые напрямую */
|
|
49
|
+
style?: CSSProperties;
|
|
48
50
|
/** Дополнительный класс */
|
|
49
51
|
className?: string;
|
|
50
52
|
/** Многострочное поле */
|
|
@@ -134,8 +136,10 @@ export interface DropdownProps {
|
|
|
134
136
|
value?: string | number | TOptions | null;
|
|
135
137
|
/** Значение по умолчанию */
|
|
136
138
|
defaultValue?: string | number | TOptions | null;
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
+
/** Вариaнты выпадающего списка(текст + иконка, текст)' */
|
|
140
|
+
variant?: 'icons' | 'text';
|
|
141
|
+
/** Стили передаваемые напрямую */
|
|
142
|
+
style?: CSSProperties;
|
|
139
143
|
/**Дополнительный класс */
|
|
140
144
|
className?: string;
|
|
141
145
|
/** Заблокированный */
|
|
@@ -307,4 +311,8 @@ export interface FileAttachProps {
|
|
|
307
311
|
setAddedFiles: (addedFiles: File[]) => void;
|
|
308
312
|
/**Заблокировано добавление файлов*/
|
|
309
313
|
disabled?: boolean;
|
|
314
|
+
/** Дополнительный класс */
|
|
315
|
+
className?: string;
|
|
316
|
+
/** Стили передаваемые напрямую */
|
|
317
|
+
style?: CSSProperties;
|
|
310
318
|
}
|