@true-engineering/true-react-common-ui-kit 4.0.0-alpha2 → 4.0.0-alpha20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -567
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.d.ts +2 -0
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
- package/dist/components/ControlWrapper/index.d.ts +1 -0
- package/dist/components/ControlWrapper/types.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.d.ts +3 -3
- package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
- package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +2 -4
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +5 -3
- package/dist/components/FiltersPane/FiltersPane.d.ts +7 -2
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
- package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
- package/dist/components/FiltersPane/types.d.ts +15 -5
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -3
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +8 -8
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Input/InputBase.d.ts +2 -2
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/Modal/Modal.styles.d.ts +1 -1
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/Select/Select.d.ts +5 -3
- package/dist/components/Select/Select.styles.d.ts +4 -4
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Status/Status.styles.d.ts +3 -2
- package/dist/components/Status/constants.d.ts +0 -1
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/Status/types.d.ts +5 -2
- package/dist/components/TextArea/TextArea.d.ts +2 -5
- package/dist/components/TextArea/TextArea.styles.d.ts +1 -2
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +21 -6
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithPopup/helpers.d.ts +2 -0
- package/dist/components/WithPopup/types.d.ts +3 -0
- package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-merge.d.ts +1 -0
- package/dist/hooks/use-mixed-styles.d.ts +3 -1
- package/dist/hooks/use-tweak-styles.d.ts +5 -5
- package/dist/style.css +78 -142
- package/dist/theme/Provider.d.ts +6 -3
- package/dist/theme/common.d.ts +4 -2
- package/dist/theme/create-themed-styles.d.ts +2 -0
- package/dist/theme/helpers.d.ts +9 -3
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
- package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
- package/dist/theme/true-jss/index.d.ts +2 -0
- package/dist/theme/true-jss/jss-context.d.ts +9 -0
- package/dist/theme/types.d.ts +5 -3
- package/dist/true-react-common-ui-kit.js +7519 -6456
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7455 -6393
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +4 -5
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
- package/src/components/ControlWrapper/ControlWrapper.tsx +8 -2
- package/src/components/ControlWrapper/index.ts +1 -0
- package/src/components/ControlWrapper/types.ts +4 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +2 -1
- package/src/components/DatePicker/DatePicker.styles.ts +3 -1
- package/src/components/DatePicker/DatePicker.tsx +12 -7
- package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +4 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +9 -4
- package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
- package/src/components/FiltersPane/FiltersPane.tsx +19 -13
- package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
- package/src/components/FiltersPane/types.ts +23 -5
- package/src/components/Flag/Flag.stories.tsx +2 -1
- package/src/components/Flag/Flag.styles.ts +4 -0
- package/src/components/Flag/Flag.tsx +23 -9
- package/src/components/Flag/customFlags/AB.svg +1 -0
- package/src/components/Flag/customFlags/OS.svg +1 -0
- package/src/components/Flag/customFlags/augment.d.ts +1 -0
- package/src/components/Flag/customFlags/customFlags.ts +13 -0
- package/src/components/Flag/customFlags/index.ts +1 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -5
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +13 -12
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +8 -12
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/InputBase.tsx +27 -24
- package/src/components/List/List.tsx +5 -2
- package/src/components/List/index.ts +2 -1
- package/src/components/List/types.ts +5 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +5 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/SearchInput/SearchInput.tsx +20 -29
- package/src/components/Select/Select.tsx +12 -2
- package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
- package/src/components/Select/index.ts +1 -1
- package/src/components/Status/Status.stories.tsx +54 -1
- package/src/components/Status/Status.styles.ts +2 -37
- package/src/components/Status/constants.ts +0 -10
- package/src/components/Status/index.ts +1 -1
- package/src/components/Status/types.ts +7 -3
- package/src/components/TextArea/TextArea.styles.ts +2 -6
- package/src/components/TextArea/TextArea.tsx +41 -20
- package/src/components/TextArea/index.ts +0 -1
- package/src/components/TextButton/TextButton.styles.ts +1 -0
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
- package/src/components/WithPopup/WithPopup.styles.ts +2 -0
- package/src/components/WithPopup/WithPopup.tsx +64 -16
- package/src/components/WithPopup/helpers.ts +9 -0
- package/src/components/WithPopup/types.ts +7 -0
- package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
- package/src/components/WithTooltip/WithTooltip.tsx +7 -2
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-merge.ts +8 -0
- package/src/hooks/use-mixed-styles.ts +9 -11
- package/src/hooks/use-tweak-styles.ts +49 -27
- package/src/theme/Provider.tsx +10 -5
- package/src/theme/common.ts +5 -2
- package/src/theme/create-themed-styles.ts +78 -0
- package/src/theme/helpers.ts +39 -39
- package/src/theme/index.ts +2 -0
- package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
- package/src/theme/true-jss/TweakStylesManager.ts +157 -0
- package/src/theme/true-jss/index.ts +2 -0
- package/src/theme/true-jss/jss-context.tsx +34 -0
- package/src/theme/types.ts +5 -3
- package/src/types.ts +17 -4
- package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
- package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
- package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
- package/dist/components/Colors/Colors.stories.d.ts +0 -5
- package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
- package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
- package/dist/components/Description/Description.stories.d.ts +0 -16
- package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
- package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
- package/dist/components/Flag/Flag.stories.d.ts +0 -12
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
- package/dist/components/Icon/Icon.stories.d.ts +0 -6
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
- package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
- package/dist/components/Input/Input.stories.d.ts +0 -25
- package/dist/components/List/List.stories.d.ts +0 -5
- package/dist/components/Modal/Modal.stories.d.ts +0 -29
- package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
- package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
- package/dist/components/Notification/Notification.stories.d.ts +0 -8
- package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
- package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
- package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -6
- package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
- package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
- package/dist/components/Select/Select.stories.d.ts +0 -15
- package/dist/components/Selector/Selector.stories.d.ts +0 -7
- package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
- package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
- package/dist/components/Status/Status.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -16
- package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
- package/dist/components/TextArea/types.d.ts +0 -2
- package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
- package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
- package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
- package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
- package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
- package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
- package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
- package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
- package/src/components/TextArea/types.ts +0 -6
|
@@ -15,12 +15,12 @@ import InputMask, { Props as ReactInputMaskBaseProps } from 'react-input-mask';
|
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import {
|
|
17
17
|
addDataTestId,
|
|
18
|
+
isArrayLikeNotEmpty,
|
|
18
19
|
isNotEmpty,
|
|
19
20
|
isReactNodeNotEmpty,
|
|
20
21
|
isStringNotEmpty,
|
|
21
|
-
mergeRefs,
|
|
22
22
|
} from '@true-engineering/true-react-platform-helpers';
|
|
23
|
-
import { useTweakStyles } from '../../hooks';
|
|
23
|
+
import { useMergedRefs, useTweakStyles } from '../../hooks';
|
|
24
24
|
import { IClickHandlerEvent, ICommonProps } from '../../types';
|
|
25
25
|
import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
|
|
26
26
|
import { IChangeInputEvent } from './types';
|
|
@@ -28,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
|
) => {
|
|
@@ -123,7 +119,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
123
119
|
const [unitsWidth, setUnitsWidth] = useState<number>();
|
|
124
120
|
|
|
125
121
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
126
|
-
const mergedRef =
|
|
122
|
+
const mergedRef = useMergedRefs([ref, inputRef]);
|
|
127
123
|
|
|
128
124
|
// Try to guess input-mode if possible
|
|
129
125
|
const inputMode: IInputBaseProps['inputMode'] =
|
|
@@ -131,7 +127,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
131
127
|
(['email', 'tel', 'url'].includes(type) ? (type as 'email' | 'tel' | 'url') : undefined);
|
|
132
128
|
|
|
133
129
|
const hasFocus = isFocused || isActive;
|
|
134
|
-
const hasValue =
|
|
130
|
+
const hasValue = isArrayLikeNotEmpty(value);
|
|
135
131
|
const hasUnits = isReactNodeNotEmpty(units);
|
|
136
132
|
const hasPlaceholder =
|
|
137
133
|
(!isReactNodeNotEmpty(label) || hasFocus || shouldAlwaysShowPlaceholder) &&
|
|
@@ -194,7 +190,8 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
194
190
|
onFocus: handleFocus,
|
|
195
191
|
onBlur: handleBlur,
|
|
196
192
|
onChange: handleChange,
|
|
197
|
-
...addDataTestId(testId
|
|
193
|
+
...addDataTestId(testId),
|
|
194
|
+
...inputProps,
|
|
198
195
|
};
|
|
199
196
|
|
|
200
197
|
useEffect(() => {
|
|
@@ -234,11 +231,17 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
234
231
|
isDisabled={isDisabled}
|
|
235
232
|
isFocused={hasFocus}
|
|
236
233
|
isInvalid={isInvalid}
|
|
237
|
-
hasValue={hasValue
|
|
234
|
+
hasValue={hasValue}
|
|
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>
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import { addDataAttributes } from '../../helpers';
|
|
9
9
|
import { ICommonProps } from '../../types';
|
|
10
10
|
import { WithPopup } from '../WithPopup';
|
|
11
|
-
import { IListItemProps,
|
|
11
|
+
import { IListItemProps, ListItem } from './components';
|
|
12
|
+
import { IListItem } from './types';
|
|
12
13
|
import { useStyles, IListStyles, withPopupStyles } from './List.styles';
|
|
13
14
|
|
|
14
15
|
export interface IListProps extends ICommonProps<IListStyles> {
|
|
@@ -29,9 +30,11 @@ export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
const filteredItems = items.filter(({ isHidden }) => !isHidden);
|
|
34
|
+
|
|
32
35
|
return (
|
|
33
36
|
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
34
|
-
{
|
|
37
|
+
{filteredItems.map((item, i) => {
|
|
35
38
|
const itemProps: IListItemProps = {
|
|
36
39
|
testId: getTestId(testId, `item-${i}`),
|
|
37
40
|
...item,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './List';
|
|
2
2
|
export type { IListStyles } from './List.styles';
|
|
3
|
-
export
|
|
3
|
+
export type { IListItem } from './types';
|
|
4
|
+
export { type IListItemStyles, type IListItemProps, ListItem } from './components';
|
|
@@ -9,7 +9,11 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
const Template: ComponentStory<typeof NumberInput> = (args) => {
|
|
11
11
|
const [value, setValue] = useState<number>();
|
|
12
|
-
return
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ width: 300 }}>
|
|
14
|
+
<NumberInput {...args} value={value} onChange={(v) => setValue(v)} />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export const Default = Template.bind({});
|
|
@@ -26,7 +26,8 @@ export default {
|
|
|
26
26
|
const Template: ComponentStory<typeof PhoneInput> = (args) => {
|
|
27
27
|
const [value, setValue] = useState<IPhoneValue>({
|
|
28
28
|
dialCode: '7',
|
|
29
|
-
phoneNumber: '
|
|
29
|
+
phoneNumber: '9134567890',
|
|
30
|
+
countryCode: 'RU',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return <PhoneInput {...args} value={value} onChange={setValue} />;
|
|
@@ -76,7 +76,7 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
76
76
|
|
|
77
77
|
const countryCode = useMemo(
|
|
78
78
|
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
79
|
-
[value.dialCode, value.phoneNumber],
|
|
79
|
+
[value.countryCode, value.dialCode, value.phoneNumber],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const handleClose = () => {
|
|
@@ -122,7 +122,10 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
122
122
|
if (newPhoneInfo.countryCode !== countryCode) {
|
|
123
123
|
onChange(
|
|
124
124
|
{
|
|
125
|
-
phoneNumber:
|
|
125
|
+
phoneNumber:
|
|
126
|
+
newPhoneInfo.dialCode !== value.dialCode
|
|
127
|
+
? ''
|
|
128
|
+
: getPhoneObjFromString(phoneWithCode).phoneNumber,
|
|
126
129
|
dialCode: newPhoneInfo.dialCode,
|
|
127
130
|
countryCode: newPhoneInfo.countryCode,
|
|
128
131
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
3
2
|
import { useTweakStyles } from '../../hooks';
|
|
4
3
|
import { ICommonProps } from '../../types';
|
|
5
4
|
import { IInputProps, Input } from '../Input';
|
|
@@ -11,31 +10,23 @@ export type ISearchInputProps = Omit<
|
|
|
11
10
|
> &
|
|
12
11
|
ICommonProps<ISearchInputStyles>;
|
|
13
12
|
|
|
14
|
-
export const SearchInput
|
|
15
|
-
isClearable = true,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}) => {
|
|
23
|
-
const tweakInputStyles = useTweakStyles({
|
|
24
|
-
innerStyles: inputStyles,
|
|
25
|
-
tweakStyles,
|
|
26
|
-
className: 'tweakInput',
|
|
27
|
-
currentComponentName: 'SearchInput',
|
|
28
|
-
});
|
|
13
|
+
export const SearchInput = forwardRef<HTMLInputElement, ISearchInputProps>(
|
|
14
|
+
({ isClearable = true, tweakStyles, ...props }, ref) => {
|
|
15
|
+
const tweakInputStyles = useTweakStyles({
|
|
16
|
+
innerStyles: inputStyles,
|
|
17
|
+
tweakStyles,
|
|
18
|
+
className: 'tweakInput',
|
|
19
|
+
currentComponentName: 'SearchInput',
|
|
20
|
+
});
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
22
|
+
return (
|
|
23
|
+
<Input
|
|
24
|
+
ref={ref}
|
|
25
|
+
icon="search"
|
|
26
|
+
isClearable={isClearable}
|
|
27
|
+
tweakStyles={tweakInputStyles}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
KeyboardEvent,
|
|
6
6
|
MouseEvent,
|
|
7
7
|
ReactNode,
|
|
8
|
+
Ref,
|
|
8
9
|
SyntheticEvent,
|
|
9
10
|
useCallback,
|
|
10
11
|
useEffect,
|
|
@@ -63,7 +64,11 @@ export interface ISelectProps<Value>
|
|
|
63
64
|
/** @default true */
|
|
64
65
|
shouldScrollToList?: boolean;
|
|
65
66
|
isMultiSelect?: false;
|
|
66
|
-
searchInput?: {
|
|
67
|
+
searchInput?: {
|
|
68
|
+
/** @default false */
|
|
69
|
+
shouldRenderInList?: boolean;
|
|
70
|
+
ref?: Ref<HTMLInputElement>;
|
|
71
|
+
} & Pick<ISearchInputProps, 'placeholder' | 'shouldFocusOnMount'>;
|
|
67
72
|
isOptionDisabled?: (option: Value) => boolean;
|
|
68
73
|
onChange: (value: Value | undefined, event: IChangeSelectEvent) => void; // подумать как возвращать индекс
|
|
69
74
|
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
@@ -248,10 +253,14 @@ export function Select<Value>(
|
|
|
248
253
|
|
|
249
254
|
const handleListClose = useCallback(
|
|
250
255
|
(event: Event | SyntheticEvent) => {
|
|
256
|
+
if (!isListOpen) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
closeList();
|
|
252
261
|
onBlur?.(event);
|
|
253
262
|
},
|
|
254
|
-
[closeList, onBlur],
|
|
263
|
+
[isListOpen, closeList, onBlur],
|
|
255
264
|
);
|
|
256
265
|
|
|
257
266
|
const handleListOpen = () => {
|
|
@@ -581,6 +590,7 @@ export function Select<Value>(
|
|
|
581
590
|
errorMessage={errorMessage}
|
|
582
591
|
infoMessage={infoMessage}
|
|
583
592
|
tweakStyles={tweakWithMessagesStyles}
|
|
593
|
+
testId={getTestId(testId, 'wrapper')}
|
|
584
594
|
>
|
|
585
595
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
586
596
|
<div
|
|
@@ -84,7 +84,7 @@ export function SelectList<Value>({
|
|
|
84
84
|
})}
|
|
85
85
|
>
|
|
86
86
|
{isHeaderNotEmpty && <div className={classes.listHeader}>{customListHeader}</div>}
|
|
87
|
-
<div className={classes.list} {...addDataTestId(testId)}>
|
|
87
|
+
<div className={classes.list} {...addDataTestId(testId)} tabIndex={-1}>
|
|
88
88
|
{isLoading ? (
|
|
89
89
|
<div className={clsx(classes.cell, classes.loading)}>{loadingLabel}</div>
|
|
90
90
|
) : (
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
import { Status } from '.';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { rgba } from '../../helpers';
|
|
4
|
+
import { IExtendableProps } from '../../types';
|
|
3
5
|
import { iconsList, IIconType } from '../Icon';
|
|
4
6
|
import { complexIcons } from '../Icon/complexIcons';
|
|
5
|
-
import {
|
|
7
|
+
import { STATUS_SIZES } from './constants';
|
|
6
8
|
import { IStatusStyles } from './Status.styles';
|
|
7
9
|
|
|
10
|
+
export const STATUS_COLORS = [
|
|
11
|
+
'green',
|
|
12
|
+
'teal',
|
|
13
|
+
'blue',
|
|
14
|
+
'grey',
|
|
15
|
+
'orange',
|
|
16
|
+
'red',
|
|
17
|
+
'violet',
|
|
18
|
+
'custom',
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
8
21
|
export default {
|
|
9
22
|
title: 'Data Display/Status',
|
|
10
23
|
component: Status,
|
|
11
24
|
};
|
|
12
25
|
|
|
26
|
+
declare module './types' {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
28
|
+
export interface IStatusColors extends IExtendableProps<typeof STATUS_COLORS> {}
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
const icons = [undefined, ...Object.keys(iconsList), ...Object.keys(complexIcons)] as IIconType[];
|
|
14
32
|
|
|
15
33
|
const customTweakStyles: IStatusStyles = {
|
|
34
|
+
green: {
|
|
35
|
+
'--status-background': rgba('#D4E3AC', 0.5),
|
|
36
|
+
'--status-color': '#6F990F',
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
blue: {
|
|
40
|
+
'--status-background': rgba('#AABFFC', 0.4),
|
|
41
|
+
'--status-color': '#4C6EBF',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
grey: {
|
|
45
|
+
'--status-background': rgba('#95A0B3', 0.25),
|
|
46
|
+
'--status-color': '#7A869A',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
orange: {
|
|
50
|
+
'--status-background': rgba('#FCD3A9', 0.5),
|
|
51
|
+
'--status-color': '#E5741C',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
red: {
|
|
55
|
+
'--status-background': rgba('#F7949A', 0.25),
|
|
56
|
+
'--status-color': '#F14D56',
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
teal: {
|
|
60
|
+
'--status-background': rgba('#8CE3EA', 0.4),
|
|
61
|
+
'--status-color': '#0092A6',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
violet: {
|
|
65
|
+
'--status-background': rgba('#BEABE0', 0.4),
|
|
66
|
+
'--status-color': '#7450B2',
|
|
67
|
+
},
|
|
68
|
+
|
|
16
69
|
custom: {
|
|
17
70
|
'--status-color': '#793472',
|
|
18
71
|
'--status-background': '#F2B9ED',
|
|
@@ -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;
|
|
@@ -65,13 +65,9 @@ export const useStyles = createThemedStyles('TextArea', {
|
|
|
65
65
|
symbolsCountError: {
|
|
66
66
|
color: 'red',
|
|
67
67
|
},
|
|
68
|
-
});
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
top: 16,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
69
|
+
withLabel: {},
|
|
70
|
+
});
|
|
75
71
|
|
|
76
72
|
export type ITextAreaStyles = ITweakStyles<
|
|
77
73
|
typeof useStyles,
|
|
@@ -1,7 +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,
|
|
12
|
+
getTestId,
|
|
13
|
+
isArrayLikeNotEmpty,
|
|
5
14
|
isNotEmpty,
|
|
6
15
|
isReactNodeNotEmpty,
|
|
7
16
|
isStringNotEmpty,
|
|
@@ -10,19 +19,19 @@ import { useTweakStyles } from '../../hooks';
|
|
|
10
19
|
import { ICommonProps } from '../../types';
|
|
11
20
|
import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
|
|
12
21
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
13
|
-
import {
|
|
14
|
-
import { controlWrapperStyles, ITextAreaStyles, useStyles } from './TextArea.styles';
|
|
22
|
+
import { ITextAreaStyles, useStyles } from './TextArea.styles';
|
|
15
23
|
|
|
16
24
|
export interface ITextAreaProps
|
|
17
25
|
extends ICommonProps<ITextAreaStyles>,
|
|
18
|
-
|
|
19
|
-
Pick<
|
|
20
|
-
|
|
26
|
+
Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'>,
|
|
27
|
+
Pick<
|
|
28
|
+
IControlWrapperProps,
|
|
29
|
+
'label' | 'isInvalid' | 'isRequired' | 'isDisabled' | 'size' | 'groupPlacement'
|
|
30
|
+
>,
|
|
31
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {
|
|
21
32
|
value?: string;
|
|
22
33
|
placeholder?: string;
|
|
23
34
|
/** @default false */
|
|
24
|
-
isDisabled?: boolean;
|
|
25
|
-
/** @default false */
|
|
26
35
|
isActive?: boolean;
|
|
27
36
|
/**
|
|
28
37
|
* Должна ли высота и ширина textarea подстраиваться под содержимое
|
|
@@ -46,17 +55,13 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
46
55
|
(
|
|
47
56
|
{
|
|
48
57
|
value = DEFAULT_VALUE,
|
|
49
|
-
label,
|
|
50
58
|
placeholder,
|
|
51
|
-
infoMessage,
|
|
52
|
-
errorMessage,
|
|
53
59
|
name,
|
|
54
60
|
shouldFocusOnMount,
|
|
55
61
|
hasCounter = true,
|
|
56
62
|
shouldTrimAfterMaxLength,
|
|
57
63
|
isAutoSized = true,
|
|
58
64
|
shouldAlwaysShowPlaceholder,
|
|
59
|
-
isDisabled,
|
|
60
65
|
isActive,
|
|
61
66
|
maxLength,
|
|
62
67
|
rows,
|
|
@@ -67,7 +72,17 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
67
72
|
onPaste,
|
|
68
73
|
onFocus,
|
|
69
74
|
onBlur,
|
|
70
|
-
|
|
75
|
+
// Пропсы WithMessages
|
|
76
|
+
infoMessage,
|
|
77
|
+
errorMessage,
|
|
78
|
+
// Пропсы ControlWrapper
|
|
79
|
+
label,
|
|
80
|
+
isDisabled,
|
|
81
|
+
isInvalid,
|
|
82
|
+
isRequired,
|
|
83
|
+
size,
|
|
84
|
+
groupPlacement,
|
|
85
|
+
...textAreaProps
|
|
71
86
|
},
|
|
72
87
|
ref,
|
|
73
88
|
) => {
|
|
@@ -80,7 +95,6 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
80
95
|
});
|
|
81
96
|
|
|
82
97
|
const tweakControlWrapperStyles = useTweakStyles({
|
|
83
|
-
innerStyles: controlWrapperStyles,
|
|
84
98
|
tweakStyles,
|
|
85
99
|
className: 'tweakControlWrapper',
|
|
86
100
|
currentComponentName: 'TextArea',
|
|
@@ -89,8 +103,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
89
103
|
const [isFocused, setFocused] = useState(false);
|
|
90
104
|
|
|
91
105
|
const hasFocus = isFocused || isActive;
|
|
92
|
-
|
|
93
|
-
const hasValue = value !== undefined && value !== '';
|
|
106
|
+
const hasValue = isArrayLikeNotEmpty(value);
|
|
94
107
|
const hasLabel = isReactNodeNotEmpty(label);
|
|
95
108
|
const hasPlaceholder =
|
|
96
109
|
(!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
|
|
@@ -114,6 +127,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
114
127
|
errorMessage={errorMessage}
|
|
115
128
|
infoMessage={infoMessage}
|
|
116
129
|
tweakStyles={tweakWithMessagesStyles}
|
|
130
|
+
testId={getTestId(testId, 'wrapper')}
|
|
117
131
|
>
|
|
118
132
|
<ControlWrapper
|
|
119
133
|
label={label}
|
|
@@ -121,12 +135,17 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
121
135
|
isFocused={hasFocus}
|
|
122
136
|
isDisabled={isDisabled}
|
|
123
137
|
hasValue={hasValue}
|
|
138
|
+
isInvalid={isInvalid}
|
|
139
|
+
isRequired={isRequired}
|
|
140
|
+
groupPlacement={groupPlacement}
|
|
141
|
+
size={size}
|
|
124
142
|
isFullWidth
|
|
125
|
-
testId={testId}
|
|
126
|
-
{...controlProps}
|
|
127
143
|
>
|
|
128
144
|
<div
|
|
129
|
-
className={clsx(classes.wrapper, {
|
|
145
|
+
className={clsx(classes.wrapper, {
|
|
146
|
+
[classes.autoSized]: isAutoSized,
|
|
147
|
+
[classes.withLabel]: hasLabel,
|
|
148
|
+
})}
|
|
130
149
|
{...(isAutoSized && { 'data-value': value })}
|
|
131
150
|
>
|
|
132
151
|
<textarea
|
|
@@ -142,7 +161,9 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
142
161
|
onFocus={handleFocus}
|
|
143
162
|
onBlur={handleBlur}
|
|
144
163
|
onChange={handleChange}
|
|
145
|
-
{
|
|
164
|
+
autoFocus={shouldFocusOnMount}
|
|
165
|
+
{...addDataAttributes(data, testId)}
|
|
166
|
+
{...textAreaProps}
|
|
146
167
|
/>
|
|
147
168
|
</div>
|
|
148
169
|
</ControlWrapper>
|
|
@@ -8,7 +8,7 @@ import { useStyles, ITooltipStyles } from './Tooltip.styles';
|
|
|
8
8
|
export interface ITooltipProps extends ICommonProps<ITooltipStyles> {
|
|
9
9
|
text: ReactNode;
|
|
10
10
|
/** @default 'tooltip' */
|
|
11
|
-
view?: 'tooltip' | 'hint';
|
|
11
|
+
view?: 'tooltip' | 'hint' | 'custom';
|
|
12
12
|
/** @default 'info' */
|
|
13
13
|
type?: 'info' | 'error';
|
|
14
14
|
}
|