@true-engineering/true-react-common-ui-kit 4.0.0-alpha20 → 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/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -3
- package/dist/components/Input/InputBase.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +78 -84
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +78 -84
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.stories.tsx +1 -1
- 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/InputBase.tsx +3 -1
- package/src/components/WithMessages/WithMessages.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -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
|
};
|
|
@@ -33,13 +33,13 @@ export interface IInputBaseProps
|
|
|
33
33
|
IControlWrapperProps,
|
|
34
34
|
| 'label'
|
|
35
35
|
| 'icon'
|
|
36
|
+
| 'size'
|
|
36
37
|
| 'groupPlacement'
|
|
37
38
|
| 'isInvalid'
|
|
38
39
|
| 'isRequired'
|
|
39
40
|
| 'isLoading'
|
|
40
41
|
| 'isDisabled'
|
|
41
42
|
| 'onIconClick'
|
|
42
|
-
| 'size'
|
|
43
43
|
>,
|
|
44
44
|
Pick<
|
|
45
45
|
Partial<ReactInputMaskBaseProps>,
|
|
@@ -103,6 +103,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
103
103
|
isRequired,
|
|
104
104
|
size,
|
|
105
105
|
onIconClick,
|
|
106
|
+
children,
|
|
106
107
|
...inputProps
|
|
107
108
|
},
|
|
108
109
|
ref,
|
|
@@ -248,6 +249,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
248
249
|
) : (
|
|
249
250
|
inputContent
|
|
250
251
|
)}
|
|
252
|
+
{children}
|
|
251
253
|
</ControlWrapper>
|
|
252
254
|
);
|
|
253
255
|
},
|