hrm_ui_lib 3.1.11 → 3.1.12
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.
|
@@ -8,8 +8,9 @@ import { DROPDOWN_HEIGHT, DROPDOWN_WIDTH, ITEM_SIZE, ITEM_SIZE_MOBILE } from '..
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { noop } from '../../../../utils/helpers';
|
|
10
10
|
export const MultiBase = (props) => {
|
|
11
|
-
const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth } = props;
|
|
11
|
+
const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth, applySelectedItems } = props;
|
|
12
12
|
const { emptyListMainMessage, emptyListSecondaryMessage } = translations || {};
|
|
13
|
+
const [navigationMode, setNavigationMode] = useState(false);
|
|
13
14
|
const [searchValue, setSearchValue] = useState('');
|
|
14
15
|
const [isAllSelected, setAllSelected] = useState(false);
|
|
15
16
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
@@ -20,28 +21,39 @@ export const MultiBase = (props) => {
|
|
|
20
21
|
case 'ArrowDown':
|
|
21
22
|
e.preventDefault();
|
|
22
23
|
setActiveIndex((prev) => Math.min(prev + 1, filteredData.length - 1));
|
|
24
|
+
setNavigationMode(true);
|
|
23
25
|
break;
|
|
24
26
|
case 'ArrowUp':
|
|
25
27
|
e.preventDefault();
|
|
26
28
|
setActiveIndex((prev) => Math.max(prev - 1, 0));
|
|
29
|
+
setNavigationMode(true);
|
|
30
|
+
break;
|
|
31
|
+
case ' ':
|
|
32
|
+
if (navigationMode && activeIndex !== null) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
const item = filteredData[activeIndex];
|
|
35
|
+
if (!item) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const isSelected = checkIsSelected(item.value);
|
|
39
|
+
if (isSelected) {
|
|
40
|
+
onDeselect(item);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
onItemSelect(item);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
27
46
|
break;
|
|
28
47
|
case 'Enter':
|
|
29
48
|
e.preventDefault();
|
|
30
|
-
|
|
31
|
-
if (!item) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const isSelected = checkIsSelected(item.value);
|
|
35
|
-
if (isSelected) {
|
|
36
|
-
onDeselect(item);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
onItemSelect(item);
|
|
40
|
-
}
|
|
49
|
+
applySelectedItems();
|
|
41
50
|
break;
|
|
42
51
|
case 'Escape':
|
|
43
52
|
closeDropdown();
|
|
44
53
|
break;
|
|
54
|
+
default:
|
|
55
|
+
// any typing key exits navigation mode
|
|
56
|
+
setNavigationMode(false);
|
|
45
57
|
}
|
|
46
58
|
};
|
|
47
59
|
useEffect(() => {
|
|
@@ -63,6 +63,6 @@ export const MultiSelect = forwardRef((props, _ref) => {
|
|
|
63
63
|
// @ts-ignore
|
|
64
64
|
, Object.assign({
|
|
65
65
|
// @ts-ignore
|
|
66
|
-
options: options, isOpen: isOpen, translations: localizations, setIsOpen: setIsOpen, dropdownRef: dropdownRef, openDropdown: openDropdown, selectedValues: selectedValues, setSelectedValues: setSelectedValues, containerRef: containerRef, dropdownWidth: dropdownWidth, isMobileFullScreen: isMobileFullScreen }, rest)), options.length && !(isMobile && isMobileFullScreen) ? (_jsx(Footer, { checkboxInfo: checkboxInfo, hasChange: hasChange, buttonProps: footerButtonProps, onCancel: cancelSelectedItems, onApply: applySelectedItems, language: language })) : null] }) }));
|
|
66
|
+
options: options, isOpen: isOpen, translations: localizations, setIsOpen: setIsOpen, dropdownRef: dropdownRef, openDropdown: openDropdown, selectedValues: selectedValues, setSelectedValues: setSelectedValues, containerRef: containerRef, dropdownWidth: dropdownWidth, isMobileFullScreen: isMobileFullScreen, applySelectedItems: applySelectedItems }, rest)), options.length && !(isMobile && isMobileFullScreen) ? (_jsx(Footer, { checkboxInfo: checkboxInfo, hasChange: hasChange, buttonProps: footerButtonProps, onCancel: cancelSelectedItems, onApply: applySelectedItems, language: language })) : null] }) }));
|
|
67
67
|
});
|
|
68
68
|
MultiSelect.displayName = 'MultiSelect';
|
|
@@ -66,6 +66,7 @@ interface TMultiSelectCompProps extends IFormCompProps, TSelectBaseProps {
|
|
|
66
66
|
}
|
|
67
67
|
export interface TMultiSingleTabPropTypes extends TMultiSelectCompProps {
|
|
68
68
|
options: TSelectOptions;
|
|
69
|
+
applySelectedItems: () => void;
|
|
69
70
|
}
|
|
70
71
|
export interface TMultiSelectGroupedProps extends TMultiSelectCompProps {
|
|
71
72
|
options: TSelectGroupOptions;
|