@blaze-cms/plugin-search-ui 0.146.0-tooltips.6 → 0.146.0-translations.11
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 +6 -12
- package/lib/components/SearchAdmin/RecentSearches/RecentSearches.js +1 -0
- package/lib/components/SearchAdmin/RecentSearches/RecentSearches.js.map +1 -1
- package/lib/components/SearchAdmin/SearchAdmin.js +4 -5
- package/lib/components/SearchAdmin/SearchAdmin.js.map +1 -1
- package/lib/components/SearchAdmin/SearchAdminSideBar/SearchAdminSideBar.js +1 -2
- package/lib/components/SearchAdmin/SearchAdminSideBar/SearchAdminSideBar.js.map +1 -1
- package/lib/components/SearchAdmin/SearchResults/SearchResults.js +9 -10
- package/lib/components/SearchAdmin/SearchResults/SearchResults.js.map +1 -1
- package/lib/components/SearchPublishedContent/SearchPublishedContent.js +1 -2
- package/lib/components/SearchPublishedContent/SearchPublishedContent.js.map +1 -1
- package/lib/components/useLocalStorage/useLocalStorage.js +1 -0
- package/lib/components/useLocalStorage/useLocalStorage.js.map +1 -1
- package/lib/components/useSearch/useSearch.js +9 -6
- package/lib/components/useSearch/useSearch.js.map +1 -1
- package/lib/components/useSearchResults/useSearchResults.js +4 -2
- package/lib/components/useSearchResults/useSearchResults.js.map +1 -1
- package/lib/constants.js +3 -2
- package/lib/constants.js.map +1 -1
- package/lib/hooks/useDebounceSearch.js +4 -2
- package/lib/hooks/useDebounceSearch.js.map +1 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/SearchAdmin/SearchResults/SearchResults.js +2 -2
- 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 +8 -5
- package/lib-es/components/useSearch/useSearch.js.map +1 -1
- package/lib-es/components/useSearchResults/useSearchResults.js +4 -2
- package/lib-es/components/useSearchResults/useSearchResults.js.map +1 -1
- package/lib-es/constants.js +3 -2
- package/lib-es/constants.js.map +1 -1
- package/lib-es/hooks/useDebounceSearch.js +4 -2
- package/lib-es/hooks/useDebounceSearch.js.map +1 -1
- package/package.json +7 -8
- package/src/components/SearchAdmin/SearchResults/SearchResults.js +7 -2
- package/src/components/useSearch/useSearch.js +8 -5
- package/src/components/useSearchResults/useSearchResults.js +2 -2
- package/src/constants.js +4 -2
- package/src/hooks/useDebounceSearch.js +3 -2
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import { useLazyQuery } from '@apollo/client';
|
|
3
3
|
import searchQueries from '../../application/query';
|
|
4
4
|
|
|
5
|
-
function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters }) {
|
|
5
|
+
function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters, queryHook }) {
|
|
6
6
|
const [queryParams, setParams] = useState({ limit: 20, offset: 0, value: '' });
|
|
7
7
|
const [searchedValue, setSearchedValue] = useState(null);
|
|
8
8
|
const [previousEntities, setPreviousEntities] = useState([]);
|
|
@@ -43,8 +43,8 @@ function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters }
|
|
|
43
43
|
}))
|
|
44
44
|
: [];
|
|
45
45
|
|
|
46
|
-
if (isNewValueSet || isNewOffsetSet || notSameLength) {
|
|
47
|
-
|
|
46
|
+
if (value && (isNewValueSet || isNewOffsetSet || notSameLength)) {
|
|
47
|
+
const variables = {
|
|
48
48
|
variables: {
|
|
49
49
|
limit,
|
|
50
50
|
offset,
|
|
@@ -71,7 +71,9 @@ function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters }
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
|
+
const updatedVariables = queryHook ? queryHook(variables) : variables;
|
|
76
|
+
getSearchResults(updatedVariables);
|
|
75
77
|
setSearchedValue(value);
|
|
76
78
|
setPreviousOffset(offset);
|
|
77
79
|
setPreviousEntities(entities);
|
|
@@ -89,7 +91,8 @@ function useSearch({ queryKey, resultKeys, entities = [], fields, extraFilters }
|
|
|
89
91
|
fields,
|
|
90
92
|
entities.length,
|
|
91
93
|
previousEntities.length,
|
|
92
|
-
extraFilters
|
|
94
|
+
extraFilters,
|
|
95
|
+
queryHook
|
|
93
96
|
]
|
|
94
97
|
);
|
|
95
98
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import useSearch from '../useSearch';
|
|
3
3
|
|
|
4
|
-
function useSearchResults({ queryKey, resultKeys, entities, fields }) {
|
|
4
|
+
function useSearchResults({ queryKey, resultKeys, entities, fields, queryHook }) {
|
|
5
5
|
const [currentResults, setCurrentResults] = useState([]);
|
|
6
6
|
const [allResults, setAllResults] = useState([]);
|
|
7
7
|
const [
|
|
@@ -11,7 +11,7 @@ function useSearchResults({ queryKey, resultKeys, entities, fields }) {
|
|
|
11
11
|
data: { results, total }
|
|
12
12
|
},
|
|
13
13
|
setParams
|
|
14
|
-
] = useSearch({ queryKey, resultKeys, entities, fields });
|
|
14
|
+
] = useSearch({ queryKey, resultKeys, entities, fields, queryHook });
|
|
15
15
|
|
|
16
16
|
useEffect(
|
|
17
17
|
() => {
|
package/src/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const SEARCH_ADMIN = 'SEARCH_ADMIN';
|
|
2
2
|
const SEARCH_PUBLISHED = 'SEARCH_PUBLISHED';
|
|
3
3
|
const SEARCH_RESULTS_OVER_SCAN_BUFFER = 0;
|
|
4
|
-
const
|
|
4
|
+
const SEARCH_RESULTS_ELEMENTS_HEIGHT_ABOVE_LIST = 186;
|
|
5
|
+
const SEARCH_RESULTS_HEIGHT_OFFSET = 100;
|
|
5
6
|
const SEARCH_RESULTS_ITEM_SIZE = 105;
|
|
6
7
|
const DEFAULT_RESULTS_KEYS = 'name, url';
|
|
7
8
|
const SEARCH_BUTTON = 'search-button';
|
|
@@ -11,7 +12,8 @@ export {
|
|
|
11
12
|
SEARCH_ADMIN,
|
|
12
13
|
SEARCH_PUBLISHED,
|
|
13
14
|
SEARCH_RESULTS_OVER_SCAN_BUFFER,
|
|
14
|
-
|
|
15
|
+
SEARCH_RESULTS_ELEMENTS_HEIGHT_ABOVE_LIST,
|
|
16
|
+
SEARCH_RESULTS_HEIGHT_OFFSET,
|
|
15
17
|
SEARCH_RESULTS_ITEM_SIZE,
|
|
16
18
|
DEFAULT_RESULTS_KEYS,
|
|
17
19
|
SEARCH_BUTTON,
|
|
@@ -3,7 +3,7 @@ import { useDebounce } from '@blaze-react/utils/lib/customHooks';
|
|
|
3
3
|
import useSearchResults from '../components/useSearchResults';
|
|
4
4
|
import { SEARCH_PUBLISHED } from '../constants';
|
|
5
5
|
|
|
6
|
-
const useDebounceSearch = ({ entities, resultKeys, fields, initialSearchTerm }) => {
|
|
6
|
+
const useDebounceSearch = ({ entities, resultKeys, fields, initialSearchTerm, queryHook }) => {
|
|
7
7
|
const [searchTerm, setSearchTerm] = useState(initialSearchTerm ?? '');
|
|
8
8
|
const [previousSearchTerm, setPreviousSearchTerm] = useState(null);
|
|
9
9
|
const debouncedSearchTerm = useDebounce(searchTerm, 500);
|
|
@@ -12,7 +12,8 @@ const useDebounceSearch = ({ entities, resultKeys, fields, initialSearchTerm })
|
|
|
12
12
|
queryKey: SEARCH_PUBLISHED,
|
|
13
13
|
resultKeys,
|
|
14
14
|
entities,
|
|
15
|
-
fields
|
|
15
|
+
fields,
|
|
16
|
+
queryHook
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
useEffect(
|