@true-engineering/true-react-common-ui-kit 4.0.0-alpha2 → 4.0.0-alpha21
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 +11 -567
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.d.ts +2 -0
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
- package/dist/components/ControlWrapper/index.d.ts +1 -0
- package/dist/components/ControlWrapper/types.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.d.ts +3 -3
- package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
- package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +2 -4
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +5 -3
- package/dist/components/FiltersPane/FiltersPane.d.ts +7 -2
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
- package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
- package/dist/components/FiltersPane/types.d.ts +15 -5
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -3
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +8 -8
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -3
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Input/InputBase.d.ts +2 -2
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/Modal/Modal.styles.d.ts +1 -1
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/Select/Select.d.ts +5 -3
- package/dist/components/Select/Select.styles.d.ts +4 -4
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Status/Status.styles.d.ts +3 -2
- package/dist/components/Status/constants.d.ts +0 -1
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/Status/types.d.ts +5 -2
- package/dist/components/TextArea/TextArea.d.ts +2 -5
- package/dist/components/TextArea/TextArea.styles.d.ts +1 -2
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +21 -6
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithPopup/helpers.d.ts +2 -0
- package/dist/components/WithPopup/types.d.ts +3 -0
- package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-merge.d.ts +1 -0
- package/dist/hooks/use-mixed-styles.d.ts +3 -1
- package/dist/hooks/use-tweak-styles.d.ts +5 -5
- package/dist/style.css +78 -142
- package/dist/theme/Provider.d.ts +6 -3
- package/dist/theme/common.d.ts +4 -2
- package/dist/theme/create-themed-styles.d.ts +2 -0
- package/dist/theme/helpers.d.ts +9 -3
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
- package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
- package/dist/theme/true-jss/index.d.ts +2 -0
- package/dist/theme/true-jss/jss-context.d.ts +9 -0
- package/dist/theme/types.d.ts +5 -3
- package/dist/true-react-common-ui-kit.js +7580 -6523
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7466 -6410
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +4 -5
- package/src/components/ControlWrapper/ControlWrapper.stories.tsx +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
- package/src/components/ControlWrapper/ControlWrapper.tsx +8 -2
- package/src/components/ControlWrapper/index.ts +1 -0
- package/src/components/ControlWrapper/types.ts +4 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +2 -1
- package/src/components/DatePicker/DatePicker.styles.ts +3 -1
- package/src/components/DatePicker/DatePicker.tsx +12 -7
- package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +4 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +9 -4
- package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
- package/src/components/FiltersPane/FiltersPane.tsx +19 -13
- package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
- package/src/components/FiltersPane/types.ts +23 -5
- package/src/components/Flag/Flag.stories.tsx +2 -1
- package/src/components/Flag/Flag.styles.ts +4 -0
- package/src/components/Flag/Flag.tsx +23 -9
- package/src/components/Flag/customFlags/AB.svg +1 -0
- package/src/components/Flag/customFlags/OS.svg +1 -0
- package/src/components/Flag/customFlags/augment.d.ts +1 -0
- package/src/components/Flag/customFlags/customFlags.ts +13 -0
- package/src/components/Flag/customFlags/index.ts +1 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -5
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +13 -12
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +8 -12
- package/src/components/IncrementInput/IncrementInput.stories.tsx +2 -0
- package/src/components/IncrementInput/IncrementInput.styles.ts +31 -39
- package/src/components/IncrementInput/IncrementInput.tsx +28 -25
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/InputBase.tsx +29 -24
- package/src/components/List/List.tsx +5 -2
- package/src/components/List/index.ts +2 -1
- package/src/components/List/types.ts +5 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +5 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/SearchInput/SearchInput.tsx +20 -29
- package/src/components/Select/Select.tsx +12 -2
- package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
- package/src/components/Select/index.ts +1 -1
- package/src/components/Status/Status.stories.tsx +54 -1
- package/src/components/Status/Status.styles.ts +2 -37
- package/src/components/Status/constants.ts +0 -10
- package/src/components/Status/index.ts +1 -1
- package/src/components/Status/types.ts +7 -3
- package/src/components/TextArea/TextArea.styles.ts +2 -6
- package/src/components/TextArea/TextArea.tsx +41 -20
- package/src/components/TextArea/index.ts +0 -1
- package/src/components/TextButton/TextButton.styles.ts +1 -0
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/WithMessages/WithMessages.stories.tsx +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
- package/src/components/WithPopup/WithPopup.styles.ts +2 -0
- package/src/components/WithPopup/WithPopup.tsx +64 -16
- package/src/components/WithPopup/helpers.ts +9 -0
- package/src/components/WithPopup/types.ts +7 -0
- package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
- package/src/components/WithTooltip/WithTooltip.tsx +7 -2
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-merge.ts +8 -0
- package/src/hooks/use-mixed-styles.ts +9 -11
- package/src/hooks/use-tweak-styles.ts +49 -27
- package/src/theme/Provider.tsx +10 -5
- package/src/theme/common.ts +5 -2
- package/src/theme/create-themed-styles.ts +78 -0
- package/src/theme/helpers.ts +39 -39
- package/src/theme/index.ts +2 -0
- package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
- package/src/theme/true-jss/TweakStylesManager.ts +157 -0
- package/src/theme/true-jss/index.ts +2 -0
- package/src/theme/true-jss/jss-context.tsx +34 -0
- package/src/theme/types.ts +5 -3
- package/src/types.ts +17 -4
- package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
- package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
- package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
- package/dist/components/Colors/Colors.stories.d.ts +0 -5
- package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
- package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
- package/dist/components/Description/Description.stories.d.ts +0 -16
- package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
- package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
- package/dist/components/Flag/Flag.stories.d.ts +0 -12
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
- package/dist/components/Icon/Icon.stories.d.ts +0 -6
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
- package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
- package/dist/components/Input/Input.stories.d.ts +0 -25
- package/dist/components/List/List.stories.d.ts +0 -5
- package/dist/components/Modal/Modal.stories.d.ts +0 -29
- package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
- package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
- package/dist/components/Notification/Notification.stories.d.ts +0 -8
- package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
- package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
- package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -6
- package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
- package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
- package/dist/components/Select/Select.stories.d.ts +0 -15
- package/dist/components/Selector/Selector.stories.d.ts +0 -7
- package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
- package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
- package/dist/components/Status/Status.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -16
- package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
- package/dist/components/TextArea/types.d.ts +0 -2
- package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
- package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
- package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
- package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
- package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
- package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
- package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
- package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
- package/src/components/TextArea/types.ts +0 -6
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { animations, colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
2
|
import { IInputStyles } from '../Input';
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export const inputStyles: IInputStyles = {
|
|
5
|
+
tweakControlWrapper: {
|
|
6
|
+
controlWrapper: {
|
|
7
|
+
'--increment-buttons-width': '36px',
|
|
8
|
+
'--increment-buttons-gap': '1px',
|
|
9
|
+
'--increment-buttons-margin': '1px',
|
|
10
|
+
'--increment-button-icon-size': '16px',
|
|
11
|
+
},
|
|
12
12
|
},
|
|
13
|
+
};
|
|
13
14
|
|
|
15
|
+
export const useStyles = createThemedStyles('IncrementInput', {
|
|
14
16
|
buttons: {
|
|
15
17
|
display: 'flex',
|
|
16
18
|
flexDirection: 'column',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
height: 'calc(100% - var(--increment-buttons-margin) * 2)',
|
|
20
|
+
margin: 'var(--increment-buttons-margin)',
|
|
21
|
+
gap: 'var(--increment-buttons-gap)',
|
|
22
|
+
flexShrink: 0,
|
|
23
|
+
order: 1000, // сдвигаем кнопки на самый конец
|
|
24
|
+
|
|
22
25
|
zIndex: dimensions.Z_INDEX.CONTROL_FOCUS + 1,
|
|
23
26
|
},
|
|
24
27
|
|
|
25
28
|
button: {
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
width: 'var(--increment-buttons-width)',
|
|
33
|
+
flexGrow: 1,
|
|
34
|
+
|
|
35
|
+
cursor: 'pointer',
|
|
28
36
|
border: 'none',
|
|
29
37
|
outline: 'none',
|
|
38
|
+
color: colors.FONT_MEDIUM,
|
|
30
39
|
backgroundColor: colors.GREY_BACKGROUND,
|
|
31
40
|
transition: animations.defaultTransition,
|
|
32
|
-
transitionProperty: 'background-color',
|
|
33
|
-
color: colors.FONT_MEDIUM,
|
|
34
|
-
cursor: 'pointer',
|
|
35
|
-
display: 'flex',
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
justifyContent: 'center',
|
|
38
|
-
padding: [0, 10],
|
|
41
|
+
transitionProperty: 'background-color, color',
|
|
39
42
|
|
|
40
43
|
'&:hover, &:focus': {
|
|
41
44
|
backgroundColor: colors.GREY_HOVER,
|
|
@@ -44,16 +47,12 @@ export const useStyles = createThemedStyles('IncrementInput', {
|
|
|
44
47
|
'&:active': {
|
|
45
48
|
backgroundColor: colors.GREY_ACTIVE,
|
|
46
49
|
},
|
|
47
|
-
|
|
48
|
-
'&:first-child': {
|
|
49
|
-
marginBottom: 1,
|
|
50
|
-
},
|
|
51
50
|
},
|
|
52
51
|
|
|
53
52
|
disabledButton: {
|
|
54
|
-
backgroundColor: colors.CLASSIC_WHITE,
|
|
55
|
-
color: colors.FONT_DISABLED,
|
|
56
53
|
cursor: 'default',
|
|
54
|
+
color: colors.FONT_DISABLED,
|
|
55
|
+
backgroundColor: colors.CLASSIC_WHITE,
|
|
57
56
|
|
|
58
57
|
'&:hover': {
|
|
59
58
|
backgroundColor: colors.CLASSIC_WHITE,
|
|
@@ -61,18 +60,11 @@ export const useStyles = createThemedStyles('IncrementInput', {
|
|
|
61
60
|
},
|
|
62
61
|
|
|
63
62
|
errorButton: {},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const inputStyles: IInputStyles = {
|
|
67
|
-
input: {
|
|
68
|
-
paddingRight: BUTTONS_WIDTH + BUTTONS_GAP,
|
|
69
|
-
},
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
64
|
+
icon: {
|
|
65
|
+
width: 'var(--increment-button-icon-size)',
|
|
66
|
+
height: 'var(--increment-button-icon-size)',
|
|
75
67
|
},
|
|
76
|
-
};
|
|
68
|
+
});
|
|
77
69
|
|
|
78
70
|
export type IIncrementInputStyles = ITweakStyles<typeof useStyles, { tweakInput: IInputStyles }>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, useEffect } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { isNotEmpty, isNumberInteger } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { getNumberInRange, getNumberLength } from '../../helpers';
|
|
5
5
|
import { useTweakStyles } from '../../hooks';
|
|
6
6
|
import { ICommonProps } from '../../types';
|
|
7
7
|
import { Icon } from '../Icon';
|
|
@@ -22,8 +22,6 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
|
|
|
22
22
|
max,
|
|
23
23
|
step = 1,
|
|
24
24
|
intPartPrecision,
|
|
25
|
-
data,
|
|
26
|
-
testId,
|
|
27
25
|
tweakStyles,
|
|
28
26
|
isDisabled,
|
|
29
27
|
isReadonly,
|
|
@@ -39,14 +37,15 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
|
|
|
39
37
|
|
|
40
38
|
const classes = useStyles({ theme: tweakStyles });
|
|
41
39
|
|
|
40
|
+
const isEditDisabled = isDisabled || isReadonly;
|
|
41
|
+
|
|
42
42
|
const isIncreaseDisabled =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(
|
|
46
|
-
(max !== undefined && value !== undefined && value >= max);
|
|
43
|
+
isEditDisabled ||
|
|
44
|
+
(isNotEmpty(intPartPrecision) && getNumberLength((value ?? 0) + step) > intPartPrecision) ||
|
|
45
|
+
(isNotEmpty(max) && isNotEmpty(value) && value >= max);
|
|
47
46
|
|
|
48
47
|
const isDecreaseDisabled =
|
|
49
|
-
|
|
48
|
+
isEditDisabled || (isNotEmpty(min) && isNotEmpty(value) && value <= min);
|
|
50
49
|
|
|
51
50
|
const increment = (): void => {
|
|
52
51
|
onChange(getNumberInRange((value ?? 0) + step, min, max));
|
|
@@ -63,19 +62,18 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
|
|
|
63
62
|
}, [step]);
|
|
64
63
|
|
|
65
64
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/>
|
|
65
|
+
<NumberInput
|
|
66
|
+
{...props}
|
|
67
|
+
isInvalid={isInvalid}
|
|
68
|
+
isDisabled={isDisabled}
|
|
69
|
+
isReadonly={isReadonly}
|
|
70
|
+
min={min}
|
|
71
|
+
max={max}
|
|
72
|
+
intPartPrecision={intPartPrecision}
|
|
73
|
+
onChange={onChange}
|
|
74
|
+
value={value}
|
|
75
|
+
tweakStyles={tweakInputStyles}
|
|
76
|
+
>
|
|
79
77
|
<div className={classes.buttons}>
|
|
80
78
|
<button
|
|
81
79
|
className={clsx(classes.button, {
|
|
@@ -86,8 +84,11 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
|
|
|
86
84
|
disabled={isIncreaseDisabled}
|
|
87
85
|
onClick={increment}
|
|
88
86
|
>
|
|
89
|
-
<
|
|
87
|
+
<div className={classes.icon}>
|
|
88
|
+
<Icon type="plus" />
|
|
89
|
+
</div>
|
|
90
90
|
</button>
|
|
91
|
+
|
|
91
92
|
<button
|
|
92
93
|
className={clsx(classes.button, {
|
|
93
94
|
[classes.disabledButton]: isDecreaseDisabled,
|
|
@@ -97,9 +98,11 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
|
|
|
97
98
|
disabled={isDecreaseDisabled}
|
|
98
99
|
onClick={decrement}
|
|
99
100
|
>
|
|
100
|
-
<
|
|
101
|
+
<div className={classes.icon}>
|
|
102
|
+
<Icon type="minus" />
|
|
103
|
+
</div>
|
|
101
104
|
</button>
|
|
102
105
|
</div>
|
|
103
|
-
</
|
|
106
|
+
</NumberInput>
|
|
104
107
|
);
|
|
105
108
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
2
3
|
import { useTweakStyles } from '../../hooks';
|
|
3
4
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
4
5
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
-
|
|
7
|
+
export interface IInputProps
|
|
8
|
+
extends IInputBaseProps,
|
|
9
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {}
|
|
8
10
|
|
|
9
11
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
10
12
|
({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
|
|
@@ -17,7 +19,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
17
19
|
<WithMessages
|
|
18
20
|
errorMessage={errorMessage}
|
|
19
21
|
infoMessage={infoMessage}
|
|
20
|
-
testId={testId}
|
|
22
|
+
testId={getTestId(testId, 'wrapper')}
|
|
21
23
|
tweakStyles={tweakWithMessagesStyles}
|
|
22
24
|
>
|
|
23
25
|
<InputBase
|
|
@@ -15,12 +15,12 @@ import InputMask, { Props as ReactInputMaskBaseProps } from 'react-input-mask';
|
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import {
|
|
17
17
|
addDataTestId,
|
|
18
|
+
isArrayLikeNotEmpty,
|
|
18
19
|
isNotEmpty,
|
|
19
20
|
isReactNodeNotEmpty,
|
|
20
21
|
isStringNotEmpty,
|
|
21
|
-
mergeRefs,
|
|
22
22
|
} from '@true-engineering/true-react-platform-helpers';
|
|
23
|
-
import { useTweakStyles } from '../../hooks';
|
|
23
|
+
import { useMergedRefs, useTweakStyles } from '../../hooks';
|
|
24
24
|
import { IClickHandlerEvent, ICommonProps } from '../../types';
|
|
25
25
|
import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
|
|
26
26
|
import { IChangeInputEvent } from './types';
|
|
@@ -28,10 +28,12 @@ import { IInputStyles, useStyles } from './Input.styles';
|
|
|
28
28
|
|
|
29
29
|
export interface IInputBaseProps
|
|
30
30
|
extends ICommonProps<IInputStyles>,
|
|
31
|
+
Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>,
|
|
31
32
|
Pick<
|
|
32
33
|
IControlWrapperProps,
|
|
33
34
|
| 'label'
|
|
34
35
|
| 'icon'
|
|
36
|
+
| 'size'
|
|
35
37
|
| 'groupPlacement'
|
|
36
38
|
| 'isInvalid'
|
|
37
39
|
| 'isRequired'
|
|
@@ -39,20 +41,6 @@ export interface IInputBaseProps
|
|
|
39
41
|
| 'isDisabled'
|
|
40
42
|
| 'onIconClick'
|
|
41
43
|
>,
|
|
42
|
-
Pick<
|
|
43
|
-
InputHTMLAttributes<HTMLInputElement>,
|
|
44
|
-
| 'type'
|
|
45
|
-
| 'inputMode'
|
|
46
|
-
| 'autoComplete'
|
|
47
|
-
| 'name'
|
|
48
|
-
| 'maxLength'
|
|
49
|
-
| 'tabIndex'
|
|
50
|
-
| 'placeholder'
|
|
51
|
-
| 'onFocus'
|
|
52
|
-
| 'onBlur'
|
|
53
|
-
| 'onPaste'
|
|
54
|
-
| 'onKeyDown'
|
|
55
|
-
>,
|
|
56
44
|
Pick<
|
|
57
45
|
Partial<ReactInputMaskBaseProps>,
|
|
58
46
|
'mask' | 'maskPlaceholder' | 'alwaysShowMask' | 'beforeMaskedStateChange'
|
|
@@ -71,7 +59,7 @@ export interface IInputBaseProps
|
|
|
71
59
|
isAutoSized?: boolean;
|
|
72
60
|
/** @default false */
|
|
73
61
|
shouldAlwaysShowPlaceholder?: boolean;
|
|
74
|
-
onChange(value: string, event: IChangeInputEvent)
|
|
62
|
+
onChange: (value: string, event: IChangeInputEvent) => void;
|
|
75
63
|
}
|
|
76
64
|
|
|
77
65
|
export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
@@ -96,6 +84,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
96
84
|
units,
|
|
97
85
|
testId,
|
|
98
86
|
tabIndex,
|
|
87
|
+
shouldAlwaysShowPlaceholder,
|
|
99
88
|
onChange,
|
|
100
89
|
onPaste,
|
|
101
90
|
onFocus,
|
|
@@ -105,9 +94,17 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
105
94
|
mask,
|
|
106
95
|
maskPlaceholder,
|
|
107
96
|
alwaysShowMask,
|
|
108
|
-
shouldAlwaysShowPlaceholder,
|
|
109
97
|
beforeMaskedStateChange,
|
|
110
|
-
|
|
98
|
+
// Пропсы ControlWrapper
|
|
99
|
+
data,
|
|
100
|
+
groupPlacement,
|
|
101
|
+
icon,
|
|
102
|
+
isLoading,
|
|
103
|
+
isRequired,
|
|
104
|
+
size,
|
|
105
|
+
onIconClick,
|
|
106
|
+
children,
|
|
107
|
+
...inputProps
|
|
111
108
|
},
|
|
112
109
|
ref,
|
|
113
110
|
) => {
|
|
@@ -123,7 +120,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
123
120
|
const [unitsWidth, setUnitsWidth] = useState<number>();
|
|
124
121
|
|
|
125
122
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
126
|
-
const mergedRef =
|
|
123
|
+
const mergedRef = useMergedRefs([ref, inputRef]);
|
|
127
124
|
|
|
128
125
|
// Try to guess input-mode if possible
|
|
129
126
|
const inputMode: IInputBaseProps['inputMode'] =
|
|
@@ -131,7 +128,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
131
128
|
(['email', 'tel', 'url'].includes(type) ? (type as 'email' | 'tel' | 'url') : undefined);
|
|
132
129
|
|
|
133
130
|
const hasFocus = isFocused || isActive;
|
|
134
|
-
const hasValue =
|
|
131
|
+
const hasValue = isArrayLikeNotEmpty(value);
|
|
135
132
|
const hasUnits = isReactNodeNotEmpty(units);
|
|
136
133
|
const hasPlaceholder =
|
|
137
134
|
(!isReactNodeNotEmpty(label) || hasFocus || shouldAlwaysShowPlaceholder) &&
|
|
@@ -194,7 +191,8 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
194
191
|
onFocus: handleFocus,
|
|
195
192
|
onBlur: handleBlur,
|
|
196
193
|
onChange: handleChange,
|
|
197
|
-
...addDataTestId(testId
|
|
194
|
+
...addDataTestId(testId),
|
|
195
|
+
...inputProps,
|
|
198
196
|
};
|
|
199
197
|
|
|
200
198
|
useEffect(() => {
|
|
@@ -234,17 +232,24 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
234
232
|
isDisabled={isDisabled}
|
|
235
233
|
isFocused={hasFocus}
|
|
236
234
|
isInvalid={isInvalid}
|
|
237
|
-
hasValue={hasValue
|
|
235
|
+
hasValue={hasValue}
|
|
238
236
|
isFullWidth={!isAutoSized}
|
|
239
237
|
tweakStyles={tweakControlWrapperStyles}
|
|
240
238
|
onClear={isClearable && hasValue ? handleInputClear : undefined}
|
|
241
|
-
{
|
|
239
|
+
data={data}
|
|
240
|
+
groupPlacement={groupPlacement}
|
|
241
|
+
icon={icon}
|
|
242
|
+
isLoading={isLoading}
|
|
243
|
+
isRequired={isRequired}
|
|
244
|
+
onIconClick={onIconClick}
|
|
245
|
+
size={size}
|
|
242
246
|
>
|
|
243
247
|
{hasUnits || isAutoSized ? (
|
|
244
248
|
<div className={classes.autoSizeWrapper}>{inputContent}</div>
|
|
245
249
|
) : (
|
|
246
250
|
inputContent
|
|
247
251
|
)}
|
|
252
|
+
{children}
|
|
248
253
|
</ControlWrapper>
|
|
249
254
|
);
|
|
250
255
|
},
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import { addDataAttributes } from '../../helpers';
|
|
9
9
|
import { ICommonProps } from '../../types';
|
|
10
10
|
import { WithPopup } from '../WithPopup';
|
|
11
|
-
import { IListItemProps,
|
|
11
|
+
import { IListItemProps, ListItem } from './components';
|
|
12
|
+
import { IListItem } from './types';
|
|
12
13
|
import { useStyles, IListStyles, withPopupStyles } from './List.styles';
|
|
13
14
|
|
|
14
15
|
export interface IListProps extends ICommonProps<IListStyles> {
|
|
@@ -29,9 +30,11 @@ export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
const filteredItems = items.filter(({ isHidden }) => !isHidden);
|
|
34
|
+
|
|
32
35
|
return (
|
|
33
36
|
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
34
|
-
{
|
|
37
|
+
{filteredItems.map((item, i) => {
|
|
35
38
|
const itemProps: IListItemProps = {
|
|
36
39
|
testId: getTestId(testId, `item-${i}`),
|
|
37
40
|
...item,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './List';
|
|
2
2
|
export type { IListStyles } from './List.styles';
|
|
3
|
-
export
|
|
3
|
+
export type { IListItem } from './types';
|
|
4
|
+
export { type IListItemStyles, type IListItemProps, ListItem } from './components';
|
|
@@ -9,7 +9,11 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
const Template: ComponentStory<typeof NumberInput> = (args) => {
|
|
11
11
|
const [value, setValue] = useState<number>();
|
|
12
|
-
return
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ width: 300 }}>
|
|
14
|
+
<NumberInput {...args} value={value} onChange={(v) => setValue(v)} />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export const Default = Template.bind({});
|
|
@@ -26,7 +26,8 @@ export default {
|
|
|
26
26
|
const Template: ComponentStory<typeof PhoneInput> = (args) => {
|
|
27
27
|
const [value, setValue] = useState<IPhoneValue>({
|
|
28
28
|
dialCode: '7',
|
|
29
|
-
phoneNumber: '
|
|
29
|
+
phoneNumber: '9134567890',
|
|
30
|
+
countryCode: 'RU',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return <PhoneInput {...args} value={value} onChange={setValue} />;
|
|
@@ -76,7 +76,7 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
76
76
|
|
|
77
77
|
const countryCode = useMemo(
|
|
78
78
|
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
79
|
-
[value.dialCode, value.phoneNumber],
|
|
79
|
+
[value.countryCode, value.dialCode, value.phoneNumber],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const handleClose = () => {
|
|
@@ -122,7 +122,10 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
122
122
|
if (newPhoneInfo.countryCode !== countryCode) {
|
|
123
123
|
onChange(
|
|
124
124
|
{
|
|
125
|
-
phoneNumber:
|
|
125
|
+
phoneNumber:
|
|
126
|
+
newPhoneInfo.dialCode !== value.dialCode
|
|
127
|
+
? ''
|
|
128
|
+
: getPhoneObjFromString(phoneWithCode).phoneNumber,
|
|
126
129
|
dialCode: newPhoneInfo.dialCode,
|
|
127
130
|
countryCode: newPhoneInfo.countryCode,
|
|
128
131
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
3
2
|
import { useTweakStyles } from '../../hooks';
|
|
4
3
|
import { ICommonProps } from '../../types';
|
|
5
4
|
import { IInputProps, Input } from '../Input';
|
|
@@ -11,31 +10,23 @@ export type ISearchInputProps = Omit<
|
|
|
11
10
|
> &
|
|
12
11
|
ICommonProps<ISearchInputStyles>;
|
|
13
12
|
|
|
14
|
-
export const SearchInput
|
|
15
|
-
isClearable = true,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}) => {
|
|
23
|
-
const tweakInputStyles = useTweakStyles({
|
|
24
|
-
innerStyles: inputStyles,
|
|
25
|
-
tweakStyles,
|
|
26
|
-
className: 'tweakInput',
|
|
27
|
-
currentComponentName: 'SearchInput',
|
|
28
|
-
});
|
|
13
|
+
export const SearchInput = forwardRef<HTMLInputElement, ISearchInputProps>(
|
|
14
|
+
({ isClearable = true, tweakStyles, ...props }, ref) => {
|
|
15
|
+
const tweakInputStyles = useTweakStyles({
|
|
16
|
+
innerStyles: inputStyles,
|
|
17
|
+
tweakStyles,
|
|
18
|
+
className: 'tweakInput',
|
|
19
|
+
currentComponentName: 'SearchInput',
|
|
20
|
+
});
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
22
|
+
return (
|
|
23
|
+
<Input
|
|
24
|
+
ref={ref}
|
|
25
|
+
icon="search"
|
|
26
|
+
isClearable={isClearable}
|
|
27
|
+
tweakStyles={tweakInputStyles}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
KeyboardEvent,
|
|
6
6
|
MouseEvent,
|
|
7
7
|
ReactNode,
|
|
8
|
+
Ref,
|
|
8
9
|
SyntheticEvent,
|
|
9
10
|
useCallback,
|
|
10
11
|
useEffect,
|
|
@@ -63,7 +64,11 @@ export interface ISelectProps<Value>
|
|
|
63
64
|
/** @default true */
|
|
64
65
|
shouldScrollToList?: boolean;
|
|
65
66
|
isMultiSelect?: false;
|
|
66
|
-
searchInput?: {
|
|
67
|
+
searchInput?: {
|
|
68
|
+
/** @default false */
|
|
69
|
+
shouldRenderInList?: boolean;
|
|
70
|
+
ref?: Ref<HTMLInputElement>;
|
|
71
|
+
} & Pick<ISearchInputProps, 'placeholder' | 'shouldFocusOnMount'>;
|
|
67
72
|
isOptionDisabled?: (option: Value) => boolean;
|
|
68
73
|
onChange: (value: Value | undefined, event: IChangeSelectEvent) => void; // подумать как возвращать индекс
|
|
69
74
|
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
@@ -248,10 +253,14 @@ export function Select<Value>(
|
|
|
248
253
|
|
|
249
254
|
const handleListClose = useCallback(
|
|
250
255
|
(event: Event | SyntheticEvent) => {
|
|
256
|
+
if (!isListOpen) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
closeList();
|
|
252
261
|
onBlur?.(event);
|
|
253
262
|
},
|
|
254
|
-
[closeList, onBlur],
|
|
263
|
+
[isListOpen, closeList, onBlur],
|
|
255
264
|
);
|
|
256
265
|
|
|
257
266
|
const handleListOpen = () => {
|
|
@@ -581,6 +590,7 @@ export function Select<Value>(
|
|
|
581
590
|
errorMessage={errorMessage}
|
|
582
591
|
infoMessage={infoMessage}
|
|
583
592
|
tweakStyles={tweakWithMessagesStyles}
|
|
593
|
+
testId={getTestId(testId, 'wrapper')}
|
|
584
594
|
>
|
|
585
595
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
586
596
|
<div
|
|
@@ -84,7 +84,7 @@ export function SelectList<Value>({
|
|
|
84
84
|
})}
|
|
85
85
|
>
|
|
86
86
|
{isHeaderNotEmpty && <div className={classes.listHeader}>{customListHeader}</div>}
|
|
87
|
-
<div className={classes.list} {...addDataTestId(testId)}>
|
|
87
|
+
<div className={classes.list} {...addDataTestId(testId)} tabIndex={-1}>
|
|
88
88
|
{isLoading ? (
|
|
89
89
|
<div className={clsx(classes.cell, classes.loading)}>{loadingLabel}</div>
|
|
90
90
|
) : (
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
import { Status } from '.';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { rgba } from '../../helpers';
|
|
4
|
+
import { IExtendableProps } from '../../types';
|
|
3
5
|
import { iconsList, IIconType } from '../Icon';
|
|
4
6
|
import { complexIcons } from '../Icon/complexIcons';
|
|
5
|
-
import {
|
|
7
|
+
import { STATUS_SIZES } from './constants';
|
|
6
8
|
import { IStatusStyles } from './Status.styles';
|
|
7
9
|
|
|
10
|
+
export const STATUS_COLORS = [
|
|
11
|
+
'green',
|
|
12
|
+
'teal',
|
|
13
|
+
'blue',
|
|
14
|
+
'grey',
|
|
15
|
+
'orange',
|
|
16
|
+
'red',
|
|
17
|
+
'violet',
|
|
18
|
+
'custom',
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
8
21
|
export default {
|
|
9
22
|
title: 'Data Display/Status',
|
|
10
23
|
component: Status,
|
|
11
24
|
};
|
|
12
25
|
|
|
26
|
+
declare module './types' {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
28
|
+
export interface IStatusColors extends IExtendableProps<typeof STATUS_COLORS> {}
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
const icons = [undefined, ...Object.keys(iconsList), ...Object.keys(complexIcons)] as IIconType[];
|
|
14
32
|
|
|
15
33
|
const customTweakStyles: IStatusStyles = {
|
|
34
|
+
green: {
|
|
35
|
+
'--status-background': rgba('#D4E3AC', 0.5),
|
|
36
|
+
'--status-color': '#6F990F',
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
blue: {
|
|
40
|
+
'--status-background': rgba('#AABFFC', 0.4),
|
|
41
|
+
'--status-color': '#4C6EBF',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
grey: {
|
|
45
|
+
'--status-background': rgba('#95A0B3', 0.25),
|
|
46
|
+
'--status-color': '#7A869A',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
orange: {
|
|
50
|
+
'--status-background': rgba('#FCD3A9', 0.5),
|
|
51
|
+
'--status-color': '#E5741C',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
red: {
|
|
55
|
+
'--status-background': rgba('#F7949A', 0.25),
|
|
56
|
+
'--status-color': '#F14D56',
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
teal: {
|
|
60
|
+
'--status-background': rgba('#8CE3EA', 0.4),
|
|
61
|
+
'--status-color': '#0092A6',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
violet: {
|
|
65
|
+
'--status-background': rgba('#BEABE0', 0.4),
|
|
66
|
+
'--status-color': '#7450B2',
|
|
67
|
+
},
|
|
68
|
+
|
|
16
69
|
custom: {
|
|
17
70
|
'--status-color': '#793472',
|
|
18
71
|
'--status-background': '#F2B9ED',
|