@true-engineering/true-react-common-ui-kit 4.0.0-alpha3 → 4.0.0-alpha30
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 -607
- 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 +4 -2
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
- package/dist/components/ControlWrapper/helpers.d.ts +4 -0
- package/dist/components/ControlWrapper/index.d.ts +2 -0
- package/dist/components/ControlWrapper/types.d.ts +12 -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/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
- package/dist/components/FiltersPane/types.d.ts +16 -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 +20 -12
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -3
- 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 +5 -5
- package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -1
- 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 +4 -5
- package/dist/components/TextArea/TextArea.styles.d.ts +5 -4
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextArea/types.d.ts +4 -2
- 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 +11 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-intersection-ref.d.ts +8 -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/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 +7593 -6483
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7618 -6509
- 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.stories.tsx +8 -3
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
- package/src/components/ControlWrapper/ControlWrapper.tsx +31 -20
- package/src/components/ControlWrapper/helpers.ts +11 -0
- package/src/components/ControlWrapper/index.ts +2 -0
- package/src/components/ControlWrapper/types.ts +16 -0
- package/src/components/DateInput/DateInput.stories.tsx +0 -1
- package/src/components/DatePicker/DatePicker.stories.tsx +24 -11
- package/src/components/DatePicker/DatePicker.styles.ts +3 -1
- package/src/components/DatePicker/DatePicker.tsx +18 -10
- 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 +28 -19
- package/src/components/FiltersPane/components/Filter/Filter.tsx +36 -30
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterSelect/FilterSelect.tsx +22 -23
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +2 -1
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +4 -3
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +14 -10
- package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +5 -0
- package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.tsx +16 -19
- package/src/components/FiltersPane/types.ts +24 -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 +40 -63
- 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 +20 -16
- package/src/components/IncrementInput/IncrementInput.stories.tsx +2 -0
- package/src/components/IncrementInput/IncrementInput.styles.ts +31 -39
- package/src/components/IncrementInput/IncrementInput.tsx +28 -25
- package/src/components/Input/Input.stories.tsx +1 -6
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/InputBase.tsx +27 -25
- 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/MultiSelectList/MultiSelectList.tsx +15 -11
- 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/CustomSelect.stories.tsx +1 -0
- package/src/components/Select/MultiSelect.stories.tsx +5 -0
- package/src/components/Select/Select.stories.tsx +6 -0
- package/src/components/Select/Select.styles.ts +5 -40
- package/src/components/Select/Select.tsx +36 -22
- package/src/components/Select/components/SelectList/SelectList.tsx +4 -2
- package/src/components/Select/components/SelectListItem/SelectListItem.tsx +5 -2
- 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.stories.tsx +15 -1
- package/src/components/TextArea/TextArea.styles.ts +15 -8
- package/src/components/TextArea/TextArea.tsx +96 -62
- package/src/components/TextArea/index.ts +1 -1
- package/src/components/TextArea/types.ts +5 -5
- 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/WithMessages/WithMessages.stories.tsx +1 -1
- package/src/components/WithPopup/WithPopup.tsx +36 -15
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-intersection-ref.ts +30 -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/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/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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode, useEffect, useState } from 'react';
|
|
2
2
|
import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
3
3
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
4
|
+
import { iconsList } from '../Icon';
|
|
4
5
|
import { ISelectProps, Select } from './Select';
|
|
5
6
|
|
|
6
7
|
interface ObjectValue {
|
|
@@ -54,6 +55,8 @@ const objectOptions: ObjectValue[] = [
|
|
|
54
55
|
{ name: 'Artem', age: 23 },
|
|
55
56
|
];
|
|
56
57
|
|
|
58
|
+
const icons = [undefined, ...Object.keys(iconsList)];
|
|
59
|
+
|
|
57
60
|
// Максимум не включается, минимум включается
|
|
58
61
|
const getRandomInt = (min: number, max: number) =>
|
|
59
62
|
Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
|
|
@@ -192,6 +195,7 @@ export default {
|
|
|
192
195
|
control: 'inline-radio',
|
|
193
196
|
options: ['strings', 'objects'],
|
|
194
197
|
},
|
|
198
|
+
icon: { control: 'select', options: icons },
|
|
195
199
|
},
|
|
196
200
|
} as ComponentMeta<typeof SelectWithCustomProps>;
|
|
197
201
|
|
|
@@ -213,6 +217,7 @@ Default.args = {
|
|
|
213
217
|
isClearable: false,
|
|
214
218
|
isLoading: false,
|
|
215
219
|
debounceTime: 400,
|
|
220
|
+
icon: undefined,
|
|
216
221
|
// custom options
|
|
217
222
|
shouldUseReactNodes: false,
|
|
218
223
|
valuesType: 'strings',
|
|
@@ -225,4 +230,5 @@ Default.args = {
|
|
|
225
230
|
shouldScrollToList: true,
|
|
226
231
|
canBeFlipped: false,
|
|
227
232
|
scrollParent: 'document',
|
|
233
|
+
size: undefined,
|
|
228
234
|
};
|
|
@@ -5,7 +5,7 @@ import { type ISearchInputStyles } from '../SearchInput';
|
|
|
5
5
|
import { IWithMessagesStyles } from '../WithMessages';
|
|
6
6
|
import { type ISelectListStyles } from './components';
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { Z_INDEX } = dimensions;
|
|
9
9
|
|
|
10
10
|
export const useStyles = createThemedStyles('Select', {
|
|
11
11
|
root: {
|
|
@@ -17,7 +17,6 @@ export const useStyles = createThemedStyles('Select', {
|
|
|
17
17
|
inputWrapper: {
|
|
18
18
|
width: '100%',
|
|
19
19
|
cursor: 'text',
|
|
20
|
-
position: 'relative',
|
|
21
20
|
},
|
|
22
21
|
|
|
23
22
|
listWrapper: {
|
|
@@ -40,20 +39,16 @@ export const useStyles = createThemedStyles('Select', {
|
|
|
40
39
|
},
|
|
41
40
|
|
|
42
41
|
arrow: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
top: '50%',
|
|
46
|
-
width: 20,
|
|
47
|
-
height: 20,
|
|
42
|
+
width: 'var(--icon-inner-size, 20px)',
|
|
43
|
+
height: 'var(--icon-inner-size, 20px)',
|
|
48
44
|
cursor: 'pointer',
|
|
49
|
-
transform: 'translateY(-50%)',
|
|
50
45
|
transition: animations.defaultTransition,
|
|
51
46
|
transitionProperty: 'transform',
|
|
52
47
|
zIndex: Z_INDEX.CONTROL_FOCUS + 1,
|
|
53
48
|
},
|
|
54
49
|
|
|
55
50
|
activeArrow: {
|
|
56
|
-
transform: '
|
|
51
|
+
transform: 'rotate(180deg)',
|
|
57
52
|
},
|
|
58
53
|
|
|
59
54
|
disabled: {
|
|
@@ -62,45 +57,15 @@ export const useStyles = createThemedStyles('Select', {
|
|
|
62
57
|
},
|
|
63
58
|
},
|
|
64
59
|
|
|
65
|
-
counter: {
|
|
66
|
-
'&:not(:last-child)': {
|
|
67
|
-
paddingRight: 8,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
icon: {
|
|
72
|
-
width: CONTROL.ICON_INNER_SIZE,
|
|
73
|
-
height: CONTROL.ICON_INNER_SIZE,
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
iconWrapper: {
|
|
77
|
-
display: 'flex',
|
|
78
|
-
alignItems: 'center',
|
|
79
|
-
},
|
|
60
|
+
counter: {},
|
|
80
61
|
});
|
|
81
62
|
|
|
82
63
|
const baseInputStyles: IInputStyles = {
|
|
83
|
-
inputContent: {
|
|
84
|
-
paddingRight: 32,
|
|
85
|
-
},
|
|
86
|
-
|
|
87
64
|
input: {
|
|
88
65
|
'&[readonly]': {
|
|
89
66
|
cursor: 'pointer',
|
|
90
67
|
},
|
|
91
68
|
},
|
|
92
|
-
|
|
93
|
-
tweakControlWrapper: {
|
|
94
|
-
controls: {
|
|
95
|
-
paddingRight: 40,
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
icon: {
|
|
99
|
-
'&:last-child': {
|
|
100
|
-
paddingRight: 0,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
69
|
};
|
|
105
70
|
|
|
106
71
|
const readonlyInputBaseStyles: IInputStyles = {
|
|
@@ -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,
|
|
@@ -17,6 +18,7 @@ import clsx from 'clsx';
|
|
|
17
18
|
import { debounce } from 'ts-debounce';
|
|
18
19
|
import {
|
|
19
20
|
createFilter,
|
|
21
|
+
getArray,
|
|
20
22
|
getTestId,
|
|
21
23
|
isNotEmpty,
|
|
22
24
|
isReactNodeNotEmpty,
|
|
@@ -63,7 +65,11 @@ export interface ISelectProps<Value>
|
|
|
63
65
|
/** @default true */
|
|
64
66
|
shouldScrollToList?: boolean;
|
|
65
67
|
isMultiSelect?: false;
|
|
66
|
-
searchInput?: {
|
|
68
|
+
searchInput?: {
|
|
69
|
+
/** @default false */
|
|
70
|
+
shouldRenderInList?: boolean;
|
|
71
|
+
ref?: Ref<HTMLInputElement>;
|
|
72
|
+
} & Pick<ISearchInputProps, 'placeholder' | 'shouldFocusOnMount'>;
|
|
67
73
|
isOptionDisabled?: (option: Value) => boolean;
|
|
68
74
|
onChange: (value: Value | undefined, event: IChangeSelectEvent) => void; // подумать как возвращать индекс
|
|
69
75
|
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
@@ -248,10 +254,14 @@ export function Select<Value>(
|
|
|
248
254
|
|
|
249
255
|
const handleListClose = useCallback(
|
|
250
256
|
(event: Event | SyntheticEvent) => {
|
|
257
|
+
if (!isListOpen) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
251
261
|
closeList();
|
|
252
262
|
onBlur?.(event);
|
|
253
263
|
},
|
|
254
|
-
[closeList, onBlur],
|
|
264
|
+
[isListOpen, closeList, onBlur],
|
|
255
265
|
);
|
|
256
266
|
|
|
257
267
|
const handleListOpen = () => {
|
|
@@ -566,21 +576,12 @@ export function Select<Value>(
|
|
|
566
576
|
</div>
|
|
567
577
|
);
|
|
568
578
|
|
|
569
|
-
const multiSelectCounterWithIcon =
|
|
570
|
-
shouldShowMultiSelectCounter || isNotEmpty(icon) ? (
|
|
571
|
-
<div className={classes.iconWrapper}>
|
|
572
|
-
{shouldShowMultiSelectCounter && (
|
|
573
|
-
<div className={classes.counter}>(+{value.length - 1})</div>
|
|
574
|
-
)}
|
|
575
|
-
{isNotEmpty(icon) && <div className={classes.icon}>{renderIcon(icon)}</div>}
|
|
576
|
-
</div>
|
|
577
|
-
) : undefined;
|
|
578
|
-
|
|
579
579
|
return (
|
|
580
580
|
<WithMessages
|
|
581
581
|
errorMessage={errorMessage}
|
|
582
582
|
infoMessage={infoMessage}
|
|
583
583
|
tweakStyles={tweakWithMessagesStyles}
|
|
584
|
+
testId={getTestId(testId, 'wrapper')}
|
|
584
585
|
>
|
|
585
586
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
586
587
|
<div
|
|
@@ -602,18 +603,31 @@ export function Select<Value>(
|
|
|
602
603
|
isLoading={areOptionsLoading}
|
|
603
604
|
tweakStyles={tweakInputStyles}
|
|
604
605
|
testId={testId}
|
|
605
|
-
icon={
|
|
606
|
+
icon={[
|
|
607
|
+
isMultiSelect && shouldShowMultiSelectCounter
|
|
608
|
+
? {
|
|
609
|
+
key: 'counter',
|
|
610
|
+
iconComponent: (
|
|
611
|
+
<div key="counter" className={classes.counter}>
|
|
612
|
+
(+{value.length - 1})
|
|
613
|
+
</div>
|
|
614
|
+
),
|
|
615
|
+
shouldResetSize: true,
|
|
616
|
+
}
|
|
617
|
+
: undefined,
|
|
618
|
+
|
|
619
|
+
...getArray(icon),
|
|
620
|
+
|
|
621
|
+
<div
|
|
622
|
+
key="arrow"
|
|
623
|
+
className={clsx(classes.arrow, isOpen && classes.activeArrow)}
|
|
624
|
+
onClick={onArrowClick} // клик тут, потому что onClick в ControlWrapper добавляет tabIndex={0}
|
|
625
|
+
>
|
|
626
|
+
{renderIcon(dropdownIcon)}
|
|
627
|
+
</div>,
|
|
628
|
+
].filter(isNotEmpty)}
|
|
606
629
|
{...inputProps}
|
|
607
630
|
/>
|
|
608
|
-
<div
|
|
609
|
-
onMouseDown={(event: MouseEvent) => {
|
|
610
|
-
event.preventDefault();
|
|
611
|
-
}}
|
|
612
|
-
onClick={onArrowClick}
|
|
613
|
-
className={clsx(classes.arrow, isOpen && classes.activeArrow)}
|
|
614
|
-
>
|
|
615
|
-
{renderIcon(dropdownIcon)}
|
|
616
|
-
</div>
|
|
617
631
|
</div>
|
|
618
632
|
{shouldUsePopper ? (
|
|
619
633
|
<Portal container={shouldRenderInBody ? document.body : inputWrapper.current}>
|
|
@@ -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
|
) : (
|
|
@@ -119,8 +119,9 @@ export function SelectList<Value>({
|
|
|
119
119
|
)}
|
|
120
120
|
{listOptions.map((opt, i) => {
|
|
121
121
|
const optionValue = options[i];
|
|
122
|
+
const id = convertValueToId(optionValue);
|
|
122
123
|
const isFocused = focusedIndex === i;
|
|
123
|
-
const isActive = activeOptionsIds.has(
|
|
124
|
+
const isActive = activeOptionsIds.has(id);
|
|
124
125
|
// проверяем, что опция задизейблена
|
|
125
126
|
const isDisabled = optionsDisableMap[i];
|
|
126
127
|
|
|
@@ -135,6 +136,7 @@ export function SelectList<Value>({
|
|
|
135
136
|
isMultiSelect={isMultiSelect}
|
|
136
137
|
onOptionSelect={onOptionSelect}
|
|
137
138
|
onToggleCheckbox={onToggleCheckbox}
|
|
139
|
+
data={{ id }}
|
|
138
140
|
>
|
|
139
141
|
{opt}
|
|
140
142
|
</SelectListItem>
|
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { type Classes } from 'jss';
|
|
10
|
-
import { addDataAttributes } from '
|
|
10
|
+
import { addDataAttributes } from '@true-engineering/true-react-platform-helpers';
|
|
11
|
+
import { IDataAttributesProps } from '../../../../types';
|
|
11
12
|
import { Checkbox } from '../../../Checkbox';
|
|
12
13
|
import { ScrollIntoViewIfNeeded } from '../../../ScrollIntoViewIfNeeded';
|
|
13
14
|
import { checkboxStyles } from './SelectListItem.styles';
|
|
14
15
|
|
|
15
|
-
export interface ISelectListItemProps {
|
|
16
|
+
export interface ISelectListItemProps extends IDataAttributesProps {
|
|
16
17
|
index: number;
|
|
17
18
|
isSemiChecked?: boolean;
|
|
18
19
|
isDisabled?: boolean;
|
|
@@ -38,6 +39,7 @@ export const SelectListItem: FC<ISelectListItemProps> = ({
|
|
|
38
39
|
children,
|
|
39
40
|
isFocused,
|
|
40
41
|
isMultiSelect,
|
|
42
|
+
data,
|
|
41
43
|
onOptionSelect,
|
|
42
44
|
onToggleCheckbox,
|
|
43
45
|
}) => {
|
|
@@ -67,6 +69,7 @@ export const SelectListItem: FC<ISelectListItemProps> = ({
|
|
|
67
69
|
disabled: isDisabled,
|
|
68
70
|
active: isActive,
|
|
69
71
|
focused: isFocused,
|
|
72
|
+
...data,
|
|
70
73
|
})}
|
|
71
74
|
onClick={!isDisabled && !isMultiSelect ? (event) => onOptionSelect(index, event) : undefined}
|
|
72
75
|
>
|
|
@@ -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,7 +1,10 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { IExtendableProps } from '../../types';
|
|
3
4
|
import { TextArea } from './TextArea';
|
|
4
5
|
|
|
6
|
+
const COUNTER_POSITIONS = ['default', 'top'] as const;
|
|
7
|
+
|
|
5
8
|
export default {
|
|
6
9
|
title: 'Inputs/TextArea',
|
|
7
10
|
component: TextArea,
|
|
@@ -12,9 +15,14 @@ export default {
|
|
|
12
15
|
},
|
|
13
16
|
};
|
|
14
17
|
|
|
18
|
+
declare module './types' {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
20
|
+
export interface ITextAreaCounterPositions extends IExtendableProps<typeof COUNTER_POSITIONS> {}
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
const Template: ComponentStory<typeof TextArea> = (args) => {
|
|
16
24
|
const [value, setValue] = useState('');
|
|
17
|
-
return <TextArea {...args} value={value} onChange={
|
|
25
|
+
return <TextArea {...args} value={value} onChange={setValue} />;
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
export const Default = Template.bind({});
|
|
@@ -26,10 +34,16 @@ Default.args = {
|
|
|
26
34
|
rows: 5,
|
|
27
35
|
maxLength: 500,
|
|
28
36
|
isInvalid: false,
|
|
37
|
+
counterPosition: 'default',
|
|
29
38
|
errorMessage: 'Error Text',
|
|
30
39
|
isActive: false,
|
|
31
40
|
isDisabled: false,
|
|
32
41
|
isRequired: false,
|
|
33
42
|
isAutoSized: true,
|
|
34
43
|
shouldAlwaysShowPlaceholder: false,
|
|
44
|
+
size: undefined,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Default.argTypes = {
|
|
48
|
+
counterPosition: { options: [undefined, ...COUNTER_POSITIONS], control: 'select' },
|
|
35
49
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { animations, createThemedStyles, helpers, ITweakStyles } from '../../theme';
|
|
2
|
-
import {
|
|
2
|
+
import { IWithPrefix } from '../../types';
|
|
3
|
+
import { IControlWrapperSizes, IControlWrapperStyles } from '../ControlWrapper';
|
|
3
4
|
import { IWithMessagesStyles } from '../WithMessages';
|
|
5
|
+
import { ITextAreaCounterPositions } from './types';
|
|
4
6
|
|
|
5
7
|
export const useStyles = createThemedStyles('TextArea', {
|
|
8
|
+
root: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
},
|
|
11
|
+
|
|
6
12
|
textarea: {
|
|
7
13
|
...helpers.withScrollBar,
|
|
8
14
|
width: '100%',
|
|
@@ -65,18 +71,19 @@ export const useStyles = createThemedStyles('TextArea', {
|
|
|
65
71
|
symbolsCountError: {
|
|
66
72
|
color: 'red',
|
|
67
73
|
},
|
|
68
|
-
});
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
+
symbolsCountActive: {},
|
|
76
|
+
|
|
77
|
+
'counter-default': {},
|
|
78
|
+
|
|
79
|
+
withLabel: {},
|
|
80
|
+
});
|
|
75
81
|
|
|
76
82
|
export type ITextAreaStyles = ITweakStyles<
|
|
77
83
|
typeof useStyles,
|
|
78
84
|
{
|
|
79
85
|
tweakWithMessages: IWithMessagesStyles;
|
|
80
86
|
tweakControlWrapper: IControlWrapperStyles;
|
|
81
|
-
}
|
|
87
|
+
} & IWithPrefix<ITextAreaCounterPositions, 'counter-'> &
|
|
88
|
+
IControlWrapperSizes
|
|
82
89
|
>;
|