@blaze-cms/plugin-search-ui 0.146.0-translations.8 → 0.147.0-rc-eagle.2
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/lib/application/query/index.js +31 -15
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/SearchAdmin/RecentSearches/RecentSearches.js +33 -42
- package/lib/components/SearchAdmin/RecentSearches/RecentSearches.js.map +1 -1
- package/lib/components/SearchAdmin/RecentSearches/index.js +2 -3
- package/lib/components/SearchAdmin/RecentSearches/index.js.map +1 -1
- package/lib/components/SearchAdmin/SearchAdmin.js +63 -105
- package/lib/components/SearchAdmin/SearchAdmin.js.map +1 -1
- package/lib/components/SearchAdmin/SearchAdminSideBar/SearchAdminSideBar.js +50 -78
- package/lib/components/SearchAdmin/SearchAdminSideBar/SearchAdminSideBar.js.map +1 -1
- package/lib/components/SearchAdmin/SearchAdminSideBar/index.js +2 -3
- package/lib/components/SearchAdmin/SearchAdminSideBar/index.js.map +1 -1
- package/lib/components/SearchAdmin/SearchBar/SearchBar.js +41 -45
- package/lib/components/SearchAdmin/SearchBar/SearchBar.js.map +1 -1
- package/lib/components/SearchAdmin/SearchBar/index.js +2 -3
- package/lib/components/SearchAdmin/SearchBar/index.js.map +1 -1
- package/lib/components/SearchAdmin/SearchResults/SearchResults.js +99 -148
- package/lib/components/SearchAdmin/SearchResults/SearchResults.js.map +1 -1
- package/lib/components/SearchAdmin/SearchResults/index.js +2 -3
- package/lib/components/SearchAdmin/SearchResults/index.js.map +1 -1
- package/lib/components/SearchAdmin/TriggerModal/TriggerModal.js +10 -12
- package/lib/components/SearchAdmin/TriggerModal/TriggerModal.js.map +1 -1
- package/lib/components/SearchAdmin/TriggerModal/index.js +2 -3
- package/lib/components/SearchAdmin/TriggerModal/index.js.map +1 -1
- package/lib/components/SearchAdmin/index.js +2 -3
- package/lib/components/SearchAdmin/index.js.map +1 -1
- package/lib/components/SearchPublishedContent/SearchPublishedContent.js +74 -100
- package/lib/components/SearchPublishedContent/SearchPublishedContent.js.map +1 -1
- package/lib/components/SearchPublishedContent/index.js +2 -3
- package/lib/components/SearchPublishedContent/index.js.map +1 -1
- package/lib/components/useLocalStorage/index.js +2 -3
- package/lib/components/useLocalStorage/index.js.map +1 -1
- package/lib/components/useLocalStorage/useLocalStorage.js +8 -15
- package/lib/components/useLocalStorage/useLocalStorage.js.map +1 -1
- package/lib/components/useSearch/index.js +2 -3
- package/lib/components/useSearch/index.js.map +1 -1
- package/lib/components/useSearch/useSearch.js +60 -87
- package/lib/components/useSearch/useSearch.js.map +1 -1
- package/lib/components/useSearchResults/index.js +2 -3
- package/lib/components/useSearchResults/index.js.map +1 -1
- package/lib/components/useSearchResults/useSearchResults.js +34 -53
- package/lib/components/useSearchResults/useSearchResults.js.map +1 -1
- package/lib/constants.js +9 -10
- package/lib/constants.js.map +1 -1
- package/lib/hooks/index.js +2 -3
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDebounceSearch.js +31 -40
- package/lib/hooks/useDebounceSearch.js.map +1 -1
- package/lib/index.js +8 -9
- package/lib/index.js.map +1 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/SearchAdmin/SearchAdmin.js.map +1 -1
- package/lib-es/components/SearchAdmin/SearchResults/SearchResults.js.map +1 -1
- package/lib-es/components/SearchPublishedContent/SearchPublishedContent.js.map +1 -1
- package/lib-es/components/useSearch/useSearch.js.map +1 -1
- package/lib-es/components/useSearchResults/useSearchResults.js.map +1 -1
- package/lib-es/hooks/useDebounceSearch.js.map +1 -1
- package/package.json +21 -16
- package/src/components/SearchAdmin/SearchAdmin.js +5 -8
- package/src/components/SearchAdmin/SearchResults/SearchResults.js +26 -37
- package/src/components/SearchPublishedContent/SearchPublishedContent.js +6 -9
- package/src/components/useSearch/useSearch.js +56 -59
- package/src/components/useSearchResults/useSearchResults.js +6 -9
- package/src/hooks/useDebounceSearch.js +6 -9
- package/CHANGELOG.md +0 -912
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -31,70 +31,67 @@ function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters,
|
|
|
31
31
|
setParams({ ...queryParams, ...newQueryParams });
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
useEffect(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
: [];
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const { limit, offset, value } = queryParams;
|
|
36
|
+
const isNewValueSet = value && value !== searchedValue;
|
|
37
|
+
const isNewOffsetSet = previousOffset !== null && offset !== previousOffset;
|
|
38
|
+
const notSameLength = previousEntities.length !== entities.length;
|
|
39
|
+
const parsedEntities = entities.length
|
|
40
|
+
? entities.map(entity => ({
|
|
41
|
+
match: { docType: entity }
|
|
42
|
+
}))
|
|
43
|
+
: [];
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
bool: {
|
|
66
|
-
should: parsedEntities
|
|
67
|
-
}
|
|
45
|
+
if (value && (isNewValueSet || isNewOffsetSet || notSameLength)) {
|
|
46
|
+
const variables = {
|
|
47
|
+
variables: {
|
|
48
|
+
limit,
|
|
49
|
+
offset,
|
|
50
|
+
rawQuery: {
|
|
51
|
+
query: {
|
|
52
|
+
bool: {
|
|
53
|
+
must: [
|
|
54
|
+
{
|
|
55
|
+
query_string: {
|
|
56
|
+
query: value,
|
|
57
|
+
fields,
|
|
58
|
+
type: 'most_fields',
|
|
59
|
+
default_operator: 'AND',
|
|
60
|
+
extraFilters
|
|
68
61
|
}
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
bool: {
|
|
65
|
+
should: parsedEntities
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const updatedVariables = queryHook ? queryHook(variables) : variables;
|
|
75
|
+
getSearchResults(updatedVariables);
|
|
76
|
+
setSearchedValue(value);
|
|
77
|
+
setPreviousOffset(offset);
|
|
78
|
+
setPreviousEntities(entities);
|
|
79
|
+
}
|
|
80
|
+
}, [
|
|
81
|
+
queryParams,
|
|
82
|
+
queryParams.limit,
|
|
83
|
+
queryParams.value,
|
|
84
|
+
queryParams.offset,
|
|
85
|
+
searchedValue,
|
|
86
|
+
previousOffset,
|
|
87
|
+
getSearchResults,
|
|
88
|
+
entities,
|
|
89
|
+
fields,
|
|
90
|
+
entities.length,
|
|
91
|
+
previousEntities.length,
|
|
92
|
+
extraFilters,
|
|
93
|
+
queryHook
|
|
94
|
+
]);
|
|
98
95
|
|
|
99
96
|
return [
|
|
100
97
|
{ searchedValue: queryParams.value, loading, data: { results: results || jsonResults, total } },
|
|
@@ -13,15 +13,12 @@ function useSearchResults({ queryKey, resultKeys, entities, fields, queryHook })
|
|
|
13
13
|
setParams
|
|
14
14
|
] = useSearch({ queryKey, resultKeys, entities, fields, queryHook });
|
|
15
15
|
|
|
16
|
-
useEffect(
|
|
17
|
-
()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
[allResults, currentResults, results]
|
|
24
|
-
);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (currentResults.length !== results.length) {
|
|
18
|
+
setAllResults([...allResults, ...results]);
|
|
19
|
+
setCurrentResults(results);
|
|
20
|
+
}
|
|
21
|
+
}, [allResults, currentResults, results]);
|
|
25
22
|
|
|
26
23
|
const clearList = params => {
|
|
27
24
|
setAllResults([]);
|
|
@@ -16,15 +16,12 @@ const useDebounceSearch = ({ entities, resultKeys, fields, initialSearchTerm, qu
|
|
|
16
16
|
queryHook
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
useEffect(
|
|
20
|
-
()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
[debouncedSearchTerm, previousSearchTerm, setQueryParams]
|
|
27
|
-
);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (debouncedSearchTerm && debouncedSearchTerm !== previousSearchTerm) {
|
|
21
|
+
setQueryParams({ value: debouncedSearchTerm });
|
|
22
|
+
setPreviousSearchTerm(debouncedSearchTerm);
|
|
23
|
+
}
|
|
24
|
+
}, [debouncedSearchTerm, previousSearchTerm, setQueryParams]);
|
|
28
25
|
|
|
29
26
|
return {
|
|
30
27
|
loading,
|