kamotive_ui 14.1.26 → 14.5.26

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.
@@ -3,4 +3,4 @@ import { ButtonProps } from '../../types';
3
3
  /**
4
4
  * Компонент Button представляет собой кнопку, которую можно настроить с помощью различных параметров (размер, иконки, стили, состояние).
5
5
  */
6
- export declare const Button: React.FC<ButtonProps>;
6
+ export declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
@@ -1,16 +1,24 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import styles from './Button.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { Typography } from '../Typography/Typography';
5
5
  /**
6
6
  * Компонент Button представляет собой кнопку, которую можно настроить с помощью различных параметров (размер, иконки, стили, состояние).
7
7
  */
8
- export const Button = ({ label, variant = 'fill', size = 'md', style, condition, icon, disabled = false, onClick, children, error, color, name, type = 'button', form }) => {
9
- const [buttonStyle, setButtonStyle] = useState('');
10
- const [buttonCondition, setButtonCondition] = useState(condition);
11
- const buttonClasses = classNames(styles['button'], styles[`button--${size}`], styles[`button--${buttonStyle}`], {
8
+ export const Button = React.forwardRef(({ label, variant = 'fill', size = 'md', mode, style, condition, icon, disabled = false, onClick, children, error, color, name, type = 'button', form, className, active, }, ref) => {
9
+ const btnIcon = icon || typeof children === 'object' && children;
10
+ let modeStyle = 'text';
11
+ if (mode) {
12
+ modeStyle = mode;
13
+ }
14
+ else if (btnIcon && variant !== 'link') {
15
+ modeStyle = (!label && !children) ? 'icon' : 'default';
16
+ }
17
+ const buttonCondition = error ? 'error' : (condition || 'default');
18
+ const buttonClasses = classNames(styles['button'], styles[`button--${size}`], styles[`button--${modeStyle}`], className, {
12
19
  [styles[`button--${variant}-${buttonCondition}`]]: buttonCondition && !color,
13
- [styles[`button--${variant}-custom`]]: color && !error
20
+ [styles[`button--${variant}-custom`]]: color && !error,
21
+ [styles[`button--${variant}-${buttonCondition}--active`]]: active && buttonCondition && !color,
14
22
  });
15
23
  const iconColorFn = () => {
16
24
  if (buttonCondition && !color) {
@@ -48,51 +56,19 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
48
56
  return '#FFFFFF';
49
57
  }
50
58
  };
51
- const btnIcon = icon || typeof children === 'object' && children;
52
- useEffect(() => {
53
- if (!buttonStyle && style) {
54
- setButtonStyle(style);
55
- }
56
- else {
57
- if (btnIcon && variant !== 'link') {
58
- if (!label && !(typeof children === 'string' && children)) {
59
- setButtonStyle('icon');
60
- }
61
- else {
62
- setButtonStyle('default');
63
- }
64
- }
65
- else {
66
- setButtonStyle('text');
67
- }
68
- }
69
- }, [style, btnIcon, label, children]);
70
- useEffect(() => {
71
- if (!condition) {
72
- if (error) {
73
- setButtonCondition('error');
74
- }
75
- else {
76
- setButtonCondition('default');
77
- }
78
- }
79
- else {
80
- error ? setButtonCondition('error') : setButtonCondition(condition);
81
- }
82
- }, [condition, error]);
83
59
  const iconColorStyle = iconColorFn();
84
- if (!buttonStyle) {
60
+ if (!modeStyle) {
85
61
  return (React.createElement("button", { className: buttonClasses },
86
62
  React.createElement(Typography, { variant: "Body1" }, "\u041A\u043D\u043E\u043F\u043A\u0430")));
87
63
  }
88
- return (React.createElement("button", { className: buttonClasses, style: color && !error ? {
64
+ return (React.createElement("button", { className: buttonClasses, ref: ref, style: Object.assign(Object.assign({}, style), (color && !error ? {
89
65
  '--button-color': color,
90
66
  '--button-hover-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 90%, black)` : `color-mix(in srgb, ${color} 10%, transparent)`,
91
67
  '--button-active-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, black)` : `color-mix(in srgb, ${color} 20%, transparent)`,
92
68
  '--button-disabled-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 10%, transparent)`,
93
69
  '--button-disabled-textColor': variant === 'fill' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 50%, transparent)`,
94
- } : {}, onClick: onClick, disabled: disabled, "aria-disabled": disabled, type: type, name: name ? name : label ? `button-${label}` : 'button', form: form },
95
- btnIcon && (buttonStyle === 'icon' || buttonStyle === 'default') && (() => {
70
+ } : {})), onClick: (e) => onClick === null || onClick === void 0 ? void 0 : onClick(e), disabled: disabled, "aria-disabled": disabled, type: type, name: name ? name : label ? `button-${label}` : 'button', form: form },
71
+ btnIcon && (modeStyle === 'icon' || modeStyle === 'default') && (() => {
96
72
  var _a;
97
73
  const iconElement = btnIcon;
98
74
  const defaultStrokeWidth = size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0';
@@ -101,5 +77,5 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
101
77
  strokeWidth: (_a = iconElement.props.strokeWidth) !== null && _a !== void 0 ? _a : defaultStrokeWidth,
102
78
  });
103
79
  })(),
104
- (buttonStyle === 'text' || buttonStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
105
- };
80
+ (modeStyle === 'text' || modeStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
81
+ });
@@ -200,7 +200,8 @@
200
200
  color: var(--blue-main);
201
201
  border: 1px solid var(--blue-main);
202
202
  }
203
- .button--outline-default:hover {
203
+ .button--outline-default:hover,
204
+ .button--outline-default--active {
204
205
  background-color: rgba(13, 153, 255, 0.07);
205
206
  color: var(--blue-main);
206
207
  border: 1px solid var(--blue-main);
@@ -24,6 +24,7 @@
24
24
  display: flex;
25
25
  flex-direction: column;
26
26
  gap: 1rem;
27
+ min-height: 0;
27
28
  }
28
29
 
29
30
  .maxWidth--xs {
@@ -1,19 +1,19 @@
1
- import React, { FC } from 'react';
2
- import { DropdownProps, TOptions } from '../../types';
1
+ import React from 'react';
2
+ import { DropdownProps, BaseOptions } from '../../types';
3
3
  /**
4
4
  * Компонент Dropdown позволяет пользователям выбирать однин вариант из выпадающего меню
5
5
  */
6
- export interface DropdownListItemProps {
7
- item: TOptions | null;
8
- getOptionLabel?: (option: TOptions) => string;
6
+ export interface DropdownListItemProps<T extends BaseOptions> {
7
+ item: T | null;
8
+ getOptionLabel?: (option: T) => string;
9
9
  size: 'md' | 'lg';
10
- selectedItem: TOptions | null;
11
- variant?: 'icons' | 'text';
12
- onChange: (event: React.MouseEvent<HTMLElement>, item: TOptions | null) => void;
10
+ selectedItem: T | null | T[];
11
+ variant?: 'icons' | 'text' | 'filter';
12
+ onChange: (event: React.MouseEvent<HTMLElement>, item: T | null) => void;
13
13
  isActive?: boolean;
14
14
  activeIndex?: number;
15
15
  index?: number;
16
16
  isChild?: boolean;
17
17
  }
18
- export declare const DropdownListItem: FC<DropdownListItemProps>;
19
- export declare const Dropdown: FC<DropdownProps>;
18
+ export declare const DropdownListItem: <T extends BaseOptions>({ item, getOptionLabel, size, selectedItem, variant, onChange, isActive, activeIndex, index, isChild, }: DropdownListItemProps<T>) => React.JSX.Element;
19
+ export declare const Dropdown: <T extends BaseOptions>({ options, id, label, placeholder, required, value, defaultValue, onChange, showLoadMore, loadMore, getOptionLabel, variant, size, style, className, isLeftLabel, isDivider, disabled, readOnly, isOpened, error, helperText, onOpen, onClick, onBlur, onFocus, onClose, clearable, enableAutocomplete, onSearch, isOptionsLoading, isSearchLoading, noOptionsText, lng, multiple, limitTags, }: DropdownProps<T>) => React.JSX.Element;