hrm_ui_lib 3.1.83 → 3.1.84

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.
@@ -1,11 +1,19 @@
1
- function containsSearchString(source, searchString) {
2
- const sourceWords = String(source).toLowerCase();
3
- const targetWords = searchString.toLowerCase().split(/\s+/);
4
- return targetWords.every((word) => sourceWords.includes(word));
1
+ function containsSearchString(source, tokens) {
2
+ return tokens.reduce(({ contains, sourceStr }, w) => {
3
+ const remainingStr = sourceStr.replace(w, '');
4
+ return {
5
+ contains: contains && remainingStr.length < sourceStr.length,
6
+ sourceStr: remainingStr
7
+ };
8
+ }, { contains: true, sourceStr: source }).contains;
5
9
  }
6
10
  export const filterSearchData = (data, searchString) => {
7
11
  if (!searchString) {
8
12
  return data;
9
13
  }
10
- return data.filter(({ label }) => containsSearchString(label, searchString));
14
+ const tokens = searchString
15
+ .toLowerCase()
16
+ .split(/\s+/)
17
+ .sort((a, b) => b.length - a.length);
18
+ return data.filter(({ label }) => containsSearchString(label.toString().toLowerCase(), tokens));
11
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "3.1.83",
3
+ "version": "3.1.84",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",