hrm_ui_lib 3.1.62 → 3.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Select/MultiSelect/MultiBase/MultiBase.js +2 -4
- package/components/Select/MultiSelect/MultiSelectGrouped/MultiSelectGrouped.js +2 -4
- package/components/Select/MultiSelect/MultiSelectWithTabs/MultiSelectWithTabs.js +2 -4
- package/components/Select/Select/helpers.d.ts +1 -0
- package/components/Select/Select/helpers.js +8 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { FixedSizeList as List } from 'react-window';
|
|
|
7
7
|
import { DROPDOWN_HEIGHT, DROPDOWN_WIDTH, ITEM_SIZE, ITEM_SIZE_MOBILE } from '../../constants';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { noop } from '../../../../utils/helpers';
|
|
10
|
+
import { filterSearchData } from '../../Select/helpers';
|
|
10
11
|
export const MultiBase = (props) => {
|
|
11
12
|
const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth, applySelectedItems } = props;
|
|
12
13
|
const { emptyListMainMessage, emptyListSecondaryMessage } = translations || {};
|
|
@@ -71,10 +72,7 @@ export const MultiBase = (props) => {
|
|
|
71
72
|
const newOptions = options.filter((item) => selectedValuesArray.indexOf(item.value) === -1);
|
|
72
73
|
return [...selectedValues, ...newOptions];
|
|
73
74
|
}
|
|
74
|
-
return options
|
|
75
|
-
return (typeof dataItem.label === 'string' &&
|
|
76
|
-
dataItem.label.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase()));
|
|
77
|
-
});
|
|
75
|
+
return filterSearchData(options, searchValue);
|
|
78
76
|
}, [searchValue, options, selectedValues]);
|
|
79
77
|
const selectAll = useCallback(() => {
|
|
80
78
|
setAllSelected(true);
|
|
@@ -9,6 +9,7 @@ import { ContentTop } from '../../SharedComponents';
|
|
|
9
9
|
import { DROPDOWN_MAX_HEIGHT } from '../../constants';
|
|
10
10
|
import IconCaretUpFilled from '../../../SVGIcons/IconCaretUpFilled';
|
|
11
11
|
import IconCaretDownFilled from '../../../SVGIcons/IconCaretDownFilled';
|
|
12
|
+
import { filterSearchData } from '../../Select/helpers';
|
|
12
13
|
export const MultiSelectGrouped = (props) => {
|
|
13
14
|
const { isMobile, options, helperText, translations, selectedValues, onItemSelect, onItemDeselect, setSelectedValues, isSearchAvailable, labelLeftIconProps, scrollableContentStyle, optionRightIconComponent, labelRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, closeDropdown } = props;
|
|
14
15
|
const { emptyListMainMessage, emptyListSecondaryMessage } = translations;
|
|
@@ -23,10 +24,7 @@ export const MultiSelectGrouped = (props) => {
|
|
|
23
24
|
}
|
|
24
25
|
return options.reduce((acc, group) => {
|
|
25
26
|
const { data, title } = group;
|
|
26
|
-
const groupData = data
|
|
27
|
-
return (typeof dataItem.label === 'string' &&
|
|
28
|
-
dataItem.label.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase()));
|
|
29
|
-
});
|
|
27
|
+
const groupData = filterSearchData(data, searchValue);
|
|
30
28
|
if (groupData.length) {
|
|
31
29
|
return [
|
|
32
30
|
...acc,
|
|
@@ -7,6 +7,7 @@ import { useGetElemSizes } from '../../../../hooks';
|
|
|
7
7
|
import { OptionItem } from '../../../../helperComponents/OptionItem';
|
|
8
8
|
import { ContentTop } from '../../SharedComponents';
|
|
9
9
|
import { DROPDOWN_MAX_HEIGHT } from '../../constants';
|
|
10
|
+
import { filterSearchData } from '../../Select/helpers';
|
|
10
11
|
export const MultiSelectWithTabs = (props) => {
|
|
11
12
|
const { options, scrollableContentStyle, selectedValues, onItemSelect, onItemDeselect, setSelectedValues, labelLeftIconProps, optionRightIconComponent, labelRightIconComponent, helperText, translations, isSearchAvailable, maxSelectCount, menuOptions, dataIdPrefix, closeDropdown } = props;
|
|
12
13
|
const { emptyListMainMessage, emptyListSecondaryMessage } = translations;
|
|
@@ -20,10 +21,7 @@ export const MultiSelectWithTabs = (props) => {
|
|
|
20
21
|
if (!searchValue) {
|
|
21
22
|
return currentTabData;
|
|
22
23
|
}
|
|
23
|
-
return currentTabData
|
|
24
|
-
return (typeof dataItem.label === 'string' &&
|
|
25
|
-
dataItem.label.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase()));
|
|
26
|
-
});
|
|
24
|
+
return filterSearchData(currentTabData, searchValue);
|
|
27
25
|
}, [searchValue, currentTabData]);
|
|
28
26
|
const clearAll = useCallback(() => {
|
|
29
27
|
setAllSelected(false);
|
|
@@ -7,3 +7,11 @@ export const filterOptions = (options, searchValue) => {
|
|
|
7
7
|
dataItem.label.toLowerCase().includes(searchValue.toLowerCase()));
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
function containsSearchString(source, searchString) {
|
|
11
|
+
const sourceWords = String(source).toLowerCase();
|
|
12
|
+
const targetWords = searchString.toLowerCase().split(/\s+/);
|
|
13
|
+
return targetWords.every((word) => sourceWords.includes(word));
|
|
14
|
+
}
|
|
15
|
+
export const filterSearchData = (data, searchString) => {
|
|
16
|
+
return data.filter(({ label }) => containsSearchString(label, searchString));
|
|
17
|
+
};
|