@alfalab/core-components-select 17.8.2 → 17.8.3
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/components/arrow/Component.js +1 -1
- package/components/arrow/index.css +6 -4
- package/components/base-checkmark/Component.js +1 -1
- package/components/base-checkmark/index.css +9 -7
- package/components/base-option/Component.js +1 -1
- package/components/base-option/index.css +21 -19
- package/components/base-select/Component.d.ts +8 -14
- package/components/base-select/Component.js +48 -75
- package/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
- package/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +19 -0
- package/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
- package/components/base-select/components/list-desktop/list-popover-desktop.js +12 -0
- package/components/base-select/components/list-desktop/types/types.d.ts +3 -0
- package/components/base-select/components/list-desktop/types/types.js +2 -0
- package/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
- package/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +23 -0
- package/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
- package/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +22 -0
- package/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
- package/components/base-select/components/list-mobile/helpers/index.js +11 -0
- package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
- package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +28 -0
- package/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
- package/components/base-select/components/list-mobile/list-mobile.js +26 -0
- package/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
- package/components/base-select/components/list-mobile/list-modal-mobile.js +42 -0
- package/components/base-select/components/list-mobile/types/types.d.ts +4 -0
- package/components/base-select/components/list-mobile/types/types.js +2 -0
- package/components/base-select/index.css +16 -14
- package/components/base-select/mobile.css +19 -17
- package/components/base-select/types/component-types.d.ts +50 -0
- package/components/base-select/types/component-types.js +2 -0
- package/components/checkmark/Component.js +1 -1
- package/components/checkmark/index.css +15 -13
- package/components/checkmark-mobile/Component.js +1 -1
- package/components/checkmark-mobile/index.css +9 -7
- package/components/field/Component.js +1 -1
- package/components/field/index.css +15 -13
- package/components/footer/Component.js +1 -1
- package/components/footer/index.css +9 -7
- package/components/optgroup/Component.js +1 -1
- package/components/optgroup/index.css +12 -10
- package/components/option/Component.js +1 -1
- package/components/option/index.css +24 -22
- package/components/options-list/Component.js +1 -1
- package/components/options-list/index.css +16 -14
- package/components/search/Component.js +1 -1
- package/components/search/index.css +5 -3
- package/components/virtual-options-list/Component.js +1 -1
- package/components/virtual-options-list/index.css +21 -19
- package/cssm/components/arrow/index.module.css +3 -1
- package/cssm/components/base-checkmark/index.module.css +3 -1
- package/cssm/components/base-option/index.module.css +6 -4
- package/cssm/components/base-select/Component.d.ts +8 -14
- package/cssm/components/base-select/Component.js +38 -60
- package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
- package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +19 -0
- package/cssm/components/base-select/components/list-desktop/list-popover-desktop.d.ts +9 -0
- package/cssm/components/base-select/components/list-desktop/list-popover-desktop.js +24 -0
- package/cssm/components/base-select/components/list-desktop/types/types.d.ts +3 -0
- package/cssm/components/base-select/components/list-desktop/types/types.js +2 -0
- package/cssm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
- package/cssm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +23 -0
- package/cssm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
- package/cssm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +22 -0
- package/cssm/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
- package/cssm/components/base-select/components/list-mobile/helpers/index.js +11 -0
- package/cssm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
- package/cssm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +29 -0
- package/cssm/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
- package/cssm/components/base-select/components/list-mobile/list-mobile.js +26 -0
- package/cssm/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
- package/cssm/components/base-select/components/list-mobile/list-modal-mobile.js +43 -0
- package/cssm/components/base-select/components/list-mobile/types/types.d.ts +4 -0
- package/cssm/components/base-select/components/list-mobile/types/types.js +2 -0
- package/cssm/components/base-select/index.module.css +5 -3
- package/cssm/components/base-select/mobile.module.css +7 -5
- package/cssm/components/base-select/types/component-types.d.ts +50 -0
- package/cssm/components/base-select/types/component-types.js +2 -0
- package/cssm/components/checkmark/index.module.css +5 -3
- package/cssm/components/checkmark-mobile/index.module.css +3 -1
- package/cssm/components/field/index.module.css +3 -1
- package/cssm/components/footer/index.module.css +4 -2
- package/cssm/components/optgroup/index.module.css +6 -4
- package/cssm/components/option/index.module.css +5 -3
- package/cssm/components/options-list/index.module.css +6 -4
- package/cssm/components/search/index.module.css +3 -1
- package/cssm/components/virtual-options-list/index.module.css +6 -4
- package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +5 -3
- package/cssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +5 -3
- package/esm/components/arrow/Component.js +1 -1
- package/esm/components/arrow/index.css +6 -4
- package/esm/components/base-checkmark/Component.js +1 -1
- package/esm/components/base-checkmark/index.css +9 -7
- package/esm/components/base-option/Component.js +1 -1
- package/esm/components/base-option/index.css +21 -19
- package/esm/components/base-select/Component.d.ts +8 -14
- package/esm/components/base-select/Component.js +39 -66
- package/esm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
- package/esm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +15 -0
- package/esm/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
- package/esm/components/base-select/components/list-desktop/list-popover-desktop.js +4 -0
- package/esm/components/base-select/components/list-desktop/types/types.d.ts +3 -0
- package/esm/components/base-select/components/list-desktop/types/types.js +1 -0
- package/esm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
- package/esm/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +19 -0
- package/esm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
- package/esm/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +18 -0
- package/esm/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
- package/esm/components/base-select/components/list-mobile/helpers/index.js +2 -0
- package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
- package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +20 -0
- package/esm/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
- package/esm/components/base-select/components/list-mobile/list-mobile.js +18 -0
- package/esm/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
- package/esm/components/base-select/components/list-mobile/list-modal-mobile.js +32 -0
- package/esm/components/base-select/components/list-mobile/types/types.d.ts +4 -0
- package/esm/components/base-select/components/list-mobile/types/types.js +1 -0
- package/esm/components/base-select/index.css +16 -14
- package/esm/components/base-select/mobile.css +19 -17
- package/esm/components/base-select/types/component-types.d.ts +50 -0
- package/esm/components/base-select/types/component-types.js +1 -0
- package/esm/components/checkmark/Component.js +1 -1
- package/esm/components/checkmark/index.css +15 -13
- package/esm/components/checkmark-mobile/Component.js +1 -1
- package/esm/components/checkmark-mobile/index.css +9 -7
- package/esm/components/field/Component.js +1 -1
- package/esm/components/field/index.css +15 -13
- package/esm/components/footer/Component.js +1 -1
- package/esm/components/footer/index.css +9 -7
- package/esm/components/optgroup/Component.js +1 -1
- package/esm/components/optgroup/index.css +12 -10
- package/esm/components/option/Component.js +1 -1
- package/esm/components/option/index.css +24 -22
- package/esm/components/options-list/Component.js +1 -1
- package/esm/components/options-list/index.css +16 -14
- package/esm/components/search/Component.js +1 -1
- package/esm/components/search/index.css +5 -3
- package/esm/components/virtual-options-list/Component.js +1 -1
- package/esm/components/virtual-options-list/index.css +21 -19
- package/esm/list-popover-desktop-a16c1a9c.d.ts +9 -0
- package/esm/list-popover-desktop-a16c1a9c.js +16 -0
- package/esm/mobile/Component.mobile.js +1 -1
- package/esm/mobile.module-3975aa85.js +4 -0
- package/esm/presets/index.js +1 -1
- package/esm/presets/useSelectWithApply/hook.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
- package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/esm/presets/useSelectWithLoading/hook.js +1 -1
- package/esm/presets/useSelectWithLoading/index.css +2 -2
- package/esm/shared/index.js +1 -1
- package/list-popover-desktop-63ceae1a.d.ts +9 -0
- package/list-popover-desktop-63ceae1a.js +24 -0
- package/mobile/Component.mobile.js +1 -1
- package/mobile.module-f44f34a3.js +6 -0
- package/modern/components/arrow/Component.js +1 -1
- package/modern/components/arrow/index.css +6 -4
- package/modern/components/base-checkmark/Component.js +1 -1
- package/modern/components/base-checkmark/index.css +9 -7
- package/modern/components/base-option/Component.js +1 -1
- package/modern/components/base-option/index.css +21 -19
- package/modern/components/base-select/Component.d.ts +8 -14
- package/modern/components/base-select/Component.js +23 -56
- package/modern/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +12 -0
- package/modern/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.js +15 -0
- package/modern/components/base-select/components/list-desktop/list-popover-desktop.d.ts +0 -0
- package/modern/components/base-select/components/list-desktop/list-popover-desktop.js +3 -0
- package/modern/components/base-select/components/list-desktop/types/types.d.ts +3 -0
- package/modern/components/base-select/components/list-desktop/types/types.js +1 -0
- package/modern/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.d.ts +16 -0
- package/modern/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.js +19 -0
- package/modern/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.d.ts +28 -0
- package/modern/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.js +18 -0
- package/modern/components/base-select/components/list-mobile/helpers/index.d.ts +2 -0
- package/modern/components/base-select/components/list-mobile/helpers/index.js +2 -0
- package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.d.ts +15 -0
- package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +24 -0
- package/modern/components/base-select/components/list-mobile/list-mobile.d.ts +16 -0
- package/modern/components/base-select/components/list-mobile/list-mobile.js +17 -0
- package/modern/components/base-select/components/list-mobile/list-modal-mobile.d.ts +15 -0
- package/modern/components/base-select/components/list-mobile/list-modal-mobile.js +32 -0
- package/modern/components/base-select/components/list-mobile/types/types.d.ts +4 -0
- package/modern/components/base-select/components/list-mobile/types/types.js +1 -0
- package/modern/components/base-select/index.css +16 -14
- package/modern/components/base-select/mobile.css +19 -17
- package/modern/components/base-select/types/component-types.d.ts +50 -0
- package/modern/components/base-select/types/component-types.js +1 -0
- package/modern/components/checkmark/Component.js +1 -1
- package/modern/components/checkmark/index.css +15 -13
- package/modern/components/checkmark-mobile/Component.js +1 -1
- package/modern/components/checkmark-mobile/index.css +9 -7
- package/modern/components/field/Component.js +1 -1
- package/modern/components/field/index.css +15 -13
- package/modern/components/footer/Component.js +1 -1
- package/modern/components/footer/index.css +9 -7
- package/modern/components/optgroup/Component.js +1 -1
- package/modern/components/optgroup/index.css +12 -10
- package/modern/components/option/Component.js +1 -1
- package/modern/components/option/index.css +24 -22
- package/modern/components/options-list/Component.js +1 -1
- package/modern/components/options-list/index.css +16 -14
- package/modern/components/search/Component.js +1 -1
- package/modern/components/search/index.css +5 -3
- package/modern/components/virtual-options-list/Component.js +1 -1
- package/modern/components/virtual-options-list/index.css +21 -19
- package/modern/list-popover-desktop-380bb61b.d.ts +9 -0
- package/modern/list-popover-desktop-380bb61b.js +15 -0
- package/modern/mobile/Component.mobile.js +1 -1
- package/modern/mobile.module-5f7203b5.js +4 -0
- package/modern/presets/index.js +1 -1
- package/modern/presets/useSelectWithApply/hook.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
- package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/modern/presets/useSelectWithLoading/hook.js +1 -1
- package/modern/presets/useSelectWithLoading/index.css +2 -2
- package/modern/shared/index.js +1 -1
- package/package.json +6 -4
- package/presets/index.js +1 -1
- package/presets/useSelectWithApply/hook.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -6
- package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/header/index.css +8 -6
- package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/presets/useSelectWithLoading/hook.js +1 -1
- package/presets/useSelectWithLoading/index.css +2 -2
- package/shared/index.js +1 -1
- package/src/components/base-select/Component.tsx +49 -185
- package/src/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.tsx +24 -0
- package/src/components/base-select/components/list-desktop/list-popover-desktop.tsx +47 -0
- package/src/components/base-select/components/list-desktop/types/types.ts +3 -0
- package/src/components/base-select/components/list-mobile/helpers/get-list-bottom-sheet-mobile-props.tsx +32 -0
- package/src/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.tsx +30 -0
- package/src/components/base-select/components/list-mobile/helpers/index.ts +2 -0
- package/src/components/base-select/components/list-mobile/list-bottom-sheet-mobile.tsx +84 -0
- package/src/components/base-select/components/list-mobile/list-mobile.tsx +39 -0
- package/src/components/base-select/components/list-mobile/list-modal-mobile.tsx +94 -0
- package/src/components/base-select/components/list-mobile/types/types.ts +4 -0
- package/src/components/base-select/types/component-types.ts +39 -0
- /package/esm/{hook-86063cab.d.ts → hook-74830211.d.ts} +0 -0
- /package/esm/{hook-86063cab.js → hook-74830211.js} +0 -0
- /package/{hook-777449d0.d.ts → hook-b7a5b3a9.d.ts} +0 -0
- /package/{hook-777449d0.js → hook-b7a5b3a9.js} +0 -0
- /package/modern/{hook-1c546c40.d.ts → hook-d5ca0e82.d.ts} +0 -0
- /package/modern/{hook-1c546c40.js → hook-d5ca0e82.js} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import React, {
|
|
3
|
-
FC,
|
|
4
3
|
FocusEvent,
|
|
5
4
|
forwardRef,
|
|
6
|
-
ForwardRefExoticComponent,
|
|
7
5
|
KeyboardEvent,
|
|
8
6
|
MouseEvent,
|
|
9
7
|
RefAttributes,
|
|
@@ -23,27 +21,10 @@ import {
|
|
|
23
21
|
UseMultipleSelectionState,
|
|
24
22
|
} from 'downshift';
|
|
25
23
|
|
|
26
|
-
import type { BottomSheetProps } from '@alfalab/core-components-bottom-sheet';
|
|
27
|
-
import type { ModalMobileProps } from '@alfalab/core-components-modal/mobile';
|
|
28
|
-
import type {
|
|
29
|
-
ModalContentProps,
|
|
30
|
-
ModalFooterProps,
|
|
31
|
-
ModalHeaderProps,
|
|
32
|
-
} from '@alfalab/core-components-modal/shared';
|
|
33
|
-
import type { PopoverProps } from '@alfalab/core-components-popover';
|
|
34
24
|
import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
|
|
35
25
|
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
36
26
|
|
|
37
|
-
import type {
|
|
38
|
-
AdditionalMobileProps,
|
|
39
|
-
AnyObject,
|
|
40
|
-
BaseSelectProps,
|
|
41
|
-
BottomSheetSelectMobileProps,
|
|
42
|
-
ModalSelectMobileProps,
|
|
43
|
-
OptionShape,
|
|
44
|
-
OptionsListProps,
|
|
45
|
-
SearchProps,
|
|
46
|
-
} from '../../typings';
|
|
27
|
+
import type { AnyObject, OptionShape, OptionsListProps, SearchProps } from '../../typings';
|
|
47
28
|
import {
|
|
48
29
|
defaultAccessor,
|
|
49
30
|
defaultFilterFn,
|
|
@@ -53,44 +34,33 @@ import {
|
|
|
53
34
|
} from '../../utils';
|
|
54
35
|
import { NativeSelect } from '../native-select';
|
|
55
36
|
|
|
37
|
+
import { getListPopoverDesktopProps } from './components/list-desktop/helpers/get-list-popover-desktop-props';
|
|
38
|
+
import { ListPopoverDesktop } from './components/list-desktop/list-popover-desktop';
|
|
39
|
+
import {
|
|
40
|
+
getListBottomSheetMobileProps,
|
|
41
|
+
getListModalMobileProps,
|
|
42
|
+
} from './components/list-mobile/helpers';
|
|
43
|
+
import { ListMobile } from './components/list-mobile/list-mobile';
|
|
44
|
+
import { ComponentProps } from './types/component-types';
|
|
45
|
+
|
|
56
46
|
import styles from './index.module.css';
|
|
57
47
|
import mobileStyles from './mobile.module.css';
|
|
58
48
|
|
|
59
|
-
type ComponentProps = BaseSelectProps &
|
|
60
|
-
AdditionalMobileProps &
|
|
61
|
-
BottomSheetSelectMobileProps &
|
|
62
|
-
ModalSelectMobileProps & {
|
|
63
|
-
isBottomSheet?: boolean;
|
|
64
|
-
view: 'desktop' | 'mobile';
|
|
65
|
-
Popover?: ForwardRefExoticComponent<PopoverProps & RefAttributes<HTMLDivElement>>;
|
|
66
|
-
BottomSheet?: React.ForwardRefExoticComponent<
|
|
67
|
-
BottomSheetProps & React.RefAttributes<HTMLDivElement>
|
|
68
|
-
>;
|
|
69
|
-
ModalMobile?: ForwardRefExoticComponent<
|
|
70
|
-
ModalMobileProps & RefAttributes<HTMLDivElement>
|
|
71
|
-
> & {
|
|
72
|
-
Header: FC<ModalHeaderProps>;
|
|
73
|
-
Footer: FC<ModalFooterProps>;
|
|
74
|
-
Content: FC<ModalContentProps>;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
49
|
const itemToString = (option: OptionShape | null) => (option ? option.key : '');
|
|
79
50
|
|
|
80
51
|
const isItemDisabled = (option: OptionShape | null) => Boolean(option?.disabled);
|
|
81
52
|
|
|
82
|
-
export const BaseSelect = forwardRef(
|
|
53
|
+
export const BaseSelect = forwardRef<unknown, ComponentProps>(
|
|
83
54
|
// TODO: 😭
|
|
84
55
|
// eslint-disable-next-line complexity
|
|
85
|
-
(
|
|
86
|
-
{
|
|
56
|
+
(props, ref) => {
|
|
57
|
+
const {
|
|
87
58
|
dataTestId,
|
|
88
59
|
className,
|
|
89
60
|
fieldClassName,
|
|
90
61
|
optionGroupClassName,
|
|
91
62
|
optionsListClassName,
|
|
92
63
|
optionClassName,
|
|
93
|
-
popperClassName,
|
|
94
64
|
options,
|
|
95
65
|
autocomplete = false,
|
|
96
66
|
multiple = false,
|
|
@@ -101,8 +71,6 @@ export const BaseSelect = forwardRef(
|
|
|
101
71
|
nativeSelect = false,
|
|
102
72
|
defaultOpen = false,
|
|
103
73
|
open: openProp,
|
|
104
|
-
popoverPosition = 'bottom-start',
|
|
105
|
-
preventFlip = true,
|
|
106
74
|
optionsListWidth = 'content',
|
|
107
75
|
name,
|
|
108
76
|
id,
|
|
@@ -132,26 +100,15 @@ export const BaseSelect = forwardRef(
|
|
|
132
100
|
Optgroup = () => null,
|
|
133
101
|
Option = () => null,
|
|
134
102
|
Search = () => null,
|
|
135
|
-
updatePopover,
|
|
136
|
-
zIndexPopover,
|
|
137
103
|
showEmptyOptionsList = false,
|
|
138
104
|
visibleOptions,
|
|
139
105
|
view,
|
|
140
106
|
isBottomSheet = true,
|
|
141
|
-
footer,
|
|
142
|
-
swipeable,
|
|
143
107
|
modalProps,
|
|
144
|
-
popoverProps,
|
|
145
|
-
modalFooterProps,
|
|
146
|
-
modalHeaderProps,
|
|
147
108
|
bottomSheetProps,
|
|
148
|
-
Popover,
|
|
149
|
-
ModalMobile,
|
|
150
|
-
BottomSheet,
|
|
151
109
|
limitDynamicOptionGroupSize,
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
) => {
|
|
110
|
+
} = props;
|
|
111
|
+
const shouldSearchBlurRef = useRef(true);
|
|
155
112
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
156
113
|
const fieldRef = useRef<HTMLInputElement>(null);
|
|
157
114
|
const listRef = useRef<HTMLDivElement>(null);
|
|
@@ -479,6 +436,13 @@ export const BaseSelect = forwardRef(
|
|
|
479
436
|
index,
|
|
480
437
|
item: option,
|
|
481
438
|
onMouseDown: (event: MouseEvent) => event.preventDefault(),
|
|
439
|
+
onClick: () => {
|
|
440
|
+
if (view === 'mobile' || !showSearch || multiple) return;
|
|
441
|
+
shouldSearchBlurRef.current = false;
|
|
442
|
+
searchRef.current?.blur();
|
|
443
|
+
shouldSearchBlurRef.current = true;
|
|
444
|
+
fieldRef.current?.focus();
|
|
445
|
+
},
|
|
482
446
|
}),
|
|
483
447
|
multiple,
|
|
484
448
|
index,
|
|
@@ -576,6 +540,7 @@ export const BaseSelect = forwardRef(
|
|
|
576
540
|
};
|
|
577
541
|
|
|
578
542
|
const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
|
|
543
|
+
if (!shouldSearchBlurRef.current) return;
|
|
579
544
|
searchProps.componentProps?.onBlur?.(event);
|
|
580
545
|
handleFieldBlur(event);
|
|
581
546
|
};
|
|
@@ -674,130 +639,6 @@ export const BaseSelect = forwardRef(
|
|
|
674
639
|
);
|
|
675
640
|
};
|
|
676
641
|
|
|
677
|
-
const renderInPopover = () => {
|
|
678
|
-
if (!nativeSelect && Popover) {
|
|
679
|
-
return (
|
|
680
|
-
<Popover
|
|
681
|
-
{...popoverProps}
|
|
682
|
-
open={open}
|
|
683
|
-
withTransition={false}
|
|
684
|
-
anchorElement={fieldRef.current as HTMLElement}
|
|
685
|
-
position={popoverPosition}
|
|
686
|
-
preventFlip={preventFlip}
|
|
687
|
-
popperClassName={cn(styles.popoverInner, popperClassName)}
|
|
688
|
-
update={updatePopover}
|
|
689
|
-
zIndex={zIndexPopover}
|
|
690
|
-
>
|
|
691
|
-
{renderOptionsList()}
|
|
692
|
-
</Popover>
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
return null;
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
const renderInBottomSheet = () => {
|
|
700
|
-
if (!nativeSelect && BottomSheet) {
|
|
701
|
-
return (
|
|
702
|
-
<BottomSheet
|
|
703
|
-
dataTestId={getDataTestId(dataTestId, 'bottom-sheet')}
|
|
704
|
-
open={open}
|
|
705
|
-
className={mobileStyles.sheet}
|
|
706
|
-
contentClassName={mobileStyles.sheetContent}
|
|
707
|
-
containerClassName={mobileStyles.sheetContainer}
|
|
708
|
-
title={label || placeholder}
|
|
709
|
-
actionButton={footer}
|
|
710
|
-
stickyHeader={true}
|
|
711
|
-
hasCloser={true}
|
|
712
|
-
swipeable={swipeable}
|
|
713
|
-
initialHeight={showSearch ? 'full' : 'default'}
|
|
714
|
-
{...bottomSheetProps}
|
|
715
|
-
sheetContainerRef={menuRef}
|
|
716
|
-
scrollableContainerRef={scrollableContainerRef}
|
|
717
|
-
onClose={() => {
|
|
718
|
-
closeMenu();
|
|
719
|
-
bottomSheetProps?.onClose?.();
|
|
720
|
-
}}
|
|
721
|
-
transitionProps={{
|
|
722
|
-
...bottomSheetProps?.transitionProps,
|
|
723
|
-
onEntered: handleEntered,
|
|
724
|
-
}}
|
|
725
|
-
bottomAddons={
|
|
726
|
-
<React.Fragment>
|
|
727
|
-
{renderSearch()}
|
|
728
|
-
{flatOptions.length > 0 && bottomSheetProps?.bottomAddons}
|
|
729
|
-
</React.Fragment>
|
|
730
|
-
}
|
|
731
|
-
containerProps={{
|
|
732
|
-
...bottomSheetProps?.containerProps,
|
|
733
|
-
onScroll,
|
|
734
|
-
}}
|
|
735
|
-
>
|
|
736
|
-
{renderOptionsList()}
|
|
737
|
-
</BottomSheet>
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return null;
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
const renderInModalMobile = () => {
|
|
745
|
-
if (!nativeSelect && ModalMobile) {
|
|
746
|
-
return (
|
|
747
|
-
<ModalMobile
|
|
748
|
-
dataTestId={getDataTestId(dataTestId, 'modal')}
|
|
749
|
-
open={open}
|
|
750
|
-
hasCloser={true}
|
|
751
|
-
{...modalProps}
|
|
752
|
-
componentRef={menuRef}
|
|
753
|
-
onClose={(...args) => {
|
|
754
|
-
closeMenu();
|
|
755
|
-
modalProps?.onClose?.(...args);
|
|
756
|
-
}}
|
|
757
|
-
contentClassName={cn(
|
|
758
|
-
mobileStyles.sheetContent,
|
|
759
|
-
modalProps?.contentClassName,
|
|
760
|
-
)}
|
|
761
|
-
ref={mergeRefs([
|
|
762
|
-
scrollableContainerRef,
|
|
763
|
-
modalProps?.ref as React.Ref<HTMLDivElement>,
|
|
764
|
-
])}
|
|
765
|
-
wrapperProps={{
|
|
766
|
-
...modalProps?.wrapperProps,
|
|
767
|
-
onScroll,
|
|
768
|
-
}}
|
|
769
|
-
transitionProps={{
|
|
770
|
-
...modalProps?.transitionProps,
|
|
771
|
-
onEntered: handleEntered,
|
|
772
|
-
}}
|
|
773
|
-
>
|
|
774
|
-
<ModalMobile.Header
|
|
775
|
-
hasCloser={true}
|
|
776
|
-
sticky={true}
|
|
777
|
-
{...modalHeaderProps}
|
|
778
|
-
title={undefined}
|
|
779
|
-
bottomAddons={
|
|
780
|
-
<React.Fragment>
|
|
781
|
-
{renderSearch()}
|
|
782
|
-
{flatOptions.length > 0 && modalHeaderProps?.bottomAddons}
|
|
783
|
-
</React.Fragment>
|
|
784
|
-
}
|
|
785
|
-
>
|
|
786
|
-
{modalHeaderProps?.title || label || placeholder}
|
|
787
|
-
</ModalMobile.Header>
|
|
788
|
-
|
|
789
|
-
<ModalMobile.Content flex={true} className={mobileStyles.modalContent}>
|
|
790
|
-
{renderOptionsList()}
|
|
791
|
-
</ModalMobile.Content>
|
|
792
|
-
|
|
793
|
-
{modalFooterProps?.children && <ModalMobile.Footer {...modalFooterProps} />}
|
|
794
|
-
</ModalMobile>
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
return null;
|
|
799
|
-
};
|
|
800
|
-
|
|
801
642
|
return (
|
|
802
643
|
<div
|
|
803
644
|
{...(disabled && { 'aria-disabled': true })}
|
|
@@ -848,9 +689,32 @@ export const BaseSelect = forwardRef(
|
|
|
848
689
|
|
|
849
690
|
{name && !nativeSelect && renderValue()}
|
|
850
691
|
|
|
851
|
-
{view === 'desktop' &&
|
|
852
|
-
|
|
853
|
-
|
|
692
|
+
{view === 'desktop' && !nativeSelect && (
|
|
693
|
+
<ListPopoverDesktop
|
|
694
|
+
{...getListPopoverDesktopProps(props)}
|
|
695
|
+
open={open}
|
|
696
|
+
fieldRef={fieldRef}
|
|
697
|
+
renderOptionsList={renderOptionsList}
|
|
698
|
+
/>
|
|
699
|
+
)}
|
|
700
|
+
|
|
701
|
+
{view === 'mobile' && (
|
|
702
|
+
<ListMobile
|
|
703
|
+
baseProps={
|
|
704
|
+
isBottomSheet
|
|
705
|
+
? getListBottomSheetMobileProps(props)
|
|
706
|
+
: getListModalMobileProps(props)
|
|
707
|
+
}
|
|
708
|
+
open={open}
|
|
709
|
+
menuRef={menuRef}
|
|
710
|
+
scrollableContainerRef={scrollableContainerRef}
|
|
711
|
+
flatOptions={flatOptions}
|
|
712
|
+
renderOptionsList={renderOptionsList}
|
|
713
|
+
renderSearch={renderSearch}
|
|
714
|
+
closeMenu={closeMenu}
|
|
715
|
+
handleEntered={handleEntered}
|
|
716
|
+
/>
|
|
717
|
+
)}
|
|
854
718
|
</div>
|
|
855
719
|
);
|
|
856
720
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentProps } from '../../../types/component-types';
|
|
2
|
+
|
|
3
|
+
// отделяем необходимые пропсы для передачи в компонент
|
|
4
|
+
export const getListPopoverDesktopProps = (props: ComponentProps) => {
|
|
5
|
+
const {
|
|
6
|
+
Popover,
|
|
7
|
+
popoverProps,
|
|
8
|
+
popoverPosition = 'bottom-start',
|
|
9
|
+
preventFlip = true,
|
|
10
|
+
popperClassName,
|
|
11
|
+
updatePopover,
|
|
12
|
+
zIndexPopover,
|
|
13
|
+
} = props;
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
Popover,
|
|
17
|
+
popoverProps,
|
|
18
|
+
popoverPosition,
|
|
19
|
+
preventFlip,
|
|
20
|
+
popperClassName,
|
|
21
|
+
updatePopover,
|
|
22
|
+
zIndexPopover,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { FC, ReactNode, RefObject } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { ListPopoverDesktopRestProps } from './types/types';
|
|
5
|
+
|
|
6
|
+
import styles from '../../index.module.css';
|
|
7
|
+
|
|
8
|
+
type ListPopoverDesktopProps = {
|
|
9
|
+
open: boolean;
|
|
10
|
+
fieldRef: RefObject<HTMLInputElement>;
|
|
11
|
+
renderOptionsList: () => ReactNode;
|
|
12
|
+
} & ListPopoverDesktopRestProps;
|
|
13
|
+
|
|
14
|
+
export const ListPopoverDesktop: FC<ListPopoverDesktopProps> = (props) => {
|
|
15
|
+
const {
|
|
16
|
+
Popover,
|
|
17
|
+
open,
|
|
18
|
+
popoverProps,
|
|
19
|
+
fieldRef,
|
|
20
|
+
popoverPosition = 'bottom-start',
|
|
21
|
+
preventFlip = true,
|
|
22
|
+
popperClassName,
|
|
23
|
+
updatePopover,
|
|
24
|
+
zIndexPopover,
|
|
25
|
+
renderOptionsList,
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
if (Popover) {
|
|
29
|
+
return (
|
|
30
|
+
<Popover
|
|
31
|
+
{...popoverProps}
|
|
32
|
+
open={open}
|
|
33
|
+
withTransition={false}
|
|
34
|
+
anchorElement={fieldRef.current as HTMLElement}
|
|
35
|
+
position={popoverPosition}
|
|
36
|
+
preventFlip={preventFlip}
|
|
37
|
+
popperClassName={cn(styles.popoverInner, popperClassName)}
|
|
38
|
+
update={updatePopover}
|
|
39
|
+
zIndex={zIndexPopover}
|
|
40
|
+
>
|
|
41
|
+
{renderOptionsList()}
|
|
42
|
+
</Popover>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentProps } from '../../../types/component-types';
|
|
2
|
+
|
|
3
|
+
// отделяем необходимые пропсы для передачи в компонент
|
|
4
|
+
export const getListBottomSheetMobileProps = (props: ComponentProps) => {
|
|
5
|
+
const {
|
|
6
|
+
BottomSheet,
|
|
7
|
+
dataTestId,
|
|
8
|
+
label,
|
|
9
|
+
placeholder,
|
|
10
|
+
footer,
|
|
11
|
+
swipeable,
|
|
12
|
+
showSearch,
|
|
13
|
+
bottomSheetProps,
|
|
14
|
+
isBottomSheet = true,
|
|
15
|
+
nativeSelect = false,
|
|
16
|
+
onScroll,
|
|
17
|
+
} = props;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
BottomSheet,
|
|
21
|
+
dataTestId,
|
|
22
|
+
label,
|
|
23
|
+
placeholder,
|
|
24
|
+
footer,
|
|
25
|
+
swipeable,
|
|
26
|
+
showSearch,
|
|
27
|
+
bottomSheetProps,
|
|
28
|
+
isBottomSheet,
|
|
29
|
+
nativeSelect,
|
|
30
|
+
onScroll,
|
|
31
|
+
};
|
|
32
|
+
};
|
package/src/components/base-select/components/list-mobile/helpers/get-list-modal-mobile-props.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentProps } from '../../../types/component-types';
|
|
2
|
+
|
|
3
|
+
// отделяем необходимые пропсы для передачи в компонент
|
|
4
|
+
export const getListModalMobileProps = (props: ComponentProps) => {
|
|
5
|
+
const {
|
|
6
|
+
ModalMobile,
|
|
7
|
+
dataTestId,
|
|
8
|
+
modalProps,
|
|
9
|
+
modalHeaderProps,
|
|
10
|
+
modalFooterProps,
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
isBottomSheet = true,
|
|
14
|
+
nativeSelect = false,
|
|
15
|
+
onScroll,
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
ModalMobile,
|
|
20
|
+
dataTestId,
|
|
21
|
+
modalProps,
|
|
22
|
+
modalHeaderProps,
|
|
23
|
+
modalFooterProps,
|
|
24
|
+
label,
|
|
25
|
+
placeholder,
|
|
26
|
+
isBottomSheet,
|
|
27
|
+
nativeSelect,
|
|
28
|
+
onScroll,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { FC, ReactNode, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
import { OptionShape } from '@alfalab/core-components-select/typings';
|
|
4
|
+
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
5
|
+
|
|
6
|
+
import { ListBottomSheetMobileRestProps } from './types/types';
|
|
7
|
+
|
|
8
|
+
import mobileStyles from '../../mobile.module.css';
|
|
9
|
+
|
|
10
|
+
type ListMobileProps = {
|
|
11
|
+
open: boolean;
|
|
12
|
+
menuRef: RefObject<HTMLDivElement>;
|
|
13
|
+
scrollableContainerRef: RefObject<HTMLDivElement>;
|
|
14
|
+
flatOptions: OptionShape[];
|
|
15
|
+
closeMenu: () => void;
|
|
16
|
+
handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
|
|
17
|
+
renderSearch: () => ReactNode;
|
|
18
|
+
renderOptionsList: () => ReactNode;
|
|
19
|
+
} & ListBottomSheetMobileRestProps;
|
|
20
|
+
|
|
21
|
+
export const ListBottomSheetMobile: FC<ListMobileProps> = (props) => {
|
|
22
|
+
const {
|
|
23
|
+
BottomSheet,
|
|
24
|
+
dataTestId,
|
|
25
|
+
open,
|
|
26
|
+
label,
|
|
27
|
+
placeholder,
|
|
28
|
+
footer,
|
|
29
|
+
swipeable,
|
|
30
|
+
showSearch,
|
|
31
|
+
bottomSheetProps,
|
|
32
|
+
menuRef,
|
|
33
|
+
scrollableContainerRef,
|
|
34
|
+
onScroll,
|
|
35
|
+
flatOptions,
|
|
36
|
+
closeMenu,
|
|
37
|
+
handleEntered,
|
|
38
|
+
renderSearch,
|
|
39
|
+
renderOptionsList,
|
|
40
|
+
} = props;
|
|
41
|
+
|
|
42
|
+
if (BottomSheet) {
|
|
43
|
+
return (
|
|
44
|
+
<BottomSheet
|
|
45
|
+
dataTestId={getDataTestId(dataTestId, 'bottom-sheet')}
|
|
46
|
+
open={open}
|
|
47
|
+
className={mobileStyles.sheet}
|
|
48
|
+
contentClassName={mobileStyles.sheetContent}
|
|
49
|
+
containerClassName={mobileStyles.sheetContainer}
|
|
50
|
+
title={label || placeholder}
|
|
51
|
+
actionButton={footer}
|
|
52
|
+
stickyHeader={true}
|
|
53
|
+
hasCloser={true}
|
|
54
|
+
swipeable={swipeable}
|
|
55
|
+
initialHeight={showSearch ? 'full' : 'default'}
|
|
56
|
+
{...bottomSheetProps}
|
|
57
|
+
sheetContainerRef={menuRef}
|
|
58
|
+
scrollableContainerRef={scrollableContainerRef}
|
|
59
|
+
onClose={() => {
|
|
60
|
+
closeMenu();
|
|
61
|
+
bottomSheetProps?.onClose?.();
|
|
62
|
+
}}
|
|
63
|
+
transitionProps={{
|
|
64
|
+
...bottomSheetProps?.transitionProps,
|
|
65
|
+
onEntered: handleEntered,
|
|
66
|
+
}}
|
|
67
|
+
bottomAddons={
|
|
68
|
+
<React.Fragment>
|
|
69
|
+
{renderSearch()}
|
|
70
|
+
{flatOptions.length > 0 && bottomSheetProps?.bottomAddons}
|
|
71
|
+
</React.Fragment>
|
|
72
|
+
}
|
|
73
|
+
containerProps={{
|
|
74
|
+
...bottomSheetProps?.containerProps,
|
|
75
|
+
onScroll,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{renderOptionsList()}
|
|
79
|
+
</BottomSheet>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return null;
|
|
84
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { FC, ReactNode, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
import { OptionShape } from '@alfalab/core-components-select/typings';
|
|
4
|
+
|
|
5
|
+
import { ListBottomSheetMobileRestProps, ListModalMobileRestProps } from './types/types';
|
|
6
|
+
import { ListBottomSheetMobile } from './list-bottom-sheet-mobile';
|
|
7
|
+
import { ListModalMobile } from './list-modal-mobile';
|
|
8
|
+
|
|
9
|
+
type ListMobileProps = {
|
|
10
|
+
baseProps: ListBottomSheetMobileRestProps | ListModalMobileRestProps;
|
|
11
|
+
open: boolean;
|
|
12
|
+
menuRef: RefObject<HTMLDivElement>;
|
|
13
|
+
scrollableContainerRef: RefObject<HTMLDivElement>;
|
|
14
|
+
flatOptions: OptionShape[];
|
|
15
|
+
closeMenu: () => void;
|
|
16
|
+
handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
|
|
17
|
+
renderSearch: () => ReactNode;
|
|
18
|
+
renderOptionsList: () => ReactNode;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ListMobile: FC<ListMobileProps> = (props) => {
|
|
22
|
+
const { baseProps, ...restProps } = props;
|
|
23
|
+
const { isBottomSheet, nativeSelect } = baseProps;
|
|
24
|
+
|
|
25
|
+
if (isBottomSheet && !nativeSelect) {
|
|
26
|
+
return (
|
|
27
|
+
<ListBottomSheetMobile
|
|
28
|
+
{...(baseProps as ListBottomSheetMobileRestProps)}
|
|
29
|
+
{...restProps}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!isBottomSheet && !nativeSelect) {
|
|
35
|
+
return <ListModalMobile {...(baseProps as ListModalMobileRestProps)} {...restProps} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { FC, ReactNode, RefObject } from 'react';
|
|
2
|
+
import mergeRefs from 'react-merge-refs';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { OptionShape } from '@alfalab/core-components-select/typings';
|
|
6
|
+
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
7
|
+
|
|
8
|
+
import { ListModalMobileRestProps } from './types/types';
|
|
9
|
+
|
|
10
|
+
import mobileStyles from '../../mobile.module.css';
|
|
11
|
+
|
|
12
|
+
type ListModalMobileProps = {
|
|
13
|
+
open: boolean;
|
|
14
|
+
menuRef: RefObject<HTMLDivElement>;
|
|
15
|
+
scrollableContainerRef: RefObject<HTMLDivElement>;
|
|
16
|
+
flatOptions: OptionShape[];
|
|
17
|
+
closeMenu: () => void;
|
|
18
|
+
handleEntered: (node: HTMLElement, isAppearing: boolean) => void;
|
|
19
|
+
renderSearch: () => ReactNode;
|
|
20
|
+
renderOptionsList: () => ReactNode;
|
|
21
|
+
} & ListModalMobileRestProps;
|
|
22
|
+
|
|
23
|
+
export const ListModalMobile: FC<ListModalMobileProps> = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
ModalMobile,
|
|
26
|
+
dataTestId,
|
|
27
|
+
open,
|
|
28
|
+
modalProps,
|
|
29
|
+
modalHeaderProps,
|
|
30
|
+
modalFooterProps,
|
|
31
|
+
menuRef,
|
|
32
|
+
scrollableContainerRef,
|
|
33
|
+
label,
|
|
34
|
+
placeholder,
|
|
35
|
+
onScroll,
|
|
36
|
+
flatOptions,
|
|
37
|
+
closeMenu,
|
|
38
|
+
handleEntered,
|
|
39
|
+
renderSearch,
|
|
40
|
+
renderOptionsList,
|
|
41
|
+
} = props;
|
|
42
|
+
|
|
43
|
+
if (ModalMobile) {
|
|
44
|
+
return (
|
|
45
|
+
<ModalMobile
|
|
46
|
+
dataTestId={getDataTestId(dataTestId, 'modal')}
|
|
47
|
+
open={open}
|
|
48
|
+
hasCloser={true}
|
|
49
|
+
{...modalProps}
|
|
50
|
+
componentRef={menuRef}
|
|
51
|
+
onClose={(...args) => {
|
|
52
|
+
closeMenu();
|
|
53
|
+
modalProps?.onClose?.(...args);
|
|
54
|
+
}}
|
|
55
|
+
contentClassName={cn(mobileStyles.sheetContent, modalProps?.contentClassName)}
|
|
56
|
+
ref={mergeRefs([
|
|
57
|
+
scrollableContainerRef,
|
|
58
|
+
modalProps?.ref as React.Ref<HTMLDivElement>,
|
|
59
|
+
])}
|
|
60
|
+
wrapperProps={{
|
|
61
|
+
...modalProps?.wrapperProps,
|
|
62
|
+
onScroll,
|
|
63
|
+
}}
|
|
64
|
+
transitionProps={{
|
|
65
|
+
...modalProps?.transitionProps,
|
|
66
|
+
onEntered: handleEntered,
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<ModalMobile.Header
|
|
70
|
+
hasCloser={true}
|
|
71
|
+
sticky={true}
|
|
72
|
+
{...modalHeaderProps}
|
|
73
|
+
title={undefined}
|
|
74
|
+
bottomAddons={
|
|
75
|
+
<React.Fragment>
|
|
76
|
+
{renderSearch()}
|
|
77
|
+
{flatOptions.length > 0 && modalHeaderProps?.bottomAddons}
|
|
78
|
+
</React.Fragment>
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
{modalHeaderProps?.title || label || placeholder}
|
|
82
|
+
</ModalMobile.Header>
|
|
83
|
+
|
|
84
|
+
<ModalMobile.Content flex={true} className={mobileStyles.modalContent}>
|
|
85
|
+
{renderOptionsList()}
|
|
86
|
+
</ModalMobile.Content>
|
|
87
|
+
|
|
88
|
+
{modalFooterProps?.children && <ModalMobile.Footer {...modalFooterProps} />}
|
|
89
|
+
</ModalMobile>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return null;
|
|
94
|
+
};
|