@empathyco/x-components 6.0.0-alpha.217 → 6.0.0-alpha.219

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 (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/API-reference/api/x-components.aixevents.aicomponentmounted.md +11 -0
  3. package/docs/API-reference/api/x-components.aixevents.md +1 -1
  4. package/docs/API-reference/api/x-components.baseeventsmodalclose.md +1 -1
  5. package/docs/API-reference/api/x-components.baseeventsmodalopen.md +1 -1
  6. package/docs/API-reference/api/x-components.hierarchicalfilter.md +1 -1
  7. package/docs/API-reference/api/x-components.md +2 -0
  8. package/docs/API-reference/api/x-components.simplefilter.md +1 -1
  9. package/docs/API-reference/api/x-components.snippetcallbacks.md +1 -1
  10. package/docs/API-reference/api/x-components.typinghtmlelement.md +2 -0
  11. package/docs/API-reference/api/x-types.aisuggestionquery.categories.md +11 -0
  12. package/docs/API-reference/api/x-types.aisuggestionquery.md +73 -0
  13. package/docs/API-reference/api/x-types.aisuggestionquery.query.md +11 -0
  14. package/docs/API-reference/api/x-types.aisuggestiontagging.md +90 -0
  15. package/docs/API-reference/api/x-types.aisuggestiontagging.searchqueries.md +15 -0
  16. package/docs/API-reference/api/x-types.aisuggestiontagging.toolingdisplay.md +11 -0
  17. package/docs/API-reference/api/x-types.aisuggestiontagging.toolingdisplayclick.md +11 -0
  18. package/docs/API-reference/api/x-types.md +22 -0
  19. package/js/directives/typing.js +1 -1
  20. package/js/directives/typing.js.map +1 -1
  21. package/js/plugins/x-plugin.js +1 -2
  22. package/js/plugins/x-plugin.js.map +1 -1
  23. package/js/utils/storage.js +3 -4
  24. package/js/utils/storage.js.map +1 -1
  25. package/js/x-modules/ai/components/ai-carousel.vue.js.map +1 -1
  26. package/js/x-modules/ai/components/ai-carousel.vue2.js +4 -1
  27. package/js/x-modules/ai/components/ai-carousel.vue2.js.map +1 -1
  28. package/js/x-modules/ai/components/ai-overview.vue.js.map +1 -1
  29. package/js/x-modules/ai/components/ai-overview.vue2.js +1 -1
  30. package/js/x-modules/ai/components/ai-overview.vue2.js.map +1 -1
  31. package/js/x-modules/ai/wiring.js +1 -1
  32. package/js/x-modules/ai/wiring.js.map +1 -1
  33. package/js/x-modules/tagging/service/external-tagging.service.js +1 -2
  34. package/js/x-modules/tagging/service/external-tagging.service.js.map +1 -1
  35. package/package.json +7 -10
  36. package/report/x-adapter-platform.api.json +2 -2
  37. package/report/x-components.api.json +13 -13
  38. package/report/x-components.api.md +9 -9
  39. package/report/x-types.api.json +205 -0
  40. package/types/components/modals/base-events-modal-close.vue.d.ts +1 -1
  41. package/types/components/modals/base-events-modal-open.vue.d.ts +1 -1
  42. package/types/components/snippet-callbacks.vue.d.ts +1 -1
  43. package/types/directives/typing.d.ts +4 -2
  44. package/types/directives/typing.d.ts.map +1 -1
  45. package/types/plugins/x-plugin.d.ts.map +1 -1
  46. package/types/utils/storage.d.ts +3 -4
  47. package/types/utils/storage.d.ts.map +1 -1
  48. package/types/x-modules/ai/components/ai-carousel.vue.d.ts.map +1 -1
  49. package/types/x-modules/ai/events.types.d.ts +1 -1
  50. package/types/x-modules/ai/events.types.d.ts.map +1 -1
  51. package/types/x-modules/ai/wiring.d.ts +1 -1
  52. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +1 -1
  53. package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts +1 -1
  54. package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts.map +1 -1
  55. package/types/x-modules/tagging/service/external-tagging.service.d.ts +1 -1
  56. package/types/x-modules/tagging/service/external-tagging.service.d.ts.map +1 -1
  57. package/docs/API-reference/api/x-components.aixevents.aioverviewmounted.md +0 -11
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.0.0-alpha.219 (2026-03-09)
7
+
8
+ - feat(deep-merge-storage-service): clean up deep-merge and storage-service deps and side effects (#20 ([668130c](https://github.com/empathyco/x/commit/668130c)), closes [#2048](https://github.com/empathyco/x/issues/2048)
9
+
10
+ ## 6.0.0-alpha.218 (2026-03-05)
11
+
12
+ - fix: rename `AiOverviewMounted` to `AiComponentMounted` across components, tests, and wiring (#2044) ([28b3c10](https://github.com/empathyco/x/commit/28b3c10)), closes [#2044](https://github.com/empathyco/x/issues/2044)
13
+
6
14
  ## 6.0.0-alpha.217 (2026-03-05)
7
15
 
8
16
  - feat(x-utils): recover cjs bundler ([5f9dd59](https://github.com/empathyco/x/commit/5f9dd59))
@@ -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; [AiXEvents](./x-components.aixevents.md) &gt; [AiComponentMounted](./x-components.aixevents.aicomponentmounted.md)
4
+
5
+ ## AiXEvents.AiComponentMounted property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ AiComponentMounted: void;
11
+ ```
@@ -37,7 +37,7 @@ Description
37
37
  </th></tr></thead>
38
38
  <tbody><tr><td>
39
39
 
40
- [AiOverviewMounted](./x-components.aixevents.aioverviewmounted.md)
40
+ [AiComponentMounted](./x-components.aixevents.aicomponentmounted.md)
41
41
 
42
42
 
43
43
  </td><td>
@@ -22,7 +22,7 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
22
22
  default: string;
23
23
  };
24
24
  }>> & Readonly<{}>, {
25
- closingEvent: "UserClickedCloseEventsModal" | "UserClickedCloseX" | "UserClickedOutOfMainModal" | "UserClickedOpenEventsModal" | "UserClickedOpenX" | "UserClickedOutOfEventsModal" | "UserOpenXProgrammatically" | "UserReachedEmpathizeTop" | "EmpathizeClosed" | "EmpathizeOpened" | "UserClosedEmpathize" | "UserPressedClearHistoryQueries" | "UserClickedEnableHistoryQueries" | "UserClickedDisableHistoryQueries" | "UserClickedConfirmDisableHistoryQueries" | "UserClickedDismissDisableHistoryQueries" | "ScrollRestoreSucceeded" | "ScrollRestoreFailed" | "UserHoveredInSearchBox" | "UserHoveredOutSearchBox" | "UserBlurredSearchBox" | "UserClickedSearchBox" | "UserFocusedSearchBox" | "UserPressedClearSearchBoxButton" | "ReloadSearchRequested" | "UserReachedResultsListEnd" | "UserClickedAbortARedirection" | "RelatedPromptsUnmounted" | "ReloadRelatedPromptsRequested" | "AiOverviewMounted";
25
+ closingEvent: "UserClickedCloseEventsModal" | "UserClickedCloseX" | "UserClickedOutOfMainModal" | "UserClickedOpenEventsModal" | "UserClickedOpenX" | "UserClickedOutOfEventsModal" | "UserOpenXProgrammatically" | "UserReachedEmpathizeTop" | "EmpathizeClosed" | "EmpathizeOpened" | "UserClosedEmpathize" | "UserPressedClearHistoryQueries" | "UserClickedEnableHistoryQueries" | "UserClickedDisableHistoryQueries" | "UserClickedConfirmDisableHistoryQueries" | "UserClickedDismissDisableHistoryQueries" | "ScrollRestoreSucceeded" | "ScrollRestoreFailed" | "UserHoveredInSearchBox" | "UserHoveredOutSearchBox" | "UserBlurredSearchBox" | "UserClickedSearchBox" | "UserFocusedSearchBox" | "UserPressedClearSearchBoxButton" | "ReloadSearchRequested" | "UserReachedResultsListEnd" | "UserClickedAbortARedirection" | "RelatedPromptsUnmounted" | "ReloadRelatedPromptsRequested" | "AiComponentMounted";
26
26
  }, {}, {
27
27
  BaseEventButton: import("vue").DefineComponent<{}, {}, any>;
28
28
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
@@ -22,7 +22,7 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
22
22
  default: string;
23
23
  };
24
24
  }>> & Readonly<{}>, {
25
- openingEvent: "UserClickedCloseEventsModal" | "UserClickedCloseX" | "UserClickedOutOfMainModal" | "UserClickedOpenEventsModal" | "UserClickedOpenX" | "UserClickedOutOfEventsModal" | "UserOpenXProgrammatically" | "UserReachedEmpathizeTop" | "EmpathizeClosed" | "EmpathizeOpened" | "UserClosedEmpathize" | "UserPressedClearHistoryQueries" | "UserClickedEnableHistoryQueries" | "UserClickedDisableHistoryQueries" | "UserClickedConfirmDisableHistoryQueries" | "UserClickedDismissDisableHistoryQueries" | "ScrollRestoreSucceeded" | "ScrollRestoreFailed" | "UserHoveredInSearchBox" | "UserHoveredOutSearchBox" | "UserBlurredSearchBox" | "UserClickedSearchBox" | "UserFocusedSearchBox" | "UserPressedClearSearchBoxButton" | "ReloadSearchRequested" | "UserReachedResultsListEnd" | "UserClickedAbortARedirection" | "RelatedPromptsUnmounted" | "ReloadRelatedPromptsRequested" | "AiOverviewMounted";
25
+ openingEvent: "UserClickedCloseEventsModal" | "UserClickedCloseX" | "UserClickedOutOfMainModal" | "UserClickedOpenEventsModal" | "UserClickedOpenX" | "UserClickedOutOfEventsModal" | "UserOpenXProgrammatically" | "UserReachedEmpathizeTop" | "EmpathizeClosed" | "EmpathizeOpened" | "UserClosedEmpathize" | "UserPressedClearHistoryQueries" | "UserClickedEnableHistoryQueries" | "UserClickedDisableHistoryQueries" | "UserClickedConfirmDisableHistoryQueries" | "UserClickedDismissDisableHistoryQueries" | "ScrollRestoreSucceeded" | "ScrollRestoreFailed" | "UserHoveredInSearchBox" | "UserHoveredOutSearchBox" | "UserBlurredSearchBox" | "UserClickedSearchBox" | "UserFocusedSearchBox" | "UserPressedClearSearchBoxButton" | "ReloadSearchRequested" | "UserReachedResultsListEnd" | "UserClickedAbortARedirection" | "RelatedPromptsUnmounted" | "ReloadRelatedPromptsRequested" | "AiComponentMounted";
26
26
  }, {}, {
27
27
  BaseEventButton: import("vue").DefineComponent<{}, {}, any>;
28
28
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
@@ -198,7 +198,7 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
198
198
  AiSuggestionsSearchChanged?: import("@empathyco/x-types").AiSuggestionSearch[] | undefined;
199
199
  UserClickedAiOverviewExpandButton?: boolean | undefined;
200
200
  UserClickedAnAiOverviewResult?: import("@empathyco/x-types").Result | undefined;
201
- AiOverviewMounted?: void | undefined;
201
+ AiComponentMounted?: void | undefined;
202
202
  }>;
203
203
  innerCssClasses: import("vue").ComputedRef<(string | Dictionary<boolean>)[]>;
204
204
  renderedChildrenFilters: import("vue").ComputedRef<HierarchicalFilterModel[]>;
@@ -3130,6 +3130,8 @@ Options for wire operators that delay subscribers.
3130
3130
 
3131
3131
  </td><td>
3132
3132
 
3133
+ TypingHTMLElement interface.
3134
+
3133
3135
 
3134
3136
  </td></tr>
3135
3137
  <tr><td>
@@ -195,7 +195,7 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
195
195
  AiSuggestionsSearchChanged?: import("@empathyco/x-types").AiSuggestionSearch[] | undefined;
196
196
  UserClickedAiOverviewExpandButton?: boolean | undefined;
197
197
  UserClickedAnAiOverviewResult?: import("@empathyco/x-types").Result | undefined;
198
- AiOverviewMounted?: void | undefined;
198
+ AiComponentMounted?: void | undefined;
199
199
  }>;
200
200
  innerCssClasses: import("vue").ComputedRef<(string | Dictionary<boolean>)[]>;
201
201
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -185,7 +185,7 @@ _default: import("vue").DefineComponent<{}, {
185
185
  AiSuggestionsSearchChanged: (payload: import("@empathyco/x-types").AiSuggestionSearch[], metadata: WireMetadata) => unknown;
186
186
  UserClickedAiOverviewExpandButton: (payload: boolean, metadata: WireMetadata) => unknown;
187
187
  UserClickedAnAiOverviewResult: (payload: import("@empathyco/x-types").Result, metadata: WireMetadata) => unknown;
188
- AiOverviewMounted: (payload: undefined, metadata: WireMetadata) => unknown;
188
+ AiComponentMounted: (payload: undefined, metadata: WireMetadata) => unknown;
189
189
  }>>;
190
190
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {
191
191
  GlobalXBus: import("vue").DefineComponent<{}, {}, any>;
@@ -4,6 +4,8 @@
4
4
 
5
5
  ## TypingHTMLElement interface
6
6
 
7
+ TypingHTMLElement interface.
8
+
7
9
  **Signature:**
8
10
 
9
11
  ```typescript
@@ -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-types](./x-types.md) &gt; [AiSuggestionQuery](./x-types.aisuggestionquery.md) &gt; [categories](./x-types.aisuggestionquery.categories.md)
4
+
5
+ ## AiSuggestionQuery.categories property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ categories: string[];
11
+ ```
@@ -0,0 +1,73 @@
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; [AiSuggestionQuery](./x-types.aisuggestionquery.md)
4
+
5
+ ## AiSuggestionQuery interface
6
+
7
+ Data for each query suggested.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export interface AiSuggestionQuery
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Property
20
+
21
+
22
+ </th><th>
23
+
24
+ Modifiers
25
+
26
+
27
+ </th><th>
28
+
29
+ Type
30
+
31
+
32
+ </th><th>
33
+
34
+ Description
35
+
36
+
37
+ </th></tr></thead>
38
+ <tbody><tr><td>
39
+
40
+ [categories](./x-types.aisuggestionquery.categories.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ string\[\]
49
+
50
+
51
+ </td><td>
52
+
53
+
54
+ </td></tr>
55
+ <tr><td>
56
+
57
+ [query](./x-types.aisuggestionquery.query.md)
58
+
59
+
60
+ </td><td>
61
+
62
+
63
+ </td><td>
64
+
65
+ string
66
+
67
+
68
+ </td><td>
69
+
70
+
71
+ </td></tr>
72
+ </tbody></table>
73
+
@@ -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-types](./x-types.md) &gt; [AiSuggestionQuery](./x-types.aisuggestionquery.md) &gt; [query](./x-types.aisuggestionquery.query.md)
4
+
5
+ ## AiSuggestionQuery.query property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ query: string;
11
+ ```
@@ -0,0 +1,90 @@
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; [AiSuggestionTagging](./x-types.aisuggestiontagging.md)
4
+
5
+ ## AiSuggestionTagging interface
6
+
7
+ Interface for the AI suggestion tagging.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export interface AiSuggestionTagging
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Property
20
+
21
+
22
+ </th><th>
23
+
24
+ Modifiers
25
+
26
+
27
+ </th><th>
28
+
29
+ Type
30
+
31
+
32
+ </th><th>
33
+
34
+ Description
35
+
36
+
37
+ </th></tr></thead>
38
+ <tbody><tr><td>
39
+
40
+ [searchQueries](./x-types.aisuggestiontagging.searchqueries.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ Record&lt;string, { toolingDisplay: [TaggingRequest](./x-types.taggingrequest.md)<!-- -->; toolingDisplayClick: [TaggingRequest](./x-types.taggingrequest.md)<!-- -->; toolingDisplayAdd2Cart: [TaggingRequest](./x-types.taggingrequest.md)<!-- -->; }&gt;
49
+
50
+
51
+ </td><td>
52
+
53
+
54
+ </td></tr>
55
+ <tr><td>
56
+
57
+ [toolingDisplay](./x-types.aisuggestiontagging.toolingdisplay.md)
58
+
59
+
60
+ </td><td>
61
+
62
+
63
+ </td><td>
64
+
65
+ [TaggingRequest](./x-types.taggingrequest.md)
66
+
67
+
68
+ </td><td>
69
+
70
+
71
+ </td></tr>
72
+ <tr><td>
73
+
74
+ [toolingDisplayClick](./x-types.aisuggestiontagging.toolingdisplayclick.md)
75
+
76
+
77
+ </td><td>
78
+
79
+
80
+ </td><td>
81
+
82
+ [TaggingRequest](./x-types.taggingrequest.md)
83
+
84
+
85
+ </td><td>
86
+
87
+
88
+ </td></tr>
89
+ </tbody></table>
90
+
@@ -0,0 +1,15 @@
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; [AiSuggestionTagging](./x-types.aisuggestiontagging.md) &gt; [searchQueries](./x-types.aisuggestiontagging.searchqueries.md)
4
+
5
+ ## AiSuggestionTagging.searchQueries property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ searchQueries: Record<string, {
11
+ toolingDisplay: TaggingRequest;
12
+ toolingDisplayClick: TaggingRequest;
13
+ toolingDisplayAdd2Cart: TaggingRequest;
14
+ }>;
15
+ ```
@@ -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-types](./x-types.md) &gt; [AiSuggestionTagging](./x-types.aisuggestiontagging.md) &gt; [toolingDisplay](./x-types.aisuggestiontagging.toolingdisplay.md)
4
+
5
+ ## AiSuggestionTagging.toolingDisplay property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ toolingDisplay: TaggingRequest;
11
+ ```
@@ -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-types](./x-types.md) &gt; [AiSuggestionTagging](./x-types.aisuggestiontagging.md) &gt; [toolingDisplayClick](./x-types.aisuggestiontagging.toolingdisplayclick.md)
4
+
5
+ ## AiSuggestionTagging.toolingDisplayClick property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ toolingDisplayClick: TaggingRequest;
11
+ ```
@@ -191,6 +191,17 @@ Request for the question endpoint.
191
191
  Response for the question endpoint.
192
192
 
193
193
 
194
+ </td></tr>
195
+ <tr><td>
196
+
197
+ [AiSuggestionQuery](./x-types.aisuggestionquery.md)
198
+
199
+
200
+ </td><td>
201
+
202
+ Data for each query suggested.
203
+
204
+
194
205
  </td></tr>
195
206
  <tr><td>
196
207
 
@@ -235,6 +246,17 @@ Request for the suggestions-search endpoint.
235
246
  Response for the AI suggestions search endpoint.
236
247
 
237
248
 
249
+ </td></tr>
250
+ <tr><td>
251
+
252
+ [AiSuggestionTagging](./x-types.aisuggestiontagging.md)
253
+
254
+
255
+ </td><td>
256
+
257
+ Interface for the AI suggestion tagging.
258
+
259
+
238
260
  </td></tr>
239
261
  <tr><td>
240
262
 
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Typing directive.
3
- *
4
3
  * @public
5
4
  */
6
5
  const typing = {
@@ -22,6 +21,7 @@ const typing = {
22
21
  *
23
22
  * @param el - The HTML element where the typing animation will be displayed.
24
23
  * @param options - Options for the behavior of the animation.
24
+ * @internal
25
25
  */
26
26
  function execute(el, options) {
27
27
  const { text, speed = 1, targetAttr = '' } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"typing.js","sources":["../../../src/directives/typing.ts"],"sourcesContent":["import type { Directive } from 'vue'\n\n/**\n * TypingOptions interface.\n *\n * @public\n */\nexport interface TypingOptions {\n /**\n * The text (plain or html) that will be typed into the target element.\n */\n text: string\n /**\n * The typing speed in milliseconds per character.\n *\n */\n speed?: number\n /**\n * The attribute of the HTML element where the typed text will be placed.\n * If not specified, the text will be set as content (innerHTML).\n *\n * @example 'placeholder'\n */\n targetAttr?: string\n}\n\nexport interface TypingHTMLElement extends HTMLElement {\n __timeoutId?: number\n}\n\n/**\n * Typing directive.\n *\n * @public\n */\nexport const typing: Directive<TypingHTMLElement, TypingOptions> = {\n mounted(el, binding) {\n execute(el, binding.value)\n },\n\n updated(el, binding) {\n if (binding.value.text !== binding.oldValue?.text) {\n clearTimeout(el.__timeoutId)\n execute(el, binding.value)\n }\n },\n\n unmounted(el) {\n clearTimeout(el.__timeoutId)\n },\n}\n\n/**\n * Execute a typing animation in an HTML element.\n *\n * @param el - The HTML element where the typing animation will be displayed.\n * @param options - Options for the behavior of the animation.\n */\nfunction execute(el: TypingHTMLElement, options: TypingOptions) {\n const { text, speed = 1, targetAttr = '' } = options\n\n if (!text) {\n console.error('v-typing: \"text\" is required.')\n return\n }\n\n let index = 0\n\n const updateContent = (value: string) => {\n if (targetAttr) {\n el.setAttribute(targetAttr, value)\n } else {\n el.innerHTML = value\n }\n }\n\n const type = () => {\n if (index < text.length) {\n updateContent(text.slice(0, index + 1))\n index++\n el.__timeoutId = setTimeout(type, speed) as unknown as number\n } else {\n updateContent(text)\n clearTimeout(el.__timeoutId)\n el.__timeoutId = undefined\n }\n }\n\n type()\n}\n"],"names":[],"mappings":"AA8BA;;;;AAIG;AACI,MAAM,MAAM,GAAgD;IACjE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAA;AACjB,QAAA,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,EAAE,EAAE,OAAO,EAAA;AACjB,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE;AACjD,YAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;AAC5B,YAAA,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;QAC5B;IACF,CAAC;AAED,IAAA,SAAS,CAAC,EAAE,EAAA;AACV,QAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;IAC9B,CAAC;;AAGH;;;;;AAKG;AACH,SAAS,OAAO,CAAC,EAAqB,EAAE,OAAsB,EAAA;AAC5D,IAAA,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO;IAEpD,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC;QAC9C;IACF;IAEA,IAAI,KAAK,GAAG,CAAC;AAEb,IAAA,MAAM,aAAa,GAAG,CAAC,KAAa,KAAI;QACtC,IAAI,UAAU,EAAE;AACd,YAAA,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC;QACpC;aAAO;AACL,YAAA,EAAE,CAAC,SAAS,GAAG,KAAK;QACtB;AACF,IAAA,CAAC;IAED,MAAM,IAAI,GAAG,MAAK;AAChB,QAAA,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;AACvB,YAAA,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACvC,YAAA,KAAK,EAAE;YACP,EAAE,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAsB;QAC/D;aAAO;YACL,aAAa,CAAC,IAAI,CAAC;AACnB,YAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;AAC5B,YAAA,EAAE,CAAC,WAAW,GAAG,SAAS;QAC5B;AACF,IAAA,CAAC;AAED,IAAA,IAAI,EAAE;AACR;;;;"}
1
+ {"version":3,"file":"typing.js","sources":["../../../src/directives/typing.ts"],"sourcesContent":["import type { Directive } from 'vue'\n\n/**\n * TypingOptions interface.\n * @public\n */\nexport interface TypingOptions {\n /**\n * The text (plain or html) that will be typed into the target element.\n */\n text: string\n /**\n * The typing speed in milliseconds per character.\n *\n */\n speed?: number\n /**\n * The attribute of the HTML element where the typed text will be placed.\n * If not specified, the text will be set as content (innerHTML).\n *\n * @example 'placeholder'\n */\n targetAttr?: string\n}\n\n/**\n * TypingHTMLElement interface.\n * @public\n */\nexport interface TypingHTMLElement extends HTMLElement {\n __timeoutId?: number\n}\n\n/**\n * Typing directive.\n * @public\n */\nexport const typing: Directive<TypingHTMLElement, TypingOptions> = {\n mounted(el, binding) {\n execute(el, binding.value)\n },\n\n updated(el, binding) {\n if (binding.value.text !== binding.oldValue?.text) {\n clearTimeout(el.__timeoutId)\n execute(el, binding.value)\n }\n },\n\n unmounted(el) {\n clearTimeout(el.__timeoutId)\n },\n}\n\n/**\n * Execute a typing animation in an HTML element.\n *\n * @param el - The HTML element where the typing animation will be displayed.\n * @param options - Options for the behavior of the animation.\n * @internal\n */\nfunction execute(el: TypingHTMLElement, options: TypingOptions) {\n const { text, speed = 1, targetAttr = '' } = options\n\n if (!text) {\n console.error('v-typing: \"text\" is required.')\n return\n }\n\n let index = 0\n\n const updateContent = (value: string) => {\n if (targetAttr) {\n el.setAttribute(targetAttr, value)\n } else {\n el.innerHTML = value\n }\n }\n\n const type = () => {\n if (index < text.length) {\n updateContent(text.slice(0, index + 1))\n index++\n el.__timeoutId = setTimeout(type, speed) as unknown as number\n } else {\n updateContent(text)\n clearTimeout(el.__timeoutId)\n el.__timeoutId = undefined\n }\n }\n\n type()\n}\n"],"names":[],"mappings":"AAiCA;;;AAGG;AACI,MAAM,MAAM,GAAgD;IACjE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAA;AACjB,QAAA,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,EAAE,EAAE,OAAO,EAAA;AACjB,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE;AACjD,YAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;AAC5B,YAAA,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;QAC5B;IACF,CAAC;AAED,IAAA,SAAS,CAAC,EAAE,EAAA;AACV,QAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;IAC9B,CAAC;;AAGH;;;;;;AAMG;AACH,SAAS,OAAO,CAAC,EAAqB,EAAE,OAAsB,EAAA;AAC5D,IAAA,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO;IAEpD,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC;QAC9C;IACF;IAEA,IAAI,KAAK,GAAG,CAAC;AAEb,IAAA,MAAM,aAAa,GAAG,CAAC,KAAa,KAAI;QACtC,IAAI,UAAU,EAAE;AACd,YAAA,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC;QACpC;aAAO;AACL,YAAA,EAAE,CAAC,SAAS,GAAG,KAAK;QACtB;AACF,IAAA,CAAC;IAED,MAAM,IAAI,GAAG,MAAK;AAChB,QAAA,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;AACvB,YAAA,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACvC,YAAA,KAAK,EAAE;YACP,EAAE,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAsB;QAC/D;aAAO;YACL,aAAa,CAAC,IAAI,CAAC;AACnB,YAAA,YAAY,CAAC,EAAE,CAAC,WAAW,CAAC;AAC5B,YAAA,EAAE,CAAC,WAAW,GAAG,SAAS;QAC5B;AACF,IAAA,CAAC;AAED,IAAA,IAAI,EAAE;AACR;;;;"}
@@ -1,5 +1,4 @@
1
- import { deepMerge } from '@empathyco/x-deep-merge';
2
- import { forEach } from '@empathyco/x-utils';
1
+ import { deepMerge, forEach } from '@empathyco/x-utils';
3
2
  import { createStore } from 'vuex';
4
3
  import { cleanGettersProxyCache } from '../store/utils/getters-proxy.utils.js';
5
4
  import { RootXStoreModule } from '../store/x.module.js';
@@ -1 +1 @@
1
- {"version":3,"file":"x-plugin.js","sources":["../../../src/plugins/x-plugin.ts"],"sourcesContent":["import type { XComponentsAdapter } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { Observable } from 'rxjs'\nimport type { App } from 'vue'\nimport type { Module, Store } from 'vuex'\nimport type { AnyXStoreModule, RootXStoreState } from '../store/store.types'\nimport type { XEvent, XEventsTypes } from '../wiring/events.types'\nimport type { AnyWire, WireMetadata } from '../wiring/wiring.types'\nimport type { EventPayload, SubjectPayload, XBus } from '../x-bus'\nimport type { AnyXModule, XModuleName } from '../x-modules/x-modules.types'\nimport type { AnyXStoreModuleOption, XModuleOptions, XPluginOptions } from './x-plugin.types'\nimport { deepMerge } from '@empathyco/x-deep-merge'\nimport { forEach } from '@empathyco/x-utils'\nimport { createStore } from 'vuex'\nimport { cleanGettersProxyCache } from '../store/utils/getters-proxy.utils'\nimport { RootXStoreModule } from '../store/x.module'\nimport { sendWiringToDevtools } from './devtools/wiring.devtools'\nimport { bus } from './x-bus'\nimport { registerStoreEmitters } from './x-emitters'\nimport { assertXPluginOptionsAreValid } from './x-plugin.utils'\n\n/**\n * Vue plugin that initializes the properties needed by the x-components, and exposes the events bus\n * and the adapter after it has been installed.\n *\n * @public\n */\nexport class XPlugin {\n /**\n * XComponentsAdapter Is the middleware between the components and our API where data can be\n * mapped to client needs.\n * This property is only available after installing the plugin.\n *\n * @returns The installed adapter.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get adapter(): XComponentsAdapter {\n return this.getInstance().adapter\n }\n\n /**\n * Exposed XBus, so any kind of application can subscribe to\n * {@link XEventsTypes} without having to pass through a component.\n * This property is only available after installing the plugin.\n *\n * @returns The installed bus.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get bus(): XBus<XEventsTypes, WireMetadata> {\n return this.getInstance().bus\n }\n\n /**\n * {@link https://vuex.vuejs.org | Vuex Store} Is the place where all shared data\n * is saved.\n *\n * @returns The installed store.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get store(): Store<RootXStoreState> {\n return this.getInstance().store\n }\n\n /**\n * Safely retrieves the installed instance of the XPlugin.\n *\n * @returns The installed instance of the XPlugin.\n * @throws If this method is called before calling `Vue.use(xPlugin)`.\n * @internal\n */\n protected static getInstance(): XPlugin {\n if (!this.instance) {\n throw new Error(\"XPlugin must be installed before accessing it's API.\")\n }\n return this.instance\n }\n\n /**\n * Record of modules that have been tried to be installed before the installation of the plugin.\n *\n * @internal\n */\n protected static pendingXModules: Partial<Record<XModuleName, AnyXModule>> = {}\n\n /**\n * Instance of the installed plugin. Used to expose the bus and the adapter.\n *\n * @internal\n */\n protected static instance?: XPlugin\n\n public wiring: Partial<Record<XModuleName, Partial<Record<XEvent, string[]>>>> = {}\n /**\n * Bus for retrieving the observables when registering the wiring.\n *\n * @internal\n */\n protected bus: XBus<XEventsTypes, WireMetadata>\n\n /**\n * Adapter for the API, responsible for transforming requests and responses.\n *\n * @internal\n */\n protected adapter!: XComponentsAdapter\n\n /**\n * Set of the already installed XModules to avoid re-registering them.\n *\n * @internal\n */\n protected installedXModules = new Set<string>()\n\n /**\n * True if the plugin has been installed in a Vue instance, in this case\n * XModules will be installed immediately. False otherwise, in this case\n * XModules will be installed lazily when the {@link XPlugin#install} method\n * is called.\n *\n * @internal\n */\n protected isInstalled = false\n\n /**\n * The installation options of the plugin, where all the customization of\n * {@link XModule | XModules} is done.\n *\n * @internal\n */\n protected options!: XPluginOptions\n\n /**\n * The Vuex store, to pass to the wires for its registration, and to register the store\n * modules on it.\n *\n * @internal\n */\n protected store!: Store<any>\n\n /**\n * The Vue application instance, passed by the installation method.\n *\n * @internal\n */\n protected app!: App\n\n /**\n * Creates a new instance of the XPlugin with the given bus passed as parameter.\n *\n * @param bus - The XBus implementation to use for the plugin.\n *\n * @public\n */\n public constructor(bus: XBus<XEventsTypes, WireMetadata>) {\n this.bus = bus\n }\n\n /**\n * If the plugin has already been installed, it immediately registers a {@link XModule}. If it\n * has not been installed yet, it stores the module in a list until the plugin is installed.\n *\n * @param xModule - The module to register.\n *\n * @public\n */\n static registerXModule(xModule: AnyXModule): void {\n if (this.instance) {\n this.instance.registerXModule(xModule)\n } else {\n this.lazyRegisterXModule(xModule)\n }\n }\n\n /**\n * Utility method for resetting the installed instance of the plugin.\n *\n * @remarks Use only for testing.\n *\n * @internal\n */\n static resetInstance(): void {\n cleanGettersProxyCache()\n this.instance = undefined\n }\n\n /**\n * Stores the {@link XModule} in a dictionary, so it can be registered later in the installation\n * process.\n *\n * @param xModule - The module to register.\n *\n * @internal\n */\n protected static lazyRegisterXModule(xModule: AnyXModule): void {\n this.pendingXModules[xModule.name] = xModule\n }\n\n /**\n * Installs the plugin into the Vue instance.\n *\n * @param app - The Vue application instance.\n * @param options - The options to install this plugin with.\n * @throws If the XPlugin has already been installed, or the options are not valid.\n *\n * @internal\n */\n install(app: App, options?: XPluginOptions): void {\n if (this.isInstalled) {\n throw new Error('XPlugin has already been installed')\n }\n assertXPluginOptionsAreValid(options)\n XPlugin.instance = this\n this.app = app\n this.options = options\n this.adapter = options.adapter\n this.registerStore()\n this.registerInitialModules()\n this.registerPendingXModules()\n this.isInstalled = true\n }\n\n /**\n * Performs the registration of a {@link XModule}.\n *\n * @param xModule - The module to register.\n *\n * @internal\n */\n protected registerXModule(xModule: AnyXModule): void {\n if (!this.installedXModules.has(xModule.name)) {\n const customizedXModule = this.customizeXModule(xModule)\n this.registerStoreModule(customizedXModule)\n this.registerStoreEmitters(customizedXModule)\n this.registerWiring(customizedXModule)\n // The wiring must be registered after the store emitters\n // to allow lazy loaded modules work properly.\n this.installedXModules.add(xModule.name)\n void this.bus.emit('ModuleRegistered', xModule.name)\n }\n }\n\n /**\n * Performs a customization of a {@link XModule} using the XPlugin public and private options.\n *\n * @param xModule - The module to customize.\n * @returns The customized xModule.\n * @internal\n */\n protected customizeXModule({\n name,\n wiring,\n storeModule,\n storeEmitters,\n ...restXModule\n }: AnyXModule): AnyXModule {\n const { wiring: wiringOptions, config }: XModuleOptions<XModuleName> =\n this.options.xModules?.[name] ?? {}\n\n const { storeModule: storeModuleOptions, storeEmitters: emittersOptions } =\n this.options.__PRIVATE__xModules?.[name] ?? {}\n\n return {\n name,\n // eslint-disable-next-line ts/no-unsafe-assignment\n wiring: wiringOptions ? deepMerge({}, wiring, wiringOptions) : wiring,\n storeModule: this.customizeStoreModule(storeModule, storeModuleOptions ?? {}, config),\n // eslint-disable-next-line ts/no-unsafe-assignment\n storeEmitters: emittersOptions\n ? deepMerge({}, storeEmitters, emittersOptions)\n : storeEmitters,\n ...restXModule,\n }\n }\n\n /**\n * Performs the registration of the wiring, retrieving the observable for each event, and\n * executing each wire.\n *\n * @param xModule - The {@link XModule} to register its wiring.\n * @internal\n */\n protected registerWiring({ wiring, name }: AnyXModule): void {\n sendWiringToDevtools(name, wiring)\n forEach(wiring, (event, wires: Dictionary<AnyWire>) => {\n // Obtain the observable\n const observable = this.bus.on(event, true) as unknown as Observable<\n SubjectPayload<EventPayload<XEventsTypes, typeof event>, WireMetadata>\n >\n // Register event wires\n forEach(wires, (_, wire) => {\n wire(observable, this.store as Store<RootXStoreState>, this.bus.on.bind(this.bus))\n })\n })\n }\n\n /**\n * Registers a {@link https://vuex.vuejs.org/ | Vuex} store module under the 'x' module.\n *\n * @param xModule - The {@link XModule} to register its Store Module.\n * @internal\n */\n protected registerStoreModule({ name, storeModule }: AnyXModule): void {\n ;(storeModule as Module<any, any>).namespaced = true\n this.store.registerModule(['x', name], storeModule)\n }\n\n /**\n * Overrides a {@link https://vuex.vuejs.org/ | Vuex} store module definition.\n *\n * Priority of configuration merging.\n * 1st {@link XPluginOptions.xModules | xModules XPlugin option}.\n * 2nd {@link XPluginOptions.__PRIVATE__xModules | Private xModules XPlugin option}.\n * 3rd {@link XStoreModule.state | Default state of the xModule}.\n *\n * @param defaultModule - The default store module to override.\n * @param moduleOptions - The state, actions, mutations and getters to override the defaultModule.\n * @param configOptions - The state config to override the moduleOptions.\n * @returns The {@link XStoreModule} customized.\n * @internal\n */\n protected customizeStoreModule(\n { state: defaultState, ...actionsGettersMutations }: AnyXStoreModule,\n { state: xModuleState, ...newActionsGettersMutations }: AnyXStoreModuleOption,\n configOptions: unknown,\n ): AnyXStoreModule {\n const configOptionsObject = configOptions ? { config: configOptions } : {}\n // eslint-disable-next-line ts/no-unsafe-assignment\n const customizedModule = deepMerge({}, actionsGettersMutations, newActionsGettersMutations)\n // eslint-disable-next-line ts/no-unsafe-assignment,ts/no-unsafe-member-access\n customizedModule.state = deepMerge(defaultState(), xModuleState, configOptionsObject)\n // eslint-disable-next-line ts/no-unsafe-return\n return customizedModule\n }\n\n /**\n * Registers the store emitters, making them emit the event when the part of the state selected\n * changes.\n *\n * @param xModule - The {@link XModule} to register its Store Emitters.\n * @internal\n */\n protected registerStoreEmitters(xModule: AnyXModule): void {\n registerStoreEmitters(xModule, this.bus, this.store)\n }\n\n /**\n * Registers the {@link https://vuex.vuejs.org/ | Vuex} store. If the store has not been passed\n * through the {@link XPluginOptions} object, it creates one, and injects it in the Vue\n * prototype. Then it registers an x module in the store, to safe scope all the\n * {@link XModule | XModules} dynamically installed.\n *\n * @internal\n */\n protected registerStore(): void {\n this.store = this.options.store ?? createStore({})\n this.app.use(this.store)\n this.store.registerModule('x', RootXStoreModule)\n }\n /**\n * Registers the initial {@link XModule | XModules} during the {@link XPlugin} installation.\n *\n * @internal\n */\n protected registerInitialModules(): void {\n this.options.initialXModules?.forEach(xModule => {\n this.registerXModule(xModule)\n })\n }\n\n /**\n * Registers the pending {@link XModule | XModules}, that requested to be registered before the\n * installation of the plugin.\n *\n * @internal\n */\n protected registerPendingXModules(): void {\n forEach(XPlugin.pendingXModules, (_, xModule) => {\n this.registerXModule(xModule)\n })\n XPlugin.pendingXModules = {}\n }\n}\n\n/**\n * Vue plugin that modifies each component instance, extending them with the\n * {@link XComponentAPI | X Component API }.\n *\n * @example\n * Minimal installation example. An API adapter is needed to connect the X Components with the\n * suggestions, search, or tagging APIs. In this example we are using the default Empathy's platform\n * adapter.\n *\n * ```typescript\n * import { platformAdapter } from '@empathyco/x-adapter-platform';\n * Vue.use(xPlugin, { adapter: platformAdapter });\n * ```\n *\n * @example\n * If you are using {@link https://vuex.vuejs.org/ | Vuex} in your project you must install its\n * plugin, and instantiate a store before installing the XPlugin:\n * ```typescript\n * Vue.use(Vuex);\n * const store = new Store({ ... });\n * Vue.use(xPlugin, { adapter, store });\n * ```\n * @public\n */\nexport const xPlugin = new XPlugin(bus)\n"],"names":[],"mappings":";;;;;;;;;;AAqBA;;;;;AAKG;MACU,OAAO,CAAA;AAClB;;;;;;;;AAQG;AACI,IAAA,WAAW,OAAO,GAAA;AACvB,QAAA,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO;IACnC;AAEA;;;;;;;;AAQG;AACI,IAAA,WAAW,GAAG,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG;IAC/B;AAEA;;;;;;;AAOG;AACI,IAAA,WAAW,KAAK,GAAA;AACrB,QAAA,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK;IACjC;AAEA;;;;;;AAMG;AACO,IAAA,OAAO,WAAW,GAAA;AAC1B,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AAClB,YAAA,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;QACzE;QACA,OAAO,IAAI,CAAC,QAAQ;IACtB;AAuEA;;;;;;AAMG;AACH,IAAA,WAAA,CAAmB,GAAqC,EAAA;QA9DjD,IAAA,CAAA,MAAM,GAAoE,EAAE;AAenF;;;;AAIG;AACO,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,GAAG,EAAU;AAE/C;;;;;;;AAOG;QACO,IAAA,CAAA,WAAW,GAAG,KAAK;AAiC3B,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;AAEA;;;;;;;AAOG;IACH,OAAO,eAAe,CAAC,OAAmB,EAAA;AACxC,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAA,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC;QACxC;aAAO;AACL,YAAA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;QACnC;IACF;AAEA;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AAC;IAClD;AACA;;;;AAIG;IACO,sBAAsB,GAAA;QAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,IAAG;AAC9C,YAAA,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;AAC/B,QAAA,CAAC,CAAC;IACJ;AAEA;;;;;AAKG;IACO,uBAAuB,GAAA;QAC/B,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAI;AAC9C,YAAA,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;AAC/B,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,CAAC,eAAe,GAAG,EAAE;IAC9B;;AA/SA;;;;AAIG;AACc,OAAA,CAAA,eAAe,GAA6C,EAA7C;AA6SlC;;;;;;;;;;;;;;;;;;;;;;;AAuBG;MACU,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG;;;;"}
1
+ {"version":3,"file":"x-plugin.js","sources":["../../../src/plugins/x-plugin.ts"],"sourcesContent":["import type { XComponentsAdapter } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { Observable } from 'rxjs'\nimport type { App } from 'vue'\nimport type { Module, Store } from 'vuex'\nimport type { AnyXStoreModule, RootXStoreState } from '../store/store.types'\nimport type { XEvent, XEventsTypes } from '../wiring/events.types'\nimport type { AnyWire, WireMetadata } from '../wiring/wiring.types'\nimport type { EventPayload, SubjectPayload, XBus } from '../x-bus'\nimport type { AnyXModule, XModuleName } from '../x-modules/x-modules.types'\nimport type { AnyXStoreModuleOption, XModuleOptions, XPluginOptions } from './x-plugin.types'\nimport { deepMerge, forEach } from '@empathyco/x-utils'\nimport { createStore } from 'vuex'\nimport { cleanGettersProxyCache } from '../store/utils/getters-proxy.utils'\nimport { RootXStoreModule } from '../store/x.module'\nimport { sendWiringToDevtools } from './devtools/wiring.devtools'\nimport { bus } from './x-bus'\nimport { registerStoreEmitters } from './x-emitters'\nimport { assertXPluginOptionsAreValid } from './x-plugin.utils'\n\n/**\n * Vue plugin that initializes the properties needed by the x-components, and exposes the events bus\n * and the adapter after it has been installed.\n *\n * @public\n */\nexport class XPlugin {\n /**\n * XComponentsAdapter Is the middleware between the components and our API where data can be\n * mapped to client needs.\n * This property is only available after installing the plugin.\n *\n * @returns The installed adapter.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get adapter(): XComponentsAdapter {\n return this.getInstance().adapter\n }\n\n /**\n * Exposed XBus, so any kind of application can subscribe to\n * {@link XEventsTypes} without having to pass through a component.\n * This property is only available after installing the plugin.\n *\n * @returns The installed bus.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get bus(): XBus<XEventsTypes, WireMetadata> {\n return this.getInstance().bus\n }\n\n /**\n * {@link https://vuex.vuejs.org | Vuex Store} Is the place where all shared data\n * is saved.\n *\n * @returns The installed store.\n * @throws If this property is accessed before calling `Vue.use(xPlugin)`.\n * @public\n */\n public static get store(): Store<RootXStoreState> {\n return this.getInstance().store\n }\n\n /**\n * Safely retrieves the installed instance of the XPlugin.\n *\n * @returns The installed instance of the XPlugin.\n * @throws If this method is called before calling `Vue.use(xPlugin)`.\n * @internal\n */\n protected static getInstance(): XPlugin {\n if (!this.instance) {\n throw new Error(\"XPlugin must be installed before accessing it's API.\")\n }\n return this.instance\n }\n\n /**\n * Record of modules that have been tried to be installed before the installation of the plugin.\n *\n * @internal\n */\n protected static pendingXModules: Partial<Record<XModuleName, AnyXModule>> = {}\n\n /**\n * Instance of the installed plugin. Used to expose the bus and the adapter.\n *\n * @internal\n */\n protected static instance?: XPlugin\n\n public wiring: Partial<Record<XModuleName, Partial<Record<XEvent, string[]>>>> = {}\n /**\n * Bus for retrieving the observables when registering the wiring.\n *\n * @internal\n */\n protected bus: XBus<XEventsTypes, WireMetadata>\n\n /**\n * Adapter for the API, responsible for transforming requests and responses.\n *\n * @internal\n */\n protected adapter!: XComponentsAdapter\n\n /**\n * Set of the already installed XModules to avoid re-registering them.\n *\n * @internal\n */\n protected installedXModules = new Set<string>()\n\n /**\n * True if the plugin has been installed in a Vue instance, in this case\n * XModules will be installed immediately. False otherwise, in this case\n * XModules will be installed lazily when the {@link XPlugin#install} method\n * is called.\n *\n * @internal\n */\n protected isInstalled = false\n\n /**\n * The installation options of the plugin, where all the customization of\n * {@link XModule | XModules} is done.\n *\n * @internal\n */\n protected options!: XPluginOptions\n\n /**\n * The Vuex store, to pass to the wires for its registration, and to register the store\n * modules on it.\n *\n * @internal\n */\n protected store!: Store<any>\n\n /**\n * The Vue application instance, passed by the installation method.\n *\n * @internal\n */\n protected app!: App\n\n /**\n * Creates a new instance of the XPlugin with the given bus passed as parameter.\n *\n * @param bus - The XBus implementation to use for the plugin.\n *\n * @public\n */\n public constructor(bus: XBus<XEventsTypes, WireMetadata>) {\n this.bus = bus\n }\n\n /**\n * If the plugin has already been installed, it immediately registers a {@link XModule}. If it\n * has not been installed yet, it stores the module in a list until the plugin is installed.\n *\n * @param xModule - The module to register.\n *\n * @public\n */\n static registerXModule(xModule: AnyXModule): void {\n if (this.instance) {\n this.instance.registerXModule(xModule)\n } else {\n this.lazyRegisterXModule(xModule)\n }\n }\n\n /**\n * Utility method for resetting the installed instance of the plugin.\n *\n * @remarks Use only for testing.\n *\n * @internal\n */\n static resetInstance(): void {\n cleanGettersProxyCache()\n this.instance = undefined\n }\n\n /**\n * Stores the {@link XModule} in a dictionary, so it can be registered later in the installation\n * process.\n *\n * @param xModule - The module to register.\n *\n * @internal\n */\n protected static lazyRegisterXModule(xModule: AnyXModule): void {\n this.pendingXModules[xModule.name] = xModule\n }\n\n /**\n * Installs the plugin into the Vue instance.\n *\n * @param app - The Vue application instance.\n * @param options - The options to install this plugin with.\n * @throws If the XPlugin has already been installed, or the options are not valid.\n *\n * @internal\n */\n install(app: App, options?: XPluginOptions): void {\n if (this.isInstalled) {\n throw new Error('XPlugin has already been installed')\n }\n assertXPluginOptionsAreValid(options)\n XPlugin.instance = this\n this.app = app\n this.options = options\n this.adapter = options.adapter\n this.registerStore()\n this.registerInitialModules()\n this.registerPendingXModules()\n this.isInstalled = true\n }\n\n /**\n * Performs the registration of a {@link XModule}.\n *\n * @param xModule - The module to register.\n *\n * @internal\n */\n protected registerXModule(xModule: AnyXModule): void {\n if (!this.installedXModules.has(xModule.name)) {\n const customizedXModule = this.customizeXModule(xModule)\n this.registerStoreModule(customizedXModule)\n this.registerStoreEmitters(customizedXModule)\n this.registerWiring(customizedXModule)\n // The wiring must be registered after the store emitters\n // to allow lazy loaded modules work properly.\n this.installedXModules.add(xModule.name)\n void this.bus.emit('ModuleRegistered', xModule.name)\n }\n }\n\n /**\n * Performs a customization of a {@link XModule} using the XPlugin public and private options.\n *\n * @param xModule - The module to customize.\n * @returns The customized xModule.\n * @internal\n */\n protected customizeXModule({\n name,\n wiring,\n storeModule,\n storeEmitters,\n ...restXModule\n }: AnyXModule): AnyXModule {\n const { wiring: wiringOptions, config }: XModuleOptions<XModuleName> =\n this.options.xModules?.[name] ?? {}\n\n const { storeModule: storeModuleOptions, storeEmitters: emittersOptions } =\n this.options.__PRIVATE__xModules?.[name] ?? {}\n\n return {\n name,\n // eslint-disable-next-line ts/no-unsafe-assignment\n wiring: wiringOptions ? deepMerge({}, wiring, wiringOptions) : wiring,\n storeModule: this.customizeStoreModule(storeModule, storeModuleOptions ?? {}, config),\n // eslint-disable-next-line ts/no-unsafe-assignment\n storeEmitters: emittersOptions\n ? deepMerge({}, storeEmitters, emittersOptions)\n : storeEmitters,\n ...restXModule,\n }\n }\n\n /**\n * Performs the registration of the wiring, retrieving the observable for each event, and\n * executing each wire.\n *\n * @param xModule - The {@link XModule} to register its wiring.\n * @internal\n */\n protected registerWiring({ wiring, name }: AnyXModule): void {\n sendWiringToDevtools(name, wiring)\n forEach(wiring, (event, wires: Dictionary<AnyWire>) => {\n // Obtain the observable\n const observable = this.bus.on(event, true) as unknown as Observable<\n SubjectPayload<EventPayload<XEventsTypes, typeof event>, WireMetadata>\n >\n // Register event wires\n forEach(wires, (_, wire) => {\n wire(observable, this.store as Store<RootXStoreState>, this.bus.on.bind(this.bus))\n })\n })\n }\n\n /**\n * Registers a {@link https://vuex.vuejs.org/ | Vuex} store module under the 'x' module.\n *\n * @param xModule - The {@link XModule} to register its Store Module.\n * @internal\n */\n protected registerStoreModule({ name, storeModule }: AnyXModule): void {\n ;(storeModule as Module<any, any>).namespaced = true\n this.store.registerModule(['x', name], storeModule)\n }\n\n /**\n * Overrides a {@link https://vuex.vuejs.org/ | Vuex} store module definition.\n *\n * Priority of configuration merging.\n * 1st {@link XPluginOptions.xModules | xModules XPlugin option}.\n * 2nd {@link XPluginOptions.__PRIVATE__xModules | Private xModules XPlugin option}.\n * 3rd {@link XStoreModule.state | Default state of the xModule}.\n *\n * @param defaultModule - The default store module to override.\n * @param moduleOptions - The state, actions, mutations and getters to override the defaultModule.\n * @param configOptions - The state config to override the moduleOptions.\n * @returns The {@link XStoreModule} customized.\n * @internal\n */\n protected customizeStoreModule(\n { state: defaultState, ...actionsGettersMutations }: AnyXStoreModule,\n { state: xModuleState, ...newActionsGettersMutations }: AnyXStoreModuleOption,\n configOptions: unknown,\n ): AnyXStoreModule {\n const configOptionsObject = configOptions ? { config: configOptions } : {}\n // eslint-disable-next-line ts/no-unsafe-assignment\n const customizedModule = deepMerge({}, actionsGettersMutations, newActionsGettersMutations)\n // eslint-disable-next-line ts/no-unsafe-assignment,ts/no-unsafe-member-access\n customizedModule.state = deepMerge(defaultState(), xModuleState, configOptionsObject)\n // eslint-disable-next-line ts/no-unsafe-return\n return customizedModule\n }\n\n /**\n * Registers the store emitters, making them emit the event when the part of the state selected\n * changes.\n *\n * @param xModule - The {@link XModule} to register its Store Emitters.\n * @internal\n */\n protected registerStoreEmitters(xModule: AnyXModule): void {\n registerStoreEmitters(xModule, this.bus, this.store)\n }\n\n /**\n * Registers the {@link https://vuex.vuejs.org/ | Vuex} store. If the store has not been passed\n * through the {@link XPluginOptions} object, it creates one, and injects it in the Vue\n * prototype. Then it registers an x module in the store, to safe scope all the\n * {@link XModule | XModules} dynamically installed.\n *\n * @internal\n */\n protected registerStore(): void {\n this.store = this.options.store ?? createStore({})\n this.app.use(this.store)\n this.store.registerModule('x', RootXStoreModule)\n }\n /**\n * Registers the initial {@link XModule | XModules} during the {@link XPlugin} installation.\n *\n * @internal\n */\n protected registerInitialModules(): void {\n this.options.initialXModules?.forEach(xModule => {\n this.registerXModule(xModule)\n })\n }\n\n /**\n * Registers the pending {@link XModule | XModules}, that requested to be registered before the\n * installation of the plugin.\n *\n * @internal\n */\n protected registerPendingXModules(): void {\n forEach(XPlugin.pendingXModules, (_, xModule) => {\n this.registerXModule(xModule)\n })\n XPlugin.pendingXModules = {}\n }\n}\n\n/**\n * Vue plugin that modifies each component instance, extending them with the\n * {@link XComponentAPI | X Component API }.\n *\n * @example\n * Minimal installation example. An API adapter is needed to connect the X Components with the\n * suggestions, search, or tagging APIs. In this example we are using the default Empathy's platform\n * adapter.\n *\n * ```typescript\n * import { platformAdapter } from '@empathyco/x-adapter-platform';\n * Vue.use(xPlugin, { adapter: platformAdapter });\n * ```\n *\n * @example\n * If you are using {@link https://vuex.vuejs.org/ | Vuex} in your project you must install its\n * plugin, and instantiate a store before installing the XPlugin:\n * ```typescript\n * Vue.use(Vuex);\n * const store = new Store({ ... });\n * Vue.use(xPlugin, { adapter, store });\n * ```\n * @public\n */\nexport const xPlugin = new XPlugin(bus)\n"],"names":[],"mappings":";;;;;;;;;AAoBA;;;;;AAKG;MACU,OAAO,CAAA;AAClB;;;;;;;;AAQG;AACI,IAAA,WAAW,OAAO,GAAA;AACvB,QAAA,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO;IACnC;AAEA;;;;;;;;AAQG;AACI,IAAA,WAAW,GAAG,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG;IAC/B;AAEA;;;;;;;AAOG;AACI,IAAA,WAAW,KAAK,GAAA;AACrB,QAAA,OAA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C;;;;;;;;;;;;;;;;;;;;;;;AAuBG;MACU,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG;;;;"}
@@ -1,12 +1,11 @@
1
- import { BrowserStorageService } from '@empathyco/x-storage-service';
1
+ import { BrowserStorageService } from '@empathyco/x-utils';
2
2
  import { noOp } from './function.js';
3
3
 
4
4
  /**
5
- * Service instance of {@link @empathyco/x-storage-service#StorageService | storage service} if
5
+ * Service instance of {@link @empathyco/x-utils#StorageService | storage service} if
6
6
  * localStorage is available.
7
- * If not, required {@link @empathyco/x-storage-service#StorageService | storage service} functions
7
+ * If not, required {@link @empathyco/x-utils#StorageService | storage service} functions
8
8
  * are initialized with empty implementations.
9
- *
10
9
  * @internal
11
10
  */
12
11
  const localStorageService = typeof localStorage !== 'undefined'
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sources":["../../../src/utils/storage.ts"],"sourcesContent":["import type { StorageService } from '@empathyco/x-storage-service'\nimport { BrowserStorageService } from '@empathyco/x-storage-service'\nimport { noOp } from './function'\n\n/**\n * Service instance of {@link @empathyco/x-storage-service#StorageService | storage service} if\n * localStorage is available.\n * If not, required {@link @empathyco/x-storage-service#StorageService | storage service} functions\n * are initialized with empty implementations.\n *\n * @internal\n */\nexport const localStorageService: StorageService =\n typeof localStorage !== 'undefined'\n ? new BrowserStorageService(localStorage, 'x')\n : {\n clear: noOp,\n getItem: noOp,\n setItem: noOp,\n removeItem: noOp,\n }\n"],"names":[],"mappings":";;;AAIA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAC9B,OAAO,YAAY,KAAK;AACtB,MAAE,IAAI,qBAAqB,CAAC,YAAY,EAAE,GAAG;AAC7C,MAAE;AACE,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,UAAU,EAAE,IAAI;;;;;"}
1
+ {"version":3,"file":"storage.js","sources":["../../../src/utils/storage.ts"],"sourcesContent":["import type { StorageService } from '@empathyco/x-utils'\nimport { BrowserStorageService } from '@empathyco/x-utils'\nimport { noOp } from './function'\n\n/**\n * Service instance of {@link @empathyco/x-utils#StorageService | storage service} if\n * localStorage is available.\n * If not, required {@link @empathyco/x-utils#StorageService | storage service} functions\n * are initialized with empty implementations.\n * @internal\n */\nexport const localStorageService: StorageService =\n typeof localStorage !== 'undefined'\n ? new BrowserStorageService(localStorage, 'x')\n : {\n clear: noOp,\n getItem: noOp,\n setItem: noOp,\n removeItem: noOp,\n }\n"],"names":[],"mappings":";;;AAIA;;;;;;AAMG;AACI,MAAM,mBAAmB,GAC9B,OAAO,YAAY,KAAK;AACtB,MAAE,IAAI,qBAAqB,CAAC,YAAY,EAAE,GAAG;AAC7C,MAAE;AACE,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,UAAU,EAAE,IAAI;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-carousel.vue.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? 'Collapse' : 'Expand'\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n <slot name=\"sliding-panel\" :suggestions=\"suggestionsSearch\" :tagging=\"tagging\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <div class=\"x-flex x-gap-8\">\n <ul class=\"x-ai-carousel-suggestion-results\">\n <DisplayClickProvider\n v-for=\"suggestion in suggestionsSearch\"\n :key=\"suggestion.query\"\n :tooling-display-tagging=\"\n tagging?.searchQueries[suggestion.query].toolingDisplayClick\n \"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestion.query].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <li\n v-for=\"result in suggestion.results\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </DisplayClickProvider>\n </ul>\n </div>\n </SlidingPanel>\n </slot>\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n SlidingPanel,\n} from '../../../components'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport { use$x, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n ChangeHeight,\n DisplayClickProvider,\n DisplayEmitter,\n CollapseHeight,\n AIStarIcon,\n ChevronDownIcon,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: {\n type: String,\n },\n /* The classes added to the sliding panel. */\n slidingPanelClasses: {\n type: String,\n },\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: {\n type: String,\n },\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: {\n type: String,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, isNoResults, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n emptyTaggingRequest,\n isNoResults,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["_createBlock","_withCtx","_openBlock","_createElementBlock","_createVNode","_createElementVNode","_normalizeClass","_renderSlot","_Fragment","_renderList","_createCommentVNode"],"mappings":";;;;;;;EAEyC,KAAA,EAAM;;;AAuDhC,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,gBAAA,EAAgB;AACrB,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,kCAAA,EAAkC;;;;;;;;;sBAzDtDA,WAAA,CAqFiB,yBAAA,EAAA,IAAA,EAAA;AAAA,IAAA,OAAA,EAAAC,OAAA,CApFf,MAmFM;AAAA,MAnFK,IAAA,CAAA,iBAAA,CAAkB,MAAA,IAAAC,SAAA,EAAA,EAA7BC,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BJA,kBAAA,CAqBK,MArBL,UAAA,EAqBK;AAAA,mBAAAH,SAAA,CAAA,IAAA,CAAA,EApBHC,kBAAA;AAAA,oBAmBuBK,QAAA;AAAA,oBAAA,IAAA;AAAA,oBAAAC,UAAA,CAlBA,IAAA,CAAA,iBAAA,EAAiB,CAA/B,UAAA,KAAU;0CADnBT,WAAA,CAmBuB,+BAAA,EAAA;AAAA,wBAjBpB,KAAK,UAAA,CAAW,KAAA;AAAA,wBAChB,yBAAA,EAA4C,IAAA,CAAA,OAAA,EAAS,aAAA,CAAc,UAAA,CAAW,KAAK,CAAA,CAAE,mBAAA;AAAA,wBAGrF,2BAAA,EAA8C,IAAA,CAAA,OAAA,EAAS,aAAA,CAAc,UAAA,CAAW,KAAK,CAAA,CAAE,sBAAA;AAAA,wBAGxF,gBAAA,EAAe;AAAA,uBAAA,EAAA;yCAGb,MAAoC;AAAA,2BAAAE,SAAA,CAAA,IAAA,CAAA,EADtCC,kBAAA;AAAA,4BAOKK,QAAA;AAAA,4BAAA,IAAA;AAAA,4BAAAC,UAAA,CANc,UAAA,CAAW,OAAA,EAAO,CAA5B,MAAA,KAAM;kDADfN,kBAAA,CAOK,IAAA,EAAA;AAAA,gCALF,KAAK,MAAA,CAAO,EAAA;AAAA,gCACb,WAAA,EAAU;AAAA,+BAAA,EAAA;AAGV,gCAAAI,UAAA,CAAuC,yBAAlB,MAAA,EAAc;AAAA,+BAAA,CAAA;;;;;;;;;;;;;;;;;;;;QAO/CA,UAAA,CAA6B,IAAA,CAAA,MAAA,EAAA,eAAA,CAAA;AAAA,QAC7BA,UAAA,CAA0B,IAAA,CAAA,MAAA,EAAA,YAAA;AAAA,OAAA,CAAA,IAAAG,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"ai-carousel.vue.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? 'Collapse' : 'Expand'\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n <slot name=\"sliding-panel\" :suggestions=\"suggestionsSearch\" :tagging=\"tagging\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <div class=\"x-flex x-gap-8\">\n <ul class=\"x-ai-carousel-suggestion-results\">\n <DisplayClickProvider\n v-for=\"suggestion in suggestionsSearch\"\n :key=\"suggestion.query\"\n :tooling-display-tagging=\"\n tagging?.searchQueries[suggestion.query].toolingDisplayClick\n \"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestion.query].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <li\n v-for=\"result in suggestion.results\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </DisplayClickProvider>\n </ul>\n </div>\n </SlidingPanel>\n </slot>\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, onMounted, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n SlidingPanel,\n} from '../../../components'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport { use$x, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n ChangeHeight,\n DisplayClickProvider,\n DisplayEmitter,\n CollapseHeight,\n AIStarIcon,\n ChevronDownIcon,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: {\n type: String,\n },\n /* The classes added to the sliding panel. */\n slidingPanelClasses: {\n type: String,\n },\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: {\n type: String,\n },\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: {\n type: String,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, isNoResults, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n onMounted(() => {\n $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' })\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n emptyTaggingRequest,\n isNoResults,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["_createBlock","_withCtx","_openBlock","_createElementBlock","_createVNode","_createElementVNode","_normalizeClass","_renderSlot","_Fragment","_renderList","_createCommentVNode"],"mappings":";;;;;;;EAEyC,KAAA,EAAM;;;AAuDhC,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,gBAAA,EAAgB;AACrB,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,kCAAA,EAAkC;;;;;;;;;sBAzDtDA,WAAA,CAqFiB,yBAAA,EAAA,IAAA,EAAA;AAAA,IAAA,OAAA,EAAAC,OAAA,CApFf,MAmFM;AAAA,MAnFK,IAAA,CAAA,iBAAA,CAAkB,MAAA,IAAAC,SAAA,EAAA,EAA7BC,kBAAA,CAmFM,KAAA,EAnFN,UAAA,EAmFM;AAAA,QAlFJC,WAAA,CAqCiB,yBAAA,EAAA;AAAA,UApCd,OAAA,EAAS,cAAS,cAAA,IAAkB,IAAA,CAAA,mBAAA;AAAA,UACpC,gBAAA,EAAc;AAAA,YAAA,OAAA,EAAA,aAAA;kCAAsE,IAAA,CAAA,KAAA,IAAK,2BAAA;AAAA,YAAA,WAAA,EAAA;;UAK1F,WAAA,EAAU;AAAA,SAAA,EAAA;2BAEV,MA2BO;AAAA,YA3BPC,kBAAA;AAAA,cA2BO,MAAA;AAAA,cAAA;AAAA,gBA1BL,KAAA,EAAKC,cAAA,CAAA,CAAC,qBAAA,EAAqB,EAAA,+BAAA,EACgB,IAAA,CAAA,aAAA,EAAa,CAAA,CAAA;AAAA,gBACxD,WAAA,EAAU,mBAAA;AAAA,gBACT,SAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,oBAAA,IAAA,IAAA,CAAA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AA,CANc,UAAA,CAAW,OAAA,EAAO,CAA5B,MAAA,KAAM;kDADfN,kBAAA,CAOK,IAAA,EAAA;AAAA,gCALF,KAAK,MAAA,CAAO,EAAA;AAAA,gCACb,WAAA,EAAU;AAAA,+BAAA,EAAA;AAGV,gCAAAI,UAAA,CAAuC,yBAAlB,MAAA,EAAc;AAAA,+BAAA,CAAA;;;;;;;;;;;;;;;;;;;;QAO/CA,UAAA,CAA6B,IAAA,CAAA,MAAA,EAAA,eAAA,CAAA;AAAA,QAC7BA,UAAA,CAA0B,IAAA,CAAA,MAAA,EAAA,YAAA;AAAA,OAAA,CAAA,IAAAG,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { useResizeObserver } from '@vueuse/core';
2
- import { defineComponent, ref, computed, watch } from 'vue';
2
+ import { defineComponent, ref, computed, watch, onMounted } from 'vue';
3
3
  import '../../../components/animations/animate-clip-path/animate-clip-path.style.css.js';
4
4
  import '../../../components/animations/animate-scale/animate-scale.style.css.js';
5
5
  import '../../../components/animations/animate-translate/animate-translate.style.css.js';
@@ -178,6 +178,9 @@ var _sfc_main = defineComponent({
178
178
  $x.emit('AiSuggestionsSearchRequestUpdated');
179
179
  }
180
180
  });
181
+ onMounted(() => {
182
+ $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' });
183
+ });
181
184
  useResizeObserver(titleRef, updateTitleOverflow);
182
185
  return {
183
186
  emptyTaggingRequest,