@true-engineering/true-react-common-ui-kit 3.0.6 → 3.1.1

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 (42) hide show
  1. package/README.md +43 -0
  2. package/dist/components/Notification/Notification.d.ts +0 -1
  3. package/dist/components/Selector/Selector.d.ts +21 -0
  4. package/dist/components/Selector/Selector.stories.d.ts +8 -0
  5. package/dist/components/Selector/Selector.styles.d.ts +9 -0
  6. package/dist/components/Selector/index.d.ts +2 -0
  7. package/dist/components/Selector/types.d.ts +10 -0
  8. package/dist/components/Status/Status.d.ts +16 -0
  9. package/dist/components/Status/Status.stories.d.ts +8 -0
  10. package/dist/components/Status/Status.styles.d.ts +3 -0
  11. package/dist/components/Status/constants.d.ts +2 -0
  12. package/dist/components/Status/index.d.ts +2 -0
  13. package/dist/components/Status/types.d.ts +3 -0
  14. package/dist/components/TextButton/TextButton.d.ts +30 -0
  15. package/dist/components/TextButton/TextButton.stories.d.ts +6 -0
  16. package/dist/components/TextButton/TextButton.styles.d.ts +7 -0
  17. package/dist/components/TextButton/index.d.ts +3 -0
  18. package/dist/components/index.d.ts +7 -4
  19. package/dist/theme/types.d.ts +4 -1
  20. package/dist/true-react-common-ui-kit.js +2286 -1487
  21. package/dist/true-react-common-ui-kit.js.map +1 -1
  22. package/dist/true-react-common-ui-kit.umd.cjs +2285 -1486
  23. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/Notification/Notification.tsx +0 -2
  26. package/src/components/Selector/Selector.stories.tsx +62 -0
  27. package/src/components/Selector/Selector.styles.ts +164 -0
  28. package/src/components/Selector/Selector.tsx +115 -0
  29. package/src/components/Selector/index.ts +2 -0
  30. package/src/components/Selector/types.ts +12 -0
  31. package/src/components/Status/Status.stories.tsx +73 -0
  32. package/src/components/Status/Status.styles.ts +143 -0
  33. package/src/components/Status/Status.tsx +49 -0
  34. package/src/components/Status/constants.ts +11 -0
  35. package/src/components/Status/index.ts +3 -0
  36. package/src/components/Status/types.ts +5 -0
  37. package/src/components/TextButton/TextButton.stories.tsx +46 -0
  38. package/src/components/TextButton/TextButton.styles.ts +129 -0
  39. package/src/components/TextButton/TextButton.tsx +103 -0
  40. package/src/components/TextButton/index.ts +4 -0
  41. package/src/components/index.ts +7 -4
  42. package/src/theme/types.ts +11 -5
@@ -0,0 +1,46 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { IIconType, iconsList } from '../Icon';
3
+ import { complexIcons } from '../Icon/complexIcons';
4
+ import { TextButton } from './TextButton';
5
+
6
+ const iconTypes = [
7
+ undefined,
8
+ ...Object.keys(iconsList),
9
+ ...Object.keys(complexIcons),
10
+ ] as IIconType[];
11
+
12
+ export default {
13
+ title: 'TextButton',
14
+ component: TextButton,
15
+ args: {
16
+ children: 'Text Button',
17
+ icon: 'chevron-right-small',
18
+ size: 'l',
19
+ view: 'primary',
20
+ isBold: false,
21
+ isLoading: false,
22
+ isActive: false,
23
+ isDisabled: false,
24
+ hasCircleUnderIcon: true,
25
+ iconPosition: 'left',
26
+ preloaderType: 'dots',
27
+ },
28
+
29
+ argTypes: {
30
+ icon: { control: 'select', options: iconTypes },
31
+ size: { control: 'inline-radio' },
32
+ view: { control: 'inline-radio' },
33
+ iconPosition: { control: 'inline-radio' },
34
+ preloaderType: { control: 'inline-radio' },
35
+ },
36
+
37
+ parameters: {
38
+ controls: {
39
+ exclude: ['testId', 'tweakStyles', 'data', 'onClick'],
40
+ },
41
+ },
42
+ } as ComponentMeta<typeof TextButton>;
43
+
44
+ export const Default: ComponentStory<typeof TextButton> = (args) => (
45
+ <TextButton {...args} key={args.size} />
46
+ );
@@ -0,0 +1,129 @@
1
+ import { createThemedStyles, ITweakStyles } from '../../theme';
2
+ import { IThemedPreloaderStyles } from '../ThemedPreloader';
3
+
4
+ export const useStyles = createThemedStyles('TextButton', {
5
+ root: {
6
+ display: 'flex',
7
+ alignItems: 'center',
8
+ height: 24,
9
+ padding: 0,
10
+ background: 'transparent',
11
+ border: 'none',
12
+ borderRadius: 0,
13
+ cursor: 'pointer',
14
+ outline: 'none',
15
+ transition: 'color 0.25s ease-in-out',
16
+
17
+ '&[disabled]': {
18
+ cursor: 'default',
19
+ pointerEvents: 'none',
20
+ },
21
+ },
22
+
23
+ xl: {
24
+ fontSize: 16,
25
+
26
+ '& $content': {
27
+ gap: 14,
28
+ },
29
+ },
30
+
31
+ l: {
32
+ fontSize: 14,
33
+ letterSpacing: '0.15px',
34
+
35
+ '& $content': {
36
+ gap: 10,
37
+
38
+ '&$reverseContent': {
39
+ gap: 6,
40
+ },
41
+ },
42
+ },
43
+
44
+ primary: {},
45
+
46
+ secondary: {},
47
+
48
+ custom: {},
49
+
50
+ active: {},
51
+
52
+ disabled: {},
53
+
54
+ bold: {
55
+ fontWeight: 'bold',
56
+ },
57
+
58
+ iconContainer: {
59
+ display: 'flex',
60
+ alignItems: 'center',
61
+ justifyContent: 'center',
62
+ },
63
+
64
+ circle: {
65
+ width: 24,
66
+ height: 24,
67
+ borderRadius: '50%',
68
+ transition: '0.25s ease-in-out',
69
+ transitionProperty: ['background', 'color'],
70
+ },
71
+
72
+ icon: {
73
+ width: 20,
74
+ height: 20,
75
+ },
76
+
77
+ content: {
78
+ display: 'flex',
79
+ alignItems: 'center',
80
+ height: '100%',
81
+ },
82
+
83
+ reverseContent: {
84
+ flexDirection: 'row-reverse',
85
+ },
86
+
87
+ loader: {
88
+ display: 'none',
89
+ height: 8,
90
+ position: 'absolute',
91
+ left: '50%',
92
+ top: '50%',
93
+ transform: 'translate(-50%, -50%)',
94
+ },
95
+
96
+ loading: {
97
+ '& $content': {
98
+ visibility: 'hidden',
99
+ },
100
+
101
+ '& $loader': {
102
+ display: 'block',
103
+ },
104
+ },
105
+ });
106
+
107
+ export const preloaderStyles: IThemedPreloaderStyles = {
108
+ tweakDotsPreloader: {
109
+ fadedDot: {
110
+ width: 6,
111
+ height: 6,
112
+ },
113
+ },
114
+
115
+ logo: {
116
+ width: 24,
117
+ height: 24,
118
+ },
119
+
120
+ default: {
121
+ width: 24,
122
+ height: 24,
123
+ },
124
+ };
125
+
126
+ export type ITextButtonStyles = ITweakStyles<
127
+ typeof useStyles,
128
+ { tweakPreloader: IThemedPreloaderStyles }
129
+ >;
@@ -0,0 +1,103 @@
1
+ import { ButtonHTMLAttributes, FC, ReactNode } from 'react';
2
+ import clsx from 'clsx';
3
+ import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
+ import { addDataAttributes } from '../../helpers';
5
+ import { useTweakStyles } from '../../hooks';
6
+ import { ICommonProps } from '../../types';
7
+ import { IIcon, renderIcon } from '../Icon';
8
+ import { IThemedPreloaderProps, ThemedPreloader } from '../ThemedPreloader';
9
+ import { useStyles, ITextButtonStyles, preloaderStyles } from './TextButton.styles';
10
+
11
+ export interface ITextButtonProps
12
+ extends ICommonProps<ITextButtonStyles>,
13
+ Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'disabled'> {
14
+ /** @default 'undefined' */
15
+ children?: ReactNode;
16
+ /** @default 'undefined' */
17
+ icon?: IIcon;
18
+ /** @default 'primary' */
19
+ view?: 'primary' | 'secondary' | 'custom';
20
+ /** @default false */
21
+ isBold?: boolean;
22
+ /** @default false */
23
+ hasCircleUnderIcon?: boolean;
24
+ /** @default false */
25
+ isDisabled?: boolean;
26
+ /** @default false */
27
+ isLoading?: boolean;
28
+ /** @default false */
29
+ isActive?: boolean;
30
+ /** @default 'l' */
31
+ size?: 'l' | 'xl';
32
+ /** @default 'left' */
33
+ iconPosition?: 'left' | 'right';
34
+ /** @default `dots` */
35
+ preloaderType?: IThemedPreloaderProps['type'];
36
+ }
37
+
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 });
58
+
59
+ const tweakPreloaderStyles = useTweakStyles({
60
+ innerStyles: preloaderStyles,
61
+ tweakStyles,
62
+ className: 'tweakPreloader',
63
+ currentComponentName: 'TextButton',
64
+ });
65
+
66
+ const hasNoAction = isDisabled || isLoading;
67
+
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>
87
+ </span>
88
+ )}
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
+ };
@@ -0,0 +1,4 @@
1
+ export * from './TextButton';
2
+ export * from './TextButton';
3
+
4
+ export type { ITextButtonStyles } from './TextButton.styles';
@@ -21,17 +21,20 @@ export * from './MultiSelect';
21
21
  export * from './MultiSelectList';
22
22
  export * from './Notification';
23
23
  export * from './NumberInput';
24
- export * from './SearchInput';
25
- export * from './SmartInput';
26
24
  export * from './PhoneInput';
27
25
  export * from './RadioButton';
26
+ export * from './ScrollIntoViewIfNeeded';
27
+ export * from './SearchInput';
28
28
  export * from './Select';
29
+ export * from './Selector';
30
+ export * from './Skeleton';
31
+ export * from './SmartInput';
32
+ export * from './Status';
29
33
  export * from './Switch';
30
34
  export * from './TextArea';
35
+ export * from './TextButton';
31
36
  export * from './TextWithInfo';
32
37
  export * from './TextWithTooltip';
33
38
  export * from './ThemedPreloader';
34
39
  export * from './Toaster';
35
40
  export * from './Tooltip';
36
- export * from './ScrollIntoViewIfNeeded';
37
- export * from './Skeleton';
@@ -40,20 +40,23 @@ import type {
40
40
  ISearchInputStyles,
41
41
  ISelectListStyles,
42
42
  ISelectStyles,
43
+ IFilterValueViewStyles,
44
+ IFlexibleTableCellStyles,
45
+ IFlexibleTableRowStyles,
46
+ IListItemStyles,
47
+ ISelectorStyles,
48
+ ISkeletonStyles,
43
49
  ISvgIcon,
44
50
  ISvgPreloaderStyles,
45
51
  ISwitchStyles,
46
52
  ITextAreaStyles,
53
+ ITextButtonStyles,
47
54
  ITextWithInfoStyles,
55
+ IStatusStyles,
48
56
  ITextWithTooltipStyles,
49
57
  IThemedPreloaderStyles,
50
58
  IToasterStyles,
51
59
  ITooltipStyles,
52
- IFlexibleTableCellStyles,
53
- IFlexibleTableRowStyles,
54
- IFilterValueViewStyles,
55
- ISkeletonStyles,
56
- IListItemStyles,
57
60
  } from '../components';
58
61
 
59
62
  export type IStyles<C extends string, P> = Styles<C, P, Partial<Styles<C, P>>>;
@@ -111,11 +114,14 @@ export interface IComponentStyles {
111
114
  SearchInput: ISearchInputStyles;
112
115
  Select: ISelectStyles;
113
116
  SelectList: ISelectListStyles;
117
+ Selector: ISelectorStyles;
114
118
  Skeleton: ISkeletonStyles;
115
119
  Switch: ISwitchStyles;
120
+ TextButton: ITextButtonStyles;
116
121
  TextArea: ITextAreaStyles;
117
122
  TextWithInfo: ITextWithInfoStyles;
118
123
  TextWithTooltip: ITextWithTooltipStyles;
124
+ Status: IStatusStyles;
119
125
  ThemedPreloader: IThemedPreloaderStyles;
120
126
  Tooltip: ITooltipStyles;
121
127
  Toaster: IToasterStyles;