@alfalab/core-components-select 15.0.4 → 15.1.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.js +5 -2
- package/Component.mobile.d.ts +1 -1
- package/Component.mobile.js +9 -4
- package/Component.modal.mobile.d.ts +1 -1
- package/Component.modal.mobile.js +7 -2
- package/Component.responsive.js +4 -1
- package/components/arrow/Component.js +1 -1
- package/components/arrow/index.css +3 -3
- 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 +13 -13
- package/components/base-select/Component.js +73 -12
- package/components/base-select/index.css +16 -9
- package/components/base-select-mobile/Component.js +51 -11
- package/components/base-select-mobile/footer/Component.js +1 -1
- package/components/base-select-mobile/footer/index.css +5 -5
- package/components/base-select-mobile/index.css +26 -11
- package/components/base-select-mobile/index.js +3 -0
- 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/field/Component.js +1 -1
- package/components/field/index.css +12 -12
- package/components/index.d.ts +1 -0
- package/components/index.js +4 -0
- package/components/optgroup/Component.js +1 -1
- package/components/optgroup/index.css +6 -6
- package/components/option/Component.js +1 -1
- package/components/option/index.css +20 -20
- package/components/options-list/Component.js +5 -5
- package/components/options-list/index.css +9 -9
- package/components/search/Component.d.ts +7 -0
- package/components/search/Component.js +24 -0
- package/components/search/index.css +28 -0
- package/components/search/index.d.ts +1 -0
- package/components/search/index.js +14 -0
- package/components/virtual-options-list/Component.js +1 -1
- package/components/virtual-options-list/index.css +15 -15
- package/cssm/Component.desktop.js +6 -2
- package/cssm/Component.mobile.d.ts +1 -1
- package/cssm/Component.mobile.js +10 -4
- package/cssm/Component.modal.mobile.d.ts +1 -1
- package/cssm/Component.modal.mobile.js +8 -2
- package/cssm/Component.responsive.js +5 -1
- package/cssm/components/base-select/Component.js +72 -11
- package/cssm/components/base-select/index.module.css +8 -1
- package/cssm/components/base-select-mobile/Component.js +51 -10
- package/cssm/components/base-select-mobile/index.js +4 -0
- package/cssm/components/base-select-mobile/index.module.css +15 -0
- package/cssm/components/index.d.ts +1 -0
- package/cssm/components/index.js +5 -0
- package/cssm/components/options-list/Component.js +4 -4
- package/cssm/components/search/Component.d.ts +7 -0
- package/cssm/components/search/Component.js +23 -0
- package/cssm/components/search/index.d.ts +1 -0
- package/cssm/components/search/index.js +15 -0
- package/cssm/components/search/index.module.css +27 -0
- package/cssm/desktop.js +4 -0
- package/{modern/hook-9ea9e32c.d.ts → cssm/hook-8abfea97.d.ts} +20 -5
- package/cssm/{hook-97e6e688.js → hook-d1f5dd40.js} +19 -5
- package/cssm/index.js +5 -1
- package/cssm/mobile.js +5 -1
- package/cssm/presets/index.d.ts +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/index.d.ts +1 -1
- package/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +1 -1
- package/cssm/shared.js +8 -1
- package/cssm/typings.d.ts +23 -1
- package/cssm/utils.d.ts +5 -2
- package/cssm/utils.js +34 -5
- package/desktop.js +3 -0
- package/esm/Component.desktop.js +5 -2
- package/esm/Component.mobile.d.ts +1 -1
- package/esm/Component.mobile.js +9 -4
- package/esm/Component.modal.mobile.d.ts +1 -1
- package/esm/Component.modal.mobile.js +7 -2
- package/esm/Component.responsive.js +4 -1
- package/esm/components/arrow/Component.js +1 -1
- package/esm/components/arrow/index.css +3 -3
- 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 +13 -13
- package/esm/components/base-select/Component.js +74 -13
- package/esm/components/base-select/index.css +16 -9
- package/esm/components/base-select-mobile/Component.js +52 -12
- package/esm/components/base-select-mobile/footer/Component.js +1 -1
- package/esm/components/base-select-mobile/footer/index.css +5 -5
- package/esm/components/base-select-mobile/index.css +26 -11
- package/esm/components/base-select-mobile/index.js +3 -0
- 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/field/Component.js +1 -1
- package/esm/components/field/index.css +12 -12
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +3 -0
- package/esm/components/optgroup/Component.js +1 -1
- package/esm/components/optgroup/index.css +6 -6
- package/esm/components/option/Component.js +1 -1
- package/esm/components/option/index.css +20 -20
- package/esm/components/options-list/Component.js +5 -5
- package/esm/components/options-list/index.css +9 -9
- package/esm/components/search/Component.d.ts +7 -0
- package/esm/components/search/Component.js +15 -0
- package/esm/components/search/index.css +28 -0
- package/esm/components/search/index.d.ts +1 -0
- package/esm/components/search/index.js +6 -0
- package/esm/components/virtual-options-list/Component.js +1 -1
- package/esm/components/virtual-options-list/index.css +15 -15
- package/esm/desktop.js +3 -0
- package/esm/{hook-276cd428.js → hook-758ebd33.js} +21 -7
- package/{hook-9ea9e32c.d.ts → esm/hook-8abfea97.d.ts} +20 -5
- package/esm/index.js +4 -1
- package/esm/mobile.js +4 -1
- package/esm/presets/index.d.ts +1 -1
- package/esm/presets/index.js +1 -1
- package/esm/presets/useSelectWithApply/hook.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/esm/presets/useSelectWithApply/options-list-with-apply/footer/index.css +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 +1 -1
- package/esm/presets/useSelectWithLoading/hook.js +1 -1
- package/esm/presets/useSelectWithLoading/index.css +2 -2
- package/esm/shared.js +5 -2
- package/esm/typings.d.ts +23 -1
- package/esm/utils.d.ts +5 -2
- package/esm/utils.js +33 -6
- package/{cssm/hook-9ea9e32c.d.ts → hook-8abfea97.d.ts} +20 -5
- package/{hook-ac9069cc.js → hook-9b793700.js} +19 -5
- package/index.js +4 -1
- package/mobile.js +4 -1
- package/modern/Component.desktop.js +5 -2
- package/modern/Component.mobile.d.ts +1 -1
- package/modern/Component.mobile.js +9 -4
- package/modern/Component.modal.mobile.d.ts +1 -1
- package/modern/Component.modal.mobile.js +7 -2
- package/modern/Component.responsive.js +4 -1
- package/modern/components/arrow/Component.js +1 -1
- package/modern/components/arrow/index.css +3 -3
- 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 +13 -13
- package/modern/components/base-select/Component.js +62 -9
- package/modern/components/base-select/index.css +16 -9
- package/modern/components/base-select-mobile/Component.js +42 -9
- package/modern/components/base-select-mobile/footer/Component.js +1 -1
- package/modern/components/base-select-mobile/footer/index.css +5 -5
- package/modern/components/base-select-mobile/index.css +26 -11
- package/modern/components/base-select-mobile/index.js +3 -0
- 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/field/Component.js +1 -1
- package/modern/components/field/index.css +12 -12
- package/modern/components/index.d.ts +1 -0
- package/modern/components/index.js +3 -0
- package/modern/components/optgroup/Component.js +1 -1
- package/modern/components/optgroup/index.css +6 -6
- package/modern/components/option/Component.js +1 -1
- package/modern/components/option/index.css +20 -20
- package/modern/components/options-list/Component.js +5 -5
- package/modern/components/options-list/index.css +9 -9
- package/modern/components/search/Component.d.ts +7 -0
- package/modern/components/search/Component.js +11 -0
- package/modern/components/search/index.css +28 -0
- package/modern/components/search/index.d.ts +1 -0
- package/modern/components/search/index.js +5 -0
- package/modern/components/virtual-options-list/Component.js +1 -1
- package/modern/components/virtual-options-list/index.css +15 -15
- package/modern/desktop.js +3 -0
- package/modern/{hook-f0d60b8e.js → hook-707bbdbf.js} +23 -6
- package/{esm/hook-9ea9e32c.d.ts → modern/hook-8abfea97.d.ts} +20 -5
- package/modern/index.js +4 -1
- package/modern/mobile.js +4 -1
- package/modern/presets/index.d.ts +1 -1
- package/modern/presets/index.js +1 -1
- package/modern/presets/useSelectWithApply/hook.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/modern/presets/useSelectWithApply/options-list-with-apply/footer/index.css +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 +1 -1
- package/modern/presets/useSelectWithLoading/hook.js +1 -1
- package/modern/presets/useSelectWithLoading/index.css +2 -2
- package/modern/shared.js +5 -2
- package/modern/typings.d.ts +23 -1
- package/modern/utils.d.ts +5 -2
- package/modern/utils.js +34 -6
- package/package.json +6 -6
- package/presets/index.d.ts +1 -1
- package/presets/index.js +1 -1
- package/presets/useSelectWithApply/hook.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/footer/Component.js +1 -1
- package/presets/useSelectWithApply/options-list-with-apply/footer/index.css +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 +1 -1
- package/presets/useSelectWithLoading/hook.js +1 -1
- package/presets/useSelectWithLoading/index.css +2 -2
- package/shared.js +7 -1
- package/src/Component.desktop.tsx +4 -1
- package/src/Component.mobile.tsx +7 -0
- package/src/Component.modal.mobile.tsx +4 -0
- package/src/components/base-select/Component.tsx +101 -10
- package/src/components/base-select/index.module.css +12 -0
- package/src/components/base-select-mobile/Component.tsx +78 -8
- package/src/components/base-select-mobile/index.module.css +24 -0
- package/src/components/index.ts +1 -0
- package/src/components/options-list/Component.tsx +8 -3
- package/src/components/search/Component.tsx +31 -0
- package/src/components/search/index.module.css +6 -0
- package/src/components/search/index.ts +1 -0
- package/src/presets/useSelectWithApply/hook.tsx +32 -3
- package/src/presets/useSelectWithApply/options-list-with-apply/Component.tsx +13 -1
- package/src/typings.ts +27 -0
- package/src/utils.ts +37 -5
- package/typings.d.ts +23 -1
- package/utils.d.ts +5 -2
- package/utils.js +34 -5
- /package/cssm/{hook-97e6e688.d.ts → hook-d1f5dd40.d.ts} +0 -0
- /package/esm/{hook-276cd428.d.ts → hook-758ebd33.d.ts} +0 -0
- /package/{hook-ac9069cc.d.ts → hook-9b793700.d.ts} +0 -0
- /package/modern/{hook-f0d60b8e.d.ts → hook-707bbdbf.d.ts} +0 -0
|
@@ -16,6 +16,7 @@ var components_field_Component = require('../field/Component.js');
|
|
|
16
16
|
var components_optgroup_Component = require('../optgroup/Component.js');
|
|
17
17
|
var components_option_Component = require('../option/Component.js');
|
|
18
18
|
var components_optionsList_Component = require('../options-list/Component.js');
|
|
19
|
+
var components_search_Component = require('../search/Component.js');
|
|
19
20
|
var styles = require('./index.module.css');
|
|
20
21
|
require('@alfalab/icons-glyph/ChevronDownMIcon');
|
|
21
22
|
require('../arrow/index.module.css');
|
|
@@ -34,6 +35,9 @@ require('../option/index.module.css');
|
|
|
34
35
|
require('@alfalab/core-components-scrollbar/cssm');
|
|
35
36
|
require('../../consts.js');
|
|
36
37
|
require('../options-list/index.module.css');
|
|
38
|
+
require('@alfalab/core-components-input/cssm');
|
|
39
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
40
|
+
require('../search/index.module.css');
|
|
37
41
|
|
|
38
42
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
39
43
|
|
|
@@ -44,14 +48,24 @@ var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
|
44
48
|
|
|
45
49
|
var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
46
50
|
var _b;
|
|
47
|
-
var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, optionGroupClassName = _a.optionGroupClassName, optionsListProps = _a.optionsListProps, _c = _a.options, options = _c === void 0 ? [] : _c, _d = _a.autocomplete, autocomplete = _d === void 0 ? false : _d, _e = _a.multiple, multiple = _e === void 0 ? false : _e, _f = _a.allowUnselect, allowUnselect = _f === void 0 ? false : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.closeOnSelect, closeOnSelect = _h === void 0 ? !multiple : _h, _j = _a.circularNavigation, circularNavigation = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, openProp = _a.open, _l = _a.optionsListWidth, optionsListWidth = _l === void 0 ? 'content' : _l, name = _a.name, id = _a.id, _m = _a.selected, selected = _m === void 0 ? [] : _m, _o = _a.size, size = _o === void 0 ? 'm' : _o, _p = _a.optionsSize, optionsSize = _p === void 0 ? 'm' : _p, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, labelView = _a.labelView, placeholder = _a.placeholder, _q = _a.fieldProps, fieldProps = _q === void 0 ? {} : _q, _r = _a.optionProps, optionProps = _r === void 0 ? {} : _r, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur,
|
|
51
|
+
var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, optionGroupClassName = _a.optionGroupClassName, optionsListProps = _a.optionsListProps, _c = _a.options, options = _c === void 0 ? [] : _c, _d = _a.autocomplete, autocomplete = _d === void 0 ? false : _d, _e = _a.multiple, multiple = _e === void 0 ? false : _e, _f = _a.allowUnselect, allowUnselect = _f === void 0 ? false : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.closeOnSelect, closeOnSelect = _h === void 0 ? !multiple : _h, _j = _a.circularNavigation, circularNavigation = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, openProp = _a.open, _l = _a.optionsListWidth, optionsListWidth = _l === void 0 ? 'content' : _l, name = _a.name, id = _a.id, _m = _a.selected, selected = _m === void 0 ? [] : _m, _o = _a.size, size = _o === void 0 ? 'm' : _o, _p = _a.optionsSize, optionsSize = _p === void 0 ? 'm' : _p, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, labelView = _a.labelView, placeholder = _a.placeholder, _q = _a.fieldProps, fieldProps = _q === void 0 ? {} : _q, _r = _a.optionProps, optionProps = _r === void 0 ? {} : _r, _s = _a.searchProps, searchProps = _s === void 0 ? {} : _s, _t = _a.showSearch, showSearch = _t === void 0 ? false : _t, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur, _u = _a.Arrow, Arrow = _u === void 0 ? components_arrow_Component.Arrow : _u, _v = _a.Field, Field = _v === void 0 ? components_field_Component.Field : _v, _w = _a.Optgroup, Optgroup = _w === void 0 ? components_optgroup_Component.Optgroup : _w, _x = _a.Option, Option = _x === void 0 ? components_option_Component.Option : _x, _y = _a.OptionsList, OptionsList = _y === void 0 ? components_optionsList_Component.OptionsList : _y, _z = _a.Search, Search = _z === void 0 ? components_search_Component.Search : _z, swipeable = _a.swipeable, footer = _a.footer, isBottomSheet = _a.isBottomSheet, bottomSheetProps = _a.bottomSheetProps, modalProps = _a.modalProps, modalHeaderProps = _a.modalHeaderProps, modalFooterProps = _a.modalFooterProps, _0 = _a.showEmptyOptionsList, showEmptyOptionsList = _0 === void 0 ? false : _0;
|
|
48
52
|
var rootRef = React.useRef(null);
|
|
49
53
|
var fieldRef = React.useRef(null);
|
|
50
54
|
var listRef = React.useRef(null);
|
|
51
55
|
var initiatorRef = React.useRef(null);
|
|
52
56
|
var alreadyClickedRef = React.useRef(false);
|
|
57
|
+
var searchRef = React.useRef(null);
|
|
58
|
+
var _1 = React__default.default.useState(''), searchState = _1[0], setSearchState = _1[1];
|
|
59
|
+
var _2 = typeof (searchProps === null || searchProps === void 0 ? void 0 : searchProps.value) === 'string'
|
|
60
|
+
? [searchProps.value, searchProps.onChange]
|
|
61
|
+
: [searchState, setSearchState], search = _2[0], setSearch = _2[1];
|
|
53
62
|
var itemToString = function (option) { return (option ? option.key : ''); };
|
|
54
|
-
var
|
|
63
|
+
var accessor = searchProps.accessor || utils.defaultAccessor;
|
|
64
|
+
var _3 = React.useMemo(function () {
|
|
65
|
+
return utils.processOptions(options, selected, function (option) {
|
|
66
|
+
return utils.defaultFilterFn(accessor(option), search);
|
|
67
|
+
});
|
|
68
|
+
}, [accessor, options, search, selected]), filteredOptions = _3.filteredOptions, flatOptions = _3.flatOptions, selectedOptions = _3.selectedOptions;
|
|
55
69
|
var scrollableContainerRef = React.useRef(null);
|
|
56
70
|
var useMultipleSelectionProps = {
|
|
57
71
|
itemToString: itemToString,
|
|
@@ -79,8 +93,8 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
79
93
|
if (selected !== undefined) {
|
|
80
94
|
useMultipleSelectionProps.selectedItems = selectedOptions;
|
|
81
95
|
}
|
|
82
|
-
var
|
|
83
|
-
var
|
|
96
|
+
var _4 = downshift.useMultipleSelection(useMultipleSelectionProps), selectedItems = _4.selectedItems, addSelectedItem = _4.addSelectedItem, setSelectedItems = _4.setSelectedItems, removeSelectedItem = _4.removeSelectedItem, getDropdownProps = _4.getDropdownProps;
|
|
97
|
+
var _5 = downshift.useCombobox({
|
|
84
98
|
id: id,
|
|
85
99
|
isOpen: openProp,
|
|
86
100
|
circularNavigation: circularNavigation,
|
|
@@ -103,6 +117,18 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
103
117
|
});
|
|
104
118
|
}, 0);
|
|
105
119
|
}
|
|
120
|
+
if (showSearch) {
|
|
121
|
+
if (isOpen) {
|
|
122
|
+
setTimeout(function () {
|
|
123
|
+
var _a;
|
|
124
|
+
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
125
|
+
// BottomSheet transition duration
|
|
126
|
+
}, 500);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
setSearch === null || setSearch === void 0 ? void 0 : setSearch('');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
106
132
|
},
|
|
107
133
|
stateReducer: function (state, actionAndChanges) {
|
|
108
134
|
var type = actionAndChanges.type, changes = actionAndChanges.changes;
|
|
@@ -149,7 +175,7 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
149
175
|
return changes;
|
|
150
176
|
}
|
|
151
177
|
},
|
|
152
|
-
}), open =
|
|
178
|
+
}), open = _5.isOpen, getMenuProps = _5.getMenuProps, getInputProps = _5.getInputProps, getItemProps = _5.getItemProps, getComboboxProps = _5.getComboboxProps, getLabelProps = _5.getLabelProps, highlightedIndex = _5.highlightedIndex, toggleMenu = _5.toggleMenu, openMenu = _5.openMenu;
|
|
153
179
|
var menuProps = getMenuProps({ ref: listRef }, { suppressRefError: true });
|
|
154
180
|
var inputProps = getInputProps(getDropdownProps({ ref: mergeRefs__default.default([ref, fieldRef]) }));
|
|
155
181
|
var handleFieldFocus = function (event) {
|
|
@@ -212,11 +238,24 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
212
238
|
var renderValue = function () {
|
|
213
239
|
return selectedItems.map(function (option) { return (React__default.default.createElement("input", { type: 'hidden', name: name, value: option.key, key: option.key })); });
|
|
214
240
|
};
|
|
241
|
+
var renderSearch = function () {
|
|
242
|
+
return showSearch && (React__default.default.createElement(Search, tslib.__assign({}, searchProps === null || searchProps === void 0 ? void 0 : searchProps.componentProps, { value: search, onChange: function (_, payload) { return setSearch === null || setSearch === void 0 ? void 0 : setSearch(payload.value); }, dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'search'), onClear: function () { return setSearch === null || setSearch === void 0 ? void 0 : setSearch(''); }, className: styles__default.default.search, ref: searchRef })));
|
|
243
|
+
};
|
|
244
|
+
var emptyPlaceholder = optionsListProps.emptyPlaceholder;
|
|
245
|
+
var renderEmptyPlaceholder = function () {
|
|
246
|
+
if (emptyPlaceholder) {
|
|
247
|
+
return emptyPlaceholder;
|
|
248
|
+
}
|
|
249
|
+
if (showSearch) {
|
|
250
|
+
return React__default.default.createElement("div", { className: styles__default.default.emptySearchPlaceholder }, "\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0448\u043B\u043E\u0441\u044C");
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
};
|
|
215
254
|
var renderOptionsList = function () {
|
|
216
|
-
if (flatOptions.length === 0 && !showEmptyOptionsList)
|
|
255
|
+
if (flatOptions.length === 0 && !showEmptyOptionsList && !showSearch)
|
|
217
256
|
return null;
|
|
218
|
-
return (React__default.default.createElement("div", tslib.__assign({}, menuProps, { className: optionsListClassName }),
|
|
219
|
-
React__default.default.createElement(OptionsList, tslib.__assign({}, optionsListProps, { ref: scrollableContainerRef, optionsListWidth: optionsListWidth, flatOptions: flatOptions, highlightedIndex: highlightedIndex, open: open, size: size, options:
|
|
257
|
+
return (React__default.default.createElement("div", tslib.__assign({}, menuProps, { className: cn__default.default(styles__default.default.optionsListWrapper, optionsListClassName) }),
|
|
258
|
+
React__default.default.createElement(OptionsList, tslib.__assign({}, optionsListProps, { ref: scrollableContainerRef, className: styles__default.default.optionsList, scrollbarClassName: styles__default.default.scrollbar, optionsListWidth: optionsListWidth, flatOptions: flatOptions, highlightedIndex: highlightedIndex, open: open, size: size, options: filteredOptions, Optgroup: Optgroup, Option: Option, selectedItems: selectedItems, setSelectedItems: setSelectedItems, toggleMenu: toggleMenu, getOptionProps: getOptionProps, visibleOptions: 0, dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'options-list'), optionGroupClassName: cn__default.default(styles__default.default.optionGroup, optionGroupClassName), emptyPlaceholder: renderEmptyPlaceholder() }))));
|
|
220
259
|
};
|
|
221
260
|
return (React__default.default.createElement("div", tslib.__assign({}, getComboboxProps(tslib.__assign(tslib.__assign({ ref: rootRef }, (disabled && { 'aria-disabled': true })), { className: cn__default.default(styles__default.default.component, (_b = {}, _b[styles__default.default.block] = block, _b), className) })), { onKeyDown: disabled ? undefined : handleFieldKeyDown, tabIndex: -1, "data-test-id": coreComponentsShared.getDataTestId(dataTestId) }),
|
|
222
261
|
React__default.default.createElement(Field, tslib.__assign({ selectedMultiple: selectedItems, selected: selectedItems[0], setSelectedItems: setSelectedItems, toggleMenu: toggleMenu, multiple: multiple, open: open, disabled: disabled, size: size, placeholder: placeholder, label: label && React__default.default.createElement("span", tslib.__assign({}, getLabelProps()), label), labelView: labelView, Arrow: Arrow && React__default.default.createElement(Arrow, { open: open }), error: error, hint: hint, valueRenderer: valueRenderer, className: fieldClassName, innerProps: {
|
|
@@ -233,7 +272,9 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
233
272
|
: undefined,
|
|
234
273
|
}, dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'field') }, fieldProps)),
|
|
235
274
|
name && renderValue(),
|
|
236
|
-
isBottomSheet ? (React__default.default.createElement(coreComponentsBottomSheet.BottomSheet, tslib.__assign({ open: open, onClose: handleClose, className: styles__default.default.sheet, contentClassName: styles__default.default.sheetContent, containerClassName: styles__default.default.sheetContainer, title: label || placeholder, actionButton: footer, stickyHeader: true, hasCloser: true, swipeable: swipeable, scrollableContainerRef: scrollableContainerRef }, bottomSheetProps
|
|
275
|
+
isBottomSheet ? (React__default.default.createElement(coreComponentsBottomSheet.BottomSheet, tslib.__assign({ open: open, onClose: handleClose, className: styles__default.default.sheet, contentClassName: styles__default.default.sheetContent, containerClassName: styles__default.default.sheetContainer, title: label || placeholder, actionButton: footer, stickyHeader: true, hasCloser: true, swipeable: swipeable, scrollableContainerRef: scrollableContainerRef, initialHeight: showSearch ? 'full' : 'default' }, bottomSheetProps, { bottomAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
276
|
+
renderSearch(), bottomSheetProps === null || bottomSheetProps === void 0 ? void 0 :
|
|
277
|
+
bottomSheetProps.bottomAddons) }), renderOptionsList())) : (React__default.default.createElement(mobile.ModalMobile, tslib.__assign({ open: open, hasCloser: true }, modalProps, { onClose: function () {
|
|
237
278
|
var _a;
|
|
238
279
|
var args = [];
|
|
239
280
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -245,7 +286,7 @@ var BaseSelectMobile = React.forwardRef(function (_a, ref) {
|
|
|
245
286
|
scrollableContainerRef,
|
|
246
287
|
modalProps === null || modalProps === void 0 ? void 0 : modalProps.ref,
|
|
247
288
|
]) }),
|
|
248
|
-
React__default.default.createElement(mobile.ModalMobile.Header, tslib.__assign({ hasCloser: true, sticky: true }, modalHeaderProps), label || placeholder),
|
|
289
|
+
React__default.default.createElement(mobile.ModalMobile.Header, tslib.__assign({ hasCloser: true, sticky: true, bottomAddons: renderSearch() }, modalHeaderProps), label || placeholder),
|
|
249
290
|
React__default.default.createElement(mobile.ModalMobile.Content, { flex: true, className: styles__default.default.modalContent }, renderOptionsList()),
|
|
250
291
|
(modalFooterProps === null || modalFooterProps === void 0 ? void 0 : modalFooterProps.children) && React__default.default.createElement(mobile.ModalMobile.Footer, tslib.__assign({}, modalFooterProps))))));
|
|
251
292
|
});
|
|
@@ -34,6 +34,10 @@ require('../options-list/Component.js');
|
|
|
34
34
|
require('@alfalab/core-components-scrollbar/cssm');
|
|
35
35
|
require('../../consts.js');
|
|
36
36
|
require('../options-list/index.module.css');
|
|
37
|
+
require('../search/Component.js');
|
|
38
|
+
require('@alfalab/core-components-input/cssm');
|
|
39
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
40
|
+
require('../search/index.module.css');
|
|
37
41
|
require('./index.module.css');
|
|
38
42
|
|
|
39
43
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
} :root {
|
|
14
14
|
--gap-2xs: 4px;
|
|
15
15
|
--gap-xs: 8px;
|
|
16
|
+
--gap-s: 12px;
|
|
16
17
|
--gap-m: 16px;
|
|
17
18
|
--gap-l: 20px;
|
|
18
19
|
} :root {
|
|
@@ -36,10 +37,24 @@
|
|
|
36
37
|
padding: 0
|
|
37
38
|
} .sheetContent .modalContent {
|
|
38
39
|
padding: 0;
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
39
42
|
} .sheetContainer {
|
|
40
43
|
padding: 0;
|
|
41
44
|
} .block {
|
|
42
45
|
width: 100%;
|
|
46
|
+
} .optionsListWrapper {
|
|
47
|
+
flex: 1;
|
|
48
|
+
} .optionsList {
|
|
49
|
+
height: 100%;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
} .scrollbar {
|
|
53
|
+
flex: 1;
|
|
54
|
+
} .emptySearchPlaceholder {
|
|
55
|
+
text-align: center;
|
|
56
|
+
} .search {
|
|
57
|
+
padding: var(--gap-m) var(--gap-xs) var(--gap-s);
|
|
43
58
|
} /* width: max-content; fix for IE */ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
44
59
|
.component {
|
|
45
60
|
float: left;
|
package/cssm/components/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var components_option_Component = require('./option/Component.js');
|
|
|
10
10
|
var components_optionsList_Component = require('./options-list/Component.js');
|
|
11
11
|
var components_virtualOptionsList_Component = require('./virtual-options-list/Component.js');
|
|
12
12
|
var components_baseOption_Component = require('./base-option/Component.js');
|
|
13
|
+
var components_search_Component = require('./search/Component.js');
|
|
13
14
|
require('react');
|
|
14
15
|
require('classnames');
|
|
15
16
|
require('@alfalab/icons-glyph/ChevronDownMIcon');
|
|
@@ -43,6 +44,9 @@ require('./virtual-options-list/index.module.css');
|
|
|
43
44
|
require('./base-checkmark/Component.js');
|
|
44
45
|
require('./base-checkmark/index.module.css');
|
|
45
46
|
require('./base-option/index.module.css');
|
|
47
|
+
require('@alfalab/core-components-input/cssm');
|
|
48
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
49
|
+
require('./search/index.module.css');
|
|
46
50
|
|
|
47
51
|
|
|
48
52
|
|
|
@@ -54,3 +58,4 @@ exports.Option = components_option_Component.Option;
|
|
|
54
58
|
exports.OptionsList = components_optionsList_Component.OptionsList;
|
|
55
59
|
exports.VirtualOptionsList = components_virtualOptionsList_Component.VirtualOptionsList;
|
|
56
60
|
exports.BaseOption = components_baseOption_Component.BaseOption;
|
|
61
|
+
exports.Search = components_search_Component.Search;
|
|
@@ -28,7 +28,7 @@ var createCounter = function () {
|
|
|
28
28
|
};
|
|
29
29
|
var OptionsList = React.forwardRef(function (_a, ref) {
|
|
30
30
|
var _b;
|
|
31
|
-
var _c = _a.size, size = _c === void 0 ? 's' : _c, className = _a.className, optionGroupClassName = _a.optionGroupClassName, Option = _a.Option, getOptionProps = _a.getOptionProps, _d = _a.options, options = _d === void 0 ? [] : _d, _e = _a.Optgroup, Optgroup = _e === void 0 ? components_optgroup_Component.Optgroup : _e, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _f = _a.visibleOptions, visibleOptions = _f === void 0 ? consts.DEFAULT_VISIBLE_OPTIONS : _f, onScroll = _a.onScroll, open = _a.open, header = _a.header, footer = _a.footer, _g = _a.showFooter, showFooter = _g === void 0 ? true : _g, optionsListWidth = _a.optionsListWidth, nativeScrollbarProp = _a.nativeScrollbar, _h = _a.flatOptions, flatOptions = _h === void 0 ? [] : _h;
|
|
31
|
+
var _c = _a.size, size = _c === void 0 ? 's' : _c, className = _a.className, optionGroupClassName = _a.optionGroupClassName, scrollbarClassName = _a.scrollbarClassName, Option = _a.Option, getOptionProps = _a.getOptionProps, _d = _a.options, options = _d === void 0 ? [] : _d, _e = _a.Optgroup, Optgroup = _e === void 0 ? components_optgroup_Component.Optgroup : _e, dataTestId = _a.dataTestId, emptyPlaceholder = _a.emptyPlaceholder, _f = _a.visibleOptions, visibleOptions = _f === void 0 ? consts.DEFAULT_VISIBLE_OPTIONS : _f, onScroll = _a.onScroll, open = _a.open, header = _a.header, footer = _a.footer, _g = _a.showFooter, showFooter = _g === void 0 ? true : _g, optionsListWidth = _a.optionsListWidth, nativeScrollbarProp = _a.nativeScrollbar, _h = _a.flatOptions, flatOptions = _h === void 0 ? [] : _h;
|
|
32
32
|
var nativeScrollbar = hooks.useMedia([[true, '(max-width: 1023px)']], false)[0];
|
|
33
33
|
nativeScrollbar = Boolean(nativeScrollbarProp !== null && nativeScrollbarProp !== void 0 ? nativeScrollbarProp : nativeScrollbar);
|
|
34
34
|
var renderOption = function (option, index) { return (React__default.default.createElement(Option, tslib.__assign({ key: option.key }, getOptionProps(option, index)))); };
|
|
@@ -37,7 +37,7 @@ var OptionsList = React.forwardRef(function (_a, ref) {
|
|
|
37
37
|
var counter = createCounter();
|
|
38
38
|
var renderGroup = function (group) { return (React__default.default.createElement(Optgroup, { className: optionGroupClassName, label: group.label, key: group.label, size: size }, group.options.map(function (option) { return renderOption(option, counter()); }))); };
|
|
39
39
|
utils.useVisibleOptions(tslib.__assign(tslib.__assign({}, (!nativeScrollbar && { styleTargetRef: scrollbarRef })), { visibleOptions: visibleOptions, listRef: listRef, open: open, invalidate: options }));
|
|
40
|
-
if (options.length === 0 && !emptyPlaceholder) {
|
|
40
|
+
if (options.length === 0 && !emptyPlaceholder && !header && !footer) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
var renderListItems = function () { return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
@@ -51,9 +51,9 @@ var OptionsList = React.forwardRef(function (_a, ref) {
|
|
|
51
51
|
'data-test-id': dataTestId,
|
|
52
52
|
ref: ref,
|
|
53
53
|
};
|
|
54
|
-
return (React__default.default.createElement(coreComponentsScrollbar.Scrollbar, { className: styles__default.default.scrollable, ref: scrollbarRef, horizontalAutoStretch: optionsListWidth === 'content', scrollableNodeProps: scrollableNodeProps, contentNodeProps: { ref: listRef } }, renderListItems()));
|
|
54
|
+
return (React__default.default.createElement(coreComponentsScrollbar.Scrollbar, { className: cn__default.default(styles__default.default.scrollable, scrollbarClassName), ref: scrollbarRef, horizontalAutoStretch: optionsListWidth === 'content', scrollableNodeProps: scrollableNodeProps, contentNodeProps: { ref: listRef } }, renderListItems()));
|
|
55
55
|
};
|
|
56
|
-
var renderWithNativeScrollbar = function () { return (React__default.default.createElement("div", { className: styles__default.default.scrollable, ref: mergeRefs__default.default([listRef, ref]), onScroll: onScroll }, renderListItems())); };
|
|
56
|
+
var renderWithNativeScrollbar = function () { return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.scrollable, scrollbarClassName), ref: mergeRefs__default.default([listRef, ref]), onScroll: onScroll }, renderListItems())); };
|
|
57
57
|
return (React__default.default.createElement("div", tslib.__assign({}, (nativeScrollbar && { 'data-test-id': dataTestId }), { className: cn__default.default(styles__default.default.optionsList, styles__default.default[size], className) }),
|
|
58
58
|
header && React__default.default.createElement("div", { className: styles__default.default.optionsListHeader }, header),
|
|
59
59
|
nativeScrollbar ? renderWithNativeScrollbar() : renderWithCustomScrollbar(),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const Search: React.ForwardRefExoticComponent<Omit<import("packages/input/src/components/base-input").BaseInputProps, "colorStyles" | "FormControlComponent"> & {
|
|
4
|
+
breakpoint?: number | undefined;
|
|
5
|
+
defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
|
|
6
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
7
|
+
export { Search };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cn = require('classnames');
|
|
8
|
+
var coreComponentsInput = require('@alfalab/core-components-input/cssm');
|
|
9
|
+
var MagnifierMIcon = require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
10
|
+
var styles = require('./index.module.css');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
16
|
+
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
17
|
+
|
|
18
|
+
var Search = React.forwardRef(function (_a, ref) {
|
|
19
|
+
var _b = _a.clear, clear = _b === void 0 ? true : _b, _c = _a.placeholder, placeholder = _c === void 0 ? 'Поиск' : _c, className = _a.className, _d = _a.leftAddons, leftAddons = _d === void 0 ? React__default.default.createElement(MagnifierMIcon.MagnifierMIcon, { color: '#86868A' }) : _d, restProps = tslib.__rest(_a, ["clear", "placeholder", "className", "leftAddons"]);
|
|
20
|
+
return (React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({ ref: ref, className: cn__default.default(styles__default.default.component, className), placeholder: placeholder, leftAddons: leftAddons, clear: clear }, restProps)));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.Search = Search;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var components_search_Component = require('./Component.js');
|
|
6
|
+
require('tslib');
|
|
7
|
+
require('react');
|
|
8
|
+
require('classnames');
|
|
9
|
+
require('@alfalab/core-components-input/cssm');
|
|
10
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
11
|
+
require('./index.module.css');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.Search = components_search_Component.Search;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
} /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
4
|
+
} :root {
|
|
5
|
+
} :root {
|
|
6
|
+
|
|
7
|
+
/* Hard */
|
|
8
|
+
|
|
9
|
+
/* Up */
|
|
10
|
+
|
|
11
|
+
/* Hard up */
|
|
12
|
+
} :root {
|
|
13
|
+
} :root {
|
|
14
|
+
} :root {
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
|
|
18
|
+
/* options list */
|
|
19
|
+
|
|
20
|
+
/* option */
|
|
21
|
+
|
|
22
|
+
/* checkmark */
|
|
23
|
+
|
|
24
|
+
/* optgroup */
|
|
25
|
+
} .component {
|
|
26
|
+
width: auto;
|
|
27
|
+
}
|
package/cssm/desktop.js
CHANGED
|
@@ -38,6 +38,10 @@ require('./components/options-list/Component.js');
|
|
|
38
38
|
require('@alfalab/core-components-scrollbar/cssm');
|
|
39
39
|
require('./consts.js');
|
|
40
40
|
require('./components/options-list/index.module.css');
|
|
41
|
+
require('./components/search/Component.js');
|
|
42
|
+
require('@alfalab/core-components-input/cssm');
|
|
43
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
44
|
+
require('./components/search/index.module.css');
|
|
41
45
|
|
|
42
46
|
|
|
43
47
|
|
|
@@ -21,6 +21,14 @@ type UseSelectWithApplyProps = {
|
|
|
21
21
|
* Пропсы, которые будут прокинуты в компонент списка
|
|
22
22
|
*/
|
|
23
23
|
optionsListProps?: BaseSelectProps['optionsListProps'];
|
|
24
|
+
/**
|
|
25
|
+
* Включает отображение поиска
|
|
26
|
+
*/
|
|
27
|
+
showSearch?: BaseSelectProps['showSearch'];
|
|
28
|
+
/**
|
|
29
|
+
* Настройки поиска
|
|
30
|
+
*/
|
|
31
|
+
searchProps?: BaseSelectProps['searchProps'];
|
|
24
32
|
/**
|
|
25
33
|
* Показывать кнопку очистки
|
|
26
34
|
*/
|
|
@@ -35,17 +43,17 @@ type UseSelectWithApplyProps = {
|
|
|
35
43
|
showHeaderWithSelectAll?: boolean;
|
|
36
44
|
};
|
|
37
45
|
declare const SELECT_ALL_KEY = "select_all";
|
|
38
|
-
declare function useSelectWithApply({ options, selected, onChange, OptionsList, optionsListProps, showClear, showSelectAll, showHeaderWithSelectAll, }: UseSelectWithApplyProps): {
|
|
46
|
+
declare function useSelectWithApply({ options, selected, onChange, OptionsList, optionsListProps, showClear, showSelectAll, showHeaderWithSelectAll, showSearch, searchProps, }: UseSelectWithApplyProps): {
|
|
39
47
|
OptionsList: import("react").ForwardRefExoticComponent<import("./typings").OptionsListProps & {
|
|
40
48
|
showClear?: boolean | undefined;
|
|
41
|
-
onClose?: (() => void) | undefined;
|
|
49
|
+
onClose?: (() => void) | undefined; /**
|
|
50
|
+
* Компонент выпадающего меню
|
|
51
|
+
*/
|
|
42
52
|
selectedDraft?: OptionShape[] | undefined;
|
|
43
53
|
OptionsList?: import("react").FC<import("./typings").OptionsListProps & import("react").RefAttributes<HTMLDivElement>> | undefined;
|
|
44
54
|
Footer?: import("react").FC<import("./presets/useSelectWithApply/options-list-with-apply/footer/Component").FooterProps> | undefined;
|
|
45
55
|
Header?: import("react").FC<import("./presets/useSelectWithApply/options-list-with-apply/header/Component").HeaderProps> | undefined;
|
|
46
|
-
headerProps?: import("./presets/useSelectWithApply/options-list-with-apply/header/Component").HeaderProps | undefined;
|
|
47
|
-
* Показывать кнопку очистки
|
|
48
|
-
*/
|
|
56
|
+
headerProps?: import("./presets/useSelectWithApply/options-list-with-apply/header/Component").HeaderProps | undefined;
|
|
49
57
|
showHeaderWithSelectAll?: boolean | undefined;
|
|
50
58
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
59
|
optionsListProps: {
|
|
@@ -70,5 +78,12 @@ declare function useSelectWithApply({ options, selected, onChange, OptionsList,
|
|
|
70
78
|
})[];
|
|
71
79
|
onChange: (payload: import("./typings").BaseSelectChangePayload) => void;
|
|
72
80
|
selected: string | OptionShape | (string | OptionShape)[] | null | undefined;
|
|
81
|
+
showSearch: boolean | undefined;
|
|
82
|
+
searchProps: {
|
|
83
|
+
value: string;
|
|
84
|
+
onChange: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
85
|
+
componentProps?: import("packages/input/src").InputProps | undefined;
|
|
86
|
+
accessor?: ((option: OptionShape) => string) | undefined;
|
|
87
|
+
} | undefined;
|
|
73
88
|
};
|
|
74
89
|
export { UseSelectWithApplyProps, SELECT_ALL_KEY, useSelectWithApply };
|
|
@@ -13,7 +13,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
14
|
|
|
15
15
|
var OptionsListWithApply = React.forwardRef(function (_a, ref) {
|
|
16
|
-
var toggleMenu = _a.toggleMenu, defaultGetOptionProps = _a.getOptionProps, _b = _a.showClear, showClear = _b === void 0 ? true : _b, showHeaderWithSelectAll = _a.showHeaderWithSelectAll, _c = _a.selectedDraft, selectedDraft = _c === void 0 ? [] : _c, _d = _a.flatOptions, flatOptions = _d === void 0 ? [] : _d, _e = _a.OptionsList, OptionsList = _e === void 0 ? components_optionsList_Component.OptionsList : _e, _f = _a.onApply, onApply = _f === void 0 ? function () { return null; } : _f, _g = _a.onClear, onClear = _g === void 0 ? function () { return null; } : _g, _h = _a.onClose, onClose = _h === void 0 ? function () { return null; } : _h, _j = _a.visibleOptions, visibleOptions = _j === void 0 ? consts.DEFAULT_VISIBLE_OPTIONS : _j, _k = _a.Footer, Footer = _k === void 0 ? presets_useSelectWithApply_optionsListWithApply_footer_Component.Footer : _k, _l = _a.Header, Header = _l === void 0 ? presets_useSelectWithApply_optionsListWithApply_header_Component.Header : _l, headerProps = _a.headerProps, restProps = tslib.__rest(_a, ["toggleMenu", "getOptionProps", "showClear", "showHeaderWithSelectAll", "selectedDraft", "flatOptions", "OptionsList", "onApply", "onClear", "onClose", "visibleOptions", "Footer", "Header", "headerProps"]);
|
|
16
|
+
var toggleMenu = _a.toggleMenu, defaultGetOptionProps = _a.getOptionProps, _b = _a.showClear, showClear = _b === void 0 ? true : _b, showHeaderWithSelectAll = _a.showHeaderWithSelectAll, _c = _a.selectedDraft, selectedDraft = _c === void 0 ? [] : _c, _d = _a.flatOptions, flatOptions = _d === void 0 ? [] : _d, _e = _a.OptionsList, OptionsList = _e === void 0 ? components_optionsList_Component.OptionsList : _e, _f = _a.onApply, onApply = _f === void 0 ? function () { return null; } : _f, _g = _a.onClear, onClear = _g === void 0 ? function () { return null; } : _g, _h = _a.onClose, onClose = _h === void 0 ? function () { return null; } : _h, _j = _a.visibleOptions, visibleOptions = _j === void 0 ? consts.DEFAULT_VISIBLE_OPTIONS : _j, _k = _a.Footer, Footer = _k === void 0 ? presets_useSelectWithApply_optionsListWithApply_footer_Component.Footer : _k, _l = _a.Header, Header = _l === void 0 ? presets_useSelectWithApply_optionsListWithApply_header_Component.Header : _l, header = _a.header, headerProps = _a.headerProps, restProps = tslib.__rest(_a, ["toggleMenu", "getOptionProps", "showClear", "showHeaderWithSelectAll", "selectedDraft", "flatOptions", "OptionsList", "onApply", "onClear", "onClose", "visibleOptions", "Footer", "Header", "header", "headerProps"]);
|
|
17
17
|
var getOptionProps = React.useCallback(function (option, index) {
|
|
18
18
|
var optionProps = defaultGetOptionProps(option, index);
|
|
19
19
|
var selected = option.key === SELECT_ALL_KEY
|
|
@@ -39,15 +39,26 @@ var OptionsListWithApply = React.forwardRef(function (_a, ref) {
|
|
|
39
39
|
};
|
|
40
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
41
|
}, []);
|
|
42
|
-
|
|
42
|
+
var renderHeader = function () {
|
|
43
|
+
if (!showHeaderWithSelectAll && !header)
|
|
44
|
+
return undefined;
|
|
45
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
46
|
+
header,
|
|
47
|
+
showHeaderWithSelectAll && React__default.default.createElement(Header, tslib.__assign({}, headerProps))));
|
|
48
|
+
};
|
|
49
|
+
return (React__default.default.createElement(OptionsList, tslib.__assign({}, restProps, { ref: ref, visibleOptions: visibleOptions, toggleMenu: toggleMenu, flatOptions: flatOptions, getOptionProps: getOptionProps, onApply: handleApply, onClear: handleClear, header: renderHeader(), footer: React__default.default.createElement(Footer, { handleApply: handleApply, handleClear: handleClear, showClear: showClear, selectedDraft: selectedDraft }) })));
|
|
43
50
|
});
|
|
44
51
|
|
|
45
52
|
var SELECT_ALL_KEY = 'select_all';
|
|
46
53
|
var selectAllOption = { key: SELECT_ALL_KEY, content: 'Выбрать все' };
|
|
47
54
|
function useSelectWithApply(_a) {
|
|
48
|
-
var options = _a.options, selected = _a.selected, _b = _a.onChange, onChange = _b === void 0 ? function () { return null; } : _b, OptionsList = _a.OptionsList, _c = _a.optionsListProps, optionsListProps = _c === void 0 ? {} : _c, _d = _a.showClear, showClear = _d === void 0 ? true : _d, _e = _a.showSelectAll, showSelectAll = _e === void 0 ? false : _e, _f = _a.showHeaderWithSelectAll, showHeaderWithSelectAll = _f === void 0 ? false : _f;
|
|
49
|
-
var
|
|
50
|
-
var
|
|
55
|
+
var options = _a.options, selected = _a.selected, _b = _a.onChange, onChange = _b === void 0 ? function () { return null; } : _b, OptionsList = _a.OptionsList, _c = _a.optionsListProps, optionsListProps = _c === void 0 ? {} : _c, _d = _a.showClear, showClear = _d === void 0 ? true : _d, _e = _a.showSelectAll, showSelectAll = _e === void 0 ? false : _e, _f = _a.showHeaderWithSelectAll, showHeaderWithSelectAll = _f === void 0 ? false : _f, showSearch = _a.showSearch, _g = _a.searchProps, searchProps = _g === void 0 ? {} : _g;
|
|
56
|
+
var _h = React.useState(''), search = _h[0], setSearch = _h[1];
|
|
57
|
+
var accessor = searchProps.accessor || utils.defaultAccessor;
|
|
58
|
+
var _j = React.useMemo(function () {
|
|
59
|
+
return utils.processOptions(options, selected, showSearch ? function (option) { return utils.defaultFilterFn(accessor(option), search); } : undefined);
|
|
60
|
+
}, [accessor, options, search, selected, showSearch]), flatOptions = _j.flatOptions, selectedOptions = _j.selectedOptions;
|
|
61
|
+
var _k = React.useState(selectedOptions), selectedDraft = _k[0], setSelectedDraft = _k[1];
|
|
51
62
|
var selectedOptionsRef = React.useRef(selectedOptions);
|
|
52
63
|
var handleApply = function () {
|
|
53
64
|
onChange({
|
|
@@ -102,6 +113,9 @@ function useSelectWithApply(_a) {
|
|
|
102
113
|
options: memoizedOptions,
|
|
103
114
|
onChange: handleChange,
|
|
104
115
|
selected: selected,
|
|
116
|
+
showSearch: showSearch,
|
|
117
|
+
searchProps: showSearch
|
|
118
|
+
? tslib.__assign(tslib.__assign({}, searchProps), { value: search, onChange: setSearch }) : undefined,
|
|
105
119
|
};
|
|
106
120
|
}
|
|
107
121
|
|
package/cssm/index.js
CHANGED
|
@@ -39,6 +39,10 @@ require('./components/options-list/Component.js');
|
|
|
39
39
|
require('@alfalab/core-components-scrollbar/cssm');
|
|
40
40
|
require('./consts.js');
|
|
41
41
|
require('./components/options-list/index.module.css');
|
|
42
|
+
require('./components/search/Component.js');
|
|
43
|
+
require('@alfalab/core-components-input/cssm');
|
|
44
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
45
|
+
require('./components/search/index.module.css');
|
|
42
46
|
require('./Component.mobile.js');
|
|
43
47
|
require('@alfalab/core-components-form-control/cssm/mobile');
|
|
44
48
|
require('./components/base-select-mobile/Component.js');
|
|
@@ -52,7 +56,7 @@ require('./components/base-select-mobile/footer/index.module.css');
|
|
|
52
56
|
require('./components/virtual-options-list/Component.js');
|
|
53
57
|
require('react-virtual');
|
|
54
58
|
require('./components/virtual-options-list/index.module.css');
|
|
55
|
-
require('./hook-
|
|
59
|
+
require('./hook-d1f5dd40.js');
|
|
56
60
|
require('./presets/useSelectWithApply/options-list-with-apply/footer/Component.js');
|
|
57
61
|
require('@alfalab/core-components-button/cssm/desktop');
|
|
58
62
|
require('./presets/useSelectWithApply/options-list-with-apply/footer/index.module.css');
|
package/cssm/mobile.js
CHANGED
|
@@ -37,6 +37,10 @@ require('./components/options-list/Component.js');
|
|
|
37
37
|
require('@alfalab/core-components-scrollbar/cssm');
|
|
38
38
|
require('./consts.js');
|
|
39
39
|
require('./components/options-list/index.module.css');
|
|
40
|
+
require('./components/search/Component.js');
|
|
41
|
+
require('@alfalab/core-components-input/cssm');
|
|
42
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
43
|
+
require('./components/search/index.module.css');
|
|
40
44
|
require('./components/base-select-mobile/index.module.css');
|
|
41
45
|
require('./components/base-select-mobile/footer/Component.js');
|
|
42
46
|
require('@alfalab/core-components-base-modal/cssm');
|
|
@@ -45,7 +49,7 @@ require('./components/base-select-mobile/footer/index.module.css');
|
|
|
45
49
|
require('./components/virtual-options-list/Component.js');
|
|
46
50
|
require('react-virtual');
|
|
47
51
|
require('./components/virtual-options-list/index.module.css');
|
|
48
|
-
require('./hook-
|
|
52
|
+
require('./hook-d1f5dd40.js');
|
|
49
53
|
require('./presets/useSelectWithApply/options-list-with-apply/footer/Component.js');
|
|
50
54
|
require('@alfalab/core-components-button/cssm/desktop');
|
|
51
55
|
require('./presets/useSelectWithApply/options-list-with-apply/footer/index.module.css');
|
package/cssm/presets/index.d.ts
CHANGED
package/cssm/presets/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var presets_useSelectWithLoading_hook = require('./useSelectWithLoading/hook.js');
|
|
6
6
|
var presets_useLazyLoading_hook = require('./useLazyLoading/hook.js');
|
|
7
|
-
var presets_useSelectWithApply_optionsListWithApply_Component = require('../hook-
|
|
7
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('../hook-d1f5dd40.js');
|
|
8
8
|
require('tslib');
|
|
9
9
|
require('react');
|
|
10
10
|
require('@alfalab/core-components-skeleton/cssm');
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
require('tslib');
|
|
6
6
|
require('react');
|
|
7
7
|
require('../../utils.js');
|
|
8
|
-
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../hook-
|
|
8
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../hook-d1f5dd40.js');
|
|
9
9
|
require('../../components/options-list/Component.js');
|
|
10
10
|
require('react-merge-refs');
|
|
11
11
|
require('classnames');
|
|
@@ -6,7 +6,7 @@ require('tslib');
|
|
|
6
6
|
require('react');
|
|
7
7
|
require('../../../components/options-list/Component.js');
|
|
8
8
|
require('../../../consts.js');
|
|
9
|
-
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../../hook-
|
|
9
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../../hook-d1f5dd40.js');
|
|
10
10
|
require('./footer/Component.js');
|
|
11
11
|
require('./header/Component.js');
|
|
12
12
|
require('react-merge-refs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "../../../hook-
|
|
1
|
+
export * from "../../../hook-d1f5dd40";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../../hook-
|
|
5
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('../../../hook-d1f5dd40.js');
|
|
6
6
|
require('tslib');
|
|
7
7
|
require('react');
|
|
8
8
|
require('../../../utils.js');
|
package/cssm/shared.js
CHANGED
|
@@ -10,9 +10,10 @@ var components_option_Component = require('./components/option/Component.js');
|
|
|
10
10
|
var components_optionsList_Component = require('./components/options-list/Component.js');
|
|
11
11
|
var components_virtualOptionsList_Component = require('./components/virtual-options-list/Component.js');
|
|
12
12
|
var components_baseOption_Component = require('./components/base-option/Component.js');
|
|
13
|
+
var components_search_Component = require('./components/search/Component.js');
|
|
13
14
|
var presets_useSelectWithLoading_hook = require('./presets/useSelectWithLoading/hook.js');
|
|
14
15
|
var presets_useLazyLoading_hook = require('./presets/useLazyLoading/hook.js');
|
|
15
|
-
var presets_useSelectWithApply_optionsListWithApply_Component = require('./hook-
|
|
16
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('./hook-d1f5dd40.js');
|
|
16
17
|
var utils = require('./utils.js');
|
|
17
18
|
require('react');
|
|
18
19
|
require('classnames');
|
|
@@ -46,6 +47,9 @@ require('./components/virtual-options-list/index.module.css');
|
|
|
46
47
|
require('./components/base-checkmark/Component.js');
|
|
47
48
|
require('./components/base-checkmark/index.module.css');
|
|
48
49
|
require('./components/base-option/index.module.css');
|
|
50
|
+
require('@alfalab/core-components-input/cssm');
|
|
51
|
+
require('@alfalab/icons-glyph/MagnifierMIcon');
|
|
52
|
+
require('./components/search/index.module.css');
|
|
49
53
|
require('@alfalab/core-components-skeleton/cssm');
|
|
50
54
|
require('./presets/useSelectWithLoading/index.module.css');
|
|
51
55
|
require('intersection-observer');
|
|
@@ -65,10 +69,13 @@ exports.Option = components_option_Component.Option;
|
|
|
65
69
|
exports.OptionsList = components_optionsList_Component.OptionsList;
|
|
66
70
|
exports.VirtualOptionsList = components_virtualOptionsList_Component.VirtualOptionsList;
|
|
67
71
|
exports.BaseOption = components_baseOption_Component.BaseOption;
|
|
72
|
+
exports.Search = components_search_Component.Search;
|
|
68
73
|
exports.useSelectWithLoading = presets_useSelectWithLoading_hook.useSelectWithLoading;
|
|
69
74
|
exports.useLazyLoading = presets_useLazyLoading_hook.useLazyLoading;
|
|
70
75
|
exports.SELECT_ALL_KEY = presets_useSelectWithApply_optionsListWithApply_Component.SELECT_ALL_KEY;
|
|
71
76
|
exports.useSelectWithApply = presets_useSelectWithApply_optionsListWithApply_Component.useSelectWithApply;
|
|
77
|
+
exports.defaultAccessor = utils.defaultAccessor;
|
|
78
|
+
exports.defaultFilterFn = utils.defaultFilterFn;
|
|
72
79
|
exports.isGroup = utils.isGroup;
|
|
73
80
|
exports.isOptionShape = utils.isOptionShape;
|
|
74
81
|
exports.joinOptions = utils.joinOptions;
|