@alfalab/core-components-select 15.3.0 → 16.0.1
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/Component.desktop.d.ts +3 -15
- package/Component.desktop.js +4 -2
- package/Component.mobile.d.ts +3 -39
- package/Component.mobile.js +23 -10
- package/Component.modal.mobile.d.ts +2 -256
- package/Component.modal.mobile.js +23 -35
- package/Component.responsive.d.ts +3 -17
- package/Component.responsive.js +11 -13
- package/components/arrow/Component.js +1 -1
- package/components/arrow/index.css +5 -5
- package/components/base-checkmark/Component.js +1 -1
- package/components/base-checkmark/index.css +4 -4
- package/components/base-option/Component.js +1 -1
- package/components/base-option/index.css +16 -16
- package/components/base-select/Component.d.ts +17 -2
- package/components/base-select/Component.js +188 -81
- package/components/base-select/index.css +12 -12
- package/components/base-select/index.js +1 -1
- package/{esm/components/base-select-mobile/index.css → components/base-select/mobile.css} +13 -22
- package/components/checkmark/Component.js +1 -1
- package/components/checkmark/index.css +11 -11
- package/components/checkmark-mobile/Component.js +1 -1
- package/components/checkmark-mobile/index.css +6 -6
- package/components/field/Component.js +1 -1
- package/components/field/index.css +15 -17
- package/components/footer/Component.d.ts +12 -0
- package/components/{base-select-mobile/footer → footer}/Component.js +6 -5
- package/components/{base-select-mobile/footer → footer}/index.css +6 -6
- package/components/footer/index.d.ts +1 -0
- package/components/{base-select-mobile/footer → footer}/index.js +3 -2
- package/components/index.js +2 -1
- package/components/optgroup/Component.js +1 -1
- package/components/optgroup/index.css +7 -7
- package/components/option/Component.js +1 -1
- package/components/option/index.css +24 -24
- package/components/options-list/Component.js +7 -3
- package/components/options-list/index.css +11 -11
- package/components/options-list/index.js +2 -1
- package/components/search/Component.d.ts +2 -4
- package/components/search/Component.js +1 -1
- package/components/search/index.css +2 -2
- package/components/virtual-options-list/Component.js +7 -3
- package/components/virtual-options-list/index.css +18 -18
- package/components/virtual-options-list/index.js +2 -1
- package/cssm/Component.desktop.d.ts +3 -15
- package/cssm/Component.desktop.js +5 -2
- package/cssm/Component.mobile.d.ts +3 -39
- package/cssm/Component.mobile.js +27 -13
- package/cssm/Component.modal.mobile.d.ts +2 -256
- package/cssm/Component.modal.mobile.js +28 -39
- package/cssm/Component.responsive.d.ts +3 -17
- package/cssm/Component.responsive.js +13 -15
- package/cssm/components/arrow/index.module.css +2 -2
- package/cssm/components/base-option/index.module.css +3 -3
- package/cssm/components/base-select/Component.d.ts +17 -2
- package/cssm/components/base-select/Component.js +186 -80
- package/cssm/components/base-select/index.js +2 -1
- package/cssm/components/base-select/index.module.css +2 -2
- package/cssm/components/{base-select-mobile/index.module.css → base-select/mobile.module.css} +0 -9
- package/cssm/components/checkmark/index.module.css +1 -1
- package/cssm/components/field/index.module.css +3 -5
- package/cssm/components/footer/Component.d.ts +12 -0
- package/cssm/components/{base-select-mobile/footer → footer}/Component.js +5 -4
- package/cssm/components/footer/index.d.ts +1 -0
- package/cssm/components/{base-select-mobile/footer → footer}/index.js +3 -2
- package/cssm/components/{base-select-mobile/footer → footer}/index.module.css +1 -1
- package/cssm/components/index.js +3 -1
- package/cssm/components/optgroup/index.module.css +1 -1
- package/cssm/components/option/index.module.css +4 -4
- package/cssm/components/options-list/Component.js +6 -2
- package/cssm/components/options-list/index.js +2 -1
- package/cssm/components/options-list/index.module.css +2 -2
- package/cssm/components/search/Component.d.ts +2 -4
- package/cssm/components/virtual-options-list/Component.js +6 -2
- package/cssm/components/virtual-options-list/index.js +2 -1
- package/cssm/components/virtual-options-list/index.module.css +3 -3
- package/cssm/desktop/index.d.ts +2 -2
- package/cssm/desktop/index.js +4 -1
- package/cssm/{hook-244c8d6e.js → hook-2f9ec939.js} +9 -5
- package/{esm/hook-8abfea97.d.ts → cssm/hook-ad89c253.d.ts} +3 -2
- package/cssm/index.d.ts +2 -2
- package/cssm/index.js +10 -9
- package/cssm/mobile/index.d.ts +1 -3
- package/cssm/mobile/index.js +15 -10
- package/cssm/presets/index.d.ts +1 -1
- package/cssm/presets/index.js +3 -2
- package/cssm/presets/useSelectWithApply/hook.js +3 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
- package/cssm/shared/index.d.ts +9 -2
- package/cssm/shared/index.js +50 -48
- package/cssm/typings.d.ts +86 -7
- package/desktop/index.d.ts +2 -2
- package/desktop/index.js +3 -1
- package/esm/Component.desktop.d.ts +3 -15
- package/esm/Component.desktop.js +4 -2
- package/esm/Component.mobile.d.ts +3 -39
- package/esm/Component.mobile.js +22 -9
- package/esm/Component.modal.mobile.d.ts +2 -256
- package/esm/Component.modal.mobile.js +24 -36
- package/esm/Component.responsive.d.ts +3 -17
- package/esm/Component.responsive.js +11 -13
- package/esm/components/arrow/Component.js +1 -1
- package/esm/components/arrow/index.css +5 -5
- package/esm/components/base-checkmark/Component.js +1 -1
- package/esm/components/base-checkmark/index.css +4 -4
- package/esm/components/base-option/Component.js +1 -1
- package/esm/components/base-option/index.css +16 -16
- package/esm/components/base-select/Component.d.ts +17 -2
- package/esm/components/base-select/Component.js +190 -83
- package/esm/components/base-select/index.css +12 -12
- package/esm/components/base-select/index.js +1 -1
- package/{modern/components/base-select-mobile/index.css → esm/components/base-select/mobile.css} +13 -22
- package/esm/components/checkmark/Component.js +1 -1
- package/esm/components/checkmark/index.css +11 -11
- package/esm/components/checkmark-mobile/Component.js +1 -1
- package/esm/components/checkmark-mobile/index.css +6 -6
- package/esm/components/field/Component.js +1 -1
- package/esm/components/field/index.css +15 -17
- package/esm/components/footer/Component.d.ts +12 -0
- package/esm/components/{base-select-mobile/footer → footer}/Component.js +6 -5
- package/esm/components/{base-select-mobile/footer → footer}/index.css +6 -6
- package/esm/components/footer/index.d.ts +1 -0
- package/esm/components/{base-select-mobile/footer → footer}/index.js +1 -0
- package/esm/components/index.js +2 -1
- package/esm/components/optgroup/Component.js +1 -1
- package/esm/components/optgroup/index.css +7 -7
- package/esm/components/option/Component.js +1 -1
- package/esm/components/option/index.css +24 -24
- package/esm/components/options-list/Component.js +7 -3
- package/esm/components/options-list/index.css +11 -11
- package/esm/components/options-list/index.js +2 -1
- package/esm/components/search/Component.d.ts +2 -4
- package/esm/components/search/Component.js +1 -1
- package/esm/components/search/index.css +2 -2
- package/esm/components/virtual-options-list/Component.js +7 -3
- package/esm/components/virtual-options-list/index.css +18 -18
- package/esm/components/virtual-options-list/index.js +2 -1
- package/esm/desktop/index.d.ts +2 -2
- package/esm/desktop/index.js +3 -1
- package/{hook-8abfea97.d.ts → esm/hook-ad89c253.d.ts} +3 -2
- package/esm/{hook-70d58270.js → hook-d82699d1.js} +10 -6
- package/esm/index.d.ts +2 -2
- package/esm/index.js +8 -7
- package/esm/mobile/index.d.ts +1 -3
- package/esm/mobile/index.js +12 -8
- package/esm/presets/index.d.ts +1 -1
- package/esm/presets/index.js +3 -2
- package/esm/presets/useSelectWithApply/hook.js +3 -2
- package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
- package/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
- package/esm/presets/useSelectWithLoading/hook.js +1 -1
- package/esm/presets/useSelectWithLoading/index.css +2 -2
- package/esm/shared/index.d.ts +9 -2
- package/esm/shared/index.js +30 -29
- package/esm/typings.d.ts +86 -7
- package/{cssm/hook-8abfea97.d.ts → hook-ad89c253.d.ts} +3 -2
- package/{hook-0a5c9f56.js → hook-df30325f.js} +9 -5
- package/index.d.ts +2 -2
- package/index.js +8 -7
- package/mobile/index.d.ts +1 -3
- package/mobile/index.js +12 -8
- package/modern/Component.desktop.d.ts +3 -15
- package/modern/Component.desktop.js +5 -3
- package/modern/Component.mobile.d.ts +3 -39
- package/modern/Component.mobile.js +29 -13
- package/modern/Component.modal.mobile.d.ts +2 -256
- package/modern/Component.modal.mobile.js +23 -43
- package/modern/Component.responsive.d.ts +3 -17
- package/modern/Component.responsive.js +11 -13
- package/modern/components/arrow/Component.js +1 -1
- package/modern/components/arrow/index.css +5 -5
- package/modern/components/base-checkmark/Component.js +1 -1
- package/modern/components/base-checkmark/index.css +4 -4
- package/modern/components/base-option/Component.js +1 -1
- package/modern/components/base-option/index.css +16 -16
- package/modern/components/base-select/Component.d.ts +17 -2
- package/modern/components/base-select/Component.js +179 -72
- package/modern/components/base-select/index.css +12 -12
- package/modern/components/base-select/index.js +1 -1
- package/{components/base-select-mobile/index.css → modern/components/base-select/mobile.css} +13 -22
- package/modern/components/checkmark/Component.js +1 -1
- package/modern/components/checkmark/index.css +11 -11
- package/modern/components/checkmark-mobile/Component.js +1 -1
- package/modern/components/checkmark-mobile/index.css +6 -6
- package/modern/components/field/Component.js +1 -1
- package/modern/components/field/index.css +15 -17
- package/modern/components/footer/Component.d.ts +12 -0
- package/modern/components/{base-select-mobile/footer → footer}/Component.js +5 -4
- package/modern/components/{base-select-mobile/footer → footer}/index.css +6 -6
- package/modern/components/footer/index.d.ts +1 -0
- package/modern/components/{base-select-mobile/footer → footer}/index.js +1 -0
- package/modern/components/index.js +2 -1
- package/modern/components/optgroup/Component.js +1 -1
- package/modern/components/optgroup/index.css +7 -7
- package/modern/components/option/Component.js +1 -1
- package/modern/components/option/index.css +24 -24
- package/modern/components/options-list/Component.js +5 -3
- package/modern/components/options-list/index.css +11 -11
- package/modern/components/options-list/index.js +2 -1
- package/modern/components/search/Component.d.ts +2 -4
- package/modern/components/search/Component.js +1 -1
- package/modern/components/search/index.css +2 -2
- package/modern/components/virtual-options-list/Component.js +5 -3
- package/modern/components/virtual-options-list/index.css +18 -18
- package/modern/components/virtual-options-list/index.js +2 -1
- package/modern/desktop/index.d.ts +2 -2
- package/modern/desktop/index.js +3 -1
- package/modern/{hook-8abfea97.d.ts → hook-ad89c253.d.ts} +3 -2
- package/modern/{hook-4eceefed.js → hook-d879e08e.js} +7 -3
- package/modern/index.d.ts +2 -2
- package/modern/index.js +8 -7
- package/modern/mobile/index.d.ts +1 -3
- package/modern/mobile/index.js +12 -8
- package/modern/presets/index.d.ts +1 -1
- package/modern/presets/index.js +3 -2
- package/modern/presets/useSelectWithApply/hook.js +3 -2
- package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
- package/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
- package/modern/presets/useSelectWithLoading/hook.js +1 -1
- package/modern/presets/useSelectWithLoading/index.css +2 -2
- package/modern/shared/index.d.ts +9 -2
- package/modern/shared/index.js +29 -28
- package/modern/typings.d.ts +86 -7
- package/package.json +13 -11
- package/presets/index.d.ts +1 -1
- package/presets/index.js +3 -2
- package/presets/useSelectWithApply/hook.js +3 -2
- package/presets/useSelectWithApply/options-list-with-apply/Component.js +3 -2
- package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +3 -3
- package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/header/index.css +3 -3
- package/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/index.js +3 -2
- package/presets/useSelectWithLoading/hook.js +1 -1
- package/presets/useSelectWithLoading/index.css +2 -2
- package/shared/index.d.ts +9 -2
- package/shared/index.js +39 -38
- package/src/Component.desktop.tsx +5 -14
- package/src/Component.mobile.tsx +38 -57
- package/src/Component.modal.mobile.tsx +5 -147
- package/src/Component.responsive.tsx +9 -44
- package/src/components/base-select/Component.tsx +380 -156
- package/src/components/base-select/index.module.css +1 -1
- package/src/components/{base-select-mobile/index.module.css → base-select/mobile.module.css} +0 -15
- package/src/components/{base-select-mobile/footer → footer}/Component.tsx +22 -4
- package/src/components/{base-select-mobile/footer → footer}/index.module.css +1 -1
- package/src/components/footer/index.ts +1 -0
- package/src/components/options-list/Component.tsx +6 -2
- package/src/components/virtual-options-list/Component.tsx +6 -2
- package/src/desktop/index.ts +2 -1
- package/src/index.ts +2 -4
- package/src/mobile/index.ts +1 -2
- package/src/presets/useSelectWithApply/hook.tsx +9 -3
- package/src/shared/index.ts +10 -2
- package/src/typings.ts +110 -9
- package/src/vars.css +1 -1
- package/typings.d.ts +86 -7
- package/components/base-select-mobile/Component.d.ts +0 -71
- package/components/base-select-mobile/Component.js +0 -296
- package/components/base-select-mobile/footer/Component.d.ts +0 -9
- package/components/base-select-mobile/footer/index.d.ts +0 -1
- package/components/base-select-mobile/index.d.ts +0 -1
- package/components/base-select-mobile/index.js +0 -36
- package/cssm/components/base-select-mobile/Component.d.ts +0 -71
- package/cssm/components/base-select-mobile/Component.js +0 -303
- package/cssm/components/base-select-mobile/footer/Component.d.ts +0 -9
- package/cssm/components/base-select-mobile/footer/index.d.ts +0 -1
- package/cssm/components/base-select-mobile/index.d.ts +0 -1
- package/cssm/components/base-select-mobile/index.js +0 -45
- package/esm/components/base-select-mobile/Component.d.ts +0 -71
- package/esm/components/base-select-mobile/Component.js +0 -286
- package/esm/components/base-select-mobile/footer/Component.d.ts +0 -9
- package/esm/components/base-select-mobile/footer/index.d.ts +0 -1
- package/esm/components/base-select-mobile/index.d.ts +0 -1
- package/esm/components/base-select-mobile/index.js +0 -28
- package/modern/components/base-select-mobile/Component.d.ts +0 -71
- package/modern/components/base-select-mobile/Component.js +0 -285
- package/modern/components/base-select-mobile/footer/Component.d.ts +0 -9
- package/modern/components/base-select-mobile/footer/index.d.ts +0 -1
- package/modern/components/base-select-mobile/index.d.ts +0 -1
- package/modern/components/base-select-mobile/index.js +0 -27
- package/src/components/base-select-mobile/Component.tsx +0 -572
- package/src/components/base-select-mobile/footer/index.ts +0 -1
- package/src/components/base-select-mobile/index.ts +0 -1
- /package/cssm/{hook-244c8d6e.d.ts → hook-2f9ec939.d.ts} +0 -0
- /package/esm/{hook-70d58270.d.ts → hook-d82699d1.d.ts} +0 -0
- /package/{hook-0a5c9f56.d.ts → hook-df30325f.d.ts} +0 -0
- /package/modern/{hook-4eceefed.d.ts → hook-d879e08e.d.ts} +0 -0
package/src/components/{base-select-mobile/index.module.css → base-select/mobile.module.css}
RENAMED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
2
|
@import '../../vars.css';
|
|
3
3
|
|
|
4
|
-
.component {
|
|
5
|
-
width: max-content;
|
|
6
|
-
position: relative;
|
|
7
|
-
outline: 0;
|
|
8
|
-
max-width: 100%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
4
|
.sheet {
|
|
12
5
|
overflow: hidden;
|
|
13
6
|
}
|
|
@@ -26,10 +19,6 @@
|
|
|
26
19
|
padding: 0;
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
.block {
|
|
30
|
-
width: 100%;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
22
|
.optionsListWrapper {
|
|
34
23
|
flex: 1;
|
|
35
24
|
}
|
|
@@ -44,10 +33,6 @@
|
|
|
44
33
|
flex: 1;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
.emptySearchPlaceholder {
|
|
48
|
-
text-align: center;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
36
|
.search {
|
|
52
37
|
padding: var(--gap-xs);
|
|
53
38
|
}
|
|
@@ -3,6 +3,7 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import { BaseModalContext } from '@alfalab/core-components-base-modal';
|
|
5
5
|
import { ButtonMobile } from '@alfalab/core-components-button/mobile';
|
|
6
|
+
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
6
7
|
|
|
7
8
|
import styles from './index.module.css';
|
|
8
9
|
|
|
@@ -10,9 +11,19 @@ export type FooterProps = {
|
|
|
10
11
|
handleClear?: () => void;
|
|
11
12
|
handleApply?: () => void;
|
|
12
13
|
showClear?: boolean;
|
|
14
|
+
clearText?: string;
|
|
15
|
+
applyText?: string;
|
|
16
|
+
dataTestId?: string;
|
|
13
17
|
};
|
|
14
18
|
|
|
15
|
-
export const Footer = ({
|
|
19
|
+
export const Footer = ({
|
|
20
|
+
handleApply,
|
|
21
|
+
handleClear,
|
|
22
|
+
showClear,
|
|
23
|
+
clearText = 'Сбросить',
|
|
24
|
+
applyText = 'Применить',
|
|
25
|
+
dataTestId,
|
|
26
|
+
}: FooterProps) => {
|
|
16
27
|
const { footerHighlighted, setHasFooter } = useContext(BaseModalContext);
|
|
17
28
|
|
|
18
29
|
useEffect(() => {
|
|
@@ -33,13 +44,20 @@ export const Footer = ({ handleApply, handleClear, showClear }: FooterProps) =>
|
|
|
33
44
|
view='secondary'
|
|
34
45
|
className={styles.button}
|
|
35
46
|
onClick={handleClear}
|
|
47
|
+
dataTestId={getDataTestId(dataTestId, 'clear')}
|
|
36
48
|
>
|
|
37
|
-
|
|
49
|
+
{clearText}
|
|
38
50
|
</ButtonMobile>
|
|
39
51
|
)}
|
|
40
52
|
|
|
41
|
-
<ButtonMobile
|
|
42
|
-
|
|
53
|
+
<ButtonMobile
|
|
54
|
+
size='m'
|
|
55
|
+
view='primary'
|
|
56
|
+
className={styles.button}
|
|
57
|
+
onClick={handleApply}
|
|
58
|
+
dataTestId={getDataTestId(dataTestId, 'apply')}
|
|
59
|
+
>
|
|
60
|
+
{applyText}
|
|
43
61
|
</ButtonMobile>
|
|
44
62
|
</div>
|
|
45
63
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Footer } from './Component';
|
|
@@ -2,8 +2,9 @@ import React, { forwardRef, useRef } from 'react';
|
|
|
2
2
|
import mergeRefs from 'react-merge-refs';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
|
|
5
|
+
import { useMatchMedia } from '@alfalab/core-components-mq';
|
|
5
6
|
import { Scrollbar } from '@alfalab/core-components-scrollbar';
|
|
6
|
-
import {
|
|
7
|
+
import { isClient } from '@alfalab/core-components-shared';
|
|
7
8
|
|
|
8
9
|
import { DEFAULT_VISIBLE_OPTIONS } from '../../consts';
|
|
9
10
|
import { GroupShape, OptionShape, OptionsListProps } from '../../typings';
|
|
@@ -45,7 +46,10 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
|
|
|
45
46
|
},
|
|
46
47
|
ref,
|
|
47
48
|
) => {
|
|
48
|
-
|
|
49
|
+
const query = '(max-width: 1023px)';
|
|
50
|
+
let [nativeScrollbar] = useMatchMedia(query, () =>
|
|
51
|
+
isClient() ? window.matchMedia(query).matches : true,
|
|
52
|
+
);
|
|
49
53
|
|
|
50
54
|
nativeScrollbar = Boolean(nativeScrollbarProp ?? nativeScrollbar);
|
|
51
55
|
|
|
@@ -3,8 +3,9 @@ import mergeRefs from 'react-merge-refs';
|
|
|
3
3
|
import { useVirtual } from 'react-virtual';
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
|
|
6
|
+
import { useMatchMedia } from '@alfalab/core-components-mq';
|
|
6
7
|
import { Scrollbar } from '@alfalab/core-components-scrollbar';
|
|
7
|
-
import {
|
|
8
|
+
import { isClient } from '@alfalab/core-components-shared';
|
|
8
9
|
|
|
9
10
|
import { DEFAULT_VISIBLE_OPTIONS } from '../../consts';
|
|
10
11
|
import { GroupShape, OptionShape, OptionsListProps } from '../../typings';
|
|
@@ -44,7 +45,10 @@ export const VirtualOptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
|
|
|
44
45
|
const [visibleOptionsInvalidateKey, setVisibleOptionsInvalidateKey] = useState('');
|
|
45
46
|
const prevHighlightedIndex = usePrevious(highlightedIndex) || -1;
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
const query = '(max-width: 1023px)';
|
|
49
|
+
let [nativeScrollbar] = useMatchMedia(query, () =>
|
|
50
|
+
isClient() ? window.matchMedia(query).matches : true,
|
|
51
|
+
);
|
|
48
52
|
|
|
49
53
|
const rowVirtualizer = useVirtual({
|
|
50
54
|
size: flatOptions.length,
|
package/src/desktop/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { SelectDesktop
|
|
1
|
+
export { SelectDesktop } from '../Component.desktop';
|
|
2
|
+
export type { SelectDesktopProps } from '../typings';
|
package/src/index.ts
CHANGED
package/src/mobile/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { SelectMobile } from '../Component.mobile';
|
|
2
2
|
export { SelectModalMobile } from '../Component.modal.mobile';
|
|
3
3
|
|
|
4
|
-
export type { SelectMobileProps } from '../
|
|
5
|
-
export type { SelectModalMobileProps } from '../Component.modal.mobile';
|
|
4
|
+
export type { SelectMobileProps, SelectModalMobileProps } from '../typings';
|
|
@@ -73,18 +73,24 @@ export function useSelectWithApply({
|
|
|
73
73
|
showSearch,
|
|
74
74
|
searchProps = {},
|
|
75
75
|
}: UseSelectWithApplyProps) {
|
|
76
|
-
const [
|
|
76
|
+
const [searchState, setSearchState] = useState('');
|
|
77
|
+
|
|
78
|
+
const [search, setSearch] =
|
|
79
|
+
typeof searchProps?.value === 'string'
|
|
80
|
+
? [searchProps.value, searchProps.onChange]
|
|
81
|
+
: [searchState, setSearchState];
|
|
77
82
|
|
|
78
83
|
const accessor = searchProps.accessor || defaultAccessor;
|
|
84
|
+
const filterFn = searchProps.filterFn || defaultFilterFn;
|
|
79
85
|
|
|
80
86
|
const { flatOptions, selectedOptions } = useMemo(
|
|
81
87
|
() =>
|
|
82
88
|
processOptions(
|
|
83
89
|
options,
|
|
84
90
|
selected,
|
|
85
|
-
showSearch ? (option) =>
|
|
91
|
+
showSearch ? (option) => filterFn(accessor(option), search) : undefined,
|
|
86
92
|
),
|
|
87
|
-
[accessor, options, search, selected, showSearch],
|
|
93
|
+
[filterFn, accessor, options, search, selected, showSearch],
|
|
88
94
|
);
|
|
89
95
|
|
|
90
96
|
const [selectedDraft, setSelectedDraft] = useState<OptionShape[]>(selectedOptions);
|
package/src/shared/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
export * from '../components';
|
|
2
1
|
export * from '../presets';
|
|
3
2
|
export * from '../typings';
|
|
4
3
|
export * from '../utils';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
export * from '../components/option';
|
|
6
|
+
export * from '../components/base-option';
|
|
7
|
+
export * from '../components/options-list';
|
|
8
|
+
export * from '../components/virtual-options-list';
|
|
9
|
+
export * from '../components/field';
|
|
10
|
+
export * from '../components/arrow';
|
|
11
|
+
export * from '../components/base-select';
|
|
12
|
+
export * from '../components/optgroup';
|
|
13
|
+
export * from '../components/footer';
|
package/src/typings.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
AriaAttributes,
|
|
3
3
|
FC,
|
|
4
4
|
FocusEvent,
|
|
@@ -9,8 +9,14 @@ import {
|
|
|
9
9
|
SVGProps,
|
|
10
10
|
} from 'react';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import type { BottomSheetProps } from '@alfalab/core-components-bottom-sheet';
|
|
13
|
+
import type { FormControlProps } from '@alfalab/core-components-form-control';
|
|
14
|
+
import type { InputProps } from '@alfalab/core-components-input';
|
|
15
|
+
import type { ModalProps } from '@alfalab/core-components-modal';
|
|
16
|
+
import type { ModalFooterProps, ModalHeaderProps } from '@alfalab/core-components-modal/shared';
|
|
17
|
+
import type { PopoverProps } from '@alfalab/core-components-popover';
|
|
18
|
+
|
|
19
|
+
import type { UseSelectWithApplyProps } from './presets/useSelectWithApply/hook';
|
|
14
20
|
|
|
15
21
|
// eslint-disable-next-line
|
|
16
22
|
export type AnyObject = Record<string, any>;
|
|
@@ -284,7 +290,7 @@ export type BaseSelectProps = {
|
|
|
284
290
|
/**
|
|
285
291
|
* Компонент поиска
|
|
286
292
|
*/
|
|
287
|
-
Search?: FC<SearchProps
|
|
293
|
+
Search?: FC<SearchProps>;
|
|
288
294
|
|
|
289
295
|
/**
|
|
290
296
|
* Настройки поиска
|
|
@@ -292,6 +298,7 @@ export type BaseSelectProps = {
|
|
|
292
298
|
searchProps?: {
|
|
293
299
|
componentProps?: SearchProps;
|
|
294
300
|
accessor?: (option: OptionShape) => string;
|
|
301
|
+
filterFn?: (optionText: string, search: string) => boolean;
|
|
295
302
|
value?: string;
|
|
296
303
|
onChange?: (value: string) => void;
|
|
297
304
|
};
|
|
@@ -665,10 +672,10 @@ export type OptionProps = {
|
|
|
665
672
|
*/
|
|
666
673
|
innerProps: {
|
|
667
674
|
id: string;
|
|
668
|
-
onClick
|
|
669
|
-
onMouseDown
|
|
670
|
-
onMouseMove
|
|
671
|
-
role
|
|
675
|
+
onClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
676
|
+
onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
677
|
+
onMouseMove?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
678
|
+
role?: string;
|
|
672
679
|
} & RefAttributes<HTMLDivElement> &
|
|
673
680
|
AriaAttributes;
|
|
674
681
|
|
|
@@ -720,4 +727,98 @@ export type CheckmarkProps = {
|
|
|
720
727
|
icon?: FC<SVGProps<SVGSVGElement>>;
|
|
721
728
|
};
|
|
722
729
|
|
|
723
|
-
export type SearchProps = InputProps
|
|
730
|
+
export type SearchProps = InputProps & RefAttributes<HTMLInputElement>;
|
|
731
|
+
|
|
732
|
+
export type SelectFieldProps = Omit<FormControlProps, 'size'> & Record<string, unknown>;
|
|
733
|
+
|
|
734
|
+
export type AdditionalMobileProps = {
|
|
735
|
+
/**
|
|
736
|
+
* Показывать кнопку 'Сбросить' в футере мобильного компонента
|
|
737
|
+
*/
|
|
738
|
+
showClear?: UseSelectWithApplyProps['showClear'];
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Показывать пункт "Выбрать все"
|
|
742
|
+
*/
|
|
743
|
+
showSelectAll?: UseSelectWithApplyProps['showSelectAll'];
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Показывать пункт "Выбрать все" в заголовке списка у мобильного компонента
|
|
747
|
+
*/
|
|
748
|
+
showHeaderWithSelectAll?: UseSelectWithApplyProps['showHeaderWithSelectAll'];
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Использовать ли хук useSelectWithApply в мобильном компоненте
|
|
752
|
+
*/
|
|
753
|
+
useWithApplyHook?: boolean;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
export type BottomSheetSelectMobileProps = {
|
|
757
|
+
/**
|
|
758
|
+
* Футер
|
|
759
|
+
* @deprecated Используйте bottomSheetProps.actionButton
|
|
760
|
+
*/
|
|
761
|
+
footer?: ReactNode;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Будет ли свайпаться шторка
|
|
765
|
+
* @deprecated Используйте bottomSheetProps.swipeable
|
|
766
|
+
*/
|
|
767
|
+
swipeable?: boolean;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Дополнительные пропсы шторки
|
|
771
|
+
*/
|
|
772
|
+
bottomSheetProps?: Partial<BottomSheetProps>;
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
export type ModalSelectMobileProps = {
|
|
776
|
+
/**
|
|
777
|
+
* Дополнительные пропсы шапки модалки
|
|
778
|
+
*/
|
|
779
|
+
modalHeaderProps?: Partial<ModalHeaderProps>;
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Дополнительные пропсы модалки
|
|
783
|
+
*/
|
|
784
|
+
modalProps?: Partial<ModalProps & RefAttributes<HTMLDivElement>>;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Дополнительные пропсы футера модалки
|
|
788
|
+
*/
|
|
789
|
+
modalFooterProps?: Partial<ModalFooterProps>;
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
type ConditionalMobileProps =
|
|
793
|
+
| ({ isBottomSheet?: true } & BottomSheetSelectMobileProps)
|
|
794
|
+
| ({ isBottomSheet: false } & ModalSelectMobileProps);
|
|
795
|
+
|
|
796
|
+
export type SelectModalMobileProps = Omit<BaseSelectProps, 'Checkmark'> &
|
|
797
|
+
AdditionalMobileProps &
|
|
798
|
+
ModalSelectMobileProps;
|
|
799
|
+
|
|
800
|
+
export type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark'> &
|
|
801
|
+
AdditionalMobileProps &
|
|
802
|
+
ConditionalMobileProps;
|
|
803
|
+
|
|
804
|
+
export type SelectDesktopProps = Omit<BaseSelectProps, 'fieldProps'> & {
|
|
805
|
+
/**
|
|
806
|
+
* Пропсы, которые будут прокинуты в компонент поля
|
|
807
|
+
*/
|
|
808
|
+
fieldProps?: SelectFieldProps;
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
export type SelectProps = BaseSelectProps &
|
|
812
|
+
AdditionalMobileProps &
|
|
813
|
+
ConditionalMobileProps & {
|
|
814
|
+
/**
|
|
815
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
816
|
+
* @default 1024
|
|
817
|
+
*/
|
|
818
|
+
breakpoint?: number;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Значение по-умолчанию для хука useMatchMedia
|
|
822
|
+
*/
|
|
823
|
+
defaultMatchMediaValue?: boolean | (() => boolean);
|
|
824
|
+
};
|
package/src/vars.css
CHANGED
package/typings.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { AriaAttributes, FC, FocusEvent, MouseEvent, ReactElement, ReactNode, RefAttributes, SVGProps } from 'react';
|
|
2
|
+
import { BottomSheetProps } from "@alfalab/core-components-bottom-sheet";
|
|
3
|
+
import { FormControlProps } from "@alfalab/core-components-form-control";
|
|
2
4
|
import { InputProps } from "@alfalab/core-components-input";
|
|
5
|
+
import { ModalProps } from "@alfalab/core-components-modal";
|
|
6
|
+
import { ModalFooterProps, ModalHeaderProps } from "@alfalab/core-components-modal/shared";
|
|
3
7
|
import { PopoverProps } from "@alfalab/core-components-popover";
|
|
8
|
+
import { UseSelectWithApplyProps } from "./hook-ad89c253";
|
|
4
9
|
type AnyObject = Record<string, any>;
|
|
5
10
|
type OptionShape = {
|
|
6
11
|
/**
|
|
@@ -217,13 +222,14 @@ type BaseSelectProps = {
|
|
|
217
222
|
/**
|
|
218
223
|
* Компонент поиска
|
|
219
224
|
*/
|
|
220
|
-
Search?: FC<SearchProps
|
|
225
|
+
Search?: FC<SearchProps>;
|
|
221
226
|
/**
|
|
222
227
|
* Настройки поиска
|
|
223
228
|
*/
|
|
224
229
|
searchProps?: {
|
|
225
230
|
componentProps?: SearchProps;
|
|
226
231
|
accessor?: (option: OptionShape) => string;
|
|
232
|
+
filterFn?: (optionText: string, search: string) => boolean;
|
|
227
233
|
value?: string;
|
|
228
234
|
onChange?: (value: string) => void;
|
|
229
235
|
};
|
|
@@ -528,10 +534,10 @@ type OptionProps = {
|
|
|
528
534
|
*/
|
|
529
535
|
innerProps: {
|
|
530
536
|
id: string;
|
|
531
|
-
onClick
|
|
532
|
-
onMouseDown
|
|
533
|
-
onMouseMove
|
|
534
|
-
role
|
|
537
|
+
onClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
538
|
+
onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
539
|
+
onMouseMove?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
540
|
+
role?: string;
|
|
535
541
|
} & RefAttributes<HTMLDivElement> & AriaAttributes;
|
|
536
542
|
/**
|
|
537
543
|
* Идентификатор для систем автоматизированного тестирования
|
|
@@ -572,5 +578,78 @@ type CheckmarkProps = {
|
|
|
572
578
|
*/
|
|
573
579
|
icon?: FC<SVGProps<SVGSVGElement>>;
|
|
574
580
|
};
|
|
575
|
-
type SearchProps = InputProps
|
|
576
|
-
|
|
581
|
+
type SearchProps = InputProps & RefAttributes<HTMLInputElement>;
|
|
582
|
+
type SelectFieldProps = Omit<FormControlProps, 'size'> & Record<string, unknown>;
|
|
583
|
+
type AdditionalMobileProps = {
|
|
584
|
+
/**
|
|
585
|
+
* Показывать кнопку 'Сбросить' в футере мобильного компонента
|
|
586
|
+
*/
|
|
587
|
+
showClear?: UseSelectWithApplyProps['showClear'];
|
|
588
|
+
/**
|
|
589
|
+
* Показывать пункт "Выбрать все"
|
|
590
|
+
*/
|
|
591
|
+
showSelectAll?: UseSelectWithApplyProps['showSelectAll'];
|
|
592
|
+
/**
|
|
593
|
+
* Показывать пункт "Выбрать все" в заголовке списка у мобильного компонента
|
|
594
|
+
*/
|
|
595
|
+
showHeaderWithSelectAll?: UseSelectWithApplyProps['showHeaderWithSelectAll'];
|
|
596
|
+
/**
|
|
597
|
+
* Использовать ли хук useSelectWithApply в мобильном компоненте
|
|
598
|
+
*/
|
|
599
|
+
useWithApplyHook?: boolean;
|
|
600
|
+
};
|
|
601
|
+
type BottomSheetSelectMobileProps = {
|
|
602
|
+
/**
|
|
603
|
+
* Футер
|
|
604
|
+
* @deprecated Используйте bottomSheetProps.actionButton
|
|
605
|
+
*/
|
|
606
|
+
footer?: ReactNode;
|
|
607
|
+
/**
|
|
608
|
+
* Будет ли свайпаться шторка
|
|
609
|
+
* @deprecated Используйте bottomSheetProps.swipeable
|
|
610
|
+
*/
|
|
611
|
+
swipeable?: boolean;
|
|
612
|
+
/**
|
|
613
|
+
* Дополнительные пропсы шторки
|
|
614
|
+
*/
|
|
615
|
+
bottomSheetProps?: Partial<BottomSheetProps>;
|
|
616
|
+
};
|
|
617
|
+
type ModalSelectMobileProps = {
|
|
618
|
+
/**
|
|
619
|
+
* Дополнительные пропсы шапки модалки
|
|
620
|
+
*/
|
|
621
|
+
modalHeaderProps?: Partial<ModalHeaderProps>;
|
|
622
|
+
/**
|
|
623
|
+
* Дополнительные пропсы модалки
|
|
624
|
+
*/
|
|
625
|
+
modalProps?: Partial<ModalProps & RefAttributes<HTMLDivElement>>;
|
|
626
|
+
/**
|
|
627
|
+
* Дополнительные пропсы футера модалки
|
|
628
|
+
*/
|
|
629
|
+
modalFooterProps?: Partial<ModalFooterProps>;
|
|
630
|
+
};
|
|
631
|
+
type ConditionalMobileProps = ({
|
|
632
|
+
isBottomSheet?: true;
|
|
633
|
+
} & BottomSheetSelectMobileProps) | ({
|
|
634
|
+
isBottomSheet: false;
|
|
635
|
+
} & ModalSelectMobileProps);
|
|
636
|
+
type SelectModalMobileProps = Omit<BaseSelectProps, 'Checkmark'> & AdditionalMobileProps & ModalSelectMobileProps;
|
|
637
|
+
type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark'> & AdditionalMobileProps & ConditionalMobileProps;
|
|
638
|
+
type SelectDesktopProps = Omit<BaseSelectProps, 'fieldProps'> & {
|
|
639
|
+
/**
|
|
640
|
+
* Пропсы, которые будут прокинуты в компонент поля
|
|
641
|
+
*/
|
|
642
|
+
fieldProps?: SelectFieldProps;
|
|
643
|
+
};
|
|
644
|
+
type SelectProps = BaseSelectProps & AdditionalMobileProps & ConditionalMobileProps & {
|
|
645
|
+
/**
|
|
646
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
647
|
+
* @default 1024
|
|
648
|
+
*/
|
|
649
|
+
breakpoint?: number;
|
|
650
|
+
/**
|
|
651
|
+
* Значение по-умолчанию для хука useMatchMedia
|
|
652
|
+
*/
|
|
653
|
+
defaultMatchMediaValue?: boolean | (() => boolean);
|
|
654
|
+
};
|
|
655
|
+
export { AnyObject, OptionShape, GroupShape, BaseSelectChangePayload, BaseSelectProps, FieldProps, ArrowProps, OptionsListProps, OptgroupProps, OptionProps, CheckmarkProps, SearchProps, SelectFieldProps, AdditionalMobileProps, BottomSheetSelectMobileProps, ModalSelectMobileProps, SelectModalMobileProps, SelectMobileProps, SelectDesktopProps, SelectProps };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
import { BottomSheetProps } from "@alfalab/core-components-bottom-sheet";
|
|
5
|
-
import { ModalMobile } from "@alfalab/core-components-modal/mobile";
|
|
6
|
-
import { BaseSelectProps } from "../../typings";
|
|
7
|
-
type SelectMobileProps = Omit<BaseSelectProps, 'Checkmark' | 'onScroll'> & {
|
|
8
|
-
/**
|
|
9
|
-
* Футер
|
|
10
|
-
* @deprecated Используйте bottomSheetProps.actionButton
|
|
11
|
-
*/
|
|
12
|
-
footer?: ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
* Будет ли свайпаться шторка
|
|
15
|
-
* @deprecated Используйте bottomSheetProps.swipeable
|
|
16
|
-
*/
|
|
17
|
-
swipeable?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Отображать в BottomSheet
|
|
20
|
-
*/
|
|
21
|
-
isBottomSheet?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Дополнительные пропсы шторки
|
|
24
|
-
*/
|
|
25
|
-
bottomSheetProps?: Partial<BottomSheetProps>;
|
|
26
|
-
/**
|
|
27
|
-
* Дополнительные пропсы модалки
|
|
28
|
-
*/
|
|
29
|
-
modalProps?: Partial<React.ComponentProps<typeof ModalMobile>>;
|
|
30
|
-
/**
|
|
31
|
-
* Дополнительные пропсы шапки модалки
|
|
32
|
-
*/
|
|
33
|
-
modalHeaderProps?: Partial<React.ComponentProps<typeof ModalMobile.Header>>;
|
|
34
|
-
/**
|
|
35
|
-
* Дополнительные пропсы футера модалки
|
|
36
|
-
*/
|
|
37
|
-
modalFooterProps?: Partial<React.ComponentProps<typeof ModalMobile.Footer>>;
|
|
38
|
-
};
|
|
39
|
-
declare const BaseSelectMobile: React.ForwardRefExoticComponent<Omit<BaseSelectProps, "onScroll" | "Checkmark"> & {
|
|
40
|
-
/**
|
|
41
|
-
* Футер
|
|
42
|
-
* @deprecated Используйте bottomSheetProps.actionButton
|
|
43
|
-
*/
|
|
44
|
-
footer?: ReactNode;
|
|
45
|
-
/**
|
|
46
|
-
* Будет ли свайпаться шторка
|
|
47
|
-
* @deprecated Используйте bottomSheetProps.swipeable
|
|
48
|
-
*/
|
|
49
|
-
swipeable?: boolean | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Отображать в BottomSheet
|
|
52
|
-
*/
|
|
53
|
-
isBottomSheet?: boolean | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Дополнительные пропсы шторки
|
|
56
|
-
*/
|
|
57
|
-
bottomSheetProps?: Partial<BottomSheetProps> | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Дополнительные пропсы модалки
|
|
60
|
-
*/
|
|
61
|
-
modalProps?: Partial<import("@alfalab/core-components-modal/mobile").ModalMobileProps & React.RefAttributes<HTMLDivElement>> | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Дополнительные пропсы шапки модалки
|
|
64
|
-
*/
|
|
65
|
-
modalHeaderProps?: Partial<import("../../Component.modal.mobile").HeaderProps> | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Дополнительные пропсы футера модалки
|
|
68
|
-
*/
|
|
69
|
-
modalFooterProps?: Partial<import("../../Component.modal.mobile").FooterProps> | undefined;
|
|
70
|
-
} & React.RefAttributes<unknown>>;
|
|
71
|
-
export { SelectMobileProps, BaseSelectMobile };
|