@snack-uikit/fields 0.39.3 → 0.40.0
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/CHANGELOG.md +11 -0
- package/dist/cjs/components/FieldSelect/hooks.js +3 -1
- package/dist/cjs/components/FieldSelect/utils/filterItemsByFlattenIds.js +8 -5
- package/dist/esm/components/FieldSelect/hooks.js +1 -1
- package/dist/esm/components/FieldSelect/utils/filterItemsByFlattenIds.js +8 -5
- package/package.json +2 -2
- package/src/components/FieldSelect/hooks.ts +1 -1
- package/src/components/FieldSelect/utils/filterItemsByFlattenIds.ts +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.40.0 (2025-02-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-1648:** enabled scored sort for FuzzySearch ([e45e33e](https://github.com/cloud-ru-tech/snack-uikit/commit/e45e33ea3c2516dc4ad3e42bbd52cfd253e20392))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.39.3 (2025-02-10)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
|
@@ -166,7 +166,9 @@ function useSearch(items) {
|
|
|
166
166
|
return value.toLowerCase().includes(search.toLowerCase());
|
|
167
167
|
}));
|
|
168
168
|
}
|
|
169
|
-
const searcher = new fuzzy_search_1.default(flattenItems, COMMON_FIELDS_TO_SEARCH, {
|
|
169
|
+
const searcher = new fuzzy_search_1.default(flattenItems, COMMON_FIELDS_TO_SEARCH, {
|
|
170
|
+
sort: true
|
|
171
|
+
});
|
|
170
172
|
return searcher.search(search);
|
|
171
173
|
}, [enableFuzzySearch, flattenItems]);
|
|
172
174
|
const filterFunction = (0, react_1.useCallback)(search => {
|
|
@@ -7,11 +7,14 @@ exports.filterItemsByFlattenIds = filterItemsByFlattenIds;
|
|
|
7
7
|
const isItemWithId = item => item.id !== undefined;
|
|
8
8
|
const isGroupItem = item => item.type === 'group';
|
|
9
9
|
function filterItemsByFlattenIds(items, ids) {
|
|
10
|
-
const filteredItems =
|
|
10
|
+
const filteredItems = Array(ids.length);
|
|
11
11
|
items.forEach(item => {
|
|
12
|
-
if (isItemWithId(item) && item.id
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (isItemWithId(item) && item.id) {
|
|
13
|
+
const index = ids.indexOf(item.id);
|
|
14
|
+
if (index !== -1) {
|
|
15
|
+
filteredItems[index] = item;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
if (isGroupItem(item)) {
|
|
17
20
|
const filteredSubItems = filterItemsByFlattenIds(item.items, ids);
|
|
@@ -21,5 +24,5 @@ function filterItemsByFlattenIds(items, ids) {
|
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
});
|
|
24
|
-
return filteredItems;
|
|
27
|
+
return filteredItems.filter(Boolean);
|
|
25
28
|
}
|
|
@@ -108,7 +108,7 @@ export function useSearch(items, enableFuzzySearch = true) {
|
|
|
108
108
|
return value.toLowerCase().includes(search.toLowerCase());
|
|
109
109
|
}));
|
|
110
110
|
}
|
|
111
|
-
const searcher = new FuzzySearch(flattenItems, COMMON_FIELDS_TO_SEARCH, {});
|
|
111
|
+
const searcher = new FuzzySearch(flattenItems, COMMON_FIELDS_TO_SEARCH, { sort: true });
|
|
112
112
|
return searcher.search(search);
|
|
113
113
|
}, [enableFuzzySearch, flattenItems]);
|
|
114
114
|
const filterFunction = useCallback((search) => {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const isItemWithId = (item) => item.id !== undefined;
|
|
2
2
|
const isGroupItem = (item) => item.type === 'group';
|
|
3
3
|
export function filterItemsByFlattenIds(items, ids) {
|
|
4
|
-
const filteredItems =
|
|
4
|
+
const filteredItems = Array(ids.length);
|
|
5
5
|
items.forEach(item => {
|
|
6
|
-
if (isItemWithId(item) && item.id
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (isItemWithId(item) && item.id) {
|
|
7
|
+
const index = ids.indexOf(item.id);
|
|
8
|
+
if (index !== -1) {
|
|
9
|
+
filteredItems[index] = item;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
9
12
|
}
|
|
10
13
|
if (isGroupItem(item)) {
|
|
11
14
|
const filteredSubItems = filterItemsByFlattenIds(item.items, ids);
|
|
@@ -13,5 +16,5 @@ export function filterItemsByFlattenIds(items, ids) {
|
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
18
|
});
|
|
16
|
-
return filteredItems;
|
|
19
|
+
return filteredItems.filter(Boolean);
|
|
17
20
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.40.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "39aa81a0292402ee81d037dd0a0bcd8bead1d220"
|
|
69
69
|
}
|
|
@@ -199,7 +199,7 @@ export function useSearch(items: ItemProps[], enableFuzzySearch: boolean = true)
|
|
|
199
199
|
);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const searcher = new FuzzySearch(flattenItems, COMMON_FIELDS_TO_SEARCH, {});
|
|
202
|
+
const searcher = new FuzzySearch(flattenItems, COMMON_FIELDS_TO_SEARCH, { sort: true });
|
|
203
203
|
return searcher.search(search);
|
|
204
204
|
},
|
|
205
205
|
[enableFuzzySearch, flattenItems],
|
|
@@ -7,11 +7,16 @@ const isItemWithId = (item: ItemProps): item is ItemWithId => (item as ItemWithI
|
|
|
7
7
|
const isGroupItem = (item: ItemProps): item is GroupItemProps => (item as GroupItemProps).type === 'group';
|
|
8
8
|
|
|
9
9
|
export function filterItemsByFlattenIds(items: ItemProps[], ids: ItemId[]) {
|
|
10
|
-
const filteredItems: ItemProps[] =
|
|
10
|
+
const filteredItems: ItemProps[] = Array(ids.length);
|
|
11
|
+
|
|
11
12
|
items.forEach(item => {
|
|
12
|
-
if (isItemWithId(item) && item.id
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (isItemWithId(item) && item.id) {
|
|
14
|
+
const index = ids.indexOf(item.id);
|
|
15
|
+
|
|
16
|
+
if (index !== -1) {
|
|
17
|
+
filteredItems[index] = item;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
if (isGroupItem(item)) {
|
|
17
22
|
const filteredSubItems = filterItemsByFlattenIds(item.items, ids);
|
|
@@ -19,5 +24,6 @@ export function filterItemsByFlattenIds(items: ItemProps[], ids: ItemId[]) {
|
|
|
19
24
|
return;
|
|
20
25
|
}
|
|
21
26
|
});
|
|
22
|
-
|
|
27
|
+
|
|
28
|
+
return filteredItems.filter(Boolean);
|
|
23
29
|
}
|