@empathyco/x-components 3.0.0-alpha.374 → 3.0.0-alpha.376

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
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
+ ## [3.0.0-alpha.376](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.375...@empathyco/x-components@3.0.0-alpha.376) (2023-05-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * **queries-preview:** make the QueryPreviewRequestUpdated not replaceable (#1203) ([ccccd90](https://github.com/empathyco/x/commit/ccccd908110080afd2d5ee06c828e2c2293b67ac))
12
+
13
+
14
+
15
+ ## [3.0.0-alpha.375](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.374...@empathyco/x-components@3.0.0-alpha.375) (2023-05-24)
16
+
17
+
18
+ ### Features
19
+
20
+ * **tagging:** add new type values to ResultFeature and FeatureLocation (#1209) ([a48dc72](https://github.com/empathyco/x/commit/a48dc720b10d7e8ad59445f684cee3fc18d9bb8d))
21
+
22
+
23
+
6
24
  ## [3.0.0-alpha.374](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.373...@empathyco/x-components@3.0.0-alpha.374) (2023-05-24)
7
25
 
8
26
  **Note:** Version bump only for package @empathyco/x-components
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  .x-uppercase {
2
4
  text-transform: uppercase;
3
5
  }
@@ -950,7 +952,6 @@
950
952
  [dir="rtl"] .x-margin--left-20 {
951
953
  margin-right: var(--x-size-base-20) !important;
952
954
  }
953
-
954
955
  .x-line-height--none {
955
956
  line-height: 1 !important;
956
957
  }
@@ -4817,6 +4818,23 @@
4817
4818
  --x-size-border-width-result-description-default: 0;
4818
4819
  --x-size-border-width-result-picture-default: 0;
4819
4820
  }
4821
+ :root {
4822
+ --x-color-border-result-default: var(--x-color-base-lead);
4823
+ --x-color-border-result-overlay-default: var(--x-color-border-result-default);
4824
+ --x-color-border-result-description-default: var(--x-color-border-result-default);
4825
+ --x-color-border-result-picture-default: var(--x-color-border-result-default);
4826
+ --x-color-background-result-default: transparent;
4827
+ --x-size-padding-result-default: 0;
4828
+ --x-size-padding-result-overlay-default: 0;
4829
+ --x-size-padding-result-description-default: 0;
4830
+ --x-size-gap-result-default: var(--x-size-base-03);
4831
+ --x-size-padding-result-picture-default: 0;
4832
+ --x-size-border-radius-result-default: var(--x-size-border-radius-base-none);
4833
+ --x-size-border-width-result-default: 0;
4834
+ --x-size-border-width-result-overlay-default: 0;
4835
+ --x-size-border-width-result-description-default: 0;
4836
+ --x-size-border-width-result-picture-default: 0;
4837
+ }
4820
4838
 
4821
4839
  .x-result {
4822
4840
  display: grid;
@@ -4871,25 +4889,16 @@
4871
4889
  }
4872
4890
  }
4873
4891
  :root {
4874
- --x-color-border-result-default: var(--x-color-base-lead);
4875
- --x-color-border-result-overlay-default: var(--x-color-border-result-default);
4876
- --x-color-border-result-description-default: var(--x-color-border-result-default);
4877
- --x-color-border-result-picture-default: var(--x-color-border-result-default);
4878
- --x-color-background-result-default: transparent;
4879
- --x-size-padding-result-default: 0;
4880
- --x-size-padding-result-overlay-default: 0;
4881
- --x-size-padding-result-description-default: 0;
4882
- --x-size-gap-result-default: var(--x-size-base-03);
4883
- --x-size-padding-result-picture-default: 0;
4884
- --x-size-border-radius-result-default: var(--x-size-border-radius-base-none);
4885
- --x-size-border-width-result-default: 0;
4886
- --x-size-border-width-result-overlay-default: 0;
4887
- --x-size-border-width-result-description-default: 0;
4888
- --x-size-border-width-result-picture-default: 0;
4892
+ --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
4889
4893
  }
4890
4894
  :root {
4891
4895
  --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
4892
4896
  }
4897
+
4898
+ .x-result.x-result--card {
4899
+ overflow: hidden;
4900
+ --x-size-border-radius-result-default: var(--x-size-border-radius-result-card);
4901
+ }
4893
4902
  :root {
4894
4903
  --x-size-height-progress-bar-line-default: var(--x-size-base-02);
4895
4904
  --x-size-width-progress-bar-line-default: var(--x-size-base-20);
@@ -4924,14 +4933,6 @@
4924
4933
  border-radius: var(--x-size-border-radius-progress-bar-default);
4925
4934
  background-color: var(--x-color-background-progress-bar-line-default);
4926
4935
  }
4927
- :root {
4928
- --x-size-border-radius-result-card: var(--x-size-border-radius-base-s);
4929
- }
4930
-
4931
- .x-result.x-result--card {
4932
- overflow: hidden;
4933
- --x-size-border-radius-result-default: var(--x-size-border-radius-result-card);
4934
- }
4935
4936
  :root {
4936
4937
  --x-number-zoom-scale-picture: 1.1;
4937
4938
  --x-number-zoom-duration-picture: 0.3s;
@@ -4950,14 +4951,14 @@
4950
4951
  :root {
4951
4952
  --x-number-aspect-ratio-picture: 1;
4952
4953
  }
4954
+ :root {
4955
+ --x-number-aspect-ratio-picture: 1;
4956
+ }
4953
4957
 
4954
4958
  .x-picture--fixed-ratio.x-picture {
4955
4959
  aspect-ratio: var(--x-number-aspect-ratio-picture);
4956
4960
  width: 100%;
4957
4961
  }
4958
- :root {
4959
- --x-number-aspect-ratio-picture: 1;
4960
- }
4961
4962
  :root {
4962
4963
  --x-size-border-radius-picture-default: 0;
4963
4964
  --x-size-border-radius-top-picture-default: var(--x-size-border-radius-picture-default);
@@ -5585,22 +5586,6 @@
5585
5586
  --x-size-font-message-default: var(--x-size-font-title3);
5586
5587
  --x-number-font-weight-message-default: var(--x-number-font-weight-title3);
5587
5588
  }
5588
- /* @deprecated */
5589
- :root {
5590
- --x-size-padding-list-01: var(--x-size-base-01);
5591
- --x-size-padding-list-02: var(--x-size-base-02);
5592
- --x-size-padding-list-03: var(--x-size-base-03);
5593
- --x-size-padding-list-04: var(--x-size-base-04);
5594
- --x-size-padding-list-05: var(--x-size-base-05);
5595
- --x-size-padding-list-06: var(--x-size-base-06);
5596
- --x-size-padding-list-07: var(--x-size-base-07);
5597
- --x-size-padding-list-08: var(--x-size-base-08);
5598
- --x-size-padding-list-09: var(--x-size-base-09);
5599
- --x-size-padding-list-10: var(--x-size-base-10);
5600
- --x-size-padding-list-11: var(--x-size-base-11);
5601
- --x-size-padding-list-12: var(--x-size-base-12);
5602
- --x-size-padding-list-13: var(--x-size-base-13);
5603
- }
5604
5589
  :root {
5605
5590
  --x-string-justify-message-default: center;
5606
5591
  --x-size-gap-message-default: var(--x-size-base-03);
@@ -5688,6 +5673,22 @@
5688
5673
  --x-size-padding-list-12: var(--x-size-base-12);
5689
5674
  --x-size-padding-list-13: var(--x-size-base-13);
5690
5675
  }
5676
+ /* @deprecated */
5677
+ :root {
5678
+ --x-size-padding-list-01: var(--x-size-base-01);
5679
+ --x-size-padding-list-02: var(--x-size-base-02);
5680
+ --x-size-padding-list-03: var(--x-size-base-03);
5681
+ --x-size-padding-list-04: var(--x-size-base-04);
5682
+ --x-size-padding-list-05: var(--x-size-base-05);
5683
+ --x-size-padding-list-06: var(--x-size-base-06);
5684
+ --x-size-padding-list-07: var(--x-size-base-07);
5685
+ --x-size-padding-list-08: var(--x-size-base-08);
5686
+ --x-size-padding-list-09: var(--x-size-base-09);
5687
+ --x-size-padding-list-10: var(--x-size-base-10);
5688
+ --x-size-padding-list-11: var(--x-size-base-11);
5689
+ --x-size-padding-list-12: var(--x-size-base-12);
5690
+ --x-size-padding-list-13: var(--x-size-base-13);
5691
+ }
5691
5692
 
5692
5693
  /* @deprecated */
5693
5694
  [class*=x-list--padding-].x-list.x-list--padding-top:not(.x-list--padding-right) {
@@ -8840,4 +8841,4 @@
8840
8841
  --x-size-border-radius-base-m: var(--x-size-base-06);
8841
8842
  --x-size-border-radius-base-pill: 99999px;
8842
8843
  --x-size-border-width-base: 1px;
8843
- }
8844
+ }
@@ -9,7 +9,7 @@ Indicates where the feature is placed.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'no_results' | 'none' | 'predictive_layer' | 'results' | 'pdp' | 'url_history' | 'url_history_pdp';
12
+ export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp';
13
13
  ```
14
14
 
15
15
  ## Example 1
@@ -9,5 +9,5 @@ The name of the tool that generated the results.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result';
12
+ export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result' | 'brand_recommendations' | 'semantics';
13
13
  ```
@@ -1 +1 @@
1
- {"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <NoElement v-if=\"queryPreviewResults && queryPreviewResults.totalResults\">\n <!--\n @slot Query Preview default slot.\n @binding {string} query - query\n @binding {Result[]} results - The results preview of the query preview\n @binding {number} totalResults - The total results of the search request\n -->\n <slot\n :query=\"query\"\n :results=\"queryPreviewResults.results\"\n :totalResults=\"queryPreviewResults.totalResults\"\n >\n <ul data-test=\"query-preview\" class=\"x-query-preview\">\n <li\n v-for=\"result in queryPreviewResults.results\"\n :key=\"result.id\"\n class=\"x-query-preview__item\"\n data-test=\"query-preview-item\"\n >\n <!--\n @slot Query Preview result slot.\n @binding {Result} result - A Query Preview result\n -->\n <slot name=\"result\" :result=\"result\">\n <span data-test=\"result-name\">{{ result.name }}</span>\n </slot>\n </li>\n </ul>\n </slot>\n </NoElement>\n</template>\n\n<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Prop, Inject, Watch } from 'vue-property-decorator';\n import { Dictionary } from '@empathyco/x-utils';\n import { SearchRequest, Result } from '@empathyco/x-types';\n import { State } from '../../../components/decorators/store.decorators';\n import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts';\n import { XProvide } from '../../../components/decorators/injection.decorators';\n import { xComponentMixin } from '../../../components/x-component.mixin';\n import { NoElement } from '../../../components/no-element';\n import { RequestStatus } from '../../../store';\n import { QueryFeature, FeatureLocation } from '../../../types/origin';\n import { QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import { createOrigin } from '../../../utils/origin';\n import { debounce } from '../../../utils/debounce';\n import { DebouncedFunction } from '../../../utils';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n @Component({\n components: {\n NoElement\n },\n mixins: [xComponentMixin(queriesPreviewXModule)]\n })\n export default class QueryPreview extends Vue {\n /**\n * The query to retrieve the results preview.\n *\n * @public\n */\n @Prop({\n required: true\n })\n protected query!: string;\n\n /**\n * The origin property for the request.\n *\n * @public\n */\n @Prop()\n protected queryFeature?: QueryFeature;\n\n /**\n * Number of query preview results to be rendered.\n *\n * @public\n */\n @Prop()\n protected maxItemsToRender?: number;\n\n /**\n * Debounce time in milliseconds for triggering the search requests.\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n @Prop({ default: 0 })\n public debounceTimeMs!: number;\n\n /**\n * The results preview of the queries preview mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n @State('queriesPreview', 'queriesPreview')\n public previewResults!: Dictionary<QueryPreviewItem>;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n @State('queriesPreview', 'params')\n public params!: Dictionary<unknown>;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n @State('queriesPreview', 'config')\n public config!: QueriesPreviewConfig;\n\n /**\n * The results to render from the state.\n *\n * @remarks The results list are provided with `items` key. It can be\n * concatenated with list items from components such as `BannersList`, `PromotedsList`,\n * `BaseGrid` or any component that injects the list.\n *\n * @returns A list of results.\n * @public\n */\n @XProvide(LIST_ITEMS_KEY)\n public get results(): Result[] | undefined {\n return this.queryPreviewResults?.results;\n }\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n @Inject({ default: undefined })\n protected location?: FeatureLocation;\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n * @internal\n */\n protected get queryPreviewRequest(): SearchRequest {\n const origin = createOrigin({\n feature: this.queryFeature,\n location: this.location\n });\n\n return {\n query: this.query,\n rows: this.config.maxItemsToRequest,\n extraParams: this.params,\n ...(origin && { origin })\n };\n }\n\n /**\n * Gets from the state the results preview of the query preview.\n *\n * @returns The results preview of the actual query preview.\n */\n public get queryPreviewResults(): Partial<QueryPreviewItem> | undefined {\n const previewResults = this.previewResults[this.query];\n return previewResults?.results\n ? {\n ...previewResults,\n results: previewResults.results.slice(0, this.maxItemsToRender)\n }\n : undefined;\n }\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined.\n *\n * @returns The search request object.\n * @internal\n */\n protected get emitQueryPreviewRequestUpdated(): DebouncedFunction<[SearchRequest]> {\n return debounce(request => {\n this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0 });\n }, this.debounceTimeMs);\n }\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n protected created(): void {\n this.$watch(\n () => this.queryPreviewRequest,\n request => this.emitQueryPreviewRequestUpdated(request)\n );\n this.emitQueryPreviewRequestUpdated(this.queryPreviewRequest);\n }\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n }\n\n /**\n * Cancels the previous request when the debounced function changes (e.g: the debounceTimeMs\n * prop changes or there is a request in progress that cancels it).\n *\n * @param _new - The new debounced function.\n * @param old - The previous debounced function.\n * @internal\n */\n @Watch('emitQueryPreviewRequestUpdated')\n protected cancelEmitPreviewRequestUpdated(\n _new: DebouncedFunction<[SearchRequest]>,\n old: DebouncedFunction<[SearchRequest]>\n ): void {\n old.cancel();\n }\n\n /**\n * Emits an event when the query results are loaded or fail to load.\n *\n * @param status - The status of the query preview request.\n * @internal\n */\n @Watch('queryPreviewResults.status')\n emitLoad(status: RequestStatus | undefined): void {\n if (status === 'success') {\n this.$emit(this.results?.length ? 'load' : 'error', this.query);\n } else if (status === 'error') {\n this.$emit('error', this.query);\n }\n }\n }\n</script>\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- `QueryPreviewRequestUpdated`: the event is emitted when the component is mounted and when the\n properties of the request object changes. The event payload is the `queryPreviewRequest` object.\n\n## Vue Events\n\nA list of vue events that the component will emit:\n\n- `load`: the event is emitted when the query results have been loaded.\n- `error`: the event is emitted if there is some error when retrieving the query results.\n\n## See it in action\n\nHere you have a basic example of how the QueryPreview is rendered. Keep in mind that this component\nis intended to be used overriding its default slot. By default it will only render the names of the\nresults.\n\n```vue live\n<template>\n <QueryPreview :query=\"query\" />\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n QueryPreview\n },\n data() {\n return {\n query: 'sandals'\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreview :query=\"query\" #default=\"{ totalResults, results }\">\n <section>\n <p>Total results: {{ totalResults }}</p>\n <SlidingPanel :resetOnContentChange=\"false\">\n <article\n v-for=\"result in results\"\n :key=\"result.id\"\n class=\"x-result\"\n style=\"max-width: 300px; overflow: hidden\"\n >\n <BaseResultLink :result=\"result\">\n <BaseResultImage :result=\"result\" class=\"x-result__picture\" />\n </BaseResultLink>\n <div class=\"x-result__description\">\n <BaseResultLink :result=\"result\">\n <h1 class=\"x-title3\">{{ result.name }}</h1>\n </BaseResultLink>\n </div>\n </article>\n </SlidingPanel>\n </section>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreview,\n SlidingPanel\n },\n data() {\n return {\n query: 'flip-flops'\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreview :query=\"query\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemoOverridingResultSlot',\n components: {\n QueryPreview\n },\n data() {\n return {\n query: 'flips-flops'\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the query preview has been limited to render a maximum of 4 results.\n\n```vue\n<template>\n <QueryPreview :maxItemsToRender=\"maxItemsToRender\" :query=\"query\" #default=\"{ results }\">\n <BaseGrid #default=\"{ item }\" :items=\"results\">\n <BaseResultLink :result=\"item\">\n <BaseResultImage :result=\"item\" />\n </BaseResultLink>\n </BaseGrid>\n </QueryPreview>\n</template>\n\n<script>\n import { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components';\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n BaseGrid,\n BaseResultImage,\n BaseResultLink,\n QueryPreview\n },\n data() {\n return {\n maxItemsToRender: 4,\n query: 'flips-flops'\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <NoElement v-if=\"queryPreviewResults && queryPreviewResults.totalResults\">\n <!--\n @slot Query Preview default slot.\n @binding {string} query - query\n @binding {Result[]} results - The results preview of the query preview\n @binding {number} totalResults - The total results of the search request\n -->\n <slot\n :query=\"query\"\n :results=\"queryPreviewResults.results\"\n :totalResults=\"queryPreviewResults.totalResults\"\n >\n <ul data-test=\"query-preview\" class=\"x-query-preview\">\n <li\n v-for=\"result in queryPreviewResults.results\"\n :key=\"result.id\"\n class=\"x-query-preview__item\"\n data-test=\"query-preview-item\"\n >\n <!--\n @slot Query Preview result slot.\n @binding {Result} result - A Query Preview result\n -->\n <slot name=\"result\" :result=\"result\">\n <span data-test=\"result-name\">{{ result.name }}</span>\n </slot>\n </li>\n </ul>\n </slot>\n </NoElement>\n</template>\n\n<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Prop, Inject, Watch } from 'vue-property-decorator';\n import { Dictionary } from '@empathyco/x-utils';\n import { SearchRequest, Result } from '@empathyco/x-types';\n import { State } from '../../../components/decorators/store.decorators';\n import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts';\n import { XProvide } from '../../../components/decorators/injection.decorators';\n import { xComponentMixin } from '../../../components/x-component.mixin';\n import { NoElement } from '../../../components/no-element';\n import { RequestStatus } from '../../../store';\n import { QueryFeature, FeatureLocation } from '../../../types/origin';\n import { QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import { createOrigin } from '../../../utils/origin';\n import { debounce } from '../../../utils/debounce';\n import { DebouncedFunction } from '../../../utils';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n @Component({\n components: {\n NoElement\n },\n mixins: [xComponentMixin(queriesPreviewXModule)]\n })\n export default class QueryPreview extends Vue {\n /**\n * The query to retrieve the results preview.\n *\n * @public\n */\n @Prop({\n required: true\n })\n protected query!: string;\n\n /**\n * The origin property for the request.\n *\n * @public\n */\n @Prop()\n protected queryFeature?: QueryFeature;\n\n /**\n * Number of query preview results to be rendered.\n *\n * @public\n */\n @Prop()\n protected maxItemsToRender?: number;\n\n /**\n * Debounce time in milliseconds for triggering the search requests.\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n @Prop({ default: 0 })\n public debounceTimeMs!: number;\n\n /**\n * The results preview of the queries preview mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n @State('queriesPreview', 'queriesPreview')\n public previewResults!: Dictionary<QueryPreviewItem>;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n @State('queriesPreview', 'params')\n public params!: Dictionary<unknown>;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n @State('queriesPreview', 'config')\n public config!: QueriesPreviewConfig;\n\n /**\n * The results to render from the state.\n *\n * @remarks The results list are provided with `items` key. It can be\n * concatenated with list items from components such as `BannersList`, `PromotedsList`,\n * `BaseGrid` or any component that injects the list.\n *\n * @returns A list of results.\n * @public\n */\n @XProvide(LIST_ITEMS_KEY)\n public get results(): Result[] | undefined {\n return this.queryPreviewResults?.results;\n }\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n @Inject({ default: undefined })\n protected location?: FeatureLocation;\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n * @internal\n */\n protected get queryPreviewRequest(): SearchRequest {\n const origin = createOrigin({\n feature: this.queryFeature,\n location: this.location\n });\n\n return {\n query: this.query,\n rows: this.config.maxItemsToRequest,\n extraParams: this.params,\n ...(origin && { origin })\n };\n }\n\n /**\n * Gets from the state the results preview of the query preview.\n *\n * @returns The results preview of the actual query preview.\n */\n public get queryPreviewResults(): Partial<QueryPreviewItem> | undefined {\n const previewResults = this.previewResults[this.query];\n return previewResults?.results\n ? {\n ...previewResults,\n results: previewResults.results.slice(0, this.maxItemsToRender)\n }\n : undefined;\n }\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined.\n *\n * @returns The search request object.\n * @internal\n */\n protected get emitQueryPreviewRequestUpdated(): DebouncedFunction<[SearchRequest]> {\n return debounce(request => {\n this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false });\n }, this.debounceTimeMs);\n }\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n protected created(): void {\n this.$watch(\n () => this.queryPreviewRequest,\n request => this.emitQueryPreviewRequestUpdated(request)\n );\n this.emitQueryPreviewRequestUpdated(this.queryPreviewRequest);\n }\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n }\n\n /**\n * Cancels the previous request when the debounced function changes (e.g: the debounceTimeMs\n * prop changes or there is a request in progress that cancels it).\n *\n * @param _new - The new debounced function.\n * @param old - The previous debounced function.\n * @internal\n */\n @Watch('emitQueryPreviewRequestUpdated')\n protected cancelEmitPreviewRequestUpdated(\n _new: DebouncedFunction<[SearchRequest]>,\n old: DebouncedFunction<[SearchRequest]>\n ): void {\n old.cancel();\n }\n\n /**\n * Emits an event when the query results are loaded or fail to load.\n *\n * @param status - The status of the query preview request.\n * @internal\n */\n @Watch('queryPreviewResults.status')\n emitLoad(status: RequestStatus | undefined): void {\n if (status === 'success') {\n this.$emit(this.results?.length ? 'load' : 'error', this.query);\n } else if (status === 'error') {\n this.$emit('error', this.query);\n }\n }\n }\n</script>\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- `QueryPreviewRequestUpdated`: the event is emitted when the component is mounted and when the\n properties of the request object changes. The event payload is the `queryPreviewRequest` object.\n\n## Vue Events\n\nA list of vue events that the component will emit:\n\n- `load`: the event is emitted when the query results have been loaded.\n- `error`: the event is emitted if there is some error when retrieving the query results.\n\n## See it in action\n\nHere you have a basic example of how the QueryPreview is rendered. Keep in mind that this component\nis intended to be used overriding its default slot. By default it will only render the names of the\nresults.\n\n```vue live\n<template>\n <QueryPreview :query=\"query\" />\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n QueryPreview\n },\n data() {\n return {\n query: 'sandals'\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreview :query=\"query\" #default=\"{ totalResults, results }\">\n <section>\n <p>Total results: {{ totalResults }}</p>\n <SlidingPanel :resetOnContentChange=\"false\">\n <article\n v-for=\"result in results\"\n :key=\"result.id\"\n class=\"x-result\"\n style=\"max-width: 300px; overflow: hidden\"\n >\n <BaseResultLink :result=\"result\">\n <BaseResultImage :result=\"result\" class=\"x-result__picture\" />\n </BaseResultLink>\n <div class=\"x-result__description\">\n <BaseResultLink :result=\"result\">\n <h1 class=\"x-title3\">{{ result.name }}</h1>\n </BaseResultLink>\n </div>\n </article>\n </SlidingPanel>\n </section>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreview,\n SlidingPanel\n },\n data() {\n return {\n query: 'flip-flops'\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreview :query=\"query\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemoOverridingResultSlot',\n components: {\n QueryPreview\n },\n data() {\n return {\n query: 'flips-flops'\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the query preview has been limited to render a maximum of 4 results.\n\n```vue\n<template>\n <QueryPreview :maxItemsToRender=\"maxItemsToRender\" :query=\"query\" #default=\"{ results }\">\n <BaseGrid #default=\"{ item }\" :items=\"results\">\n <BaseResultLink :result=\"item\">\n <BaseResultImage :result=\"item\" />\n </BaseResultLink>\n </BaseGrid>\n </QueryPreview>\n</template>\n\n<script>\n import { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components';\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n BaseGrid,\n BaseResultImage,\n BaseResultLink,\n QueryPreview\n },\n data() {\n return {\n maxItemsToRender: 4,\n query: 'flips-flops'\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -71,7 +71,7 @@ let QueryPreview = class QueryPreview extends Vue {
71
71
  */
72
72
  get emitQueryPreviewRequestUpdated() {
73
73
  return debounce(request => {
74
- this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0 });
74
+ this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false });
75
75
  }, this.debounceTimeMs);
76
76
  }
77
77
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"query-preview.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import Vue from 'vue';\n import { Component, Prop, Inject, Watch } from 'vue-property-decorator';\n import { Dictionary } from '@empathyco/x-utils';\n import { SearchRequest, Result } from '@empathyco/x-types';\n import { State } from '../../../components/decorators/store.decorators';\n import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts';\n import { XProvide } from '../../../components/decorators/injection.decorators';\n import { xComponentMixin } from '../../../components/x-component.mixin';\n import { NoElement } from '../../../components/no-element';\n import { RequestStatus } from '../../../store';\n import { QueryFeature, FeatureLocation } from '../../../types/origin';\n import { QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import { createOrigin } from '../../../utils/origin';\n import { debounce } from '../../../utils/debounce';\n import { DebouncedFunction } from '../../../utils';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n @Component({\n components: {\n NoElement\n },\n mixins: [xComponentMixin(queriesPreviewXModule)]\n })\n export default class QueryPreview extends Vue {\n /**\n * The query to retrieve the results preview.\n *\n * @public\n */\n @Prop({\n required: true\n })\n protected query!: string;\n\n /**\n * The origin property for the request.\n *\n * @public\n */\n @Prop()\n protected queryFeature?: QueryFeature;\n\n /**\n * Number of query preview results to be rendered.\n *\n * @public\n */\n @Prop()\n protected maxItemsToRender?: number;\n\n /**\n * Debounce time in milliseconds for triggering the search requests.\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n @Prop({ default: 0 })\n public debounceTimeMs!: number;\n\n /**\n * The results preview of the queries preview mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n @State('queriesPreview', 'queriesPreview')\n public previewResults!: Dictionary<QueryPreviewItem>;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n @State('queriesPreview', 'params')\n public params!: Dictionary<unknown>;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n @State('queriesPreview', 'config')\n public config!: QueriesPreviewConfig;\n\n /**\n * The results to render from the state.\n *\n * @remarks The results list are provided with `items` key. It can be\n * concatenated with list items from components such as `BannersList`, `PromotedsList`,\n * `BaseGrid` or any component that injects the list.\n *\n * @returns A list of results.\n * @public\n */\n @XProvide(LIST_ITEMS_KEY)\n public get results(): Result[] | undefined {\n return this.queryPreviewResults?.results;\n }\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n @Inject({ default: undefined })\n protected location?: FeatureLocation;\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n * @internal\n */\n protected get queryPreviewRequest(): SearchRequest {\n const origin = createOrigin({\n feature: this.queryFeature,\n location: this.location\n });\n\n return {\n query: this.query,\n rows: this.config.maxItemsToRequest,\n extraParams: this.params,\n ...(origin && { origin })\n };\n }\n\n /**\n * Gets from the state the results preview of the query preview.\n *\n * @returns The results preview of the actual query preview.\n */\n public get queryPreviewResults(): Partial<QueryPreviewItem> | undefined {\n const previewResults = this.previewResults[this.query];\n return previewResults?.results\n ? {\n ...previewResults,\n results: previewResults.results.slice(0, this.maxItemsToRender)\n }\n : undefined;\n }\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined.\n *\n * @returns The search request object.\n * @internal\n */\n protected get emitQueryPreviewRequestUpdated(): DebouncedFunction<[SearchRequest]> {\n return debounce(request => {\n this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0 });\n }, this.debounceTimeMs);\n }\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n protected created(): void {\n this.$watch(\n () => this.queryPreviewRequest,\n request => this.emitQueryPreviewRequestUpdated(request)\n );\n this.emitQueryPreviewRequestUpdated(this.queryPreviewRequest);\n }\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n }\n\n /**\n * Cancels the previous request when the debounced function changes (e.g: the debounceTimeMs\n * prop changes or there is a request in progress that cancels it).\n *\n * @param _new - The new debounced function.\n * @param old - The previous debounced function.\n * @internal\n */\n @Watch('emitQueryPreviewRequestUpdated')\n protected cancelEmitPreviewRequestUpdated(\n _new: DebouncedFunction<[SearchRequest]>,\n old: DebouncedFunction<[SearchRequest]>\n ): void {\n old.cancel();\n }\n\n /**\n * Emits an event when the query results are loaded or fail to load.\n *\n * @param status - The status of the query preview request.\n * @internal\n */\n @Watch('queryPreviewResults.status')\n emitLoad(status: RequestStatus | undefined): void {\n if (status === 'success') {\n this.$emit(this.results?.length ? 'load' : 'error', this.query);\n } else if (status === 'error') {\n this.$emit('error', this.query);\n }\n }\n }\n"],"names":[],"mappings":";;;;;;;;;;;;AAoDE;;;;;;AAMG;AAOY,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,GAAG,CAAA;AAwD3C;;;;;;;;;AASG;AAEH,IAAA,IAAW,OAAO,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC;KAC1C;AAUD;;;;;AAKG;AACH,IAAA,IAAc,mBAAmB,GAAA;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC;YAC1B,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACxB,SAAA,CAAC,CAAC;QAEH,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;AACjB,YAAA,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB;YACnC,WAAW,EAAE,IAAI,CAAC,MAAM;AACxB,YAAA,IAAI,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC;SAC1B,CAAC;KACH;AAED;;;;AAIG;AACH,IAAA,IAAW,mBAAmB,GAAA;QAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,cAAc,EAAE,OAAO;AAC5B,cAAE;AACE,gBAAA,GAAG,cAAc;AACjB,gBAAA,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CA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AA,EAAA,iCAAA,EAAA,IAAA,CAAA,CAAA;AASD,UAAA,CAAA;IADC,KAAK,CAAC,4BAA4B,CAAC;AAOnC,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,IAAA,CAAA,CAAA;AAlLkB,YAAY,GAAA,UAAA,CAAA;AANhC,IAAA,SAAS,CAAC;AACT,QAAA,UAAU,EAAE;YACV,SAAS;AACV,SAAA;AACD,QAAA,MAAM,EAAE,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;KACjD,CAAC;AACmB,CAAA,EAAA,YAAY,CAmLhC,CAAA;aAnLoB,YAAY;;;;"}
1
+ {"version":3,"file":"query-preview.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import Vue from 'vue';\n import { Component, Prop, Inject, Watch } from 'vue-property-decorator';\n import { Dictionary } from '@empathyco/x-utils';\n import { SearchRequest, Result } from '@empathyco/x-types';\n import { State } from '../../../components/decorators/store.decorators';\n import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts';\n import { XProvide } from '../../../components/decorators/injection.decorators';\n import { xComponentMixin } from '../../../components/x-component.mixin';\n import { NoElement } from '../../../components/no-element';\n import { RequestStatus } from '../../../store';\n import { QueryFeature, FeatureLocation } from '../../../types/origin';\n import { QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import { createOrigin } from '../../../utils/origin';\n import { debounce } from '../../../utils/debounce';\n import { DebouncedFunction } from '../../../utils';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n @Component({\n components: {\n NoElement\n },\n mixins: [xComponentMixin(queriesPreviewXModule)]\n })\n export default class QueryPreview extends Vue {\n /**\n * The query to retrieve the results preview.\n *\n * @public\n */\n @Prop({\n required: true\n })\n protected query!: string;\n\n /**\n * The origin property for the request.\n *\n * @public\n */\n @Prop()\n protected queryFeature?: QueryFeature;\n\n /**\n * Number of query preview results to be rendered.\n *\n * @public\n */\n @Prop()\n protected maxItemsToRender?: number;\n\n /**\n * Debounce time in milliseconds for triggering the search requests.\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n @Prop({ default: 0 })\n public debounceTimeMs!: number;\n\n /**\n * The results preview of the queries preview mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n @State('queriesPreview', 'queriesPreview')\n public previewResults!: Dictionary<QueryPreviewItem>;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n @State('queriesPreview', 'params')\n public params!: Dictionary<unknown>;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n @State('queriesPreview', 'config')\n public config!: QueriesPreviewConfig;\n\n /**\n * The results to render from the state.\n *\n * @remarks The results list are provided with `items` key. It can be\n * concatenated with list items from components such as `BannersList`, `PromotedsList`,\n * `BaseGrid` or any component that injects the list.\n *\n * @returns A list of results.\n * @public\n */\n @XProvide(LIST_ITEMS_KEY)\n public get results(): Result[] | undefined {\n return this.queryPreviewResults?.results;\n }\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n @Inject({ default: undefined })\n protected location?: FeatureLocation;\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n * @internal\n */\n protected get queryPreviewRequest(): SearchRequest {\n const origin = createOrigin({\n feature: this.queryFeature,\n location: this.location\n });\n\n return {\n query: this.query,\n rows: this.config.maxItemsToRequest,\n extraParams: this.params,\n ...(origin && { origin })\n };\n }\n\n /**\n * Gets from the state the results preview of the query preview.\n *\n * @returns The results preview of the actual query preview.\n */\n public get queryPreviewResults(): Partial<QueryPreviewItem> | undefined {\n const previewResults = this.previewResults[this.query];\n return previewResults?.results\n ? {\n ...previewResults,\n results: previewResults.results.slice(0, this.maxItemsToRender)\n }\n : undefined;\n }\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined.\n *\n * @returns The search request object.\n * @internal\n */\n protected get emitQueryPreviewRequestUpdated(): DebouncedFunction<[SearchRequest]> {\n return debounce(request => {\n this.$x.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false });\n }, this.debounceTimeMs);\n }\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n protected created(): void {\n this.$watch(\n () => this.queryPreviewRequest,\n request => this.emitQueryPreviewRequestUpdated(request)\n );\n this.emitQueryPreviewRequestUpdated(this.queryPreviewRequest);\n }\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n }\n\n /**\n * Cancels the previous request when the debounced function changes (e.g: the debounceTimeMs\n * prop changes or there is a request in progress that cancels it).\n *\n * @param _new - The new debounced function.\n * @param old - The previous debounced function.\n * @internal\n */\n @Watch('emitQueryPreviewRequestUpdated')\n protected cancelEmitPreviewRequestUpdated(\n _new: DebouncedFunction<[SearchRequest]>,\n old: DebouncedFunction<[SearchRequest]>\n ): void {\n old.cancel();\n }\n\n /**\n * Emits an event when the query results are loaded or fail to load.\n *\n * @param status - The status of the query preview request.\n * @internal\n */\n @Watch('queryPreviewResults.status')\n emitLoad(status: RequestStatus | undefined): void {\n if (status === 'success') {\n this.$emit(this.results?.length ? 'load' : 'error', this.query);\n } else if (status === 'error') {\n this.$emit('error', this.query);\n }\n }\n }\n"],"names":[],"mappings":";;;;;;;;;;;;AAoDE;;;;;;AAMG;AAOY,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,GAAG,CAAA;AAwD3C;;;;;;;;;AASG;AAEH,IAAA,IAAW,OAAO,GAAA;AAChB,QAAA,OAAO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0.0-alpha.374",
3
+ "version": "3.0.0-alpha.376",
4
4
  "description": "Empathy X Components",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -143,5 +143,5 @@
143
143
  "access": "public",
144
144
  "directory": "dist"
145
145
  },
146
- "gitHead": "1394c8e94386fa6f9f53ffd8cc7a70bbf359f6c1"
146
+ "gitHead": "7b9ea368adcc01551cdc64d7a6474fb42f65e0c0"
147
147
  }
@@ -19793,7 +19793,7 @@
19793
19793
  },
19794
19794
  {
19795
19795
  "kind": "Content",
19796
- "text": "'external' | 'my_history' | 'no_query' | 'no_results' | 'none' | 'predictive_layer' | 'results' | 'pdp' | 'url_history' | 'url_history_pdp'"
19796
+ "text": "'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp'"
19797
19797
  },
19798
19798
  {
19799
19799
  "kind": "Content",
@@ -43131,7 +43131,7 @@
43131
43131
  },
43132
43132
  {
43133
43133
  "kind": "Content",
43134
- "text": "'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result'"
43134
+ "text": "'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result' | 'brand_recommendations' | 'semantics'"
43135
43135
  },
43136
43136
  {
43137
43137
  "kind": "Content",
@@ -1963,7 +1963,7 @@ export class FallbackDisclaimer extends Vue_2 {
1963
1963
  }
1964
1964
 
1965
1965
  // @public
1966
- export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'no_results' | 'none' | 'predictive_layer' | 'results' | 'pdp' | 'url_history' | 'url_history_pdp';
1966
+ export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp';
1967
1967
 
1968
1968
  // @public
1969
1969
  export interface FetchAndSaveActions<Context extends XActionContext<StatusState, object, StatusMutations, object>, Request> {
@@ -4034,7 +4034,7 @@ export function resettableState(): {
4034
4034
  export const RESULT_WITH_VARIANTS_KEY: XInjectKey<Result>;
4035
4035
 
4036
4036
  // @public
4037
- export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result';
4037
+ export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result' | 'brand_recommendations' | 'semantics';
4038
4038
 
4039
4039
  // @public
4040
4040
  export type ResultOrigin = `${ResultFeature}:${FeatureLocation}`;
@@ -24,7 +24,7 @@ export type QueryFeature = 'search_box' | 'url' | 'query_suggestion' | 'next_que
24
24
  *
25
25
  * @public
26
26
  */
27
- export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result';
27
+ export type ResultFeature = 'search' | 'recommendations' | 'next_query_results' | 'partial_results' | 'identifier_result' | 'brand_recommendations' | 'semantics';
28
28
  /**
29
29
  * Indicates where the feature is placed.
30
30
  *
@@ -36,7 +36,7 @@ export type ResultFeature = 'search' | 'recommendations' | 'next_query_results'
36
36
  *
37
37
  * @public
38
38
  */
39
- export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'no_results' | 'none' | 'predictive_layer' | 'results' | 'pdp' | 'url_history' | 'url_history_pdp';
39
+ export type FeatureLocation = 'external' | 'my_history' | 'no_query' | 'results' | 'no_results' | 'low_results' | 'none' | 'predictive_layer' | 'pdp' | 'url_history' | 'url_history_pdp';
40
40
  /**
41
41
  * Parameters to create a {@link QueryOrigin} or {@link ResultOrigin}.
42
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../../src/types/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,YAAY,IAAI,eAAe,EAAE,CAAC;AAC/D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,aAAa,IAAI,eAAe,EAAE,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,KAAK,GACL,kBAAkB,GAClB,YAAY,GACZ,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,UAAU,CAAC;AAEf;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,MAAM,GACN,kBAAkB,GAClB,SAAS,GACT,KAAK,GACL,aAAa,GACb,iBAAiB,CAAC;AAEtB;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../../src/types/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,YAAY,IAAI,eAAe,EAAE,CAAC;AAC/D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,aAAa,IAAI,eAAe,EAAE,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,KAAK,GACL,kBAAkB,GAClB,YAAY,GACZ,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,UAAU,CAAC;AAEf;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,uBAAuB,GACvB,WAAW,CAAC;AAEhB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB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