hrm_ui_lib 3.1.64 → 3.1.66
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/MultiSelectWithTabs/MultiSelectWithTabs.js +1 -6
- package/components/Select/Select/Select.js +2 -4
- package/components/Select/Select/helpers.d.ts +0 -1
- package/components/Select/Select/helpers.js +3 -9
- package/components/Select/helper.d.ts +1 -0
- package/components/Select/helper.js +9 -1
- package/package.json +1 -1
|
@@ -17,12 +17,7 @@ export const MultiSelectWithTabs = (props) => {
|
|
|
17
17
|
const [isAllSelected, setAllSelected] = useState(false);
|
|
18
18
|
const [searchValue, setSearchValue] = useState('');
|
|
19
19
|
const currentTabData = options[activeTab].data;
|
|
20
|
-
const filteredData = useMemo(() =>
|
|
21
|
-
if (!searchValue) {
|
|
22
|
-
return currentTabData;
|
|
23
|
-
}
|
|
24
|
-
return filterSearchData(currentTabData, searchValue);
|
|
25
|
-
}, [searchValue, currentTabData]);
|
|
20
|
+
const filteredData = useMemo(() => filterSearchData(currentTabData, searchValue), [searchValue, currentTabData]);
|
|
26
21
|
const clearAll = useCallback(() => {
|
|
27
22
|
setAllSelected(false);
|
|
28
23
|
const filteredValues = selectedValues.filter((selectedItem) => {
|
|
@@ -22,7 +22,7 @@ import IconChevronUp from '../../SVGIcons/IconChevronUp';
|
|
|
22
22
|
import IconChevronDown from '../../SVGIcons/IconChevronDown';
|
|
23
23
|
import { SELECT_TRANSLATIONS } from '../localization';
|
|
24
24
|
import { Button } from '../../Button';
|
|
25
|
-
import {
|
|
25
|
+
import { filterSearchData } from './helpers';
|
|
26
26
|
export const Select = forwardRef((props, _ref) => {
|
|
27
27
|
var _a, _b;
|
|
28
28
|
const { labelAddons, dataId, className, size = 'small', label, hasError, isValid, disabled, outerHelperText, isRequiredField, placeHolder, selectRightIconProps = {
|
|
@@ -83,9 +83,7 @@ export const Select = forwardRef((props, _ref) => {
|
|
|
83
83
|
const onItemDeselect = () => onItemSelect(null);
|
|
84
84
|
const currentSelection = value || selectedItem;
|
|
85
85
|
const localizations = Object.assign(Object.assign({}, SELECT_TRANSLATIONS[language]), translations);
|
|
86
|
-
const filteredData = useMemo(() =>
|
|
87
|
-
return filterOptions(options, searchValue);
|
|
88
|
-
}, [searchValue, options]);
|
|
86
|
+
const filteredData = useMemo(() => filterSearchData(options, searchValue), [searchValue, options]);
|
|
89
87
|
const handleKeyDown = (e) => {
|
|
90
88
|
if (!isOpen)
|
|
91
89
|
return;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
export const filterOptions = (options, searchValue) => {
|
|
2
|
-
if (!searchValue) {
|
|
3
|
-
return options;
|
|
4
|
-
}
|
|
5
|
-
return options.filter((dataItem) => {
|
|
6
|
-
return (typeof dataItem.label === 'string' &&
|
|
7
|
-
dataItem.label.toLowerCase().includes(searchValue.toLowerCase()));
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
function containsSearchString(source, searchString) {
|
|
11
2
|
const sourceWords = String(source).toLowerCase();
|
|
12
3
|
const targetWords = searchString.toLowerCase().split(/\s+/);
|
|
13
4
|
return targetWords.every((word) => sourceWords.includes(word));
|
|
14
5
|
}
|
|
15
6
|
export const filterSearchData = (data, searchString) => {
|
|
7
|
+
if (!searchString) {
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
16
10
|
return data.filter(({ label }) => containsSearchString(label, searchString));
|
|
17
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCurrentWeekWorkdaysRange: () => [Date, Date];
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export const getCurrentWeekWorkdaysRange = () => {
|
|
2
|
+
const today = new Date();
|
|
3
|
+
const start = new Date(today);
|
|
4
|
+
const end = new Date(today);
|
|
5
|
+
const day = today.getDay();
|
|
6
|
+
const diffToMonday = day === 0 ? -6 : 1 - day;
|
|
7
|
+
start.setDate(today.getDate() + diffToMonday);
|
|
8
|
+
return [start, end];
|
|
9
|
+
};
|