@empathyco/x-components 8.1.1 → 8.3.0

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 (51) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/docs/API-reference/api/x-components.baseaddtocart.md +12 -2
  3. package/docs/API-reference/api/x-components.baseresultlink.md +12 -2
  4. package/docs/API-reference/api/x-components.hierarchicalfilter.md +3 -0
  5. package/docs/API-reference/api/x-components.md +9 -0
  6. package/docs/API-reference/api/x-components.simplefilter.md +3 -0
  7. package/docs/API-reference/api/x-components.snippetcallbacks.md +3 -0
  8. package/docs/API-reference/api/x-components.vendorresult.md +21 -2
  9. package/docs/API-reference/api/x-components.vendorresult.tagging.md +11 -0
  10. package/docs/API-reference/api/x-components.vendorresulttagging.add2carturl.md +11 -0
  11. package/docs/API-reference/api/x-components.vendorresulttagging.clickurl.md +11 -0
  12. package/docs/API-reference/api/x-components.vendorresulttagging.md +88 -0
  13. package/docs/API-reference/api/x-components.vendorresulttagging.viewurl.md +11 -0
  14. package/docs/API-reference/api/x-components.vendorxevents.md +57 -0
  15. package/docs/API-reference/api/x-components.vendorxevents.userclickedavendorresult.md +13 -0
  16. package/docs/API-reference/api/x-components.vendorxevents.userclickedvendorresultaddtocart.md +13 -0
  17. package/docs/API-reference/api/x-components.vendorxevents.userviewedavendorresult.md +13 -0
  18. package/docs/API-reference/components/common/result/x-components.base-result-add-to-cart.md +4 -3
  19. package/docs/API-reference/components/common/result/x-components.base-result-link.md +4 -3
  20. package/js/components/result/base-result-add-to-cart.vue.js.map +1 -1
  21. package/js/components/result/base-result-add-to-cart.vue2.js +6 -2
  22. package/js/components/result/base-result-add-to-cart.vue2.js.map +1 -1
  23. package/js/components/result/base-result-link.vue.js +8 -12
  24. package/js/components/result/base-result-link.vue.js.map +1 -1
  25. package/js/components/result/base-result-link.vue2.js +7 -3
  26. package/js/components/result/base-result-link.vue2.js.map +1 -1
  27. package/js/x-modules/url/wiring.js +1 -0
  28. package/js/x-modules/url/wiring.js.map +1 -1
  29. package/js/x-modules/vendor/wiring.js +14 -0
  30. package/js/x-modules/vendor/wiring.js.map +1 -1
  31. package/package.json +2 -2
  32. package/report/x-components.api.json +451 -15
  33. package/report/x-components.api.md +59 -5
  34. package/types/src/components/result/base-result-add-to-cart.vue.d.ts +13 -2
  35. package/types/src/components/result/base-result-add-to-cart.vue.d.ts.map +1 -1
  36. package/types/src/components/result/base-result-link.vue.d.ts +14 -2
  37. package/types/src/components/result/base-result-link.vue.d.ts.map +1 -1
  38. package/types/src/components/snippet-callbacks.vue.d.ts +3 -0
  39. package/types/src/components/snippet-callbacks.vue.d.ts.map +1 -1
  40. package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +3 -0
  41. package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
  42. package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts +3 -0
  43. package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
  44. package/types/src/x-modules/url/wiring.d.ts +1 -0
  45. package/types/src/x-modules/url/wiring.d.ts.map +1 -1
  46. package/types/src/x-modules/vendor/events.types.d.ts +15 -0
  47. package/types/src/x-modules/vendor/events.types.d.ts.map +1 -1
  48. package/types/src/x-modules/vendor/types.d.ts +7 -1
  49. package/types/src/x-modules/vendor/types.d.ts.map +1 -1
  50. package/types/src/x-modules/vendor/wiring.d.ts +9 -0
  51. package/types/src/x-modules/vendor/wiring.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
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
+ ## [8.3.0](https://github.com/empathyco/x/compare/@empathyco/x-components@8.2.0...@empathyco/x-components@8.3.0) (2026-07-15)
7
+
8
+ ### Features
9
+
10
+ * **vendor:** result events (#2135)
11
+
12
+
13
+ ## [8.2.0](https://github.com/empathyco/x/compare/@empathyco/x-components@8.1.1...@empathyco/x-components@8.2.0) (2026-07-14)
14
+
15
+ ### Features
16
+
17
+ * reset browse fields when UserAcceptedAQuery (#2138)
18
+
19
+
6
20
  ## [8.1.1](https://github.com/empathyco/x/compare/@empathyco/x-components@8.1.0...@empathyco/x-components@8.1.1) (2026-07-14)
7
21
 
8
22
  **Note:** Version bump only for package @empathyco/x-components
@@ -14,15 +14,25 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  type: PropType<Result>;
15
15
  required: true;
16
16
  };
17
+ clickEvent: {
18
+ type: PropType<XEvent>;
19
+ default: string;
20
+ };
17
21
  }>, {
18
- events: {};
22
+ events: import("vue").ComputedRef<Partial<XEventsTypes>>;
19
23
  metadata: Omit<WireMetadata, "moduleName" | "origin" | "location">;
20
24
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
25
  result: {
22
26
  type: PropType<Result>;
23
27
  required: true;
24
28
  };
25
- }>> & Readonly<{}>, {}, {}, {
29
+ clickEvent: {
30
+ type: PropType<XEvent>;
31
+ default: string;
32
+ };
33
+ }>> & Readonly<{}>, {
34
+ clickEvent: keyof XEventsTypes;
35
+ }, {}, {
26
36
  BaseEventButton: import("vue").DefineComponent<{}, {}, any>;
27
37
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
28
38
  ```
@@ -14,15 +14,25 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  type: PropType<Result>;
15
15
  required: true;
16
16
  };
17
+ clickEvent: {
18
+ type: PropType<XEvent>;
19
+ default: string;
20
+ };
17
21
  }>, {
18
22
  el: import("vue").Ref<any, any>;
19
- emitUserClickedAResult: () => void;
23
+ onClick: () => void;
20
24
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
25
  result: {
22
26
  type: PropType<Result>;
23
27
  required: true;
24
28
  };
25
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
29
+ clickEvent: {
30
+ type: PropType<XEvent>;
31
+ default: string;
32
+ };
33
+ }>> & Readonly<{}>, {
34
+ clickEvent: keyof XEventsTypes;
35
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
26
36
  ```
27
37
 
28
38
  ## Remarks
@@ -210,6 +210,9 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
210
210
  UserClickedAnAiCarouselAdd2Cart?: import("@empathyco/x-types").Result | undefined;
211
211
  AiComponentMounted?: void | undefined;
212
212
  VendorResultsChanged?: Omit<import("../../../vendor").VendorResult, "modelName">[] | undefined;
213
+ UserViewedAVendorResult?: import("../../../vendor").VendorResult | undefined;
214
+ UserClickedAVendorResult?: import("../../../vendor").VendorResult | undefined;
215
+ UserClickedVendorResultAddToCart?: import("../../../vendor").VendorResult | undefined;
213
216
  }>;
214
217
  innerCssClasses: import("vue").ComputedRef<(string | Dictionary<boolean>)[]>;
215
218
  renderedChildrenFilters: import("vue").ComputedRef<HierarchicalFilterModel[]>;
@@ -3413,6 +3413,15 @@ Alias to facilitate retrieving the modules with status.
3413
3413
  The interface for a vendor result, extending the base Result interface.
3414
3414
 
3415
3415
 
3416
+ </td></tr>
3417
+ <tr><td>
3418
+
3419
+ [VendorResultTagging](./x-components.vendorresulttagging.md)
3420
+
3421
+
3422
+ </td><td>
3423
+
3424
+
3416
3425
  </td></tr>
3417
3426
  <tr><td>
3418
3427
 
@@ -207,6 +207,9 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
207
207
  UserClickedAnAiCarouselAdd2Cart?: import("@empathyco/x-types").Result | undefined;
208
208
  AiComponentMounted?: void | undefined;
209
209
  VendorResultsChanged?: Omit<import("../../../vendor").VendorResult, "modelName">[] | undefined;
210
+ UserViewedAVendorResult?: import("../../../vendor").VendorResult | undefined;
211
+ UserClickedAVendorResult?: import("../../../vendor").VendorResult | undefined;
212
+ UserClickedVendorResultAddToCart?: import("../../../vendor").VendorResult | undefined;
210
213
  }>;
211
214
  innerCssClasses: import("vue").ComputedRef<(string | Dictionary<boolean>)[]>;
212
215
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -197,6 +197,9 @@ _default: import("vue").DefineComponent<{}, {
197
197
  UserClickedAnAiCarouselAdd2Cart: (payload: import("@empathyco/x-types").Result, metadata: WireMetadata) => unknown;
198
198
  AiComponentMounted: (payload: undefined, metadata: WireMetadata) => unknown;
199
199
  VendorResultsChanged: (payload: Omit<import("..").VendorResult, "modelName">[], metadata: WireMetadata) => unknown;
200
+ UserViewedAVendorResult: (payload: import("..").VendorResult, metadata: WireMetadata) => unknown;
201
+ UserClickedAVendorResult: (payload: import("..").VendorResult, metadata: WireMetadata) => unknown;
202
+ UserClickedVendorResultAddToCart: (payload: import("..").VendorResult, metadata: WireMetadata) => unknown;
200
203
  }>>;
201
204
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {
202
205
  GlobalXBus: import("vue").DefineComponent<{}, {}, any>;
@@ -9,9 +9,9 @@ The interface for a vendor result, extending the base Result interface.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export interface VendorResult extends Omit<Result, 'modelName'>, NamedModel<'VendorResult'>
12
+ export interface VendorResult extends Omit<Result, 'modelName' | 'tagging'>, NamedModel<'VendorResult'>
13
13
  ```
14
- **Extends:** Omit&lt;Result, 'modelName'&gt;, NamedModel&lt;'VendorResult'&gt;
14
+ **Extends:** Omit&lt;Result, 'modelName' \| 'tagging'&gt;, NamedModel&lt;'VendorResult'&gt;
15
15
 
16
16
  ## Properties
17
17
 
@@ -52,6 +52,25 @@ number
52
52
  </td><td>
53
53
 
54
54
 
55
+ </td></tr>
56
+ <tr><td>
57
+
58
+ [tagging?](./x-components.vendorresult.tagging.md)
59
+
60
+
61
+ </td><td>
62
+
63
+
64
+ </td><td>
65
+
66
+ [VendorResultTagging](./x-components.vendorresulttagging.md)
67
+
68
+
69
+ </td><td>
70
+
71
+ _(Optional)_
72
+
73
+
55
74
  </td></tr>
56
75
  </tbody></table>
57
76
 
@@ -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; [VendorResult](./x-components.vendorresult.md) &gt; [tagging](./x-components.vendorresult.tagging.md)
4
+
5
+ ## VendorResult.tagging property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ tagging?: VendorResultTagging;
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-components](./x-components.md) &gt; [VendorResultTagging](./x-components.vendorresulttagging.md) &gt; [add2cartUrl](./x-components.vendorresulttagging.add2carturl.md)
4
+
5
+ ## VendorResultTagging.add2cartUrl property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ add2cartUrl: string;
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-components](./x-components.md) &gt; [VendorResultTagging](./x-components.vendorresulttagging.md) &gt; [clickUrl](./x-components.vendorresulttagging.clickurl.md)
4
+
5
+ ## VendorResultTagging.clickUrl property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ clickUrl: string;
11
+ ```
@@ -0,0 +1,88 @@
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; [VendorResultTagging](./x-components.vendorresulttagging.md)
4
+
5
+ ## VendorResultTagging interface
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ export interface VendorResultTagging
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ <table><thead><tr><th>
16
+
17
+ Property
18
+
19
+
20
+ </th><th>
21
+
22
+ Modifiers
23
+
24
+
25
+ </th><th>
26
+
27
+ Type
28
+
29
+
30
+ </th><th>
31
+
32
+ Description
33
+
34
+
35
+ </th></tr></thead>
36
+ <tbody><tr><td>
37
+
38
+ [add2cartUrl](./x-components.vendorresulttagging.add2carturl.md)
39
+
40
+
41
+ </td><td>
42
+
43
+
44
+ </td><td>
45
+
46
+ string
47
+
48
+
49
+ </td><td>
50
+
51
+
52
+ </td></tr>
53
+ <tr><td>
54
+
55
+ [clickUrl](./x-components.vendorresulttagging.clickurl.md)
56
+
57
+
58
+ </td><td>
59
+
60
+
61
+ </td><td>
62
+
63
+ string
64
+
65
+
66
+ </td><td>
67
+
68
+
69
+ </td></tr>
70
+ <tr><td>
71
+
72
+ [viewUrl](./x-components.vendorresulttagging.viewurl.md)
73
+
74
+
75
+ </td><td>
76
+
77
+
78
+ </td><td>
79
+
80
+ string
81
+
82
+
83
+ </td><td>
84
+
85
+
86
+ </td></tr>
87
+ </tbody></table>
88
+
@@ -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; [VendorResultTagging](./x-components.vendorresulttagging.md) &gt; [viewUrl](./x-components.vendorresulttagging.viewurl.md)
4
+
5
+ ## VendorResultTagging.viewUrl property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ viewUrl: string;
11
+ ```
@@ -37,6 +37,63 @@ Description
37
37
  </th></tr></thead>
38
38
  <tbody><tr><td>
39
39
 
40
+ [UserClickedAVendorResult](./x-components.vendorxevents.userclickedavendorresult.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ [VendorResult](./x-components.vendorresult.md)
49
+
50
+
51
+ </td><td>
52
+
53
+ The user clicked on a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was clicked.
54
+
55
+
56
+ </td></tr>
57
+ <tr><td>
58
+
59
+ [UserClickedVendorResultAddToCart](./x-components.vendorxevents.userclickedvendorresultaddtocart.md)
60
+
61
+
62
+ </td><td>
63
+
64
+
65
+ </td><td>
66
+
67
+ [VendorResult](./x-components.vendorresult.md)
68
+
69
+
70
+ </td><td>
71
+
72
+ The user clicked on the add to cart button of a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was clicked.
73
+
74
+
75
+ </td></tr>
76
+ <tr><td>
77
+
78
+ [UserViewedAVendorResult](./x-components.vendorxevents.userviewedavendorresult.md)
79
+
80
+
81
+ </td><td>
82
+
83
+
84
+ </td><td>
85
+
86
+ [VendorResult](./x-components.vendorresult.md)
87
+
88
+
89
+ </td><td>
90
+
91
+ The user viewed a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was viewed.
92
+
93
+
94
+ </td></tr>
95
+ <tr><td>
96
+
40
97
  [VendorResultsChanged](./x-components.vendorxevents.vendorresultschanged.md)
41
98
 
42
99
 
@@ -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; [VendorXEvents](./x-components.vendorxevents.md) &gt; [UserClickedAVendorResult](./x-components.vendorxevents.userclickedavendorresult.md)
4
+
5
+ ## VendorXEvents.UserClickedAVendorResult property
6
+
7
+ The user clicked on a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was clicked.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ UserClickedAVendorResult: VendorResult;
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; [VendorXEvents](./x-components.vendorxevents.md) &gt; [UserClickedVendorResultAddToCart](./x-components.vendorxevents.userclickedvendorresultaddtocart.md)
4
+
5
+ ## VendorXEvents.UserClickedVendorResultAddToCart property
6
+
7
+ The user clicked on the add to cart button of a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was clicked.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ UserClickedVendorResultAddToCart: VendorResult;
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; [VendorXEvents](./x-components.vendorxevents.md) &gt; [UserViewedAVendorResult](./x-components.vendorxevents.userviewedavendorresult.md)
4
+
5
+ ## VendorXEvents.UserViewedAVendorResult property
6
+
7
+ The user viewed a vendor result. Payload: The [vendor result](./x-components.vendorresult.md) that was viewed.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ UserViewedAVendorResult: VendorResult;
13
+ ```
@@ -11,9 +11,10 @@ XEventsTypes.UserClickedResultAddToCart to the bus on click mouse event.
11
11
 
12
12
  ## Props
13
13
 
14
- | Name | Description | Type | Default |
15
- | ------------------- | ----------------------------------------------------- | ------------------- | ------------- |
16
- | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
14
+ | Name | Description | Type | Default |
15
+ | ----------------------- | ----------------------------------------------------- | ------------------- | ----------------------------------------- |
16
+ | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
17
+ | <code>clickEvent</code> | | <code>XEvent</code> | <code>'UserClickedResultAddToCart'</code> |
17
18
 
18
19
  ## Slots
19
20
 
@@ -10,9 +10,10 @@ Component to be reused that renders an `<a>` wrapping the result contents.
10
10
 
11
11
  ## Props
12
12
 
13
- | Name | Description | Type | Default |
14
- | ------------------- | ----------------------------------------------------- | ------------------- | ------------- |
15
- | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
13
+ | Name | Description | Type | Default |
14
+ | ----------------------- | ----------------------------------------------------- | ------------------- | --------------------------------- |
15
+ | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
16
+ | <code>clickEvent</code> | | <code>XEvent</code> | <code>'UserClickedAResult'</code> |
16
17
 
17
18
  ## Slots
18
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-result-add-to-cart.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-result-add-to-cart xds:button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/index'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/index'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Renders a button with a default slot. It receives the result with the data and emits\n * {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.\n *\n * @public\n */\nexport default defineComponent({\n components: { BaseEventButton },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * The list of additional events to be emitted by the component when user clicks the add2cart button.\n *\n * @internal\n */\n const resultAddToCartExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultAddToCartExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component.\n */\n const metadata = inject<Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>>(\n 'resultAddToCartExtraEventsMetadata',\n {},\n )\n\n /**\n * The events to be emitted by the button.\n *\n * @returns Events {@link XEventsTypes} to emit.\n *\n * @public\n */\n const events = computed(() => {\n return resultAddToCartExtraEvents.reduce(\n (acc, event) => {\n acc[event] = props.result\n return acc\n },\n { UserClickedResultAddToCart: props.result } as Partial<XEventsTypes>,\n )\n })\n\n return {\n events: props.result.modelName === 'Result' ? events : {},\n metadata,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` when clicked by the user.\n\n```vue\n<template>\n <BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" alt=\"Add to cart\" />\n <span>Add to cart</span>\n </BaseResultAddToCart>\n</template>\n\n<script setup>\nimport { BaseResultAddToCart } from '@empathyco/x-components'\nconst result = {\n id: '123',\n name: 'Product name',\n price: 19.99,\n // ...other result properties\n}\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACR,QAAA,EAAU,IAAA,CAAA,QAAA;AAAA,IACX,KAAA,EAAM,iCAAA;AAAA,IACN,WAAA,EAAU;AAAA,GAAA,EAAA;qBAGV,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"base-result-add-to-cart.vue.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-result-add-to-cart xds:button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/index'\nimport type { XEvent, XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/index'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Renders a button with a default slot. It receives the result with the data and emits\n * {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.\n *\n * @public\n */\nexport default defineComponent({\n components: { BaseEventButton },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n clickEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedResultAddToCart',\n },\n },\n setup(props) {\n /**\n * The list of additional events to be emitted by the component when user clicks the add2cart button.\n *\n * @internal\n */\n const resultAddToCartExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultAddToCartExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component.\n */\n const metadata = inject<Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>>(\n 'resultAddToCartExtraEventsMetadata',\n {},\n )\n\n /**\n * The events to be emitted by the button.\n *\n * @returns Events {@link XEventsTypes} to emit.\n *\n * @public\n */\n const events = computed(() => {\n return resultAddToCartExtraEvents.reduce(\n (acc, event) => {\n acc[event] = props.result\n return acc\n },\n { [props.clickEvent]: props.result } as Partial<XEventsTypes>,\n )\n })\n\n return {\n events,\n metadata,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` when clicked by the user.\n\n```vue\n<template>\n <BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" alt=\"Add to cart\" />\n <span>Add to cart</span>\n </BaseResultAddToCart>\n</template>\n\n<script setup>\nimport { BaseResultAddToCart } from '@empathyco/x-components'\nconst result = {\n id: '123',\n name: 'Product name',\n price: 19.99,\n // ...other result properties\n}\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACR,QAAA,EAAU,IAAA,CAAA,QAAA;AAAA,IACX,KAAA,EAAM,iCAAA;AAAA,IACN,WAAA,EAAU;AAAA,GAAA,EAAA;qBAGV,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -19,6 +19,10 @@ var _sfc_main = defineComponent({
19
19
  type: Object,
20
20
  required: true,
21
21
  },
22
+ clickEvent: {
23
+ type: String,
24
+ default: 'UserClickedResultAddToCart',
25
+ },
22
26
  },
23
27
  setup(props) {
24
28
  /**
@@ -42,10 +46,10 @@ var _sfc_main = defineComponent({
42
46
  return resultAddToCartExtraEvents.reduce((acc, event) => {
43
47
  acc[event] = props.result;
44
48
  return acc;
45
- }, { UserClickedResultAddToCart: props.result });
49
+ }, { [props.clickEvent]: props.result });
46
50
  });
47
51
  return {
48
- events: props.result.modelName === 'Result' ? events : {},
52
+ events,
49
53
  metadata,
50
54
  };
51
55
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base-result-add-to-cart.vue2.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-result-add-to-cart xds:button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/index'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/index'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Renders a button with a default slot. It receives the result with the data and emits\n * {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.\n *\n * @public\n */\nexport default defineComponent({\n components: { BaseEventButton },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * The list of additional events to be emitted by the component when user clicks the add2cart button.\n *\n * @internal\n */\n const resultAddToCartExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultAddToCartExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component.\n */\n const metadata = inject<Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>>(\n 'resultAddToCartExtraEventsMetadata',\n {},\n )\n\n /**\n * The events to be emitted by the button.\n *\n * @returns Events {@link XEventsTypes} to emit.\n *\n * @public\n */\n const events = computed(() => {\n return resultAddToCartExtraEvents.reduce(\n (acc, event) => {\n acc[event] = props.result\n return acc\n },\n { UserClickedResultAddToCart: props.result } as Partial<XEventsTypes>,\n )\n })\n\n return {\n events: props.result.modelName === 'Result' ? events : {},\n metadata,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` when clicked by the user.\n\n```vue\n<template>\n <BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" alt=\"Add to cart\" />\n <span>Add to cart</span>\n </BaseResultAddToCart>\n</template>\n\n<script setup>\nimport { BaseResultAddToCart } from '@empathyco/x-components'\nconst result = {\n id: '123',\n name: 'Product name',\n price: 19.99,\n // ...other result properties\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;AAqBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,6BAA6B,MAAM,CACvC,4BAA4B,EAC5B,EAAE,CACJ;AAEA;;AAEE;QACF,MAAM,QAAO,GAAI,MAAM,CACrB,oCAAoC,EACpC,EAAE,CACJ;AAEA;;;;;;AAME;AACF,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAC,MAAI;YAC1B,OAAO,0BAA0B,CAAC,MAAM,CACtC,CAAC,GAAG,EAAE,KAAK,KAAG;AACZ,gBAAA,GAAG,CAAC,KAAK,CAAA,GAAI,KAAK,CAAC,MAAK;AACxB,gBAAA,OAAO,GAAE;YACX,CAAC,EACD,EAAE,0BAA0B,EAAE,KAAK,CAAC,MAAK,EAA4B,CACvE;AACF,QAAA,CAAC,CAAA;QAED,OAAO;AACL,YAAA,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,QAAO,GAAI,MAAK,GAAI,EAAE;YACzD,QAAQ;SACV;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-result-add-to-cart.vue2.js","sources":["../../../../src/components/result/base-result-add-to-cart.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-result-add-to-cart xds:button\"\n data-test=\"result-add-to-cart\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/index'\nimport type { XEvent, XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/index'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Renders a button with a default slot. It receives the result with the data and emits\n * {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.\n *\n * @public\n */\nexport default defineComponent({\n components: { BaseEventButton },\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n clickEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedResultAddToCart',\n },\n },\n setup(props) {\n /**\n * The list of additional events to be emitted by the component when user clicks the add2cart button.\n *\n * @internal\n */\n const resultAddToCartExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultAddToCartExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component.\n */\n const metadata = inject<Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>>(\n 'resultAddToCartExtraEventsMetadata',\n {},\n )\n\n /**\n * The events to be emitted by the button.\n *\n * @returns Events {@link XEventsTypes} to emit.\n *\n * @public\n */\n const events = computed(() => {\n return resultAddToCartExtraEvents.reduce(\n (acc, event) => {\n acc[event] = props.result\n return acc\n },\n { [props.clickEvent]: props.result } as Partial<XEventsTypes>,\n )\n })\n\n return {\n events,\n metadata,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the result data.\n\n## Examples\n\nRenders a button with a default slot. It receives the result with the data and emits an event\n`UserClickedResultAddToCart` to the bus on click mouse event.\n\n### Basic example\n\nThis component is a button to emit `UserClickedResultAddToCart` when clicked by the user.\n\n```vue\n<template>\n <BaseResultAddToCart :result=\"result\">\n <img src=\"./add-to-cart.svg\" alt=\"Add to cart\" />\n <span>Add to cart</span>\n </BaseResultAddToCart>\n</template>\n\n<script setup>\nimport { BaseResultAddToCart } from '@empathyco/x-components'\nconst result = {\n id: '123',\n name: 'Product name',\n price: 19.99,\n // ...other result properties\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;AAqBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,4BAA4B;AACtC,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,6BAA6B,MAAM,CACvC,4BAA4B,EAC5B,EAAE,CACJ;AAEA;;AAEE;QACF,MAAM,QAAO,GAAI,MAAM,CACrB,oCAAoC,EACpC,EAAE,CACJ;AAEA;;;;;;AAME;AACF,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAC,MAAI;YAC1B,OAAO,0BAA0B,CAAC,MAAM,CACtC,CAAC,GAAG,EAAE,KAAK,KAAG;AACZ,gBAAA,GAAG,CAAC,KAAK,CAAA,GAAI,KAAK,CAAC,MAAK;AACxB,gBAAA,OAAO,GAAE;AACX,YAAA,CAAC,EACD,EAAE,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,MAAK,EAA4B,CAC/D;AACF,QAAA,CAAC,CAAA;QAED,OAAO;YACL,MAAM;YACN,QAAQ;SACV;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -1,25 +1,21 @@
1
1
  import _sfc_main from './base-result-link.vue2.js';
2
- import { openBlock, createElementBlock, mergeProps, toHandlers, renderSlot } from 'vue';
2
+ import { openBlock, createElementBlock, renderSlot } from 'vue';
3
3
  import './base-result-link.vue3.js';
4
4
  import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
5
5
 
6
6
  const _hoisted_1 = ["href"];
7
7
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
8
- return openBlock(), createElementBlock("a", mergeProps({
8
+ return openBlock(), createElementBlock("a", {
9
9
  ref: _ctx.el,
10
10
  href: _ctx.result.url,
11
11
  class: "x-result-link",
12
- "data-test": "result-link"
13
- }, toHandlers(
14
- _ctx.result.modelName === "Result" ? {
15
- click: _ctx.emitUserClickedAResult,
16
- contextmenu: _ctx.emitUserClickedAResult,
17
- auxclick: (event) => event.button === 1 && _ctx.emitUserClickedAResult()
18
- } : {},
19
- true
20
- )), [
12
+ "data-test": "result-link",
13
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args)),
14
+ onContextmenu: _cache[1] || (_cache[1] = (...args) => _ctx.onClick && _ctx.onClick(...args)),
15
+ onAuxclick: _cache[2] || (_cache[2] = ({ button }) => button === 1 && _ctx.onClick())
16
+ }, [
21
17
  renderSlot(_ctx.$slots, "default", { result: _ctx.result }, void 0, true)
22
- ], 16, _hoisted_1);
18
+ ], 40, _hoisted_1);
23
19
  }
24
20
  var baseResultLink = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4d589f60"]]);
25
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-result-link.vue.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n :ref=\"el\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n v-on=\"\n result.modelName === 'Result'\n ? {\n click: emitUserClickedAResult,\n contextmenu: emitUserClickedAResult,\n auxclick: (event: { button: number }) => event.button === 1 && emitUserClickedAResult(),\n }\n : {}\n \"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { WireMetadata } from '../../wiring'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { defineComponent, inject, ref } from 'vue'\nimport { use$x } from '../../composables/index'\n\n/**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\nexport default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref()\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {})\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const emitUserClickedAResult = (): void => {\n $x.emit('UserClickedAResult', props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent.UserClickedAResult,\n })\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] })\n })\n }\n\n return {\n el,\n emitUserClickedAResult,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-link {\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## Examples\n\nThis component is a wrapper for the result contents (images, name, price...). It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide these events.\n\nThe result prop is required. It will render an anchor element with the href to the result URL:\n\n```vue\n<template>\n <BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\" alt=\"Result image\" />\n <span>{{ result.name }}</span>\n </template>\n </BaseResultLink>\n</template>\n\n<script setup>\nimport { BaseResultLink } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n url: 'https://shop.com/jacket',\n images: ['https://shop.com/jacket.jpg'],\n}\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_toHandlers","_renderSlot"],"mappings":";;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAoBI,KApBJC,UAAA,CAoBI;AAAA,IAnBD,GAAA,EAAK,IAAA,CAAA,EAAA;AAAA,IACL,MAAM,IAAA,CAAA,MAAA,CAAO,GAAA;AAAA,IACd,KAAA,EAAM,eAAA;AAAA,IACN,WAAA,EAAU;AAAA,GAAA,EACVC,UAAA;AAAA,IAAa,YAAO,SAAA,KAAS,QAAA,GAAA;AAA6C,MAAA,KAAA,EAAA,IAAA,CAAA,sBAAA;AAAA,MAAA,WAAA,EAAiD,IAAA,CAAA,sBAAA;AAAA,MAAA,QAAA,EAAA,CAA+C,KAAA,KAA8B,KAAA,CAAM,MAAA,KAAM,CAAA,IAAU,IAAA,CAAA,sBAAA;AAAsB,KAAA,GAAA,EAAA;;;IAcpPC,UAAA,CAAyB,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAlB,QAAQ,IAAA,CAAA,MAAA,EAAM,EAAA,MAAA,EAAA,IAAA;AAAA,GAAA,EAAA,EAAA,EAAA,UAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"base-result-link.vue.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n :ref=\"el\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n @click=\"onClick\"\n @contextmenu=\"onClick\"\n @auxclick=\"({ button }) => button === 1 && onClick()\"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { WireMetadata, XEvent } from '../../wiring'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { defineComponent, inject, ref } from 'vue'\nimport { use$x } from '../../composables/index'\n\n/**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\nexport default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n clickEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedAResult',\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref()\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {})\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const onClick = (): void => {\n $x.emit(props.clickEvent, props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent.UserClickedAResult,\n })\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] })\n })\n }\n\n return {\n el,\n onClick,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-link {\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## Examples\n\nThis component is a wrapper for the result contents (images, name, price...). It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide these events.\n\nThe result prop is required. It will render an anchor element with the href to the result URL:\n\n```vue\n<template>\n <BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\" alt=\"Result image\" />\n <span>{{ result.name }}</span>\n </template>\n </BaseResultLink>\n</template>\n\n<script setup>\nimport { BaseResultLink } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n url: 'https://shop.com/jacket',\n images: ['https://shop.com/jacket.jpg'],\n}\n</script>\n```\n</docs>\n"],"names":["_createElementBlock","_renderSlot"],"mappings":";;;;;;;sBACEA,kBAAA,CAcI,GAAA,EAAA;AAAA,IAbD,GAAA,EAAK,IAAA,CAAA,EAAA;AAAA,IACL,MAAM,IAAA,CAAA,MAAA,CAAO,GAAA;AAAA,IACd,KAAA,EAAM,eAAA;AAAA,IACN,WAAA,EAAU,aAAA;AAAA,IACT,SAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,OAAA,IAAA,IAAA,CAAA,OAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IACP,eAAW,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,OAAA,IAAA,IAAA,CAAA,OAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IACb,YAAQ,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,EAAK,MAAA,EAAM,KAAO,MAAA,KAAM,KAAU,IAAA,CAAA,OAAA,EAAO;AAAA,GAAA,EAAA;IAMlDC,UAAA,CAAyB,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAlB,QAAQ,IAAA,CAAA,MAAA,EAAM,EAAA,MAAA,EAAA,IAAA;AAAA,GAAA,EAAA,EAAA,EAAA,UAAA,CAAA;;;;;;"}
@@ -29,6 +29,10 @@ var _sfc_main = defineComponent({
29
29
  type: Object,
30
30
  required: true,
31
31
  },
32
+ clickEvent: {
33
+ type: String,
34
+ default: 'UserClickedAResult',
35
+ },
32
36
  },
33
37
  setup(props) {
34
38
  const $x = use$x();
@@ -55,8 +59,8 @@ var _sfc_main = defineComponent({
55
59
  *
56
60
  * @internal
57
61
  */
58
- const emitUserClickedAResult = () => {
59
- $x.emit('UserClickedAResult', props.result, {
62
+ const onClick = () => {
63
+ $x.emit(props.clickEvent, props.result, {
60
64
  target: el.value,
61
65
  ...resultLinkMetadataPerEvent.UserClickedAResult,
62
66
  });
@@ -66,7 +70,7 @@ var _sfc_main = defineComponent({
66
70
  };
67
71
  return {
68
72
  el,
69
- emitUserClickedAResult,
73
+ onClick,
70
74
  };
71
75
  },
72
76
  });