@empathyco/x-components 3.0.0-alpha.407 → 3.0.0-alpha.409

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.409](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.408...@empathyco/x-components@3.0.0-alpha.409) (2023-09-15)
7
+
8
+
9
+ ### Features
10
+
11
+ * **scroll:** add top offset when automatically scrolling to main-scroll-item (#1277) ([42dc680](https://github.com/empathyco/x/commit/42dc680e3ee3af4ccda6454d967da0750d2bba7e))
12
+
13
+
14
+
15
+ ## [3.0.0-alpha.408](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.407...@empathyco/x-components@3.0.0-alpha.408) (2023-09-12)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * prevent flickering animation on query preview list second load ([e7141a3](https://github.com/empathyco/x/commit/e7141a3941284896bd9a341b8a81bfdfa07515c5))
21
+
22
+
23
+
6
24
  ## [3.0.0-alpha.407](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.406...@empathyco/x-components@3.0.0-alpha.407) (2023-09-07)
7
25
 
8
26
  **Note:** Version bump only for package @empathyco/x-components
@@ -1,5 +1,20 @@
1
1
 
2
2
 
3
+ .x-uppercase {
4
+ text-transform: uppercase;
5
+ }
6
+
7
+ .x-lowercase {
8
+ text-transform: lowercase;
9
+ }
10
+
11
+ .x-capitalize {
12
+ text-transform: capitalize;
13
+ }
14
+
15
+ .x-normal-case {
16
+ text-transform: none;
17
+ }
3
18
  .x-underline {
4
19
  -webkit-text-decoration-line: underline;
5
20
  text-decoration-line: underline;
@@ -19,21 +34,6 @@
19
34
  -webkit-text-decoration-line: none;
20
35
  text-decoration-line: none;
21
36
  }
22
- .x-uppercase {
23
- text-transform: uppercase;
24
- }
25
-
26
- .x-lowercase {
27
- text-transform: lowercase;
28
- }
29
-
30
- .x-capitalize {
31
- text-transform: capitalize;
32
- }
33
-
34
- .x-normal-case {
35
- text-transform: none;
36
- }
37
37
  .x-static {
38
38
  position: static !important;
39
39
  }
@@ -4955,14 +4955,6 @@
4955
4955
  :root {
4956
4956
  --x-number-aspect-ratio-picture: 1;
4957
4957
  }
4958
- :root {
4959
- --x-number-aspect-ratio-picture: 1;
4960
- }
4961
-
4962
- .x-picture--fixed-ratio.x-picture {
4963
- aspect-ratio: var(--x-number-aspect-ratio-picture);
4964
- width: 100%;
4965
- }
4966
4958
  :root {
4967
4959
  --x-size-border-radius-picture-default: 0;
4968
4960
  --x-size-border-radius-top-picture-default: var(--x-size-border-radius-picture-default);
@@ -4981,6 +4973,14 @@
4981
4973
  --x-mix-blend-mode-picture-fallback-default: var(--x-mix-blend-mode-picture-default);
4982
4974
  --x-mix-blend-mode-picture-placeholder-default: var(--x-mix-blend-mode-picture-default);
4983
4975
  }
4976
+ :root {
4977
+ --x-number-aspect-ratio-picture: 1;
4978
+ }
4979
+
4980
+ .x-picture--fixed-ratio.x-picture {
4981
+ aspect-ratio: var(--x-number-aspect-ratio-picture);
4982
+ width: 100%;
4983
+ }
4984
4984
  :root {
4985
4985
  --x-size-border-radius-picture-default: 0;
4986
4986
  --x-size-border-radius-top-picture-default: var(--x-size-border-radius-picture-default);
@@ -7417,6 +7417,12 @@
7417
7417
  .x-grid-list--cols-auto .x-grid-list__item {
7418
7418
  min-width: var(--x-size-min-width-grid-item);
7419
7419
  }
7420
+ .x-filter--justified.x-filter > *:last-child:not(.x-filter__label),
7421
+ .x-filter--justified.x-facet-filter > *:last-child:not(.x-filter__label),
7422
+ .x-filter--justified .x-filter > *:last-child:not(.x-filter__label),
7423
+ .x-filter--justified .x-facet-filter > *:last-child:not(.x-filter__label) {
7424
+ margin-left: auto;
7425
+ }
7420
7426
  :root {
7421
7427
  --x-size-margin-filter-children: 0;
7422
7428
  --x-size-padding-top-filter-children: 0;
@@ -7424,12 +7430,6 @@
7424
7430
  --x-size-padding-bottom-filter-children: 0;
7425
7431
  --x-size-padding-left-filter-children: var(--x-size-base-05);
7426
7432
  }
7427
- .x-filter--justified.x-filter > *:last-child:not(.x-filter__label),
7428
- .x-filter--justified.x-facet-filter > *:last-child:not(.x-filter__label),
7429
- .x-filter--justified .x-filter > *:last-child:not(.x-filter__label),
7430
- .x-filter--justified .x-facet-filter > *:last-child:not(.x-filter__label) {
7431
- margin-left: auto;
7432
- }
7433
7433
  :root {
7434
7434
  --x-size-margin-filter-children: 0;
7435
7435
  --x-size-padding-top-filter-children: 0;
@@ -8384,6 +8384,19 @@
8384
8384
  --x-size-border-width-bottom-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8385
8385
  --x-size-border-width-left-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8386
8386
  }
8387
+ :root {
8388
+ --x-size-gap-dropdown-card: var(--x-size-base-03);
8389
+ --x-size-border-radius-dropdown-card: var(--x-size-border-radius-base-s);
8390
+ --x-size-border-radius-top-left-dropdown-card: var(--x-size-border-radius-dropdown-card);
8391
+ --x-size-border-radius-top-right-dropdown-card: var(--x-size-border-radius-dropdown-card);
8392
+ --x-size-border-radius-bottom-right-dropdown-card: var(--x-size-border-radius-dropdown-card);
8393
+ --x-size-border-radius-bottom-left-dropdown-card: var(--x-size-border-radius-dropdown-card);
8394
+ --x-size-border-width-dropdown-list-card: var(--x-size-border-width-base);
8395
+ --x-size-border-width-top-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8396
+ --x-size-border-width-right-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8397
+ --x-size-border-width-bottom-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8398
+ --x-size-border-width-left-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8399
+ }
8387
8400
 
8388
8401
  .x-dropdown--card {
8389
8402
  --x-size-gap-dropdown-default: var(--x-size-gap-dropdown-card);
@@ -8414,19 +8427,6 @@
8414
8427
  --x-size-border-width-left-dropdown-list-card
8415
8428
  );
8416
8429
  }
8417
- :root {
8418
- --x-size-gap-dropdown-card: var(--x-size-base-03);
8419
- --x-size-border-radius-dropdown-card: var(--x-size-border-radius-base-s);
8420
- --x-size-border-radius-top-left-dropdown-card: var(--x-size-border-radius-dropdown-card);
8421
- --x-size-border-radius-top-right-dropdown-card: var(--x-size-border-radius-dropdown-card);
8422
- --x-size-border-radius-bottom-right-dropdown-card: var(--x-size-border-radius-dropdown-card);
8423
- --x-size-border-radius-bottom-left-dropdown-card: var(--x-size-border-radius-dropdown-card);
8424
- --x-size-border-width-dropdown-list-card: var(--x-size-border-width-base);
8425
- --x-size-border-width-top-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8426
- --x-size-border-width-right-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8427
- --x-size-border-width-bottom-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8428
- --x-size-border-width-left-dropdown-list-card: var(--x-size-border-width-dropdown-list-card);
8429
- }
8430
8430
  :root {
8431
8431
  --x-color-background-button-tertiary: var(--x-color-base-neutral-95);
8432
8432
  --x-color-border-button-tertiary: var(--x-color-base-neutral-70);
@@ -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; [QueryPreview](./x-components.querypreview.md) &gt; [clearOnDestroy](./x-components.querypreview.clearondestroy.md)
4
+
5
+ ## QueryPreview.clearOnDestroy property
6
+
7
+ Controls whether the QueryPreview should be removed from the state when the component is destroyed.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ clearOnDestroy: boolean;
13
+ ```
@@ -17,6 +17,7 @@ export default class QueryPreview extends Vue
17
17
 
18
18
  | Property | Modifiers | Type | Description |
19
19
  | --- | --- | --- | --- |
20
+ | [clearOnDestroy](./x-components.querypreview.clearondestroy.md) | | boolean | Controls whether the QueryPreview should be removed from the state when the component is destroyed. |
20
21
  | [config](./x-components.querypreview.config.md) | | [QueriesPreviewConfig](./x-components.queriespreviewconfig.md) | As the request is handled in this component, we need the config that will be used in the request. |
21
22
  | [debounceTimeMs](./x-components.querypreview.debouncetimems.md) | | number | Debounce time in milliseconds for triggering the search requests. It will default to 0 to fit the most common use case (pre-search), and it would work properly with a 250 value inside empathize. |
22
23
  | [maxItemsToRender?](./x-components.querypreview.maxitemstorender.md) | <code>protected</code> | number | _(Optional)_ Number of query preview results to be rendered. |
@@ -12,12 +12,13 @@ results.
12
12
 
13
13
  ## Props
14
14
 
15
- | Name | Description | Type | Default |
16
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | -------------- |
17
- | <code>query</code> | The query to retrieve the results preview. | <code>string</code> | <code></code> |
18
- | <code>queryFeature</code> | The origin property for the request. | <code>QueryFeature</code> | <code></code> |
19
- | <code>maxItemsToRender</code> | Number of query preview results to be rendered. | <code>number</code> | <code></code> |
20
- | <code>debounceTimeMs</code> | Debounce time in milliseconds for triggering the search requests.<br />It will default to 0 to fit the most common use case (pre-search),<br />and it would work properly with a 250 value inside empathize. | <code>number</code> | <code>0</code> |
15
+ | Name | Description | Type | Default |
16
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | ----------------- |
17
+ | <code>query</code> | The query to retrieve the results preview. | <code>string</code> | <code></code> |
18
+ | <code>queryFeature</code> | The origin property for the request. | <code>QueryFeature</code> | <code></code> |
19
+ | <code>maxItemsToRender</code> | Number of query preview results to be rendered. | <code>number</code> | <code></code> |
20
+ | <code>debounceTimeMs</code> | Debounce time in milliseconds for triggering the search requests.<br />It will default to 0 to fit the most common use case (pre-search),<br />and it would work properly with a 250 value inside empathize. | <code>number</code> | <code>0</code> |
21
+ | <code>clearOnDestroy</code> | Controls whether the QueryPreview should be removed from the state<br />when the component is destroyed. | <code>boolean</code> | <code>true</code> |
21
22
 
22
23
  ## Events
23
24
 
@@ -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, 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`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted when the component is mounted and when the properties of the request object\n 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 { Result, SearchRequest } 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 * 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 * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n @Prop({ default: true })\n public clearOnDestroy!: boolean;\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 * If the prop 'clearOnDestroy' is set to true, it also removes the QueryPreview\n * from the state when the component is destroyed.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n\n if (this.clearOnDestroy) {\n this.$x.emit('QueryPreviewUnmountedHook', this.query, { priority: 0, replaceable: false });\n }\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`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted when the component is mounted and when the properties of the request object\n 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -86,11 +86,16 @@ let QueryPreview = class QueryPreview extends Vue {
86
86
  /**
87
87
  * Cancels the (remaining) requests when the component is destroyed
88
88
  * via the `debounce.cancel()` method.
89
+ * If the prop 'clearOnDestroy' is set to true, it also removes the QueryPreview
90
+ * from the state when the component is destroyed.
89
91
  *
90
92
  * @internal
91
93
  */
92
94
  beforeDestroy() {
93
95
  this.emitQueryPreviewRequestUpdated.cancel();
96
+ if (this.clearOnDestroy) {
97
+ this.$x.emit('QueryPreviewUnmountedHook', this.query, { priority: 0, replaceable: false });
98
+ }
94
99
  }
95
100
  /**
96
101
  * Cancels the previous request when the debounced function changes (e.g: the debounceTimeMs
@@ -132,6 +137,9 @@ __decorate([
132
137
  __decorate([
133
138
  Prop({ default: 0 })
134
139
  ], QueryPreview.prototype, "debounceTimeMs", void 0);
140
+ __decorate([
141
+ Prop({ default: true })
142
+ ], QueryPreview.prototype, "clearOnDestroy", void 0);
135
143
  __decorate([
136
144
  State('queriesPreview', 'queriesPreview')
137
145
  ], QueryPreview.prototype, "previewResults", void 0);
@@ -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, 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,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,WAA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AA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAarC,UAAA,CAAA;IADC,QAAQ,CAAC,cAAc,CAAC;AAGxB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,SAAA,EAAA,IAAA,CAAA,CAAA;AAQD,UAAA,CAAA;AADC,IAAA,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACM,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAiFrC,UAAA,CAAA;IADC,KAAK,CAAC,gCAAgC,CAAC;AAMvC,CAAA,EAAA,YAAA,CAAA,SAAA,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 { Result, SearchRequest } 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 * 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 * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n @Prop({ default: true })\n public clearOnDestroy!: boolean;\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 * If the prop 'clearOnDestroy' is set to true, it also removes the QueryPreview\n * from the state when the component is destroyed.\n *\n * @internal\n */\n protected beforeDestroy(): void {\n this.emitQueryPreviewRequestUpdated.cancel();\n\n if (this.clearOnDestroy) {\n this.$x.emit('QueryPreviewUnmountedHook', this.query, { priority: 0, replaceable: false });\n }\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":";;;;;;;;;;;;AAmDE;;;;;;AAMG;AAOY,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,GAAG,CAAA;AAiE3C;;;;;;;;;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,E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CAAA,CAAA,CAAA;AAOpC,UAAA,CAAA;AADC,IAAA,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC;AACG,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAarC,UAAA,CAAA;IADC,QAAQ,CAAC,cAAc,CAAC;AAGxB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,SAAA,EAAA,IAAA,CAAA,CAAA;AAQD,UAAA,CAAA;AADC,IAAA,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACM,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAuFrC,UAAA,CAAA;IADC,KAAK,CAAC,gCAAgC,CAAC;AAMvC,CAAA,EAAA,YAAA,CAAA,SAAA,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;AAjMkB,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,CAkMhC,CAAA;aAlMoB,YAAY;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/queries-preview/wiring.ts"],"sourcesContent":["import {\n namespacedWireCommit,\n namespacedWireDispatch\n} from '../../wiring/namespaced-wires.factory';\nimport { createWiring } from '../../wiring/wiring.utils';\n\n/**\n * `queriesPreview` {@link XModuleName | XModule name}.\n *\n * @internal\n */\nconst moduleName = 'queriesPreview';\n\n/**\n * WireCommit for {@link QueriesPreviewXModule}.\n *\n * @internal\n */\nconst wireCommit = namespacedWireCommit(moduleName);\n\n/**\n * WireDispatch for {@link QueriesPreviewXModule}.\n *\n * @internal\n */\nconst wireDispatch = namespacedWireDispatch(moduleName);\n\n/**\n * Requests and stores the query preview results.\n *\n * @public\n */\nexport const fetchAndSaveQueryPreviewWire = wireDispatch('fetchAndSaveQueryPreview');\n\n/**\n * Clears a query preview from queries preview module.\n *\n * @public\n */\n\nexport const clearQueryPreviewWire = wireCommit('clearQueryPreview');\n\n/**\n * Sets the queries preview state `params`.\n *\n * @public\n */\nexport const setQueriesPreviewExtraParamsWire = wireCommit('setParams');\n\n/**\n * Wiring configuration for the {@link QueriesPreviewXModule | queriesPreview module}.\n *\n * @internal\n */\nexport const queriesPreviewWiring = createWiring({\n QueryPreviewRequestUpdated: {\n fetchAndSaveQueryPreviewWire\n },\n QueryPreviewUnmountedHook: {\n clearQueryPreviewWire\n },\n ExtraParamsChanged: {\n setQueriesPreviewExtraParamsWire\n }\n});\n"],"names":[],"mappings":";;;AAMA;;;;AAIG;AACH,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC;;;;AAIG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAEpD;;;;AAIG;AACH,MAAM,YAAY,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAExD;;;;AAIG;MACU,4BAA4B,GAAG,YAAY,CAAC,0BAA0B,EAAE;AAErF;;;;AAIG;MAEU,qBAAqB,GAAG,UAAU,CAAC,mBAAmB,EAAE;AAErE;;;;AAIG;MACU,gCAAgC,GAAG,UAAU,CAAC,WAAW,EAAE;AAExE;;;;AAIG;AACI,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAC/C,IAAA,0BAA0B,EAAE;QAC1B,4BAA4B;AAC7B,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,qBAAqB;AACtB,KAAA;AACD,IAAA,kBAAkB,EAAE;QAClB,gCAAgC;AACjC,KAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/queries-preview/wiring.ts"],"sourcesContent":["import {\n namespacedWireCommit,\n namespacedWireDispatch\n} from '../../wiring/namespaced-wires.factory';\nimport { createWiring } from '../../wiring/wiring.utils';\n\n/**\n * `queriesPreview` {@link XModuleName | XModule name}.\n *\n * @internal\n */\nconst moduleName = 'queriesPreview';\n\n/**\n * WireCommit for {@link QueriesPreviewXModule}.\n *\n * @internal\n */\nconst wireCommit = namespacedWireCommit(moduleName);\n\n/**\n * WireDispatch for {@link QueriesPreviewXModule}.\n *\n * @internal\n */\nconst wireDispatch = namespacedWireDispatch(moduleName);\n\n/**\n * Requests and stores the query preview results.\n *\n * @public\n */\nexport const fetchAndSaveQueryPreviewWire = wireDispatch('fetchAndSaveQueryPreview');\n\n/**\n * Clears a query preview from queries preview module.\n *\n * @public\n */\nexport const clearQueryPreviewWire = wireCommit('clearQueryPreview');\n\n/**\n * Sets the queries preview state `params`.\n *\n * @public\n */\nexport const setQueriesPreviewExtraParamsWire = wireCommit('setParams');\n\n/**\n * Wiring configuration for the {@link QueriesPreviewXModule | queriesPreview module}.\n *\n * @internal\n */\nexport const queriesPreviewWiring = createWiring({\n QueryPreviewRequestUpdated: {\n fetchAndSaveQueryPreviewWire\n },\n QueryPreviewUnmountedHook: {\n clearQueryPreviewWire\n },\n ExtraParamsChanged: {\n setQueriesPreviewExtraParamsWire\n }\n});\n"],"names":[],"mappings":";;;AAMA;;;;AAIG;AACH,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC;;;;AAIG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAEpD;;;;AAIG;AACH,MAAM,YAAY,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAExD;;;;AAIG;MACU,4BAA4B,GAAG,YAAY,CAAC,0BAA0B,EAAE;AAErF;;;;AAIG;MACU,qBAAqB,GAAG,UAAU,CAAC,mBAAmB,EAAE;AAErE;;;;AAIG;MACU,gCAAgC,GAAG,UAAU,CAAC,WAAW,EAAE;AAExE;;;;AAIG;AACI,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAC/C,IAAA,0BAA0B,EAAE;QAC1B,4BAA4B;AAC7B,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,qBAAqB;AACtB,KAAA;AACD,IAAA,kBAAkB,EAAE;QAClB,gCAAgC;AACjC,KAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"main-scroll-item.vue.js","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue"],"sourcesContent":["<template>\n <component :is=\"tag\" v-on=\"$listeners\" :data-scroll=\"item.id\">\n <slot />\n </component>\n</template>\n<script lang=\"ts\">\n import { Identifiable } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { XInject } from '../../../components/decorators/injection.decorators';\n import { scrollXModule } from '../x-module';\n import { ScrollObserverKey } from './scroll.const';\n import { ScrollVisibilityObserver } from './scroll.types';\n\n /**\n * Wrapper for elements contained in the {@link MainScroll} that should store/restore its\n * position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)]\n })\n export default class MainScrollItem extends Vue {\n /**\n * Rendered HTML node.\n *\n * @public\n */\n public $el!: HTMLElement;\n\n /**\n * The item data. Used to set the scroll identifier.\n *\n * @public\n */\n @Prop({ required: true })\n public item!: Identifiable;\n\n /**\n * The tag to render.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public tag!: string | typeof Vue;\n\n /**\n * Pending identifier scroll position to restore. If it matches the {@link MainScrollItem.item}\n * `id` property, this component should be scrolled into view.\n *\n * @internal\n */\n @State('scroll', 'pendingScrollTo')\n public pendingScrollTo!: string;\n\n /**\n * Observer to detect the first visible element.\n *\n * @internal\n */\n @XInject(ScrollObserverKey)\n public firstVisibleItemObserver!: ScrollVisibilityObserver | null;\n\n /**\n * Initialise scroll behavior.\n * - Observes the rendered element to detect if it is the first visible item.\n * - If the rendered element matches the {@link MainScrollItem.pendingScrollTo}, scrolls the\n * element into the first position of the view.\n *\n * @internal\n */\n async mounted(): Promise<void> {\n await this.$nextTick(); // Mounted does not guarantee that child components are mounted too\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.$watch('firstVisibleItemObserver', this.observeItem, { immediate: true });\n }\n\n /**\n * Detaches the observer from the rendered element to prevent memory leaks.\n *\n * @internal\n */\n beforeDestroy(): void {\n this.firstVisibleItemObserver?.unobserve(this.$el);\n }\n\n /**\n * Initialises the element visibility observation, stopping the previous one if it has.\n *\n * @param newObserver - The new observer for the HTML element.\n * @param oldObserver - The old observer for the HTML element.\n */\n observeItem(\n newObserver: ScrollVisibilityObserver | null,\n oldObserver: ScrollVisibilityObserver | null\n ): void {\n oldObserver?.unobserve(this.$el);\n newObserver?.observe(this.$el);\n if (this.pendingScrollTo === this.item.id) {\n this.$el.scrollIntoView();\n this.$x.emit('ScrollRestoreSucceeded');\n }\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis components emits the following events:\n\n- [`ScrollRestoreSucceeded`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component has no predefined template. It renders whatever you decide using the `tag` prop. It's\nmain purpose is to help storing and restoring the scroll position so URLs can be shared, and also to\nallow users to smoothly navigate back and forth.\n\nTo do so, it must be wrapped with the `MainScroll` component. In the following example we make use\nof all of these components. The URL is modified as the user scrolls.\n\n```vue\n<template>\n <div>\n <UrlHandler />\n <SearchInput />\n\n <MainScroll>\n <Scroll>\n <ResultsList #result=\"{ item }\">\n <MainScrollItem :item=\"item\" tag=\"article\">\n <BaseResultLink :item=\"item\">\n <img :src=\"item.images[0]\" />\n <p>{{ item.title }}</p>\n </BaseResultLink>\n </MainScrollItem>\n </ResultsList>\n </Scroll>\n </MainScroll>\n </div>\n</template>\n\n<script>\n import { MainScroll, Scroll, MainScrollItem } from '@empathyco/x-components/scroll';\n import { ResultsList } from '@empathyco/x-components/search';\n import { SearchInput } from '@empathyco/x-components/search-box';\n import { UrlHandler } from '@empathyco/x-components/url';\n\n export default {\n name: 'ScrollItemDemo',\n components: {\n Scroll,\n ResultsList,\n MainScroll,\n MainScrollItem,\n SearchInput,\n UrlHandler\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main-scroll-item.vue.js","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue"],"sourcesContent":["<template>\n <component :is=\"tag\" v-on=\"$listeners\" :data-scroll=\"item.id\">\n <slot />\n </component>\n</template>\n<script lang=\"ts\">\n import { Identifiable } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { XInject } from '../../../components/decorators/injection.decorators';\n import { scrollXModule } from '../x-module';\n import { ScrollObserverKey } from './scroll.const';\n import { ScrollVisibilityObserver } from './scroll.types';\n\n /**\n * Wrapper for elements contained in the {@link MainScroll} that should store/restore its\n * position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)]\n })\n export default class MainScrollItem extends Vue {\n /**\n * Rendered HTML node.\n *\n * @public\n */\n public $el!: HTMLElement;\n\n /**\n * The item data. Used to set the scroll identifier.\n *\n * @public\n */\n @Prop({ required: true })\n public item!: Identifiable;\n\n /**\n * The tag to render.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public tag!: string | typeof Vue;\n\n /**\n * Pending identifier scroll position to restore. If it matches the {@link MainScrollItem.item}\n * `id` property, this component should be scrolled into view.\n *\n * @internal\n */\n @State('scroll', 'pendingScrollTo')\n public pendingScrollTo!: string;\n\n /**\n * Observer to detect the first visible element.\n *\n * @internal\n */\n @XInject(ScrollObserverKey)\n public firstVisibleItemObserver!: ScrollVisibilityObserver | null;\n\n /**\n * Initialise scroll behavior.\n * - Observes the rendered element to detect if it is the first visible item.\n * - If the rendered element matches the {@link MainScrollItem.pendingScrollTo}, scrolls the\n * element into the first position of the view.\n *\n * @internal\n */\n async mounted(): Promise<void> {\n await this.$nextTick(); // Mounted does not guarantee that child components are mounted too\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.$watch('firstVisibleItemObserver', this.observeItem, { immediate: true });\n }\n\n /**\n * Detaches the observer from the rendered element to prevent memory leaks.\n *\n * @internal\n */\n beforeDestroy(): void {\n this.firstVisibleItemObserver?.unobserve(this.$el);\n }\n\n /**\n * Initialises the element visibility observation, stopping the previous one if it has.\n *\n * @param newObserver - The new observer for the HTML element.\n * @param oldObserver - The old observer for the HTML element.\n */\n observeItem(\n newObserver: ScrollVisibilityObserver | null,\n oldObserver: ScrollVisibilityObserver | null\n ): void {\n oldObserver?.unobserve(this.$el);\n newObserver?.observe(this.$el);\n if (this.pendingScrollTo === this.item.id) {\n Vue.nextTick(() => {\n this.$el.scrollIntoView({\n block: 'center'\n });\n });\n this.$x.emit('ScrollRestoreSucceeded');\n }\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis components emits the following events:\n\n- [`ScrollRestoreSucceeded`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component has no predefined template. It renders whatever you decide using the `tag` prop. It's\nmain purpose is to help storing and restoring the scroll position so URLs can be shared, and also to\nallow users to smoothly navigate back and forth.\n\nTo do so, it must be wrapped with the `MainScroll` component. In the following example we make use\nof all of these components. The URL is modified as the user scrolls.\n\n```vue\n<template>\n <div>\n <UrlHandler />\n <SearchInput />\n\n <MainScroll>\n <Scroll>\n <ResultsList #result=\"{ item }\">\n <MainScrollItem :item=\"item\" tag=\"article\">\n <BaseResultLink :item=\"item\">\n <img :src=\"item.images[0]\" />\n <p>{{ item.title }}</p>\n </BaseResultLink>\n </MainScrollItem>\n </ResultsList>\n </Scroll>\n </MainScroll>\n </div>\n</template>\n\n<script>\n import { MainScroll, Scroll, MainScrollItem } from '@empathyco/x-components/scroll';\n import { ResultsList } from '@empathyco/x-components/search';\n import { SearchInput } from '@empathyco/x-components/search-box';\n import { UrlHandler } from '@empathyco/x-components/url';\n\n export default {\n name: 'ScrollItemDemo',\n components: {\n Scroll,\n ResultsList,\n MainScroll,\n MainScrollItem,\n SearchInput,\n UrlHandler\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -189,7 +189,11 @@ let MainScrollItem = class MainScrollItem extends Vue {
189
189
  oldObserver?.unobserve(this.$el);
190
190
  newObserver?.observe(this.$el);
191
191
  if (this.pendingScrollTo === this.item.id) {
192
- this.$el.scrollIntoView();
192
+ Vue.nextTick(() => {
193
+ this.$el.scrollIntoView({
194
+ block: 'center'
195
+ });
196
+ });
193
197
  this.$x.emit('ScrollRestoreSucceeded');
194
198
  }
195
199
  }
@@ -1 +1 @@
1
- {"version":3,"file":"main-scroll-item.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n import { Identifiable } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { XInject } from '../../../components/decorators/injection.decorators';\n import { scrollXModule } from '../x-module';\n import { ScrollObserverKey } from './scroll.const';\n import { ScrollVisibilityObserver } from './scroll.types';\n\n /**\n * Wrapper for elements contained in the {@link MainScroll} that should store/restore its\n * position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)]\n })\n export default class MainScrollItem extends Vue {\n /**\n * Rendered HTML node.\n *\n * @public\n */\n public $el!: HTMLElement;\n\n /**\n * The item data. Used to set the scroll identifier.\n *\n * @public\n */\n @Prop({ required: true })\n public item!: Identifiable;\n\n /**\n * The tag to render.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public tag!: string | typeof Vue;\n\n /**\n * Pending identifier scroll position to restore. If it matches the {@link MainScrollItem.item}\n * `id` property, this component should be scrolled into view.\n *\n * @internal\n */\n @State('scroll', 'pendingScrollTo')\n public pendingScrollTo!: string;\n\n /**\n * Observer to detect the first visible element.\n *\n * @internal\n */\n @XInject(ScrollObserverKey)\n public firstVisibleItemObserver!: ScrollVisibilityObserver | null;\n\n /**\n * Initialise scroll behavior.\n * - Observes the rendered element to detect if it is the first visible item.\n * - If the rendered element matches the {@link MainScrollItem.pendingScrollTo}, scrolls the\n * element into the first position of the view.\n *\n * @internal\n */\n async mounted(): Promise<void> {\n await this.$nextTick(); // Mounted does not guarantee that child components are mounted too\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.$watch('firstVisibleItemObserver', this.observeItem, { immediate: true });\n }\n\n /**\n * Detaches the observer from the rendered element to prevent memory leaks.\n *\n * @internal\n */\n beforeDestroy(): void {\n this.firstVisibleItemObserver?.unobserve(this.$el);\n }\n\n /**\n * Initialises the element visibility observation, stopping the previous one if it has.\n *\n * @param newObserver - The new observer for the HTML element.\n * @param oldObserver - The old observer for the HTML element.\n */\n observeItem(\n newObserver: ScrollVisibilityObserver | null,\n oldObserver: ScrollVisibilityObserver | null\n ): void {\n oldObserver?.unobserve(this.$el);\n newObserver?.observe(this.$el);\n if (this.pendingScrollTo === this.item.id) {\n this.$el.scrollIntoView();\n this.$x.emit('ScrollRestoreSucceeded');\n }\n }\n }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeE;;;;;AAKG;AAIY,IAAM,cAAc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AAA,CAAA,CAAA;AAQhC,UAAA,CAAA;IADC,OAAO,CAAC,iBAAiB,CAAC;AACuC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,0BAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAvC/C,cAAc,GAAA,UAAA,CAAA;AAHlC,IAAA,SAAS,CAAC;AACT,QAAA,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;AACmB,CAAA,EAAA,cAAc,CAiFlC,CAAA;aAjFoB,cAAc;;;;"}
1
+ {"version":3,"file":"main-scroll-item.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n import { Identifiable } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { XInject } from '../../../components/decorators/injection.decorators';\n import { scrollXModule } from '../x-module';\n import { ScrollObserverKey } from './scroll.const';\n import { ScrollVisibilityObserver } from './scroll.types';\n\n /**\n * Wrapper for elements contained in the {@link MainScroll} that should store/restore its\n * position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)]\n })\n export default class MainScrollItem extends Vue {\n /**\n * Rendered HTML node.\n *\n * @public\n */\n public $el!: HTMLElement;\n\n /**\n * The item data. Used to set the scroll identifier.\n *\n * @public\n */\n @Prop({ required: true })\n public item!: Identifiable;\n\n /**\n * The tag to render.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public tag!: string | typeof Vue;\n\n /**\n * Pending identifier scroll position to restore. If it matches the {@link MainScrollItem.item}\n * `id` property, this component should be scrolled into view.\n *\n * @internal\n */\n @State('scroll', 'pendingScrollTo')\n public pendingScrollTo!: string;\n\n /**\n * Observer to detect the first visible element.\n *\n * @internal\n */\n @XInject(ScrollObserverKey)\n public firstVisibleItemObserver!: ScrollVisibilityObserver | null;\n\n /**\n * Initialise scroll behavior.\n * - Observes the rendered element to detect if it is the first visible item.\n * - If the rendered element matches the {@link MainScrollItem.pendingScrollTo}, scrolls the\n * element into the first position of the view.\n *\n * @internal\n */\n async mounted(): Promise<void> {\n await this.$nextTick(); // Mounted does not guarantee that child components are mounted too\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.$watch('firstVisibleItemObserver', this.observeItem, { immediate: true });\n }\n\n /**\n * Detaches the observer from the rendered element to prevent memory leaks.\n *\n * @internal\n */\n beforeDestroy(): void {\n this.firstVisibleItemObserver?.unobserve(this.$el);\n }\n\n /**\n * Initialises the element visibility observation, stopping the previous one if it has.\n *\n * @param newObserver - The new observer for the HTML element.\n * @param oldObserver - The old observer for the HTML element.\n */\n observeItem(\n newObserver: ScrollVisibilityObserver | null,\n oldObserver: ScrollVisibilityObserver | null\n ): void {\n oldObserver?.unobserve(this.$el);\n newObserver?.observe(this.$el);\n if (this.pendingScrollTo === this.item.id) {\n Vue.nextTick(() => {\n this.$el.scrollIntoView({\n block: 'center'\n });\n });\n this.$x.emit('ScrollRestoreSucceeded');\n }\n }\n }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeE;;;;;AAKG;AAIY,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,GAAG,CAAA;AAyC7C;;;;;;;AAOG;AACH,IAAA,MAAM,OAAO,GAAA;AACX,QAAA,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;;AAEvB,QAAA,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAChF;AAED;;;;AAIG;IACH,aAAa,GAAA;QACX,IAAI,CAAC,wBAAw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CAAC;AACT,QAAA,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;AACmB,CAAA,EAAA,cAAc,CAqFlC,CAAA;aArFoB,cAAc;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-components",
3
- "version": "3.0.0-alpha.407",
3
+ "version": "3.0.0-alpha.409",
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": "c5f5c8c6a59c1a9f98410d719f484afd26376cc9"
146
+ "gitHead": "ce1b2f9c5069026f19cb31f07b1ba17d877a67c7"
147
147
  }
@@ -37555,6 +37555,36 @@
37555
37555
  "name": "QueryPreview",
37556
37556
  "preserveMemberOrder": false,
37557
37557
  "members": [
37558
+ {
37559
+ "kind": "Property",
37560
+ "canonicalReference": "@empathyco/x-components!QueryPreview#clearOnDestroy:member",
37561
+ "docComment": "/**\n * Controls whether the QueryPreview should be removed from the state when the component is destroyed.\n *\n * @public\n */\n",
37562
+ "excerptTokens": [
37563
+ {
37564
+ "kind": "Content",
37565
+ "text": "clearOnDestroy: "
37566
+ },
37567
+ {
37568
+ "kind": "Content",
37569
+ "text": "boolean"
37570
+ },
37571
+ {
37572
+ "kind": "Content",
37573
+ "text": ";"
37574
+ }
37575
+ ],
37576
+ "isReadonly": false,
37577
+ "isOptional": false,
37578
+ "releaseTag": "Public",
37579
+ "name": "clearOnDestroy",
37580
+ "propertyTypeTokenRange": {
37581
+ "startIndex": 1,
37582
+ "endIndex": 2
37583
+ },
37584
+ "isStatic": false,
37585
+ "isProtected": false,
37586
+ "isAbstract": false
37587
+ },
37558
37588
  {
37559
37589
  "kind": "Property",
37560
37590
  "canonicalReference": "@empathyco/x-components!QueryPreview#config:member",
@@ -3501,6 +3501,7 @@ export class QueryPreview extends Vue_2 {
3501
3501
  protected beforeDestroy(): void;
3502
3502
  // @internal
3503
3503
  protected cancelEmitPreviewRequestUpdated(_new: DebouncedFunction<[SearchRequest]>, old: DebouncedFunction<[SearchRequest]>): void;
3504
+ clearOnDestroy: boolean;
3504
3505
  config: QueriesPreviewConfig;
3505
3506
  // @internal
3506
3507
  protected created(): void;
@@ -1,6 +1,6 @@
1
1
  import Vue from 'vue';
2
2
  import { Dictionary } from '@empathyco/x-utils';
3
- import { SearchRequest, Result } from '@empathyco/x-types';
3
+ import { Result, SearchRequest } from '@empathyco/x-types';
4
4
  import { RequestStatus } from '../../../store';
5
5
  import { QueryFeature, FeatureLocation } from '../../../types/origin';
6
6
  import { QueryPreviewItem } from '../store/types';
@@ -38,6 +38,13 @@ export default class QueryPreview extends Vue {
38
38
  * and it would work properly with a 250 value inside empathize.
39
39
  */
40
40
  debounceTimeMs: number;
41
+ /**
42
+ * Controls whether the QueryPreview should be removed from the state
43
+ * when the component is destroyed.
44
+ *
45
+ * @public
46
+ */
47
+ clearOnDestroy: boolean;
41
48
  /**
42
49
  * The results preview of the queries preview mounted.
43
50
  * It is a dictionary, indexed by the query preview query.
@@ -99,6 +106,8 @@ export default class QueryPreview extends Vue {
99
106
  /**
100
107
  * Cancels the (remaining) requests when the component is destroyed
101
108
  * via the `debounce.cancel()` method.
109
+ * If the prop 'clearOnDestroy' is set to true, it also removes the QueryPreview
110
+ * from the state when the component is destroyed.
102
111
  *
103
112
  * @internal
104
113
  */
@@ -1 +1 @@
1
- {"version":3,"file":"query-preview.vue?rollup-plugin-vue=script.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue?rollup-plugin-vue=script.ts"],"names":[],"mappings":"AAkCE,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM3D,OAAO,EAAE,aAAa,E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IAEH,SAAS,CAAC,+BAA+B,CACvC,IAAI,EAAE,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,EACxC,GAAG,EAAE,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,GACtC,IAAI;IAIP;;;;;OAKG;IAEH,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;CAOlD"}
1
+ {"version":3,"file":"query-preview.vue?rollup-plugin-vue=script.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue?rollup-plugin-vue=script.ts"],"names":[],"mappings":"AAkCE,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAM3D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAIvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD;;;;;;GAMG;AAOH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,GAAG;IAC3C;;;;OAIG;IAIH,SAAS,CAAC,KAAK,EAAG,MAAM,CAAC;IAEzB;;;;OAIG;IAEH,SAAS,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAEtC;;;;OAIG;IAEH,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;IAEI,cAAc,EAAG,MAAM,CAAC;IAE/B;;;;;OAKG;IAEI,cAAc,EAAG,OAAO,CAAC;IAEhC;;;OAGG;IAEI,cAAc,EAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAErD;;;OAGG;IAEI,MAAM,EAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpC;;;OAGG;IAEI,MAAM,EAAG,oBAAoB,CAAC;IAErC;;;;;;;;;OASG;IACH,IACW,OAAO,IAAI,MAAM,EAAE,GAAG,SAAS,CAEzC;IAED;;;;OAIG;IAEH,SAAS,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAErC;;;;;OAKG;IACH,SAAS,KAAK,mBAAmB,IAAI,aAAa,CAYjD;IAED;;;;OAIG;IACH,IAAW,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAQtE;IAED;;;;;OAKG;IACH,SAAS,KAAK,8BAA8B,IAAI,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,CAIjF;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;IAQzB;;;;;;;OAOG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI;IAQ/B;;;;;;;OAOG;IAEH,SAAS,CAAC,+BAA+B,CACvC,IAAI,EAAE,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,EACxC,GAAG,EAAE,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,GACtC,IAAI;IAIP;;;;;OAKG;IAEH,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;CAOlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../../../src/x-modules/queries-preview/wiring.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,kEAA2C,CAAC;AAErF;;;;GAIG;AAEH,eAAO,MAAM,qBAAqB,8BAAkC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,wEAA0B,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;CAU/B,CAAC"}
1
+ {"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../../../src/x-modules/queries-preview/wiring.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,kEAA2C,CAAC;AAErF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,8BAAkC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,wEAA0B,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;CAU/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"main-scroll-item.vue?rollup-plugin-vue=script.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue?rollup-plugin-vue=script.ts"],"names":[],"mappings":"AAME,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;GAKG;AAIH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,GAAG;IAC7C;;;;OAIG;IACI,GAAG,EAAG,WAAW,CAAC;IAEzB;;;;OAIG;IAEI,IAAI,EAAG,YAAY,CAAC;IAE3B;;;;OAIG;IAEI,GAAG,EAAG,MAAM,GAAG,OAAO,GAAG,CAAC;IAEjC;;;;;OAKG;IAEI,eAAe,EAAG,MAAM,CAAC;IAEhC;;;;OAIG;IAEI,wBAAwB,EAAG,wBAAwB,GAAG,IAAI,CAAC;IAElE;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAIrB;;;;;OAKG;IACH,WAAW,CACT,WAAW,EAAE,wBAAwB,GAAG,IAAI,EAC5C,WAAW,EAAE,wBAAwB,GAAG,IAAI,GAC3C,IAAI;CAQR"}
1
+ {"version":3,"file":"main-scroll-item.vue?rollup-plugin-vue=script.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/scroll/components/main-scroll-item.vue?rollup-plugin-vue=script.ts"],"names":[],"mappings":"AAME,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;GAKG;AAIH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,GAAG;IAC7C;;;;OAIG;IACI,GAAG,EAAG,WAAW,CAAC;IAEzB;;;;OAIG;IAEI,IAAI,EAAG,YAAY,CAAC;IAE3B;;;;OAIG;IAEI,GAAG,EAAG,MAAM,GAAG,OAAO,GAAG,CAAC;IAEjC;;;;;OAKG;IAEI,eAAe,EAAG,MAAM,CAAC;IAEhC;;;;OAIG;IAEI,wBAAwB,EAAG,wBAAwB,GAAG,IAAI,CAAC;IAElE;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAIrB;;;;;OAKG;IACH,WAAW,CACT,WAAW,EAAE,wBAAwB,GAAG,IAAI,EAC5C,WAAW,EAAE,wBAAwB,GAAG,IAAI,GAC3C,IAAI;CAYR"}