@true-engineering/true-react-common-ui-kit 3.1.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/components/AccountInfo/AccountInfo.d.ts +1 -0
- package/dist/components/AddButton/AddButton.d.ts +4 -1
- package/dist/components/Button/Button.d.ts +11 -29
- package/dist/components/Checkbox/Checkbox.d.ts +7 -5
- package/dist/components/CloseButton/CloseButton.d.ts +2 -1
- package/dist/components/DateInput/DateInput.d.ts +5 -2
- package/dist/components/DatePicker/DatePicker.d.ts +7 -5
- package/dist/components/Description/Description.d.ts +2 -0
- package/dist/components/FiltersPane/FiltersPane.d.ts +6 -3
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.d.ts +3 -3
- package/dist/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +1 -1
- package/dist/components/Flag/Flag.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +7 -4
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +1 -1
- package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -4
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
- package/dist/components/IncrementInput/IncrementInput.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +17 -23
- package/dist/components/Input/Input.stories.d.ts +1 -1
- package/dist/components/Input/types.d.ts +2 -0
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/components/ListItem/ListItem.d.ts +1 -1
- package/dist/components/Modal/Modal.d.ts +11 -1
- package/dist/components/MoreMenu/MoreMenu.d.ts +4 -5
- package/dist/components/MultiSelect/MultiSelect.d.ts +7 -2
- package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.d.ts +1 -1
- package/dist/components/MultiSelectList/MultiSelectList.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +2 -6
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/NumberInput/NumberInput.d.ts +5 -1
- package/dist/components/PhoneInput/PhoneInput.d.ts +5 -1
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.d.ts +2 -2
- package/dist/components/RadioButton/RadioButton.d.ts +3 -1
- package/dist/components/Select/Select.d.ts +17 -12
- package/dist/components/Select/components/SelectList/SelectList.d.ts +6 -6
- package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -2
- package/dist/components/SmartInput/SmartInput.d.ts +2 -0
- package/dist/components/SmartInput/SmartInput.stories.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +6 -7
- package/dist/components/TextArea/TextArea.d.ts +13 -4
- package/dist/components/TextButton/TextButton.d.ts +1 -1
- package/dist/components/TextWithInfo/TextWithInfo.d.ts +2 -1
- package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +7 -0
- package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +2 -3
- package/dist/components/Toaster/Toaster.d.ts +5 -11
- package/dist/components/Tooltip/Tooltip.d.ts +2 -6
- package/dist/hooks/use-dropdown.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +138 -45
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +138 -45
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountInfo/AccountInfo.tsx +1 -0
- package/src/components/AddButton/AddButton.tsx +6 -3
- package/src/components/Button/Button.tsx +11 -29
- package/src/components/Checkbox/Checkbox.tsx +12 -10
- package/src/components/CloseButton/CloseButton.tsx +2 -1
- package/src/components/DateInput/DateInput.tsx +6 -3
- package/src/components/DatePicker/DatePicker.tsx +10 -8
- package/src/components/Description/Description.tsx +2 -0
- package/src/components/FiltersPane/FiltersPane.tsx +6 -3
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -3
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +2 -2
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +1 -1
- package/src/components/Flag/Flag.tsx +1 -0
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +14 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +53 -33
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -3
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +2 -0
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +17 -8
- package/src/components/IncrementInput/IncrementInput.tsx +1 -0
- package/src/components/Input/Input.tsx +28 -41
- package/src/components/Input/types.ts +26 -0
- package/src/components/List/List.tsx +1 -1
- package/src/components/List/components/ListItem/ListItem.tsx +1 -1
- package/src/components/Modal/Modal.tsx +12 -2
- package/src/components/MoreMenu/MoreMenu.tsx +5 -6
- package/src/components/MultiSelect/MultiSelect.tsx +9 -4
- package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +1 -1
- package/src/components/MultiSelectList/MultiSelectList.tsx +3 -0
- package/src/components/Notification/Notification.tsx +2 -6
- package/src/components/NumberInput/NumberInput.tsx +5 -1
- package/src/components/PhoneInput/PhoneInput.tsx +6 -2
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +2 -2
- package/src/components/RadioButton/RadioButton.tsx +5 -3
- package/src/components/Select/Select.tsx +18 -13
- package/src/components/Select/components/SelectList/SelectList.tsx +6 -6
- package/src/components/Select/components/SelectListItem/SelectListItem.tsx +2 -2
- package/src/components/SmartInput/SmartInput.tsx +11 -1
- package/src/components/Switch/Switch.tsx +8 -9
- package/src/components/TextArea/TextArea.tsx +16 -7
- package/src/components/TextButton/TextButton.tsx +1 -1
- package/src/components/TextWithInfo/TextWithInfo.tsx +2 -1
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +8 -1
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +2 -3
- package/src/components/Toaster/Toaster.tsx +5 -11
- package/src/components/Tooltip/Tooltip.tsx +2 -6
- package/src/hooks/use-dropdown.ts +1 -1
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
FormEvent,
|
|
7
7
|
FocusEvent,
|
|
8
8
|
MouseEvent,
|
|
9
|
-
KeyboardEvent,
|
|
10
|
-
ClipboardEvent,
|
|
11
9
|
InputHTMLAttributes,
|
|
12
10
|
ReactNode,
|
|
13
11
|
} from 'react';
|
|
@@ -24,31 +22,30 @@ import { ICommonProps } from '../../types';
|
|
|
24
22
|
import { renderIcon, Icon, IIcon } from '../Icon';
|
|
25
23
|
import { ThemedPreloader } from '../ThemedPreloader';
|
|
26
24
|
import { DEFAULT_SIZE } from './constants';
|
|
27
|
-
import { IReactInputMaskProps } from './types';
|
|
25
|
+
import { IInputHTMLBaseProps, IReactInputMaskProps } from './types';
|
|
28
26
|
import { useStyles, IInputStyles } from './Input.styles';
|
|
29
27
|
|
|
30
|
-
export interface IInputProps
|
|
28
|
+
export interface IInputProps
|
|
29
|
+
extends ICommonProps<IInputStyles>,
|
|
30
|
+
IReactInputMaskProps,
|
|
31
|
+
IInputHTMLBaseProps {
|
|
31
32
|
value?: string;
|
|
32
33
|
label?: ReactNode;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @default `text`
|
|
36
|
-
*/
|
|
37
|
-
type?: 'text' | 'password' | 'email' | 'number';
|
|
34
|
+
/** @default false */
|
|
38
35
|
isDisabled?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* @default true
|
|
41
|
-
*/
|
|
36
|
+
/** @default true */
|
|
42
37
|
hasFloatingLabel?: boolean;
|
|
38
|
+
/** @default false */
|
|
43
39
|
isReadonly?: boolean;
|
|
40
|
+
/** @default false */
|
|
44
41
|
isInvalid?: boolean;
|
|
42
|
+
/** @default false */
|
|
45
43
|
isActive?: boolean;
|
|
44
|
+
/** @default false */
|
|
46
45
|
isClearable?: boolean;
|
|
47
46
|
infoMessage?: string;
|
|
48
47
|
errorMessage?: string;
|
|
49
|
-
/**
|
|
50
|
-
* @default `bottom`
|
|
51
|
-
*/
|
|
48
|
+
/** @default 'bottom' */
|
|
52
49
|
errorPosition?: 'top' | 'bottom';
|
|
53
50
|
inlineStyle?:
|
|
54
51
|
| 'top'
|
|
@@ -61,7 +58,9 @@ export interface IInputProps extends ICommonProps<IInputStyles>, IReactInputMask
|
|
|
61
58
|
| 'right'
|
|
62
59
|
| 'middle';
|
|
63
60
|
border?: 'top' | 'bottom' | 'left' | 'right';
|
|
61
|
+
/** @default false */
|
|
64
62
|
isRequired?: boolean;
|
|
63
|
+
/** @default false */
|
|
65
64
|
isLoading?: boolean;
|
|
66
65
|
/**
|
|
67
66
|
* Должна ли ширина input'а подстраиваться под ширину контента
|
|
@@ -75,18 +74,14 @@ export interface IInputProps extends ICommonProps<IInputStyles>, IReactInputMask
|
|
|
75
74
|
defaultSize?: number;
|
|
76
75
|
iconType?: IIcon;
|
|
77
76
|
units?: string;
|
|
78
|
-
|
|
77
|
+
/** @default false */
|
|
79
78
|
hasRequiredLabel?: boolean;
|
|
79
|
+
/** @default false */
|
|
80
80
|
shouldFocusOnMount?: boolean;
|
|
81
|
-
|
|
82
|
-
tabIndex?: number;
|
|
81
|
+
/** @default false */
|
|
83
82
|
shouldAlwaysShowPlaceholder?: boolean;
|
|
84
|
-
onChange(value: string, event: FormEvent<HTMLInputElement>)
|
|
85
|
-
|
|
86
|
-
onBlur?(event: FocusEvent<HTMLInputElement>): void;
|
|
87
|
-
onPaste?(event: ClipboardEvent<HTMLInputElement>): void;
|
|
88
|
-
onIconClick?(): void;
|
|
89
|
-
onKeyDown?(event: KeyboardEvent<HTMLInputElement>): void;
|
|
83
|
+
onChange: (value: string, event: FormEvent<HTMLInputElement>) => void;
|
|
84
|
+
onIconClick?: () => void;
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
@@ -97,7 +92,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
97
92
|
placeholder,
|
|
98
93
|
type = 'text',
|
|
99
94
|
isDisabled,
|
|
100
|
-
isReadonly,
|
|
95
|
+
isReadonly = false,
|
|
101
96
|
hasFloatingLabel = true,
|
|
102
97
|
isInvalid = false,
|
|
103
98
|
isActive = false,
|
|
@@ -107,32 +102,28 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
107
102
|
errorPosition = 'bottom',
|
|
108
103
|
inlineStyle,
|
|
109
104
|
border,
|
|
110
|
-
isRequired,
|
|
111
|
-
isLoading,
|
|
112
|
-
isAutoSizeable,
|
|
105
|
+
isRequired = false,
|
|
106
|
+
isLoading = false,
|
|
107
|
+
isAutoSizeable = false,
|
|
113
108
|
defaultSize = DEFAULT_SIZE,
|
|
114
109
|
iconType,
|
|
115
|
-
name,
|
|
116
110
|
hasRequiredLabel,
|
|
117
111
|
data,
|
|
118
112
|
tweakStyles,
|
|
119
|
-
|
|
120
|
-
shouldFocusOnMount,
|
|
113
|
+
shouldFocusOnMount = false,
|
|
121
114
|
units,
|
|
122
115
|
testId,
|
|
123
|
-
tabIndex,
|
|
124
116
|
onChange,
|
|
125
|
-
onPaste,
|
|
126
117
|
onFocus,
|
|
127
118
|
onBlur,
|
|
128
119
|
onIconClick,
|
|
129
|
-
onKeyDown,
|
|
130
120
|
// Пропсы react-input-mask
|
|
131
121
|
mask,
|
|
132
122
|
maskPlaceholder,
|
|
133
123
|
alwaysShowMask,
|
|
134
|
-
shouldAlwaysShowPlaceholder,
|
|
124
|
+
shouldAlwaysShowPlaceholder = false,
|
|
135
125
|
beforeMaskedStateChange,
|
|
126
|
+
...inputProps
|
|
136
127
|
},
|
|
137
128
|
ref,
|
|
138
129
|
) => {
|
|
@@ -181,6 +172,8 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
181
172
|
const shouldShowUnits = (hasValue || (isFocused && !hasPlaceholder)) && hasUnits;
|
|
182
173
|
|
|
183
174
|
const props: InputHTMLAttributes<HTMLInputElement> = {
|
|
175
|
+
...inputProps,
|
|
176
|
+
...addDataTestId(testId),
|
|
184
177
|
className: clsx(classes.input, {
|
|
185
178
|
[classes.withFloatingLabel]: hasFloatingLabel && hasLabel,
|
|
186
179
|
[classes.withIcons]: hasControls,
|
|
@@ -191,19 +184,13 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
191
184
|
onFocus: handleFocus,
|
|
192
185
|
onBlur: handleBlur,
|
|
193
186
|
onChange: handleChange,
|
|
194
|
-
onKeyDown,
|
|
195
|
-
onPaste,
|
|
196
187
|
value,
|
|
197
188
|
type,
|
|
198
189
|
disabled: isDisabled,
|
|
199
190
|
placeholder: hasPlaceholder ? placeholder : undefined,
|
|
200
|
-
name,
|
|
201
|
-
maxLength,
|
|
202
191
|
autoFocus: shouldFocusOnMount,
|
|
203
192
|
readOnly: isReadonly,
|
|
204
193
|
size: isAutoSizeable ? defaultSize : undefined,
|
|
205
|
-
tabIndex,
|
|
206
|
-
...addDataTestId(testId),
|
|
207
194
|
};
|
|
208
195
|
|
|
209
196
|
return (
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
1
2
|
import { Props as ReactInputMaskBaseProps } from 'react-input-mask';
|
|
2
3
|
|
|
3
4
|
export type IReactInputMaskProps = Pick<
|
|
4
5
|
Partial<ReactInputMaskBaseProps>,
|
|
5
6
|
'mask' | 'maskPlaceholder' | 'alwaysShowMask' | 'beforeMaskedStateChange'
|
|
6
7
|
>;
|
|
8
|
+
|
|
9
|
+
export type IInputHTMLBaseProps = Pick<
|
|
10
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
11
|
+
| 'maxLength'
|
|
12
|
+
| 'name'
|
|
13
|
+
| 'tabIndex'
|
|
14
|
+
| 'placeholder'
|
|
15
|
+
| 'type'
|
|
16
|
+
| 'onBlur'
|
|
17
|
+
| 'onFocus'
|
|
18
|
+
| 'onInput'
|
|
19
|
+
| 'onKeyDown'
|
|
20
|
+
| 'onPaste'
|
|
21
|
+
>;
|
|
22
|
+
// Возможно это лучше заменить на
|
|
23
|
+
// Omit< InputHTMLAttributes<HTMLInputElement>,
|
|
24
|
+
// | 'className'
|
|
25
|
+
// | 'value'
|
|
26
|
+
// | 'onChange'
|
|
27
|
+
// | 'disabled'
|
|
28
|
+
// | 'required'
|
|
29
|
+
// | 'autoFocus'
|
|
30
|
+
// | 'readOnly'
|
|
31
|
+
// | 'size'
|
|
32
|
+
// >
|
|
@@ -7,7 +7,7 @@ import { useStyles, IListStyles } from './List.styles';
|
|
|
7
7
|
|
|
8
8
|
export interface IListProps extends ICommonProps<IListStyles> {
|
|
9
9
|
items: IListItem[];
|
|
10
|
-
onClick
|
|
10
|
+
onClick?: (event: MouseEvent | KeyboardEvent) => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick }) => {
|
|
@@ -18,7 +18,7 @@ export interface IListItemProps extends ICommonProps<IListItemStyles> {
|
|
|
18
18
|
shouldDrawSpacerAbove?: boolean;
|
|
19
19
|
shouldDrawSpacerBelow?: boolean;
|
|
20
20
|
withIconGap?: boolean;
|
|
21
|
-
onClick(event: MouseEvent | KeyboardEvent)
|
|
21
|
+
onClick: (event: MouseEvent | KeyboardEvent) => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const ListItem: FC<IListItemProps> = ({
|
|
@@ -16,20 +16,30 @@ import { useStyles, IModalStyles } from './Modal.styles';
|
|
|
16
16
|
|
|
17
17
|
export interface IModalProps extends ICommonProps<IModalStyles>, IModalTransitionProps {
|
|
18
18
|
title?: ReactNode;
|
|
19
|
+
/** @default 'l */
|
|
19
20
|
size?: 'l' | 'm' | 's';
|
|
21
|
+
/** @default false */
|
|
20
22
|
isFooterSticky?: boolean;
|
|
21
23
|
buttons?: ReactNode[];
|
|
24
|
+
/** @default 'right' */
|
|
22
25
|
buttonsAlign?: 'left' | 'center' | 'right';
|
|
23
26
|
children?: ReactNode | ReactNode[];
|
|
27
|
+
/** @default 'center' */
|
|
24
28
|
position?: IModalPosition;
|
|
29
|
+
/** @default true */
|
|
25
30
|
hasCloseButton?: boolean;
|
|
31
|
+
/** @default true */
|
|
26
32
|
hasOverlay?: boolean;
|
|
33
|
+
/** @default true */
|
|
27
34
|
shouldCloseOnOverlayClick?: boolean;
|
|
35
|
+
/** @default true */
|
|
28
36
|
shouldCloseOnEsc?: boolean;
|
|
37
|
+
/** @default true */
|
|
29
38
|
shouldBlockScroll?: boolean;
|
|
39
|
+
/** @default false */
|
|
30
40
|
isOpen?: boolean;
|
|
31
41
|
zIndex?: number;
|
|
32
|
-
onClose
|
|
42
|
+
onClose?: () => void;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export const Modal: FC<IModalProps> = ({
|
|
@@ -37,7 +47,7 @@ export const Modal: FC<IModalProps> = ({
|
|
|
37
47
|
tweakStyles,
|
|
38
48
|
title,
|
|
39
49
|
size = 'l',
|
|
40
|
-
isFooterSticky,
|
|
50
|
+
isFooterSticky = false,
|
|
41
51
|
buttons,
|
|
42
52
|
buttonsAlign = 'right',
|
|
43
53
|
hasCloseButton = true,
|
|
@@ -10,18 +10,17 @@ import { useStyles, IMoreMenuStyles } from './MoreMenu.styles';
|
|
|
10
10
|
|
|
11
11
|
export interface IMoreMenuProps extends ICommonProps<IMoreMenuStyles> {
|
|
12
12
|
items: IListItem[];
|
|
13
|
+
/** @default false */
|
|
13
14
|
isDisabled?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
15
|
+
/** @default true */
|
|
17
16
|
hasDefaultStateBackground?: boolean;
|
|
18
|
-
onMenuOpen
|
|
19
|
-
onMenuClose
|
|
17
|
+
onMenuOpen?: () => void;
|
|
18
|
+
onMenuClose?: () => void;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export const MoreMenu: FC<IMoreMenuProps> = ({
|
|
23
22
|
items,
|
|
24
|
-
isDisabled,
|
|
23
|
+
isDisabled = false,
|
|
25
24
|
hasDefaultStateBackground = true,
|
|
26
25
|
data,
|
|
27
26
|
testId,
|
|
@@ -16,22 +16,27 @@ import { useStyles, IMultiSelectStyles, multiSelectListStyles } from './MultiSel
|
|
|
16
16
|
|
|
17
17
|
export interface IMultiSelectProps<Value = string> extends ICommonProps<IMultiSelectStyles> {
|
|
18
18
|
value?: IMultiSelectListValues<Value>;
|
|
19
|
+
/** @default 'full' */
|
|
19
20
|
corners?: IHorizontalCornerConnection;
|
|
21
|
+
/** @default false */
|
|
20
22
|
isInvalid?: boolean;
|
|
23
|
+
/** @default false */
|
|
21
24
|
isRequired?: boolean;
|
|
25
|
+
/** @default false */
|
|
22
26
|
isDisabled?: boolean;
|
|
27
|
+
/** @default '' */
|
|
23
28
|
placeholder?: string;
|
|
24
29
|
localeKey?: IMultiSelectLocaleKey;
|
|
25
30
|
locale?: IMultiSelectLocale;
|
|
26
|
-
onChange(value?: IMultiSelectListValues<Value>)
|
|
27
|
-
fetchOptions(value?: string, page?: number)
|
|
31
|
+
onChange: (value?: IMultiSelectListValues<Value>) => void;
|
|
32
|
+
fetchOptions: (value?: string, page?: number) => Promise<Value[]>;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
export function MultiSelect<Value = string>({
|
|
31
36
|
value,
|
|
32
37
|
corners = 'full',
|
|
33
|
-
isInvalid,
|
|
34
|
-
isRequired,
|
|
38
|
+
isInvalid = false,
|
|
39
|
+
isRequired = false,
|
|
35
40
|
isDisabled = false,
|
|
36
41
|
placeholder = '',
|
|
37
42
|
localeKey,
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
export interface IMultiSelectListProps<Value, Option> extends ICommonProps<IMultiSelectListStyles> {
|
|
23
23
|
value?: Value;
|
|
24
|
+
/** @default false */
|
|
24
25
|
isSearchEnabled?: boolean;
|
|
25
26
|
localeKey?: IMultiSelectLocaleKey;
|
|
26
27
|
locale?: Partial<IMultiSelectLocale>;
|
|
@@ -31,7 +32,9 @@ export interface IMultiSelectListProps<Value, Option> extends ICommonProps<IMult
|
|
|
31
32
|
getValueView?: (val: Option) => ReactNode;
|
|
32
33
|
getValueId?: (val: Option) => string;
|
|
33
34
|
getValueString?: (val: Option) => string;
|
|
35
|
+
/** @default по умолчанию значение совпадает с isSearchEnabled */
|
|
34
36
|
isGroupingEnabled?: boolean;
|
|
37
|
+
/** @default 'left' */
|
|
35
38
|
checkboxPosition?: 'left' | 'right';
|
|
36
39
|
pageSize?: number;
|
|
37
40
|
searchMaxLength?: number;
|
|
@@ -13,15 +13,11 @@ import { useStyles, INotificationStyles } from './Notification.styles';
|
|
|
13
13
|
|
|
14
14
|
export interface INotificationProps extends ICommonProps<INotificationStyles> {
|
|
15
15
|
type: INotificationType;
|
|
16
|
-
/**
|
|
17
|
-
* @default true
|
|
18
|
-
*/
|
|
16
|
+
/** @default true */
|
|
19
17
|
isFullWidth?: boolean;
|
|
20
18
|
text?: string;
|
|
21
19
|
title?: string;
|
|
22
|
-
/**
|
|
23
|
-
* @default `s`
|
|
24
|
-
*/
|
|
20
|
+
/** @default 's' */
|
|
25
21
|
size?: 's' | 'm' | 'l';
|
|
26
22
|
children?: ReactNode;
|
|
27
23
|
}
|
|
@@ -14,14 +14,18 @@ import { constructRegExp, formatNumberWithDefault, getNewCaretPosition } from '.
|
|
|
14
14
|
|
|
15
15
|
export interface INumberInputProps extends Omit<IInputProps, 'value' | 'onChange' | 'type'> {
|
|
16
16
|
value?: number;
|
|
17
|
+
/** @default 3 */
|
|
17
18
|
precision?: number;
|
|
19
|
+
/** @default 7 */
|
|
18
20
|
intPartPrecision?: number;
|
|
19
21
|
defaultValue?: number;
|
|
22
|
+
/** @default false */
|
|
20
23
|
canBeFloat?: boolean;
|
|
24
|
+
/** @default false */
|
|
21
25
|
canBeNegative?: boolean;
|
|
22
26
|
min?: number;
|
|
23
27
|
max?: number;
|
|
24
|
-
onChange(value: number | undefined, event?: FormEvent<HTMLInputElement>)
|
|
28
|
+
onChange: (value: number | undefined, event?: FormEvent<HTMLInputElement>) => void;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export const NumberInput = forwardRef<HTMLInputElement, INumberInputProps>(
|
|
@@ -25,14 +25,18 @@ export interface IPhoneInputProps
|
|
|
25
25
|
'value' | 'onChange' | 'type' | 'mask' | 'units' | 'placeholder' | 'tweakStyles'
|
|
26
26
|
>,
|
|
27
27
|
ICommonProps<IPhoneInputStyles> {
|
|
28
|
+
/** @default 'ru' */
|
|
28
29
|
locale?: string;
|
|
30
|
+
/** @default 'Поиск' */
|
|
29
31
|
codeSearchPlaceholder?: string;
|
|
32
|
+
/** @default 'Ничего не найдено' */
|
|
30
33
|
noMatchesLabel?: string;
|
|
34
|
+
/** @default { phoneNumber: '', dialCode: '' } */
|
|
31
35
|
value?: IPhoneValue;
|
|
32
|
-
onChange(
|
|
36
|
+
onChange: (
|
|
33
37
|
phone: IPhoneValue,
|
|
34
38
|
event: MouseEvent | KeyboardEvent | FormEvent<HTMLInputElement>,
|
|
35
|
-
)
|
|
39
|
+
) => void;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
export const PhoneInput: FC<IPhoneInputProps> = ({
|
package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx
CHANGED
|
@@ -26,8 +26,8 @@ export interface IPhoneInputCountryListProps
|
|
|
26
26
|
locale: string;
|
|
27
27
|
placeholder: string;
|
|
28
28
|
noMatchesLabel: string;
|
|
29
|
-
closeList()
|
|
30
|
-
onChange(country: IPhoneInfo, event: MouseEvent | KeyboardEvent)
|
|
29
|
+
closeList: () => void;
|
|
30
|
+
onChange: (country: IPhoneInfo, event: MouseEvent | KeyboardEvent) => void;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const PhoneInputCountryList: FC<IPhoneInputCountryListProps> = ({
|
|
@@ -10,9 +10,11 @@ export interface IRadioButtonProps<Value extends string> extends ICommonProps<IR
|
|
|
10
10
|
value: Value;
|
|
11
11
|
groupName: string;
|
|
12
12
|
isChecked?: boolean;
|
|
13
|
+
/** @default false */
|
|
13
14
|
isDisabled?: boolean;
|
|
15
|
+
/** @default false */
|
|
14
16
|
isInvalid?: boolean;
|
|
15
|
-
onChange(value: Value)
|
|
17
|
+
onChange: (value: Value) => void | Promise<void>;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export function RadioButton<Value extends string>({
|
|
@@ -20,8 +22,8 @@ export function RadioButton<Value extends string>({
|
|
|
20
22
|
value,
|
|
21
23
|
groupName,
|
|
22
24
|
isChecked,
|
|
23
|
-
isDisabled,
|
|
24
|
-
isInvalid,
|
|
25
|
+
isDisabled = false,
|
|
26
|
+
isInvalid = false,
|
|
25
27
|
data,
|
|
26
28
|
testId,
|
|
27
29
|
tweakStyles,
|
|
@@ -45,39 +45,44 @@ export interface ISelectProps<Value>
|
|
|
45
45
|
allOptionsLabel?: string;
|
|
46
46
|
noMatchesLabel?: string;
|
|
47
47
|
loadingLabel?: ReactNode;
|
|
48
|
+
/** @default 'normal' */
|
|
48
49
|
optionsMode?: 'search' | 'dynamic' | 'normal';
|
|
50
|
+
/** @default 400 */
|
|
49
51
|
debounceTime?: number;
|
|
52
|
+
/** @default 0 */
|
|
50
53
|
minSymbolsCountToOpenList?: number;
|
|
51
54
|
dropdownOptions?: IDropdownWithPopperOptions;
|
|
55
|
+
/** @default 'chevron-down' */
|
|
52
56
|
dropdownIcon?: IIcon;
|
|
53
57
|
options: Value[];
|
|
54
58
|
value: Value | undefined;
|
|
59
|
+
/** @default true */
|
|
55
60
|
shouldScrollToList?: boolean;
|
|
56
61
|
isMultiSelect?: boolean;
|
|
57
62
|
searchInput?: { shouldRenderInList: true } & Pick<ISearchInputProps, 'placeholder'>;
|
|
58
|
-
isOptionDisabled
|
|
59
|
-
onChange(value?: Value)
|
|
60
|
-
onBlur
|
|
61
|
-
onType
|
|
62
|
-
optionsFilter
|
|
63
|
-
onOpen
|
|
64
|
-
compareValuesOnChange
|
|
63
|
+
isOptionDisabled?: (option: Value) => boolean;
|
|
64
|
+
onChange: (value?: Value) => void; // подумать как возвращать индекс
|
|
65
|
+
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
66
|
+
onType?: (value: string) => Promise<void>;
|
|
67
|
+
optionsFilter?: (options: Value[], query: string) => Value[];
|
|
68
|
+
onOpen?: () => void;
|
|
69
|
+
compareValuesOnChange?: (v1?: Value, v2?: Value) => boolean;
|
|
65
70
|
// Для избежания проблем юзайте useCallback на эти функции
|
|
66
71
|
// или выносите их из компонента (чтобы не было сайдэфектов от перерендеринга их)
|
|
67
|
-
convertValueToString
|
|
68
|
-
convertValueToReactNode
|
|
69
|
-
convertValueToId
|
|
72
|
+
convertValueToString?: (value: Value) => string | undefined;
|
|
73
|
+
convertValueToReactNode?: (value: Value, isDisabled: boolean) => ReactNode;
|
|
74
|
+
convertValueToId?: (value: Value) => string | undefined;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
export interface IMultipleSelectProps<Value>
|
|
73
78
|
extends Omit<ISelectProps<Value>, 'value' | 'onChange' | 'compareValuesOnChange'> {
|
|
74
79
|
isMultiSelect: true;
|
|
75
80
|
value: IMultipleSelectValue<Value> | undefined;
|
|
76
|
-
onChange(value?: IMultipleSelectValue<Value>)
|
|
77
|
-
compareValuesOnChange
|
|
81
|
+
onChange: (value?: IMultipleSelectValue<Value>) => void;
|
|
82
|
+
compareValuesOnChange?: (
|
|
78
83
|
v1?: IMultipleSelectValue<Value>,
|
|
79
84
|
v2?: IMultipleSelectValue<Value>,
|
|
80
|
-
)
|
|
85
|
+
) => boolean;
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
export function Select<Value>(
|
|
@@ -25,12 +25,12 @@ export interface ISelectListProps<Value> extends ICommonProps<ISelectListStyles>
|
|
|
25
25
|
areAllOptionsSelected?: boolean;
|
|
26
26
|
shouldScrollToList?: boolean;
|
|
27
27
|
customListHeader?: ReactNode;
|
|
28
|
-
onOptionSelect(index: number, event: MouseEvent<HTMLElement>)
|
|
29
|
-
onToggleCheckbox
|
|
30
|
-
isOptionDisabled(value: Value)
|
|
31
|
-
convertValueToString(value: Value)
|
|
32
|
-
convertValueToReactNode
|
|
33
|
-
convertValueToId(value: Value)
|
|
28
|
+
onOptionSelect: (index: number, event: MouseEvent<HTMLElement>) => void;
|
|
29
|
+
onToggleCheckbox?: (index: number, isSelected: boolean) => void;
|
|
30
|
+
isOptionDisabled: (value: Value) => boolean;
|
|
31
|
+
convertValueToString: (value: Value) => string | undefined;
|
|
32
|
+
convertValueToReactNode?: (value: Value, isDisabled: boolean) => ReactNode;
|
|
33
|
+
convertValueToId: (value: Value) => string | undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function SelectList<Value>({
|
|
@@ -15,8 +15,8 @@ export interface ISelectListItemProps {
|
|
|
15
15
|
isFocused?: boolean;
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
classes: Classes<'cellWithCheckbox' | 'cell' | 'focused' | 'active' | 'disabled'>; // TODO: !!!
|
|
18
|
-
onOptionSelect(index: number, event: MouseEvent<HTMLElement>)
|
|
19
|
-
onToggleCheckbox
|
|
18
|
+
onOptionSelect: (index: number, event: MouseEvent<HTMLElement>) => void;
|
|
19
|
+
onToggleCheckbox?: (index: number, isSelected: boolean) => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const SelectListItem: FC<ISelectListItemProps> = ({
|
|
@@ -5,7 +5,9 @@ import { transformCaseSensitive } from './helpers';
|
|
|
5
5
|
import { ISmartType } from './types';
|
|
6
6
|
|
|
7
7
|
export interface ISmartInputProps extends IInputProps {
|
|
8
|
+
/** @default false */
|
|
8
9
|
isUpperCase?: boolean;
|
|
10
|
+
/** @default 'default' */
|
|
9
11
|
smartType?: ISmartType;
|
|
10
12
|
regExp?: RegExp;
|
|
11
13
|
onChange: (value: string) => void;
|
|
@@ -13,7 +15,15 @@ export interface ISmartInputProps extends IInputProps {
|
|
|
13
15
|
|
|
14
16
|
export const SmartInput = forwardRef<HTMLInputElement, ISmartInputProps>(
|
|
15
17
|
(
|
|
16
|
-
{
|
|
18
|
+
{
|
|
19
|
+
onChange,
|
|
20
|
+
isUpperCase = false,
|
|
21
|
+
smartType = 'default',
|
|
22
|
+
regExp,
|
|
23
|
+
value = '',
|
|
24
|
+
maxLength,
|
|
25
|
+
...rest
|
|
26
|
+
},
|
|
17
27
|
ref,
|
|
18
28
|
) => {
|
|
19
29
|
const [currentValue, setCurrentValue] = useState<string>(getUpperCaseIfNeeded(value));
|
|
@@ -9,24 +9,23 @@ import { useStyles, ISwitchStyles } from './Switch.styles';
|
|
|
9
9
|
export interface ISwitchProps<V extends string> extends ICommonProps<ISwitchStyles> {
|
|
10
10
|
children?: ReactNode;
|
|
11
11
|
value: V;
|
|
12
|
+
/** @default false */
|
|
12
13
|
isChecked: boolean | undefined;
|
|
14
|
+
/** @default false */
|
|
13
15
|
isDisabled?: boolean;
|
|
16
|
+
/** @default false */
|
|
14
17
|
isInvalid?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* @default `right`
|
|
17
|
-
*/
|
|
18
|
+
/** @default 'right' */
|
|
18
19
|
labelPosition?: 'left' | 'right';
|
|
19
|
-
/**
|
|
20
|
-
* @default `primary`
|
|
21
|
-
*/
|
|
20
|
+
/** @default 'primary' */
|
|
22
21
|
color?: 'primary' | 'secondary';
|
|
23
|
-
onChange(state: ISwitchState<V>)
|
|
22
|
+
onChange: (state: ISwitchState<V>) => void;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export const Switch = <V extends string>({
|
|
27
|
-
isDisabled,
|
|
26
|
+
isDisabled = false,
|
|
28
27
|
isChecked = false,
|
|
29
|
-
isInvalid,
|
|
28
|
+
isInvalid = false,
|
|
30
29
|
value,
|
|
31
30
|
children,
|
|
32
31
|
labelPosition = 'right',
|
|
@@ -17,24 +17,33 @@ export interface ITextAreaProps extends ICommonProps<ITextAreaStyles> {
|
|
|
17
17
|
value?: string;
|
|
18
18
|
label?: string;
|
|
19
19
|
placeholder?: string;
|
|
20
|
+
/** @default false */
|
|
20
21
|
isDisabled?: boolean;
|
|
22
|
+
/** @default true */
|
|
21
23
|
hasFloatingLabel?: boolean;
|
|
24
|
+
/** @default false */
|
|
22
25
|
isInvalid?: boolean;
|
|
26
|
+
/** @default false */
|
|
23
27
|
isActive?: boolean;
|
|
24
28
|
infoMessage?: string;
|
|
25
29
|
errorMessage?: string;
|
|
30
|
+
/** @default false */
|
|
26
31
|
isRequired?: boolean;
|
|
27
32
|
name?: string;
|
|
33
|
+
/** @default false */
|
|
28
34
|
hasRequiredLabel?: boolean;
|
|
35
|
+
/** @default false */
|
|
29
36
|
shouldFocusOnMount?: boolean;
|
|
37
|
+
/** @default true */
|
|
30
38
|
hasCounter?: boolean;
|
|
39
|
+
/** @default false */
|
|
31
40
|
shouldTrimAfterMaxLength?: boolean;
|
|
32
41
|
maxLength?: number;
|
|
33
42
|
rows?: number;
|
|
34
|
-
onChange(value: string, event?: FormEvent<HTMLTextAreaElement>)
|
|
35
|
-
onFocus
|
|
36
|
-
onBlur
|
|
37
|
-
onPaste
|
|
43
|
+
onChange: (value: string, event?: FormEvent<HTMLTextAreaElement>) => void;
|
|
44
|
+
onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
45
|
+
onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
46
|
+
onPaste?: (event: ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
const DEFAULT_VALUE = '';
|
|
@@ -49,10 +58,10 @@ export const TextArea: FC<ITextAreaProps> = ({
|
|
|
49
58
|
isActive = false,
|
|
50
59
|
infoMessage,
|
|
51
60
|
errorMessage,
|
|
52
|
-
isRequired,
|
|
61
|
+
isRequired = false,
|
|
53
62
|
name,
|
|
54
|
-
hasRequiredLabel,
|
|
55
|
-
shouldFocusOnMount,
|
|
63
|
+
hasRequiredLabel = false,
|
|
64
|
+
shouldFocusOnMount = false,
|
|
56
65
|
hasCounter = true,
|
|
57
66
|
shouldTrimAfterMaxLength = false,
|
|
58
67
|
maxLength,
|