@true-engineering/true-react-common-ui-kit 2.3.1 → 2.3.2
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/LICENSE +201 -201
- package/README.md +12 -0
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/FiltersPane/FilterSelect/FilterSelect.d.ts +1 -1
- package/dist/components/FiltersPane/FiltersPane.d.ts +1 -1
- package/dist/components/Flag/augment.d.ts +1 -1
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +1 -1
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/Icon/complexIcons/augment.d.ts +1 -1
- package/dist/components/MultiSelectList/MultiSelectList.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +577 -577
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +577 -577
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/vite-env.d.ts +1 -1
- package/package.json +93 -93
- package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
- package/src/components/AccountInfo/AccountInfo.styles.ts +55 -55
- package/src/components/AccountInfo/AccountInfo.tsx +77 -77
- package/src/components/AccountInfo/index.ts +2 -2
- package/src/components/AddButton/AddButton.stories.tsx +21 -21
- package/src/components/AddButton/AddButton.styles.ts +34 -34
- package/src/components/AddButton/AddButton.tsx +48 -48
- package/src/components/AddButton/index.ts +2 -2
- package/src/components/Button/Button.stories.tsx +52 -52
- package/src/components/Button/Button.styles.ts +196 -196
- package/src/components/Button/Button.tsx +167 -167
- package/src/components/Button/index.ts +2 -2
- package/src/components/Checkbox/Checkbox.stories.tsx +32 -32
- package/src/components/Checkbox/Checkbox.styles.ts +62 -62
- package/src/components/Checkbox/Checkbox.tsx +105 -105
- package/src/components/Checkbox/index.ts +2 -2
- package/src/components/CloseButton/CloseButton.styles.ts +34 -34
- package/src/components/CloseButton/CloseButton.tsx +35 -35
- package/src/components/CloseButton/index.ts +2 -2
- package/src/components/Colors/Colors.stories.tsx +7 -7
- package/src/components/Colors/Colors.styles.ts +38 -38
- package/src/components/Colors/Colors.tsx +26 -26
- package/src/components/Colors/index.ts +2 -2
- package/src/components/CssBaseline/CssBaseline.styles.ts +15 -15
- package/src/components/CssBaseline/CssBaseline.tsx +15 -15
- package/src/components/CssBaseline/index.ts +2 -2
- package/src/components/DateInput/DateInput.stories.tsx +61 -61
- package/src/components/DateInput/DateInput.styles.ts +14 -14
- package/src/components/DateInput/DateInput.tsx +82 -82
- package/src/components/DateInput/constants.ts +2 -2
- package/src/components/DateInput/index.ts +3 -3
- package/src/components/DatePicker/DatePicker.stories.tsx +87 -87
- package/src/components/DatePicker/DatePicker.styles.ts +44 -44
- package/src/components/DatePicker/DatePicker.tsx +327 -327
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.styles.ts +84 -84
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.tsx +79 -79
- package/src/components/DatePicker/DatePickerHeader/index.ts +2 -2
- package/src/components/DatePicker/constants.ts +1 -1
- package/src/components/DatePicker/helpers.ts +23 -23
- package/src/components/DatePicker/index.ts +3 -3
- package/src/components/DatePicker/types.ts +45 -45
- package/src/components/Description/Description.stories.tsx +27 -27
- package/src/components/Description/Description.styles.ts +31 -31
- package/src/components/Description/Description.tsx +60 -60
- package/src/components/Description/index.ts +2 -2
- package/src/components/FiltersPane/FilterInterval/FilterInterval.styles.ts +64 -64
- package/src/components/FiltersPane/FilterInterval/FilterInterval.tsx +143 -143
- package/src/components/FiltersPane/FilterInterval/index.ts +1 -1
- package/src/components/FiltersPane/FilterMultiSelect/FilterMultiSelect.tsx +10 -10
- package/src/components/FiltersPane/FilterMultiSelect/index.ts +1 -1
- package/src/components/FiltersPane/FilterSelect/FilterSelect.styles.ts +143 -143
- package/src/components/FiltersPane/FilterSelect/FilterSelect.tsx +348 -348
- package/src/components/FiltersPane/FilterSelect/index.ts +1 -1
- package/src/components/FiltersPane/FilterSelect/locales.ts +37 -37
- package/src/components/FiltersPane/FilterValueView/FilterValueView.styles.tsx +15 -15
- package/src/components/FiltersPane/FilterValueView/FilterValueView.tsx +166 -166
- package/src/components/FiltersPane/FilterValueView/index.tsx +1 -1
- package/src/components/FiltersPane/FilterWithDates/FilterWithDates.styles.ts +60 -60
- package/src/components/FiltersPane/FilterWithDates/FilterWithDates.tsx +184 -184
- package/src/components/FiltersPane/FilterWithDates/index.ts +1 -1
- package/src/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.styles.ts +17 -17
- package/src/components/FiltersPane/FilterWithPeriod/FilterWithPeriod.tsx +198 -198
- package/src/components/FiltersPane/FilterWithPeriod/index.ts +1 -1
- package/src/components/FiltersPane/FilterWrapper/FilterWrapper.styles.ts +110 -110
- package/src/components/FiltersPane/FilterWrapper/FilterWrapper.tsx +346 -346
- package/src/components/FiltersPane/FilterWrapper/index.ts +1 -1
- package/src/components/FiltersPane/FiltersPane.stories.tsx +295 -295
- package/src/components/FiltersPane/FiltersPane.styles.ts +71 -71
- package/src/components/FiltersPane/FiltersPane.tsx +151 -151
- package/src/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.styles.ts +109 -109
- package/src/components/FiltersPane/FiltersPaneSearch/FiltersPaneSearch.tsx +155 -155
- package/src/components/FiltersPane/FiltersPaneSearch/index.ts +1 -1
- package/src/components/FiltersPane/index.ts +20 -20
- package/src/components/FiltersPane/locales.ts +107 -107
- package/src/components/FiltersPane/types.ts +112 -112
- package/src/components/Flag/Flag.stories.tsx +29 -29
- package/src/components/Flag/Flag.styles.ts +18 -18
- package/src/components/Flag/Flag.tsx +27 -27
- package/src/components/Flag/augment.d.ts +1 -1
- package/src/components/Flag/index.ts +2 -2
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +84 -84
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +131 -131
- package/src/components/FlexibleTable/FlexibleTable.tsx +205 -205
- package/src/components/FlexibleTable/TableRow.tsx +152 -152
- package/src/components/FlexibleTable/TableValue.tsx +75 -75
- package/src/components/FlexibleTable/fixture-test.ts +254 -254
- package/src/components/FlexibleTable/index.ts +3 -3
- package/src/components/FlexibleTable/types.ts +52 -52
- package/src/components/Icon/ComplexIconBoilerplate.tsx +17 -17
- package/src/components/Icon/Icon.stories.tsx +85 -85
- package/src/components/Icon/Icon.styles.ts +10 -10
- package/src/components/Icon/Icon.tsx +32 -32
- package/src/components/Icon/IconBoilerplate.tsx +42 -42
- package/src/components/Icon/complexIcons/augment.d.ts +1 -1
- package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
- package/src/components/Icon/complexIcons/icons.ts +7 -7
- package/src/components/Icon/complexIcons/index.ts +1 -1
- package/src/components/Icon/icons/icons.ts +838 -838
- package/src/components/Icon/icons/index.ts +1 -1
- package/src/components/Icon/index.ts +4 -4
- package/src/components/IncrementInput/ChangeButton.tsx +33 -33
- package/src/components/IncrementInput/IncrementInput.stories.tsx +31 -31
- package/src/components/IncrementInput/IncrementInput.styles.ts +77 -77
- package/src/components/IncrementInput/IncrementInput.tsx +80 -80
- package/src/components/IncrementInput/index.ts +2 -2
- package/src/components/Input/Input.stories.tsx +86 -86
- package/src/components/Input/Input.styles.ts +307 -307
- package/src/components/Input/Input.tsx +311 -311
- package/src/components/Input/index.ts +2 -2
- package/src/components/List/List.stories.tsx +62 -62
- package/src/components/List/List.styles.ts +52 -52
- package/src/components/List/List.tsx +64 -64
- package/src/components/List/index.ts +2 -2
- package/src/components/Modal/Modal.stories.tsx +105 -105
- package/src/components/Modal/Modal.styles.ts +305 -305
- package/src/components/Modal/Modal.tsx +200 -200
- package/src/components/Modal/index.ts +2 -2
- package/src/components/MoreMenu/MoreMenu.stories.tsx +46 -46
- package/src/components/MoreMenu/MoreMenu.styles.ts +70 -70
- package/src/components/MoreMenu/MoreMenu.tsx +90 -90
- package/src/components/MoreMenu/index.ts +2 -2
- package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
- package/src/components/MultiSelect/MultiSelect.styles.ts +55 -55
- package/src/components/MultiSelect/MultiSelect.tsx +89 -89
- package/src/components/MultiSelect/MultiSelectInput/MultiSelectInput.styles.ts +73 -73
- package/src/components/MultiSelect/MultiSelectInput/MultiSelectInput.tsx +51 -51
- package/src/components/MultiSelect/MultiSelectInput/index.ts +1 -1
- package/src/components/MultiSelect/index.ts +3 -3
- package/src/components/MultiSelectList/MultiSelectList.styles.ts +124 -124
- package/src/components/MultiSelectList/MultiSelectList.tsx +451 -451
- package/src/components/MultiSelectList/index.ts +2 -2
- package/src/components/MultiSelectList/locales.ts +37 -37
- package/src/components/Notification/Notification.stories.tsx +46 -46
- package/src/components/Notification/Notification.styles.ts +50 -50
- package/src/components/Notification/Notification.tsx +79 -79
- package/src/components/Notification/index.ts +2 -2
- package/src/components/NumberInput/NumberInput.stories.tsx +35 -35
- package/src/components/NumberInput/NumberInput.tsx +133 -133
- package/src/components/NumberInput/helpers.ts +86 -86
- package/src/components/NumberInput/index.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +70 -70
- package/src/components/PhoneInput/PhoneInput.styles.ts +84 -84
- package/src/components/PhoneInput/PhoneInput.tsx +194 -194
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.stories.tsx +21 -21
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.styles.ts +100 -100
- package/src/components/PhoneInput/PhoneInputCountryList/PhoneInputCountryList.tsx +147 -147
- package/src/components/PhoneInput/PhoneInputCountryList/index.ts +2 -2
- package/src/components/PhoneInput/index.ts +6 -6
- package/src/components/PhoneInput/phone-info.ts +2147 -2147
- package/src/components/PhoneInput/types.ts +16 -16
- package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
- package/src/components/RadioButton/RadioButton.styles.ts +37 -37
- package/src/components/RadioButton/RadioButton.tsx +55 -55
- package/src/components/RadioButton/index.ts +2 -2
- package/src/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.ts +61 -61
- package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +23 -23
- package/src/components/SearchInput/SearchInput.styles.ts +50 -50
- package/src/components/SearchInput/SearchInput.tsx +50 -50
- package/src/components/SearchInput/index.ts +2 -2
- package/src/components/Select/MultiSelect.stories.tsx +240 -240
- package/src/components/Select/Select.stories.tsx +235 -235
- package/src/components/Select/Select.styles.ts +96 -96
- package/src/components/Select/Select.tsx +575 -575
- package/src/components/Select/SelectList/SelectList.styles.ts +72 -72
- package/src/components/Select/SelectList/SelectList.tsx +158 -158
- package/src/components/Select/SelectList/index.ts +1 -1
- package/src/components/Select/SelectListItem/SelectListItem.styles.ts +14 -14
- package/src/components/Select/SelectListItem/SelectListItem.tsx +68 -68
- package/src/components/Select/constants.ts +2 -2
- package/src/components/Select/helpers.ts +26 -26
- package/src/components/Select/index.ts +4 -4
- package/src/components/Select/types.ts +1 -1
- package/src/components/SmartInput/SmartInput.stories.tsx +50 -50
- package/src/components/SmartInput/SmartInput.tsx +147 -147
- package/src/components/SmartInput/helpers.ts +85 -85
- package/src/components/SmartInput/index.ts +1 -1
- package/src/components/Switch/Switch.stories.tsx +40 -40
- package/src/components/Switch/Switch.styles.ts +75 -75
- package/src/components/Switch/Switch.tsx +83 -83
- package/src/components/Switch/index.ts +2 -2
- package/src/components/TextArea/TextArea.stories.tsx +35 -35
- package/src/components/TextArea/TextArea.styles.ts +153 -153
- package/src/components/TextArea/TextArea.tsx +165 -165
- package/src/components/TextArea/index.ts +2 -2
- package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
- package/src/components/TextWithInfo/TextWithInfo.styles.ts +60 -60
- package/src/components/TextWithInfo/TextWithInfo.tsx +60 -60
- package/src/components/TextWithInfo/index.ts +2 -2
- package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
- package/src/components/TextWithTooltip/TextWithTooltip.styles.ts +19 -19
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +143 -143
- package/src/components/TextWithTooltip/index.ts +2 -2
- package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
- package/src/components/ThemedPreloader/ThemedPreloader.styles.ts +21 -21
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +50 -50
- package/src/components/ThemedPreloader/components/DefaultPreloader/DefaultPreloader.tsx +29 -29
- package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
- package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.ts +54 -54
- package/src/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.tsx +18 -18
- package/src/components/ThemedPreloader/components/DotsPreloader/index.ts +2 -2
- package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.ts +11 -11
- package/src/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.tsx +25 -25
- package/src/components/ThemedPreloader/components/SvgPreloader/index.ts +2 -2
- package/src/components/ThemedPreloader/components/index.ts +2 -2
- package/src/components/ThemedPreloader/index.ts +2 -2
- package/src/components/Toaster/Toaster.stories.tsx +30 -30
- package/src/components/Toaster/Toaster.styles.ts +59 -59
- package/src/components/Toaster/Toaster.tsx +110 -110
- package/src/components/Toaster/index.ts +2 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
- package/src/components/Tooltip/Tooltip.styles.ts +45 -45
- package/src/components/Tooltip/Tooltip.tsx +35 -35
- package/src/components/Tooltip/index.ts +3 -3
- package/src/components/Tooltip/types.ts +1 -1
- package/src/components/index.ts +36 -36
- package/src/helpers/deprecated.ts +23 -23
- package/src/helpers/index.ts +4 -4
- package/src/helpers/misc.ts +158 -158
- package/src/helpers/phone.ts +87 -87
- package/src/helpers/popper-helpers.ts +17 -17
- package/src/helpers/snippets.tsx +6 -6
- package/src/hooks/index.ts +6 -6
- package/src/hooks/use-did-mount-effect.ts +18 -18
- package/src/hooks/use-dropdown.ts +82 -82
- package/src/hooks/use-is-mounted.ts +15 -15
- package/src/hooks/use-on-click-outside.ts +77 -77
- package/src/hooks/use-theme.ts +32 -32
- package/src/hooks/use-tweak-styles.ts +13 -13
- package/src/index.ts +6 -6
- package/src/theme.ts +149 -149
- package/src/types.ts +107 -107
- package/src/vite-env.d.ts +1 -1
|
@@ -1,346 +1,346 @@
|
|
|
1
|
-
import { useState, useRef, useMemo, useLayoutEffect, RefObject } from 'react';
|
|
2
|
-
import { CSSTransition } from 'react-transition-group';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { Classes } from 'jss';
|
|
5
|
-
import { useTheme, useOnClickOutsideWithRef } from '../../../hooks';
|
|
6
|
-
import { Icon } from '../../Icon';
|
|
7
|
-
import { FilterInterval } from '../FilterInterval';
|
|
8
|
-
import { FilterMultiSelect } from '../FilterMultiSelect';
|
|
9
|
-
import { FilterSelect } from '../FilterSelect';
|
|
10
|
-
import { FilterValueView } from '../FilterValueView';
|
|
11
|
-
import { FilterWithDates } from '../FilterWithDates';
|
|
12
|
-
import { FilterWithPeriod } from '../FilterWithPeriod';
|
|
13
|
-
import { IFilterLocaleKey, getLocale, IPartialFilterLocale } from '../locales';
|
|
14
|
-
import { ConfigItem, IFilterMultiSelectValues, IFilterWithDatesValue, IPeriod } from '../types';
|
|
15
|
-
import { FilterWrapperStyles, styles } from './FilterWrapper.styles';
|
|
16
|
-
|
|
17
|
-
export interface IFilterWrapperProps<Values, Key extends keyof Values> {
|
|
18
|
-
tweakStyles?: FilterWrapperStyles;
|
|
19
|
-
filter: ConfigItem<Values[Key]>;
|
|
20
|
-
value?: Values[Key];
|
|
21
|
-
onChange: <V>(value: V) => void;
|
|
22
|
-
isDisabled?: boolean;
|
|
23
|
-
localeKey?: IFilterLocaleKey;
|
|
24
|
-
locale?: IPartialFilterLocale;
|
|
25
|
-
testId?: string;
|
|
26
|
-
filtersPaneRef: RefObject<HTMLDivElement> | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface IFilterOtherProps<Values, Key extends keyof Values>
|
|
30
|
-
extends IFilterWrapperProps<Values, Key> {
|
|
31
|
-
parentRef?: RefObject<HTMLElement>;
|
|
32
|
-
isInline?: boolean;
|
|
33
|
-
onChange: <V>(v: V) => void;
|
|
34
|
-
onClose?: () => void;
|
|
35
|
-
filtersPaneRef: RefObject<HTMLDivElement> | null;
|
|
36
|
-
classes: Classes<'left' | 'right' | 'dropdown'>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function FilterWrapper<Values, Key extends keyof Values>({
|
|
40
|
-
filter,
|
|
41
|
-
value,
|
|
42
|
-
isDisabled,
|
|
43
|
-
onChange,
|
|
44
|
-
locale,
|
|
45
|
-
localeKey,
|
|
46
|
-
testId,
|
|
47
|
-
filtersPaneRef,
|
|
48
|
-
tweakStyles,
|
|
49
|
-
}: IFilterWrapperProps<Values, Key>): JSX.Element {
|
|
50
|
-
const { classes } = useTheme('FilterWrapper', styles, tweakStyles);
|
|
51
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
-
const refItem = useRef<HTMLDivElement>(null);
|
|
53
|
-
|
|
54
|
-
const { type } = filter;
|
|
55
|
-
|
|
56
|
-
let hasValue = false;
|
|
57
|
-
|
|
58
|
-
if (Array.isArray(value) && value.length > 0) {
|
|
59
|
-
hasValue = true;
|
|
60
|
-
} else if (
|
|
61
|
-
typeof value === 'object' &&
|
|
62
|
-
Object.values(value as unknown as Record<any, any>).some((v) =>
|
|
63
|
-
Array.isArray(v) ? v.length > 0 : Boolean(v),
|
|
64
|
-
)
|
|
65
|
-
) {
|
|
66
|
-
hasValue = true;
|
|
67
|
-
} else if (!Array.isArray(value) && typeof value !== 'object') {
|
|
68
|
-
hasValue = Boolean(value);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Для того, чтобы фильтр закрывался, если мы работаем с простыми значениями, типа селекта
|
|
72
|
-
function handleChange<V>(v: V) {
|
|
73
|
-
if (type === 'select') {
|
|
74
|
-
setIsOpen(false);
|
|
75
|
-
}
|
|
76
|
-
onChange(v);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const handleLabelClick = () => {
|
|
80
|
-
if (!isBoolean && !isDisabled) {
|
|
81
|
-
setIsOpen(!isOpen);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (isBoolean) {
|
|
85
|
-
onChange(!value);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const handleOnClose = () => {
|
|
90
|
-
setIsOpen(false);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const isBoolean = filter.type === 'boolean';
|
|
94
|
-
|
|
95
|
-
return !filter.isInline ? (
|
|
96
|
-
<div
|
|
97
|
-
className={clsx(classes.root, {
|
|
98
|
-
[classes.noValue]: !hasValue,
|
|
99
|
-
[classes.openNoValue]: isOpen && !hasValue,
|
|
100
|
-
[classes.withValue]: !isOpen && hasValue,
|
|
101
|
-
[classes.openWithValue]: isOpen && hasValue,
|
|
102
|
-
[classes.boolean]: isBoolean,
|
|
103
|
-
[classes.disabled]: isDisabled,
|
|
104
|
-
})}
|
|
105
|
-
data-testid={testId}
|
|
106
|
-
>
|
|
107
|
-
<div
|
|
108
|
-
ref={refItem}
|
|
109
|
-
onClick={handleLabelClick}
|
|
110
|
-
className={clsx(classes.item, {
|
|
111
|
-
[classes.booleanItem]: isBoolean,
|
|
112
|
-
})}
|
|
113
|
-
>
|
|
114
|
-
<div className={classes.name}>{filter.name}</div>
|
|
115
|
-
{!isBoolean && value !== undefined && value !== null && (
|
|
116
|
-
<div className={classes.value}>
|
|
117
|
-
<FilterValueView value={value} filter={filter} localeKey={localeKey} locale={locale} />
|
|
118
|
-
</div>
|
|
119
|
-
)}
|
|
120
|
-
{!isBoolean && (
|
|
121
|
-
<div className={clsx(classes.iconContainer, isOpen && classes.open)}>
|
|
122
|
-
<Icon type="chevron-down" />
|
|
123
|
-
</div>
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
<CSSTransition
|
|
127
|
-
in={isOpen}
|
|
128
|
-
timeout={150}
|
|
129
|
-
unmountOnExit
|
|
130
|
-
classNames={{
|
|
131
|
-
enter: classes['dropdown-enter'],
|
|
132
|
-
enterActive: classes['dropdown-enter-active'],
|
|
133
|
-
exit: classes['dropdown-exit'],
|
|
134
|
-
exitActive: classes['dropdown-exit-active'],
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
<Filter
|
|
138
|
-
value={value}
|
|
139
|
-
filter={filter}
|
|
140
|
-
localeKey={localeKey}
|
|
141
|
-
locale={locale}
|
|
142
|
-
onClose={handleOnClose}
|
|
143
|
-
onChange={handleChange}
|
|
144
|
-
parentRef={refItem}
|
|
145
|
-
filtersPaneRef={filtersPaneRef}
|
|
146
|
-
testId={testId}
|
|
147
|
-
classes={classes}
|
|
148
|
-
/>
|
|
149
|
-
</CSSTransition>
|
|
150
|
-
</div>
|
|
151
|
-
) : (
|
|
152
|
-
<Filter
|
|
153
|
-
value={value}
|
|
154
|
-
filter={filter}
|
|
155
|
-
localeKey={localeKey}
|
|
156
|
-
locale={locale}
|
|
157
|
-
onClose={handleOnClose}
|
|
158
|
-
onChange={onChange}
|
|
159
|
-
isInline={true}
|
|
160
|
-
filtersPaneRef={filtersPaneRef}
|
|
161
|
-
testId={testId}
|
|
162
|
-
classes={classes}
|
|
163
|
-
/>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export function Filter<Values, Key extends keyof Values>({
|
|
168
|
-
filter,
|
|
169
|
-
value,
|
|
170
|
-
parentRef,
|
|
171
|
-
isInline,
|
|
172
|
-
onChange,
|
|
173
|
-
onClose,
|
|
174
|
-
localeKey,
|
|
175
|
-
locale,
|
|
176
|
-
filtersPaneRef,
|
|
177
|
-
testId,
|
|
178
|
-
classes,
|
|
179
|
-
}: IFilterOtherProps<Values, Key>): JSX.Element | null {
|
|
180
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
181
|
-
const [dropdownPosition, setDropdownPosition] = useState<'left' | 'right'>('left');
|
|
182
|
-
const translatesLocaleKey = filter.localeKey ?? localeKey;
|
|
183
|
-
const translates = useMemo(
|
|
184
|
-
() => getLocale(translatesLocaleKey, locale, filter.locale),
|
|
185
|
-
[localeKey, locale, filter.locale],
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
useOnClickOutsideWithRef(
|
|
189
|
-
ref,
|
|
190
|
-
() => {
|
|
191
|
-
if (!isInline && onClose !== undefined) {
|
|
192
|
-
onClose();
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
parentRef,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
useLayoutEffect(() => {
|
|
199
|
-
if (
|
|
200
|
-
ref.current === null ||
|
|
201
|
-
filtersPaneRef === undefined ||
|
|
202
|
-
filtersPaneRef === null ||
|
|
203
|
-
filtersPaneRef?.current === null
|
|
204
|
-
) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const { width, left } = ref.current.getBoundingClientRect();
|
|
209
|
-
const filtersPaneWidth = filtersPaneRef.current.offsetWidth;
|
|
210
|
-
|
|
211
|
-
const filterValueWidth = ref.current.parentElement
|
|
212
|
-
? ref.current.parentElement.getBoundingClientRect().width
|
|
213
|
-
: 0;
|
|
214
|
-
|
|
215
|
-
if (filtersPaneWidth - left < width - filterValueWidth) {
|
|
216
|
-
setDropdownPosition('right');
|
|
217
|
-
} else if (left < 0) {
|
|
218
|
-
setDropdownPosition('left');
|
|
219
|
-
}
|
|
220
|
-
}, [value, filtersPaneRef]);
|
|
221
|
-
|
|
222
|
-
const props = {
|
|
223
|
-
ref,
|
|
224
|
-
className: clsx(classes[dropdownPosition], {
|
|
225
|
-
[classes.dropdown]: !isInline,
|
|
226
|
-
}),
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const handleOnClose = () => {
|
|
230
|
-
if (onClose !== undefined) {
|
|
231
|
-
onClose();
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
if (filter.type === 'custom' && filter.component) {
|
|
236
|
-
const Component = filter.component;
|
|
237
|
-
return (
|
|
238
|
-
<div {...props}>
|
|
239
|
-
<Component
|
|
240
|
-
{...{
|
|
241
|
-
value,
|
|
242
|
-
onChange,
|
|
243
|
-
onClose,
|
|
244
|
-
filter,
|
|
245
|
-
locale,
|
|
246
|
-
localeKey,
|
|
247
|
-
testId,
|
|
248
|
-
}}
|
|
249
|
-
/>
|
|
250
|
-
</div>
|
|
251
|
-
);
|
|
252
|
-
} else if (filter.type === 'custom' && filter.component === undefined) {
|
|
253
|
-
console.warn(
|
|
254
|
-
`%cДля фильтра типа custom (${filter.name}) в конфиге обязательно нужно задать component`,
|
|
255
|
-
'background: red; color: black',
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (filter.type === 'select') {
|
|
260
|
-
return (
|
|
261
|
-
<div {...props}>
|
|
262
|
-
<FilterSelect
|
|
263
|
-
onChange={onChange}
|
|
264
|
-
value={value}
|
|
265
|
-
localeKey={translatesLocaleKey}
|
|
266
|
-
locale={translates}
|
|
267
|
-
testId={testId !== undefined ? `${testId}-select` : undefined}
|
|
268
|
-
{...filter}
|
|
269
|
-
/>
|
|
270
|
-
</div>
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (filter.type === 'dateRange') {
|
|
275
|
-
return (
|
|
276
|
-
<div {...props}>
|
|
277
|
-
<FilterWithPeriod
|
|
278
|
-
localeKey={translatesLocaleKey}
|
|
279
|
-
locale={translates}
|
|
280
|
-
onChange={onChange}
|
|
281
|
-
value={{ ...value } as IPeriod}
|
|
282
|
-
onClose={handleOnClose}
|
|
283
|
-
testId={testId !== undefined ? `${testId}-period` : undefined}
|
|
284
|
-
{...filter}
|
|
285
|
-
/>
|
|
286
|
-
</div>
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (filter.type === 'dateRangeWithoutPeriod') {
|
|
291
|
-
const dateRangeValue = value as unknown as IFilterWithDatesValue;
|
|
292
|
-
|
|
293
|
-
return (
|
|
294
|
-
<div {...props} style={{ width: 320 }}>
|
|
295
|
-
<FilterWithDates
|
|
296
|
-
value={dateRangeValue}
|
|
297
|
-
onEndBtnSubmit={() => onChange(undefined)}
|
|
298
|
-
onChange={(v) => onChange({ ...v, periodType: 'CUSTOM' })}
|
|
299
|
-
localeKey={translatesLocaleKey}
|
|
300
|
-
locale={translates}
|
|
301
|
-
testId={testId !== undefined ? `${testId}-dates` : undefined}
|
|
302
|
-
{...filter}
|
|
303
|
-
/>
|
|
304
|
-
</div>
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (filter.type === 'multiSelect') {
|
|
309
|
-
return (
|
|
310
|
-
<div {...props}>
|
|
311
|
-
<FilterMultiSelect
|
|
312
|
-
onChange={onChange}
|
|
313
|
-
onClose={handleOnClose}
|
|
314
|
-
value={value as unknown as IFilterMultiSelectValues<any>}
|
|
315
|
-
localeKey={translatesLocaleKey}
|
|
316
|
-
locale={translates}
|
|
317
|
-
testId={testId !== undefined ? `${testId}-multiSelect` : undefined}
|
|
318
|
-
{...filter}
|
|
319
|
-
/>
|
|
320
|
-
</div>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (filter.type === 'interval') {
|
|
325
|
-
return (
|
|
326
|
-
<div {...props}>
|
|
327
|
-
<FilterInterval
|
|
328
|
-
value={value as unknown as number[]}
|
|
329
|
-
labelName={filter.name}
|
|
330
|
-
localeKey={translatesLocaleKey}
|
|
331
|
-
locale={translates}
|
|
332
|
-
onChange={onChange}
|
|
333
|
-
testId={testId !== undefined ? `${testId}-interval` : undefined}
|
|
334
|
-
{...filter}
|
|
335
|
-
/>
|
|
336
|
-
</div>
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
console.warn(
|
|
341
|
-
`%cДля фильтра ${filter.name} не задан тип или component`,
|
|
342
|
-
'background: red; color: black',
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
1
|
+
import { useState, useRef, useMemo, useLayoutEffect, RefObject } from 'react';
|
|
2
|
+
import { CSSTransition } from 'react-transition-group';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Classes } from 'jss';
|
|
5
|
+
import { useTheme, useOnClickOutsideWithRef } from '../../../hooks';
|
|
6
|
+
import { Icon } from '../../Icon';
|
|
7
|
+
import { FilterInterval } from '../FilterInterval';
|
|
8
|
+
import { FilterMultiSelect } from '../FilterMultiSelect';
|
|
9
|
+
import { FilterSelect } from '../FilterSelect';
|
|
10
|
+
import { FilterValueView } from '../FilterValueView';
|
|
11
|
+
import { FilterWithDates } from '../FilterWithDates';
|
|
12
|
+
import { FilterWithPeriod } from '../FilterWithPeriod';
|
|
13
|
+
import { IFilterLocaleKey, getLocale, IPartialFilterLocale } from '../locales';
|
|
14
|
+
import { ConfigItem, IFilterMultiSelectValues, IFilterWithDatesValue, IPeriod } from '../types';
|
|
15
|
+
import { FilterWrapperStyles, styles } from './FilterWrapper.styles';
|
|
16
|
+
|
|
17
|
+
export interface IFilterWrapperProps<Values, Key extends keyof Values> {
|
|
18
|
+
tweakStyles?: FilterWrapperStyles;
|
|
19
|
+
filter: ConfigItem<Values[Key]>;
|
|
20
|
+
value?: Values[Key];
|
|
21
|
+
onChange: <V>(value: V) => void;
|
|
22
|
+
isDisabled?: boolean;
|
|
23
|
+
localeKey?: IFilterLocaleKey;
|
|
24
|
+
locale?: IPartialFilterLocale;
|
|
25
|
+
testId?: string;
|
|
26
|
+
filtersPaneRef: RefObject<HTMLDivElement> | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface IFilterOtherProps<Values, Key extends keyof Values>
|
|
30
|
+
extends IFilterWrapperProps<Values, Key> {
|
|
31
|
+
parentRef?: RefObject<HTMLElement>;
|
|
32
|
+
isInline?: boolean;
|
|
33
|
+
onChange: <V>(v: V) => void;
|
|
34
|
+
onClose?: () => void;
|
|
35
|
+
filtersPaneRef: RefObject<HTMLDivElement> | null;
|
|
36
|
+
classes: Classes<'left' | 'right' | 'dropdown'>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function FilterWrapper<Values, Key extends keyof Values>({
|
|
40
|
+
filter,
|
|
41
|
+
value,
|
|
42
|
+
isDisabled,
|
|
43
|
+
onChange,
|
|
44
|
+
locale,
|
|
45
|
+
localeKey,
|
|
46
|
+
testId,
|
|
47
|
+
filtersPaneRef,
|
|
48
|
+
tweakStyles,
|
|
49
|
+
}: IFilterWrapperProps<Values, Key>): JSX.Element {
|
|
50
|
+
const { classes } = useTheme('FilterWrapper', styles, tweakStyles);
|
|
51
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
const refItem = useRef<HTMLDivElement>(null);
|
|
53
|
+
|
|
54
|
+
const { type } = filter;
|
|
55
|
+
|
|
56
|
+
let hasValue = false;
|
|
57
|
+
|
|
58
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
59
|
+
hasValue = true;
|
|
60
|
+
} else if (
|
|
61
|
+
typeof value === 'object' &&
|
|
62
|
+
Object.values(value as unknown as Record<any, any>).some((v) =>
|
|
63
|
+
Array.isArray(v) ? v.length > 0 : Boolean(v),
|
|
64
|
+
)
|
|
65
|
+
) {
|
|
66
|
+
hasValue = true;
|
|
67
|
+
} else if (!Array.isArray(value) && typeof value !== 'object') {
|
|
68
|
+
hasValue = Boolean(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Для того, чтобы фильтр закрывался, если мы работаем с простыми значениями, типа селекта
|
|
72
|
+
function handleChange<V>(v: V) {
|
|
73
|
+
if (type === 'select') {
|
|
74
|
+
setIsOpen(false);
|
|
75
|
+
}
|
|
76
|
+
onChange(v);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const handleLabelClick = () => {
|
|
80
|
+
if (!isBoolean && !isDisabled) {
|
|
81
|
+
setIsOpen(!isOpen);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isBoolean) {
|
|
85
|
+
onChange(!value);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const handleOnClose = () => {
|
|
90
|
+
setIsOpen(false);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const isBoolean = filter.type === 'boolean';
|
|
94
|
+
|
|
95
|
+
return !filter.isInline ? (
|
|
96
|
+
<div
|
|
97
|
+
className={clsx(classes.root, {
|
|
98
|
+
[classes.noValue]: !hasValue,
|
|
99
|
+
[classes.openNoValue]: isOpen && !hasValue,
|
|
100
|
+
[classes.withValue]: !isOpen && hasValue,
|
|
101
|
+
[classes.openWithValue]: isOpen && hasValue,
|
|
102
|
+
[classes.boolean]: isBoolean,
|
|
103
|
+
[classes.disabled]: isDisabled,
|
|
104
|
+
})}
|
|
105
|
+
data-testid={testId}
|
|
106
|
+
>
|
|
107
|
+
<div
|
|
108
|
+
ref={refItem}
|
|
109
|
+
onClick={handleLabelClick}
|
|
110
|
+
className={clsx(classes.item, {
|
|
111
|
+
[classes.booleanItem]: isBoolean,
|
|
112
|
+
})}
|
|
113
|
+
>
|
|
114
|
+
<div className={classes.name}>{filter.name}</div>
|
|
115
|
+
{!isBoolean && value !== undefined && value !== null && (
|
|
116
|
+
<div className={classes.value}>
|
|
117
|
+
<FilterValueView value={value} filter={filter} localeKey={localeKey} locale={locale} />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
{!isBoolean && (
|
|
121
|
+
<div className={clsx(classes.iconContainer, isOpen && classes.open)}>
|
|
122
|
+
<Icon type="chevron-down" />
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
<CSSTransition
|
|
127
|
+
in={isOpen}
|
|
128
|
+
timeout={150}
|
|
129
|
+
unmountOnExit
|
|
130
|
+
classNames={{
|
|
131
|
+
enter: classes['dropdown-enter'],
|
|
132
|
+
enterActive: classes['dropdown-enter-active'],
|
|
133
|
+
exit: classes['dropdown-exit'],
|
|
134
|
+
exitActive: classes['dropdown-exit-active'],
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
<Filter
|
|
138
|
+
value={value}
|
|
139
|
+
filter={filter}
|
|
140
|
+
localeKey={localeKey}
|
|
141
|
+
locale={locale}
|
|
142
|
+
onClose={handleOnClose}
|
|
143
|
+
onChange={handleChange}
|
|
144
|
+
parentRef={refItem}
|
|
145
|
+
filtersPaneRef={filtersPaneRef}
|
|
146
|
+
testId={testId}
|
|
147
|
+
classes={classes}
|
|
148
|
+
/>
|
|
149
|
+
</CSSTransition>
|
|
150
|
+
</div>
|
|
151
|
+
) : (
|
|
152
|
+
<Filter
|
|
153
|
+
value={value}
|
|
154
|
+
filter={filter}
|
|
155
|
+
localeKey={localeKey}
|
|
156
|
+
locale={locale}
|
|
157
|
+
onClose={handleOnClose}
|
|
158
|
+
onChange={onChange}
|
|
159
|
+
isInline={true}
|
|
160
|
+
filtersPaneRef={filtersPaneRef}
|
|
161
|
+
testId={testId}
|
|
162
|
+
classes={classes}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function Filter<Values, Key extends keyof Values>({
|
|
168
|
+
filter,
|
|
169
|
+
value,
|
|
170
|
+
parentRef,
|
|
171
|
+
isInline,
|
|
172
|
+
onChange,
|
|
173
|
+
onClose,
|
|
174
|
+
localeKey,
|
|
175
|
+
locale,
|
|
176
|
+
filtersPaneRef,
|
|
177
|
+
testId,
|
|
178
|
+
classes,
|
|
179
|
+
}: IFilterOtherProps<Values, Key>): JSX.Element | null {
|
|
180
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
181
|
+
const [dropdownPosition, setDropdownPosition] = useState<'left' | 'right'>('left');
|
|
182
|
+
const translatesLocaleKey = filter.localeKey ?? localeKey;
|
|
183
|
+
const translates = useMemo(
|
|
184
|
+
() => getLocale(translatesLocaleKey, locale, filter.locale),
|
|
185
|
+
[localeKey, locale, filter.locale],
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
useOnClickOutsideWithRef(
|
|
189
|
+
ref,
|
|
190
|
+
() => {
|
|
191
|
+
if (!isInline && onClose !== undefined) {
|
|
192
|
+
onClose();
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
parentRef,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
useLayoutEffect(() => {
|
|
199
|
+
if (
|
|
200
|
+
ref.current === null ||
|
|
201
|
+
filtersPaneRef === undefined ||
|
|
202
|
+
filtersPaneRef === null ||
|
|
203
|
+
filtersPaneRef?.current === null
|
|
204
|
+
) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const { width, left } = ref.current.getBoundingClientRect();
|
|
209
|
+
const filtersPaneWidth = filtersPaneRef.current.offsetWidth;
|
|
210
|
+
|
|
211
|
+
const filterValueWidth = ref.current.parentElement
|
|
212
|
+
? ref.current.parentElement.getBoundingClientRect().width
|
|
213
|
+
: 0;
|
|
214
|
+
|
|
215
|
+
if (filtersPaneWidth - left < width - filterValueWidth) {
|
|
216
|
+
setDropdownPosition('right');
|
|
217
|
+
} else if (left < 0) {
|
|
218
|
+
setDropdownPosition('left');
|
|
219
|
+
}
|
|
220
|
+
}, [value, filtersPaneRef]);
|
|
221
|
+
|
|
222
|
+
const props = {
|
|
223
|
+
ref,
|
|
224
|
+
className: clsx(classes[dropdownPosition], {
|
|
225
|
+
[classes.dropdown]: !isInline,
|
|
226
|
+
}),
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const handleOnClose = () => {
|
|
230
|
+
if (onClose !== undefined) {
|
|
231
|
+
onClose();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
if (filter.type === 'custom' && filter.component) {
|
|
236
|
+
const Component = filter.component;
|
|
237
|
+
return (
|
|
238
|
+
<div {...props}>
|
|
239
|
+
<Component
|
|
240
|
+
{...{
|
|
241
|
+
value,
|
|
242
|
+
onChange,
|
|
243
|
+
onClose,
|
|
244
|
+
filter,
|
|
245
|
+
locale,
|
|
246
|
+
localeKey,
|
|
247
|
+
testId,
|
|
248
|
+
}}
|
|
249
|
+
/>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
} else if (filter.type === 'custom' && filter.component === undefined) {
|
|
253
|
+
console.warn(
|
|
254
|
+
`%cДля фильтра типа custom (${filter.name}) в конфиге обязательно нужно задать component`,
|
|
255
|
+
'background: red; color: black',
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (filter.type === 'select') {
|
|
260
|
+
return (
|
|
261
|
+
<div {...props}>
|
|
262
|
+
<FilterSelect
|
|
263
|
+
onChange={onChange}
|
|
264
|
+
value={value}
|
|
265
|
+
localeKey={translatesLocaleKey}
|
|
266
|
+
locale={translates}
|
|
267
|
+
testId={testId !== undefined ? `${testId}-select` : undefined}
|
|
268
|
+
{...filter}
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (filter.type === 'dateRange') {
|
|
275
|
+
return (
|
|
276
|
+
<div {...props}>
|
|
277
|
+
<FilterWithPeriod
|
|
278
|
+
localeKey={translatesLocaleKey}
|
|
279
|
+
locale={translates}
|
|
280
|
+
onChange={onChange}
|
|
281
|
+
value={{ ...value } as IPeriod}
|
|
282
|
+
onClose={handleOnClose}
|
|
283
|
+
testId={testId !== undefined ? `${testId}-period` : undefined}
|
|
284
|
+
{...filter}
|
|
285
|
+
/>
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (filter.type === 'dateRangeWithoutPeriod') {
|
|
291
|
+
const dateRangeValue = value as unknown as IFilterWithDatesValue;
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<div {...props} style={{ width: 320 }}>
|
|
295
|
+
<FilterWithDates
|
|
296
|
+
value={dateRangeValue}
|
|
297
|
+
onEndBtnSubmit={() => onChange(undefined)}
|
|
298
|
+
onChange={(v) => onChange({ ...v, periodType: 'CUSTOM' })}
|
|
299
|
+
localeKey={translatesLocaleKey}
|
|
300
|
+
locale={translates}
|
|
301
|
+
testId={testId !== undefined ? `${testId}-dates` : undefined}
|
|
302
|
+
{...filter}
|
|
303
|
+
/>
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (filter.type === 'multiSelect') {
|
|
309
|
+
return (
|
|
310
|
+
<div {...props}>
|
|
311
|
+
<FilterMultiSelect
|
|
312
|
+
onChange={onChange}
|
|
313
|
+
onClose={handleOnClose}
|
|
314
|
+
value={value as unknown as IFilterMultiSelectValues<any>}
|
|
315
|
+
localeKey={translatesLocaleKey}
|
|
316
|
+
locale={translates}
|
|
317
|
+
testId={testId !== undefined ? `${testId}-multiSelect` : undefined}
|
|
318
|
+
{...filter}
|
|
319
|
+
/>
|
|
320
|
+
</div>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (filter.type === 'interval') {
|
|
325
|
+
return (
|
|
326
|
+
<div {...props}>
|
|
327
|
+
<FilterInterval
|
|
328
|
+
value={value as unknown as number[]}
|
|
329
|
+
labelName={filter.name}
|
|
330
|
+
localeKey={translatesLocaleKey}
|
|
331
|
+
locale={translates}
|
|
332
|
+
onChange={onChange}
|
|
333
|
+
testId={testId !== undefined ? `${testId}-interval` : undefined}
|
|
334
|
+
{...filter}
|
|
335
|
+
/>
|
|
336
|
+
</div>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
console.warn(
|
|
341
|
+
`%cДля фильтра ${filter.name} не задан тип или component`,
|
|
342
|
+
'background: red; color: black',
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
return null;
|
|
346
|
+
}
|