@true-engineering/true-react-common-ui-kit 3.41.0 → 3.42.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.
- package/LICENSE +201 -201
- package/README.md +7 -0
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +2 -1
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
- package/dist/components/FiltersPane/types.d.ts +1 -0
- package/dist/components/Input/Input.styles.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
- package/dist/components/Select/Select.styles.d.ts +3 -3
- package/dist/true-react-common-ui-kit.js +74 -59
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +74 -59
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +99 -98
- 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/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/Description/Description.stories.tsx +27 -27
- package/src/components/Description/Description.tsx +61 -61
- package/src/components/FiltersPane/FiltersPane.stories.tsx +12 -0
- 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.styles.ts +4 -0
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +20 -2
- package/src/components/FiltersPane/types.ts +1 -0
- 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/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
- 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/types.ts +32 -32
- package/src/components/Modal/Modal.stories.tsx +105 -105
- package/src/components/MoreMenu/MoreMenu.tsx +93 -93
- 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/Notification/Notification.stories.tsx +55 -55
- package/src/components/Notification/Notification.styles.ts +57 -57
- package/src/components/Notification/Notification.tsx +77 -77
- package/src/components/Notification/types.ts +1 -1
- 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/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.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.stories.tsx +52 -52
- package/src/components/SmartInput/SmartInput.tsx +116 -116
- package/src/components/SmartInput/constants.ts +91 -91
- package/src/components/SmartInput/helpers.ts +26 -26
- package/src/components/SmartInput/types.ts +18 -18
- 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/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/TextWithTooltip/TextWithTooltip.tsx +156 -156
- 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/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.styles.ts +45 -45
- package/src/components/WithPopup/WithPopup.tsx +184 -184
- package/src/components/WithTooltip/WithTooltip.stories.tsx +56 -56
- package/src/components/WithTooltip/WithTooltip.styles.ts +7 -7
- package/src/components/WithTooltip/WithTooltip.tsx +67 -67
- package/src/components/WithTooltip/index.ts +2 -2
- package/src/components/index.ts +46 -46
- 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/theme/types.ts +158 -158
- package/src/vite-env.d.ts +1 -1
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { rgba } from '../../helpers';
|
|
2
|
-
import { colors, createThemedStyles, ITweakStyles } from '../../theme';
|
|
3
|
-
|
|
4
|
-
export const useStyles = createThemedStyles('Status', {
|
|
5
|
-
root: {
|
|
6
|
-
display: 'inline-flex',
|
|
7
|
-
verticalAlign: 'middle',
|
|
8
|
-
color: 'var(--status-color)',
|
|
9
|
-
backgroundColor: 'var(--status-background)',
|
|
10
|
-
width: 'max-content',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
|
|
13
|
-
'& > *': {
|
|
14
|
-
flexShrink: 0,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
icon: {
|
|
19
|
-
'& > div': {
|
|
20
|
-
display: 'inline-block',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
iconLeft: {
|
|
25
|
-
order: -1,
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
text: {},
|
|
29
|
-
|
|
30
|
-
badge: {
|
|
31
|
-
color: colors.CLASSIC_WHITE,
|
|
32
|
-
backgroundColor: 'var(--status-color)',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
xs: {
|
|
36
|
-
padding: [2, 4],
|
|
37
|
-
gap: 4,
|
|
38
|
-
borderRadius: 2,
|
|
39
|
-
|
|
40
|
-
fontSize: 12,
|
|
41
|
-
lineHeight: '16px',
|
|
42
|
-
letterSpacing: 0.24,
|
|
43
|
-
fontWeight: 'bold',
|
|
44
|
-
|
|
45
|
-
'& $icon': {
|
|
46
|
-
width: 16,
|
|
47
|
-
height: 16,
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
'& $badge': {
|
|
51
|
-
padding: [0, 2],
|
|
52
|
-
marginRight: -1,
|
|
53
|
-
borderRadius: 4,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
s: {
|
|
58
|
-
padding: [3, 8, 5, 8],
|
|
59
|
-
gap: 4,
|
|
60
|
-
borderRadius: 6,
|
|
61
|
-
|
|
62
|
-
fontSize: 13,
|
|
63
|
-
lineHeight: '16px',
|
|
64
|
-
letterSpacing: 0.2,
|
|
65
|
-
fontWeight: 'bold',
|
|
66
|
-
|
|
67
|
-
'& $text': {},
|
|
68
|
-
|
|
69
|
-
'& $icon': {
|
|
70
|
-
width: 16,
|
|
71
|
-
height: 16,
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
'& $badge': {
|
|
75
|
-
padding: [0, 4, 2, 4],
|
|
76
|
-
margin: [0, -4, -2, 0],
|
|
77
|
-
borderRadius: 4,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
m: {
|
|
82
|
-
padding: [7, 12],
|
|
83
|
-
gap: 4,
|
|
84
|
-
borderRadius: 6,
|
|
85
|
-
|
|
86
|
-
fontSize: 15,
|
|
87
|
-
lineHeight: '18px',
|
|
88
|
-
letterSpacing: 0.15,
|
|
89
|
-
fontWeight: 'bold',
|
|
90
|
-
|
|
91
|
-
'& $text': {},
|
|
92
|
-
|
|
93
|
-
'& $icon': {
|
|
94
|
-
width: 18,
|
|
95
|
-
height: 18,
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
'& $badge': {
|
|
99
|
-
padding: [2, 4],
|
|
100
|
-
margin: [-2, -7, -2, 0],
|
|
101
|
-
borderRadius: 4,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
green: {
|
|
106
|
-
'--status-background': rgba('#D4E3AC', 0.5),
|
|
107
|
-
'--status-color': '#6F990F',
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
blue: {
|
|
111
|
-
'--status-background': rgba('#AABFFC', 0.4),
|
|
112
|
-
'--status-color': '#4C6EBF',
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
grey: {
|
|
116
|
-
'--status-background': rgba('#95A0B3', 0.25),
|
|
117
|
-
'--status-color': '#7A869A',
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
orange: {
|
|
121
|
-
'--status-background': rgba('#FCD3A9', 0.5),
|
|
122
|
-
'--status-color': '#E5741C',
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
red: {
|
|
126
|
-
'--status-background': rgba('#F7949A', 0.25),
|
|
127
|
-
'--status-color': '#F14D56',
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
teal: {
|
|
131
|
-
'--status-background': rgba('#8CE3EA', 0.4),
|
|
132
|
-
'--status-color': '#0092A6',
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
violet: {
|
|
136
|
-
'--status-background': rgba('#BEABE0', 0.4),
|
|
137
|
-
'--status-color': '#7450B2',
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
custom: {},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
export type IStatusStyles = ITweakStyles<typeof useStyles>;
|
|
1
|
+
import { rgba } from '../../helpers';
|
|
2
|
+
import { colors, createThemedStyles, ITweakStyles } from '../../theme';
|
|
3
|
+
|
|
4
|
+
export const useStyles = createThemedStyles('Status', {
|
|
5
|
+
root: {
|
|
6
|
+
display: 'inline-flex',
|
|
7
|
+
verticalAlign: 'middle',
|
|
8
|
+
color: 'var(--status-color)',
|
|
9
|
+
backgroundColor: 'var(--status-background)',
|
|
10
|
+
width: 'max-content',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
|
|
13
|
+
'& > *': {
|
|
14
|
+
flexShrink: 0,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
icon: {
|
|
19
|
+
'& > div': {
|
|
20
|
+
display: 'inline-block',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
iconLeft: {
|
|
25
|
+
order: -1,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
text: {},
|
|
29
|
+
|
|
30
|
+
badge: {
|
|
31
|
+
color: colors.CLASSIC_WHITE,
|
|
32
|
+
backgroundColor: 'var(--status-color)',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
xs: {
|
|
36
|
+
padding: [2, 4],
|
|
37
|
+
gap: 4,
|
|
38
|
+
borderRadius: 2,
|
|
39
|
+
|
|
40
|
+
fontSize: 12,
|
|
41
|
+
lineHeight: '16px',
|
|
42
|
+
letterSpacing: 0.24,
|
|
43
|
+
fontWeight: 'bold',
|
|
44
|
+
|
|
45
|
+
'& $icon': {
|
|
46
|
+
width: 16,
|
|
47
|
+
height: 16,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
'& $badge': {
|
|
51
|
+
padding: [0, 2],
|
|
52
|
+
marginRight: -1,
|
|
53
|
+
borderRadius: 4,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
s: {
|
|
58
|
+
padding: [3, 8, 5, 8],
|
|
59
|
+
gap: 4,
|
|
60
|
+
borderRadius: 6,
|
|
61
|
+
|
|
62
|
+
fontSize: 13,
|
|
63
|
+
lineHeight: '16px',
|
|
64
|
+
letterSpacing: 0.2,
|
|
65
|
+
fontWeight: 'bold',
|
|
66
|
+
|
|
67
|
+
'& $text': {},
|
|
68
|
+
|
|
69
|
+
'& $icon': {
|
|
70
|
+
width: 16,
|
|
71
|
+
height: 16,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
'& $badge': {
|
|
75
|
+
padding: [0, 4, 2, 4],
|
|
76
|
+
margin: [0, -4, -2, 0],
|
|
77
|
+
borderRadius: 4,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
m: {
|
|
82
|
+
padding: [7, 12],
|
|
83
|
+
gap: 4,
|
|
84
|
+
borderRadius: 6,
|
|
85
|
+
|
|
86
|
+
fontSize: 15,
|
|
87
|
+
lineHeight: '18px',
|
|
88
|
+
letterSpacing: 0.15,
|
|
89
|
+
fontWeight: 'bold',
|
|
90
|
+
|
|
91
|
+
'& $text': {},
|
|
92
|
+
|
|
93
|
+
'& $icon': {
|
|
94
|
+
width: 18,
|
|
95
|
+
height: 18,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
'& $badge': {
|
|
99
|
+
padding: [2, 4],
|
|
100
|
+
margin: [-2, -7, -2, 0],
|
|
101
|
+
borderRadius: 4,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
green: {
|
|
106
|
+
'--status-background': rgba('#D4E3AC', 0.5),
|
|
107
|
+
'--status-color': '#6F990F',
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
blue: {
|
|
111
|
+
'--status-background': rgba('#AABFFC', 0.4),
|
|
112
|
+
'--status-color': '#4C6EBF',
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
grey: {
|
|
116
|
+
'--status-background': rgba('#95A0B3', 0.25),
|
|
117
|
+
'--status-color': '#7A869A',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
orange: {
|
|
121
|
+
'--status-background': rgba('#FCD3A9', 0.5),
|
|
122
|
+
'--status-color': '#E5741C',
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
red: {
|
|
126
|
+
'--status-background': rgba('#F7949A', 0.25),
|
|
127
|
+
'--status-color': '#F14D56',
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
teal: {
|
|
131
|
+
'--status-background': rgba('#8CE3EA', 0.4),
|
|
132
|
+
'--status-color': '#0092A6',
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
violet: {
|
|
136
|
+
'--status-background': rgba('#BEABE0', 0.4),
|
|
137
|
+
'--status-color': '#7450B2',
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
custom: {},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export type IStatusStyles = ITweakStyles<typeof useStyles>;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { 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 { ICommonProps } from '../../types';
|
|
6
|
-
import { IIcon, renderIcon } from '../Icon';
|
|
7
|
-
import { IStatusColor, IStatusSize } from './types';
|
|
8
|
-
import { useStyles, IStatusStyles } from './Status.styles';
|
|
9
|
-
|
|
10
|
-
export interface IStatusProps extends ICommonProps<IStatusStyles> {
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
color: IStatusColor;
|
|
13
|
-
icon?: IIcon;
|
|
14
|
-
/** @default 's' */
|
|
15
|
-
size?: IStatusSize;
|
|
16
|
-
/** @default 'right' */
|
|
17
|
-
iconPosition?: 'left' | 'right';
|
|
18
|
-
badge?: ReactNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const Status: FC<IStatusProps> = ({
|
|
22
|
-
children,
|
|
23
|
-
color,
|
|
24
|
-
size = 's',
|
|
25
|
-
icon,
|
|
26
|
-
iconPosition = 'right',
|
|
27
|
-
badge,
|
|
28
|
-
tweakStyles,
|
|
29
|
-
testId,
|
|
30
|
-
data,
|
|
31
|
-
}) => {
|
|
32
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<span
|
|
36
|
-
className={clsx(classes.root, classes[size], classes[color])}
|
|
37
|
-
{...addDataTestId(testId)}
|
|
38
|
-
{...addDataAttributes(data)}
|
|
39
|
-
>
|
|
40
|
-
{isReactNodeNotEmpty(children) && <span className={classes.text}>{children}</span>}
|
|
41
|
-
{isReactNodeNotEmpty(icon) && (
|
|
42
|
-
<span className={clsx(classes.icon, iconPosition === 'left' && classes.iconLeft)}>
|
|
43
|
-
{renderIcon(icon)}
|
|
44
|
-
</span>
|
|
45
|
-
)}
|
|
46
|
-
{isReactNodeNotEmpty(badge) && <span className={classes.badge}>{badge}</span>}
|
|
47
|
-
</span>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
1
|
+
import { 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 { ICommonProps } from '../../types';
|
|
6
|
+
import { IIcon, renderIcon } from '../Icon';
|
|
7
|
+
import { IStatusColor, IStatusSize } from './types';
|
|
8
|
+
import { useStyles, IStatusStyles } from './Status.styles';
|
|
9
|
+
|
|
10
|
+
export interface IStatusProps extends ICommonProps<IStatusStyles> {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
color: IStatusColor;
|
|
13
|
+
icon?: IIcon;
|
|
14
|
+
/** @default 's' */
|
|
15
|
+
size?: IStatusSize;
|
|
16
|
+
/** @default 'right' */
|
|
17
|
+
iconPosition?: 'left' | 'right';
|
|
18
|
+
badge?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Status: FC<IStatusProps> = ({
|
|
22
|
+
children,
|
|
23
|
+
color,
|
|
24
|
+
size = 's',
|
|
25
|
+
icon,
|
|
26
|
+
iconPosition = 'right',
|
|
27
|
+
badge,
|
|
28
|
+
tweakStyles,
|
|
29
|
+
testId,
|
|
30
|
+
data,
|
|
31
|
+
}) => {
|
|
32
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<span
|
|
36
|
+
className={clsx(classes.root, classes[size], classes[color])}
|
|
37
|
+
{...addDataTestId(testId)}
|
|
38
|
+
{...addDataAttributes(data)}
|
|
39
|
+
>
|
|
40
|
+
{isReactNodeNotEmpty(children) && <span className={classes.text}>{children}</span>}
|
|
41
|
+
{isReactNodeNotEmpty(icon) && (
|
|
42
|
+
<span className={clsx(classes.icon, iconPosition === 'left' && classes.iconLeft)}>
|
|
43
|
+
{renderIcon(icon)}
|
|
44
|
+
</span>
|
|
45
|
+
)}
|
|
46
|
+
{isReactNodeNotEmpty(badge) && <span className={classes.badge}>{badge}</span>}
|
|
47
|
+
</span>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export const STATUS_COLORS = [
|
|
2
|
-
'green',
|
|
3
|
-
'teal',
|
|
4
|
-
'blue',
|
|
5
|
-
'grey',
|
|
6
|
-
'orange',
|
|
7
|
-
'red',
|
|
8
|
-
'violet',
|
|
9
|
-
'custom',
|
|
10
|
-
] as const;
|
|
11
|
-
export const STATUS_SIZES = ['xs', 's', 'm'] as const;
|
|
1
|
+
export const STATUS_COLORS = [
|
|
2
|
+
'green',
|
|
3
|
+
'teal',
|
|
4
|
+
'blue',
|
|
5
|
+
'grey',
|
|
6
|
+
'orange',
|
|
7
|
+
'red',
|
|
8
|
+
'violet',
|
|
9
|
+
'custom',
|
|
10
|
+
] as const;
|
|
11
|
+
export const STATUS_SIZES = ['xs', 's', 'm'] as const;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Status';
|
|
2
|
-
|
|
3
|
-
export type { IStatusStyles } from './Status.styles';
|
|
1
|
+
export * from './Status';
|
|
2
|
+
|
|
3
|
+
export type { IStatusStyles } from './Status.styles';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
2
|
-
|
|
3
|
-
export type IStatusColor = (typeof STATUS_COLORS)[number];
|
|
4
|
-
|
|
5
|
-
export type IStatusSize = (typeof STATUS_SIZES)[number];
|
|
1
|
+
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
2
|
+
|
|
3
|
+
export type IStatusColor = (typeof STATUS_COLORS)[number];
|
|
4
|
+
|
|
5
|
+
export type IStatusSize = (typeof STATUS_SIZES)[number];
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Switch } from './Switch';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Controls/Switch',
|
|
7
|
-
component: Switch,
|
|
8
|
-
argTypes: {
|
|
9
|
-
labelPosition: { control: 'inline-radio', options: ['left', 'right'] },
|
|
10
|
-
color: { control: 'inline-radio', options: ['primary', 'secondary'] },
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Template: ComponentStory<typeof Switch> = (args) => {
|
|
15
|
-
const [isChecked, setIsChecked] = useState(true);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Switch
|
|
19
|
-
{...args}
|
|
20
|
-
isChecked={isChecked}
|
|
21
|
-
onChange={(value) => setIsChecked(value.isEnabled)}
|
|
22
|
-
value="check"
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Default = Template.bind({});
|
|
28
|
-
|
|
29
|
-
Default.args = {
|
|
30
|
-
children: 'Label',
|
|
31
|
-
labelPosition: 'right',
|
|
32
|
-
isDisabled: false,
|
|
33
|
-
color: 'primary',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
Default.parameters = {
|
|
37
|
-
controls: {
|
|
38
|
-
exclude: ['data', 'testId', 'onChange'],
|
|
39
|
-
},
|
|
40
|
-
};
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Switch } from './Switch';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Controls/Switch',
|
|
7
|
+
component: Switch,
|
|
8
|
+
argTypes: {
|
|
9
|
+
labelPosition: { control: 'inline-radio', options: ['left', 'right'] },
|
|
10
|
+
color: { control: 'inline-radio', options: ['primary', 'secondary'] },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template: ComponentStory<typeof Switch> = (args) => {
|
|
15
|
+
const [isChecked, setIsChecked] = useState(true);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Switch
|
|
19
|
+
{...args}
|
|
20
|
+
isChecked={isChecked}
|
|
21
|
+
onChange={(value) => setIsChecked(value.isEnabled)}
|
|
22
|
+
value="check"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
|
|
29
|
+
Default.args = {
|
|
30
|
+
children: 'Label',
|
|
31
|
+
labelPosition: 'right',
|
|
32
|
+
isDisabled: false,
|
|
33
|
+
color: 'primary',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Default.parameters = {
|
|
37
|
+
controls: {
|
|
38
|
+
exclude: ['data', 'testId', 'onChange'],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { 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 { ICommonProps } from '../../types';
|
|
6
|
-
import { ISwitchState } from './types';
|
|
7
|
-
import { useStyles, ISwitchStyles } from './Switch.styles';
|
|
8
|
-
|
|
9
|
-
export interface ISwitchProps<V extends string> extends ICommonProps<ISwitchStyles> {
|
|
10
|
-
children?: ReactNode;
|
|
11
|
-
value: V;
|
|
12
|
-
/** @default false */
|
|
13
|
-
isChecked: boolean | undefined;
|
|
14
|
-
/** @default false */
|
|
15
|
-
isDisabled?: boolean;
|
|
16
|
-
/** @default false */
|
|
17
|
-
isInvalid?: boolean;
|
|
18
|
-
/** @default 'right' */
|
|
19
|
-
labelPosition?: 'left' | 'right';
|
|
20
|
-
/** @default 'primary' */
|
|
21
|
-
color?: 'primary' | 'secondary';
|
|
22
|
-
onChange: (state: ISwitchState<V>) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const Switch = <V extends string>({
|
|
26
|
-
isDisabled = false,
|
|
27
|
-
isChecked = false,
|
|
28
|
-
isInvalid = false,
|
|
29
|
-
value,
|
|
30
|
-
children,
|
|
31
|
-
labelPosition = 'right',
|
|
32
|
-
color = 'primary',
|
|
33
|
-
data,
|
|
34
|
-
tweakStyles,
|
|
35
|
-
testId,
|
|
36
|
-
onChange,
|
|
37
|
-
}: ISwitchProps<V>): JSX.Element => {
|
|
38
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
39
|
-
|
|
40
|
-
const handleChange = () => onChange({ name: value, isEnabled: !isChecked });
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<label
|
|
44
|
-
className={clsx(classes.root, classes[color], {
|
|
45
|
-
[classes.disabled]: isDisabled,
|
|
46
|
-
[classes.checked]: isChecked,
|
|
47
|
-
[classes.invalid]: isInvalid,
|
|
48
|
-
})}
|
|
49
|
-
{...addDataTestId(testId)}
|
|
50
|
-
{...addDataAttributes(data)}
|
|
51
|
-
>
|
|
52
|
-
<span className={classes.switch}>
|
|
53
|
-
<input
|
|
54
|
-
type="checkbox"
|
|
55
|
-
name={value}
|
|
56
|
-
className={classes.input}
|
|
57
|
-
onChange={isDisabled ? undefined : handleChange}
|
|
58
|
-
checked={isChecked}
|
|
59
|
-
disabled={isDisabled}
|
|
60
|
-
{...addDataTestId(testId, 'input')}
|
|
61
|
-
/>
|
|
62
|
-
</span>
|
|
63
|
-
{isReactNodeNotEmpty(children) && (
|
|
64
|
-
<span
|
|
65
|
-
className={clsx(
|
|
66
|
-
classes.label,
|
|
67
|
-
classes[labelPosition === 'left' ? 'labelLeft' : 'labelRight'],
|
|
68
|
-
)}
|
|
69
|
-
>
|
|
70
|
-
{children}
|
|
71
|
-
</span>
|
|
72
|
-
)}
|
|
73
|
-
</label>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
1
|
+
import { 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 { ICommonProps } from '../../types';
|
|
6
|
+
import { ISwitchState } from './types';
|
|
7
|
+
import { useStyles, ISwitchStyles } from './Switch.styles';
|
|
8
|
+
|
|
9
|
+
export interface ISwitchProps<V extends string> extends ICommonProps<ISwitchStyles> {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
value: V;
|
|
12
|
+
/** @default false */
|
|
13
|
+
isChecked: boolean | undefined;
|
|
14
|
+
/** @default false */
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
/** @default false */
|
|
17
|
+
isInvalid?: boolean;
|
|
18
|
+
/** @default 'right' */
|
|
19
|
+
labelPosition?: 'left' | 'right';
|
|
20
|
+
/** @default 'primary' */
|
|
21
|
+
color?: 'primary' | 'secondary';
|
|
22
|
+
onChange: (state: ISwitchState<V>) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Switch = <V extends string>({
|
|
26
|
+
isDisabled = false,
|
|
27
|
+
isChecked = false,
|
|
28
|
+
isInvalid = false,
|
|
29
|
+
value,
|
|
30
|
+
children,
|
|
31
|
+
labelPosition = 'right',
|
|
32
|
+
color = 'primary',
|
|
33
|
+
data,
|
|
34
|
+
tweakStyles,
|
|
35
|
+
testId,
|
|
36
|
+
onChange,
|
|
37
|
+
}: ISwitchProps<V>): JSX.Element => {
|
|
38
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
39
|
+
|
|
40
|
+
const handleChange = () => onChange({ name: value, isEnabled: !isChecked });
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<label
|
|
44
|
+
className={clsx(classes.root, classes[color], {
|
|
45
|
+
[classes.disabled]: isDisabled,
|
|
46
|
+
[classes.checked]: isChecked,
|
|
47
|
+
[classes.invalid]: isInvalid,
|
|
48
|
+
})}
|
|
49
|
+
{...addDataTestId(testId)}
|
|
50
|
+
{...addDataAttributes(data)}
|
|
51
|
+
>
|
|
52
|
+
<span className={classes.switch}>
|
|
53
|
+
<input
|
|
54
|
+
type="checkbox"
|
|
55
|
+
name={value}
|
|
56
|
+
className={classes.input}
|
|
57
|
+
onChange={isDisabled ? undefined : handleChange}
|
|
58
|
+
checked={isChecked}
|
|
59
|
+
disabled={isDisabled}
|
|
60
|
+
{...addDataTestId(testId, 'input')}
|
|
61
|
+
/>
|
|
62
|
+
</span>
|
|
63
|
+
{isReactNodeNotEmpty(children) && (
|
|
64
|
+
<span
|
|
65
|
+
className={clsx(
|
|
66
|
+
classes.label,
|
|
67
|
+
classes[labelPosition === 'left' ? 'labelLeft' : 'labelRight'],
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
</label>
|
|
74
|
+
);
|
|
75
|
+
};
|