@alfalab/core-components-select 10.2.3 → 10.4.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/CHANGELOG.md +45 -0
- package/dist/Component.d.ts +1 -1
- package/dist/Component.js +2 -1
- package/dist/components/arrow/Component.js +1 -1
- package/dist/components/arrow/index.css +3 -3
- package/dist/components/base-select/Component.js +26 -23
- package/dist/components/base-select/index.css +7 -7
- package/dist/components/base-select/index.js +1 -1
- package/dist/components/checkmark/Component.d.ts +1 -1
- package/dist/components/checkmark/Component.js +11 -5
- package/dist/components/checkmark/index.css +21 -9
- package/dist/components/checkmark/index.js +1 -0
- package/dist/components/field/Component.d.ts +1 -1
- package/dist/components/field/Component.js +3 -3
- package/dist/components/field/index.css +9 -9
- package/dist/components/field/index.js +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/native-select/Component.js +1 -1
- package/dist/components/native-select/index.js +1 -1
- package/dist/components/optgroup/Component.js +1 -1
- package/dist/components/optgroup/index.css +6 -6
- package/dist/components/option/Component.js +7 -5
- package/dist/components/option/index.css +20 -20
- package/dist/components/option/index.js +2 -1
- package/dist/components/options-list/Component.js +13 -8
- package/dist/components/options-list/index.css +9 -5
- package/dist/components/options-list/index.js +1 -0
- package/dist/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/components/virtual-options-list/Component.js +22 -18
- package/dist/components/virtual-options-list/index.css +15 -12
- package/dist/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/Component.d.ts +1 -1
- package/dist/cssm/Component.js +1 -0
- package/dist/cssm/components/base-select/Component.js +24 -21
- package/dist/cssm/components/checkmark/Component.d.ts +1 -1
- package/dist/cssm/components/checkmark/Component.js +10 -4
- package/dist/cssm/components/checkmark/index.js +1 -0
- package/dist/cssm/components/checkmark/index.module.css +19 -7
- package/dist/cssm/components/field/Component.d.ts +1 -1
- package/dist/cssm/components/field/Component.js +1 -1
- package/dist/cssm/components/index.js +1 -0
- package/dist/cssm/components/option/Component.js +5 -3
- package/dist/cssm/components/option/index.js +1 -0
- package/dist/cssm/components/options-list/Component.js +12 -7
- package/dist/cssm/components/options-list/index.js +1 -0
- package/dist/cssm/components/options-list/index.module.css +4 -0
- package/dist/cssm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/cssm/components/virtual-options-list/Component.js +21 -17
- package/dist/cssm/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/components/virtual-options-list/index.module.css +4 -1
- package/dist/cssm/hook-3b9bd559.d.ts +12 -0
- package/dist/cssm/hook-3b9bd559.js +147 -0
- package/dist/cssm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/cssm/index.js +8 -1
- package/dist/cssm/intersection-observer-8c55e13a.d.ts +1 -0
- package/dist/cssm/intersection-observer-8c55e13a.js +893 -0
- package/dist/cssm/presets/index.d.ts +1 -0
- package/dist/cssm/presets/index.js +30 -1
- package/dist/cssm/presets/useLazyLoading/hook.js +2 -892
- package/dist/cssm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/hook.js +46 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.module.css +38 -0
- package/dist/cssm/presets/useSelectWithLoading/hook.js +1 -0
- package/dist/cssm/typings.d.ts +55 -6
- package/dist/esm/Component.d.ts +1 -1
- package/dist/esm/Component.js +2 -1
- package/dist/esm/components/arrow/Component.js +1 -1
- package/dist/esm/components/arrow/index.css +3 -3
- package/dist/esm/components/base-select/Component.js +26 -23
- package/dist/esm/components/base-select/index.css +7 -7
- package/dist/esm/components/base-select/index.js +1 -1
- package/dist/esm/components/checkmark/Component.d.ts +1 -1
- package/dist/esm/components/checkmark/Component.js +12 -6
- package/dist/esm/components/checkmark/index.css +21 -9
- package/dist/esm/components/checkmark/index.js +1 -0
- package/dist/esm/components/field/Component.d.ts +1 -1
- package/dist/esm/components/field/Component.js +3 -3
- package/dist/esm/components/field/index.css +9 -9
- package/dist/esm/components/field/index.js +1 -1
- package/dist/esm/components/index.js +2 -1
- package/dist/esm/components/native-select/Component.js +1 -1
- package/dist/esm/components/native-select/index.js +1 -1
- package/dist/esm/components/optgroup/Component.js +1 -1
- package/dist/esm/components/optgroup/index.css +6 -6
- package/dist/esm/components/option/Component.js +7 -5
- package/dist/esm/components/option/index.css +20 -20
- package/dist/esm/components/option/index.js +2 -1
- package/dist/esm/components/options-list/Component.js +14 -9
- package/dist/esm/components/options-list/index.css +9 -5
- package/dist/esm/components/options-list/index.js +1 -0
- package/dist/esm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/esm/components/virtual-options-list/Component.js +22 -18
- package/dist/esm/components/virtual-options-list/index.css +15 -12
- package/dist/esm/components/virtual-options-list/index.js +1 -0
- package/dist/esm/hook-3514e1ff.d.ts +12 -0
- package/dist/esm/hook-3514e1ff.js +131 -0
- package/dist/esm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/intersection-observer-228b670b.d.ts +1 -0
- package/dist/esm/intersection-observer-228b670b.js +891 -0
- package/dist/esm/presets/index.d.ts +1 -0
- package/dist/esm/presets/index.js +21 -1
- package/dist/esm/presets/useLazyLoading/hook.js +4 -894
- package/dist/esm/presets/useLazyLoading/index.css +2 -2
- package/dist/esm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/hook.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.js +26 -0
- package/dist/esm/presets/useSelectWithLoading/hook.js +3 -2
- package/dist/esm/presets/useSelectWithLoading/index.css +2 -2
- package/dist/esm/{tslib.es6-e401d952.d.ts → tslib.es6-f688174c.d.ts} +0 -0
- package/dist/esm/{tslib.es6-e401d952.js → tslib.es6-f688174c.js} +0 -0
- package/dist/esm/typings.d.ts +55 -6
- package/dist/hook-6f1602ae.d.ts +12 -0
- package/dist/hook-6f1602ae.js +140 -0
- package/dist/hook-f5b8fe4f.d.ts +61 -0
- package/dist/index.js +7 -1
- package/dist/intersection-observer-6dcf2d59.d.ts +1 -0
- package/dist/intersection-observer-6dcf2d59.js +893 -0
- package/dist/modern/Component.d.ts +1 -1
- package/dist/modern/Component.js +1 -0
- package/dist/modern/components/arrow/Component.js +1 -1
- package/dist/modern/components/arrow/index.css +3 -3
- package/dist/modern/components/base-select/Component.js +20 -15
- package/dist/modern/components/base-select/index.css +7 -7
- package/dist/modern/components/checkmark/Component.d.ts +1 -1
- package/dist/modern/components/checkmark/Component.js +12 -4
- package/dist/modern/components/checkmark/index.css +21 -9
- package/dist/modern/components/checkmark/index.js +1 -0
- package/dist/modern/components/field/Component.d.ts +1 -1
- package/dist/modern/components/field/Component.js +2 -2
- package/dist/modern/components/field/index.css +9 -9
- package/dist/modern/components/index.js +1 -0
- package/dist/modern/components/optgroup/Component.js +1 -1
- package/dist/modern/components/optgroup/index.css +6 -6
- package/dist/modern/components/option/Component.js +6 -4
- package/dist/modern/components/option/index.css +20 -20
- package/dist/modern/components/option/index.js +1 -0
- package/dist/modern/components/options-list/Component.js +11 -7
- package/dist/modern/components/options-list/index.css +9 -5
- package/dist/modern/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/modern/components/virtual-options-list/Component.js +20 -17
- package/dist/modern/components/virtual-options-list/index.css +15 -12
- package/dist/modern/hook-d9110e41.d.ts +12 -0
- package/dist/modern/hook-d9110e41.js +132 -0
- package/dist/modern/hook-f5b8fe4f.d.ts +61 -0
- package/dist/modern/index.js +4 -0
- package/dist/modern/intersection-observer-228b670b.d.ts +1 -0
- package/dist/modern/intersection-observer-228b670b.js +891 -0
- package/dist/modern/presets/index.d.ts +1 -0
- package/dist/modern/presets/index.js +20 -0
- package/dist/modern/presets/useLazyLoading/hook.js +3 -893
- package/dist/modern/presets/useLazyLoading/index.css +2 -2
- package/dist/modern/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/hook.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.js +25 -0
- package/dist/modern/presets/useSelectWithLoading/hook.js +2 -1
- package/dist/modern/presets/useSelectWithLoading/index.css +2 -2
- package/dist/modern/typings.d.ts +55 -6
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +23 -1
- package/dist/presets/useLazyLoading/hook.js +4 -894
- package/dist/presets/useLazyLoading/index.css +2 -2
- package/dist/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/presets/useSelectWithApply/hook.js +35 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.js +34 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.js +34 -0
- package/dist/presets/useSelectWithLoading/hook.js +3 -2
- package/dist/presets/useSelectWithLoading/index.css +2 -2
- package/dist/{tslib.es6-ba995fc6.d.ts → tslib.es6-b1b1a51e.d.ts} +0 -0
- package/dist/{tslib.es6-ba995fc6.js → tslib.es6-b1b1a51e.js} +0 -0
- package/dist/typings.d.ts +55 -6
- package/package.json +5 -3
|
@@ -82,7 +82,7 @@ type SelectProps = Omit<BaseSelectProps, 'fieldProps'> & {
|
|
|
82
82
|
*/
|
|
83
83
|
fieldProps?: FormControlProps & Record<string, unknown>;
|
|
84
84
|
};
|
|
85
|
-
declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "open" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "zIndexPopover" | "showEmptyOptionsList"> & {
|
|
85
|
+
declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "popperClassName" | "open" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "zIndexPopover" | "showEmptyOptionsList"> & {
|
|
86
86
|
/**
|
|
87
87
|
* Пропсы, которые будут прокинуты в компонент поля
|
|
88
88
|
*/
|
package/dist/modern/Component.js
CHANGED
|
@@ -9,6 +9,7 @@ import { Arrow } from './components/arrow/Component.js';
|
|
|
9
9
|
import 'react-merge-refs';
|
|
10
10
|
import { Optgroup } from './components/optgroup/Component.js';
|
|
11
11
|
import { OptionsList } from './components/options-list/Component.js';
|
|
12
|
+
import '@alfalab/core-components-checkbox/dist/modern';
|
|
12
13
|
import './components/checkmark/Component.js';
|
|
13
14
|
import { Option } from './components/option/Component.js';
|
|
14
15
|
import 'resize-observer';
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { ChevronDownMIcon } from '@alfalab/icons-glyph/ChevronDownMIcon';
|
|
4
4
|
|
|
5
|
-
var styles = {"arrow":"
|
|
5
|
+
var styles = {"arrow":"select__arrow_uh35h","open":"select__open_uh35h"};
|
|
6
6
|
require('./index.css')
|
|
7
7
|
|
|
8
8
|
const Arrow = ({ open, className }) => (React.createElement(ChevronDownMIcon, { className: cn(styles.arrow, className, { [styles.open]: open }) }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 19l12 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
/* optgroup */
|
|
26
26
|
}
|
|
27
|
-
.
|
|
27
|
+
.select__arrow_uh35h {
|
|
28
28
|
display: block;
|
|
29
29
|
width: 24px;
|
|
30
30
|
height: 24px;
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
|
|
33
33
|
transition: transform 0.15s ease-in-out, opacity 0.2s ease;
|
|
34
34
|
}
|
|
35
|
-
.
|
|
35
|
+
.select__open_uh35h {
|
|
36
36
|
transform: var(--arrow-transform);
|
|
37
37
|
}
|
|
@@ -12,13 +12,14 @@ const getDataTestId = (dataTestId, element) => {
|
|
|
12
12
|
return dataTestId ? `${dataTestId}${elementPart}` : undefined;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
var styles = {"component":"
|
|
15
|
+
var styles = {"component":"select__component_1osb1","popoverInner":"select__popoverInner_1osb1","optionsList":"select__optionsList_1osb1","nativeSelect":"select__nativeSelect_1osb1","block":"select__block_1osb1"};
|
|
16
16
|
require('./index.css')
|
|
17
17
|
|
|
18
|
-
const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsListClassName, optionClassName, options, autocomplete = false, multiple = false, allowUnselect = false, disabled = false, closeOnSelect = !multiple, circularNavigation = false, nativeSelect = false, defaultOpen = false, open: openProp, popoverPosition = 'bottom-start', preventFlip = true, optionsListWidth = 'content', name, id, selected, size = 's', optionsSize = size, error, hint, block, label, placeholder, fieldProps = {}, optionsListProps = {}, optionProps = {}, valueRenderer, onChange, onOpen, onFocus, onBlur, onScroll, Arrow, Field = () => null, OptionsList = () => null, Optgroup = () => null, Option = () => null, updatePopover, zIndexPopover, showEmptyOptionsList = false, visibleOptions, }, ref) => {
|
|
18
|
+
const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsListClassName, optionClassName, popperClassName, options, autocomplete = false, multiple = false, allowUnselect = false, disabled = false, closeOnSelect = !multiple, circularNavigation = false, nativeSelect = false, defaultOpen = false, open: openProp, popoverPosition = 'bottom-start', preventFlip = true, optionsListWidth = 'content', name, id, selected, size = 's', optionsSize = size, error, hint, block, label, placeholder, fieldProps = {}, optionsListProps = {}, optionProps = {}, valueRenderer, onChange, onOpen, onFocus, onBlur, onScroll, Arrow, Field = () => null, OptionsList = () => null, Optgroup = () => null, Option = () => null, updatePopover, zIndexPopover, showEmptyOptionsList = false, visibleOptions, }, ref) => {
|
|
19
19
|
const rootRef = useRef(null);
|
|
20
20
|
const fieldRef = useRef(null);
|
|
21
21
|
const listRef = useRef(null);
|
|
22
|
+
const initiatorRef = useRef(null);
|
|
22
23
|
const itemToString = (option) => (option ? option.key : '');
|
|
23
24
|
const { flatOptions, selectedOptions } = useMemo(() => processOptions(options, selected), [
|
|
24
25
|
options,
|
|
@@ -32,8 +33,10 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
32
33
|
onChange({
|
|
33
34
|
selectedMultiple: selectedItems,
|
|
34
35
|
selected: selectedItems.length ? selectedItems[0] : null,
|
|
36
|
+
initiator: initiatorRef.current,
|
|
35
37
|
name,
|
|
36
38
|
});
|
|
39
|
+
initiatorRef.current = null;
|
|
37
40
|
}
|
|
38
41
|
},
|
|
39
42
|
stateReducer: (state, actionAndChanges) => {
|
|
@@ -78,6 +81,7 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
78
81
|
switch (type) {
|
|
79
82
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
80
83
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
84
|
+
initiatorRef.current = selectedItem;
|
|
81
85
|
if (selectedItem && !selectedItem.disabled) {
|
|
82
86
|
const alreadySelected = selectedItems.includes(selectedItem);
|
|
83
87
|
const allowRemove = allowUnselect || (multiple && selectedItems.length > 1);
|
|
@@ -125,14 +129,15 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
125
129
|
};
|
|
126
130
|
const handleFieldKeyDown = (event) => {
|
|
127
131
|
inputProps.onKeyDown(event);
|
|
128
|
-
if (autocomplete && !open && event.key.length === 1) {
|
|
132
|
+
if (autocomplete && !open && (event.key.length === 1 || event.key === 'Backspace')) {
|
|
129
133
|
// Для автокомплита - открываем меню при начале ввода
|
|
130
134
|
openMenu();
|
|
131
135
|
}
|
|
132
136
|
if ([' ', 'Enter'].includes(event.key) &&
|
|
133
137
|
!autocomplete &&
|
|
134
138
|
!nativeSelect &&
|
|
135
|
-
event.target.tagName !== 'INPUT'
|
|
139
|
+
event.target.tagName !== 'INPUT' &&
|
|
140
|
+
event.target.tagName !== 'BUTTON') {
|
|
136
141
|
// Открываем\закрываем меню по нажатию enter или пробела
|
|
137
142
|
event.preventDefault();
|
|
138
143
|
if (!open || highlightedIndex === -1)
|
|
@@ -150,9 +155,8 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
150
155
|
const handleNativeSelectChange = useCallback(event => {
|
|
151
156
|
setSelectedItems([...event.target.options].reduce((acc, option, index) => option.selected ? acc.concat(flatOptions[index]) : acc, []));
|
|
152
157
|
}, [flatOptions, setSelectedItems]);
|
|
153
|
-
const
|
|
158
|
+
const getOptionProps = useCallback((option, index) => ({
|
|
154
159
|
...optionProps,
|
|
155
|
-
...rest,
|
|
156
160
|
className: optionClassName,
|
|
157
161
|
innerProps: getItemProps({
|
|
158
162
|
index,
|
|
@@ -160,6 +164,7 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
160
164
|
disabled: option.disabled,
|
|
161
165
|
onMouseDown: (event) => event.preventDefault(),
|
|
162
166
|
}),
|
|
167
|
+
multiple,
|
|
163
168
|
index,
|
|
164
169
|
option,
|
|
165
170
|
size: optionsSize,
|
|
@@ -167,15 +172,15 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
167
172
|
highlighted: index === highlightedIndex,
|
|
168
173
|
selected: selectedItems.includes(option),
|
|
169
174
|
dataTestId: getDataTestId(dataTestId, 'option'),
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
optionProps,
|
|
173
|
-
optionClassName,
|
|
175
|
+
}), [
|
|
176
|
+
dataTestId,
|
|
174
177
|
getItemProps,
|
|
175
|
-
optionsSize,
|
|
176
178
|
highlightedIndex,
|
|
179
|
+
multiple,
|
|
180
|
+
optionClassName,
|
|
181
|
+
optionProps,
|
|
182
|
+
optionsSize,
|
|
177
183
|
selectedItems,
|
|
178
|
-
dataTestId,
|
|
179
184
|
]);
|
|
180
185
|
useEffect(() => {
|
|
181
186
|
if (defaultOpen)
|
|
@@ -221,7 +226,7 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
221
226
|
className: cn(styles.component, { [styles.block]: block }, className),
|
|
222
227
|
}), { onKeyDown: disabled ? undefined : handleFieldKeyDown, tabIndex: -1, "data-test-id": getDataTestId(dataTestId) }),
|
|
223
228
|
nativeSelect && renderNativeSelect(),
|
|
224
|
-
React.createElement(Field, Object.assign({ selectedMultiple: selectedItems, selected: selectedItems[0], multiple: multiple, open: open, disabled: disabled, size: size, placeholder: placeholder, label: label && React.createElement("span", Object.assign({}, getLabelProps()), label), Arrow: Arrow && React.createElement(Arrow, { open: open }), error: error, hint: hint, valueRenderer: valueRenderer, className: fieldClassName, innerProps: {
|
|
229
|
+
React.createElement(Field, Object.assign({ selectedMultiple: selectedItems, selected: selectedItems[0], setSelectedItems: setSelectedItems, toggleMenu: toggleMenu, multiple: multiple, open: open, disabled: disabled, size: size, placeholder: placeholder, label: label && React.createElement("span", Object.assign({}, getLabelProps()), label), Arrow: Arrow && React.createElement(Arrow, { open: open }), error: error, hint: hint, valueRenderer: valueRenderer, className: fieldClassName, innerProps: {
|
|
225
230
|
onBlur: handleFieldBlur,
|
|
226
231
|
onFocus: disabled ? undefined : handleFieldFocus,
|
|
227
232
|
onClick: disabled ? undefined : handleFieldClick,
|
|
@@ -235,8 +240,8 @@ const BaseSelect = forwardRef(({ dataTestId, className, fieldClassName, optionsL
|
|
|
235
240
|
: undefined,
|
|
236
241
|
}, dataTestId: getDataTestId(dataTestId, 'field') }, fieldProps)),
|
|
237
242
|
name && !nativeSelect && renderValue(),
|
|
238
|
-
!nativeSelect && (React.createElement(Popover, { open: open, withTransition: false, anchorElement: fieldRef.current, position: popoverPosition, preventFlip: preventFlip, popperClassName: styles.popoverInner, update: updatePopover, zIndex: zIndexPopover }, needRenderOptionsList && (React.createElement("div", Object.assign({}, menuProps, { className: cn(optionsListClassName, styles.optionsList) }),
|
|
239
|
-
React.createElement(OptionsList, Object.assign({}, optionsListProps, { flatOptions: flatOptions, highlightedIndex: highlightedIndex, open: open, size: size, options: options, Optgroup: Optgroup, Option:
|
|
243
|
+
!nativeSelect && (React.createElement(Popover, { open: open, withTransition: false, anchorElement: fieldRef.current, position: popoverPosition, preventFlip: preventFlip, popperClassName: cn(styles.popoverInner, popperClassName), update: updatePopover, zIndex: zIndexPopover }, needRenderOptionsList && (React.createElement("div", Object.assign({}, menuProps, { className: cn(optionsListClassName, styles.optionsList) }),
|
|
244
|
+
React.createElement(OptionsList, Object.assign({}, optionsListProps, { flatOptions: flatOptions, highlightedIndex: highlightedIndex, open: open, size: size, options: options, Optgroup: Optgroup, Option: Option, selectedItems: selectedItems, setSelectedItems: setSelectedItems, toggleMenu: toggleMenu, getOptionProps: getOptionProps, visibleOptions: visibleOptions, onScroll: onScroll, dataTestId: getDataTestId(dataTestId, 'options-list') }))))))));
|
|
240
245
|
});
|
|
241
246
|
|
|
242
247
|
export { BaseSelect };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: bu6ui */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
}
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
/* optgroup */
|
|
30
30
|
}
|
|
31
|
-
.
|
|
31
|
+
.select__component_1osb1 {
|
|
32
32
|
width: max-content;
|
|
33
33
|
position: relative;
|
|
34
34
|
outline: 0;
|
|
35
35
|
}
|
|
36
|
-
.
|
|
36
|
+
.select__popoverInner_1osb1 {
|
|
37
37
|
padding-top: var(--select-options-list-offset);
|
|
38
38
|
padding-bottom: var(--select-options-list-offset);
|
|
39
39
|
box-shadow: none;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
border-radius: 0;
|
|
43
43
|
position: relative;
|
|
44
44
|
}
|
|
45
|
-
.
|
|
45
|
+
.select__optionsList_1osb1 {
|
|
46
46
|
padding-top: var(--select-options-list-top-padding);
|
|
47
47
|
padding-bottom: var(--select-options-list-bottom-padding);
|
|
48
48
|
box-shadow: var(--select-options-list-box-shadow);
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
overflow: hidden;
|
|
52
52
|
will-change: transform;
|
|
53
53
|
}
|
|
54
|
-
.
|
|
54
|
+
.select__nativeSelect_1osb1 {
|
|
55
55
|
opacity: 0;
|
|
56
56
|
overflow: hidden;
|
|
57
57
|
position: absolute;
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
cursor: pointer;
|
|
66
66
|
z-index: 1;
|
|
67
67
|
}
|
|
68
|
-
.
|
|
68
|
+
.select__block_1osb1 {
|
|
69
69
|
width: 100%;
|
|
70
70
|
}
|
|
71
71
|
/* width: max-content; fix for IE */
|
|
72
72
|
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
73
|
-
.
|
|
73
|
+
.select__component_1osb1 {
|
|
74
74
|
float: left;
|
|
75
75
|
clear: left;
|
|
76
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckmarkProps } from "../../typings";
|
|
3
|
-
declare const Checkmark: ({ selected }: CheckmarkProps) => JSX.Element;
|
|
3
|
+
declare const Checkmark: ({ selected, className, multiple, position, }: CheckmarkProps) => JSX.Element;
|
|
4
4
|
export { Checkmark };
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
|
+
import { Checkbox } from '@alfalab/core-components-checkbox/dist/modern';
|
|
3
4
|
|
|
4
|
-
var styles = {"checkmark":"
|
|
5
|
+
var styles = {"checkmark":"select__checkmark_3l2l6","single":"select__single_3l2l6","selected":"select__selected_3l2l6","before":"select__before_3l2l6","multiple":"select__multiple_3l2l6","after":"select__after_3l2l6"};
|
|
5
6
|
require('./index.css')
|
|
6
7
|
|
|
7
|
-
const Checkmark = ({ selected
|
|
8
|
+
const Checkmark = ({ selected, className, multiple, position = 'before', }) => {
|
|
9
|
+
const single = !multiple || position === 'after';
|
|
10
|
+
const checkmarkClassNames = cn(styles.checkmark, className, styles[position], {
|
|
11
|
+
[styles.multiple]: !single,
|
|
12
|
+
[styles.single]: single,
|
|
8
13
|
[styles.selected]: selected,
|
|
9
|
-
})
|
|
14
|
+
});
|
|
15
|
+
const handleCheckboxClick = useCallback(event => event.stopPropagation(), []);
|
|
16
|
+
return single ? (React.createElement("span", { className: checkmarkClassNames })) : (React.createElement(Checkbox, { checked: selected, className: checkmarkClassNames, size: 'm', onClick: handleCheckboxClick }));
|
|
17
|
+
};
|
|
10
18
|
|
|
11
19
|
export { Checkmark };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: manlv */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
:root {
|
|
14
14
|
--gap-xs: 8px;
|
|
15
|
+
--gap-s: 12px;
|
|
15
16
|
}
|
|
16
17
|
:root {
|
|
17
18
|
--border-radius-circle: 50%;
|
|
@@ -26,27 +27,38 @@
|
|
|
26
27
|
|
|
27
28
|
--select-checkmark-margin: 0 var(--gap-xs) 0 0;
|
|
28
29
|
--select-checkmark-size: 4px;
|
|
29
|
-
--select-checkmark-
|
|
30
|
+
--select-checkmark-before-display: 'flex';
|
|
31
|
+
--select-checkmark-after-display: none;
|
|
30
32
|
--select-checkmark-unselected-opacity: 0;
|
|
31
33
|
--select-checkmark-background: var(--color-light-graphic-primary);
|
|
32
34
|
--select-checkmark-border-radius: var(--border-radius-circle);
|
|
33
35
|
|
|
34
36
|
/* optgroup */
|
|
35
37
|
}
|
|
36
|
-
.
|
|
38
|
+
.select__checkmark_3l2l6 {
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
margin: var(--select-checkmark-margin);
|
|
41
|
+
}
|
|
42
|
+
.select__single_3l2l6 {
|
|
37
43
|
display: flex;
|
|
38
44
|
align-items: center;
|
|
39
45
|
justify-content: center;
|
|
40
46
|
opacity: var(--select-checkmark-unselected-opacity);
|
|
41
|
-
flex-shrink: 0;
|
|
42
47
|
background: var(--select-checkmark-background);
|
|
43
48
|
background-size: cover;
|
|
44
49
|
border-radius: var(--select-checkmark-border-radius);
|
|
45
|
-
margin: var(--select-checkmark-margin);
|
|
46
|
-
order: var(--select-checkmark-order);
|
|
47
50
|
width: var(--select-checkmark-size);
|
|
48
|
-
height: var(--select-checkmark-size)
|
|
51
|
+
height: var(--select-checkmark-size)
|
|
52
|
+
}
|
|
53
|
+
.select__single_3l2l6.select__selected_3l2l6 {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
56
|
+
.select__before_3l2l6 {
|
|
57
|
+
display: var(--select-checkmark-before-display)
|
|
49
58
|
}
|
|
50
|
-
.
|
|
51
|
-
|
|
59
|
+
.select__before_3l2l6.select__multiple_3l2l6 {
|
|
60
|
+
margin-right: var(--gap-s);
|
|
61
|
+
}
|
|
62
|
+
.select__after_3l2l6 {
|
|
63
|
+
display: var(--select-checkmark-after-display);
|
|
52
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FieldProps as BaseFieldProps } from "../../typings";
|
|
4
|
-
declare const Field: ({ size, open, multiple, error, hint, disabled, label, placeholder, selectedMultiple, selected, rightAddons, valueRenderer, Arrow, innerProps, dataTestId, fieldClassName, ...restProps }: BaseFieldProps & React.HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
declare const Field: ({ size, open, multiple, error, hint, disabled, label, placeholder, selectedMultiple, selected, rightAddons, valueRenderer, setSelectedItems, toggleMenu, Arrow, innerProps, dataTestId, fieldClassName, ...restProps }: BaseFieldProps & React.HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
block?: boolean | undefined;
|
|
6
6
|
size?: "s" | "m" | "l" | "xl" | undefined;
|
|
7
7
|
colors?: "default" | "inverted" | undefined;
|
|
@@ -4,10 +4,10 @@ import { useFocus } from '@alfalab/hooks';
|
|
|
4
4
|
import { FormControl } from '@alfalab/core-components-form-control/dist/modern';
|
|
5
5
|
import { joinOptions } from '../../utils.js';
|
|
6
6
|
|
|
7
|
-
var styles = {"component":"
|
|
7
|
+
var styles = {"component":"select__component_15tn4","field":"select__field_15tn4","disabled":"select__disabled_15tn4","arrow":"select__arrow_15tn4","placeholder":"select__placeholder_15tn4","contentWrapper":"select__contentWrapper_15tn4","value":"select__value_15tn4","focusVisible":"select__focusVisible_15tn4"};
|
|
8
8
|
require('./index.css')
|
|
9
9
|
|
|
10
|
-
const Field = ({ size = 'm', open, multiple, error, hint, disabled, label, placeholder, selectedMultiple = [], selected, rightAddons, valueRenderer = joinOptions, Arrow, innerProps, dataTestId, fieldClassName, ...restProps }) => {
|
|
10
|
+
const Field = ({ size = 'm', open, multiple, error, hint, disabled, label, placeholder, selectedMultiple = [], selected, rightAddons, valueRenderer = joinOptions, setSelectedItems, toggleMenu, Arrow, innerProps, dataTestId, fieldClassName, ...restProps }) => {
|
|
11
11
|
const [focused, setFocused] = useState(false);
|
|
12
12
|
const wrapperRef = useRef(null);
|
|
13
13
|
const [focusVisible] = useFocus(wrapperRef, 'keyboard');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1csbk */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-border-link: #007aff;
|
|
4
4
|
--color-light-text-secondary: #546272;
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
|
|
27
27
|
/* optgroup */
|
|
28
28
|
}
|
|
29
|
-
.
|
|
29
|
+
.select__component_15tn4 {
|
|
30
30
|
width: 100%;
|
|
31
31
|
outline: none;
|
|
32
32
|
}
|
|
33
|
-
.
|
|
33
|
+
.select__field_15tn4:not(.select__disabled_15tn4) {
|
|
34
34
|
cursor: pointer
|
|
35
35
|
}
|
|
36
|
-
.
|
|
36
|
+
.select__field_15tn4:not(.select__disabled_15tn4):hover .select__arrow_15tn4 {
|
|
37
37
|
opacity: var(--select-arrow-hover-opacity);
|
|
38
38
|
}
|
|
39
|
-
.
|
|
39
|
+
.select__disabled_15tn4 {
|
|
40
40
|
cursor: var(--disabled-cursor);
|
|
41
41
|
}
|
|
42
42
|
/* TODO: Заюзать переменные из инпута */
|
|
43
|
-
.
|
|
43
|
+
.select__placeholder_15tn4 {
|
|
44
44
|
color: var(--color-light-text-secondary);
|
|
45
45
|
}
|
|
46
|
-
.
|
|
46
|
+
.select__contentWrapper_15tn4 {
|
|
47
47
|
font-size: 16px;
|
|
48
48
|
line-height: 20px;
|
|
49
49
|
font-weight: 400;
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
overflow: hidden;
|
|
54
54
|
width: 100%;
|
|
55
55
|
}
|
|
56
|
-
.
|
|
56
|
+
.select__value_15tn4 {
|
|
57
57
|
overflow: hidden;
|
|
58
58
|
text-overflow: ellipsis;
|
|
59
59
|
text-align: left;
|
|
60
60
|
}
|
|
61
|
-
.
|
|
61
|
+
.select__focusVisible_15tn4 {
|
|
62
62
|
outline: 2px solid var(--focus-color);
|
|
63
63
|
outline-offset: 2px;
|
|
64
64
|
}
|
|
@@ -9,6 +9,7 @@ export { Arrow } from './arrow/Component.js';
|
|
|
9
9
|
import 'react-merge-refs';
|
|
10
10
|
export { Optgroup } from './optgroup/Component.js';
|
|
11
11
|
export { OptionsList } from './options-list/Component.js';
|
|
12
|
+
import '@alfalab/core-components-checkbox/dist/modern';
|
|
12
13
|
import './checkmark/Component.js';
|
|
13
14
|
export { Option } from './option/Component.js';
|
|
14
15
|
import 'resize-observer';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
var styles = {"optgroup":"
|
|
4
|
+
var styles = {"optgroup":"select__optgroup_17qtp","label":"select__label_17qtp","l":"select__l_17qtp","xl":"select__xl_17qtp"};
|
|
5
5
|
require('./index.css')
|
|
6
6
|
|
|
7
7
|
const Optgroup = ({ children, label, size = 's' }) => (React.createElement(React.Fragment, null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1x956 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
--color-light-text-secondary: #546272;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
--select-optgroup-l-left-padding: var(--gap-m);
|
|
34
34
|
--select-optgroup-l-right-padding: var(--gap-m);
|
|
35
35
|
}
|
|
36
|
-
.
|
|
36
|
+
.select__optgroup_17qtp {
|
|
37
37
|
position: relative;
|
|
38
38
|
display: flex;
|
|
39
39
|
align-items: center;
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
background: var(--select-optgroup-background);
|
|
44
44
|
min-height: 40px
|
|
45
45
|
}
|
|
46
|
-
.
|
|
46
|
+
.select__optgroup_17qtp + *[role='option']:before {
|
|
47
47
|
display: none;
|
|
48
48
|
}
|
|
49
|
-
.
|
|
49
|
+
.select__label_17qtp {
|
|
50
50
|
font-size: 12px;
|
|
51
51
|
line-height: 16px;
|
|
52
52
|
font-weight: 500;
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
display: block;
|
|
57
57
|
color: var(--select-optgroup-color);
|
|
58
58
|
}
|
|
59
|
-
.
|
|
60
|
-
.
|
|
59
|
+
.select__l_17qtp,
|
|
60
|
+
.select__xl_17qtp {
|
|
61
61
|
padding-left: var(--select-optgroup-l-left-padding);
|
|
62
62
|
padding-right: var(--select-optgroup-l-right-padding);
|
|
63
63
|
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import React, { isValidElement } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
|
+
import '@alfalab/core-components-checkbox/dist/modern';
|
|
3
4
|
import { Checkmark } from '../checkmark/Component.js';
|
|
4
5
|
|
|
5
|
-
var styles = {"option":"
|
|
6
|
+
var styles = {"option":"select__option_1osgi","disabled":"select__disabled_1osgi","s":"select__s_1osgi","m":"select__m_1osgi","l":"select__l_1osgi","xl":"select__xl_1osgi","selected":"select__selected_1osgi","highlighted":"select__highlighted_1osgi","content":"select__content_1osgi","textContent":"select__textContent_1osgi"};
|
|
6
7
|
require('./index.css')
|
|
7
8
|
|
|
8
|
-
const Option = ({ size = 's', className, option, children, selected, highlighted, disabled, Checkmark: Checkmark$1 = Checkmark, innerProps, dataTestId, }) => {
|
|
9
|
+
const Option = ({ size = 's', className, option, children, selected, highlighted, disabled, multiple, Checkmark: Checkmark$1 = Checkmark, innerProps, dataTestId, }) => {
|
|
9
10
|
const content = children || option.content || option.key;
|
|
10
11
|
return (React.createElement("div", Object.assign({}, innerProps, { className: cn(styles.option, styles[size], className, {
|
|
11
12
|
[styles.highlighted]: highlighted,
|
|
12
13
|
[styles.selected]: selected,
|
|
13
14
|
[styles.disabled]: disabled,
|
|
14
15
|
}), "data-test-id": dataTestId }),
|
|
15
|
-
Checkmark$1 && React.createElement(Checkmark$1, { selected: selected }),
|
|
16
|
+
Checkmark$1 && React.createElement(Checkmark$1, { selected: selected, multiple: multiple, position: 'before' }),
|
|
16
17
|
React.createElement("div", { className: cn(styles.content, {
|
|
17
18
|
[styles.textContent]: !isValidElement(content),
|
|
18
|
-
}) }, content)
|
|
19
|
+
}) }, content),
|
|
20
|
+
Checkmark$1 && React.createElement(Checkmark$1, { selected: selected, multiple: multiple, position: 'after' })));
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export { Option };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: owea4 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
--color-light-bg-secondary: #f3f4f5;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
/* optgroup */
|
|
55
55
|
}
|
|
56
|
-
.
|
|
56
|
+
.select__option_1osgi {
|
|
57
57
|
font-size: 16px;
|
|
58
58
|
line-height: 20px;
|
|
59
59
|
font-weight: 400;
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
position: relative;
|
|
70
70
|
cursor: pointer
|
|
71
71
|
}
|
|
72
|
-
.
|
|
72
|
+
.select__option_1osgi:not(.select__disabled_1osgi):active {
|
|
73
73
|
background: var(--select-option-active-background);
|
|
74
74
|
color: var(--select-option-active-color);
|
|
75
75
|
}
|
|
76
|
-
.
|
|
76
|
+
.select__option_1osgi:before {
|
|
77
77
|
content: '';
|
|
78
78
|
position: absolute;
|
|
79
79
|
left: var(--select-option-left-padding);
|
|
@@ -84,60 +84,60 @@
|
|
|
84
84
|
display: var(--select-option-divider-display);
|
|
85
85
|
transition: opacity 0.2s ease;
|
|
86
86
|
}
|
|
87
|
-
.
|
|
87
|
+
.select__option_1osgi:first-child:before {
|
|
88
88
|
display: none;
|
|
89
89
|
}
|
|
90
|
-
.
|
|
90
|
+
.select__s_1osgi {
|
|
91
91
|
min-height: var(--size-s-height);
|
|
92
92
|
}
|
|
93
|
-
.
|
|
93
|
+
.select__m_1osgi {
|
|
94
94
|
min-height: var(--size-m-height);
|
|
95
95
|
}
|
|
96
|
-
.
|
|
96
|
+
.select__l_1osgi {
|
|
97
97
|
min-height: var(--size-l-height);
|
|
98
98
|
}
|
|
99
|
-
.
|
|
99
|
+
.select__xl_1osgi {
|
|
100
100
|
min-height: var(--size-xl-height);
|
|
101
101
|
}
|
|
102
|
-
.
|
|
103
|
-
.
|
|
102
|
+
.select__l_1osgi,
|
|
103
|
+
.select__xl_1osgi {
|
|
104
104
|
padding-left: var(--select-option-l-left-padding);
|
|
105
105
|
padding-right: var(--select-option-l-right-padding)
|
|
106
106
|
}
|
|
107
|
-
.
|
|
107
|
+
.select__l_1osgi:before, .select__xl_1osgi:before {
|
|
108
108
|
left: var(--select-option-l-left-padding);
|
|
109
109
|
right: var(--select-option-l-right-padding);
|
|
110
110
|
}
|
|
111
|
-
.
|
|
111
|
+
.select__selected_1osgi {
|
|
112
112
|
background: var(--select-option-selected-background);
|
|
113
113
|
color: var(--select-option-selected-color);
|
|
114
114
|
cursor: default;
|
|
115
115
|
}
|
|
116
|
-
.
|
|
116
|
+
.select__highlighted_1osgi {
|
|
117
117
|
background: var(--select-option-hover-background);
|
|
118
118
|
color: var(--select-option-hover-color)
|
|
119
119
|
}
|
|
120
|
-
.
|
|
121
|
-
.
|
|
120
|
+
.select__highlighted_1osgi:before,
|
|
121
|
+
.select__highlighted_1osgi + .select__option_1osgi:before {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
}
|
|
124
|
-
.
|
|
124
|
+
.select__disabled_1osgi {
|
|
125
125
|
cursor: var(--disabled-cursor);
|
|
126
126
|
background: var(--select-option-disabled-background);
|
|
127
127
|
color: var(--select-option-disabled-color);
|
|
128
128
|
}
|
|
129
|
-
.
|
|
129
|
+
.select__content_1osgi {
|
|
130
130
|
overflow: hidden;
|
|
131
131
|
text-overflow: ellipsis;
|
|
132
132
|
flex: 1;
|
|
133
133
|
}
|
|
134
|
-
.
|
|
134
|
+
.select__textContent_1osgi {
|
|
135
135
|
padding-top: var(--gap-s);
|
|
136
136
|
padding-bottom: var(--gap-s);
|
|
137
137
|
}
|
|
138
138
|
/* IE min-height fix */
|
|
139
139
|
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
140
|
-
.
|
|
140
|
+
.select__option_1osgi:after {
|
|
141
141
|
min-height: inherit;
|
|
142
142
|
font-size: 0;
|
|
143
143
|
content: '';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { forwardRef,
|
|
1
|
+
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { useVisibleOptions, isGroup } from '../../utils.js';
|
|
4
4
|
import mergeRefs from 'react-merge-refs';
|
|
5
5
|
import { Optgroup } from '../optgroup/Component.js';
|
|
6
6
|
|
|
7
|
-
var styles = {"optionsList":"
|
|
7
|
+
var styles = {"optionsList":"select__optionsList_o9cww","scrollable":"select__scrollable_o9cww","emptyPlaceholder":"select__emptyPlaceholder_o9cww","l":"select__l_o9cww","xl":"select__xl_o9cww"};
|
|
8
8
|
require('./index.css')
|
|
9
9
|
|
|
10
10
|
const createCounter = () => {
|
|
@@ -12,10 +12,11 @@ const createCounter = () => {
|
|
|
12
12
|
// eslint-disable-next-line no-plusplus
|
|
13
13
|
return () => count++;
|
|
14
14
|
};
|
|
15
|
-
const OptionsList = forwardRef(({ size = 's', className, Option, options = [], Optgroup: Optgroup$1 = Optgroup, dataTestId, emptyPlaceholder, visibleOptions = 5, onScroll, open, }, ref) => {
|
|
15
|
+
const OptionsList = forwardRef(({ size = 's', className, Option, getOptionProps, options = [], Optgroup: Optgroup$1 = Optgroup, dataTestId, emptyPlaceholder, visibleOptions = 5, onScroll, open, header, footer, }, ref) => {
|
|
16
|
+
const renderOption = useCallback((option, index) => (React.createElement(Option, Object.assign({ key: option.key }, getOptionProps(option, index)))), [getOptionProps]);
|
|
16
17
|
const listRef = useRef(null);
|
|
17
18
|
const counter = createCounter();
|
|
18
|
-
const renderGroup = useCallback((group) => (React.createElement(Optgroup$1, { label: group.label, key: group.label, size: size }, group.options.map(option =>
|
|
19
|
+
const renderGroup = useCallback((group) => (React.createElement(Optgroup$1, { label: group.label, key: group.label, size: size }, group.options.map(option => renderOption(option, counter())))), [counter, renderOption, size]);
|
|
19
20
|
useVisibleOptions({
|
|
20
21
|
visibleOptions,
|
|
21
22
|
listRef,
|
|
@@ -25,9 +26,12 @@ const OptionsList = forwardRef(({ size = 's', className, Option, options = [], O
|
|
|
25
26
|
if (options.length === 0 && !emptyPlaceholder) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
|
-
return (React.createElement("div", { className: cn(styles.optionsList, styles[size], className), "data-test-id": dataTestId
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
return (React.createElement("div", { className: cn(styles.optionsList, styles[size], className), "data-test-id": dataTestId },
|
|
30
|
+
header,
|
|
31
|
+
React.createElement("div", { className: styles.scrollable, ref: mergeRefs([listRef, ref]), onScroll: onScroll },
|
|
32
|
+
options.map(option => isGroup(option) ? renderGroup(option) : renderOption(option, counter())),
|
|
33
|
+
emptyPlaceholder && options.length === 0 && (React.createElement("div", { className: styles.emptyPlaceholder }, emptyPlaceholder))),
|
|
34
|
+
footer));
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
export { OptionsList };
|