@empathyco/x-components 6.0.0-alpha.55 → 6.0.0-alpha.57

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 (85) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/design-system/deprecated-full-theme.css +333 -334
  3. package/docs/API-reference/api/x-components.featurelocation.md +1 -1
  4. package/docs/API-reference/api/x-components.globalxbus.md +2 -0
  5. package/docs/API-reference/api/x-components.hierarchicalfilter.md +1 -0
  6. package/docs/API-reference/api/x-components.md +1 -0
  7. package/docs/API-reference/api/x-components.queryfeature.md +1 -1
  8. package/docs/API-reference/api/x-components.relatedpromptsactions.md +1 -0
  9. package/docs/API-reference/api/x-components.relatedpromptsactions.seturlparams.md +24 -0
  10. package/docs/API-reference/api/x-components.relatedpromptstaglist.md +2 -3
  11. package/docs/API-reference/api/x-components.relatedpromptsxevents.md +1 -0
  12. package/docs/API-reference/api/x-components.relatedpromptsxevents.selectedrelatedpromptchanged.md +13 -0
  13. package/docs/API-reference/api/x-components.resultfeature.md +1 -1
  14. package/docs/API-reference/api/x-components.seturlprompt.md +13 -0
  15. package/docs/API-reference/api/x-components.simplefilter.md +1 -0
  16. package/docs/API-reference/api/x-components.snippetcallbacks.md +1 -0
  17. package/docs/API-reference/api/x-components.urlmutations.md +1 -0
  18. package/docs/API-reference/api/x-components.urlmutations.setprompt.md +24 -0
  19. package/docs/API-reference/api/x-components.urlparams.md +1 -0
  20. package/docs/API-reference/api/x-components.urlparams.prompt.md +11 -0
  21. package/js/index.js +1 -1
  22. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue.js +6 -3
  23. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue.js.map +1 -1
  24. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +9 -14
  25. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -1
  26. package/js/x-modules/related-prompts/store/actions/set-url-params.action.js +15 -0
  27. package/js/x-modules/related-prompts/store/actions/set-url-params.action.js.map +1 -0
  28. package/js/x-modules/related-prompts/store/emitters.js +2 -1
  29. package/js/x-modules/related-prompts/store/emitters.js.map +1 -1
  30. package/js/x-modules/related-prompts/store/module.js +4 -7
  31. package/js/x-modules/related-prompts/store/module.js.map +1 -1
  32. package/js/x-modules/related-prompts/wiring.js +43 -65
  33. package/js/x-modules/related-prompts/wiring.js.map +1 -1
  34. package/js/x-modules/tagging/wiring.js +8 -4
  35. package/js/x-modules/tagging/wiring.js.map +1 -1
  36. package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
  37. package/js/x-modules/url/components/url-handler.vue2.js +2 -4
  38. package/js/x-modules/url/components/url-handler.vue2.js.map +1 -1
  39. package/js/x-modules/url/store/getters/url-params.getter.js +2 -3
  40. package/js/x-modules/url/store/getters/url-params.getter.js.map +1 -1
  41. package/js/x-modules/url/store/initial-state.js +2 -1
  42. package/js/x-modules/url/store/initial-state.js.map +1 -1
  43. package/js/x-modules/url/store/module.js +3 -0
  44. package/js/x-modules/url/store/module.js.map +1 -1
  45. package/js/x-modules/url/wiring.js +10 -1
  46. package/js/x-modules/url/wiring.js.map +1 -1
  47. package/package.json +2 -2
  48. package/report/x-components.api.json +214 -10
  49. package/report/x-components.api.md +38 -21
  50. package/types/components/global-x-bus.vue.d.ts +2 -0
  51. package/types/components/global-x-bus.vue.d.ts.map +1 -1
  52. package/types/components/snippet-callbacks.vue.d.ts +1 -0
  53. package/types/components/snippet-callbacks.vue.d.ts.map +1 -1
  54. package/types/types/origin.d.ts +3 -3
  55. package/types/types/origin.d.ts.map +1 -1
  56. package/types/types/url-params.d.ts +1 -0
  57. package/types/types/url-params.d.ts.map +1 -1
  58. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +1 -0
  59. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
  60. package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts +1 -0
  61. package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
  62. package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts +3 -4
  63. package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts.map +1 -1
  64. package/types/x-modules/related-prompts/events.types.d.ts +5 -0
  65. package/types/x-modules/related-prompts/events.types.d.ts.map +1 -1
  66. package/types/x-modules/related-prompts/store/actions/set-url-params.action.d.ts +11 -0
  67. package/types/x-modules/related-prompts/store/actions/set-url-params.action.d.ts.map +1 -0
  68. package/types/x-modules/related-prompts/store/emitters.d.ts +1 -0
  69. package/types/x-modules/related-prompts/store/emitters.d.ts.map +1 -1
  70. package/types/x-modules/related-prompts/store/module.d.ts.map +1 -1
  71. package/types/x-modules/related-prompts/store/types.d.ts +7 -0
  72. package/types/x-modules/related-prompts/store/types.d.ts.map +1 -1
  73. package/types/x-modules/related-prompts/wiring.d.ts +15 -14
  74. package/types/x-modules/related-prompts/wiring.d.ts.map +1 -1
  75. package/types/x-modules/tagging/wiring.d.ts.map +1 -1
  76. package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
  77. package/types/x-modules/url/store/getters/url-params.getter.d.ts +2 -3
  78. package/types/x-modules/url/store/getters/url-params.getter.d.ts.map +1 -1
  79. package/types/x-modules/url/store/initial-state.d.ts.map +1 -1
  80. package/types/x-modules/url/store/module.d.ts.map +1 -1
  81. package/types/x-modules/url/store/types.d.ts +6 -0
  82. package/types/x-modules/url/store/types.d.ts.map +1 -1
  83. package/types/x-modules/url/wiring.d.ts +9 -0
  84. package/types/x-modules/url/wiring.d.ts.map +1 -1
  85. package/url/index.js +1 -1
@@ -9,7 +9,7 @@ Indicates where the feature is placed.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp' | 'related-prompts';
12
+ export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp' | 'related_prompts';
13
13
  ```
14
14
 
15
15
  ## Example 1
@@ -173,6 +173,7 @@ _default: import("vue").DefineComponent<{
173
173
  PushableUrlStateUpdated: (payload: import("..").UrlParams, metadata: import("..").WireMetadata) => unknown;
174
174
  ReplaceableUrlStateUpdated: (payload: import("..").UrlParams, metadata: import("..").WireMetadata) => unknown;
175
175
  RelatedPromptsRequestUpdated: (payload: import("@empathyco/x-types").RelatedPromptsRequest | null, metadata: import("..").WireMetadata) => unknown;
176
+ SelectedRelatedPromptChanged: (payload: number, metadata: import("..").WireMetadata) => unknown;
176
177
  UserSelectedARelatedPrompt: (payload: number, metadata: import("..").WireMetadata) => unknown;
177
178
  UserSelectedARelatedPromptQuery: (payload: number, metadata: import("..").WireMetadata) => unknown;
178
179
  UserClickedARelatedPromptResult: (payload: import("@empathyco/x-types").Result, metadata: import("..").WireMetadata) => unknown;
@@ -344,6 +345,7 @@ _default: import("vue").DefineComponent<{
344
345
  PushableUrlStateUpdated: (payload: import("..").UrlParams, metadata: import("..").WireMetadata) => unknown;
345
346
  ReplaceableUrlStateUpdated: (payload: import("..").UrlParams, metadata: import("..").WireMetadata) => unknown;
346
347
  RelatedPromptsRequestUpdated: (payload: import("@empathyco/x-types").RelatedPromptsRequest | null, metadata: import("..").WireMetadata) => unknown;
348
+ SelectedRelatedPromptChanged: (payload: number, metadata: import("..").WireMetadata) => unknown;
347
349
  UserSelectedARelatedPrompt: (payload: number, metadata: import("..").WireMetadata) => unknown;
348
350
  UserSelectedARelatedPromptQuery: (payload: number, metadata: import("..").WireMetadata) => unknown;
349
351
  UserClickedARelatedPromptResult: (payload: import("@empathyco/x-types").Result, metadata: import("..").WireMetadata) => unknown;
@@ -185,6 +185,7 @@ _default: import("vue").DefineComponent<{
185
185
  PushableUrlStateUpdated?: import("../../../../types").UrlParams | undefined;
186
186
  ReplaceableUrlStateUpdated?: import("../../../../types").UrlParams | undefined;
187
187
  RelatedPromptsRequestUpdated?: import("@empathyco/x-types").RelatedPromptsRequest | null | undefined;
188
+ SelectedRelatedPromptChanged?: number | undefined;
188
189
  UserSelectedARelatedPrompt?: number | undefined;
189
190
  UserSelectedARelatedPromptQuery?: number | undefined;
190
191
  UserClickedARelatedPromptResult?: import("@empathyco/x-types").Result | undefined;
@@ -614,6 +614,7 @@ X-Components is a library usable everywhere not only for search experiences.
614
614
  | [setUrlParams](./x-components.seturlparams.md) | Sets the search state <code>query</code>. |
615
615
  | [setUrlParamsFromPreview](./x-components.seturlparamsfrompreview.md) | Sets the extra params of the url module from a selectedQueryPreview's extraParams. |
616
616
  | [setUrlParamsWire](./x-components.seturlparamswire.md) | Saves the params from the url. |
617
+ | [setUrlPrompt](./x-components.seturlprompt.md) | Sets the related prompt of the URL module. |
617
618
  | [setUrlQuery](./x-components.seturlquery.md) | Sets the query of the url module. |
618
619
  | [setUrlQueryFromPreview](./x-components.seturlqueryfrompreview.md) | Sets the url state <code>query</code> with a selectedQueryPreview's query. |
619
620
  | [setUrlRelatedTags](./x-components.seturlrelatedtags.md) | Sets the [related tags](./x-components.relatedtag.md)<!-- -->. |
@@ -9,5 +9,5 @@ The name of the tool that generated the query.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export type QueryFeature = 'search_box' | 'url' | 'query_suggestion' | 'next_query' | 'popular_search' | 'history_query' | 'partial_result' | 'related_tag' | 'spellcheck' | 'customer' | 'semantics' | 'related-prompts';
12
+ export type QueryFeature = 'search_box' | 'url' | 'query_suggestion' | 'next_query' | 'popular_search' | 'history_query' | 'partial_result' | 'related_tag' | 'spellcheck' | 'customer' | 'semantics' | 'related_prompts';
13
13
  ```
@@ -19,4 +19,5 @@ export interface RelatedPromptsActions
19
19
  | [cancelFetchAndSaveRelatedPrompts()](./x-components.relatedpromptsactions.cancelfetchandsaverelatedprompts.md) | Cancels / interrupt [RelatedPromptsActions.fetchAndSaveRelatedPrompts()](./x-components.relatedpromptsactions.fetchandsaverelatedprompts.md) synchronous promise. |
20
20
  | [fetchAndSaveRelatedPrompts(request)](./x-components.relatedpromptsactions.fetchandsaverelatedprompts.md) | Requests a new set of related prompts and stores them in the module. |
21
21
  | [fetchRelatedPrompts(request)](./x-components.relatedpromptsactions.fetchrelatedprompts.md) | Requests a new set of related prompts for the module query, and returns them. |
22
+ | [setUrlParams(urlParams)](./x-components.relatedpromptsactions.seturlparams.md) | Checks if the URL has params on it and then updates the state with these values. |
22
23
 
@@ -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; [RelatedPromptsActions](./x-components.relatedpromptsactions.md) &gt; [setUrlParams](./x-components.relatedpromptsactions.seturlparams.md)
4
+
5
+ ## RelatedPromptsActions.setUrlParams() method
6
+
7
+ Checks if the URL has params on it and then updates the state with these values.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ setUrlParams(urlParams: UrlParams): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | urlParams | [UrlParams](./x-components.urlparams.md) | List of params from the url. |
20
+
21
+ **Returns:**
22
+
23
+ void
24
+
@@ -25,13 +25,12 @@ _default: import("vue").DefineComponent<{
25
25
  default: number;
26
26
  };
27
27
  }, {
28
- isSelected: (index: number) => boolean;
29
28
  onSelect: (selectedIndex: number) => void;
30
29
  onBeforeEnter: (el: Element) => void;
31
30
  onEnter: (el: Element, done: () => void) => void;
32
31
  onLeave: (el: Element, done: () => void) => void;
33
- selectedPromptIndex: import("vue").ComputedRef<any>;
34
- visibleRelatedPrompts: import("vue").ComputedRef<{
32
+ selectedPromptIndex: ComputedRef<number>;
33
+ visibleRelatedPrompts: ComputedRef<{
35
34
  index: number;
36
35
  relatedPromptNextQueries?: import("@empathyco/x-types").RelatedPromptNextQuery[] | undefined;
37
36
  nextQueries: string[];
@@ -17,6 +17,7 @@ export interface RelatedPromptsXEvents
17
17
  | Property | Modifiers | Type | Description |
18
18
  | --- | --- | --- | --- |
19
19
  | [RelatedPromptsRequestUpdated](./x-components.relatedpromptsxevents.relatedpromptsrequestupdated.md) | | RelatedPromptsRequest \| null | Any property of the related-prompts request has changed Payload: The new related-prompts request or <code>null</code> if there is not enough data in the state to conform a valid request. |
20
+ | [SelectedRelatedPromptChanged](./x-components.relatedpromptsxevents.selectedrelatedpromptchanged.md) | | number | Selected Related Prompt has been changed. Payload: Selected Related Prompt index. -1 is deselected. |
20
21
  | [UserClickedARelatedPromptAdd2Cart](./x-components.relatedpromptsxevents.userclickedarelatedpromptadd2cart.md) | | Result | The user has clicked one add to cart from a prompt. Payload: The result that the user clicked. |
21
22
  | [UserClickedARelatedPromptResult](./x-components.relatedpromptsxevents.userclickedarelatedpromptresult.md) | | Result | The user has clicked one prompt. Payload: The result that the user clicked. |
22
23
  | [UserSelectedARelatedPrompt](./x-components.relatedpromptsxevents.userselectedarelatedprompt.md) | | number | The selected prompt has changed. Payload: The index of the prompt in the RelatedPrompts list or -1 to remove selection. |
@@ -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; [RelatedPromptsXEvents](./x-components.relatedpromptsxevents.md) &gt; [SelectedRelatedPromptChanged](./x-components.relatedpromptsxevents.selectedrelatedpromptchanged.md)
4
+
5
+ ## RelatedPromptsXEvents.SelectedRelatedPromptChanged property
6
+
7
+ Selected Related Prompt has been changed. Payload: Selected Related Prompt index. -1 is deselected.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ SelectedRelatedPromptChanged: number;
13
+ ```
@@ -9,5 +9,5 @@ The name of the tool that generated the results.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export type ResultFeature = 'search' | 'topclicked_recommendations' | 'brand_recommendations' | 'next_query_recommendations' | 'semantic_recommendations' | 'partial_results' | 'identifier_result';
12
+ export type ResultFeature = 'search' | 'topclicked_recommendations' | 'brand_recommendations' | 'next_query_recommendations' | 'semantic_recommendations' | 'partial_results' | 'identifier_result' | 'related_prompts';
13
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; [setUrlPrompt](./x-components.seturlprompt.md)
4
+
5
+ ## setUrlPrompt variable
6
+
7
+ Sets the related prompt of the URL module.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ setUrlPrompt: import("../..").Wire<number>
13
+ ```
@@ -182,6 +182,7 @@ _default: import("vue").DefineComponent<{
182
182
  PushableUrlStateUpdated?: import("../../../..").UrlParams | undefined;
183
183
  ReplaceableUrlStateUpdated?: import("../../../..").UrlParams | undefined;
184
184
  RelatedPromptsRequestUpdated?: import("@empathyco/x-types").RelatedPromptsRequest | null | undefined;
185
+ SelectedRelatedPromptChanged?: number | undefined;
185
186
  UserSelectedARelatedPrompt?: number | undefined;
186
187
  UserSelectedARelatedPromptQuery?: number | undefined;
187
188
  UserClickedARelatedPromptResult?: import("@empathyco/x-types").Result | undefined;
@@ -172,6 +172,7 @@ _default: import("vue").DefineComponent<{}, {
172
172
  PushableUrlStateUpdated: (payload: import("..").UrlParams, metadata: WireMetadata) => unknown;
173
173
  ReplaceableUrlStateUpdated: (payload: import("..").UrlParams, metadata: WireMetadata) => unknown;
174
174
  RelatedPromptsRequestUpdated: (payload: import("@empathyco/x-types").RelatedPromptsRequest | null, metadata: WireMetadata) => unknown;
175
+ SelectedRelatedPromptChanged: (payload: number, metadata: WireMetadata) => unknown;
175
176
  UserSelectedARelatedPrompt: (payload: number, metadata: WireMetadata) => unknown;
176
177
  UserSelectedARelatedPromptQuery: (payload: number, metadata: WireMetadata) => unknown;
177
178
  UserClickedARelatedPromptResult: (payload: import("@empathyco/x-types").Result, metadata: WireMetadata) => unknown;
@@ -21,6 +21,7 @@ export interface UrlMutations extends QueryMutations
21
21
  | [setInitialExtraParams(extraParams)](./x-components.urlmutations.setinitialextraparams.md) | Sets the initial extra params. |
22
22
  | [setPage(page)](./x-components.urlmutations.setpage.md) | Sets the new page. |
23
23
  | [setParams(params)](./x-components.urlmutations.setparams.md) | Sets the new params. |
24
+ | [setPrompt(prompt)](./x-components.urlmutations.setprompt.md) | Sets the related prompt. |
24
25
  | [setRelatedTags(relatedTags)](./x-components.urlmutations.setrelatedtags.md) | Sets the related tags. |
25
26
  | [setScroll(scroll)](./x-components.urlmutations.setscroll.md) | Sets the url scroll. |
26
27
  | [setSort(sort)](./x-components.urlmutations.setsort.md) | Sets the new sort. |
@@ -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; [UrlMutations](./x-components.urlmutations.md) &gt; [setPrompt](./x-components.urlmutations.setprompt.md)
4
+
5
+ ## UrlMutations.setPrompt() method
6
+
7
+ Sets the related prompt.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ setPrompt(prompt: number): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | prompt | number | The new related prompt index of the URL. |
20
+
21
+ **Returns:**
22
+
23
+ void
24
+
@@ -18,6 +18,7 @@ export interface UrlParams
18
18
  | --- | --- | --- | --- |
19
19
  | [filter](./x-components.urlparams.filter.md) | | string\[\] | |
20
20
  | [page](./x-components.urlparams.page.md) | | number | |
21
+ | [prompt](./x-components.urlparams.prompt.md) | | number | |
21
22
  | [query](./x-components.urlparams.query.md) | | string | |
22
23
  | [scroll](./x-components.urlparams.scroll.md) | | string | |
23
24
  | [sort](./x-components.urlparams.sort.md) | | string | |
@@ -0,0 +1,11 @@
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; [UrlParams](./x-components.urlparams.md) &gt; [prompt](./x-components.urlparams.prompt.md)
4
+
5
+ ## UrlParams.prompt property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ prompt: number;
11
+ ```
package/js/index.js CHANGED
@@ -416,7 +416,7 @@ export { taggingXModule } from './x-modules/tagging/x-module.js';
416
416
  export { default as UrlHandler } from './x-modules/url/components/url-handler.vue.js';
417
417
  export { replaceableParams, urlEmitters } from './x-modules/url/store/emitters.js';
418
418
  export { urlXStoreModule } from './x-modules/url/store/module.js';
419
- export { setInitialExtraParams, setParams, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring } from './x-modules/url/wiring.js';
419
+ export { setInitialExtraParams, setParams, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlPrompt, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring } from './x-modules/url/wiring.js';
420
420
  export { urlXModule } from './x-modules/url/x-module.js';
421
421
  export { default as ExperienceControls } from './x-modules/experience-controls/components/experience-controls.vue.js';
422
422
  export { cancelFetchAndSaveControls, fetchAndSaveExperienceControlsResponse } from './x-modules/experience-controls/store/actions/fetch-and-save-experience-controls.action.js';
@@ -45,13 +45,16 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
45
45
  key: relatedPrompt.suggestionText,
46
46
  class: normalizeClass(["x-related-prompts-tag-list-item", [_ctx.tagClass, _ctx.tagColors && _ctx.tagColors[index % _ctx.tagColors.length]]]),
47
47
  "data-index": index,
48
- style: normalizeStyle(_ctx.isAnimating && { pointerEvents: "none" }),
48
+ style: normalizeStyle({
49
+ ..._ctx.selectedPromptIndex === index && { width: "100%" },
50
+ ..._ctx.isAnimating && { pointerEvents: "none" }
51
+ }),
49
52
  "data-test": "related-prompts-tag-list-item"
50
53
  }, [
51
54
  renderSlot(_ctx.$slots, "default", {
52
55
  relatedPrompt,
53
56
  onSelect: () => _ctx.onSelect(index),
54
- isSelected: _ctx.isSelected(index)
57
+ isSelected: _ctx.selectedPromptIndex === index
55
58
  }, () => [
56
59
  createVNode(_component_DisplayEmitter, {
57
60
  payload: relatedPrompt.tagging?.toolingDisplayTagging,
@@ -65,7 +68,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
65
68
  createVNode(_component_RelatedPrompt, {
66
69
  onClick: ($event) => _ctx.onSelect(index),
67
70
  "related-prompt": relatedPrompt,
68
- selected: _ctx.isSelected(index)
71
+ selected: _ctx.selectedPromptIndex === index
69
72
  }, {
70
73
  "related-prompt-extra-content": withCtx(() => [
71
74
  renderSlot(_ctx.$slots, "related-prompt-extra-content", { relatedPrompt })
@@ -1 +1 @@
1
- {"version":3,"file":"related-prompts-tag-list.vue.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || ''\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"isAnimating && { pointerEvents: 'none' }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :relatedPrompt=\"relatedPrompt\"\n :onSelect=\"() => onSelect(index)\"\n :isSelected=\"isSelected(index)\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :eventMetadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false\n }\"\n >\n <RelatedPrompt\n @click=\"onSelect(index)\"\n :related-prompt=\"relatedPrompt\"\n :selected=\"isSelected(index)\"\n >\n <template #related-prompt-extra-content>\n <slot name=\"related-prompt-extra-content\" :relatedPrompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\n import { RelatedPrompt as RelatedPromptModel } from '@empathyco/x-types';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import SlidingPanel from '../../../components/sliding-panel.vue';\n import { relatedPromptsXModule } from '../x-module';\n import { use$x, useState } from '../../../composables';\n import DisplayEmitter from '../../../components/display-emitter.vue';\n import RelatedPrompt from './related-prompt.vue';\n\n /**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\n export default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700\n }\n },\n setup(props) {\n const x = use$x();\n const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts', [\n 'relatedPrompts',\n 'selectedPrompt'\n ]);\n\n const clickedListItemIndex = ref<number | null>(null);\n const initialOffsetLefts: Record<number, number> = {};\n const isAnimating = ref(false);\n const listItems = ref<HTMLElement[]>([]);\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!)\n )\n );\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length)\n );\n\n const indexRelatedPrompts = computed(() =>\n (relatedPrompts.value as RelatedPromptModel[]).map(\n (relatedPrompt: RelatedPromptModel, index: number) => ({\n ...relatedPrompt,\n index\n })\n )\n );\n\n const visibleRelatedPrompts = computed(() => {\n return selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value;\n });\n\n let timeOutId: number;\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId);\n }\n\n isAnimating.value = true;\n timeOutId = +setTimeout(() => {\n isAnimating.value = false;\n clickedListItemIndex.value = null;\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property);\n }\n });\n });\n }, props.animationDurationInMs);\n };\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle();\n\n clickedListItemIndex.value = selectedIndex;\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex\n )!;\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n initialOffsetLefts[index] = element.offsetLeft;\n element.style.left = `${element.offsetLeft}px`;\n element.style.position = 'absolute';\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n\n if (index !== selectedIndex) {\n element.style.opacity = '1';\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`;\n }\n });\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`;\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth;\n\n selected.style.left = '0px';\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important'\n );\n });\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n selected.style.left = '0px';\n selected.style.position = 'absolute';\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width');\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`;\n });\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value\n });\n };\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Prepare the element for the enter animation\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`;\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n };\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`;\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1';\n element.style.position = 'absolute';\n element.style.transform = 'translateY(0)';\n });\n\n done();\n };\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n });\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs);\n };\n\n const isSelected = (index: number): boolean => selectedPromptIndex.value === index;\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([]);\n });\n\n return {\n isSelected,\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x\n };\n }\n });\n</script>\n<style lang=\"css\">\n .x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n }\n .x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n }\n .x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n }\n</style>\n"],"names":["_resolveComponent","_openBlock","_createBlock","buttonClass","showButtons","scrollContainerClass","_renderSlot","_withCtx","onBeforeEnter","onEnter","onLeave","_createElementBlock","_Fragment","_renderList","_normalizeClass","isAnimating","_normalizeStyle","onSelect","_createVNode","isSelected"],"mappings":";;;;;;;;;kCACEA,gBAyEe,CAAA,cAAA,CAAA,CAAA;SAvEZC,SAA8B,EAAA,EAAAC,WAAA,CAAA,uBAAA,EAAA;AAAA,IAC9B,GAAcC,EAAAA,IAAAA,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA,MAAAA;AAAAA,IACd,yBAAcC,EAAAA,KAAAA;AAAAA,IACd,cAAA,EAAA,IAAA,CAAA,WAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,WAAA,IAAA,IAAA,CAAA,mBAAA,KAAA,CAAA,CAAA;AAAqFC,IAAAA,wBAAAA,EAAAA;AAAAA,MAAAA,6CAAAA;;AAK3E,KAAA;AAAA,GAAA,EAAA;;MAyDAC,UAIiC,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,CAAA;AAAA,KAAA,CAAA;;MAxEhDA,UAmEuB,CAAA,IAAA,CAAA,MAAA,EAAA,4BAAA,CAAA;AAAA,KAAA,CAAA;AAjDhB,IAAA,OAAA,EAAAC,OAAA,CAAY,MAAEC;AAAAA,MAAAA,WAAAA,CACPC,eAAO,EAAA;AAAA,QACd,aAAOC,EAAAA,IAAAA,CAAAA,aAAAA;AAAAA,QACR,OAAM,EAAA,IAAA,CAAA,OAAA;AAAA,QACL,SAAK,IAAK,CAAA,OAAA;AAAA,QACX,KAAI,EAAA,4BAAA;AAAA,QACJ,GAAA,EAAA,KAAA;AAAA,QAAA,GAAA,EAAA,IAAA;A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Q,CAAEE,MAAAA,KAAAA,IAAAA,CAAU,QAAM,CAAA,KAAA,CAAA;AAAA,wBAAA,gBAAA,EAAA,aAAA;wBAEhB,QAA4B,EAAA,IAAA,CAAA,UAAA,CAAA,KAAA,CAAA;AAAA,uBAAA,EAAA;;AA5DrD,0BAAAb,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,8BAAA,EAAA,EAAA,aAAA,EAAA,CAAA;AAAA,yBAAA,CAAA;;;AAAA,uBAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,UAAA,CAAA,CAAA;AAAA,qBAAA,CAAA;;;AAAA,mBAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,eAAA,CAAA,CAAA;AAAA,iBAAA,CAAA;;AAAA,aAAA,CAAA;AAAA,YAAA,GAAA;AAAA;AAAA,WAAA;AAAA,SAAA,CAAA;;;AAAA,OAAA,EAAA,CAAA,EAAA,CAAA,eAAA,EAAA,SAAA,EAAA,SAAA,CAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"related-prompts-tag-list.vue.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || ''\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' })\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :relatedPrompt=\"relatedPrompt\"\n :onSelect=\"() => onSelect(index)\"\n :isSelected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :eventMetadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false\n }\"\n >\n <RelatedPrompt\n @click=\"onSelect(index)\"\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n >\n <template #related-prompt-extra-content>\n <slot name=\"related-prompt-extra-content\" :relatedPrompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\n import { RelatedPrompt as RelatedPromptModel } from '@empathyco/x-types';\n import { computed, ComputedRef, defineComponent, PropType, ref } from 'vue';\n import SlidingPanel from '../../../components/sliding-panel.vue';\n import { relatedPromptsXModule } from '../x-module';\n import { use$x, useState } from '../../../composables';\n import DisplayEmitter from '../../../components/display-emitter.vue';\n import RelatedPrompt from './related-prompt.vue';\n\n /**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\n export default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700\n }\n },\n setup(props) {\n const x = use$x();\n const relatedPrompts: ComputedRef<RelatedPromptModel[]> = useState('relatedPrompts', [\n 'relatedPrompts'\n ]).relatedPrompts;\n const selectedPromptIndex: ComputedRef<number> = useState('relatedPrompts', [\n 'selectedPrompt'\n ]).selectedPrompt;\n\n const clickedListItemIndex = ref<number | null>(null);\n const initialOffsetLefts: Record<number, number> = {};\n const isAnimating = ref(false);\n const listItems = ref<HTMLElement[]>([]);\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!)\n )\n );\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length)\n );\n\n const indexRelatedPrompts = computed(() =>\n relatedPrompts.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index }))\n );\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value\n );\n\n let timeOutId: number;\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId);\n }\n\n isAnimating.value = true;\n timeOutId = +setTimeout(() => {\n isAnimating.value = false;\n clickedListItemIndex.value = null;\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property);\n }\n });\n });\n }, props.animationDurationInMs);\n };\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle();\n\n clickedListItemIndex.value = selectedIndex;\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex\n )!;\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n initialOffsetLefts[index] = element.offsetLeft;\n element.style.left = `${element.offsetLeft}px`;\n element.style.position = 'absolute';\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n\n if (index !== selectedIndex) {\n element.style.opacity = '1';\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`;\n }\n });\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`;\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth;\n\n selected.style.left = '0px';\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important'\n );\n });\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n selected.style.left = '0px';\n selected.style.position = 'absolute';\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width');\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`;\n });\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value\n });\n };\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Prepare the element for the enter animation\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`;\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n };\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`;\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1';\n element.style.position = 'absolute';\n element.style.transform = 'translateY(0)';\n });\n\n done();\n };\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n });\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs);\n };\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([]);\n });\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x\n };\n }\n });\n</script>\n\n<style lang=\"css\">\n .x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n }\n .x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n }\n .x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n }\n</style>\n"],"names":["_resolveComponent","_openBlock","_createBlock","buttonClass","showButtons","scrollContainerClass","_renderSlot","_withCtx","onBeforeEnter","onEnter","onLeave","_createElementBlock","_Fragment","_renderList","_normalizeClass","selectedPromptIndex","isAnimating","_normalizeStyle","onSelect","_createVNode"],"mappings":";;;;;;;;;kCACEA,gBA4Ee,CAAA,cAAA,CAAA,CAAA;SA1EZC,SAA8B,EAAA,EAAAC,WAAA,CAAA,uBAAA,EAAA;AAAA,IAC9B,GAAcC,EAAAA,IAAAA,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA,MAAAA;AAAAA,IACd,yBAAcC,EAAAA,KAAAA;AAAAA,IACd,cAAA,EAAA,IAAA,CAAA,WAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,WAAA,IAAA,IAAA,CAAA,mBAAA,KAAA,CAAA,CAAA;AAAqFC,IAAAA,wBAAAA,EAAAA;AAAAA,MAAAA,6CAAAA;;AAK3E,KAAA;AAAA,GAAA,EAAA;;MA4DAC,UAIiC,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,CAAA;AAAA,KAAA,CAAA;;MA3EhDA,UAsEuB,CAAA,IAAA,CAAA,MAAA,EAAA,4BAAA,CAAA;AAAA,KAAA,CAAA;AApDhB,IAAA,OAAA,EAAAC,OAAA,CAAY,MAAEC;AAAAA,MAAAA,WAAAA,CACPC,eAAO,EAAA;AAAA,QACd,aAAOC,E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,QAAA,CAAA,KAAA,CAAA;AAAA,kBAlBL,UAiBiB,EAAA,IAAA,CAAA,mBAAA,KAAA,KAAA;AAAA,iBAhBd,EAAA,MAAA;AAAA,kBAAAC,WAAA,CACA,yBAAa,EAAA;AAAA,oBAAA,OAAA,EAAA,aAAA,CAAA,OAAA,EAAA,qBAAA;;;;;;;AAOX,oBAAA,OAAA,EAAAZ,OAAA,CAAK,MAAEW;AAAAA,sBAAAA,WAAAA,CACP,wBAA6B,EAAA;AAAA,wBAC7B,OAAA,EAAQ,CAAEH,MAAAA,KAAAA,IAAAA,CAAAA,QAAAA,CAAmB,KAAK,CAAA;AAAA,wBAAA,gBAAA,EAAA,aAAA;wBAExB,QAA4B,EAAA,IAAA,CAAA,mBAAA,KAAA,KAAA;AAAA,uBAAA,EAAA;;AA/DrD,0BAAAT,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,8BAAA,EAAA,EAAA,aAAA,EAAA,CAAA;AAAA,yBAAA,CAAA;;;AAAA,uBAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,UAAA,CAAA,CAAA;AAAA,qBAAA,CAAA;;;AAAA,mBAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,eAAA,CAAA,CAAA;AAAA,iBAAA,CAAA;;AAAA,aAAA,CAAA;AAAA,YAAA,GAAA;AAAA;AAAA,WAAA;AAAA,SAAA,CAAA;;;AAAA,OAAA,EAAA,CAAA,EAAA,CAAA,eAAA,EAAA,SAAA,EAAA,SAAA,CAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -73,10 +73,12 @@ var _sfc_main = defineComponent({
73
73
  },
74
74
  setup(props) {
75
75
  const x = use$x();
76
- const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts', [
77
- 'relatedPrompts',
76
+ const relatedPrompts = useState('relatedPrompts', [
77
+ 'relatedPrompts'
78
+ ]).relatedPrompts;
79
+ const selectedPromptIndex = useState('relatedPrompts', [
78
80
  'selectedPrompt'
79
- ]);
81
+ ]).selectedPrompt;
80
82
  const clickedListItemIndex = ref(null);
81
83
  const initialOffsetLefts = {};
82
84
  const isAnimating = ref(false);
@@ -90,15 +92,10 @@ var _sfc_main = defineComponent({
90
92
  (clickedListItemIndex.value !== null
91
93
  ? relatedPrompts.value.length - 1
92
94
  : relatedPrompts.value.length));
93
- const indexRelatedPrompts = computed(() => relatedPrompts.value.map((relatedPrompt, index) => ({
94
- ...relatedPrompt,
95
- index
96
- })));
97
- const visibleRelatedPrompts = computed(() => {
98
- return selectedPromptIndex.value !== -1
99
- ? [indexRelatedPrompts.value[selectedPromptIndex.value]]
100
- : indexRelatedPrompts.value;
101
- });
95
+ const indexRelatedPrompts = computed(() => relatedPrompts.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })));
96
+ const visibleRelatedPrompts = computed(() => selectedPromptIndex.value !== -1
97
+ ? [indexRelatedPrompts.value[selectedPromptIndex.value]]
98
+ : indexRelatedPrompts.value);
102
99
  let timeOutId;
103
100
  const resetTransitionStyle = (excludedProperties = ['width']) => {
104
101
  if (timeOutId) {
@@ -201,14 +198,12 @@ var _sfc_main = defineComponent({
201
198
  // Wait for the animation to finish (done() exectution extracts the element from the DOM)
202
199
  setTimeout(done, props.animationDurationInMs);
203
200
  };
204
- const isSelected = (index) => selectedPromptIndex.value === index;
205
201
  // Changing the request will trigger the appear animation, so we need to reset the
206
202
  // style after it finishes
207
203
  x.on('SearchRequestChanged', false).subscribe(() => {
208
204
  resetTransitionStyle([]);
209
205
  });
210
206
  return {
211
- isSelected,
212
207
  onSelect,
213
208
  onBeforeEnter,
214
209
  onEnter,
@@ -1 +1 @@
1
- {"version":3,"file":"related-prompts-tag-list.vue2.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || ''\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"isAnimating && { pointerEvents: 'none' }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :relatedPrompt=\"relatedPrompt\"\n :onSelect=\"() => onSelect(index)\"\n :isSelected=\"isSelected(index)\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :eventMetadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false\n }\"\n >\n <RelatedPrompt\n @click=\"onSelect(index)\"\n :related-prompt=\"relatedPrompt\"\n :selected=\"isSelected(index)\"\n >\n <template #related-prompt-extra-content>\n <slot name=\"related-prompt-extra-content\" :relatedPrompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\n import { RelatedPrompt as RelatedPromptModel } from '@empathyco/x-types';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import SlidingPanel from '../../../components/sliding-panel.vue';\n import { relatedPromptsXModule } from '../x-module';\n import { use$x, useState } from '../../../composables';\n import DisplayEmitter from '../../../components/display-emitter.vue';\n import RelatedPrompt from './related-prompt.vue';\n\n /**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\n export default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700\n }\n },\n setup(props) {\n const x = use$x();\n const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts', [\n 'relatedPrompts',\n 'selectedPrompt'\n ]);\n\n const clickedListItemIndex = ref<number | null>(null);\n const initialOffsetLefts: Record<number, number> = {};\n const isAnimating = ref(false);\n const listItems = ref<HTMLElement[]>([]);\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!)\n )\n );\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length)\n );\n\n const indexRelatedPrompts = computed(() =>\n (relatedPrompts.value as RelatedPromptModel[]).map(\n (relatedPrompt: RelatedPromptModel, index: number) => ({\n ...relatedPrompt,\n index\n })\n )\n );\n\n const visibleRelatedPrompts = computed(() => {\n return selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value;\n });\n\n let timeOutId: number;\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId);\n }\n\n isAnimating.value = true;\n timeOutId = +setTimeout(() => {\n isAnimating.value = false;\n clickedListItemIndex.value = null;\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property);\n }\n });\n });\n }, props.animationDurationInMs);\n };\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle();\n\n clickedListItemIndex.value = selectedIndex;\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex\n )!;\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n initialOffsetLefts[index] = element.offsetLeft;\n element.style.left = `${element.offsetLeft}px`;\n element.style.position = 'absolute';\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n\n if (index !== selectedIndex) {\n element.style.opacity = '1';\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`;\n }\n });\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`;\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth;\n\n selected.style.left = '0px';\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important'\n );\n });\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n selected.style.left = '0px';\n selected.style.position = 'absolute';\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width');\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`;\n });\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value\n });\n };\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Prepare the element for the enter animation\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`;\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n };\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`;\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1';\n element.style.position = 'absolute';\n element.style.transform = 'translateY(0)';\n });\n\n done();\n };\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n });\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs);\n };\n\n const isSelected = (index: number): boolean => selectedPromptIndex.value === index;\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([]);\n });\n\n return {\n isSelected,\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x\n };\n }\n });\n</script>\n<style lang=\"css\">\n .x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n }\n .x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n }\n .x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n }\n</style>\n"],"names":["DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;AAsFE;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,kBAAEA,WAAc,EAAE,aAAa,EAAE,YAAW,EAAG;AAC3D,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,WAAW,EAAE,MAAM;AACnB;;;;AAIE;QACF,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;AAC7C;;;;AAIE;AACF,QAAA,oBAAoB,EAAE,MAAM;AAC5B;;;;AAIE;AACF,QAAA,QAAQ,EAAE,MAAM;AAChB;;;;;AAKE;AACF,QAAA,SAAS,EAAE,KAA2B;AACtC;;;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OAAM,GAAI,EAAiB,CAAA;;YAGjC,qBAAqB,CAAC,MAAM;AAC1B,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAQ,GAAE,GAAG,CAAA;AAC3B,gBAAA,OAAO,CAAC,KAAK,CAAC,YAAY,iBAAiB,CAAA;AAC7C,aAAC,CAAC,CAAA;;AAGF,YAAA,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAA;AAC/C,SAAC,CAAA;AAED,QAAA,MAAM,aAAa,CAAC,KAAa,KAAc,mBAAmB,CAAC,KAAM,KAAI,KAAK,CAAA;;;QAIlF,CAAC,CAAC,EAAE,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM;YAClD,oBAAoB,CAAC,EAAE,CAAC,CAAA;AAC1B,SAAC,CAAC,CAAA;QAEF,OAAO;YACL,UAAU;YACV,QAAQ;YACR,aAAa;YACb,OAAO;YACP,OAAO;YACP,mBAAmB;YACnB,qBAAqB;YACrB,SAAS;YACT,WAAW;YACX,CAAA;SACD,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
1
+ {"version":3,"file":"related-prompts-tag-list.vue2.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || ''\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' })\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :relatedPrompt=\"relatedPrompt\"\n :onSelect=\"() => onSelect(index)\"\n :isSelected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :eventMetadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false\n }\"\n >\n <RelatedPrompt\n @click=\"onSelect(index)\"\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n >\n <template #related-prompt-extra-content>\n <slot name=\"related-prompt-extra-content\" :relatedPrompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\n import { RelatedPrompt as RelatedPromptModel } from '@empathyco/x-types';\n import { computed, ComputedRef, defineComponent, PropType, ref } from 'vue';\n import SlidingPanel from '../../../components/sliding-panel.vue';\n import { relatedPromptsXModule } from '../x-module';\n import { use$x, useState } from '../../../composables';\n import DisplayEmitter from '../../../components/display-emitter.vue';\n import RelatedPrompt from './related-prompt.vue';\n\n /**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\n export default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700\n }\n },\n setup(props) {\n const x = use$x();\n const relatedPrompts: ComputedRef<RelatedPromptModel[]> = useState('relatedPrompts', [\n 'relatedPrompts'\n ]).relatedPrompts;\n const selectedPromptIndex: ComputedRef<number> = useState('relatedPrompts', [\n 'selectedPrompt'\n ]).selectedPrompt;\n\n const clickedListItemIndex = ref<number | null>(null);\n const initialOffsetLefts: Record<number, number> = {};\n const isAnimating = ref(false);\n const listItems = ref<HTMLElement[]>([]);\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!)\n )\n );\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length)\n );\n\n const indexRelatedPrompts = computed(() =>\n relatedPrompts.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index }))\n );\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value\n );\n\n let timeOutId: number;\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId);\n }\n\n isAnimating.value = true;\n timeOutId = +setTimeout(() => {\n isAnimating.value = false;\n clickedListItemIndex.value = null;\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property);\n }\n });\n });\n }, props.animationDurationInMs);\n };\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle();\n\n clickedListItemIndex.value = selectedIndex;\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex\n )!;\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n initialOffsetLefts[index] = element.offsetLeft;\n element.style.left = `${element.offsetLeft}px`;\n element.style.position = 'absolute';\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n\n if (index !== selectedIndex) {\n element.style.opacity = '1';\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`;\n }\n });\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`;\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth;\n\n selected.style.left = '0px';\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important'\n );\n });\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n selected.style.left = '0px';\n selected.style.position = 'absolute';\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width');\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`;\n });\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value\n });\n };\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Prepare the element for the enter animation\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`;\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`;\n };\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n const index = Number.parseInt(element.getAttribute('data-index')!);\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`;\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1';\n element.style.position = 'absolute';\n element.style.transform = 'translateY(0)';\n });\n\n done();\n };\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement;\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0';\n element.style.transform = 'translateY(5px)';\n });\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs);\n };\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([]);\n });\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x\n };\n }\n });\n</script>\n\n<style lang=\"css\">\n .x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n }\n .x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n }\n .x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n }\n</style>\n"],"names":["DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;AAyFE;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,kBAAEA,WAAc,EAAE,aAAa,EAAE,YAAW,EAAG;AAC3D,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,WAAW,EAAE,MAAM;AACnB;;;;AAIE;QACF,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;AAC7C;;;;AAIE;AACF,QAAA,oBAAoB,EAAE,MAAM;AAC5B;;;;AAIE;AACF,QAAA,QAAQ,EAAE,MAAM;AAChB;;;;;AAKE;AACF,QAAA,SAAS,EAAE,KAA2B;AACtC;;;;AAIE;AACF,QAAA,qBAAqB,EAAE;AACrB,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,GAAE;AACb,SAAA;AACD,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,CAAE,GAAE,KAAK,EAAE,CAAA;AACjB,QAAA,MAAM,cAAc,GAAsC,QAAQ,CAAC,gBAAgB,EAAE;YACnF,gBAAe;SAChB,CAAC,CAAC,cAAc,CAAA;AACjB,QAAA,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AC,CAAA;;;QAID,CAAC,CAAC,EAAE,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM;YAClD,oBAAoB,CAAC,EAAE,CAAC,CAAA;AAC1B,SAAC,CAAC,CAAA;QAEF,OAAO;YACL,QAAQ;YACR,aAAa;YACb,OAAO;YACP,OAAO;YACP,mBAAmB;YACnB,qBAAqB;YACrB,SAAS;YACT,WAAW;YACX,CAAA;SACD,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Default implementation setUrlParams.
3
+ *
4
+ * @param context - The context of the actions, provided by Vuex.
5
+ *
6
+ * @param urlParams - List of params from the url.
7
+ * @public
8
+ */
9
+ const setUrlParams = ({ commit }, { query, prompt }) => {
10
+ commit('setQuery', query);
11
+ commit('setSelectedPrompt', prompt);
12
+ };
13
+
14
+ export { setUrlParams };
15
+ //# sourceMappingURL=set-url-params.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-url-params.action.js","sources":["../../../../../../src/x-modules/related-prompts/store/actions/set-url-params.action.ts"],"sourcesContent":["import { RelatedPromptsXStoreModule } from '../types';\n\n/**\n * Default implementation setUrlParams.\n *\n * @param context - The context of the actions, provided by Vuex.\n *\n * @param urlParams - List of params from the url.\n * @public\n */\nexport const setUrlParams: RelatedPromptsXStoreModule['actions']['setUrlParams'] = (\n { commit },\n { query, prompt }\n) => {\n commit('setQuery', query);\n commit('setSelectedPrompt', prompt);\n};\n"],"names":[],"mappings":"AAEA;;;;;;;AAOG;AACI,MAAM,YAAY,GAA0D,CACjF,EAAE,MAAM,EAAE,EACV,EAAE,KAAK,EAAE,MAAM,EAAE,KACf;AACF,IAAA,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC1B,IAAA,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AACtC;;;;"}
@@ -8,7 +8,8 @@ import { relatedPromptsXStoreModule } from './module.js';
8
8
  * @internal
9
9
  */
10
10
  const relatedPromptsStoreEmitters = createStoreEmitters(relatedPromptsXStoreModule, {
11
- RelatedPromptsRequestUpdated: (_, getters) => getters.request
11
+ RelatedPromptsRequestUpdated: (_, getters) => getters.request,
12
+ SelectedRelatedPromptChanged: state => state.selectedPrompt
12
13
  });
13
14
 
14
15
  export { relatedPromptsStoreEmitters };
@@ -1 +1 @@
1
- {"version":3,"file":"emitters.js","sources":["../../../../../src/x-modules/related-prompts/store/emitters.ts"],"sourcesContent":["import { createStoreEmitters } from '../../../store';\nimport { relatedPromptsXStoreModule } from './module';\n\n/**\n * {@link StoreEmitters} For the related-prompts module.\n *\n * @internal\n */\nexport const relatedPromptsStoreEmitters = createStoreEmitters(relatedPromptsXStoreModule, {\n RelatedPromptsRequestUpdated: (_, getters) => getters.request\n});\n"],"names":[],"mappings":";;;;AAGA;;;;AAIG;AACU,MAAA,2BAA2B,GAAG,mBAAmB,CAAC,0BAA0B,EAAE;IACzF,4BAA4B,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO;AAC9D,CAAA;;;;"}
1
+ {"version":3,"file":"emitters.js","sources":["../../../../../src/x-modules/related-prompts/store/emitters.ts"],"sourcesContent":["import { createStoreEmitters } from '../../../store';\nimport { relatedPromptsXStoreModule } from './module';\n\n/**\n * {@link StoreEmitters} For the related-prompts module.\n *\n * @internal\n */\nexport const relatedPromptsStoreEmitters = createStoreEmitters(relatedPromptsXStoreModule, {\n RelatedPromptsRequestUpdated: (_, getters) => getters.request,\n SelectedRelatedPromptChanged: state => state.selectedPrompt\n});\n"],"names":[],"mappings":";;;;AAGA;;;;AAIG;AACU,MAAA,2BAA2B,GAAG,mBAAmB,CAAC,0BAA0B,EAAE;IACzF,4BAA4B,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO;AAC7D,IAAA,4BAA4B,EAAE,KAAK,IAAI,KAAK,CAAC,cAAc;AAC5D,CAAA;;;;"}
@@ -2,6 +2,7 @@ import { setStatus } from '../../../store/utils/status-store.utils.js';
2
2
  import { setQuery } from '../../../store/utils/query.utils.js';
3
3
  import { fetchAndSaveRelatedPrompts, cancelFetchAndSaveRelatedPrompts } from './actions/fetch-and-save-related-prompts.action.js';
4
4
  import { fetchRelatedPrompts } from './actions/fetch-related-prompts.action.js';
5
+ import { setUrlParams } from './actions/set-url-params.action.js';
5
6
  import { request } from './getters/request.getter.js';
6
7
 
7
8
  /**
@@ -31,12 +32,7 @@ const relatedPromptsXStoreModule = {
31
32
  state.relatedPrompts = products;
32
33
  },
33
34
  setSelectedPrompt(state, selectedPrompt) {
34
- if (state.selectedPrompt === selectedPrompt) {
35
- state.selectedPrompt = -1;
36
- }
37
- else {
38
- state.selectedPrompt = selectedPrompt;
39
- }
35
+ state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt;
40
36
  },
41
37
  setSelectedQuery(state, selectedQuery) {
42
38
  state.selectedQuery = selectedQuery;
@@ -53,7 +49,8 @@ const relatedPromptsXStoreModule = {
53
49
  actions: {
54
50
  fetchRelatedPrompts,
55
51
  fetchAndSaveRelatedPrompts,
56
- cancelFetchAndSaveRelatedPrompts
52
+ cancelFetchAndSaveRelatedPrompts,
53
+ setUrlParams
57
54
  }
58
55
  };
59
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"sourcesContent":["import { setStatus } from '../../../store/utils/status-store.utils';\nimport { setQuery } from '../../../store/utils/query.utils';\nimport { RelatedPromptsXStoreModule } from './types';\nimport {\n cancelFetchAndSaveRelatedPrompts,\n fetchAndSaveRelatedPrompts\n} from './actions/fetch-and-save-related-prompts.action';\nimport { fetchRelatedPrompts } from './actions/fetch-related-prompts.action';\nimport { request } from './getters/request.getter';\n\n/**\n * {@link XStoreModule} For the related prompt module.\n *\n * @internal\n */\nexport const relatedPromptsXStoreModule: RelatedPromptsXStoreModule = {\n state: () => ({\n query: '',\n relatedPrompts: [],\n selectedPrompt: -1,\n selectedQuery: -1,\n status: 'initial',\n params: {}\n }),\n getters: {\n request\n },\n mutations: {\n setStatus,\n setQuery,\n setParams(state, params) {\n state.params = params;\n },\n setRelatedPromptsProducts(state, products) {\n state.relatedPrompts = products;\n },\n setSelectedPrompt(state, selectedPrompt) {\n if (state.selectedPrompt === selectedPrompt) {\n state.selectedPrompt = -1;\n } else {\n state.selectedPrompt = selectedPrompt;\n }\n },\n setSelectedQuery(state, selectedQuery) {\n state.selectedQuery = selectedQuery;\n },\n resetRelatedPromptsState(state) {\n state.selectedQuery = -1;\n state.selectedPrompt = -1;\n state.relatedPrompts = [];\n },\n resetSelectedPrompt(state) {\n state.selectedPrompt = -1;\n }\n },\n actions: {\n fetchRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n cancelFetchAndSaveRelatedPrompts\n }\n};\n"],"names":[],"mappings":";;;;;;AAUA;;;;AAIG;AACU,MAAA,0BAA0B,GAA+B;AACpE,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,CAAC,CAAC;QAClB,aAAa,EAAE,CAAC,CAAC;AACjB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,MAAM,EAAE,EAAE;KACX,CAAC;AACF,IAAA,OAAO,EAAE;QACP,OAAO;AACR,KAAA;AACD,IAAA,SAAS,EAAE;QACT,SAAS;QACT,QAAQ;QACR,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;QACD,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAA;AACvC,YAAA,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAC;SACjC;QACD,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAA;AACrC,YAAA,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc,EAAE;AAC3C,gBAAA,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;AAC3B,aAAA;AAAM,iBAAA;AACL,gBAAA,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;AACvC,aAAA;SACF;QACD,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAA;AACnC,YAAA,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;SACrC;AACD,QAAA,wBAAwB,CAAC,KAAK,EAAA;AAC5B,YAAA,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;AACzB,YAAA,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;AAC1B,YAAA,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC;SAC3B;AACD,QAAA,mBAAmB,CAAC,KAAK,EAAA;AACvB,YAAA,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;SAC3B;AACF,KAAA;AACD,IAAA,OAAO,EAAE;QACP,mBAAmB;QACnB,0BAA0B;QAC1B,gCAAgC;AACjC,KAAA;;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"sourcesContent":["import { setStatus } from '../../../store/utils/status-store.utils';\nimport { setQuery } from '../../../store/utils/query.utils';\nimport { RelatedPromptsXStoreModule } from './types';\nimport {\n cancelFetchAndSaveRelatedPrompts,\n fetchAndSaveRelatedPrompts\n} from './actions/fetch-and-save-related-prompts.action';\nimport { fetchRelatedPrompts } from './actions/fetch-related-prompts.action';\nimport { setUrlParams } from './actions/set-url-params.action';\nimport { request } from './getters/request.getter';\n\n/**\n * {@link XStoreModule} For the related prompt module.\n *\n * @internal\n */\nexport const relatedPromptsXStoreModule: RelatedPromptsXStoreModule = {\n state: () => ({\n query: '',\n relatedPrompts: [],\n selectedPrompt: -1,\n selectedQuery: -1,\n status: 'initial',\n params: {}\n }),\n getters: {\n request\n },\n mutations: {\n setStatus,\n setQuery,\n setParams(state, params) {\n state.params = params;\n },\n setRelatedPromptsProducts(state, products) {\n state.relatedPrompts = products;\n },\n setSelectedPrompt(state, selectedPrompt) {\n state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt;\n },\n setSelectedQuery(state, selectedQuery) {\n state.selectedQuery = selectedQuery;\n },\n resetRelatedPromptsState(state) {\n state.selectedQuery = -1;\n state.selectedPrompt = -1;\n state.relatedPrompts = [];\n },\n resetSelectedPrompt(state) {\n state.selectedPrompt = -1;\n }\n },\n actions: {\n fetchRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n cancelFetchAndSaveRelatedPrompts,\n setUrlParams\n }\n};\n"],"names":[],"mappings":";;;;;;;AAWA;;;;AAIG;AACU,MAAA,0BAA0B,GAA+B;AACpE,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,CAAC,CAAC;QAClB,aAAa,EAAE,CAAC,CAAC;AACjB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,MAAM,EAAE,EAAE;KACX,CAAC;AACF,IAAA,OAAO,EAAE;QACP,OAAO;AACR,KAAA;AACD,IAAA,SAAS,EAAE;QACT,SAAS;QACT,QAAQ;QACR,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;QACD,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAA;AACvC,YAAA,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAC;SACjC;QACD,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAA;AACrC,YAAA,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,KAAK,cAAc,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC;SACtF;QACD,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAA;AACnC,YAAA,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;SACrC;AACD,QAAA,wBAAwB,CAAC,KAAK,EAAA;AAC5B,YAAA,KAAK,CAAC,aAAa,GAAG,CAAC,C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