@empathyco/x-components 3.0.0-alpha.140 → 3.0.0-alpha.141

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 (50) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/design-system/default-theme.css +49 -49
  3. package/design-system/full-theme.css +15 -14
  4. package/docs/API-reference/api/x-components.fetchandsavenextquerypreviewwire.md +13 -0
  5. package/docs/API-reference/api/x-components.md +2 -0
  6. package/docs/API-reference/api/x-components.nextqueriesactions.fetchandsavenextquerypreview.md +24 -0
  7. package/docs/API-reference/api/x-components.nextqueriesactions.fetchnextquerypreview.md +26 -0
  8. package/docs/API-reference/api/x-components.nextqueriesactions.md +2 -0
  9. package/docs/API-reference/api/x-components.nextqueriesconfig.maxpreviewitemstorequest.md +13 -0
  10. package/docs/API-reference/api/x-components.nextqueriesconfig.md +1 -0
  11. package/docs/API-reference/api/x-components.nextqueriesmutations.md +2 -0
  12. package/docs/API-reference/api/x-components.nextqueriesmutations.resetresultspreview.md +17 -0
  13. package/docs/API-reference/api/x-components.nextqueriesmutations.setresultspreview.md +24 -0
  14. package/docs/API-reference/api/x-components.nextqueriesstate.md +1 -0
  15. package/docs/API-reference/api/x-components.nextqueriesstate.resultspreview.md +13 -0
  16. package/docs/API-reference/api/x-components.nextqueriesxevents.md +1 -0
  17. package/docs/API-reference/api/x-components.nextqueriesxevents.nextquerypreviewmounted.md +13 -0
  18. package/docs/API-reference/api/x-components.resetresultspreviewwire.md +13 -0
  19. package/docs/API-reference/api/x-types.md +1 -0
  20. package/docs/API-reference/api/x-types.previewresults.items.md +13 -0
  21. package/docs/API-reference/api/x-types.previewresults.md +22 -0
  22. package/docs/API-reference/api/x-types.previewresults.query.md +13 -0
  23. package/docs/API-reference/api/x-types.previewresults.totalresults.md +13 -0
  24. package/js/index.js +1 -1
  25. package/js/x-modules/next-queries/store/actions/fetch-and-save-next-query-preview.action.js +22 -0
  26. package/js/x-modules/next-queries/store/actions/fetch-and-save-next-query-preview.action.js.map +1 -0
  27. package/js/x-modules/next-queries/store/actions/fetch-next-query-preview.action.js +26 -0
  28. package/js/x-modules/next-queries/store/actions/fetch-next-query-preview.action.js.map +1 -0
  29. package/js/x-modules/next-queries/store/module.js +15 -3
  30. package/js/x-modules/next-queries/store/module.js.map +1 -1
  31. package/js/x-modules/next-queries/wiring.js +24 -2
  32. package/js/x-modules/next-queries/wiring.js.map +1 -1
  33. package/next-queries/index.js +1 -1
  34. package/package.json +4 -4
  35. package/report/x-components.api.json +327 -0
  36. package/report/x-components.api.md +21 -1
  37. package/report/x-types.api.json +99 -0
  38. package/types/x-modules/next-queries/config.types.d.ts +4 -0
  39. package/types/x-modules/next-queries/config.types.d.ts.map +1 -1
  40. package/types/x-modules/next-queries/events.types.d.ts +5 -0
  41. package/types/x-modules/next-queries/events.types.d.ts.map +1 -1
  42. package/types/x-modules/next-queries/store/actions/fetch-and-save-next-query-preview.action.d.ts +3 -0
  43. package/types/x-modules/next-queries/store/actions/fetch-and-save-next-query-preview.action.d.ts.map +1 -0
  44. package/types/x-modules/next-queries/store/actions/fetch-next-query-preview.action.d.ts +12 -0
  45. package/types/x-modules/next-queries/store/actions/fetch-next-query-preview.action.d.ts.map +1 -0
  46. package/types/x-modules/next-queries/store/module.d.ts.map +1 -1
  47. package/types/x-modules/next-queries/store/types.d.ts +28 -1
  48. package/types/x-modules/next-queries/store/types.d.ts.map +1 -1
  49. package/types/x-modules/next-queries/wiring.d.ts +18 -0
  50. package/types/x-modules/next-queries/wiring.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.0-alpha.141](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.140...@empathyco/x-components@3.0.0-alpha.141) (2022-07-28)
7
+
8
+ ### Features
9
+
10
+ - **next-queries:** add next query preview logic (#611)
11
+ ([fc611fa](https://github.com/empathyco/x/commit/fc611faa39e63e5f916cd19928e9ab0755f8dc7f)),
12
+ closes [EX-6119](https://searchbroker.atlassian.net/browse/EX-6119)
13
+
14
+ # Change Log
15
+
16
+ All notable changes to this project will be documented in this file. See
17
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
18
+
6
19
  ## [3.0.0-alpha.140](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.139...@empathyco/x-components@3.0.0-alpha.140) (2022-07-26)
7
20
 
8
21
  **Note:** Version bump only for package @empathyco/x-components
@@ -8,6 +8,55 @@
8
8
  --x-number-font-weight-badge-default: var(--x-number-font-weight-base-regular);
9
9
  --x-size-font-badge-default: var(--x-size-font-base-xs);
10
10
  }
11
+
12
+ [dir="ltr"] .x-badge {
13
+ right: calc(var(--x-size-width-badge-default) / 4);
14
+ }
15
+
16
+ [dir="rtl"] .x-badge {
17
+ left: calc(var(--x-size-width-badge-default) / 4);
18
+ }
19
+
20
+ .x-badge {
21
+ border-radius: var(--x-size-border-radius-badge-default);
22
+ border-style: solid;
23
+ border-width: var(--x-size-border-width-badge-default);
24
+ font-size: var(--x-size-font-badge-default);
25
+ font-weight: var(--x-number-font-weight-badge-default);
26
+ box-sizing: border-box;
27
+ position: absolute;
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ transform: translate(50%, -50%);
32
+ z-index: 1;
33
+ /* We dont' want to have the button fully centered in the top right corner, the top right corner
34
+ of the text is the one that should be aligned with the top right corner of the container. */
35
+ top: calc(var(--x-size-width-badge-default) / 4);
36
+ min-width: var(--x-size-width-badge-default);
37
+ height: var(--x-size-width-badge-default);
38
+ padding: 2px;
39
+ background: var(--x-color-background-badge-default);
40
+ color: var(--x-color-text-badge-default);
41
+ border-color: var(--x-color-border-badge-default);
42
+ }
43
+ [dir="rtl"] .x-badge {
44
+ transform: translate(-50%, -50%);
45
+ }
46
+
47
+ .x-badge-container {
48
+ position: relative;
49
+ }
50
+ :root {
51
+ --x-color-background-badge-default: var(--x-color-base-neutral-10);
52
+ --x-color-text-badge-default: var(--x-color-base-neutral-100);
53
+ --x-color-border-badge-default: var(--x-color-base-neutral-10);
54
+ --x-size-border-radius-badge-default: var(--x-size-border-radius-base-pill);
55
+ --x-size-border-width-badge-default: 0;
56
+ --x-size-width-badge-default: 1.5em;
57
+ --x-number-font-weight-badge-default: var(--x-number-font-weight-base-regular);
58
+ --x-size-font-badge-default: var(--x-size-font-base-xs);
59
+ }
11
60
  :root {
12
61
  --x-color-background-button-default: var(--x-color-base-lead);
13
62
  --x-color-border-button-default: var(--x-color-background-button-default);
@@ -2857,53 +2906,4 @@
2857
2906
  --x-size-line-height-base-s: 16px;
2858
2907
  --x-size-line-height-base-m: 24px;
2859
2908
  --x-size-line-height-base-l: 32px;
2860
- }
2861
- :root {
2862
- --x-color-background-badge-default: var(--x-color-base-neutral-10);
2863
- --x-color-text-badge-default: var(--x-color-base-neutral-100);
2864
- --x-color-border-badge-default: var(--x-color-base-neutral-10);
2865
- --x-size-border-radius-badge-default: var(--x-size-border-radius-base-pill);
2866
- --x-size-border-width-badge-default: 0;
2867
- --x-size-width-badge-default: 1.5em;
2868
- --x-number-font-weight-badge-default: var(--x-number-font-weight-base-regular);
2869
- --x-size-font-badge-default: var(--x-size-font-base-xs);
2870
- }
2871
-
2872
- [dir="ltr"] .x-badge {
2873
- right: calc(var(--x-size-width-badge-default) / 4);
2874
- }
2875
-
2876
- [dir="rtl"] .x-badge {
2877
- left: calc(var(--x-size-width-badge-default) / 4);
2878
- }
2879
-
2880
- .x-badge {
2881
- border-radius: var(--x-size-border-radius-badge-default);
2882
- border-style: solid;
2883
- border-width: var(--x-size-border-width-badge-default);
2884
- font-size: var(--x-size-font-badge-default);
2885
- font-weight: var(--x-number-font-weight-badge-default);
2886
- box-sizing: border-box;
2887
- position: absolute;
2888
- display: flex;
2889
- align-items: center;
2890
- justify-content: center;
2891
- transform: translate(50%, -50%);
2892
- z-index: 1;
2893
- /* We dont' want to have the button fully centered in the top right corner, the top right corner
2894
- of the text is the one that should be aligned with the top right corner of the container. */
2895
- top: calc(var(--x-size-width-badge-default) / 4);
2896
- min-width: var(--x-size-width-badge-default);
2897
- height: var(--x-size-width-badge-default);
2898
- padding: 2px;
2899
- background: var(--x-color-background-badge-default);
2900
- color: var(--x-color-text-badge-default);
2901
- border-color: var(--x-color-border-badge-default);
2902
- }
2903
- [dir="rtl"] .x-badge {
2904
- transform: translate(-50%, -50%);
2905
- }
2906
-
2907
- .x-badge-container {
2908
- position: relative;
2909
2909
  }
@@ -898,20 +898,6 @@
898
898
  --x-size-border-width-bottom-facet-header-line: var(--x-size-border-width-facet-header-line);
899
899
  --x-size-border-width-left-facet-header-line: 0;
900
900
  }
901
- .x-facet--outlined.x-facet,
902
- .x-facet--outlined .x-facet {
903
- --x-color-border-facet-default: var(--x-color-border-facet-outlined);
904
- --x-size-border-width-facet-default: var(--x-size-border-width-facet-outlined);
905
- --x-size-border-width-top-facet-default: var(--x-size-border-width-top-facet-outlined);
906
- --x-size-border-width-right-facet-default: var(--x-size-border-width-right-facet-outlined);
907
- --x-size-border-width-bottom-facet-default: var(--x-size-border-width-bottom-facet-outlined);
908
- --x-size-border-width-left-facet-default: var(--x-size-border-width-left-facet-outlined);
909
- --x-size-padding-facet-header-default: var(--x-size-padding-facet-header-outlined);
910
- --x-size-padding-top-facet-header-default: var(--x-size-padding-top-facet-header-outlined);
911
- --x-size-padding-right-facet-header-default: var(--x-size-padding-right-facet-header-outlined);
912
- --x-size-padding-bottom-facet-header-default: var(--x-size-padding-bottom-facet-header-outlined);
913
- --x-size-padding-left-facet-header-default: var(--x-size-padding-left-facet-header-outlined);
914
- }
915
901
  :root {
916
902
  --x-color-border-facet-outlined: var(--x-color-base-neutral-70);
917
903
  --x-size-border-width-facet-outlined: var(--x-size-border-width-base);
@@ -7613,3 +7599,18 @@
7613
7599
  .x-normal-case {
7614
7600
  text-transform: none;
7615
7601
  }
7602
+
7603
+ .x-facet--outlined.x-facet,
7604
+ .x-facet--outlined .x-facet {
7605
+ --x-color-border-facet-default: var(--x-color-border-facet-outlined);
7606
+ --x-size-border-width-facet-default: var(--x-size-border-width-facet-outlined);
7607
+ --x-size-border-width-top-facet-default: var(--x-size-border-width-top-facet-outlined);
7608
+ --x-size-border-width-right-facet-default: var(--x-size-border-width-right-facet-outlined);
7609
+ --x-size-border-width-bottom-facet-default: var(--x-size-border-width-bottom-facet-outlined);
7610
+ --x-size-border-width-left-facet-default: var(--x-size-border-width-left-facet-outlined);
7611
+ --x-size-padding-facet-header-default: var(--x-size-padding-facet-header-outlined);
7612
+ --x-size-padding-top-facet-header-default: var(--x-size-padding-top-facet-header-outlined);
7613
+ --x-size-padding-right-facet-header-default: var(--x-size-padding-right-facet-header-outlined);
7614
+ --x-size-padding-bottom-facet-header-default: var(--x-size-padding-bottom-facet-header-outlined);
7615
+ --x-size-padding-left-facet-header-default: var(--x-size-padding-left-facet-header-outlined);
7616
+ }
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [fetchAndSaveNextQueryPreviewWire](./x-components.fetchandsavenextquerypreviewwire.md)
4
+
5
+ ## fetchAndSaveNextQueryPreviewWire variable
6
+
7
+ Requests and store the next query preview results.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ fetchAndSaveNextQueryPreviewWire: import("../..").Wire<string>
13
+ ```
@@ -414,6 +414,7 @@ X-Components is a library usable everywhere not only for search experiences.
414
414
  | [fetchAndSaveIdentifierResultsWire](./x-components.fetchandsaveidentifierresultswire.md) | Requests and stores a new set of identifier results for the [IdentifierResultsState.query](./x-components.identifierresultsstate.query.md)<!-- -->. |
415
415
  | [fetchAndSaveNextQueries](./x-components.fetchandsavenextqueries.md) | Default implementation for [NextQueriesActions.fetchAndSaveNextQueries()](./x-components.nextqueriesactions.fetchandsavenextqueries.md) action. |
416
416
  | [fetchAndSaveNextQueriesWire](./x-components.fetchandsavenextquerieswire.md) | Requests and stores the next queries. |
417
+ | [fetchAndSaveNextQueryPreviewWire](./x-components.fetchandsavenextquerypreviewwire.md) | Requests and store the next query preview results. |
417
418
  | [fetchAndSavePopularSearches](./x-components.fetchandsavepopularsearches.md) | Default implementation for [PopularSearchesActions.fetchAndSaveSuggestions()](./x-components.popularsearchesactions.fetchandsavesuggestions.md) action. |
418
419
  | [fetchAndSaveQuerySuggestions](./x-components.fetchandsavequerysuggestions.md) | Default implementation for [QuerySuggestionsActions.fetchAndSaveSuggestions()](./x-components.querysuggestionsactions.fetchandsavesuggestions.md) action. |
419
420
  | [fetchAndSaveRecommendations](./x-components.fetchandsaverecommendations.md) | Default implementation for [RecommendationsActions.fetchAndSaveRecommendations()](./x-components.recommendationsactions.fetchandsaverecommendations.md) action. |
@@ -483,6 +484,7 @@ X-Components is a library usable everywhere not only for search experiences.
483
484
  | [removeFromHistory](./x-components.removefromhistory.md) | Default implementation for the [HistoryQueriesActions.removeFromHistory()](./x-components.historyqueriesactions.removefromhistory.md)<!-- -->. |
484
485
  | [removeHistoryQuery](./x-components.removehistoryquery.md) | Removes a single history query from the history queries. |
485
486
  | [resetAppending](./x-components.resetappending.md) | Resets the search state <code>isAppendingResults</code>. |
487
+ | [resetResultsPreviewWire](./x-components.resetresultspreviewwire.md) | Resets the next query preview results. |
486
488
  | [resetSpellcheckQuery](./x-components.resetspellcheckquery.md) | Resets the search state <code>spellcheckedQuery</code> to its initial value, an empty string. |
487
489
  | [resetState](./x-components.resetstate.md) | Default implementation for the [SearchActions.resetState()](./x-components.searchactions.resetstate.md)<!-- -->. |
488
490
  | [resetStateWire](./x-components.resetstatewire.md) | Batches state resets after [SearchGetters.request](./x-components.searchgetters.request.md) parameters update. |
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesActions](./x-components.nextqueriesactions.md) &gt; [fetchAndSaveNextQueryPreview](./x-components.nextqueriesactions.fetchandsavenextquerypreview.md)
4
+
5
+ ## NextQueriesActions.fetchAndSaveNextQueryPreview() method
6
+
7
+ Requests the results to preview a next query and saves them in the state.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ fetchAndSaveNextQueryPreview(query: string): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | query | string | The next query to retrieve the results. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ void
24
+
@@ -0,0 +1,26 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesActions](./x-components.nextqueriesactions.md) &gt; [fetchNextQueryPreview](./x-components.nextqueriesactions.fetchnextquerypreview.md)
4
+
5
+ ## NextQueriesActions.fetchNextQueryPreview() method
6
+
7
+ Requests the results to preview a next query, limited by [NextQueriesConfig.maxPreviewItemsToRequest](./x-components.nextqueriesconfig.maxpreviewitemstorequest.md)<!-- -->.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ fetchNextQueryPreview(query: string): SearchResponse | null;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | query | string | The next query to retrieve the results. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ SearchResponse \| null
24
+
25
+ A search response based on the next query.
26
+
@@ -18,7 +18,9 @@ export interface NextQueriesActions
18
18
  | --- | --- |
19
19
  | [cancelFetchAndSaveNextQueries()](./x-components.nextqueriesactions.cancelfetchandsavenextqueries.md) | Cancels / interrupt [NextQueriesActions.fetchAndSaveNextQueries()](./x-components.nextqueriesactions.fetchandsavenextqueries.md) synchronous promise. |
20
20
  | [fetchAndSaveNextQueries(request)](./x-components.nextqueriesactions.fetchandsavenextqueries.md) | Requests a new set of next queries and stores them in the module. |
21
+ | [fetchAndSaveNextQueryPreview(query)](./x-components.nextqueriesactions.fetchandsavenextquerypreview.md) | Requests the results to preview a next query and saves them in the state. |
21
22
  | [fetchNextQueries(request)](./x-components.nextqueriesactions.fetchnextqueries.md) | Requests a new set of next queries for the module query, and returns them. |
23
+ | [fetchNextQueryPreview(query)](./x-components.nextqueriesactions.fetchnextquerypreview.md) | Requests the results to preview a next query, limited by [NextQueriesConfig.maxPreviewItemsToRequest](./x-components.nextqueriesconfig.maxpreviewitemstorequest.md)<!-- -->. |
22
24
  | [setQueryFromLastHistoryQuery(historyQueries)](./x-components.nextqueriesactions.setqueryfromlasthistoryquery.md) | Sets the query of the module based on the last history query. |
23
25
  | [setUrlParams(urlParams)](./x-components.nextqueriesactions.seturlparams.md) | Checks if the url has a query on it and then updates the state with that value. |
24
26
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesConfig](./x-components.nextqueriesconfig.md) &gt; [maxPreviewItemsToRequest](./x-components.nextqueriesconfig.maxpreviewitemstorequest.md)
4
+
5
+ ## NextQueriesConfig.maxPreviewItemsToRequest property
6
+
7
+ Number of results that will be requested to preview the next queries.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ maxPreviewItemsToRequest: number;
13
+ ```
@@ -19,4 +19,5 @@ export interface NextQueriesConfig
19
19
  | [hideSessionQueries](./x-components.nextqueriesconfig.hidesessionqueries.md) | boolean | Hides the next queries if it has been already searched during the session. |
20
20
  | [loadOnInit](./x-components.nextqueriesconfig.loadoninit.md) | boolean | Loads the next queries with the last searched query. |
21
21
  | [maxItemsToRequest](./x-components.nextqueriesconfig.maxitemstorequest.md) | number | Number of next queries that will be requested. |
22
+ | [maxPreviewItemsToRequest](./x-components.nextqueriesconfig.maxpreviewitemstorequest.md) | number | Number of results that will be requested to preview the next queries. |
22
23
 
@@ -17,8 +17,10 @@ export interface NextQueriesMutations extends StatusMutations, QueryMutations
17
17
 
18
18
  | Method | Description |
19
19
  | --- | --- |
20
+ | [resetResultsPreview()](./x-components.nextqueriesmutations.resetresultspreview.md) | Resets the result's dictionary. |
20
21
  | [setNextQueries(nextQueries)](./x-components.nextqueriesmutations.setnextqueries.md) | Sets the next queries of the module. |
21
22
  | [setParams(params)](./x-components.nextqueriesmutations.setparams.md) | Sets the extra params of the module. |
22
23
  | [setQuery(newQuery)](./x-components.nextqueriesmutations.setquery.md) | Sets the query of the module, which is used to retrieve the next-queries. |
24
+ | [setResultsPreview(resultsPreview)](./x-components.nextqueriesmutations.setresultspreview.md) | Adds a new entry to the result's dictionary. |
23
25
  | [setSearchedQueries(searchedQueries)](./x-components.nextqueriesmutations.setsearchedqueries.md) | Sets the searched queries of the module. |
24
26
 
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesMutations](./x-components.nextqueriesmutations.md) &gt; [resetResultsPreview](./x-components.nextqueriesmutations.resetresultspreview.md)
4
+
5
+ ## NextQueriesMutations.resetResultsPreview() method
6
+
7
+ Resets the result's dictionary.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ resetResultsPreview(): void;
13
+ ```
14
+ <b>Returns:</b>
15
+
16
+ void
17
+
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesMutations](./x-components.nextqueriesmutations.md) &gt; [setResultsPreview](./x-components.nextqueriesmutations.setresultspreview.md)
4
+
5
+ ## NextQueriesMutations.setResultsPreview() method
6
+
7
+ Adds a new entry to the result's dictionary.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ setResultsPreview(resultsPreview: Dictionary<PreviewResults>): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | resultsPreview | Dictionary&lt;PreviewResults&gt; | Object containing the next query, the totalResults and the results to add. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ void
24
+
@@ -21,5 +21,6 @@ export interface NextQueriesState extends StatusState, QueryState
21
21
  | [nextQueries](./x-components.nextqueriesstate.nextqueries.md) | NextQuery\[\] | The list of the next queries, related to the <code>query</code> property of the state. |
22
22
  | [params](./x-components.nextqueriesstate.params.md) | Dictionary&lt;unknown&gt; | The extra params property of the state. |
23
23
  | [query](./x-components.nextqueriesstate.query.md) | string | The internal query of the module. Used to request the next queries. |
24
+ | [resultsPreview](./x-components.nextqueriesstate.resultspreview.md) | Dictionary&lt;PreviewResults&gt; | Results of the next queries requests. |
24
25
  | [searchedQueries](./x-components.nextqueriesstate.searchedqueries.md) | HistoryQuery\[\] | The list of the searched queries, related to the <code>query</code> property of the state. |
25
26
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesState](./x-components.nextqueriesstate.md) &gt; [resultsPreview](./x-components.nextqueriesstate.resultspreview.md)
4
+
5
+ ## NextQueriesState.resultsPreview property
6
+
7
+ Results of the next queries requests.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ resultsPreview: Dictionary<PreviewResults>;
13
+ ```
@@ -19,5 +19,6 @@ export interface NextQueriesXEvents
19
19
  | [NextQueriesChanged](./x-components.nextqueriesxevents.nextquerieschanged.md) | NextQuery\[\] | Next Queries have been changed. Payload: The new [next queries](./x-types.nextquery.md)<!-- -->. |
20
20
  | [NextQueriesDisplayed](./x-components.nextqueriesxevents.nextqueriesdisplayed.md) | NextQuery\[\] | The current next queries have been displayed to the user. Payload: The displayed next queries. |
21
21
  | [NextQueriesRequestChanged](./x-components.nextqueriesxevents.nextqueriesrequestchanged.md) | NextQueriesRequest \| null | Any property of the next-queries request has changed Payload: The new next-queries request or <code>null</code> if there is not enough data in the state to conform a valid request. |
22
+ | [NextQueryPreviewMounted](./x-components.nextqueriesxevents.nextquerypreviewmounted.md) | string | The component to show a next query preview has been mounted. Payload: The next query to preview. |
22
23
  | [UserSelectedANextQuery](./x-components.nextqueriesxevents.userselectedanextquery.md) | NextQuery | The user has selected a next-query Payload: The next query that has been selected by the user. |
23
24
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [NextQueriesXEvents](./x-components.nextqueriesxevents.md) &gt; [NextQueryPreviewMounted](./x-components.nextqueriesxevents.nextquerypreviewmounted.md)
4
+
5
+ ## NextQueriesXEvents.NextQueryPreviewMounted property
6
+
7
+ The component to show a next query preview has been mounted. Payload: The next query to preview.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ NextQueryPreviewMounted: string;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [resetResultsPreviewWire](./x-components.resetresultspreviewwire.md)
4
+
5
+ ## resetResultsPreviewWire variable
6
+
7
+ Resets the next query preview results.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ resetResultsPreviewWire: import("../..").AnyWire
13
+ ```
@@ -57,6 +57,7 @@ Entry point to export search-type models and testing schemas in a unified api-ex
57
57
  | [PopularSearchesRequest](./x-types.popularsearchesrequest.md) | Request for Popular Searches endpoint. |
58
58
  | [PopularSearchesResponse](./x-types.popularsearchesresponse.md) | Response for the popular searches endpoint. |
59
59
  | [Previewable](./x-types.previewable.md) | Represents an item that is searchable, and the results associated to it. |
60
+ | [PreviewResults](./x-types.previewresults.md) | Interface to type the query preview objects. |
60
61
  | [Promoted](./x-types.promoted.md) | A promoted is an image with a title, that when clicked redirect the user to an URL. Often it is represented taking up the same space than a normal result. |
61
62
  | [QueryableRequest](./x-types.queryablerequest.md) | Interface for any Request with a <code>query</code> parameter. |
62
63
  | [QuerySuggestionsRequest](./x-types.querysuggestionsrequest.md) | Request for Query Suggestions endpoint. |
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-types](./x-types.md) &gt; [PreviewResults](./x-types.previewresults.md) &gt; [items](./x-types.previewresults.items.md)
4
+
5
+ ## PreviewResults.items property
6
+
7
+ The results to preview the search request.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ items: Result[];
13
+ ```
@@ -0,0 +1,22 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-types](./x-types.md) &gt; [PreviewResults](./x-types.previewresults.md)
4
+
5
+ ## PreviewResults interface
6
+
7
+ Interface to type the query preview objects.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ export interface PreviewResults
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ | Property | Type | Description |
18
+ | --- | --- | --- |
19
+ | [items](./x-types.previewresults.items.md) | [Result](./x-types.result.md)<!-- -->\[\] | The results to preview the search request. |
20
+ | [query](./x-types.previewresults.query.md) | string | The searched query. |
21
+ | [totalResults](./x-types.previewresults.totalresults.md) | number | The number of results of the query. |
22
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-types](./x-types.md) &gt; [PreviewResults](./x-types.previewresults.md) &gt; [query](./x-types.previewresults.query.md)
4
+
5
+ ## PreviewResults.query property
6
+
7
+ The searched query.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ query: string;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-types](./x-types.md) &gt; [PreviewResults](./x-types.previewresults.md) &gt; [totalResults](./x-types.previewresults.totalresults.md)
4
+
5
+ ## PreviewResults.totalResults property
6
+
7
+ The number of results of the query.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ totalResults: number;
13
+ ```
package/js/index.js CHANGED
@@ -251,7 +251,7 @@ export { nextQueriesEmitters } from './x-modules/next-queries/store/emitters.js'
251
251
  export { request as nextQueriesRequest } from './x-modules/next-queries/store/getters/request.getter.js';
252
252
  export { nextQueries } from './x-modules/next-queries/store/getters/next-queries.getter.js';
253
253
  export { nextQueriesXStoreModule } from './x-modules/next-queries/store/module.js';
254
- export { fetchAndSaveNextQueriesWire, nextQueriesWiring, setNextQueriesExtraParams, setNextQueriesQuery, setQueryFromLastHistoryQueryWire, setSearchedQueries } from './x-modules/next-queries/wiring.js';
254
+ export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesQuery, setQueryFromLastHistoryQueryWire, setSearchedQueries } from './x-modules/next-queries/wiring.js';
255
255
  export { nextQueriesXModule } from './x-modules/next-queries/x-module.js';
256
256
  export { default as PopularSearch } from './x-modules/popular-searches/components/popular-search.vue.js';
257
257
  export { default as PopularSearches } from './x-modules/popular-searches/components/popular-searches.vue.js';
@@ -0,0 +1,22 @@
1
+ // eslint-disable-next-line max-len
2
+ const fetchAndSaveNextQueryPreview = ({ dispatch, commit }, query) => {
3
+ return dispatch('fetchNextQueryPreview', query)
4
+ .then(response => {
5
+ if (response) {
6
+ commit('setResultsPreview', {
7
+ [query]: {
8
+ query,
9
+ totalResults: response.totalResults,
10
+ items: response.results
11
+ }
12
+ });
13
+ }
14
+ })
15
+ .catch(error => {
16
+ // eslint-disable-next-line no-console
17
+ console.error(error);
18
+ });
19
+ };
20
+
21
+ export { fetchAndSaveNextQueryPreview };
22
+ //# sourceMappingURL=fetch-and-save-next-query-preview.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-and-save-next-query-preview.action.js","sources":["../../../../../../src/x-modules/next-queries/store/actions/fetch-and-save-next-query-preview.action.ts"],"sourcesContent":["import { NextQueriesXStoreModule } from '../types';\n\n// eslint-disable-next-line max-len\nexport const fetchAndSaveNextQueryPreview: NextQueriesXStoreModule['actions']['fetchAndSaveNextQueryPreview'] =\n ({ dispatch, commit }, query): Promise<void> => {\n return dispatch('fetchNextQueryPreview', query)\n .then(response => {\n if (response) {\n commit('setResultsPreview', {\n [query]: {\n query,\n totalResults: response.totalResults,\n items: response.results\n }\n });\n }\n })\n .catch(error => {\n // eslint-disable-next-line no-console\n console.error(error);\n });\n };\n"],"names":[],"mappings":"AAEA;MACa,4BAA4B,GACvC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK;IAC1B,OAAO,QAAQ,CAAC,uBAAuB,EAAE,KAAK,CAAC;SAC5C,IAAI,CAAC,QAAQ;QACZ,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,mBAAmB,EAAE;gBAC1B,CAAC,KAAK,GAAG;oBACP,KAAK;oBACL,YAAY,EAAE,QAAQ,CAAC,YAAY;oBACnC,KAAK,EAAE,QAAQ,CAAC,OAAO;iBACxB;aACF,CAAC,CAAC;SACJ;KACF,CAAC;SACD,KAAK,CAAC,KAAK;;QAEV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB,CAAC,CAAC;AACP;;;;"}
@@ -0,0 +1,26 @@
1
+ import { XPlugin } from '../../../../plugins/x-plugin.js';
2
+
3
+ /**
4
+ * Default implementation for the {@link NextQueriesActions.fetchNextQueryPreview}.
5
+ *
6
+ * @param state - The state of the store, used to retrieve the rows and the extraParams to be sent
7
+ * in the request.
8
+ * @param query - The next query to send in the request.
9
+ * @returns A Promise of a SearchResponse when it fetches the results, `null` if the request was
10
+ * not made.
11
+ */
12
+ const fetchNextQueryPreview = ({ state }, query) => {
13
+ if (!query) {
14
+ return null;
15
+ }
16
+ return XPlugin.adapter.search({
17
+ query,
18
+ rows: state.config.maxPreviewItemsToRequest,
19
+ extraParams: state.params
20
+ }, {
21
+ id: `fetchNextQueryPreview-${query}`
22
+ });
23
+ };
24
+
25
+ export { fetchNextQueryPreview };
26
+ //# sourceMappingURL=fetch-next-query-preview.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-next-query-preview.action.js","sources":["../../../../../../src/x-modules/next-queries/store/actions/fetch-next-query-preview.action.ts"],"sourcesContent":["import { NextQueriesXStoreModule } from '../types';\nimport { XPlugin } from '../../../../plugins/x-plugin';\n\n/**\n * Default implementation for the {@link NextQueriesActions.fetchNextQueryPreview}.\n *\n * @param state - The state of the store, used to retrieve the rows and the extraParams to be sent\n * in the request.\n * @param query - The next query to send in the request.\n * @returns A Promise of a SearchResponse when it fetches the results, `null` if the request was\n * not made.\n */\nexport const fetchNextQueryPreview: NextQueriesXStoreModule['actions']['fetchNextQueryPreview'] = (\n { state },\n query\n) => {\n if (!query) {\n return null;\n }\n return XPlugin.adapter.search(\n {\n query,\n rows: state.config.maxPreviewItemsToRequest,\n extraParams: state.params\n },\n {\n id: `fetchNextQueryPreview-${query}`\n }\n );\n};\n"],"names":[],"mappings":";;AAGA;;;;;;;;;MASa,qBAAqB,GAAgE,CAChG,EAAE,KAAK,EAAE,EACT,KAAK;IAEL,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAC3B;QACE,KAAK;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,wBAAwB;QAC3C,WAAW,EAAE,KAAK,CAAC,MAAM;KAC1B,EACD;QACE,EAAE,EAAE,yBAAyB,KAAK,EAAE;KACrC,CACF,CAAC;AACJ;;;;"}
@@ -4,6 +4,8 @@ import { cancelFetchAndSaveNextQueries, fetchAndSaveNextQueries } from './action
4
4
  import { fetchNextQueries } from './actions/fetch-next-queries.action.js';
5
5
  import { setQueryFromLastHistoryQuery } from './actions/set-query-from-last-history-query.action.js';
6
6
  import { setUrlParams } from './actions/set-url-params.action.js';
7
+ import { fetchNextQueryPreview } from './actions/fetch-next-query-preview.action.js';
8
+ import { fetchAndSaveNextQueryPreview } from './actions/fetch-and-save-next-query-preview.action.js';
7
9
  import { nextQueries } from './getters/next-queries.getter.js';
8
10
  import { request } from './getters/request.getter.js';
9
11
 
@@ -21,9 +23,11 @@ const nextQueriesXStoreModule = {
21
23
  config: {
22
24
  maxItemsToRequest: 20,
23
25
  hideSessionQueries: true,
24
- loadOnInit: true
26
+ loadOnInit: true,
27
+ maxPreviewItemsToRequest: 8
25
28
  },
26
- params: {}
29
+ params: {},
30
+ resultsPreview: {}
27
31
  }),
28
32
  getters: {
29
33
  request,
@@ -40,6 +44,12 @@ const nextQueriesXStoreModule = {
40
44
  setStatus,
41
45
  setParams(state, params) {
42
46
  state.params = params;
47
+ },
48
+ setResultsPreview(state, resultsPreview) {
49
+ state.resultsPreview = { ...state.resultsPreview, ...resultsPreview };
50
+ },
51
+ resetResultsPreview(state) {
52
+ state.resultsPreview = {};
43
53
  }
44
54
  },
45
55
  actions: {
@@ -47,7 +57,9 @@ const nextQueriesXStoreModule = {
47
57
  fetchAndSaveNextQueries,
48
58
  fetchNextQueries,
49
59
  setQueryFromLastHistoryQuery,
50
- setUrlParams
60
+ setUrlParams,
61
+ fetchNextQueryPreview,
62
+ fetchAndSaveNextQueryPreview
51
63
  }
52
64
  };
53
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../../../../../src/x-modules/next-queries/store/module.ts"],"sourcesContent":["import { setQuery } from '../../../store/utils/query.utils';\nimport { setStatus } from '../../../store/utils/status-store.utils';\nimport {\n cancelFetchAndSaveNextQueries,\n fetchAndSaveNextQueries\n} from './actions/fetch-and-save-next-queries.action';\nimport { fetchNextQueries } from './actions/fetch-next-queries.action';\nimport { setQueryFromLastHistoryQuery } from './actions/set-query-from-last-history-query.action';\nimport { setUrlParams } from './actions/set-url-params.action';\nimport { nextQueries } from './getters/next-queries.getter';\nimport { request } from './getters/request.getter';\nimport { NextQueriesXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the next-queries module.\n *\n * @internal\n */\nexport const nextQueriesXStoreModule: NextQueriesXStoreModule = {\n state: () => ({\n query: '',\n nextQueries: [],\n searchedQueries: [],\n status: 'initial',\n config: {\n maxItemsToRequest: 20,\n hideSessionQueries: true,\n loadOnInit: true\n },\n params: {}\n }),\n getters: {\n request,\n nextQueries\n },\n mutations: {\n setQuery,\n setNextQueries(state, nextQueries) {\n state.nextQueries = nextQueries;\n },\n setSearchedQueries(state, searchedQueries) {\n state.searchedQueries = searchedQueries;\n },\n setStatus,\n setParams(state, params) {\n state.params = params;\n }\n },\n actions: {\n cancelFetchAndSaveNextQueries,\n fetchAndSaveNextQueries,\n fetchNextQueries,\n setQueryFromLastHistoryQuery,\n setUrlParams\n }\n};\n"],"names":[],"mappings":";;;;;;;;;AAaA;;;;;MAKa,uBAAuB,GAA4B;IAC9D,KAAK,EAAE,OAAO;QACZ,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,EAAE;QACnB,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE;YACN,iBAAiB,EAAE,EAAE;YACrB,kBAAkB,EAAE,IAAI;YACxB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;KACX,CAAC;IACF,OAAO,EAAE;QACP,OAAO;QACP,WAAW;KACZ;IACD,SAAS,EAAE;QACT,QAAQ;QACR,cAAc,CAAC,KAAK,EAAE,WAAW;YAC/B,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;SACjC;QACD,kBAAkB,CAAC,KAAK,EAAE,eAAe;YACvC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC;SACzC;QACD,SAAS;QACT,SAAS,CAAC,KAAK,EAAE,MAAM;YACrB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;KACF;IACD,OAAO,EAAE;QACP,6BAA6B;QAC7B,uBAAuB;QACvB,gBAAgB;QAChB,4BAA4B;QAC5B,YAAY;KACb;;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../../../../../src/x-modules/next-queries/store/module.ts"],"sourcesContent":["import { setQuery } from '../../../store/utils/query.utils';\nimport { setStatus } from '../../../store/utils/status-store.utils';\nimport {\n cancelFetchAndSaveNextQueries,\n fetchAndSaveNextQueries\n} from './actions/fetch-and-save-next-queries.action';\nimport { fetchNextQueries } from './actions/fetch-next-queries.action';\nimport { setQueryFromLastHistoryQuery } from './actions/set-query-from-last-history-query.action';\nimport { setUrlParams } from './actions/set-url-params.action';\nimport { fetchNextQueryPreview } from './actions/fetch-next-query-preview.action';\nimport { fetchAndSaveNextQueryPreview } from './actions/fetch-and-save-next-query-preview.action';\nimport { nextQueries } from './getters/next-queries.getter';\nimport { request } from './getters/request.getter';\nimport { NextQueriesXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the next-queries module.\n *\n * @internal\n */\nexport const nextQueriesXStoreModule: NextQueriesXStoreModule = {\n state: () => ({\n query: '',\n nextQueries: [],\n searchedQueries: [],\n status: 'initial',\n config: {\n maxItemsToRequest: 20,\n hideSessionQueries: true,\n loadOnInit: true,\n maxPreviewItemsToRequest: 8\n },\n params: {},\n resultsPreview: {}\n }),\n getters: {\n request,\n nextQueries\n },\n mutations: {\n setQuery,\n setNextQueries(state, nextQueries) {\n state.nextQueries = nextQueries;\n },\n setSearchedQueries(state, searchedQueries) {\n state.searchedQueries = searchedQueries;\n },\n setStatus,\n setParams(state, params) {\n state.params = params;\n },\n setResultsPreview(state, resultsPreview) {\n state.resultsPreview = { ...state.resultsPreview, ...resultsPreview };\n },\n resetResultsPreview(state) {\n state.resultsPreview = {};\n }\n },\n actions: {\n cancelFetchAndSaveNextQueries,\n fetchAndSaveNextQueries,\n fetchNextQueries,\n setQueryFromLastHistoryQuery,\n setUrlParams,\n fetchNextQueryPreview,\n fetchAndSaveNextQueryPreview\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAeA;;;;;MAKa,uBAAuB,GAA4B;IAC9D,KAAK,EAAE,OAAO;QACZ,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,EAAE;QACnB,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE;YACN,iBAAiB,EAAE,EAAE;YACrB,kBAAkB,EAAE,IAAI;YACxB,UAAU,EAAE,IAAI;YAChB,wBAAwB,EAAE,CAAC;SAC5B;QACD,MAAM,EAAE,EAAE;QACV,cAAc,EAAE,EAAE;KACnB,CAAC;IACF,OAAO,EAAE;QACP,OAAO;QACP,WAAW;KACZ;IACD,SAAS,EAAE;QACT,QAAQ;QACR,cAAc,CAAC,KAAK,EAAE,WAAW;YAC/B,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;SACjC;QACD,kBAAkB,CAAC,KAAK,EAAE,eAAe;YACvC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC;SACzC;QACD,SAAS;QACT,SAAS,CAAC,KAAK,EAAE,MAAM;YACrB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;QACD,iBAAiB,CAAC,KAAK,EAAE,cAAc;YACrC,KAAK,CAAC,cAAc,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,cAAc,EAAE,CAAC;SACvE;QACD,mBAAmB,CAAC,KAAK;YACvB,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC;SAC3B;KACF;IACD,OAAO,EAAE;QACP,6BAA6B;QAC7B,uBAAuB;QACvB,gBAAgB;QAChB,4BAA4B;QAC5B,YAAY;QACZ,qBAAqB;QACrB,4BAA4B;KAC7B;;;;;"}