@true-engineering/true-react-common-ui-kit 4.0.0-alpha0 → 4.0.0-alpha2
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/ControlWrapper/ControlWrapper.styles.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +3 -3
- package/dist/components/Input/Input.stories.d.ts +2 -2
- package/dist/components/Input/Input.styles.d.ts +3 -3
- package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -11
- package/dist/components/SearchInput/SearchInput.styles.d.ts +3 -5
- package/dist/components/Select/Select.styles.d.ts +8 -8
- package/dist/components/TextArea/TextArea.d.ts +2 -2
- package/dist/components/TextArea/TextArea.styles.d.ts +3 -3
- package/dist/components/WithMessages/WithMessages.d.ts +10 -0
- package/dist/components/{ControlGroup/ControlGroup.stories.d.ts → WithMessages/WithMessages.stories.d.ts} +2 -2
- package/dist/components/WithMessages/WithMessages.styles.d.ts +3 -0
- package/dist/components/WithMessages/index.d.ts +2 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/theme/types.d.ts +2 -2
- package/dist/true-react-common-ui-kit.js +187 -242
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +187 -242
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +1 -1
- package/src/components/ControlWrapper/ControlWrapper.tsx +1 -1
- package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.ts +1 -1
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +1 -1
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +6 -1
- package/src/components/FiltersPane/components/FilterSelect/FilterSelect.styles.ts +2 -2
- package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +8 -2
- package/src/components/IncrementInput/IncrementInput.styles.ts +1 -1
- package/src/components/Input/Input.styles.ts +5 -2
- package/src/components/Input/Input.tsx +7 -7
- package/src/components/Input/InputBase.tsx +1 -0
- package/src/components/MultiSelectList/MultiSelectList.styles.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.styles.ts +2 -2
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.ts +1 -1
- package/src/components/SearchInput/SearchInput.styles.ts +17 -30
- package/src/components/SearchInput/SearchInput.tsx +12 -20
- package/src/components/Select/CustomSelect.stories.tsx +2 -2
- package/src/components/Select/Select.styles.ts +8 -2
- package/src/components/Select/Select.tsx +7 -29
- package/src/components/TextArea/TextArea.styles.ts +7 -3
- package/src/components/TextArea/TextArea.tsx +13 -9
- package/src/components/{ControlGroup/ControlGroup.stories.tsx → WithMessages/WithMessages.stories.tsx} +10 -10
- package/src/components/{ControlGroup/ControlGroup.styles.ts → WithMessages/WithMessages.styles.ts} +4 -3
- package/src/components/{ControlGroup/ControlGroup.tsx → WithMessages/WithMessages.tsx} +13 -9
- package/src/components/WithMessages/index.ts +2 -0
- package/src/components/index.ts +1 -1
- package/src/theme/types.ts +2 -2
- package/dist/components/ControlGroup/ControlGroup.d.ts +0 -10
- package/dist/components/ControlGroup/ControlGroup.styles.d.ts +0 -3
- package/dist/components/ControlGroup/index.d.ts +0 -2
- package/src/components/ControlGroup/index.ts +0 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { IThemedPreloaderStyles } from '../ThemedPreloader';
|
|
|
4
4
|
const { CONTROL, Z_INDEX } = dimensions;
|
|
5
5
|
|
|
6
6
|
export const useStyles = createThemedStyles('ControlWrapper', {
|
|
7
|
-
|
|
7
|
+
controlWrapper: {
|
|
8
8
|
'--control-height': `${CONTROL.HEIGHT - 2}px`, // borders
|
|
9
9
|
'--control-padding': `${CONTROL.PADDING}px`,
|
|
10
10
|
'--icon-size': `${CONTROL.ICON_SIZE}px`,
|
|
@@ -7,7 +7,12 @@ import { Button } from '../../../Button';
|
|
|
7
7
|
import { NumberInput } from '../../../NumberInput';
|
|
8
8
|
import { getLocale, sortValues } from '../../helpers';
|
|
9
9
|
import { IFilterLocaleKey, IPartialFilterLocale } from '../../types';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
clearButtonStyles,
|
|
12
|
+
IFilterIntervalStyles,
|
|
13
|
+
inputStyles,
|
|
14
|
+
useStyles,
|
|
15
|
+
} from './FilterInterval.styles';
|
|
11
16
|
|
|
12
17
|
export interface IFilterIntervalProps extends ICommonProps<IFilterIntervalStyles> {
|
|
13
18
|
value?: Array<number | undefined>;
|
|
@@ -123,12 +123,12 @@ export const useStyles = createThemedStyles('FilterSelect', {
|
|
|
123
123
|
export const searchInputStyles: ISearchInputStyles = {
|
|
124
124
|
tweakInput: {
|
|
125
125
|
tweakControlWrapper: {
|
|
126
|
-
|
|
126
|
+
controlWrapper: {
|
|
127
127
|
'--control-height': '40px',
|
|
128
128
|
backgroundColor: 'transparent',
|
|
129
129
|
border: 'none',
|
|
130
130
|
},
|
|
131
|
-
}
|
|
131
|
+
},
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
134
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { rgba } from '../../../../helpers';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
animations,
|
|
4
|
+
colors,
|
|
5
|
+
createThemedStyles,
|
|
6
|
+
dimensions,
|
|
7
|
+
ITweakStyles,
|
|
8
|
+
} from '../../../../theme';
|
|
3
9
|
import { ISearchInputStyles } from '../../../SearchInput';
|
|
4
10
|
import { ISelectStyles } from '../../../Select';
|
|
5
11
|
import { FILTER_HEIGHT } from '../../FiltersPane.styles';
|
|
@@ -84,7 +90,7 @@ export const useStyles = createThemedStyles('FiltersPaneSearch', {
|
|
|
84
90
|
export const searchInputStyles: ISearchInputStyles = {
|
|
85
91
|
tweakInput: {
|
|
86
92
|
tweakControlWrapper: {
|
|
87
|
-
|
|
93
|
+
controlWrapper: {
|
|
88
94
|
'--control-height': `${FILTER_HEIGHT - 2}px`,
|
|
89
95
|
backgroundColor: 'transparent',
|
|
90
96
|
border: 'none',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createThemedStyles, ITweakStyles } from '../../theme';
|
|
2
|
-
import { IControlGroupStyles } from '../ControlGroup';
|
|
3
2
|
import { IControlWrapperStyles } from '../ControlWrapper';
|
|
3
|
+
import { IWithMessagesStyles } from '../WithMessages';
|
|
4
4
|
|
|
5
5
|
const PADDING_WITH_UNITS = 8;
|
|
6
6
|
|
|
@@ -69,12 +69,15 @@ export const useStyles = createThemedStyles('Input', {
|
|
|
69
69
|
|
|
70
70
|
withLabel: {},
|
|
71
71
|
|
|
72
|
+
withValue: {},
|
|
73
|
+
|
|
72
74
|
fakeValue: {
|
|
73
75
|
extend: 'inputContent',
|
|
74
76
|
visibility: 'hidden',
|
|
75
77
|
maxWidth: '100%',
|
|
76
78
|
overflow: 'hidden',
|
|
77
79
|
minWidth: 8,
|
|
80
|
+
whiteSpace: 'nowrap',
|
|
78
81
|
},
|
|
79
82
|
|
|
80
83
|
units: {
|
|
@@ -93,6 +96,6 @@ export type IInputStyles = ITweakStyles<
|
|
|
93
96
|
typeof useStyles,
|
|
94
97
|
{
|
|
95
98
|
tweakControlWrapper: IControlWrapperStyles;
|
|
96
|
-
|
|
99
|
+
tweakWithMessages: IWithMessagesStyles;
|
|
97
100
|
}
|
|
98
101
|
>;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { useTweakStyles } from '../../hooks';
|
|
3
|
-
import {
|
|
3
|
+
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
4
4
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
5
5
|
|
|
6
6
|
export type IInputProps = IInputBaseProps &
|
|
7
|
-
Pick<
|
|
7
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'>;
|
|
8
8
|
|
|
9
9
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
10
10
|
({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
|
|
11
|
-
const
|
|
11
|
+
const tweakWithMessagesStyles = useTweakStyles({
|
|
12
12
|
tweakStyles,
|
|
13
|
-
className: '
|
|
13
|
+
className: 'tweakWithMessages',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
17
|
+
<WithMessages
|
|
18
18
|
errorMessage={errorMessage}
|
|
19
19
|
infoMessage={infoMessage}
|
|
20
20
|
testId={testId}
|
|
21
|
-
tweakStyles={
|
|
21
|
+
tweakStyles={tweakWithMessagesStyles}
|
|
22
22
|
>
|
|
23
23
|
<InputBase
|
|
24
24
|
{...inputProps}
|
|
@@ -27,7 +27,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
27
27
|
tweakStyles={tweakStyles}
|
|
28
28
|
isInvalid={isInvalid}
|
|
29
29
|
/>
|
|
30
|
-
</
|
|
30
|
+
</WithMessages>
|
|
31
31
|
);
|
|
32
32
|
},
|
|
33
33
|
);
|
|
@@ -168,6 +168,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
168
168
|
const props: InputHTMLAttributes<HTMLInputElement> = {
|
|
169
169
|
className: clsx(classes.input, {
|
|
170
170
|
[classes.withUnits]: hasUnits,
|
|
171
|
+
[classes.withValue]: hasValue,
|
|
171
172
|
[classes.withLabel]: isReactNodeNotEmpty(label),
|
|
172
173
|
[classes.autoSized]: isAutoSized,
|
|
173
174
|
[classes.focusedInput]: isFocused,
|
|
@@ -92,7 +92,7 @@ export const useStyles = createThemedStyles('MultiSelectList', {
|
|
|
92
92
|
export const searchInputStyles: ISearchInputStyles = {
|
|
93
93
|
tweakInput: {
|
|
94
94
|
tweakControlWrapper: {
|
|
95
|
-
|
|
95
|
+
controlWrapper: {
|
|
96
96
|
'--control-height': '40px',
|
|
97
97
|
backgroundColor: 'transparent',
|
|
98
98
|
border: 'none',
|
|
@@ -73,14 +73,14 @@ export const useStyles = createThemedStyles('PhoneInput', {
|
|
|
73
73
|
|
|
74
74
|
export const inputStyles: IInputStyles = {
|
|
75
75
|
tweakControlWrapper: {
|
|
76
|
-
|
|
76
|
+
controlWrapper: {
|
|
77
77
|
paddingLeft: COUNTRY_SELECT_WIDTH,
|
|
78
78
|
},
|
|
79
79
|
|
|
80
80
|
label: {
|
|
81
81
|
marginLeft: COUNTRY_SELECT_WIDTH,
|
|
82
82
|
},
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
export type IPhoneInputStyles = ITweakStyles<
|
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
import { colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
1
|
import { IInputStyles } from '../Input';
|
|
3
2
|
|
|
4
|
-
const { Z_INDEX } = dimensions;
|
|
5
|
-
|
|
6
|
-
export const useStyles = createThemedStyles('SearchInput', {
|
|
7
|
-
root: {
|
|
8
|
-
position: 'relative',
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
icon: {
|
|
12
|
-
display: 'flex',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
position: 'absolute',
|
|
15
|
-
left: 12,
|
|
16
|
-
height: '100%',
|
|
17
|
-
width: 20,
|
|
18
|
-
color: colors.GREY_ACTIVE,
|
|
19
|
-
zIndex: Z_INDEX.CONTROL_FOCUS + 1,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
3
|
export const inputStyles: IInputStyles = {
|
|
24
4
|
tweakControlWrapper: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
endIcon: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: 40,
|
|
8
|
+
left: 0,
|
|
9
|
+
|
|
10
|
+
'&:last-child': {
|
|
11
|
+
paddingRight: 0,
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
'&:not($activeIcon)': {
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
},
|
|
30
17
|
},
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
borderColor: colors.BORDER_MAIN,
|
|
19
|
+
controlWrapper: {
|
|
20
|
+
borderColor: 'transparent',
|
|
35
21
|
},
|
|
36
22
|
},
|
|
37
|
-
|
|
38
23
|
inputContent: {
|
|
39
24
|
fontSize: 14,
|
|
40
25
|
paddingLeft: 44,
|
|
41
26
|
},
|
|
42
27
|
};
|
|
43
28
|
|
|
44
|
-
export
|
|
29
|
+
export interface ISearchInputStyles {
|
|
30
|
+
tweakInput?: IInputStyles;
|
|
31
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { addDataAttributes } from '../../helpers';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
3
|
import { useTweakStyles } from '../../hooks';
|
|
5
4
|
import { ICommonProps } from '../../types';
|
|
6
|
-
import { Icon } from '../Icon';
|
|
7
5
|
import { IInputProps, Input } from '../Input';
|
|
8
|
-
import { inputStyles, ISearchInputStyles
|
|
6
|
+
import { inputStyles, ISearchInputStyles } from './SearchInput.styles';
|
|
9
7
|
|
|
10
8
|
export type ISearchInputProps = Omit<
|
|
11
9
|
IInputProps,
|
|
@@ -15,15 +13,13 @@ export type ISearchInputProps = Omit<
|
|
|
15
13
|
|
|
16
14
|
export const SearchInput: FC<ISearchInputProps> = ({
|
|
17
15
|
isClearable = true,
|
|
18
|
-
tweakStyles,
|
|
19
16
|
placeholder,
|
|
20
17
|
value,
|
|
21
18
|
testId,
|
|
19
|
+
tweakStyles,
|
|
22
20
|
data,
|
|
23
21
|
...props
|
|
24
22
|
}) => {
|
|
25
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
26
|
-
|
|
27
23
|
const tweakInputStyles = useTweakStyles({
|
|
28
24
|
innerStyles: inputStyles,
|
|
29
25
|
tweakStyles,
|
|
@@ -32,18 +28,14 @@ export const SearchInput: FC<ISearchInputProps> = ({
|
|
|
32
28
|
});
|
|
33
29
|
|
|
34
30
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
tweakStyles={tweakInputStyles}
|
|
45
|
-
{...props}
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
31
|
+
<Input
|
|
32
|
+
value={value}
|
|
33
|
+
placeholder={placeholder}
|
|
34
|
+
icon="search"
|
|
35
|
+
isClearable={isClearable}
|
|
36
|
+
testId={getTestId(testId, 'input')}
|
|
37
|
+
tweakStyles={tweakInputStyles}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
48
40
|
);
|
|
49
41
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeStyles } from '@true-engineering/true-react-platform-helpers';
|
|
2
2
|
import { animations, createThemedStyles, dimensions, type ITweakStyles } from '../../theme';
|
|
3
|
-
import { IControlGroupStyles } from '../ControlGroup';
|
|
4
3
|
import { type IInputStyles } from '../Input';
|
|
5
4
|
import { type ISearchInputStyles } from '../SearchInput';
|
|
5
|
+
import { IWithMessagesStyles } from '../WithMessages';
|
|
6
6
|
import { type ISelectListStyles } from './components';
|
|
7
7
|
|
|
8
8
|
const { CONTROL, Z_INDEX } = dimensions;
|
|
@@ -84,6 +84,12 @@ const baseInputStyles: IInputStyles = {
|
|
|
84
84
|
paddingRight: 32,
|
|
85
85
|
},
|
|
86
86
|
|
|
87
|
+
input: {
|
|
88
|
+
'&[readonly]': {
|
|
89
|
+
cursor: 'pointer',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
87
93
|
tweakControlWrapper: {
|
|
88
94
|
controls: {
|
|
89
95
|
paddingRight: 40,
|
|
@@ -125,7 +131,7 @@ export const getInputStyles = ({
|
|
|
125
131
|
export type ISelectStyles = ITweakStyles<
|
|
126
132
|
typeof useStyles,
|
|
127
133
|
{
|
|
128
|
-
|
|
134
|
+
tweakWithMessages: IWithMessagesStyles;
|
|
129
135
|
tweakInput: IInputStyles;
|
|
130
136
|
tweakSelectList: ISelectListStyles;
|
|
131
137
|
tweakSearchInput: ISearchInputStyles;
|
|
@@ -18,7 +18,6 @@ import { debounce } from 'ts-debounce';
|
|
|
18
18
|
import {
|
|
19
19
|
createFilter,
|
|
20
20
|
getTestId,
|
|
21
|
-
isEmpty,
|
|
22
21
|
isNotEmpty,
|
|
23
22
|
isReactNodeNotEmpty,
|
|
24
23
|
isStringNotEmpty,
|
|
@@ -26,10 +25,10 @@ import {
|
|
|
26
25
|
import { hasExactParent } from '../../helpers';
|
|
27
26
|
import { useDropdown, useIsMounted, useOnClickOutsideWithRef, useTweakStyles } from '../../hooks';
|
|
28
27
|
import { ICommonProps, IDropdownWithPopperOptions } from '../../types';
|
|
29
|
-
import { ControlGroup } from '../ControlGroup';
|
|
30
28
|
import { IIcon, renderIcon } from '../Icon';
|
|
31
29
|
import { IChangeInputEvent, IInputProps, InputBase } from '../Input';
|
|
32
30
|
import { ISearchInputProps, SearchInput } from '../SearchInput';
|
|
31
|
+
import { WithMessages } from '../WithMessages';
|
|
33
32
|
import { SelectList } from './components';
|
|
34
33
|
import { ALL_OPTION_INDEX, DEFAULT_OPTION_INDEX } from './constants';
|
|
35
34
|
import {
|
|
@@ -142,9 +141,9 @@ export function Select<Value>(
|
|
|
142
141
|
const hasSearchInputInList = optionsMode !== 'normal' && shouldRenderSearchInputInList;
|
|
143
142
|
const hasReadonlyInput = isReadonly || optionsMode === 'normal' || shouldRenderSearchInputInList;
|
|
144
143
|
|
|
145
|
-
const
|
|
144
|
+
const tweakWithMessagesStyles = useTweakStyles({
|
|
146
145
|
tweakStyles,
|
|
147
|
-
className: '
|
|
146
|
+
className: 'tweakWithMessages',
|
|
148
147
|
currentComponentName: 'Select',
|
|
149
148
|
});
|
|
150
149
|
|
|
@@ -241,23 +240,10 @@ export function Select<Value>(
|
|
|
241
240
|
[convertValueToId, convertValueToString],
|
|
242
241
|
);
|
|
243
242
|
|
|
244
|
-
const getDropdownOffset = () => {
|
|
245
|
-
if (isEmpty(input.current)) {
|
|
246
|
-
return 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Высота элемента inputWrapper у компонента Input
|
|
250
|
-
return input.current.parentElement?.offsetHeight ?? 0;
|
|
251
|
-
};
|
|
252
|
-
|
|
253
243
|
const closeList = useCallback(() => {
|
|
254
244
|
setIsListOpen(false);
|
|
255
245
|
setSearchValue('');
|
|
256
246
|
setShouldShowDefaultOption(true);
|
|
257
|
-
|
|
258
|
-
if (!dropdownOptions?.shouldUsePopper) {
|
|
259
|
-
root.current?.style.removeProperty('--dropdown-offset');
|
|
260
|
-
}
|
|
261
247
|
}, [dropdownOptions?.shouldUsePopper]);
|
|
262
248
|
|
|
263
249
|
const handleListClose = useCallback(
|
|
@@ -269,16 +255,8 @@ export function Select<Value>(
|
|
|
269
255
|
);
|
|
270
256
|
|
|
271
257
|
const handleListOpen = () => {
|
|
272
|
-
if (isReadonly) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (!isListOpen) {
|
|
258
|
+
if (!isReadonly && !isListOpen) {
|
|
277
259
|
setIsListOpen(true);
|
|
278
|
-
|
|
279
|
-
if (!dropdownOptions?.shouldUsePopper) {
|
|
280
|
-
root.current?.style.setProperty('--dropdown-offset', `${getDropdownOffset()}px`);
|
|
281
|
-
}
|
|
282
260
|
}
|
|
283
261
|
};
|
|
284
262
|
|
|
@@ -599,10 +577,10 @@ export function Select<Value>(
|
|
|
599
577
|
) : undefined;
|
|
600
578
|
|
|
601
579
|
return (
|
|
602
|
-
<
|
|
580
|
+
<WithMessages
|
|
603
581
|
errorMessage={errorMessage}
|
|
604
582
|
infoMessage={infoMessage}
|
|
605
|
-
tweakStyles={
|
|
583
|
+
tweakStyles={tweakWithMessagesStyles}
|
|
606
584
|
>
|
|
607
585
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
608
586
|
<div
|
|
@@ -645,6 +623,6 @@ export function Select<Value>(
|
|
|
645
623
|
<>{isOpen && listEl}</>
|
|
646
624
|
)}
|
|
647
625
|
</div>
|
|
648
|
-
</
|
|
626
|
+
</WithMessages>
|
|
649
627
|
);
|
|
650
628
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { animations, createThemedStyles, helpers, ITweakStyles } from '../../theme';
|
|
2
|
-
import { IControlGroupStyles } from '../ControlGroup';
|
|
3
2
|
import { IControlWrapperStyles } from '../ControlWrapper';
|
|
3
|
+
import { IWithMessagesStyles } from '../WithMessages';
|
|
4
4
|
|
|
5
5
|
export const useStyles = createThemedStyles('TextArea', {
|
|
6
6
|
textarea: {
|
|
@@ -32,12 +32,16 @@ export const useStyles = createThemedStyles('TextArea', {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
|
|
35
|
+
wrapper: {
|
|
36
|
+
width: '100%',
|
|
37
|
+
},
|
|
38
|
+
|
|
35
39
|
autoSized: {
|
|
36
40
|
display: 'grid',
|
|
37
41
|
gridTemplateRows: 'minmax(0, 100%)',
|
|
38
42
|
|
|
39
43
|
'& > $textarea, &::after': {
|
|
40
|
-
gridArea: '1 /
|
|
44
|
+
gridArea: '1 / 1',
|
|
41
45
|
},
|
|
42
46
|
|
|
43
47
|
'&::after': {
|
|
@@ -72,7 +76,7 @@ export const controlWrapperStyles: IControlWrapperStyles = {
|
|
|
72
76
|
export type ITextAreaStyles = ITweakStyles<
|
|
73
77
|
typeof useStyles,
|
|
74
78
|
{
|
|
75
|
-
|
|
79
|
+
tweakWithMessages: IWithMessagesStyles;
|
|
76
80
|
tweakControlWrapper: IControlWrapperStyles;
|
|
77
81
|
}
|
|
78
82
|
>;
|
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
} from '@true-engineering/true-react-platform-helpers';
|
|
9
9
|
import { useTweakStyles } from '../../hooks';
|
|
10
10
|
import { ICommonProps } from '../../types';
|
|
11
|
-
import { ControlGroup, IControlGroupProps } from '../ControlGroup';
|
|
12
11
|
import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
|
|
12
|
+
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
13
13
|
import { ITextAreaHTMLBaseProps } from './types';
|
|
14
14
|
import { controlWrapperStyles, ITextAreaStyles, useStyles } from './TextArea.styles';
|
|
15
15
|
|
|
16
16
|
export interface ITextAreaProps
|
|
17
17
|
extends ICommonProps<ITextAreaStyles>,
|
|
18
18
|
Pick<IControlWrapperProps, 'label' | 'isInvalid' | 'isRequired' | 'isDisabled'>,
|
|
19
|
-
Pick<
|
|
19
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'>,
|
|
20
20
|
Pick<ITextAreaHTMLBaseProps, 'name' | 'maxLength' | 'rows' | 'onPaste' | 'onFocus' | 'onBlur'> {
|
|
21
21
|
value?: string;
|
|
22
22
|
placeholder?: string;
|
|
@@ -73,9 +73,9 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
73
73
|
) => {
|
|
74
74
|
const classes = useStyles({ theme: tweakStyles });
|
|
75
75
|
|
|
76
|
-
const
|
|
76
|
+
const tweakWithMessagesStyles = useTweakStyles({
|
|
77
77
|
tweakStyles,
|
|
78
|
-
className: '
|
|
78
|
+
className: 'tweakWithMessages',
|
|
79
79
|
currentComponentName: 'TextArea',
|
|
80
80
|
});
|
|
81
81
|
|
|
@@ -92,7 +92,8 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
92
92
|
// в hasValue нельзя использовать isStringNotEmpty из-за того что isStringNotEmpty делает trim
|
|
93
93
|
const hasValue = value !== undefined && value !== '';
|
|
94
94
|
const hasLabel = isReactNodeNotEmpty(label);
|
|
95
|
-
const hasPlaceholder =
|
|
95
|
+
const hasPlaceholder =
|
|
96
|
+
(!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
|
|
96
97
|
|
|
97
98
|
const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
|
|
98
99
|
onChange(event.currentTarget.value, event);
|
|
@@ -109,10 +110,10 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
109
110
|
};
|
|
110
111
|
|
|
111
112
|
return (
|
|
112
|
-
<
|
|
113
|
+
<WithMessages
|
|
113
114
|
errorMessage={errorMessage}
|
|
114
115
|
infoMessage={infoMessage}
|
|
115
|
-
tweakStyles={
|
|
116
|
+
tweakStyles={tweakWithMessagesStyles}
|
|
116
117
|
>
|
|
117
118
|
<ControlWrapper
|
|
118
119
|
label={label}
|
|
@@ -124,7 +125,10 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
124
125
|
testId={testId}
|
|
125
126
|
{...controlProps}
|
|
126
127
|
>
|
|
127
|
-
<div
|
|
128
|
+
<div
|
|
129
|
+
className={clsx(classes.wrapper, { [classes.autoSized]: isAutoSized })}
|
|
130
|
+
{...(isAutoSized && { 'data-value': value })}
|
|
131
|
+
>
|
|
128
132
|
<textarea
|
|
129
133
|
ref={ref}
|
|
130
134
|
className={classes.textarea}
|
|
@@ -151,7 +155,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
151
155
|
{value.length} / {maxLength}
|
|
152
156
|
</span>
|
|
153
157
|
)}
|
|
154
|
-
</
|
|
158
|
+
</WithMessages>
|
|
155
159
|
);
|
|
156
160
|
},
|
|
157
161
|
);
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { doNothing } from '@true-engineering/true-react-platform-helpers';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
3
|
import { IInputProps, Input } from '../Input';
|
|
4
|
-
import {
|
|
4
|
+
import { WithMessages } from './WithMessages';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
title: '
|
|
8
|
-
component:
|
|
7
|
+
title: 'WithMessages',
|
|
8
|
+
component: WithMessages,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const Template: ComponentStory<typeof
|
|
11
|
+
const Template: ComponentStory<typeof WithMessages> = ({ controlsDirection, ...args }) => {
|
|
12
12
|
let groupPlacement: Array<IInputProps['groupPlacement']> = [];
|
|
13
|
-
if (
|
|
13
|
+
if (controlsDirection === 'horizontal') {
|
|
14
14
|
groupPlacement = ['left', 'right'];
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
16
|
+
if (controlsDirection === 'vertical') {
|
|
17
17
|
groupPlacement = ['top', 'bottom'];
|
|
18
18
|
}
|
|
19
19
|
return (
|
|
20
|
-
<
|
|
20
|
+
<WithMessages {...args} controlsDirection={controlsDirection}>
|
|
21
21
|
<Input value="value" groupPlacement={groupPlacement[0]} onChange={doNothing} />
|
|
22
22
|
<Input value="value" groupPlacement={groupPlacement[1]} onChange={doNothing} />
|
|
23
|
-
</
|
|
23
|
+
</WithMessages>
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -29,11 +29,11 @@ export const Default = Template.bind({});
|
|
|
29
29
|
Default.args = {
|
|
30
30
|
infoMessage: 'Message Info',
|
|
31
31
|
errorMessage: 'Error Text',
|
|
32
|
-
|
|
32
|
+
controlsDirection: undefined,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
Default.argTypes = {
|
|
36
|
-
|
|
36
|
+
controlsDirection: {
|
|
37
37
|
options: [undefined, 'horizontal', 'vertical'],
|
|
38
38
|
control: 'radio',
|
|
39
39
|
},
|