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