@true-engineering/true-react-common-ui-kit 4.0.0-alpha10 → 4.0.0-alpha11
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/Button/Button.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/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/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Input/InputBase.d.ts +2 -2
- 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/Select/Select.styles.d.ts +2 -2
- package/dist/components/Status/Status.styles.d.ts +3 -2
- package/dist/components/Status/constants.d.ts +0 -1
- package/dist/components/Status/types.d.ts +5 -2
- package/dist/components/TextArea/TextArea.d.ts +2 -3
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +116 -151
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +115 -150
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +8 -2
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +2 -1
- package/src/components/ControlWrapper/ControlWrapper.tsx +8 -2
- package/src/components/ControlWrapper/index.ts +1 -0
- package/src/components/ControlWrapper/types.ts +3 -0
- package/src/components/Input/Input.tsx +3 -2
- package/src/components/Input/InputBase.tsx +21 -18
- 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/types.ts +7 -3
- package/src/components/TextArea/TextArea.tsx +26 -12
- package/src/components/TextArea/index.ts +0 -1
- package/src/types.ts +15 -3
- 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 -7
- 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
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FocusEventHandler,
|
|
2
|
-
import { Modifier, Placement } from 'react-overlays/usePopper';
|
|
1
|
+
import type { FocusEventHandler, KeyboardEvent, KeyboardEventHandler, MouseEvent, MouseEventHandler, PointerEventHandler, ReactNode } from 'react';
|
|
2
|
+
import type { Modifier, Placement } from 'react-overlays/usePopper';
|
|
3
|
+
import type { JssStyle } from 'jss';
|
|
3
4
|
import type { IMaybeArray } from './theme';
|
|
4
5
|
export interface ITestIdProps {
|
|
5
6
|
testId?: string;
|
|
@@ -44,3 +45,8 @@ export interface IDomElementInteractions<T> {
|
|
|
44
45
|
onPointerUp?: PointerEventHandler<T>;
|
|
45
46
|
}
|
|
46
47
|
export type IRenderNode<T> = ReactNode | ((props: T) => ReactNode);
|
|
48
|
+
export type IExtendableProps<T extends string | readonly string[]> = Record<T extends ReadonlyArray<infer P> ? P : T, JssStyle>;
|
|
49
|
+
export type IDefaultExtendableProps = IExtendableProps<'custom'>;
|
|
50
|
+
export type IWithPrefix<T, P extends string> = {
|
|
51
|
+
[K in keyof T as `${P}${K & string}`]: T[K];
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { animations, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
2
|
import { IThemedPreloaderStyles } from '../ThemedPreloader';
|
|
3
|
+
import { IControlWrapperSizes } from './types';
|
|
3
4
|
|
|
4
5
|
const { CONTROL, Z_INDEX } = dimensions;
|
|
5
6
|
|
|
@@ -181,5 +182,5 @@ export const useStyles = createThemedStyles('ControlWrapper', {
|
|
|
181
182
|
|
|
182
183
|
export type IControlWrapperStyles = ITweakStyles<
|
|
183
184
|
typeof useStyles,
|
|
184
|
-
{ tweakPreloader: IThemedPreloaderStyles }
|
|
185
|
+
{ tweakPreloader: IThemedPreloaderStyles } & IControlWrapperSizes
|
|
185
186
|
>;
|
|
@@ -12,12 +12,14 @@ import { useTweakStyles } from '../../hooks';
|
|
|
12
12
|
import { IClickHandlerEvent, ICommonProps } from '../../types';
|
|
13
13
|
import { Icon, IIcon, renderIcon } from '../Icon';
|
|
14
14
|
import { ThemedPreloader } from '../ThemedPreloader';
|
|
15
|
+
import { IControlWrapperSize } from './types';
|
|
15
16
|
import { IControlWrapperStyles, useStyles } from './ControlWrapper.styles';
|
|
16
17
|
|
|
17
18
|
export interface IControlWrapperProps extends ICommonProps<IControlWrapperStyles> {
|
|
18
19
|
children: ReactNode;
|
|
19
20
|
label?: ReactNode;
|
|
20
21
|
icon?: IIcon;
|
|
22
|
+
size?: IControlWrapperSize;
|
|
21
23
|
groupPlacement?:
|
|
22
24
|
| 'left'
|
|
23
25
|
| 'right'
|
|
@@ -57,6 +59,7 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
57
59
|
isFullWidth,
|
|
58
60
|
isDisabled,
|
|
59
61
|
hasValue,
|
|
62
|
+
size,
|
|
60
63
|
testId,
|
|
61
64
|
children,
|
|
62
65
|
tweakStyles,
|
|
@@ -70,6 +73,8 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
70
73
|
const hasClearButton = !isDisabled && !isLoading && hasValue && isNotEmpty(onClear);
|
|
71
74
|
const hasControls = hasEndIcon || hasClearButton || isLoading;
|
|
72
75
|
|
|
76
|
+
const isActive = isFocused || hasValue;
|
|
77
|
+
|
|
73
78
|
const tweakPreloaderStyles = useTweakStyles({
|
|
74
79
|
tweakStyles,
|
|
75
80
|
className: 'tweakPreloader',
|
|
@@ -80,7 +85,8 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
80
85
|
<div
|
|
81
86
|
className={clsx(
|
|
82
87
|
classes.controlWrapper,
|
|
83
|
-
isNotEmpty(groupPlacement) &&
|
|
88
|
+
isNotEmpty(groupPlacement) && classes[`placement-${groupPlacement}`],
|
|
89
|
+
isNotEmpty(size) && classes[size],
|
|
84
90
|
{
|
|
85
91
|
[classes.invalid]: isInvalid,
|
|
86
92
|
[classes.focused]: isFocused,
|
|
@@ -97,7 +103,7 @@ export const ControlWrapper: FC<IControlWrapperProps> = ({
|
|
|
97
103
|
className={clsx(classes.label, {
|
|
98
104
|
[classes.requiredLabel]: isRequired,
|
|
99
105
|
[classes.disabledLabel]: isDisabled,
|
|
100
|
-
[classes.activeLabel]:
|
|
106
|
+
[classes.activeLabel]: isActive,
|
|
101
107
|
})}
|
|
102
108
|
>
|
|
103
109
|
{label}
|
|
@@ -4,8 +4,9 @@ import { useTweakStyles } from '../../hooks';
|
|
|
4
4
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
5
5
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export interface IInputProps
|
|
8
|
+
extends IInputBaseProps,
|
|
9
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {}
|
|
9
10
|
|
|
10
11
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
11
12
|
({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
|
|
@@ -28,6 +28,7 @@ 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'
|
|
@@ -38,20 +39,7 @@ export interface IInputBaseProps
|
|
|
38
39
|
| 'isLoading'
|
|
39
40
|
| 'isDisabled'
|
|
40
41
|
| 'onIconClick'
|
|
41
|
-
|
|
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'
|
|
42
|
+
| 'size'
|
|
55
43
|
>,
|
|
56
44
|
Pick<
|
|
57
45
|
Partial<ReactInputMaskBaseProps>,
|
|
@@ -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,16 @@ 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
|
+
...inputProps
|
|
111
107
|
},
|
|
112
108
|
ref,
|
|
113
109
|
) => {
|
|
@@ -195,6 +191,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
195
191
|
onBlur: handleBlur,
|
|
196
192
|
onChange: handleChange,
|
|
197
193
|
...addDataTestId(testId),
|
|
194
|
+
...inputProps,
|
|
198
195
|
};
|
|
199
196
|
|
|
200
197
|
useEffect(() => {
|
|
@@ -238,7 +235,13 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
238
235
|
isFullWidth={!isAutoSized}
|
|
239
236
|
tweakStyles={tweakControlWrapperStyles}
|
|
240
237
|
onClear={isClearable && hasValue ? handleInputClear : undefined}
|
|
241
|
-
{
|
|
238
|
+
data={data}
|
|
239
|
+
groupPlacement={groupPlacement}
|
|
240
|
+
icon={icon}
|
|
241
|
+
isLoading={isLoading}
|
|
242
|
+
isRequired={isRequired}
|
|
243
|
+
onIconClick={onIconClick}
|
|
244
|
+
size={size}
|
|
242
245
|
>
|
|
243
246
|
{hasUnits || isAutoSized ? (
|
|
244
247
|
<div className={classes.autoSizeWrapper}>{inputContent}</div>
|
|
@@ -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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rgba } from '../../helpers';
|
|
2
1
|
import { colors, createThemedStyles, ITweakStyles } from '../../theme';
|
|
2
|
+
import { IStatusColors } from './types';
|
|
3
3
|
|
|
4
4
|
export const useStyles = createThemedStyles('Status', {
|
|
5
5
|
root: {
|
|
@@ -102,42 +102,7 @@ export const useStyles = createThemedStyles('Status', {
|
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
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
105
|
custom: {},
|
|
141
106
|
});
|
|
142
107
|
|
|
143
|
-
export type IStatusStyles = ITweakStyles<typeof useStyles>;
|
|
108
|
+
export type IStatusStyles = ITweakStyles<typeof useStyles, IStatusColors>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export type IStatusColor = (typeof STATUS_COLORS)[number];
|
|
1
|
+
import { IDefaultExtendableProps } from '../../types';
|
|
2
|
+
import type { STATUS_SIZES } from './constants';
|
|
4
3
|
|
|
5
4
|
export type IStatusSize = (typeof STATUS_SIZES)[number];
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
7
|
+
export interface IStatusColors extends IDefaultExtendableProps {}
|
|
8
|
+
|
|
9
|
+
export type IStatusColor = keyof IStatusColors;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
FocusEvent,
|
|
4
|
+
FormEvent,
|
|
5
|
+
forwardRef,
|
|
6
|
+
TextareaHTMLAttributes,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import clsx from 'clsx';
|
|
3
10
|
import {
|
|
4
11
|
addDataAttributes,
|
|
5
12
|
getTestId,
|
|
13
|
+
isArrayLikeNotEmpty,
|
|
6
14
|
isNotEmpty,
|
|
7
15
|
isReactNodeNotEmpty,
|
|
8
16
|
isStringNotEmpty,
|
|
@@ -11,14 +19,13 @@ import { useTweakStyles } from '../../hooks';
|
|
|
11
19
|
import { ICommonProps } from '../../types';
|
|
12
20
|
import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
|
|
13
21
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
14
|
-
import { ITextAreaHTMLBaseProps } from './types';
|
|
15
22
|
import { controlWrapperStyles, ITextAreaStyles, useStyles } from './TextArea.styles';
|
|
16
23
|
|
|
17
24
|
export interface ITextAreaProps
|
|
18
25
|
extends ICommonProps<ITextAreaStyles>,
|
|
19
|
-
|
|
20
|
-
Pick<
|
|
21
|
-
Pick<
|
|
26
|
+
Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'>,
|
|
27
|
+
Pick<IControlWrapperProps, 'label' | 'isInvalid' | 'isRequired' | 'isDisabled' | 'size'>,
|
|
28
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {
|
|
22
29
|
value?: string;
|
|
23
30
|
placeholder?: string;
|
|
24
31
|
/** @default false */
|
|
@@ -49,8 +56,6 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
49
56
|
value = DEFAULT_VALUE,
|
|
50
57
|
label,
|
|
51
58
|
placeholder,
|
|
52
|
-
infoMessage,
|
|
53
|
-
errorMessage,
|
|
54
59
|
name,
|
|
55
60
|
shouldFocusOnMount,
|
|
56
61
|
hasCounter = true,
|
|
@@ -68,7 +73,14 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
68
73
|
onPaste,
|
|
69
74
|
onFocus,
|
|
70
75
|
onBlur,
|
|
71
|
-
|
|
76
|
+
// Пропсы WithMessages
|
|
77
|
+
infoMessage,
|
|
78
|
+
errorMessage,
|
|
79
|
+
// Пропсы ControlWrapper
|
|
80
|
+
isInvalid,
|
|
81
|
+
isRequired,
|
|
82
|
+
size,
|
|
83
|
+
...textAreaProps
|
|
72
84
|
},
|
|
73
85
|
ref,
|
|
74
86
|
) => {
|
|
@@ -90,8 +102,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
90
102
|
const [isFocused, setFocused] = useState(false);
|
|
91
103
|
|
|
92
104
|
const hasFocus = isFocused || isActive;
|
|
93
|
-
|
|
94
|
-
const hasValue = value !== undefined && value !== '';
|
|
105
|
+
const hasValue = isArrayLikeNotEmpty(value);
|
|
95
106
|
const hasLabel = isReactNodeNotEmpty(label);
|
|
96
107
|
const hasPlaceholder =
|
|
97
108
|
(!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
|
|
@@ -123,12 +134,14 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
123
134
|
isFocused={hasFocus}
|
|
124
135
|
isDisabled={isDisabled}
|
|
125
136
|
hasValue={hasValue}
|
|
137
|
+
isInvalid={isInvalid}
|
|
138
|
+
isRequired={isRequired}
|
|
139
|
+
size={size}
|
|
126
140
|
isFullWidth
|
|
127
|
-
{...controlProps}
|
|
128
141
|
>
|
|
129
142
|
<div
|
|
130
143
|
className={clsx(classes.wrapper, { [classes.autoSized]: isAutoSized })}
|
|
131
|
-
{...(isAutoSized && {
|
|
144
|
+
{...(isAutoSized && addDataAttributes({ value }))}
|
|
132
145
|
>
|
|
133
146
|
<textarea
|
|
134
147
|
ref={ref}
|
|
@@ -144,6 +157,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
144
157
|
onBlur={handleBlur}
|
|
145
158
|
onChange={handleChange}
|
|
146
159
|
{...addDataAttributes(data, testId)}
|
|
160
|
+
{...textAreaProps}
|
|
147
161
|
/>
|
|
148
162
|
</div>
|
|
149
163
|
</ControlWrapper>
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
FocusEventHandler,
|
|
3
|
-
|
|
3
|
+
KeyboardEvent,
|
|
4
4
|
KeyboardEventHandler,
|
|
5
5
|
MouseEvent,
|
|
6
6
|
MouseEventHandler,
|
|
7
7
|
PointerEventHandler,
|
|
8
8
|
ReactNode,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import { Modifier, Placement } from 'react-overlays/usePopper';
|
|
10
|
+
import type { Modifier, Placement } from 'react-overlays/usePopper';
|
|
11
|
+
import type { JssStyle } from 'jss';
|
|
11
12
|
import type { IMaybeArray } from './theme';
|
|
12
13
|
|
|
13
14
|
export interface ITestIdProps {
|
|
@@ -64,3 +65,14 @@ export interface IDomElementInteractions<T> {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
export type IRenderNode<T> = ReactNode | ((props: T) => ReactNode);
|
|
68
|
+
|
|
69
|
+
export type IExtendableProps<T extends string | readonly string[]> = Record<
|
|
70
|
+
T extends ReadonlyArray<infer P> ? P : T,
|
|
71
|
+
JssStyle
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
export type IDefaultExtendableProps = IExtendableProps<'custom'>;
|
|
75
|
+
|
|
76
|
+
export type IWithPrefix<T, P extends string> = {
|
|
77
|
+
[K in keyof T as `${P}${K & string}`]: T[K];
|
|
78
|
+
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("./AccountInfo").IAccountInfoProps>;
|
|
4
|
-
};
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./AccountInfo").IAccountInfoProps>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("./AddButton").IAddButtonProps>;
|
|
4
|
-
};
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./AddButton").IAddButtonProps>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Button, IButtonProps } from './Button';
|
|
4
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, IButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Default: ComponentStory<typeof Button>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { Checkbox as CheckboxComponent, ICheckboxProps } from './Checkbox';
|
|
4
|
-
declare const CheckboxComponentWithData: FC<ICheckboxProps<string>>;
|
|
5
|
-
declare const meta: Meta<typeof CheckboxComponentWithData>;
|
|
6
|
-
export default meta;
|
|
7
|
-
type Story = StoryObj<typeof CheckboxComponent>;
|
|
8
|
-
export declare const Default: Story;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ComponentStory } from '@storybook/react';
|
|
2
|
-
import { CloseButton } from './CloseButton';
|
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, import("./CloseButton").ICloseButtonProps>;
|
|
4
|
-
export default _default;
|
|
5
|
-
export declare const Default: ComponentStory<typeof CloseButton>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("./ControlWrapper").IControlWrapperProps>;
|
|
4
|
-
};
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./ControlWrapper").IControlWrapperProps>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").ForwardRefExoticComponent<import("./DateInput").IDateInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./DateInput").IDateInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").ForwardRefExoticComponent<import("./DatePicker").IDatePickerProps & import("react").RefAttributes<import("react-datepicker").ReactDatePicker<never, undefined>>>;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./DatePicker").IDatePickerProps & import("react").RefAttributes<import("react-datepicker").ReactDatePicker<never, undefined>>>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("./Description").IDescriptionProps>;
|
|
4
|
-
argTypes: {
|
|
5
|
-
truncateIndex: {
|
|
6
|
-
control: {
|
|
7
|
-
type: string;
|
|
8
|
-
min: number;
|
|
9
|
-
max: number;
|
|
10
|
-
step: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
16
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./Description").IDescriptionProps>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").ForwardRefExoticComponent<import("./FileInput").IFileInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./FileInput").IFileInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ComponentStory } from '@storybook/react';
|
|
2
|
-
import { FileItem, IFileItemProps } from './FileItem';
|
|
3
|
-
declare const _default: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: import("react").FC<IFileItemProps>;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export declare const Default: ComponentStory<typeof FileItem>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { IFiltersPaneProps } from './FiltersPane';
|
|
2
|
-
interface IFiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content> extends IFiltersPaneProps<Values, Content> {
|
|
3
|
-
containerWidth: number;
|
|
4
|
-
isSearchDisabled: boolean;
|
|
5
|
-
shouldShowSettingsButton: boolean;
|
|
6
|
-
withFieldNameInLabel: boolean;
|
|
7
|
-
isGroupingEnabled: boolean;
|
|
8
|
-
checkboxPosition: 'left' | 'right';
|
|
9
|
-
isClearableFields: boolean;
|
|
10
|
-
}
|
|
11
|
-
declare function FiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content>({ containerWidth, isSearchDisabled, shouldShowSettingsButton, withFieldNameInLabel, isGroupingEnabled, checkboxPosition, isClearableFields, ...args }: IFiltersPaneWithCustomProps<Values, Content>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
declare const _default: {
|
|
13
|
-
title: string;
|
|
14
|
-
component: typeof FiltersPaneWithCustomProps;
|
|
15
|
-
argTypes: {
|
|
16
|
-
containerWidth: {
|
|
17
|
-
control: {
|
|
18
|
-
type: string;
|
|
19
|
-
min: number;
|
|
20
|
-
max: number;
|
|
21
|
-
step: number;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
checkboxPosition: {
|
|
25
|
-
control: string;
|
|
26
|
-
options: string[];
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export default _default;
|
|
31
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, IFiltersPaneWithCustomProps<Record<string, unknown>, unknown>>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("./Flag").IFlagProps>;
|
|
4
|
-
argTypes: {
|
|
5
|
-
countryCode: {
|
|
6
|
-
control: string;
|
|
7
|
-
options: string[];
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
12
|
-
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("./Flag").IFlagProps>;
|