@empathyco/x-components 3.0.0-alpha.158 → 3.0.0-alpha.160

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 (103) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/core/index.js +3 -1
  3. package/core/index.js.map +1 -1
  4. package/design-system/full-theme.css +10 -10
  5. package/docs/API-reference/api/x-components.md +2 -0
  6. package/docs/API-reference/api/x-components.resultvariantselector.level.md +13 -0
  7. package/docs/API-reference/api/x-components.resultvariantselector.md +24 -0
  8. package/docs/API-reference/api/x-components.resultvariantselector.result.md +13 -0
  9. package/docs/API-reference/api/x-components.resultvariantselector.selectedvariants.md +13 -0
  10. package/docs/API-reference/api/x-components.resultvariantselector.selectresultvariant.md +13 -0
  11. package/docs/API-reference/api/x-components.resultvariantsprovider.md +34 -0
  12. package/docs/API-reference/api/x-components.resultvariantsprovider.render.md +26 -0
  13. package/docs/API-reference/api/x-components.resultvariantsprovider.result.md +13 -0
  14. package/docs/API-reference/api/x-components.resultvariantsprovider.resulttoprovide.md +13 -0
  15. package/docs/API-reference/api/x-components.resultvariantsprovider.selectedvariants.md +13 -0
  16. package/docs/API-reference/api/x-components.resultvariantsprovider.selectresultvariant.md +25 -0
  17. package/docs/API-reference/api/x-components.xeventstypes.md +1 -0
  18. package/docs/API-reference/api/x-components.xeventstypes.userselectedaresultvariant.md +17 -0
  19. package/docs/API-reference/components/common/result/x-components.result-variant-selector.md +300 -0
  20. package/docs/API-reference/components/common/result/x-components.result-variants-provider.md +107 -0
  21. package/docs/build-search-ui/web-how-to-use-x-components-guide.md +1 -1
  22. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/README.md +22 -9
  23. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/empathize.md +7 -7
  24. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/facets-and-filters.md +24 -10
  25. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/history-queries.md +16 -13
  26. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/id-results.md +11 -6
  27. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/next-queries.md +24 -10
  28. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/popular-searches.md +19 -8
  29. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/product-results-ui.md +23 -10
  30. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/query-suggestions.md +20 -8
  31. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/recommendations.md +20 -8
  32. package/docs/experience-search-and-discovery/related-tags.md +48 -0
  33. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/search-box.md +28 -17
  34. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/serp-ui.md +31 -19
  35. package/docs/{experience-search-&-discovery → experience-search-and-discovery}/web-local-storage.md +0 -0
  36. package/js/components/decorators/injection.consts.js +20 -2
  37. package/js/components/decorators/injection.consts.js.map +1 -1
  38. package/js/components/result/result-variant-selector.vue.js +137 -0
  39. package/js/components/result/result-variant-selector.vue.js.map +1 -0
  40. package/js/components/result/result-variant-selector.vue_rollup-plugin-vue_script.vue.js +80 -0
  41. package/js/components/result/result-variant-selector.vue_rollup-plugin-vue_script.vue.js.map +1 -0
  42. package/js/components/result/result-variants-provider.vue.js +39 -0
  43. package/js/components/result/result-variants-provider.vue.js.map +1 -0
  44. package/js/components/result/result-variants-provider.vue_rollup-plugin-vue_script.vue.js +102 -0
  45. package/js/components/result/result-variants-provider.vue_rollup-plugin-vue_script.vue.js.map +1 -0
  46. package/js/index.js +3 -1
  47. package/js/index.js.map +1 -1
  48. package/js/x-modules/extra-params/components/extra-params.vue_rollup-plugin-vue_script.vue.js +2 -0
  49. package/js/x-modules/extra-params/components/extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  50. package/js/x-modules/extra-params/components/renderless-extra-param.vue_rollup-plugin-vue_script.vue.js +2 -0
  51. package/js/x-modules/extra-params/components/renderless-extra-param.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  52. package/js/x-modules/facets/components/clear-filters.vue_rollup-plugin-vue_script.vue.js +2 -0
  53. package/js/x-modules/facets/components/clear-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  54. package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js +2 -0
  55. package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  56. package/js/x-modules/facets/components/filters/all-filter.vue_rollup-plugin-vue_script.vue.js +2 -0
  57. package/js/x-modules/facets/components/filters/all-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  58. package/js/x-modules/facets/components/filters/number-range-filter.vue_rollup-plugin-vue_script.vue.js +2 -0
  59. package/js/x-modules/facets/components/filters/number-range-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  60. package/js/x-modules/facets/components/filters/renderless-filter.vue_rollup-plugin-vue_script.vue.js +2 -0
  61. package/js/x-modules/facets/components/filters/renderless-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  62. package/js/x-modules/facets/components/filters/simple-filter.vue_rollup-plugin-vue_script.vue.js +2 -0
  63. package/js/x-modules/facets/components/filters/simple-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  64. package/js/x-modules/facets/components/lists/exclude-filters-with-no-results.vue_rollup-plugin-vue_script.vue.js +2 -0
  65. package/js/x-modules/facets/components/lists/exclude-filters-with-no-results.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  66. package/js/x-modules/facets/components/lists/filters-list.vue_rollup-plugin-vue_script.vue.js +2 -0
  67. package/js/x-modules/facets/components/lists/filters-list.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  68. package/js/x-modules/facets/components/lists/filters-search.vue_rollup-plugin-vue_script.vue.js +2 -0
  69. package/js/x-modules/facets/components/lists/filters-search.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  70. package/js/x-modules/facets/components/lists/selected-filters.vue_rollup-plugin-vue_script.vue.js +2 -0
  71. package/js/x-modules/facets/components/lists/selected-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  72. package/js/x-modules/facets/components/lists/sliced-filters.vue_rollup-plugin-vue_script.vue.js +2 -0
  73. package/js/x-modules/facets/components/lists/sliced-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  74. package/js/x-modules/facets/components/lists/sorted-filters.vue_rollup-plugin-vue_script.vue.js +2 -0
  75. package/js/x-modules/facets/components/lists/sorted-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  76. package/js/x-modules/scroll/components/main-scroll-item.vue_rollup-plugin-vue_script.vue.js +2 -0
  77. package/js/x-modules/scroll/components/main-scroll-item.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  78. package/js/x-modules/scroll/components/scroll-to-top.vue_rollup-plugin-vue_script.vue.js +2 -0
  79. package/js/x-modules/scroll/components/scroll-to-top.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  80. package/js/x-modules/scroll/components/window-scroll.vue_rollup-plugin-vue_script.vue.js +2 -0
  81. package/js/x-modules/scroll/components/window-scroll.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  82. package/js/x-modules/search/components/sort-list.vue_rollup-plugin-vue_script.vue.js +2 -0
  83. package/js/x-modules/search/components/sort-list.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  84. package/js/x-modules/search/components/sort.mixin.js +2 -0
  85. package/js/x-modules/search/components/sort.mixin.js.map +1 -1
  86. package/js/x-modules/search/components/spellcheck.vue_rollup-plugin-vue_script.vue.js +2 -0
  87. package/js/x-modules/search/components/spellcheck.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  88. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js +2 -0
  89. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  90. package/package.json +2 -2
  91. package/report/x-components.api.json +421 -0
  92. package/report/x-components.api.md +40 -0
  93. package/types/components/decorators/injection.consts.d.ts +19 -0
  94. package/types/components/decorators/injection.consts.d.ts.map +1 -1
  95. package/types/components/result/index.d.ts +2 -0
  96. package/types/components/result/index.d.ts.map +1 -1
  97. package/types/components/result/result-variant-selector.vue.d.ts +64 -0
  98. package/types/components/result/result-variant-selector.vue.d.ts.map +1 -0
  99. package/types/components/result/result-variants-provider.vue.d.ts +57 -0
  100. package/types/components/result/result-variants-provider.vue.d.ts.map +1 -0
  101. package/types/wiring/events.types.d.ts +11 -1
  102. package/types/wiring/events.types.d.ts.map +1 -1
  103. package/docs/experience-search-&-discovery/related-tags.md +0 -41
package/CHANGELOG.md CHANGED
@@ -3,6 +3,31 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.0-alpha.160](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.159...@empathyco/x-components@3.0.0-alpha.160) (2022-08-25)
7
+
8
+ ### Features
9
+
10
+ - **components:** merge a variant with the result (#667)
11
+ ([553d0e5](https://github.com/empathyco/x/commit/553d0e5de8ef5468eb673246f39fbeb826301fa1)),
12
+ closes [EX-6762](https://searchbroker.atlassian.net/browse/EX-6762)
13
+
14
+ # Change Log
15
+
16
+ All notable changes to this project will be documented in this file. See
17
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
18
+
19
+ ## [3.0.0-alpha.159](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.158...@empathyco/x-components@3.0.0-alpha.159) (2022-08-24)
20
+
21
+ ### Documentation
22
+
23
+ - update functional docs callout formatting (#671)
24
+ ([5f1de74](https://github.com/empathyco/x/commit/5f1de74c2e86adb638d692781483cac1ccf70a71))
25
+
26
+ # Change Log
27
+
28
+ All notable changes to this project will be documented in this file. See
29
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
30
+
6
31
  ## [3.0.0-alpha.158](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.156...@empathyco/x-components@3.0.0-alpha.158) (2022-08-24)
7
32
 
8
33
  ### Features
package/core/index.js CHANGED
@@ -98,6 +98,8 @@ export { default as BaseResultPreviousPrice } from '../js/components/result/base
98
98
  export { default as BaseFallbackImage } from '../js/components/result/base-result-fallback-image.vue.js';
99
99
  export { default as BasePlaceholderImage } from '../js/components/result/base-result-placeholder-image.vue.js';
100
100
  export { default as BaseResultRating } from '../js/components/result/base-result-rating.vue.js';
101
+ export { default as ResultVariantsProvider } from '../js/components/result/result-variants-provider.vue.js';
102
+ export { default as ResultVariantSelector } from '../js/components/result/result-variant-selector.vue.js';
101
103
  export { default as BaseScroll } from '../js/components/scroll/base-scroll.vue.js';
102
104
  export { default as ScrollMixin } from '../js/components/scroll/scroll.mixin.js';
103
105
  export { default as BaseSuggestion } from '../js/components/suggestions/base-suggestion.vue.js';
@@ -118,7 +120,7 @@ export { default as SlidingPanel } from '../js/components/sliding-panel.vue.js';
118
120
  export { default as SnippetCallbacks } from '../js/components/snippet-callbacks.vue.js';
119
121
  export { XEmit, XOn } from '../js/components/decorators/bus.decorators.js';
120
122
  export { Debounce } from '../js/components/decorators/debounce.decorators.js';
121
- export { LIST_ITEMS_KEY, QUERY_KEY } from '../js/components/decorators/injection.consts.js';
123
+ export { LIST_ITEMS_KEY, QUERY_KEY, RESULT_WITH_VARIANTS_KEY, SELECTED_VARIANTS_KEY, SELECT_RESULT_VARIANT_KEY } from '../js/components/decorators/injection.consts.js';
122
124
  export { XInject, XProvide } from '../js/components/decorators/injection.decorators.js';
123
125
  export { Getter, State } from '../js/components/decorators/store.decorators.js';
124
126
  export { ItemsListInjectionMixin } from '../js/components/items-list-injection.mixin.js';
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -303,16 +303,6 @@
303
303
  --x-size-border-width-bottom-button-secondary: var(--x-size-border-width-button-secondary);
304
304
  --x-size-border-width-left-button-secondary: var(--x-size-border-width-button-secondary);
305
305
  }
306
- .x-button--tertiary.x-button,
307
- .x-button--tertiary .x-button {
308
- --x-color-background-button-default: var(--x-color-background-button-tertiary);
309
- --x-color-border-button-default: var(--x-color-border-button-tertiary);
310
- --x-color-text-button-default: var(--x-color-text-button-tertiary);
311
- --x-size-border-width-top-button-default: var(--x-size-border-width-top-button-tertiary);
312
- --x-size-border-width-right-button-default: var(--x-size-border-width-right-button-tertiary);
313
- --x-size-border-width-bottom-button-default: var(--x-size-border-width-bottom-button-tertiary);
314
- --x-size-border-width-left-button-default: var(--x-size-border-width-left-button-tertiary);
315
- }
316
306
  :root {
317
307
  --x-color-background-button-tertiary: var(--x-color-base-neutral-95);
318
308
  --x-color-border-button-tertiary: var(--x-color-base-neutral-70);
@@ -323,6 +313,16 @@
323
313
  --x-size-border-width-bottom-button-tertiary: var(--x-size-border-width-button-tertiary);
324
314
  --x-size-border-width-left-button-tertiary: var(--x-size-border-width-button-tertiary);
325
315
  }
316
+ .x-button--tertiary.x-button,
317
+ .x-button--tertiary .x-button {
318
+ --x-color-background-button-default: var(--x-color-background-button-tertiary);
319
+ --x-color-border-button-default: var(--x-color-border-button-tertiary);
320
+ --x-color-text-button-default: var(--x-color-text-button-tertiary);
321
+ --x-size-border-width-top-button-default: var(--x-size-border-width-top-button-tertiary);
322
+ --x-size-border-width-right-button-default: var(--x-size-border-width-right-button-tertiary);
323
+ --x-size-border-width-bottom-button-default: var(--x-size-border-width-bottom-button-tertiary);
324
+ --x-size-border-width-left-button-default: var(--x-size-border-width-left-button-tertiary);
325
+ }
326
326
  .x-dropdown--card {
327
327
  --x-size-gap-dropdown-default: var(--x-size-gap-dropdown-card);
328
328
  --x-size-border-radius-dropdown-default: var(--x-size-border-radius-dropdown-card);
@@ -115,6 +115,8 @@ X-Components is a library usable everywhere not only for search experiences.
115
115
  | [RenderlessExtraParams](./x-components.renderlessextraparams.md) | It emits a [ExtraParamsXEvents.UserChangedExtraParams](./x-components.extraparamsxevents.userchangedextraparams.md) when the <code>updateValue</code> is called. |
116
116
  | [RenderlessFilter](./x-components.renderlessfilter.md) | Renders default slot content. It binds to the default slot a [BooleanFilter](./x-types.booleanfilter.md)<!-- -->, the [XEvents](./x-components.xevent.md) that will be emitted when clicking the content, the css classes and if the content should be disabled. |
117
117
  | [ResultsList](./x-components.resultslist.md) | It renders a [ItemsList](./x-components.itemslist.md) list with the results from [SearchState.results](./x-components.searchstate.results.md) by default.<!-- -->The component provides a default slot which wraps the whole component with the <code>results</code> bound.<!-- -->It also provides the slot result to customize the item, which is within the default slot, with the result bound. |
118
+ | [ResultVariantSelector](./x-components.resultvariantselector.md) | Component to show and select the available variants of a product for a given nest level. TODO: Add logger warning on mount when result is not injected. |
119
+ | [ResultVariantsProvider](./x-components.resultvariantsprovider.md) | Component that exposes the result merged with its selected variant in the default slot.<!-- -->It receives the original result and keeps track of the selected variant.<!-- -->It provides the original result, the array containing the selected variants and a callback to set the selected variant to be used from a child. |
118
120
  | [Scroll](./x-components.scroll.md) | Scrollable container that emits scroll related X Events. It exposes all the listeners and props from the [BaseScroll](./x-components.basescroll.md) component. |
119
121
  | [ScrollMixin](./x-components.scrollmixin.md) | Mixin to share Scroll logic. |
120
122
  | [ScrollToTop](./x-components.scrolltotop.md) | The <code>ScrollToTop</code> component is a button that the user can click to make a container scroll up to its initial position. |
@@ -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; [ResultVariantSelector](./x-components.resultvariantselector.md) &gt; [level](./x-components.resultvariantselector.level.md)
4
+
5
+ ## ResultVariantSelector.level property
6
+
7
+ The nest level of the variants to be rendered.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ level: number;
13
+ ```
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [ResultVariantSelector](./x-components.resultvariantselector.md)
4
+
5
+ ## ResultVariantSelector class
6
+
7
+ Component to show and select the available variants of a product for a given nest level. TODO: Add logger warning on mount when result is not injected.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ export default class ResultVariantSelector extends Vue
13
+ ```
14
+ <b>Extends:</b> Vue
15
+
16
+ ## Properties
17
+
18
+ | Property | Modifiers | Type | Description |
19
+ | --- | --- | --- | --- |
20
+ | [level](./x-components.resultvariantselector.level.md) | | number | The nest level of the variants to be rendered. |
21
+ | [result](./x-components.resultvariantselector.result.md) | | Result | The original result, used to retrieve the available variants for the level. |
22
+ | [selectedVariants](./x-components.resultvariantselector.selectedvariants.md) | | ResultVariant\[\] | Array containing the selected variants. |
23
+ | [selectResultVariant](./x-components.resultvariantselector.selectresultvariant.md) | | (variant: ResultVariant, level?: number) =&gt; void | Callback to be called when a variant is selected. |
24
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [ResultVariantSelector](./x-components.resultvariantselector.md) &gt; [result](./x-components.resultvariantselector.result.md)
4
+
5
+ ## ResultVariantSelector.result property
6
+
7
+ The original result, used to retrieve the available variants for the level.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ result: Result;
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; [ResultVariantSelector](./x-components.resultvariantselector.md) &gt; [selectedVariants](./x-components.resultvariantselector.selectedvariants.md)
4
+
5
+ ## ResultVariantSelector.selectedVariants property
6
+
7
+ Array containing the selected variants.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ selectedVariants: ResultVariant[];
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; [ResultVariantSelector](./x-components.resultvariantselector.md) &gt; [selectResultVariant](./x-components.resultvariantselector.selectresultvariant.md)
4
+
5
+ ## ResultVariantSelector.selectResultVariant property
6
+
7
+ Callback to be called when a variant is selected.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ selectResultVariant: (variant: ResultVariant, level?: number) => void;
13
+ ```
@@ -0,0 +1,34 @@
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; [ResultVariantsProvider](./x-components.resultvariantsprovider.md)
4
+
5
+ ## ResultVariantsProvider class
6
+
7
+ Component that exposes the result merged with its selected variant in the default slot.
8
+
9
+ It receives the original result and keeps track of the selected variant.
10
+
11
+ It provides the original result, the array containing the selected variants and a callback to set the selected variant to be used from a child.
12
+
13
+ <b>Signature:</b>
14
+
15
+ ```typescript
16
+ export default class ResultVariantsProvider extends Vue
17
+ ```
18
+ <b>Extends:</b> Vue
19
+
20
+ ## Properties
21
+
22
+ | Property | Modifiers | Type | Description |
23
+ | --- | --- | --- | --- |
24
+ | [result](./x-components.resultvariantsprovider.result.md) | | Result | The original result containing the variants. |
25
+ | [resultToProvide](./x-components.resultvariantsprovider.resulttoprovide.md) | | Result | Merges the original result with the selected variant. The merge is done with all the selected variants of the array. |
26
+ | [selectedVariants](./x-components.resultvariantsprovider.selectedvariants.md) | | ResultVariant\[\] | Array to keep track of the selected variants of the result. Each position of the array is a nest level in the variants' hierarchy, so, the second position will contain a variant that is present inside the variant of the first position, and so on. |
27
+
28
+ ## Methods
29
+
30
+ | Method | Modifiers | Description |
31
+ | --- | --- | --- |
32
+ | [render(createElement)](./x-components.resultvariantsprovider.render.md) | | Render function of the provider. It exposes the result with the selected variant merged. |
33
+ | [selectResultVariant(variant, level)](./x-components.resultvariantsprovider.selectresultvariant.md) | | Selects a variant of the result. When called, it slices the array of selected variants to remove the selected child variants. Emits the [XEventsTypes.UserSelectedAResultVariant](./x-components.xeventstypes.userselectedaresultvariant.md) when called. |
34
+
@@ -0,0 +1,26 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [ResultVariantsProvider](./x-components.resultvariantsprovider.md) &gt; [render](./x-components.resultvariantsprovider.render.md)
4
+
5
+ ## ResultVariantsProvider.render() method
6
+
7
+ Render function of the provider. It exposes the result with the selected variant merged.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ render(createElement: CreateElement): VNode;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | createElement | CreateElement | Vue createElement method. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ VNode
24
+
25
+ - The VNode of the first element passed in the slot.
26
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [ResultVariantsProvider](./x-components.resultvariantsprovider.md) &gt; [result](./x-components.resultvariantsprovider.result.md)
4
+
5
+ ## ResultVariantsProvider.result property
6
+
7
+ The original result containing the variants.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ result: Result;
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; [ResultVariantsProvider](./x-components.resultvariantsprovider.md) &gt; [resultToProvide](./x-components.resultvariantsprovider.resulttoprovide.md)
4
+
5
+ ## ResultVariantsProvider.resultToProvide property
6
+
7
+ Merges the original result with the selected variant. The merge is done with all the selected variants of the array.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ get resultToProvide(): Result;
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; [ResultVariantsProvider](./x-components.resultvariantsprovider.md) &gt; [selectedVariants](./x-components.resultvariantsprovider.selectedvariants.md)
4
+
5
+ ## ResultVariantsProvider.selectedVariants property
6
+
7
+ Array to keep track of the selected variants of the result. Each position of the array is a nest level in the variants' hierarchy, so, the second position will contain a variant that is present inside the variant of the first position, and so on.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ selectedVariants: ResultVariant[];
13
+ ```
@@ -0,0 +1,25 @@
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; [ResultVariantsProvider](./x-components.resultvariantsprovider.md) &gt; [selectResultVariant](./x-components.resultvariantsprovider.selectresultvariant.md)
4
+
5
+ ## ResultVariantsProvider.selectResultVariant() method
6
+
7
+ Selects a variant of the result. When called, it slices the array of selected variants to remove the selected child variants. Emits the [XEventsTypes.UserSelectedAResultVariant](./x-components.xeventstypes.userselectedaresultvariant.md) when called.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ selectResultVariant(variant: ResultVariant, level?: number): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | variant | ResultVariant | The variant to set. |
20
+ | level | number | The nest level where the variant is placed inside the result. |
21
+
22
+ <b>Returns:</b>
23
+
24
+ void
25
+
@@ -45,5 +45,6 @@ Aside from common [XEvents](./x-components.xevent.md)<!-- -->, this interface al
45
45
  | [UserOpenXProgrammatically](./x-components.xeventstypes.useropenxprogrammatically.md) | void | The user opened X programmatically. Payload: none. |
46
46
  | [UserPressedArrowKey](./x-components.xeventstypes.userpressedarrowkey.md) | [ArrowKey](./x-components.arrowkey.md) | The user pressed an [arrow key](./x-components.arrowkey.md) with the focus on the search-box. Payload: the pressed [arrow key](./x-components.arrowkey.md)<!-- -->. |
47
47
  | [UserReachedEmpathizeTop](./x-components.xeventstypes.userreachedempathizetop.md) | void | The user has reached the top of the empathize and keeps navigating in that direction. Payload: none. |
48
+ | [UserSelectedAResultVariant](./x-components.xeventstypes.userselectedaresultvariant.md) | { result: Result; variant: ResultVariant; level: number; } | The user selected a result variant. Payload: And object containing the result, the selected variant and the level of the selected variant. |
48
49
  | [UserSelectedASuggestion](./x-components.xeventstypes.userselectedasuggestion.md) | Suggestion | User selected any kind of suggestion (query-suggestion, popular-search...) Payload: The [suggestion](./x-types.suggestion.md) that the user selected. |
49
50
 
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [XEventsTypes](./x-components.xeventstypes.md) &gt; [UserSelectedAResultVariant](./x-components.xeventstypes.userselectedaresultvariant.md)
4
+
5
+ ## XEventsTypes.UserSelectedAResultVariant property
6
+
7
+ The user selected a result variant. Payload: And object containing the result, the selected variant and the level of the selected variant.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ UserSelectedAResultVariant: {
13
+ result: Result;
14
+ variant: ResultVariant;
15
+ level: number;
16
+ };
17
+ ```
@@ -0,0 +1,300 @@
1
+ ---
2
+
3
+ title: ResultVariantSelector
4
+
5
+ ---
6
+
7
+ # ResultVariantSelector
8
+
9
+ Component to show and select the available variants of a product for a given nest level.
10
+ TODO: Add logger warning on mount when result is not injected.
11
+
12
+ ## Props
13
+
14
+ | Name | Description | Type | Default |
15
+ | ------------------ | ---------------------------------------------- | ------------------- | -------------- |
16
+ | <code>level</code> | The nest level of the variants to be rendered. | <code>number</code> | <code>0</code> |
17
+
18
+ ## Slots
19
+
20
+ | Name | Description | Bindings<br />(name - type - description) |
21
+ | ---------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
22
+ | <code>default</code> | Variants list | **variants** <code>ResultVariant[]</code> - Array containing the available variants<br />**selectedVariant** <code>ResultVariant \| undefined</code> - The selected variant<br />**selectVariant** <code>(variant: ResultVariant) => void</code> - Callback to select a variant |
23
+ | <code>variant</code> | Variant item | **variant** <code>ResultVariant</code> - The variant item<br />**isSelected** <code>boolean</code> - Indicates if the variant is selected<br />**selectVariant** <code>() => void</code> - Callback to select the variant |
24
+ | <code>variant-content</code> | Variant content | **variant** <code>ResultVariant</code> - The variant item<br />**isSelected** <code>boolean</code> - Indicates if the variant is selected |
25
+
26
+ ## Events
27
+
28
+ This component doesn't emit events.
29
+
30
+ ## See it in action
31
+
32
+ Here you have a basic example of how the `ResultVariantSelector` component is rendered.
33
+
34
+ Take into account that this component **must** be a child of a `ResultVariantsProvider` component.
35
+
36
+ Also, the component is intended to be used overwriting the content with the slots.
37
+
38
+ By default it will render a list of buttons containing the available variants.
39
+
40
+ This component only has a required `level` prop, that indicates the level of the variants to be
41
+ rendered.
42
+
43
+ ```vue
44
+ <template>
45
+ <ResultVariantsProvider :result="result" #default="{ result }">
46
+ <p>Result name: {{ result.name }}</p>
47
+
48
+ <h1>Select color</h1>
49
+ <ResultVariantSelector :level="0" #variant="{ variant, selectVariant }" />
50
+
51
+ <h1>Select size</h1>
52
+ <ResultVariantSelector :level="1" #variant="{ variant, selectVariant }" />
53
+ </ResultVariantsProvider>
54
+ </template>
55
+
56
+ <script>
57
+ import {
58
+ ResultVariantsProvider,
59
+ ResultVariantSelector
60
+ } from "@empathyco/x-components";
61
+
62
+ export default {
63
+ name: "ResultVariantSelectorDemo",
64
+ components: {
65
+ ResultVariantsProvider,
66
+ ResultVariantSelector
67
+ },
68
+ data() {
69
+ return {
70
+ result: {
71
+ id: "jacket",
72
+ modelName: "Result",
73
+ type: "Product",
74
+ isWishlisted: false,
75
+ identifier: { value: "jacket" },
76
+ images: [],
77
+ name: "jacket",
78
+ price: { hasDiscount: false, originalValue: 10, value: 10 },
79
+ url: "/products/jacket",
80
+ variants: [
81
+ {
82
+ name: "red",
83
+ variants: [
84
+ {
85
+ name: "red XL"
86
+ },
87
+ {
88
+ name: "red L"
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ name: "blue",
94
+ variants: [
95
+ {
96
+ name: "blue S"
97
+ },
98
+ {
99
+ name: "blue M"
100
+ },
101
+ {
102
+ name: "blue L"
103
+ }
104
+ ]
105
+ }
106
+ ]
107
+ }
108
+ };
109
+ }
110
+ };
111
+ </script>
112
+ ```
113
+
114
+ ### Play with the default slot
115
+
116
+ In this example the default slot is used to customize the list.
117
+
118
+ ```vue
119
+ <template>
120
+ <ResultVariantsProvider :result="result" #default="{ result }">
121
+ <p>Result name: {{ result.name }}</p>
122
+
123
+ <ResultVariantSelector
124
+ :level="0"
125
+ #default="{ variants, selectedVariant, selectVariant }"
126
+ >
127
+ <div>
128
+ <p v-if="selectedVariant">
129
+ Selected variant: {{ selectedVariant.name }}
130
+ </p>
131
+ <ul class="x-list x-list--horizontal">
132
+ <li v-for="(variant, index) in variants" :key="index">
133
+ <button @click="selectVariant(variant)">{{ variant.name }}</button>
134
+ </li>
135
+ </ul>
136
+ </div>
137
+ </ResultVariantSelector>
138
+ </ResultVariantsProvider>
139
+ </template>
140
+
141
+ <script>
142
+ import {
143
+ ResultVariantsProvider,
144
+ ResultVariantSelector
145
+ } from "@empathyco/x-components";
146
+
147
+ export default {
148
+ name: "ResultVariantSelectorDemo",
149
+ components: {
150
+ ResultVariantsProvider,
151
+ ResultVariantSelector
152
+ },
153
+ data() {
154
+ return {
155
+ result: {
156
+ id: "jacket",
157
+ modelName: "Result",
158
+ type: "Product",
159
+ isWishlisted: false,
160
+ identifier: { value: "jacket" },
161
+ images: [],
162
+ name: "jacket",
163
+ price: { hasDiscount: false, originalValue: 10, value: 10 },
164
+ url: "/products/jacket",
165
+ variants: [
166
+ {
167
+ name: "red"
168
+ },
169
+ {
170
+ name: "blue"
171
+ }
172
+ ]
173
+ }
174
+ };
175
+ }
176
+ };
177
+ </script>
178
+ ```
179
+
180
+ ### Play with variant-slot
181
+
182
+ In this example the variant-slot is used to customize the variant item.
183
+
184
+ The variant will be rendered inside a list.
185
+
186
+ ```vue
187
+ <template>
188
+ <ResultVariantsProvider :result="result" #default="{ result }">
189
+ <p>Result name: {{ result.name }}</p>
190
+
191
+ <ResultVariantSelector
192
+ :level="0"
193
+ #variant="{ variant, isSelected, selectVariant }"
194
+ >
195
+ <div>
196
+ <button @click="selectVariant">
197
+ {{ variant.name }}
198
+ <span v-if="isSelected">SELECTED!</span>
199
+ </button>
200
+ </div>
201
+ </ResultVariantSelector>
202
+ </ResultVariantsProvider>
203
+ </template>
204
+
205
+ <script>
206
+ import {
207
+ ResultVariantsProvider,
208
+ ResultVariantSelector
209
+ } from "@empathyco/x-components";
210
+
211
+ export default {
212
+ name: "ResultVariantSelectorDemo",
213
+ components: {
214
+ ResultVariantsProvider,
215
+ ResultVariantSelector
216
+ },
217
+ data() {
218
+ return {
219
+ result: {
220
+ id: "jacket",
221
+ modelName: "Result",
222
+ type: "Product",
223
+ isWishlisted: false,
224
+ identifier: { value: "jacket" },
225
+ images: [],
226
+ name: "jacket",
227
+ price: { hasDiscount: false, originalValue: 10, value: 10 },
228
+ url: "/products/jacket",
229
+ variants: [
230
+ {
231
+ name: "red"
232
+ },
233
+ {
234
+ name: "blue"
235
+ }
236
+ ]
237
+ }
238
+ };
239
+ }
240
+ };
241
+ </script>
242
+ ```
243
+
244
+ ### Play with variant-content slot
245
+
246
+ In this example the variant-content slot is used to customize the content of the default variant
247
+ button.
248
+
249
+ ```vue
250
+ <template>
251
+ <ResultVariantsProvider :result="result" #default="{ result }">
252
+ <p>Result name: {{ result.name }}</p>
253
+
254
+ <ResultVariantSelector #variant-content="{ variant, isSelected }">
255
+ <div>
256
+ {{ variant.name }}
257
+ <span v-if="isSelected">SELECTED!</span>
258
+ </div>
259
+ </ResultVariantSelector>
260
+ </ResultVariantsProvider>
261
+ </template>
262
+
263
+ <script>
264
+ import {
265
+ ResultVariantsProvider,
266
+ ResultVariantSelector
267
+ } from "@empathyco/x-components";
268
+
269
+ export default {
270
+ name: "ResultVariantSelectorDemo",
271
+ components: {
272
+ ResultVariantsProvider,
273
+ ResultVariantSelector
274
+ },
275
+ data() {
276
+ return {
277
+ result: {
278
+ id: "jacket",
279
+ modelName: "Result",
280
+ type: "Product",
281
+ isWishlisted: false,
282
+ identifier: { value: "jacket" },
283
+ images: [],
284
+ name: "jacket",
285
+ price: { hasDiscount: false, originalValue: 10, value: 10 },
286
+ url: "/products/jacket",
287
+ variants: [
288
+ {
289
+ name: "red"
290
+ },
291
+ {
292
+ name: "blue"
293
+ }
294
+ ]
295
+ }
296
+ };
297
+ }
298
+ };
299
+ </script>
300
+ ```