@alfalab/core-components-select 17.21.2 → 17.21.4
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 +5 -5
- package/components/base-checkmark/Component.js +1 -1
- package/components/base-checkmark/index.css +6 -6
- package/components/base-option/Component.js +4 -3
- package/components/base-option/index.css +20 -15
- package/components/base-select/Component.js +4 -3
- package/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
- package/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
- package/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
- package/components/base-select/index.css +17 -12
- package/components/base-select/mobile.css +12 -12
- package/components/checkmark/Component.js +1 -1
- package/components/checkmark/index.css +10 -10
- package/components/checkmark-mobile/Component.js +1 -1
- package/components/checkmark-mobile/index.css +6 -6
- package/components/clear-button/Component.js +1 -1
- package/components/clear-button/index.css +5 -5
- package/components/field/Component.js +1 -1
- package/components/field/index.css +14 -14
- package/components/footer/Component.js +1 -1
- package/components/footer/index.css +5 -5
- package/components/optgroup/Component.js +1 -1
- package/components/optgroup/index.css +5 -6
- package/components/option/desktop/Component.js +1 -1
- package/components/option/desktop/index.css +21 -22
- package/components/option/mobile/Component.js +1 -1
- package/components/option/mobile/index.css +18 -19
- package/components/options-list/Component.js +12 -5
- package/components/options-list/index.css +10 -11
- package/components/search/Component.js +1 -1
- package/components/search/index.css +2 -2
- package/components/virtual-options-list/Component.js +1 -1
- package/components/virtual-options-list/index.css +14 -15
- package/cssm/components/base-option/Component.js +3 -2
- package/cssm/components/base-option/index.module.css +7 -2
- package/cssm/components/base-select/Component.js +2 -1
- package/cssm/components/base-select/components/list-desktop/helpers/get-list-popover-desktop-props.d.ts +1 -1
- package/cssm/components/base-select/index.module.css +7 -2
- package/cssm/components/optgroup/index.module.css +1 -2
- package/cssm/components/option/desktop/index.module.css +2 -3
- package/cssm/components/option/index.module.css +2 -3
- package/cssm/components/option/mobile/index.module.css +2 -3
- package/cssm/components/options-list/Component.js +11 -4
- package/cssm/components/options-list/index.module.css +1 -2
- package/cssm/components/virtual-options-list/index.module.css +1 -2
- package/{hook-5412b662.js → cssm/hook-7f1b6f47.js} +3 -3
- package/cssm/mobile/Component.mobile.js +1 -1
- package/cssm/presets/index.js +1 -1
- package/cssm/presets/useSelectWithApply/hook.js +1 -1
- package/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +6 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
- package/cssm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +6 -2
- package/cssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +7 -3
- package/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/cssm/shared/index.js +1 -1
- package/cssm/utils.d.ts +1 -1
- package/cssm/utils.js +12 -24
- 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 +6 -6
- package/esm/components/base-option/Component.js +4 -3
- package/esm/components/base-option/index.css +20 -15
- package/esm/components/base-select/Component.js +4 -3
- package/esm/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
- package/esm/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
- package/esm/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
- package/esm/components/base-select/index.css +17 -12
- package/esm/components/base-select/mobile.css +12 -12
- package/esm/components/checkmark/Component.js +1 -1
- package/esm/components/checkmark/index.css +10 -10
- package/esm/components/checkmark-mobile/Component.js +1 -1
- package/esm/components/checkmark-mobile/index.css +6 -6
- package/esm/components/clear-button/Component.js +1 -1
- package/esm/components/clear-button/index.css +5 -5
- package/esm/components/field/Component.js +1 -1
- package/esm/components/field/index.css +14 -14
- package/esm/components/footer/Component.js +1 -1
- package/esm/components/footer/index.css +5 -5
- package/esm/components/optgroup/Component.js +1 -1
- package/esm/components/optgroup/index.css +5 -6
- package/esm/components/option/desktop/Component.js +1 -1
- package/esm/components/option/desktop/index.css +21 -22
- package/esm/components/option/mobile/Component.js +1 -1
- package/esm/components/option/mobile/index.css +18 -19
- package/esm/components/options-list/Component.js +12 -5
- package/esm/components/options-list/index.css +10 -11
- package/esm/components/search/Component.js +1 -1
- package/esm/components/search/index.css +2 -2
- package/esm/components/virtual-options-list/Component.js +1 -1
- package/esm/components/virtual-options-list/index.css +14 -15
- package/esm/{hook-e9905b00.js → hook-56374bc2.js} +3 -3
- package/esm/{list-popover-desktop-d8567402.js → list-popover-desktop-d897cee0.js} +1 -1
- package/esm/mobile/Component.mobile.js +1 -1
- package/esm/mobile.module-ebe00eaa.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.d.ts +3 -2
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -3
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +7 -3
- package/esm/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
- 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/esm/utils.d.ts +1 -1
- package/esm/utils.js +12 -24
- package/{cssm/hook-42ec365f.js → hook-7eb4a9bb.js} +3 -3
- package/{list-popover-desktop-d6bb8493.js → list-popover-desktop-b51713d2.js} +1 -1
- package/mobile/Component.mobile.js +1 -1
- package/mobile.module-a01cc277.js +6 -0
- 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 +6 -6
- package/modern/components/base-option/Component.js +4 -3
- package/modern/components/base-option/index.css +20 -15
- package/modern/components/base-select/Component.js +4 -3
- package/modern/components/base-select/components/list-desktop/list-popover-desktop.js +1 -1
- package/modern/components/base-select/components/list-mobile/list-bottom-sheet-mobile.js +1 -1
- package/modern/components/base-select/components/list-mobile/list-modal-mobile.js +1 -1
- package/modern/components/base-select/index.css +17 -12
- package/modern/components/base-select/mobile.css +12 -12
- package/modern/components/checkmark/Component.js +1 -1
- package/modern/components/checkmark/index.css +10 -10
- package/modern/components/checkmark-mobile/Component.js +1 -1
- package/modern/components/checkmark-mobile/index.css +6 -6
- package/modern/components/clear-button/Component.js +1 -1
- package/modern/components/clear-button/index.css +5 -5
- package/modern/components/field/Component.js +1 -1
- package/modern/components/field/index.css +14 -14
- package/modern/components/footer/Component.js +1 -1
- package/modern/components/footer/index.css +5 -5
- package/modern/components/optgroup/Component.js +1 -1
- package/modern/components/optgroup/index.css +5 -6
- package/modern/components/option/desktop/Component.js +1 -1
- package/modern/components/option/desktop/index.css +21 -22
- package/modern/components/option/mobile/Component.js +1 -1
- package/modern/components/option/mobile/index.css +18 -19
- package/modern/components/options-list/Component.js +4 -5
- package/modern/components/options-list/index.css +10 -11
- package/modern/components/search/Component.js +1 -1
- package/modern/components/search/index.css +2 -2
- package/modern/components/virtual-options-list/Component.js +1 -1
- package/modern/components/virtual-options-list/index.css +14 -15
- package/{moderncssm/hook-54090d24.js → modern/hook-2f7a71de.js} +3 -3
- package/modern/{list-popover-desktop-92897a4e.js → list-popover-desktop-6e43d72c.js} +1 -1
- package/modern/mobile/Component.mobile.js +1 -1
- package/modern/mobile.module-208550e0.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.d.ts +3 -2
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +5 -3
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/Component.js +6 -2
- package/modern/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
- 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/modern/utils.d.ts +1 -1
- package/modern/utils.js +10 -22
- package/moderncssm/components/base-option/Component.js +3 -2
- package/moderncssm/components/base-option/index.module.css +7 -0
- package/moderncssm/components/base-select/Component.js +2 -1
- package/moderncssm/components/base-select/index.module.css +4 -0
- package/moderncssm/components/optgroup/index.module.css +0 -1
- package/moderncssm/components/option/desktop/index.module.css +1 -2
- package/moderncssm/components/option/index.module.css +1 -2
- package/moderncssm/components/option/mobile/index.module.css +1 -2
- package/moderncssm/components/options-list/Component.js +3 -4
- package/moderncssm/components/options-list/index.module.css +0 -1
- package/moderncssm/components/virtual-options-list/index.module.css +0 -1
- package/{modern/hook-433ed72d.js → moderncssm/hook-4849257f.js} +3 -3
- package/moderncssm/mobile/Component.mobile.js +1 -1
- package/moderncssm/presets/index.js +1 -1
- package/moderncssm/presets/useSelectWithApply/hook.js +1 -1
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.d.ts +3 -2
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +4 -2
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +3 -0
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/Component.js +5 -1
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +5 -1
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -1
- package/moderncssm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/moderncssm/shared/index.js +1 -1
- package/moderncssm/utils.d.ts +1 -1
- package/moderncssm/utils.js +10 -22
- package/package.json +13 -13
- 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.d.ts +3 -2
- package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +6 -3
- package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +8 -4
- package/presets/useSelectWithApply/options-list-with-apply/header/Component.d.ts +2 -0
- package/presets/useSelectWithApply/options-list-with-apply/header/Component.js +7 -3
- package/presets/useSelectWithApply/options-list-with-apply/header/index.css +9 -5
- 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-option/Component.tsx +3 -1
- package/src/components/base-option/index.module.css +9 -0
- package/src/components/base-select/Component.tsx +9 -4
- package/src/components/base-select/index.module.css +5 -0
- package/src/components/optgroup/index.module.css +0 -1
- package/src/components/option/index.module.css +0 -1
- package/src/components/options-list/Component.tsx +3 -2
- package/src/components/options-list/index.module.css +0 -1
- package/src/components/virtual-options-list/index.module.css +0 -1
- package/src/presets/useSelectWithApply/options-list-with-apply/Component.tsx +4 -1
- package/src/presets/useSelectWithApply/options-list-with-apply/footer/Component.tsx +6 -2
- package/src/presets/useSelectWithApply/options-list-with-apply/footer/index.module.css +4 -0
- package/src/presets/useSelectWithApply/options-list-with-apply/header/Component.tsx +11 -1
- package/src/presets/useSelectWithApply/options-list-with-apply/header/index.module.css +3 -0
- package/src/utils.ts +9 -24
- package/utils.d.ts +1 -1
- package/utils.js +12 -24
- package/esm/mobile.module-17a9a022.js +0 -4
- package/mobile.module-abcf78b8.js +0 -6
- package/modern/mobile.module-dae5cd65.js +0 -4
- /package/cssm/{hook-42ec365f.d.ts → hook-7f1b6f47.d.ts} +0 -0
- /package/esm/{hook-e9905b00.d.ts → hook-56374bc2.d.ts} +0 -0
- /package/esm/{list-popover-desktop-d8567402.d.ts → list-popover-desktop-d897cee0.d.ts} +0 -0
- /package/{hook-5412b662.d.ts → hook-7eb4a9bb.d.ts} +0 -0
- /package/{list-popover-desktop-d6bb8493.d.ts → list-popover-desktop-b51713d2.d.ts} +0 -0
- /package/modern/{hook-433ed72d.d.ts → hook-2f7a71de.d.ts} +0 -0
- /package/modern/{list-popover-desktop-92897a4e.d.ts → list-popover-desktop-6e43d72c.d.ts} +0 -0
- /package/moderncssm/{hook-54090d24.d.ts → hook-4849257f.d.ts} +0 -0
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
&.checkmarkAfter.checkmarkAfter {
|
|
31
31
|
padding: var(--gap-0) var(--gap-12) var(--gap-0) var(--gap-0);
|
|
32
32
|
|
|
33
|
+
&.size-72 {
|
|
34
|
+
padding-right: var(--gap-16);
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
&.mobile {
|
|
34
38
|
padding-right: var(--gap-20);
|
|
35
39
|
}
|
|
@@ -38,6 +42,11 @@
|
|
|
38
42
|
&.textContent {
|
|
39
43
|
padding: var(--gap-12);
|
|
40
44
|
|
|
45
|
+
&.size-72 {
|
|
46
|
+
padding-left: var(--gap-16);
|
|
47
|
+
padding-right: var(--gap-16);
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
&.mobile {
|
|
42
51
|
padding: var(--gap-16) var(--gap-20) var(--gap-16) var(--gap-16);
|
|
43
52
|
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
|
|
25
25
|
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
26
26
|
|
|
27
|
+
import { SIZE_TO_CLASSNAME_MAP } from '../../consts';
|
|
27
28
|
import type { AnyObject, OptionShape, OptionsListProps, SearchProps } from '../../typings';
|
|
28
29
|
import {
|
|
29
30
|
defaultAccessor,
|
|
@@ -565,10 +566,14 @@ export const BaseSelect = forwardRef<unknown, ComponentProps>(
|
|
|
565
566
|
onChange={handleChange}
|
|
566
567
|
dataTestId={getDataTestId(dataTestId, 'search')}
|
|
567
568
|
onClear={handleClear}
|
|
568
|
-
className={cn(
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
569
|
+
className={cn(
|
|
570
|
+
searchProps?.componentProps?.className,
|
|
571
|
+
{
|
|
572
|
+
[styles.search]: view === 'desktop',
|
|
573
|
+
[mobileStyles.search]: view === 'mobile',
|
|
574
|
+
},
|
|
575
|
+
size && styles[SIZE_TO_CLASSNAME_MAP[size]],
|
|
576
|
+
)}
|
|
572
577
|
ref={mergeRefs([searchRef, searchProps?.componentProps?.ref || null])}
|
|
573
578
|
/>
|
|
574
579
|
);
|
|
@@ -120,8 +120,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
|
|
|
120
120
|
|
|
121
121
|
const actualOptionsCount = limitDynamicOptionGroupSize && options.length > 0;
|
|
122
122
|
|
|
123
|
-
const measured = useVisibleOptions({
|
|
124
|
-
...(!nativeScrollbar && { styleTargetRef: scrollbarRef }),
|
|
123
|
+
const [measured, height] = useVisibleOptions({
|
|
125
124
|
visibleOptions,
|
|
126
125
|
listRef,
|
|
127
126
|
open,
|
|
@@ -168,6 +167,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
|
|
|
168
167
|
<Scrollbar
|
|
169
168
|
className={cn(styles.scrollable, scrollbarClassName)}
|
|
170
169
|
ref={scrollbarRef}
|
|
170
|
+
style={{ height }}
|
|
171
171
|
horizontalAutoStretch={optionsListWidth === 'content'}
|
|
172
172
|
scrollableNodeProps={scrollableNodeProps}
|
|
173
173
|
contentNodeProps={{ ref: listRef }}
|
|
@@ -191,6 +191,7 @@ export const OptionsList = forwardRef<HTMLDivElement, OptionsListProps>(
|
|
|
191
191
|
className={cn(styles.scrollable, scrollbarClassName)}
|
|
192
192
|
ref={mergeRefs([listRef, ref])}
|
|
193
193
|
onScroll={handleScroll}
|
|
194
|
+
style={{ height }}
|
|
194
195
|
>
|
|
195
196
|
{renderListItems()}
|
|
196
197
|
</div>
|
|
@@ -39,6 +39,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
|
|
|
39
39
|
header,
|
|
40
40
|
headerProps,
|
|
41
41
|
setSelectedDraft,
|
|
42
|
+
size,
|
|
42
43
|
...restProps
|
|
43
44
|
}: OptionsListWithApplyProps,
|
|
44
45
|
ref,
|
|
@@ -98,7 +99,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
|
|
|
98
99
|
<React.Fragment>
|
|
99
100
|
{header}
|
|
100
101
|
{showHeaderWithSelectAll && flatOptions.length > 0 && (
|
|
101
|
-
<Header {...headerProps} />
|
|
102
|
+
<Header {...headerProps} size={size} />
|
|
102
103
|
)}
|
|
103
104
|
</React.Fragment>
|
|
104
105
|
);
|
|
@@ -107,6 +108,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
|
|
|
107
108
|
return (
|
|
108
109
|
<OptionsList
|
|
109
110
|
{...restProps}
|
|
111
|
+
size={size}
|
|
110
112
|
ref={ref}
|
|
111
113
|
visibleOptions={visibleOptions}
|
|
112
114
|
toggleMenu={toggleMenu}
|
|
@@ -124,6 +126,7 @@ export const OptionsListWithApply = forwardRef<HTMLDivElement, OptionsListWithAp
|
|
|
124
126
|
showClear={showClear}
|
|
125
127
|
selectedDraft={selectedDraft}
|
|
126
128
|
dataTestId={restProps?.dataTestId}
|
|
129
|
+
size={size}
|
|
127
130
|
/>
|
|
128
131
|
}
|
|
129
132
|
/>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
2
3
|
|
|
3
4
|
import { ButtonDesktop } from '@alfalab/core-components-button/desktop';
|
|
4
5
|
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
+
import { SIZE_TO_CLASSNAME_MAP } from '../../../../consts';
|
|
8
|
+
import { OptionShape, OptionsListProps } from '../../../../typings';
|
|
7
9
|
|
|
8
10
|
import styles from './index.module.css';
|
|
9
11
|
|
|
@@ -13,6 +15,7 @@ export type FooterProps = {
|
|
|
13
15
|
showClear?: boolean;
|
|
14
16
|
selectedDraft?: OptionShape[];
|
|
15
17
|
dataTestId?: string;
|
|
18
|
+
size?: OptionsListProps['size'];
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
export const Footer = ({
|
|
@@ -21,11 +24,12 @@ export const Footer = ({
|
|
|
21
24
|
showClear,
|
|
22
25
|
selectedDraft = [],
|
|
23
26
|
dataTestId,
|
|
27
|
+
size,
|
|
24
28
|
}: FooterProps) => (
|
|
25
29
|
<div
|
|
26
30
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
27
31
|
tabIndex={0}
|
|
28
|
-
className={styles.footer}
|
|
32
|
+
className={cn(styles.footer, size && styles[SIZE_TO_CLASSNAME_MAP[size]])}
|
|
29
33
|
>
|
|
30
34
|
<ButtonDesktop
|
|
31
35
|
size={32}
|
|
@@ -3,6 +3,9 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import { Checkbox, CheckboxProps } from '@alfalab/core-components-checkbox';
|
|
5
5
|
|
|
6
|
+
import { SIZE_TO_CLASSNAME_MAP } from '../../../../consts';
|
|
7
|
+
import { OptionsListProps } from '../../../../typings';
|
|
8
|
+
|
|
6
9
|
import styles from './index.module.css';
|
|
7
10
|
|
|
8
11
|
export type HeaderProps = {
|
|
@@ -11,6 +14,7 @@ export type HeaderProps = {
|
|
|
11
14
|
onChange?: CheckboxProps['onChange'];
|
|
12
15
|
mobile?: boolean;
|
|
13
16
|
dataTestId?: string;
|
|
17
|
+
size?: OptionsListProps['size'];
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
export const Header: React.FC<HeaderProps> = ({
|
|
@@ -19,8 +23,14 @@ export const Header: React.FC<HeaderProps> = ({
|
|
|
19
23
|
indeterminate,
|
|
20
24
|
mobile,
|
|
21
25
|
dataTestId,
|
|
26
|
+
size,
|
|
22
27
|
}) => (
|
|
23
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
className={cn(size && styles[SIZE_TO_CLASSNAME_MAP[size]], {
|
|
30
|
+
[styles.desktop]: !mobile,
|
|
31
|
+
[styles.mobile]: mobile,
|
|
32
|
+
})}
|
|
33
|
+
>
|
|
24
34
|
<Checkbox
|
|
25
35
|
block={true}
|
|
26
36
|
indeterminate={indeterminate}
|
package/src/utils.ts
CHANGED
|
@@ -231,24 +231,22 @@ export function useVirtualVisibleOptions({
|
|
|
231
231
|
export function useVisibleOptions({
|
|
232
232
|
visibleOptions,
|
|
233
233
|
listRef,
|
|
234
|
-
styleTargetRef = listRef,
|
|
235
234
|
open,
|
|
236
|
-
invalidate,
|
|
237
235
|
options,
|
|
238
236
|
size,
|
|
239
237
|
actualOptionsCount,
|
|
240
238
|
}: useVisibleOptionsArgs) {
|
|
241
239
|
const [, runIfMounted] = useIsMounted();
|
|
242
240
|
const [measured, setMeasured] = useState(false);
|
|
241
|
+
const [height, setHeight] = useState<number | undefined>();
|
|
243
242
|
|
|
244
243
|
useEffect(() => {
|
|
245
244
|
const measureOptionHeight = (element: HTMLElement) =>
|
|
246
245
|
typeof size === 'number' ? Math.min(element.clientHeight, size) : element.clientHeight;
|
|
247
246
|
|
|
248
247
|
const list = listRef.current;
|
|
249
|
-
const styleTarget = styleTargetRef.current;
|
|
250
248
|
|
|
251
|
-
if (open && list &&
|
|
249
|
+
if (open && list && visibleOptions > 0) {
|
|
252
250
|
const childCount = list.children.length;
|
|
253
251
|
const optionsNodes = ([] as HTMLElement[]).slice.call(
|
|
254
252
|
list.children,
|
|
@@ -256,7 +254,7 @@ export function useVisibleOptions({
|
|
|
256
254
|
visibleOptions + 1,
|
|
257
255
|
);
|
|
258
256
|
|
|
259
|
-
let
|
|
257
|
+
let measuredHeight = optionsNodes
|
|
260
258
|
.slice(0, visibleOptions)
|
|
261
259
|
.reduce((acc, child) => acc + measureOptionHeight(child), 0);
|
|
262
260
|
|
|
@@ -266,7 +264,7 @@ export function useVisibleOptions({
|
|
|
266
264
|
);
|
|
267
265
|
|
|
268
266
|
// Если кол-во опций больше visibleOptions на 1, то показываем все опции, иначе добавляем половинку
|
|
269
|
-
|
|
267
|
+
measuredHeight += Math.round(
|
|
270
268
|
childCount - visibleOptions === 1
|
|
271
269
|
? lastVisibleOptionHeight
|
|
272
270
|
: lastVisibleOptionHeight / 2,
|
|
@@ -281,43 +279,30 @@ export function useVisibleOptions({
|
|
|
281
279
|
0,
|
|
282
280
|
);
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
measuredHeight =
|
|
285
283
|
Math.min(
|
|
286
284
|
actualCount === 0 ? /** empty placeholder */ 1 : actualCount,
|
|
287
285
|
visibleOptions,
|
|
288
286
|
) * size;
|
|
289
287
|
|
|
290
288
|
if (visibleOptions < actualCount) {
|
|
291
|
-
|
|
289
|
+
measuredHeight += size / 2;
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
292
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
styleTarget.style.height = `${height}px`;
|
|
293
|
+
setHeight(measuredHeight);
|
|
298
294
|
|
|
299
295
|
setMeasured(true);
|
|
300
296
|
|
|
301
297
|
return () => {
|
|
302
|
-
styleTarget.style.height = prevHeight;
|
|
303
298
|
runIfMounted(() => setMeasured(false));
|
|
304
299
|
};
|
|
305
300
|
}
|
|
306
301
|
|
|
307
302
|
return fnUtils.noop;
|
|
308
|
-
}, [
|
|
309
|
-
actualOptionsCount,
|
|
310
|
-
listRef,
|
|
311
|
-
open,
|
|
312
|
-
options,
|
|
313
|
-
size,
|
|
314
|
-
styleTargetRef,
|
|
315
|
-
visibleOptions,
|
|
316
|
-
invalidate,
|
|
317
|
-
runIfMounted,
|
|
318
|
-
]);
|
|
303
|
+
}, [actualOptionsCount, listRef, open, options, size, visibleOptions, runIfMounted]);
|
|
319
304
|
|
|
320
|
-
return measured;
|
|
305
|
+
return [measured, height] as const;
|
|
321
306
|
}
|
|
322
307
|
|
|
323
308
|
export function defaultFilterFn(optionText: string, search: string) {
|
package/utils.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ type useVisibleOptionsArgs = {
|
|
|
46
46
|
actualOptionsCount?: boolean;
|
|
47
47
|
};
|
|
48
48
|
declare function useVirtualVisibleOptions({ visibleOptions, listRef, styleTargetRef, open, invalidate, options, size, actualOptionsCount, }: useVisibleOptionsArgs): void;
|
|
49
|
-
declare function useVisibleOptions({ visibleOptions, listRef,
|
|
49
|
+
declare function useVisibleOptions({ visibleOptions, listRef, open, options, size, actualOptionsCount, }: useVisibleOptionsArgs): readonly [boolean, number | undefined];
|
|
50
50
|
declare function defaultFilterFn(optionText: string, search: string): boolean;
|
|
51
51
|
declare function defaultGroupAccessor(option: GroupShape): string | undefined;
|
|
52
52
|
declare function defaultAccessor(option: OptionShape): string;
|
package/utils.js
CHANGED
|
@@ -124,25 +124,25 @@ function useVirtualVisibleOptions(_a) {
|
|
|
124
124
|
]);
|
|
125
125
|
}
|
|
126
126
|
function useVisibleOptions(_a) {
|
|
127
|
-
var visibleOptions = _a.visibleOptions, listRef = _a.listRef,
|
|
128
|
-
var
|
|
129
|
-
var
|
|
127
|
+
var visibleOptions = _a.visibleOptions, listRef = _a.listRef, open = _a.open, options = _a.options, size = _a.size, actualOptionsCount = _a.actualOptionsCount;
|
|
128
|
+
var _b = coreComponentsShared.useIsMounted(), runIfMounted = _b[1];
|
|
129
|
+
var _c = React.useState(false), measured = _c[0], setMeasured = _c[1];
|
|
130
|
+
var _d = React.useState(), height = _d[0], setHeight = _d[1];
|
|
130
131
|
React.useEffect(function () {
|
|
131
132
|
var measureOptionHeight = function (element) {
|
|
132
133
|
return typeof size === 'number' ? Math.min(element.clientHeight, size) : element.clientHeight;
|
|
133
134
|
};
|
|
134
135
|
var list = listRef.current;
|
|
135
|
-
|
|
136
|
-
if (open && list && styleTarget && visibleOptions > 0) {
|
|
136
|
+
if (open && list && visibleOptions > 0) {
|
|
137
137
|
var childCount = list.children.length;
|
|
138
138
|
var optionsNodes = [].slice.call(list.children, 0, visibleOptions + 1);
|
|
139
|
-
var
|
|
139
|
+
var measuredHeight = optionsNodes
|
|
140
140
|
.slice(0, visibleOptions)
|
|
141
141
|
.reduce(function (acc, child) { return acc + measureOptionHeight(child); }, 0);
|
|
142
142
|
if (visibleOptions < childCount) {
|
|
143
143
|
var lastVisibleOptionHeight = measureOptionHeight(optionsNodes[optionsNodes.length - 1]);
|
|
144
144
|
// Если кол-во опций больше visibleOptions на 1, то показываем все опции, иначе добавляем половинку
|
|
145
|
-
|
|
145
|
+
measuredHeight += Math.round(childCount - visibleOptions === 1
|
|
146
146
|
? lastVisibleOptionHeight
|
|
147
147
|
: lastVisibleOptionHeight / 2);
|
|
148
148
|
}
|
|
@@ -150,33 +150,21 @@ function useVisibleOptions(_a) {
|
|
|
150
150
|
actualOptionsCount &&
|
|
151
151
|
typeof size === 'number') {
|
|
152
152
|
var actualCount = (options !== null && options !== void 0 ? options : []).reduce(function (sum, option) { return sum + 1 + (isGroup(option) ? option.options.length : 0); }, 0);
|
|
153
|
-
|
|
153
|
+
measuredHeight =
|
|
154
154
|
Math.min(actualCount === 0 ? /** empty placeholder */ 1 : actualCount, visibleOptions) * size;
|
|
155
155
|
if (visibleOptions < actualCount) {
|
|
156
|
-
|
|
156
|
+
measuredHeight += size / 2;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
styleTarget.style.height = "".concat(height, "px");
|
|
159
|
+
setHeight(measuredHeight);
|
|
161
160
|
setMeasured(true);
|
|
162
161
|
return function () {
|
|
163
|
-
styleTarget.style.height = prevHeight_1;
|
|
164
162
|
runIfMounted(function () { return setMeasured(false); });
|
|
165
163
|
};
|
|
166
164
|
}
|
|
167
165
|
return coreComponentsShared.fnUtils.noop;
|
|
168
|
-
}, [
|
|
169
|
-
|
|
170
|
-
listRef,
|
|
171
|
-
open,
|
|
172
|
-
options,
|
|
173
|
-
size,
|
|
174
|
-
styleTargetRef,
|
|
175
|
-
visibleOptions,
|
|
176
|
-
invalidate,
|
|
177
|
-
runIfMounted,
|
|
178
|
-
]);
|
|
179
|
-
return measured;
|
|
166
|
+
}, [actualOptionsCount, listRef, open, options, size, visibleOptions, runIfMounted]);
|
|
167
|
+
return [measured, height];
|
|
180
168
|
}
|
|
181
169
|
function defaultFilterFn(optionText, search) {
|
|
182
170
|
if (!search)
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
|
|
2
|
-
require('./components/base-select/mobile.css')
|
|
3
|
-
|
|
4
|
-
export { mobileStyles as m };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
|
|
4
|
-
require('./components/base-select/mobile.css')
|
|
5
|
-
|
|
6
|
-
exports.mobileStyles = mobileStyles;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const mobileStyles = {"sheet":"select__sheet_12yag","sheetContent":"select__sheetContent_12yag","modalContent":"select__modalContent_12yag","sheetContainer":"select__sheetContainer_12yag","optionsListWrapper":"select__optionsListWrapper_12yag","optionsList":"select__optionsList_12yag","scrollbar":"select__scrollbar_12yag","search":"select__search_12yag","option":"select__option_12yag","optionGroup":"select__optionGroup_12yag"};
|
|
2
|
-
require('./components/base-select/mobile.css')
|
|
3
|
-
|
|
4
|
-
export { mobileStyles as m };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|