@true-engineering/true-react-common-ui-kit 2.0.1 → 2.1.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/README.md +17 -0
- package/dist/components/Button/Button.d.ts +35 -0
- package/dist/components/Checkbox/Checkbox.d.ts +15 -2
- package/dist/components/DatePicker/DatePicker.d.ts +3 -4
- package/dist/components/DatePicker/types.d.ts +1 -1
- package/dist/components/FiltersPane/FilterSelect/FilterSelect.d.ts +12 -0
- package/dist/components/Input/Input.d.ts +17 -0
- package/dist/components/MoreMenu/MoreMenu.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +6 -0
- package/dist/components/RadioButton/RadioButton.d.ts +4 -3
- package/dist/components/Switch/Switch.d.ts +10 -4
- package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +3 -0
- package/dist/components/Toaster/Toaster.d.ts +13 -0
- package/dist/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/helpers/utils.d.ts +14 -0
- package/dist/true-react-common-ui-kit.js +11 -13
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +11 -13
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +91 -91
- package/src/components/Checkbox/Checkbox.tsx +3 -2
- package/src/components/DatePicker/DatePicker.tsx +2 -4
- package/src/components/DatePicker/types.ts +5 -0
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +86 -86
- package/src/components/RadioButton/RadioButton.tsx +5 -4
- package/src/components/Select/Select.tsx +634 -634
- package/src/components/Switch/Switch.tsx +10 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useTheme } from '../../hooks';
|
|
4
|
-
import { addDataAttributes, isNotEmpty } from '../../helpers';
|
|
4
|
+
import { addDataAttributes, addDataTestId, isNotEmpty } from '../../helpers';
|
|
5
5
|
import { ICommonProps } from '../../types';
|
|
6
6
|
|
|
7
7
|
import { styles, SwitchStyles } from './Switch.styles';
|
|
@@ -13,14 +13,11 @@ export interface ISwitchState<V = string> {
|
|
|
13
13
|
|
|
14
14
|
export interface ISwitchProps<V extends string> extends ICommonProps {
|
|
15
15
|
tweakStyles?: SwitchStyles;
|
|
16
|
+
children?: ReactNode;
|
|
16
17
|
value: V;
|
|
17
18
|
isChecked: boolean;
|
|
18
19
|
isDisabled?: boolean;
|
|
19
20
|
isInvalid?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `children` instead
|
|
22
|
-
*/
|
|
23
|
-
label?: string;
|
|
24
21
|
/**
|
|
25
22
|
* @default `right`
|
|
26
23
|
*/
|
|
@@ -29,28 +26,25 @@ export interface ISwitchProps<V extends string> extends ICommonProps {
|
|
|
29
26
|
* @default `primary`
|
|
30
27
|
*/
|
|
31
28
|
color?: 'primary' | 'secondary';
|
|
32
|
-
onChange: (state: ISwitchState<V>) => void;
|
|
33
29
|
testId?: string;
|
|
30
|
+
onChange(state: ISwitchState<V>): void;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
export const Switch = <V extends string>({
|
|
37
34
|
isDisabled,
|
|
38
35
|
isChecked,
|
|
39
36
|
isInvalid,
|
|
40
|
-
onChange,
|
|
41
37
|
value,
|
|
42
|
-
label,
|
|
43
38
|
children,
|
|
44
39
|
labelPosition = 'right',
|
|
45
40
|
color = 'primary',
|
|
46
41
|
data,
|
|
47
42
|
tweakStyles,
|
|
48
43
|
testId,
|
|
49
|
-
|
|
44
|
+
onChange,
|
|
45
|
+
}: ISwitchProps<V>): JSX.Element => {
|
|
50
46
|
const { classes } = useTheme('Switch', styles, tweakStyles);
|
|
51
47
|
|
|
52
|
-
const hasLabel = isNotEmpty(label);
|
|
53
|
-
const hasChild = isNotEmpty(children);
|
|
54
48
|
const handleChange = () => onChange({ name: value, isEnabled: !isChecked });
|
|
55
49
|
|
|
56
50
|
return (
|
|
@@ -60,8 +54,8 @@ export const Switch = <V extends string>({
|
|
|
60
54
|
[classes.checked]: isChecked,
|
|
61
55
|
[classes.invalid]: isInvalid,
|
|
62
56
|
})}
|
|
57
|
+
{...addDataTestId(testId)}
|
|
63
58
|
{...addDataAttributes(data)}
|
|
64
|
-
data-testid={testId}
|
|
65
59
|
>
|
|
66
60
|
<span className={classes.switch}>
|
|
67
61
|
<input
|
|
@@ -71,17 +65,17 @@ export const Switch = <V extends string>({
|
|
|
71
65
|
onChange={isDisabled ? undefined : handleChange}
|
|
72
66
|
checked={isChecked}
|
|
73
67
|
disabled={isDisabled}
|
|
74
|
-
|
|
68
|
+
{...addDataTestId(testId, 'input')}
|
|
75
69
|
/>
|
|
76
70
|
</span>
|
|
77
|
-
{(
|
|
71
|
+
{isNotEmpty(children) && (
|
|
78
72
|
<span
|
|
79
73
|
className={clsx(
|
|
80
74
|
classes.label,
|
|
81
75
|
classes[labelPosition === 'left' ? 'labelLeft' : 'labelRight'],
|
|
82
76
|
)}
|
|
83
77
|
>
|
|
84
|
-
{
|
|
78
|
+
{children}
|
|
85
79
|
</span>
|
|
86
80
|
)}
|
|
87
81
|
</label>
|