@true-engineering/true-react-common-ui-kit 3.9.2 → 3.11.0

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 (68) hide show
  1. package/README.md +18 -0
  2. package/dist/components/Button/constants.d.ts +1 -0
  3. package/dist/components/Button/types.d.ts +2 -2
  4. package/dist/components/CloseButton/CloseButton.d.ts +1 -0
  5. package/dist/components/CloseButton/CloseButton.stories.d.ts +5 -0
  6. package/dist/components/IconButton/IconButton.d.ts +19 -0
  7. package/dist/components/IconButton/IconButton.stories.d.ts +6 -0
  8. package/dist/components/IconButton/IconButton.styles.d.ts +3 -0
  9. package/dist/components/IconButton/constants.d.ts +2 -0
  10. package/dist/components/IconButton/index.d.ts +3 -0
  11. package/dist/components/IconButton/types.d.ts +5 -0
  12. package/dist/components/Modal/Modal.styles.d.ts +3 -2
  13. package/dist/components/TextButton/TextButton.d.ts +6 -5
  14. package/dist/components/TextButton/TextButton.stories.d.ts +2 -1
  15. package/dist/components/TextButton/constants.d.ts +2 -0
  16. package/dist/components/TextButton/index.d.ts +1 -1
  17. package/dist/components/TextButton/types.d.ts +5 -0
  18. package/dist/components/Toaster/Toaster.styles.d.ts +2 -2
  19. package/dist/components/index.d.ts +1 -0
  20. package/dist/theme/common.d.ts +2 -0
  21. package/dist/theme/types.d.ts +2 -1
  22. package/dist/true-react-common-ui-kit.js +711 -493
  23. package/dist/true-react-common-ui-kit.js.map +1 -1
  24. package/dist/true-react-common-ui-kit.umd.cjs +711 -493
  25. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/AccountInfo/AccountInfo.styles.ts +3 -2
  28. package/src/components/Button/Button.stories.tsx +3 -5
  29. package/src/components/Button/Button.styles.ts +2 -2
  30. package/src/components/Button/constants.ts +2 -0
  31. package/src/components/Button/types.ts +2 -2
  32. package/src/components/CloseButton/CloseButton.stories.tsx +11 -0
  33. package/src/components/CloseButton/CloseButton.styles.ts +3 -2
  34. package/src/components/CloseButton/CloseButton.tsx +1 -0
  35. package/src/components/FiltersPane/FiltersPane.styles.ts +3 -2
  36. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.styles.ts +3 -2
  37. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.ts +2 -2
  38. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +8 -2
  39. package/src/components/FlexibleTable/FlexibleTable.styles.ts +3 -2
  40. package/src/components/IconButton/IconButton.stories.tsx +32 -0
  41. package/src/components/IconButton/IconButton.styles.ts +88 -0
  42. package/src/components/IconButton/IconButton.tsx +74 -0
  43. package/src/components/IconButton/constants.ts +3 -0
  44. package/src/components/IconButton/index.ts +3 -0
  45. package/src/components/IconButton/types.ts +11 -0
  46. package/src/components/IncrementInput/IncrementInput.styles.ts +3 -2
  47. package/src/components/Input/Input.styles.ts +6 -5
  48. package/src/components/List/List.styles.ts +3 -2
  49. package/src/components/List/components/ListItem/ListItem.styles.ts +3 -2
  50. package/src/components/Modal/Modal.styles.ts +17 -2
  51. package/src/components/Modal/Modal.tsx +7 -4
  52. package/src/components/MoreMenu/MoreMenu.styles.ts +3 -2
  53. package/src/components/NewMoreMenu/NewMoreMenu.styles.ts +3 -2
  54. package/src/components/Select/CustomSelect.stories.tsx +1 -1
  55. package/src/components/Selector/Selector.styles.ts +4 -3
  56. package/src/components/Switch/Switch.styles.ts +4 -4
  57. package/src/components/TextArea/TextArea.styles.ts +4 -4
  58. package/src/components/TextButton/TextButton.stories.tsx +3 -2
  59. package/src/components/TextButton/TextButton.styles.ts +4 -3
  60. package/src/components/TextButton/TextButton.tsx +72 -65
  61. package/src/components/TextButton/constants.ts +3 -0
  62. package/src/components/TextButton/index.ts +1 -2
  63. package/src/components/TextButton/types.ts +11 -0
  64. package/src/components/Toaster/Toaster.styles.ts +2 -2
  65. package/src/components/Toaster/Toaster.tsx +5 -4
  66. package/src/components/index.ts +1 -0
  67. package/src/theme/common.ts +2 -0
  68. package/src/theme/types.ts +8 -6
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { isNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
- import { colors, dimensions, ITweakStyles, createThemedStyles } from '../../theme';
3
+ import { colors, dimensions, ITweakStyles, createThemedStyles, animations } from '../../theme';
4
4
 
5
5
  const SELECTOR_TOTAL_GAP = 4;
6
6
  const SELECTOR_BORDER_WIDTH = 1;
@@ -107,7 +107,7 @@ export const useStyles = createThemedStyles('Selector', {
107
107
  height: `calc(100% - ${SELECTOR_GAP * 2}px)`,
108
108
  backgroundColor: colors.CLASSIC_WHITE,
109
109
  borderRadius: dimensions.BORDER_RADIUS_SMALL,
110
- transition: '0.25s ease-in-out',
110
+ transition: animations.defaultTransition,
111
111
  transitionProperty: 'transform, width',
112
112
  },
113
113
 
@@ -122,7 +122,8 @@ export const useStyles = createThemedStyles('Selector', {
122
122
  height: '100%',
123
123
  color: colors.FONT_MEDIUM,
124
124
  fontSize: 16,
125
- transition: 'color 0.25s ease-in-out',
125
+ transition: animations.defaultTransition,
126
+ transitionProperty: 'color',
126
127
  background: 'none',
127
128
 
128
129
  '&$s': {
@@ -1,4 +1,4 @@
1
- import { ITweakStyles, createThemedStyles } from '../../theme';
1
+ import { ITweakStyles, animations, createThemedStyles } from '../../theme';
2
2
 
3
3
  export const useStyles = createThemedStyles('Switch', {
4
4
  root: {
@@ -33,8 +33,8 @@ export const useStyles = createThemedStyles('Switch', {
33
33
  backgroundColor: '#333',
34
34
  borderRadius: 10,
35
35
  boxSizing: 'border-box',
36
+ transition: animations.defaultTransition,
36
37
  transitionProperty: 'opacity, background-color',
37
- transition: '0.25s ease-in-out',
38
38
 
39
39
  '&::before': {
40
40
  content: '""',
@@ -48,8 +48,8 @@ export const useStyles = createThemedStyles('Switch', {
48
48
  backgroundColor: '#fff',
49
49
  borderRadius: '50%',
50
50
  zIndex: 1,
51
+ transition: animations.defaultTransition,
51
52
  transitionProperty: 'left, background-color',
52
- transition: '0.25s ease-in-out',
53
53
  },
54
54
  },
55
55
 
@@ -58,8 +58,8 @@ export const useStyles = createThemedStyles('Switch', {
58
58
  },
59
59
 
60
60
  label: {
61
+ transition: animations.defaultTransition,
61
62
  transitionProperty: 'opacity, color',
62
- transition: '0.25s ease-in-out',
63
63
  },
64
64
 
65
65
  labelLeft: {
@@ -1,4 +1,4 @@
1
- import { ITweakStyles, createThemedStyles } from '../../theme';
1
+ import { ITweakStyles, animations, createThemedStyles } from '../../theme';
2
2
 
3
3
  const PADDING_X = 12;
4
4
 
@@ -16,7 +16,7 @@ export const useStyles = createThemedStyles('TextArea', {
16
16
  width: '100%',
17
17
  flexGrow: 1,
18
18
  boxSizing: 'border-box',
19
- transition: '0.25s ease-in-out',
19
+ transition: animations.defaultTransition,
20
20
  transitionProperty: 'border-color',
21
21
  backgroundColor: 'white',
22
22
  border: ['solid', 1, 'lightgray'],
@@ -31,7 +31,7 @@ export const useStyles = createThemedStyles('TextArea', {
31
31
  fontFamily: 'inherit',
32
32
  fontSize: 16,
33
33
  padding: [14, PADDING_X, 8],
34
- transition: '0.25s ease-in-out',
34
+ transition: animations.defaultTransition,
35
35
  transitionProperty: 'background-color',
36
36
  border: 'none',
37
37
  resize: 'none',
@@ -95,7 +95,7 @@ export const useStyles = createThemedStyles('TextArea', {
95
95
  top: PADDING_X * 2,
96
96
  transformOrigin: 'top left',
97
97
  transform: 'translateY(-50%)',
98
- transition: '0.25s ease-in-out',
98
+ transition: animations.defaultTransition,
99
99
  transitionProperty: 'transform, color',
100
100
  fontSize: 16,
101
101
  },
@@ -2,6 +2,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
2
  import { IIconType, iconsList } from '../Icon';
3
3
  import { complexIcons } from '../Icon/complexIcons';
4
4
  import { TextButton } from './TextButton';
5
+ import { TEXT_BUTTON_SIZES, TEXT_BUTTON_VIEWS } from './constants';
5
6
 
6
7
  const iconTypes = [
7
8
  undefined,
@@ -28,8 +29,8 @@ export default {
28
29
 
29
30
  argTypes: {
30
31
  icon: { control: 'select', options: iconTypes },
31
- size: { control: 'inline-radio' },
32
- view: { control: 'inline-radio' },
32
+ size: { options: TEXT_BUTTON_SIZES, control: 'inline-radio' },
33
+ view: { options: TEXT_BUTTON_VIEWS, control: 'inline-radio' },
33
34
  iconPosition: { control: 'inline-radio' },
34
35
  preloaderType: { control: 'inline-radio' },
35
36
  },
@@ -1,4 +1,4 @@
1
- import { createThemedStyles, ITweakStyles } from '../../theme';
1
+ import { animations, createThemedStyles, ITweakStyles } from '../../theme';
2
2
  import { IThemedPreloaderStyles } from '../ThemedPreloader';
3
3
 
4
4
  export const useStyles = createThemedStyles('TextButton', {
@@ -12,7 +12,8 @@ export const useStyles = createThemedStyles('TextButton', {
12
12
  borderRadius: 0,
13
13
  cursor: 'pointer',
14
14
  outline: 'none',
15
- transition: 'color 0.25s ease-in-out',
15
+ transition: animations.defaultTransition,
16
+ transitionProperty: 'color',
16
17
 
17
18
  '&[disabled]': {
18
19
  cursor: 'default',
@@ -65,7 +66,7 @@ export const useStyles = createThemedStyles('TextButton', {
65
66
  width: 24,
66
67
  height: 24,
67
68
  borderRadius: '50%',
68
- transition: '0.25s ease-in-out',
69
+ transition: animations.defaultTransition,
69
70
  transitionProperty: ['background', 'color'],
70
71
  },
71
72
 
@@ -1,4 +1,4 @@
1
- import { ButtonHTMLAttributes, FC, ReactNode } from 'react';
1
+ import { forwardRef, ReactNode } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
4
  import { addDataAttributes } from '../../helpers';
@@ -6,17 +6,18 @@ import { useTweakStyles } from '../../hooks';
6
6
  import { ICommonProps } from '../../types';
7
7
  import { IIcon, renderIcon } from '../Icon';
8
8
  import { IThemedPreloaderProps, ThemedPreloader } from '../ThemedPreloader';
9
+ import { ITextButtonHTMLBaseProps, ITextButtonSize, ITextButtonView } from './types';
9
10
  import { useStyles, ITextButtonStyles, preloaderStyles } from './TextButton.styles';
10
11
 
11
12
  export interface ITextButtonProps
12
13
  extends ICommonProps<ITextButtonStyles>,
13
- Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'disabled'> {
14
+ ITextButtonHTMLBaseProps {
14
15
  /** @default 'undefined' */
15
16
  children?: ReactNode;
16
17
  /** @default 'undefined' */
17
18
  icon?: IIcon;
18
19
  /** @default 'primary' */
19
- view?: 'primary' | 'secondary' | 'custom';
20
+ view?: ITextButtonView;
20
21
  /** @default false */
21
22
  isBold?: boolean;
22
23
  /** @default false */
@@ -28,76 +29,82 @@ export interface ITextButtonProps
28
29
  /** @default false */
29
30
  isActive?: boolean;
30
31
  /** @default 'l' */
31
- size?: 'l' | 'xl';
32
+ size?: ITextButtonSize;
32
33
  /** @default 'left' */
33
34
  iconPosition?: 'left' | 'right';
34
35
  /** @default 'dots' */
35
36
  preloaderType?: IThemedPreloaderProps['type'];
36
37
  }
37
38
 
38
- export const TextButton: FC<ITextButtonProps> = ({
39
- children,
40
- icon,
41
- view = 'primary',
42
- isDisabled = false,
43
- isBold = false,
44
- isLoading = false,
45
- isActive = false,
46
- hasCircleUnderIcon = false,
47
- size = 'l',
48
- iconPosition = 'left',
49
- preloaderType = 'dots',
50
- type = 'button',
51
- testId,
52
- tweakStyles,
53
- data,
54
- onClick,
55
- ...restProps
56
- }) => {
57
- const classes = useStyles({ theme: tweakStyles });
39
+ export const TextButton = forwardRef<HTMLButtonElement, ITextButtonProps>(
40
+ (
41
+ {
42
+ children,
43
+ icon,
44
+ view = 'primary',
45
+ isDisabled = false,
46
+ isBold = false,
47
+ isLoading = false,
48
+ isActive = false,
49
+ hasCircleUnderIcon = false,
50
+ size = 'l',
51
+ iconPosition = 'left',
52
+ preloaderType = 'dots',
53
+ type = 'button',
54
+ testId,
55
+ tweakStyles,
56
+ data,
57
+ onClick,
58
+ ...restProps
59
+ },
60
+ ref,
61
+ ) => {
62
+ const classes = useStyles({ theme: tweakStyles });
58
63
 
59
- const tweakPreloaderStyles = useTweakStyles({
60
- innerStyles: preloaderStyles,
61
- tweakStyles,
62
- className: 'tweakPreloader',
63
- currentComponentName: 'TextButton',
64
- });
64
+ const tweakPreloaderStyles = useTweakStyles({
65
+ innerStyles: preloaderStyles,
66
+ tweakStyles,
67
+ className: 'tweakPreloader',
68
+ currentComponentName: 'TextButton',
69
+ });
65
70
 
66
- const hasNoAction = isDisabled || isLoading;
71
+ const hasNoAction = isDisabled || isLoading;
67
72
 
68
- return (
69
- <button
70
- className={clsx(classes.root, classes[size], classes[view], {
71
- [classes.bold]: isBold,
72
- [classes.loading]: isLoading,
73
- [classes.active]: isActive,
74
- [classes.disabled]: isDisabled,
75
- })}
76
- onClick={!hasNoAction ? onClick : undefined}
77
- disabled={hasNoAction}
78
- type={type}
79
- {...restProps}
80
- {...addDataTestId(testId)}
81
- {...addDataAttributes(data)}
82
- >
83
- <span className={clsx(classes.content, iconPosition === 'right' && classes.reverseContent)}>
84
- {isReactNodeNotEmpty(icon) && (
85
- <span className={clsx(classes.iconContainer, hasCircleUnderIcon && classes.circle)}>
86
- <span className={classes.icon}>{renderIcon(icon)}</span>
73
+ return (
74
+ <button
75
+ ref={ref}
76
+ type={type}
77
+ className={clsx(classes.root, classes[size], classes[view], {
78
+ [classes.bold]: isBold,
79
+ [classes.loading]: isLoading,
80
+ [classes.active]: isActive,
81
+ [classes.disabled]: isDisabled,
82
+ })}
83
+ disabled={hasNoAction}
84
+ onClick={!hasNoAction ? onClick : undefined}
85
+ {...restProps}
86
+ {...addDataTestId(testId)}
87
+ {...addDataAttributes(data)}
88
+ >
89
+ <span className={clsx(classes.content, iconPosition === 'right' && classes.reverseContent)}>
90
+ {isReactNodeNotEmpty(icon) && (
91
+ <span className={clsx(classes.iconContainer, hasCircleUnderIcon && classes.circle)}>
92
+ <span className={classes.icon}>{renderIcon(icon)}</span>
93
+ </span>
94
+ )}
95
+ {children}
96
+ </span>
97
+
98
+ {isLoading && (
99
+ <span className={classes.loader}>
100
+ <ThemedPreloader
101
+ type={preloaderType}
102
+ useCurrentColor
103
+ tweakStyles={tweakPreloaderStyles}
104
+ />
87
105
  </span>
88
106
  )}
89
- {children}
90
- </span>
91
-
92
- {isLoading && (
93
- <span className={classes.loader}>
94
- <ThemedPreloader
95
- type={preloaderType}
96
- useCurrentColor
97
- tweakStyles={tweakPreloaderStyles}
98
- />
99
- </span>
100
- )}
101
- </button>
102
- );
103
- };
107
+ </button>
108
+ );
109
+ },
110
+ );
@@ -0,0 +1,3 @@
1
+ export const TEXT_BUTTON_SIZES = ['l', 'xl'] as const;
2
+
3
+ export const TEXT_BUTTON_VIEWS = ['primary', 'secondary', 'custom'] as const;
@@ -1,4 +1,3 @@
1
1
  export * from './TextButton';
2
- export * from './TextButton';
3
-
2
+ export * from './types';
4
3
  export type { ITextButtonStyles } from './TextButton.styles';
@@ -0,0 +1,11 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import { TEXT_BUTTON_SIZES, TEXT_BUTTON_VIEWS } from './constants';
3
+
4
+ export type ITextButtonSize = (typeof TEXT_BUTTON_SIZES)[number];
5
+
6
+ export type ITextButtonView = (typeof TEXT_BUTTON_VIEWS)[number];
7
+
8
+ export type ITextButtonHTMLBaseProps = Omit<
9
+ ButtonHTMLAttributes<HTMLButtonElement>,
10
+ 'disabled' | 'style' | 'className'
11
+ >;
@@ -1,5 +1,5 @@
1
1
  import { colors, ITweakStyles, createThemedStyles } from '../../theme';
2
- import { ICloseButtonStyles } from '../CloseButton';
2
+ import { IIconButtonStyles } from '../IconButton';
3
3
 
4
4
  export const useStyles = createThemedStyles('Toaster', {
5
5
  root: {
@@ -56,5 +56,5 @@ export const useStyles = createThemedStyles('Toaster', {
56
56
 
57
57
  export type IToasterStyles = ITweakStyles<
58
58
  typeof useStyles,
59
- { tweakCloseButton: ICloseButtonStyles }
59
+ { tweakCloseButton: IIconButtonStyles }
60
60
  >;
@@ -9,8 +9,8 @@ import {
9
9
  import { addDataAttributes } from '../../helpers';
10
10
  import { useTweakStyles } from '../../hooks';
11
11
  import { ICommonProps } from '../../types';
12
- import { CloseButton } from '../CloseButton';
13
12
  import { Icon } from '../Icon';
13
+ import { IconButton } from '../IconButton';
14
14
  import { DEFAULT_TIMEOUT } from './constants';
15
15
  import { IToasterType } from './types';
16
16
  import { useStyles, IToasterStyles } from './Toaster.styles';
@@ -96,10 +96,11 @@ export const Toaster: FC<IToasterProps> = ({
96
96
  </div>
97
97
  {hasCloseButton && isNotEmpty(onClose) && (
98
98
  <div className={classes.close}>
99
- <CloseButton
100
- onClose={onClose}
101
- iconType="close-window"
99
+ <IconButton
100
+ view="cancel-light"
101
+ icon="close-window"
102
102
  tweakStyles={tweakCloseButtonStyles}
103
+ onClick={onClose}
103
104
  />
104
105
  </div>
105
106
  )}
@@ -12,6 +12,7 @@ export * from './FiltersPane';
12
12
  export * from './Flag';
13
13
  export * from './FlexibleTable';
14
14
  export * from './Icon';
15
+ export * from './IconButton';
15
16
  export * from './IncrementInput';
16
17
  export * from './Input';
17
18
  export * from './List';
@@ -118,6 +118,7 @@ const SLIDE_UP_POSITION_START = 15;
118
118
  const SLIDE_UP_POSITION_END = 0;
119
119
 
120
120
  export const animations = {
121
+ defaultTransition: '0.25s ease-in-out',
121
122
  // Если понадобится, сюда можно пробросить параметры через useTheme props
122
123
  slideUp: {
123
124
  'slide-up-enter': {
@@ -150,6 +151,7 @@ export interface ICommonUiKitTheme extends IUiKitTheme {
150
151
  colors: typeof colors;
151
152
  dimensions: typeof dimensions;
152
153
  helpers: typeof helpers;
154
+ animations: typeof animations;
153
155
  }
154
156
 
155
157
  export const common: ICommonUiKitTheme = {
@@ -18,14 +18,19 @@ import type {
18
18
  IFilterSelectStyles,
19
19
  IFiltersPaneSearchStyles,
20
20
  IFiltersPaneStyles,
21
+ IFilterValueViewStyles,
21
22
  IFilterWithDatesStyles,
22
23
  IFilterWithPeriodStyles,
23
24
  IFilterWrapperStyles,
24
25
  IFlagStyles,
26
+ IFlexibleTableCellStyles,
27
+ IFlexibleTableRowStyles,
25
28
  IFlexibleTableStyles,
29
+ IIconButtonStyles,
26
30
  IIconStyles,
27
31
  IIncrementInputStyles,
28
32
  IInputStyles,
33
+ IListItemStyles,
29
34
  IListStyles,
30
35
  IModalStyles,
31
36
  IMoreMenuStyles,
@@ -39,20 +44,16 @@ import type {
39
44
  IRadioButtonStyles,
40
45
  ISearchInputStyles,
41
46
  ISelectListStyles,
42
- ISelectStyles,
43
- IFilterValueViewStyles,
44
- IFlexibleTableCellStyles,
45
- IFlexibleTableRowStyles,
46
- IListItemStyles,
47
47
  ISelectorStyles,
48
+ ISelectStyles,
48
49
  ISkeletonStyles,
50
+ IStatusStyles,
49
51
  ISvgIcon,
50
52
  ISvgPreloaderStyles,
51
53
  ISwitchStyles,
52
54
  ITextAreaStyles,
53
55
  ITextButtonStyles,
54
56
  ITextWithInfoStyles,
55
- IStatusStyles,
56
57
  ITextWithTooltipStyles,
57
58
  IThemedPreloaderStyles,
58
59
  IToasterStyles,
@@ -100,6 +101,7 @@ export interface IComponentStyles {
100
101
  FlexibleTableRow: IFlexibleTableRowStyles;
101
102
  FlexibleTableCell: IFlexibleTableCellStyles;
102
103
  Icon: IIconStyles;
104
+ IconButton: IIconButtonStyles;
103
105
  IncrementInput: IIncrementInputStyles;
104
106
  Input: IInputStyles;
105
107
  List: IListStyles;