@true-engineering/true-react-common-ui-kit 3.8.0 → 3.8.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.
- package/LICENSE +201 -201
- package/README.md +6 -0
- package/dist/components/NewMoreMenu/NewMoreMenu.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +2 -0
- package/dist/true-react-common-ui-kit.js +62 -60
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +62 -60
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
- package/src/components/AccountInfo/AccountInfo.tsx +80 -80
- package/src/components/AddButton/AddButton.stories.tsx +21 -21
- package/src/components/AddButton/AddButton.tsx +52 -52
- package/src/components/Button/Button.stories.tsx +56 -56
- package/src/components/Button/Button.tsx +129 -129
- package/src/components/Checkbox/Checkbox.stories.tsx +28 -28
- package/src/components/Checkbox/Checkbox.tsx +85 -85
- package/src/components/CloseButton/CloseButton.tsx +34 -34
- package/src/components/Colors/Colors.stories.tsx +7 -7
- package/src/components/DateInput/DateInput.tsx +90 -90
- package/src/components/DateInput/constants.ts +2 -2
- package/src/components/DatePicker/DatePicker.tsx +308 -308
- package/src/components/Description/Description.stories.tsx +27 -27
- package/src/components/Description/Description.tsx +61 -61
- package/src/components/FiltersPane/FiltersPane.tsx +158 -158
- package/src/components/FiltersPane/components/Filter/Filter.tsx +203 -203
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +167 -167
- package/src/components/Flag/Flag.stories.tsx +29 -29
- package/src/components/Flag/Flag.tsx +26 -26
- package/src/components/Flag/augment.d.ts +1 -1
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +267 -267
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +110 -110
- package/src/components/FlexibleTable/FlexibleTable.tsx +271 -271
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +38 -38
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +83 -83
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +196 -196
- package/src/components/FlexibleTable/helpers.ts +13 -13
- package/src/components/FlexibleTable/types.ts +52 -52
- package/src/components/Icon/Icon.stories.tsx +86 -86
- package/src/components/Icon/complexIcons/augment.d.ts +1 -1
- package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
- package/src/components/Icon/complexIcons/index.ts +1 -1
- package/src/components/IncrementInput/IncrementInput.tsx +105 -105
- package/src/components/Input/Input.tsx +297 -297
- package/src/components/Input/types.ts +32 -32
- package/src/components/List/List.stories.tsx +70 -70
- package/src/components/List/List.tsx +33 -33
- package/src/components/List/components/ListItem/ListItem.tsx +57 -57
- package/src/components/Modal/Modal.stories.tsx +105 -105
- package/src/components/Modal/Modal.tsx +196 -196
- package/src/components/MoreMenu/MoreMenu.styles.ts +68 -68
- package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
- package/src/components/MultiSelect/MultiSelect.tsx +106 -106
- package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
- package/src/components/MultiSelectList/MultiSelectList.tsx +461 -461
- package/src/components/NewMoreMenu/NewMoreMenu.stories.tsx +1 -0
- package/src/components/NewMoreMenu/NewMoreMenu.tsx +3 -1
- package/src/components/Notification/Notification.stories.tsx +46 -46
- package/src/components/Notification/Notification.tsx +69 -69
- package/src/components/NumberInput/NumberInput.tsx +137 -137
- package/src/components/NumberInput/index.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.tsx +214 -214
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
- package/src/components/PhoneInput/types.ts +16 -16
- package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
- package/src/components/RadioButton/RadioButton.tsx +57 -57
- package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
- package/src/components/Select/CustomSelect.stories.tsx +217 -217
- package/src/components/Select/MultiSelect.stories.tsx +240 -240
- package/src/components/Select/Select.stories.tsx +235 -235
- package/src/components/Select/Select.tsx +580 -580
- package/src/components/Select/components/SelectList/SelectList.tsx +157 -157
- package/src/components/Select/components/SelectListItem/SelectListItem.tsx +68 -68
- package/src/components/Select/constants.ts +2 -2
- package/src/components/Select/types.ts +1 -1
- package/src/components/Selector/Selector.stories.tsx +62 -62
- package/src/components/Selector/Selector.styles.ts +164 -164
- package/src/components/Selector/Selector.tsx +115 -115
- package/src/components/Selector/index.ts +2 -2
- package/src/components/Selector/types.ts +12 -12
- package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
- package/src/components/SmartInput/SmartInput.tsx +134 -134
- package/src/components/Status/Status.stories.tsx +73 -73
- package/src/components/Status/Status.styles.ts +143 -143
- package/src/components/Status/Status.tsx +49 -49
- package/src/components/Status/constants.ts +11 -11
- package/src/components/Status/index.ts +3 -3
- package/src/components/Status/types.ts +5 -5
- package/src/components/Switch/Switch.stories.tsx +40 -40
- package/src/components/Switch/Switch.tsx +75 -75
- package/src/components/TextArea/TextArea.tsx +180 -180
- package/src/components/TextButton/TextButton.stories.tsx +46 -46
- package/src/components/TextButton/TextButton.styles.ts +129 -129
- package/src/components/TextButton/TextButton.tsx +103 -103
- package/src/components/TextButton/index.ts +4 -4
- package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
- package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
- package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
- package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
- package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
- package/src/components/Toaster/Toaster.stories.tsx +30 -30
- package/src/components/Toaster/Toaster.tsx +108 -108
- package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
- package/src/components/Tooltip/Tooltip.tsx +35 -35
- package/src/components/Tooltip/types.ts +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
- package/src/components/WithPopup/WithPopup.tsx +7 -1
- package/src/helpers/popper-helpers.ts +17 -17
- package/src/hooks/use-dropdown.ts +84 -84
- package/src/hooks/use-is-mounted.ts +15 -15
- package/src/theme/helpers.ts +76 -76
- package/src/vite-env.d.ts +1 -1
|
@@ -1,129 +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
|
-
>;
|
|
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
|
+
>;
|
|
@@ -1,103 +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
|
-
};
|
|
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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './TextButton';
|
|
2
|
-
export * from './TextButton';
|
|
3
|
-
|
|
4
|
-
export type { ITextButtonStyles } from './TextButton.styles';
|
|
1
|
+
export * from './TextButton';
|
|
2
|
+
export * from './TextButton';
|
|
3
|
+
|
|
4
|
+
export type { ITextButtonStyles } from './TextButton.styles';
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { FC, useState } from 'react';
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { ITextWithInfoProps, TextWithInfo } from './TextWithInfo';
|
|
4
|
-
|
|
5
|
-
interface ITextWithInfoWithCustomProps extends ITextWithInfoProps {
|
|
6
|
-
infoTooltip: string;
|
|
7
|
-
link: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const TextWithInfoWithCustomProps: FC<ITextWithInfoWithCustomProps> = ({
|
|
11
|
-
infoTooltip,
|
|
12
|
-
link,
|
|
13
|
-
...args
|
|
14
|
-
}) => {
|
|
15
|
-
const [isSelected, setIsSelected] = useState(false);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div
|
|
19
|
-
style={{
|
|
20
|
-
display: 'flex',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
justifyContent: 'center',
|
|
23
|
-
width: 600,
|
|
24
|
-
height: 400,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<TextWithInfo
|
|
28
|
-
{...args}
|
|
29
|
-
info={{ infoTooltip, link }}
|
|
30
|
-
isSelected={isSelected}
|
|
31
|
-
onClick={() => setIsSelected(true)}
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default {
|
|
38
|
-
title: 'Data Display/TextWithInfo',
|
|
39
|
-
component: TextWithInfoWithCustomProps,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const Template: ComponentStory<typeof TextWithInfoWithCustomProps> = (args) => (
|
|
43
|
-
<TextWithInfoWithCustomProps {...args} />
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
export const Default = Template.bind({});
|
|
47
|
-
|
|
48
|
-
Default.args = {
|
|
49
|
-
text: 'Обычная перевозка',
|
|
50
|
-
textTooltip: 'Tултип для самой обычной перевозки',
|
|
51
|
-
infoTooltip: 'Читать подробную информацию',
|
|
52
|
-
link: 'https://ya.ru/',
|
|
53
|
-
};
|
|
1
|
+
import { FC, useState } from 'react';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { ITextWithInfoProps, TextWithInfo } from './TextWithInfo';
|
|
4
|
+
|
|
5
|
+
interface ITextWithInfoWithCustomProps extends ITextWithInfoProps {
|
|
6
|
+
infoTooltip: string;
|
|
7
|
+
link: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const TextWithInfoWithCustomProps: FC<ITextWithInfoWithCustomProps> = ({
|
|
11
|
+
infoTooltip,
|
|
12
|
+
link,
|
|
13
|
+
...args
|
|
14
|
+
}) => {
|
|
15
|
+
const [isSelected, setIsSelected] = useState(false);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
style={{
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
width: 600,
|
|
24
|
+
height: 400,
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<TextWithInfo
|
|
28
|
+
{...args}
|
|
29
|
+
info={{ infoTooltip, link }}
|
|
30
|
+
isSelected={isSelected}
|
|
31
|
+
onClick={() => setIsSelected(true)}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
title: 'Data Display/TextWithInfo',
|
|
39
|
+
component: TextWithInfoWithCustomProps,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const Template: ComponentStory<typeof TextWithInfoWithCustomProps> = (args) => (
|
|
43
|
+
<TextWithInfoWithCustomProps {...args} />
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const Default = Template.bind({});
|
|
47
|
+
|
|
48
|
+
Default.args = {
|
|
49
|
+
text: 'Обычная перевозка',
|
|
50
|
+
textTooltip: 'Tултип для самой обычной перевозки',
|
|
51
|
+
infoTooltip: 'Читать подробную информацию',
|
|
52
|
+
link: 'https://ya.ru/',
|
|
53
|
+
};
|