kamotive_ui 15.1.26 → 17.3.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.
@@ -1,14 +1,21 @@
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 = ({ label, variant = 'fill', size = 'md', mode, style, condition, icon, disabled = false, onClick, children, error, color, name, type = 'button', form }) => {
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}`], {
12
19
  [styles[`button--${variant}-${buttonCondition}`]]: buttonCondition && !color,
13
20
  [styles[`button--${variant}-custom`]]: color && !error
14
21
  });
@@ -48,51 +55,19 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
48
55
  return '#FFFFFF';
49
56
  }
50
57
  };
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
58
  const iconColorStyle = iconColorFn();
84
- if (!buttonStyle) {
59
+ if (!modeStyle) {
85
60
  return (React.createElement("button", { className: buttonClasses },
86
61
  React.createElement(Typography, { variant: "Body1" }, "\u041A\u043D\u043E\u043F\u043A\u0430")));
87
62
  }
88
- return (React.createElement("button", { className: buttonClasses, style: color && !error ? {
63
+ return (React.createElement("button", { className: buttonClasses, style: Object.assign(Object.assign({}, style), (color && !error ? {
89
64
  '--button-color': color,
90
65
  '--button-hover-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 90%, black)` : `color-mix(in srgb, ${color} 10%, transparent)`,
91
66
  '--button-active-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, black)` : `color-mix(in srgb, ${color} 20%, transparent)`,
92
67
  '--button-disabled-color': variant === 'fill' || variant === 'link' ? `color-mix(in srgb, ${color} 80%, white)` : `color-mix(in srgb, ${color} 10%, transparent)`,
93
68
  '--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') && (() => {
69
+ } : {})), 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 },
70
+ btnIcon && (modeStyle === 'icon' || modeStyle === 'default') && (() => {
96
71
  var _a;
97
72
  const iconElement = btnIcon;
98
73
  const defaultStrokeWidth = size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0';
@@ -101,5 +76,5 @@ export const Button = ({ label, variant = 'fill', size = 'md', style, condition,
101
76
  strokeWidth: (_a = iconElement.props.strokeWidth) !== null && _a !== void 0 ? _a : defaultStrokeWidth,
102
77
  });
103
78
  })(),
104
- (buttonStyle === 'text' || buttonStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
79
+ (modeStyle === 'text' || modeStyle === 'default') && (React.createElement(Typography, { variant: "Body1" }, label ? label : typeof children === 'string' && children))));
105
80
  };
@@ -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, isLoadMoreLoading, isSearchLoading, noOptionsText, lng, multiple, limitTags, }: DropdownProps<T>) => React.JSX.Element;