@empathyco/x-components 10.1.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/core/index.js.map +1 -1
- package/docs/API-reference/api/x-components.md +55 -0
- package/docs/API-reference/api/x-components.querypreview.md +1 -0
- package/docs/API-reference/api/x-components.relatedpromptquery.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptrequest.md +13 -0
- package/docs/API-reference/api/x-components.semanticqueriesnormalizedquery.md +13 -0
- package/docs/API-reference/api/x-components.semanticqueriesquery.md +13 -0
- package/docs/API-reference/api/x-components.semanticqueriesrequest.md +13 -0
- package/js/index.js +5 -0
- package/js/index.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue.js +13 -13
- package/js/x-modules/queries-preview/components/query-preview.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue2.js +26 -2
- package/js/x-modules/queries-preview/components/query-preview.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue3.js +7 -0
- package/js/x-modules/queries-preview/components/query-preview.vue3.js.map +1 -0
- package/package.json +2 -2
- package/related-prompts/index.js +2 -0
- package/report/x-components.api.json +151 -2
- package/report/x-components.api.md +16 -0
- package/semantic-queries/index.js +3 -0
- package/types/src/x-modules/queries-preview/components/query-preview.vue.d.ts +1 -0
- package/types/src/x-modules/queries-preview/components/query-preview.vue.d.ts.map +1 -1
- package/types/src/x-modules/related-prompts/store/index.d.ts +1 -0
- package/types/src/x-modules/related-prompts/store/index.d.ts.map +1 -1
- package/types/src/x-modules/semantic-queries/store/index.d.ts +1 -0
- package/types/src/x-modules/semantic-queries/store/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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
|
+
## [10.2.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.1.1...@empathyco/x-components@10.2.0) (2026-10-27)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **query-preview:** reserve a loading placeholder for lazy previews (#2192)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [10.1.1](https://github.com/empathyco/x/compare/@empathyco/x-components@10.1.0...@empathyco/x-components@10.1.1) (2026-10-19)
|
|
14
|
+
|
|
15
|
+
**Note:** Version bump only for package @empathyco/x-components
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
## [10.1.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.0.2...@empathyco/x-components@10.1.0) (2026-10-19)
|
|
7
22
|
|
|
8
23
|
### Features
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5987,6 +5987,28 @@ Default implementation for the [HistoryQueriesActions.refreshSession](./x-compon
|
|
|
5987
5987
|
This component shows a suggested related prompt.
|
|
5988
5988
|
|
|
5989
5989
|
|
|
5990
|
+
</td></tr>
|
|
5991
|
+
<tr><td>
|
|
5992
|
+
|
|
5993
|
+
[relatedPromptQuery](./x-components.relatedpromptquery.md)
|
|
5994
|
+
|
|
5995
|
+
|
|
5996
|
+
</td><td>
|
|
5997
|
+
|
|
5998
|
+
Default implementation for the related prompts query getter.
|
|
5999
|
+
|
|
6000
|
+
|
|
6001
|
+
</td></tr>
|
|
6002
|
+
<tr><td>
|
|
6003
|
+
|
|
6004
|
+
[relatedPromptRequest](./x-components.relatedpromptrequest.md)
|
|
6005
|
+
|
|
6006
|
+
|
|
6007
|
+
</td><td>
|
|
6008
|
+
|
|
6009
|
+
Default implementation for the [RelatedPromptsGetters.request](./x-components.relatedpromptsgetters.request.md) getter.
|
|
6010
|
+
|
|
6011
|
+
|
|
5990
6012
|
</td></tr>
|
|
5991
6013
|
<tr><td>
|
|
5992
6014
|
|
|
@@ -6718,6 +6740,39 @@ The property "alwaysVisible" handles if the component is rendered if no filters
|
|
|
6718
6740
|
Retrieves a list of semantic queries from the state and exposes them in the slots.
|
|
6719
6741
|
|
|
6720
6742
|
|
|
6743
|
+
</td></tr>
|
|
6744
|
+
<tr><td>
|
|
6745
|
+
|
|
6746
|
+
[semanticQueriesNormalizedQuery](./x-components.semanticqueriesnormalizedquery.md)
|
|
6747
|
+
|
|
6748
|
+
|
|
6749
|
+
</td><td>
|
|
6750
|
+
|
|
6751
|
+
Default implementacion for the [SemanticQueriesGetters.normalizedQuery](./x-components.semanticqueriesgetters.normalizedquery.md) getter.
|
|
6752
|
+
|
|
6753
|
+
|
|
6754
|
+
</td></tr>
|
|
6755
|
+
<tr><td>
|
|
6756
|
+
|
|
6757
|
+
[semanticQueriesQuery](./x-components.semanticqueriesquery.md)
|
|
6758
|
+
|
|
6759
|
+
|
|
6760
|
+
</td><td>
|
|
6761
|
+
|
|
6762
|
+
Default implementation for the semantic queries query getter.
|
|
6763
|
+
|
|
6764
|
+
|
|
6765
|
+
</td></tr>
|
|
6766
|
+
<tr><td>
|
|
6767
|
+
|
|
6768
|
+
[semanticQueriesRequest](./x-components.semanticqueriesrequest.md)
|
|
6769
|
+
|
|
6770
|
+
|
|
6771
|
+
</td><td>
|
|
6772
|
+
|
|
6773
|
+
Default implementation for the [SemanticQueriesGetters.request](./x-components.semanticqueriesgetters.request.md) getter.
|
|
6774
|
+
|
|
6775
|
+
|
|
6721
6776
|
</td></tr>
|
|
6722
6777
|
<tr><td>
|
|
6723
6778
|
|
|
@@ -44,6 +44,7 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
44
44
|
status: import("../../..").RequestStatus;
|
|
45
45
|
} | undefined>;
|
|
46
46
|
queryPreviewElement: Ref<HTMLElement | null, HTMLElement | null>;
|
|
47
|
+
showPlaceholder: import("vue").ComputedRef<boolean>;
|
|
47
48
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("load" | "error")[], "load" | "error", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
48
49
|
queryPreviewInfo: {
|
|
49
50
|
type: PropType<QueryPreviewInfo>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [relatedPromptQuery](./x-components.relatedpromptquery.md)
|
|
4
|
+
|
|
5
|
+
## relatedPromptQuery variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the related prompts query getter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
query: RelatedPromptsXStoreModule['getters']['query']
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [relatedPromptRequest](./x-components.relatedpromptrequest.md)
|
|
4
|
+
|
|
5
|
+
## relatedPromptRequest variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the [RelatedPromptsGetters.request](./x-components.relatedpromptsgetters.request.md) getter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
request: RelatedPromptsXStoreModule['getters']['request']
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [semanticQueriesNormalizedQuery](./x-components.semanticqueriesnormalizedquery.md)
|
|
4
|
+
|
|
5
|
+
## semanticQueriesNormalizedQuery variable
|
|
6
|
+
|
|
7
|
+
Default implementacion for the [SemanticQueriesGetters.normalizedQuery](./x-components.semanticqueriesgetters.normalizedquery.md) getter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
normalizedQuery: SemanticQueriesXStoreModule['getters']['normalizedQuery']
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [semanticQueriesQuery](./x-components.semanticqueriesquery.md)
|
|
4
|
+
|
|
5
|
+
## semanticQueriesQuery variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the semantic queries query getter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
query: SemanticQueriesXStoreModule['getters']['query']
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [semanticQueriesRequest](./x-components.semanticqueriesrequest.md)
|
|
4
|
+
|
|
5
|
+
## semanticQueriesRequest variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the [SemanticQueriesGetters.request](./x-components.semanticqueriesgetters.request.md) getter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
request: SemanticQueriesXStoreModule['getters']['request']
|
|
13
|
+
```
|
package/js/index.js
CHANGED
|
@@ -386,6 +386,8 @@ export { default as RelatedPromptsTagList } from './x-modules/related-prompts/co
|
|
|
386
386
|
export { cancelFetchAndSaveRelatedPrompts, fetchAndSaveRelatedPrompts } from './x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js';
|
|
387
387
|
export { fetchRelatedPrompts } from './x-modules/related-prompts/store/actions/fetch-related-prompts.action.js';
|
|
388
388
|
export { relatedPromptsStoreEmitters } from './x-modules/related-prompts/store/emitters.js';
|
|
389
|
+
export { query as relatedPromptQuery } from './x-modules/related-prompts/store/getters/related-prompts-query.getter.js';
|
|
390
|
+
export { request as relatedPromptRequest } from './x-modules/related-prompts/store/getters/request.getter.js';
|
|
389
391
|
export { relatedPromptsXStoreModule } from './x-modules/related-prompts/store/module.js';
|
|
390
392
|
export { relatedPromptsWiring } from './x-modules/related-prompts/wiring.js';
|
|
391
393
|
export { relatedPromptsXModule } from './x-modules/related-prompts/x-module.js';
|
|
@@ -447,6 +449,9 @@ export { default as SemanticQuery } from './x-modules/semantic-queries/component
|
|
|
447
449
|
export { fetchAndSaveSemanticQuery } from './x-modules/semantic-queries/store/actions/fetch-and-save-semantic-query.action.js';
|
|
448
450
|
export { fetchSemanticQuery } from './x-modules/semantic-queries/store/actions/fetch-semantic-query.action.js';
|
|
449
451
|
export { semanticQueriesEmitters } from './x-modules/semantic-queries/store/emitters.js';
|
|
452
|
+
export { normalizedQuery as semanticQueriesNormalizedQuery } from './x-modules/semantic-queries/store/getters/normalized-query.getter.js';
|
|
453
|
+
export { request as semanticQueriesRequest } from './x-modules/semantic-queries/store/getters/request.getter.js';
|
|
454
|
+
export { query as semanticQueriesQuery } from './x-modules/semantic-queries/store/getters/semanti-queries-query.getter.js';
|
|
450
455
|
export { semanticQueriesXStoreModule } from './x-modules/semantic-queries/store/module.js';
|
|
451
456
|
export { clearQueryWire, fetchAndSaveSemanticQueryWire, semanticQueriesWiring, setQueryFromSearchResponseChangedWire, setQueryWire, setSemanticQueriesExtraParamsWire, setTotalResultsFromSearchResponseChangedWire, setTotalResultsWire } from './x-modules/semantic-queries/wiring.js';
|
|
452
457
|
export { semanticQueriesXModule } from './x-modules/semantic-queries/x-module.js';
|
package/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import _sfc_main from './query-preview.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, Fragment, renderList, renderSlot, createElementVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
2
|
+
import { openBlock, createElementBlock, normalizeClass, Fragment, renderList, renderSlot, createElementVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
3
|
+
import './query-preview.vue3.js';
|
|
3
4
|
import _export_sfc from '../../../_virtual/_plugin-vue_export-helper.js';
|
|
4
5
|
|
|
5
6
|
const _hoisted_1 = {
|
|
6
|
-
ref: "queryPreviewElement",
|
|
7
|
-
class: "x-query-preview-wrapper__default-content"
|
|
8
|
-
};
|
|
9
|
-
const _hoisted_2 = {
|
|
10
7
|
key: 0,
|
|
11
8
|
"data-test": "query-preview",
|
|
12
9
|
class: "x-query-preview"
|
|
13
10
|
};
|
|
14
|
-
const
|
|
11
|
+
const _hoisted_2 = { "data-test": "result-name" };
|
|
15
12
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
16
13
|
return openBlock(), createElementBlock(
|
|
17
14
|
"section",
|
|
18
|
-
|
|
15
|
+
{
|
|
16
|
+
ref: "queryPreviewElement",
|
|
17
|
+
class: normalizeClass(["x-query-preview-wrapper__default-content", { "x-query-preview-wrapper--placeholder": _ctx.showPlaceholder }])
|
|
18
|
+
},
|
|
19
19
|
[
|
|
20
|
-
_ctx.hasResults ? (openBlock(), createElementBlock("ul",
|
|
20
|
+
_ctx.hasResults ? (openBlock(), createElementBlock("ul", _hoisted_1, [
|
|
21
21
|
(openBlock(true), createElementBlock(
|
|
22
22
|
Fragment,
|
|
23
23
|
null,
|
|
@@ -30,12 +30,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
30
30
|
renderSlot(_ctx.$slots, "result", { result }, () => [
|
|
31
31
|
createElementVNode(
|
|
32
32
|
"span",
|
|
33
|
-
|
|
33
|
+
_hoisted_2,
|
|
34
34
|
toDisplayString(result.name),
|
|
35
35
|
1
|
|
36
36
|
/* TEXT */
|
|
37
37
|
)
|
|
38
|
-
])
|
|
38
|
+
], true)
|
|
39
39
|
]);
|
|
40
40
|
}),
|
|
41
41
|
128
|
|
@@ -43,11 +43,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
43
43
|
))
|
|
44
44
|
])) : createCommentVNode("v-if", true)
|
|
45
45
|
],
|
|
46
|
-
|
|
47
|
-
/*
|
|
46
|
+
2
|
|
47
|
+
/* CLASS */
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
var QueryPreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
50
|
+
var QueryPreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2c40b965"]]);
|
|
51
51
|
|
|
52
52
|
export { QueryPreview as default };
|
|
53
53
|
//# sourceMappingURL=query-preview.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <!-- eslint-disable vue/no-unused-refs -->\n <section ref=\"queryPreviewElement\" class=\"x-query-preview-wrapper__default-content\">\n <ul v-if=\"hasResults\" 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 </section>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter, SearchRequest } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { FeatureLocation, QueryFeature } from '../../../types'\nimport type { DebouncedFunction } from '../../../utils'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { deepEqual } from '@empathyco/x-utils'\nimport { computed, defineComponent, h, inject, onBeforeUnmount, provide, ref, watch } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components'\nimport { useOnDisplay, useState, useXBus } from '../../../composables'\nimport { createOrigin, createRawFilters, debounceFunction } from '../../../utils'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\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 */\nexport default defineComponent({\n name: 'QueryPreview',\n xModule: queriesPreviewXModule.name,\n props: {\n /** The information about the request of the query preview. */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true,\n },\n /** The origin property for the request. */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /** Number of query preview results to be rendered. */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\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 debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n */\n persistInCache: {\n type: Boolean,\n default: false,\n },\n },\n emits: ['load', 'error'],\n setup(props, { emit, slots }) {\n const xBus = useXBus()\n\n /**\n * previewResults: The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n *\n * params: As the request is handled in this component, we need\n * the extra params that will be used in the request.\n *\n * config: As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const { queriesPreview: previewResults, params, config } = useState('queriesPreview')\n\n /**\n * Template ref for the root element to track visibility.\n */\n const queryPreviewElement = ref<HTMLElement | null>(null)\n\n /**\n * Query Preview key converted into a unique id.\n *\n * @returns The query hash.\n */\n const queryPreviewHash = computed(() =>\n getHashFromQueryPreviewInfo(props.queryPreviewInfo, {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n }),\n )\n\n provide('queryPreviewHash', queryPreviewHash)\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 const queryPreviewResults = computed(() => {\n const resultsPreview = previewResults.value[queryPreviewHash.value]\n return resultsPreview?.results\n ? {\n ...resultsPreview,\n results: resultsPreview.results.slice(0, props.maxItemsToRender),\n }\n : undefined\n })\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 */\n const results = computed(() => queryPreviewResults.value?.results)\n provide(LIST_ITEMS_KEY as string, results)\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n const injectedLocation = inject<Ref<FeatureLocation> | FeatureLocation>('location', 'none')\n const location =\n typeof injectedLocation === 'object' && 'value' in injectedLocation\n ? injectedLocation.value\n : injectedLocation\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n */\n const queryPreviewRequest = computed<SearchRequest>(() => {\n const origin = createOrigin({\n feature: props.queryFeature,\n location,\n })\n const filters = props.queryPreviewInfo.filters?.reduce(\n (filtersList, filterId) => {\n const facetId = filterId.split(':')[0]\n const rawFilter = createRawFilters([filterId])[0]\n filtersList[facetId] = filtersList[facetId]\n ? filtersList[facetId].concat(rawFilter)\n : [rawFilter]\n\n return filtersList\n },\n {} as Record<string, Filter[]>,\n )\n\n return {\n query: props.queryPreviewInfo.query,\n rows: config.value.maxItemsToRequest,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n },\n filters,\n ...(origin && { origin }),\n }\n })\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined\n * for cacheable queries.\n *\n * @returns The search request object.\n */\n const emitQueryPreviewRequestUpdated = computed<DebouncedFunction<[SearchRequest]>>(() =>\n debounceFunction(request => {\n xBus.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false })\n }, props.debounceTimeMs),\n )\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n watch(queryPreviewRequest, (newRequest, oldRequest) => {\n if (!deepEqual(newRequest, oldRequest) && !props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(newRequest)\n }\n })\n\n const cachedQueryPreview = previewResults.value[queryPreviewHash.value]\n\n // If the query has been saved it will emit load instead of the emitting the updated request.\n if (cachedQueryPreview?.status === 'success') {\n emit('load', queryPreviewHash.value)\n xBus.emit('QueryPreviewMounted', queryPreviewHash.value, {\n priority: 0,\n replaceable: false,\n })\n } else if (!props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n\n /**\n * Watch element visibility and emit request when it becomes visible for the first time\n * (only when loadWhenVisible is true).\n */\n const { unwatchDisplay } = useOnDisplay({\n element: queryPreviewElement,\n callback: () => {\n if (props.loadWhenVisible && cachedQueryPreview?.status !== 'success') {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n },\n })\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n * If the prop 'persistInCache' is set to false, it also removes the QueryPreview\n * from the state when the component is destroyed.\n */\n onBeforeUnmount(() => {\n unwatchDisplay?.()\n emitQueryPreviewRequestUpdated.value.cancel()\n xBus.emit(\n 'QueryPreviewUnmounted',\n { queryPreviewHash: queryPreviewHash.value, cache: props.persistInCache },\n {\n priority: 0,\n replaceable: false,\n },\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(\n emitQueryPreviewRequestUpdated,\n (_new: DebouncedFunction<[SearchRequest]>, old: DebouncedFunction<[SearchRequest]>) => {\n old.cancel()\n },\n )\n\n const queryPreviewResultsStatus = computed(() => queryPreviewResults.value?.status)\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 */\n watch(queryPreviewResultsStatus, () => {\n if (queryPreviewResultsStatus.value === 'success') {\n emit(results.value?.length ? 'load' : 'error', queryPreviewHash.value)\n } else if (queryPreviewResultsStatus.value === 'error') {\n emit('error', queryPreviewHash.value)\n }\n })\n\n const hasResults = computed(() => (queryPreviewResults.value?.totalResults ?? 0) > 0)\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `default` slot or empty string if there are no results. Always wrapped in a section\n * element with the `x-query-preview-wrapper__slot-content` class.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n queryPreviewHash: queryPreviewHash.value,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging,\n }\n\n const slotContent = hasResults.value ? slots.default?.(slotProps)[0] : ''\n\n return h(\n 'section',\n { ref: queryPreviewElement, class: 'x-query-preview-wrapper__slot-content' },\n [slotContent],\n )\n }\n\n /* Hack to render through a render-function, the `default` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { hasResults, queryPreviewResults, queryPreviewElement }\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\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 :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'sandals' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #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 setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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\n :maxItemsToRender=\"maxItemsToRender\"\n :queryPreviewInfo=\"queryPreviewInfo\"\n #default=\"{ results }\"\n >\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 setup>\nimport { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components'\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst maxItemsToRender = 4\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_renderSlot","_createElementVNode","_toDisplayString"],"mappings":";;;;;EAEW,GAAA,EAAI,qBAAA;AAAA,EAAsB,KAAA,EAAM;;;;EACjB,WAAA,EAAU,eAAA;AAAA,EAAgB,KAAA,EAAM;;AAY1C,MAAA,UAAA,GAAA,EAAA,WAAA,EAAU,aAAA,EAAa;;AAbrC,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IAiBU,SAAA;AAAA,IAjBV,UAAA;AAAA,IAiBU;AAAA,MAhBE,IAAA,CAAA,UAAA,IAAAD,SAAA,EAAA,EAAVC,kBAAA,CAeK,IAAA,EAfL,UAAA,EAeK;AAAA,SAAAD,SAAA,CAAA,IAAA,CAAA,EAdHC,kBAAA;AAAA,UAaKC,QAAA;AAAA,UAAA,IAAA;AAAA,UAAAC,UAAA,CAZc,IAAA,CAAA,mBAAA,EAAqB,OAAA,EAAO,CAAtC,MAAA,KAAM;gCADfF,kBAAA,CAaK,IAAA,EAAA;AAAA,cAXF,KAAK,MAAA,CAAO,EAAA;AAAA,cACb,KAAA,EAAM,uBAAA;AAAA,cACN,WAAA,EAAU;AAAA,aAAA,EAAA;cAMVG,UAAA,CAEO,IAAA,CAAA,MAAA,EAAA,QAAA,EAAA,EAFc,MAAA,EAAc,EAAnC,MAEO;AAAA,gBADLC,kBAAA;AAAA,kBAAsD,MAAA;AAAA,kBAAtD,UAAA;AAAA,kBAAsDC,eAAA,CAArB,OAAO,IAAI,CAAA;AAAA,kBAAA;AAAA;AAAA;AAAA,eAAA;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <!-- eslint-disable vue/no-unused-refs -->\n <section\n ref=\"queryPreviewElement\"\n class=\"x-query-preview-wrapper__default-content\"\n :class=\"{ 'x-query-preview-wrapper--placeholder': showPlaceholder }\"\n >\n <ul v-if=\"hasResults\" 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 </section>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter, SearchRequest } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { FeatureLocation, QueryFeature } from '../../../types'\nimport type { DebouncedFunction } from '../../../utils'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { deepEqual } from '@empathyco/x-utils'\nimport { computed, defineComponent, h, inject, onBeforeUnmount, provide, ref, watch } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components'\nimport { useOnDisplay, useState, useXBus } from '../../../composables'\nimport { createOrigin, createRawFilters, debounceFunction } from '../../../utils'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\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 */\nexport default defineComponent({\n name: 'QueryPreview',\n xModule: queriesPreviewXModule.name,\n props: {\n /** The information about the request of the query preview. */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true,\n },\n /** The origin property for the request. */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /** Number of query preview results to be rendered. */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\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 debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n */\n persistInCache: {\n type: Boolean,\n default: false,\n },\n },\n emits: ['load', 'error'],\n setup(props, { emit, slots }) {\n const xBus = useXBus()\n\n /**\n * previewResults: The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n *\n * params: As the request is handled in this component, we need\n * the extra params that will be used in the request.\n *\n * config: As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const { queriesPreview: previewResults, params, config } = useState('queriesPreview')\n\n /**\n * Template ref for the root element to track visibility.\n */\n const queryPreviewElement = ref<HTMLElement | null>(null)\n\n /**\n * Query Preview key converted into a unique id.\n *\n * @returns The query hash.\n */\n const queryPreviewHash = computed(() =>\n getHashFromQueryPreviewInfo(props.queryPreviewInfo, {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n }),\n )\n\n provide('queryPreviewHash', queryPreviewHash)\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 const queryPreviewResults = computed(() => {\n const resultsPreview = previewResults.value[queryPreviewHash.value]\n return resultsPreview?.results\n ? {\n ...resultsPreview,\n results: resultsPreview.results.slice(0, props.maxItemsToRender),\n }\n : undefined\n })\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 */\n const results = computed(() => queryPreviewResults.value?.results)\n provide(LIST_ITEMS_KEY as string, results)\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n const injectedLocation = inject<Ref<FeatureLocation> | FeatureLocation>('location', 'none')\n const location =\n typeof injectedLocation === 'object' && 'value' in injectedLocation\n ? injectedLocation.value\n : injectedLocation\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n */\n const queryPreviewRequest = computed<SearchRequest>(() => {\n const origin = createOrigin({\n feature: props.queryFeature,\n location,\n })\n const filters = props.queryPreviewInfo.filters?.reduce(\n (filtersList, filterId) => {\n const facetId = filterId.split(':')[0]\n const rawFilter = createRawFilters([filterId])[0]\n filtersList[facetId] = filtersList[facetId]\n ? filtersList[facetId].concat(rawFilter)\n : [rawFilter]\n\n return filtersList\n },\n {} as Record<string, Filter[]>,\n )\n\n return {\n query: props.queryPreviewInfo.query,\n rows: config.value.maxItemsToRequest,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n },\n filters,\n ...(origin && { origin }),\n }\n })\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined\n * for cacheable queries.\n *\n * @returns The search request object.\n */\n const emitQueryPreviewRequestUpdated = computed<DebouncedFunction<[SearchRequest]>>(() =>\n debounceFunction(request => {\n xBus.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false })\n }, props.debounceTimeMs),\n )\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n watch(queryPreviewRequest, (newRequest, oldRequest) => {\n if (!deepEqual(newRequest, oldRequest) && !props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(newRequest)\n }\n })\n\n const cachedQueryPreview = previewResults.value[queryPreviewHash.value]\n\n // If the query has been saved it will emit load instead of the emitting the updated request.\n if (cachedQueryPreview?.status === 'success') {\n emit('load', queryPreviewHash.value)\n xBus.emit('QueryPreviewMounted', queryPreviewHash.value, {\n priority: 0,\n replaceable: false,\n })\n } else if (!props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n\n /**\n * Watch element visibility and emit request when it becomes visible for the first time\n * (only when loadWhenVisible is true).\n */\n const { unwatchDisplay } = useOnDisplay({\n element: queryPreviewElement,\n callback: () => {\n if (props.loadWhenVisible && cachedQueryPreview?.status !== 'success') {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n },\n })\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n * If the prop 'persistInCache' is set to false, it also removes the QueryPreview\n * from the state when the component is destroyed.\n */\n onBeforeUnmount(() => {\n unwatchDisplay?.()\n emitQueryPreviewRequestUpdated.value.cancel()\n xBus.emit(\n 'QueryPreviewUnmounted',\n { queryPreviewHash: queryPreviewHash.value, cache: props.persistInCache },\n {\n priority: 0,\n replaceable: false,\n },\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(\n emitQueryPreviewRequestUpdated,\n (_new: DebouncedFunction<[SearchRequest]>, old: DebouncedFunction<[SearchRequest]>) => {\n old.cancel()\n },\n )\n\n const queryPreviewResultsStatus = computed(() => queryPreviewResults.value?.status)\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 */\n watch(queryPreviewResultsStatus, () => {\n if (queryPreviewResultsStatus.value === 'success') {\n emit(results.value?.length ? 'load' : 'error', queryPreviewHash.value)\n } else if (queryPreviewResultsStatus.value === 'error') {\n emit('error', queryPreviewHash.value)\n }\n })\n\n const hasResults = computed(() => (queryPreviewResults.value?.totalResults ?? 0) > 0)\n\n /**\n * Whether the wrapper should reserve placeholder space (min-height) in place of\n * the results while the query preview has not been loaded yet.\n *\n * It is only applied when `loadWhenVisible` is enabled, so the component keeps a\n * visible space and the viewport visibility trigger has a realistic area to work\n * with.\n *\n * @internal\n */\n const showPlaceholder = computed(() => {\n const status = queryPreviewResults.value?.status\n return (\n props.loadWhenVisible && !hasResults.value && status !== 'success' && status !== 'error'\n )\n })\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `default` slot or empty string if there are no results. Always wrapped in a section\n * element with the `x-query-preview-wrapper__slot-content` class.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n queryPreviewHash: queryPreviewHash.value,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging,\n }\n\n const slotContent = hasResults.value ? slots.default?.(slotProps)[0] : ''\n\n return h(\n 'section',\n {\n ref: queryPreviewElement,\n class: showPlaceholder.value\n ? 'x-query-preview-wrapper__slot-content x-query-preview-wrapper--placeholder'\n : 'x-query-preview-wrapper__slot-content',\n },\n [slotContent],\n )\n }\n\n /* Hack to render through a render-function, the `default` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = {\n hasResults,\n queryPreviewResults,\n queryPreviewElement,\n showPlaceholder,\n }\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-query-preview-wrapper--placeholder {\n min-block-size: 200px;\n position: relative;\n}\n</style>\n\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 :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'sandals' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #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 setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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\n :maxItemsToRender=\"maxItemsToRender\"\n :queryPreviewInfo=\"queryPreviewInfo\"\n #default=\"{ results }\"\n >\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 setup>\nimport { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components'\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst maxItemsToRender = 4\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_Fragment","_renderList","_renderSlot","_createElementVNode","_toDisplayString"],"mappings":";;;;;;;EAO0B,WAAA,EAAU,eAAA;AAAA,EAAgB,KAAA,EAAM;;AAY1C,MAAA,UAAA,GAAA,EAAA,WAAA,EAAU,aAAA,EAAa;;AAjBrC,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IAqBU,SAAA;AAAA,IAAA;AAAA,MApBR,GAAA,EAAI,qBAAA;AAAA,MACJ,KAAA,EAAKC,cAAA,CAAA,CAAC,0CAAA,EAA0C,EAAA,sCAAA,EACE,IAAA,CAAA,eAAA,EAAe,CAAA;AAAA,KAAA;;MAEvD,IAAA,CAAA,UAAA,IAAAF,SAAA,EAAA,EAAVC,kBAAA,CAeK,MAfL,UAAA,EAeK;AAAA,SAAAD,SAAA,CAAA,IAAA,CAAA,EAdHC,kBAAA;AAAA,UAaKE,QAAA;AAAA,UAAA,IAAA;AAAA,UAAAC,UAAA,CAZc,IAAA,CAAA,mBAAA,EAAqB,OAAA,EAAO,CAAtC,MAAA,KAAM;gCADfH,kBAAA,CAaK,IAAA,EAAA;AAAA,cAXF,KAAK,MAAA,CAAO,EAAA;AAAA,cACb,KAAA,EAAM,uBAAA;AAAA,cACN,WAAA,EAAU;AAAA,aAAA,EAAA;cAMVI,UAAA,CAEO,IAAA,CAAA,MAAA,EAAA,QAAA,EAAA,EAFc,MAAA,EAAc,EAAnC,MAEO;AAAA,gBADLC,kBAAA;AAAA,kBAAsD,MAAA;AAAA,kBAAtD,UAAA;AAAA,kBAAsDC,eAAA,CAArB,OAAO,IAAI,CAAA;AAAA,kBAAA;AAAA;AAAA;AAAA,eAAA,EAAA,IAAA;;;;;;;;;;;;;;;;"}
|
|
@@ -331,6 +331,20 @@ var _sfc_main = defineComponent({
|
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
const hasResults = computed(() => (queryPreviewResults.value?.totalResults ?? 0) > 0);
|
|
334
|
+
/**
|
|
335
|
+
* Whether the wrapper should reserve placeholder space (min-height) in place of
|
|
336
|
+
* the results while the query preview has not been loaded yet.
|
|
337
|
+
*
|
|
338
|
+
* It is only applied when `loadWhenVisible` is enabled, so the component keeps a
|
|
339
|
+
* visible space and the viewport visibility trigger has a realistic area to work
|
|
340
|
+
* with.
|
|
341
|
+
*
|
|
342
|
+
* @internal
|
|
343
|
+
*/
|
|
344
|
+
const showPlaceholder = computed(() => {
|
|
345
|
+
const status = queryPreviewResults.value?.status;
|
|
346
|
+
return (props.loadWhenVisible && !hasResults.value && status !== 'success' && status !== 'error');
|
|
347
|
+
});
|
|
334
348
|
/**
|
|
335
349
|
* Render function to execute the `default` slot, binding `slotsProps` and getting only the
|
|
336
350
|
* first `vNode` to avoid Fragments and Text root nodes.
|
|
@@ -351,11 +365,21 @@ var _sfc_main = defineComponent({
|
|
|
351
365
|
queryTagging: queryPreviewResults.value?.queryTagging,
|
|
352
366
|
};
|
|
353
367
|
const slotContent = hasResults.value ? slots.default?.(slotProps)[0] : '';
|
|
354
|
-
return h('section', {
|
|
368
|
+
return h('section', {
|
|
369
|
+
ref: queryPreviewElement,
|
|
370
|
+
class: showPlaceholder.value
|
|
371
|
+
? 'x-query-preview-wrapper__slot-content x-query-preview-wrapper--placeholder'
|
|
372
|
+
: 'x-query-preview-wrapper__slot-content',
|
|
373
|
+
}, [slotContent]);
|
|
355
374
|
}
|
|
356
375
|
/* Hack to render through a render-function, the `default` slot or, in its absence,
|
|
357
376
|
the component itself. It is the alternative for the NoElement antipattern. */
|
|
358
|
-
const componentProps = {
|
|
377
|
+
const componentProps = {
|
|
378
|
+
hasResults,
|
|
379
|
+
queryPreviewResults,
|
|
380
|
+
queryPreviewElement,
|
|
381
|
+
showPlaceholder,
|
|
382
|
+
};
|
|
359
383
|
return (slots.default ? renderDefaultSlot : componentProps);
|
|
360
384
|
},
|
|
361
385
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <!-- eslint-disable vue/no-unused-refs -->\n <section ref=\"queryPreviewElement\" class=\"x-query-preview-wrapper__default-content\">\n <ul v-if=\"hasResults\" 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 </section>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter, SearchRequest } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { FeatureLocation, QueryFeature } from '../../../types'\nimport type { DebouncedFunction } from '../../../utils'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { deepEqual } from '@empathyco/x-utils'\nimport { computed, defineComponent, h, inject, onBeforeUnmount, provide, ref, watch } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components'\nimport { useOnDisplay, useState, useXBus } from '../../../composables'\nimport { createOrigin, createRawFilters, debounceFunction } from '../../../utils'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\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 */\nexport default defineComponent({\n name: 'QueryPreview',\n xModule: queriesPreviewXModule.name,\n props: {\n /** The information about the request of the query preview. */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true,\n },\n /** The origin property for the request. */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /** Number of query preview results to be rendered. */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\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 debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n */\n persistInCache: {\n type: Boolean,\n default: false,\n },\n },\n emits: ['load', 'error'],\n setup(props, { emit, slots }) {\n const xBus = useXBus()\n\n /**\n * previewResults: The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n *\n * params: As the request is handled in this component, we need\n * the extra params that will be used in the request.\n *\n * config: As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const { queriesPreview: previewResults, params, config } = useState('queriesPreview')\n\n /**\n * Template ref for the root element to track visibility.\n */\n const queryPreviewElement = ref<HTMLElement | null>(null)\n\n /**\n * Query Preview key converted into a unique id.\n *\n * @returns The query hash.\n */\n const queryPreviewHash = computed(() =>\n getHashFromQueryPreviewInfo(props.queryPreviewInfo, {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n }),\n )\n\n provide('queryPreviewHash', queryPreviewHash)\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 const queryPreviewResults = computed(() => {\n const resultsPreview = previewResults.value[queryPreviewHash.value]\n return resultsPreview?.results\n ? {\n ...resultsPreview,\n results: resultsPreview.results.slice(0, props.maxItemsToRender),\n }\n : undefined\n })\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 */\n const results = computed(() => queryPreviewResults.value?.results)\n provide(LIST_ITEMS_KEY as string, results)\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n const injectedLocation = inject<Ref<FeatureLocation> | FeatureLocation>('location', 'none')\n const location =\n typeof injectedLocation === 'object' && 'value' in injectedLocation\n ? injectedLocation.value\n : injectedLocation\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n */\n const queryPreviewRequest = computed<SearchRequest>(() => {\n const origin = createOrigin({\n feature: props.queryFeature,\n location,\n })\n const filters = props.queryPreviewInfo.filters?.reduce(\n (filtersList, filterId) => {\n const facetId = filterId.split(':')[0]\n const rawFilter = createRawFilters([filterId])[0]\n filtersList[facetId] = filtersList[facetId]\n ? filtersList[facetId].concat(rawFilter)\n : [rawFilter]\n\n return filtersList\n },\n {} as Record<string, Filter[]>,\n )\n\n return {\n query: props.queryPreviewInfo.query,\n rows: config.value.maxItemsToRequest,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n },\n filters,\n ...(origin && { origin }),\n }\n })\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined\n * for cacheable queries.\n *\n * @returns The search request object.\n */\n const emitQueryPreviewRequestUpdated = computed<DebouncedFunction<[SearchRequest]>>(() =>\n debounceFunction(request => {\n xBus.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false })\n }, props.debounceTimeMs),\n )\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n watch(queryPreviewRequest, (newRequest, oldRequest) => {\n if (!deepEqual(newRequest, oldRequest) && !props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(newRequest)\n }\n })\n\n const cachedQueryPreview = previewResults.value[queryPreviewHash.value]\n\n // If the query has been saved it will emit load instead of the emitting the updated request.\n if (cachedQueryPreview?.status === 'success') {\n emit('load', queryPreviewHash.value)\n xBus.emit('QueryPreviewMounted', queryPreviewHash.value, {\n priority: 0,\n replaceable: false,\n })\n } else if (!props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n\n /**\n * Watch element visibility and emit request when it becomes visible for the first time\n * (only when loadWhenVisible is true).\n */\n const { unwatchDisplay } = useOnDisplay({\n element: queryPreviewElement,\n callback: () => {\n if (props.loadWhenVisible && cachedQueryPreview?.status !== 'success') {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n },\n })\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n * If the prop 'persistInCache' is set to false, it also removes the QueryPreview\n * from the state when the component is destroyed.\n */\n onBeforeUnmount(() => {\n unwatchDisplay?.()\n emitQueryPreviewRequestUpdated.value.cancel()\n xBus.emit(\n 'QueryPreviewUnmounted',\n { queryPreviewHash: queryPreviewHash.value, cache: props.persistInCache },\n {\n priority: 0,\n replaceable: false,\n },\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(\n emitQueryPreviewRequestUpdated,\n (_new: DebouncedFunction<[SearchRequest]>, old: DebouncedFunction<[SearchRequest]>) => {\n old.cancel()\n },\n )\n\n const queryPreviewResultsStatus = computed(() => queryPreviewResults.value?.status)\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 */\n watch(queryPreviewResultsStatus, () => {\n if (queryPreviewResultsStatus.value === 'success') {\n emit(results.value?.length ? 'load' : 'error', queryPreviewHash.value)\n } else if (queryPreviewResultsStatus.value === 'error') {\n emit('error', queryPreviewHash.value)\n }\n })\n\n const hasResults = computed(() => (queryPreviewResults.value?.totalResults ?? 0) > 0)\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `default` slot or empty string if there are no results. Always wrapped in a section\n * element with the `x-query-preview-wrapper__slot-content` class.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n queryPreviewHash: queryPreviewHash.value,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging,\n }\n\n const slotContent = hasResults.value ? slots.default?.(slotProps)[0] : ''\n\n return h(\n 'section',\n { ref: queryPreviewElement, class: 'x-query-preview-wrapper__slot-content' },\n [slotContent],\n )\n }\n\n /* Hack to render through a render-function, the `default` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { hasResults, queryPreviewResults, queryPreviewElement }\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\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 :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'sandals' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #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 setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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\n :maxItemsToRender=\"maxItemsToRender\"\n :queryPreviewInfo=\"queryPreviewInfo\"\n #default=\"{ results }\"\n >\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 setup>\nimport { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components'\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst maxItemsToRender = 4\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\n</script>\n```\n</docs>\n"],"names":["debounceFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,KAAK,EAAE;;AAEL,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAAoC;AAC1C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;;AAED,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAAM;AACb,SAAA;AACD;;AAEE;AACF,QAAA,eAAe,EAAE;AACf,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;AACD;;;;AAIE;AACF,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACD;;;AAGE;AACF,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE,OAAO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AY,EAAE,mBAAmB,CAAC,KAAK,EAAE,YAAY;AACrD,gBAAA,cAAc,EAAE,mBAAmB,CAAC,KAAK,EAAE,cAAc;AACzD,gBAAA,YAAY,EAAE,mBAAmB,CAAC,KAAK,EAAE,YAAY;aACvD;YAEA,MAAM,WAAU,GAAI,UAAU,CAAC,KAAI,GAAI,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA,GAAI,EAAC;AAExE,YAAA,OAAO,CAAC,CACN,SAAS,EACT,EAAE,GAAG,EAAE,mBAAmB,EAAE,KAAK,EAAE,yCAAyC,EAC5E,CAAC,WAAW,CAAC,CACf;QACF;AAEA;AAC+E;QAC/E,MAAM,cAAa,GAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAkB,EAAE;AAC9E,QAAA,QAAQ,KAAK,CAAC,OAAM,GAAI,iBAAgB,GAAI,cAAc;IAC5D,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"query-preview.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\n <!-- eslint-disable vue/no-unused-refs -->\n <section\n ref=\"queryPreviewElement\"\n class=\"x-query-preview-wrapper__default-content\"\n :class=\"{ 'x-query-preview-wrapper--placeholder': showPlaceholder }\"\n >\n <ul v-if=\"hasResults\" 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 </section>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter, SearchRequest } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { FeatureLocation, QueryFeature } from '../../../types'\nimport type { DebouncedFunction } from '../../../utils'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { deepEqual } from '@empathyco/x-utils'\nimport { computed, defineComponent, h, inject, onBeforeUnmount, provide, ref, watch } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components'\nimport { useOnDisplay, useState, useXBus } from '../../../composables'\nimport { createOrigin, createRawFilters, debounceFunction } from '../../../utils'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\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 */\nexport default defineComponent({\n name: 'QueryPreview',\n xModule: queriesPreviewXModule.name,\n props: {\n /** The information about the request of the query preview. */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true,\n },\n /** The origin property for the request. */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /** Number of query preview results to be rendered. */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\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 debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether the QueryPreview should be removed from the state\n * when the component is destroyed.\n */\n persistInCache: {\n type: Boolean,\n default: false,\n },\n },\n emits: ['load', 'error'],\n setup(props, { emit, slots }) {\n const xBus = useXBus()\n\n /**\n * previewResults: The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n *\n * params: As the request is handled in this component, we need\n * the extra params that will be used in the request.\n *\n * config: As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const { queriesPreview: previewResults, params, config } = useState('queriesPreview')\n\n /**\n * Template ref for the root element to track visibility.\n */\n const queryPreviewElement = ref<HTMLElement | null>(null)\n\n /**\n * Query Preview key converted into a unique id.\n *\n * @returns The query hash.\n */\n const queryPreviewHash = computed(() =>\n getHashFromQueryPreviewInfo(props.queryPreviewInfo, {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n }),\n )\n\n provide('queryPreviewHash', queryPreviewHash)\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 const queryPreviewResults = computed(() => {\n const resultsPreview = previewResults.value[queryPreviewHash.value]\n return resultsPreview?.results\n ? {\n ...resultsPreview,\n results: resultsPreview.results.slice(0, props.maxItemsToRender),\n }\n : undefined\n })\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 */\n const results = computed(() => queryPreviewResults.value?.results)\n provide(LIST_ITEMS_KEY as string, results)\n\n /**\n * It injects the provided {@link FeatureLocation} of the selected query in the search request.\n *\n * @internal\n */\n const injectedLocation = inject<Ref<FeatureLocation> | FeatureLocation>('location', 'none')\n const location =\n typeof injectedLocation === 'object' && 'value' in injectedLocation\n ? injectedLocation.value\n : injectedLocation\n\n /**\n * The computed request object to be used to retrieve the query preview results.\n *\n * @returns The search request object.\n */\n const queryPreviewRequest = computed<SearchRequest>(() => {\n const origin = createOrigin({\n feature: props.queryFeature,\n location,\n })\n const filters = props.queryPreviewInfo.filters?.reduce(\n (filtersList, filterId) => {\n const facetId = filterId.split(':')[0]\n const rawFilter = createRawFilters([filterId])[0]\n filtersList[facetId] = filtersList[facetId]\n ? filtersList[facetId].concat(rawFilter)\n : [rawFilter]\n\n return filtersList\n },\n {} as Record<string, Filter[]>,\n )\n\n return {\n query: props.queryPreviewInfo.query,\n rows: config.value.maxItemsToRequest,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams,\n },\n filters,\n ...(origin && { origin }),\n }\n })\n\n /**\n * The debounce method to trigger the request after the debounceTimeMs defined\n * for cacheable queries.\n *\n * @returns The search request object.\n */\n const emitQueryPreviewRequestUpdated = computed<DebouncedFunction<[SearchRequest]>>(() =>\n debounceFunction(request => {\n xBus.emit('QueryPreviewRequestUpdated', request, { priority: 0, replaceable: false })\n }, props.debounceTimeMs),\n )\n\n /**\n * Initialises watcher to emit debounced requests, and first value for the requests.\n *\n * @internal\n */\n watch(queryPreviewRequest, (newRequest, oldRequest) => {\n if (!deepEqual(newRequest, oldRequest) && !props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(newRequest)\n }\n })\n\n const cachedQueryPreview = previewResults.value[queryPreviewHash.value]\n\n // If the query has been saved it will emit load instead of the emitting the updated request.\n if (cachedQueryPreview?.status === 'success') {\n emit('load', queryPreviewHash.value)\n xBus.emit('QueryPreviewMounted', queryPreviewHash.value, {\n priority: 0,\n replaceable: false,\n })\n } else if (!props.loadWhenVisible) {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n\n /**\n * Watch element visibility and emit request when it becomes visible for the first time\n * (only when loadWhenVisible is true).\n */\n const { unwatchDisplay } = useOnDisplay({\n element: queryPreviewElement,\n callback: () => {\n if (props.loadWhenVisible && cachedQueryPreview?.status !== 'success') {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value)\n }\n },\n })\n\n /**\n * Cancels the (remaining) requests when the component is destroyed\n * via the `debounce.cancel()` method.\n * If the prop 'persistInCache' is set to false, it also removes the QueryPreview\n * from the state when the component is destroyed.\n */\n onBeforeUnmount(() => {\n unwatchDisplay?.()\n emitQueryPreviewRequestUpdated.value.cancel()\n xBus.emit(\n 'QueryPreviewUnmounted',\n { queryPreviewHash: queryPreviewHash.value, cache: props.persistInCache },\n {\n priority: 0,\n replaceable: false,\n },\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(\n emitQueryPreviewRequestUpdated,\n (_new: DebouncedFunction<[SearchRequest]>, old: DebouncedFunction<[SearchRequest]>) => {\n old.cancel()\n },\n )\n\n const queryPreviewResultsStatus = computed(() => queryPreviewResults.value?.status)\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 */\n watch(queryPreviewResultsStatus, () => {\n if (queryPreviewResultsStatus.value === 'success') {\n emit(results.value?.length ? 'load' : 'error', queryPreviewHash.value)\n } else if (queryPreviewResultsStatus.value === 'error') {\n emit('error', queryPreviewHash.value)\n }\n })\n\n const hasResults = computed(() => (queryPreviewResults.value?.totalResults ?? 0) > 0)\n\n /**\n * Whether the wrapper should reserve placeholder space (min-height) in place of\n * the results while the query preview has not been loaded yet.\n *\n * It is only applied when `loadWhenVisible` is enabled, so the component keeps a\n * visible space and the viewport visibility trigger has a realistic area to work\n * with.\n *\n * @internal\n */\n const showPlaceholder = computed(() => {\n const status = queryPreviewResults.value?.status\n return (\n props.loadWhenVisible && !hasResults.value && status !== 'success' && status !== 'error'\n )\n })\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `default` slot or empty string if there are no results. Always wrapped in a section\n * element with the `x-query-preview-wrapper__slot-content` class.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n queryPreviewHash: queryPreviewHash.value,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging,\n }\n\n const slotContent = hasResults.value ? slots.default?.(slotProps)[0] : ''\n\n return h(\n 'section',\n {\n ref: queryPreviewElement,\n class: showPlaceholder.value\n ? 'x-query-preview-wrapper__slot-content x-query-preview-wrapper--placeholder'\n : 'x-query-preview-wrapper__slot-content',\n },\n [slotContent],\n )\n }\n\n /* Hack to render through a render-function, the `default` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = {\n hasResults,\n queryPreviewResults,\n queryPreviewElement,\n showPlaceholder,\n }\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-query-preview-wrapper--placeholder {\n min-block-size: 200px;\n position: relative;\n}\n</style>\n\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 :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'sandals' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #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 setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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 :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script setup>\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\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\n :maxItemsToRender=\"maxItemsToRender\"\n :queryPreviewInfo=\"queryPreviewInfo\"\n #default=\"{ results }\"\n >\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 setup>\nimport { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components'\nimport { QueryPreview } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst maxItemsToRender = 4\nconst queryPreviewInfo = reactive({ query: 'flip-flops' })\n</script>\n```\n</docs>\n"],"names":["debounceFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,KAAK,EAA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EA;AAC+E;AAC/E,QAAA,MAAM,iBAAiB;YACrB,UAAU;YACV,mBAAmB;YACnB,mBAAmB;YACnB,eAAe;SACjB;AACA,QAAA,QAAQ,KAAK,CAAC,OAAM,GAAI,iBAAgB,GAAI,cAAc;IAC5D,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-preview.vue3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"access": "public",
|
|
118
118
|
"directory": "dist"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "74de7591d6177596a288687d41591e911a723d8e"
|
|
121
121
|
}
|
package/related-prompts/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { default as RelatedPromptsTagList } from '../js/x-modules/related-prompt
|
|
|
4
4
|
export { cancelFetchAndSaveRelatedPrompts, fetchAndSaveRelatedPrompts } from '../js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js';
|
|
5
5
|
export { fetchRelatedPrompts } from '../js/x-modules/related-prompts/store/actions/fetch-related-prompts.action.js';
|
|
6
6
|
export { relatedPromptsStoreEmitters } from '../js/x-modules/related-prompts/store/emitters.js';
|
|
7
|
+
export { query as relatedPromptQuery } from '../js/x-modules/related-prompts/store/getters/related-prompts-query.getter.js';
|
|
8
|
+
export { request as relatedPromptRequest } from '../js/x-modules/related-prompts/store/getters/request.getter.js';
|
|
7
9
|
export { relatedPromptsXStoreModule } from '../js/x-modules/related-prompts/store/module.js';
|
|
8
10
|
export { relatedPromptsWiring } from '../js/x-modules/related-prompts/wiring.js';
|
|
9
11
|
export { relatedPromptsXModule } from '../js/x-modules/related-prompts/x-module.js';
|
|
@@ -54542,7 +54542,16 @@
|
|
|
54542
54542
|
},
|
|
54543
54543
|
{
|
|
54544
54544
|
"kind": "Content",
|
|
54545
|
-
"text": " | null>;\n
|
|
54545
|
+
"text": " | null>;\n showPlaceholder: import(\"vue\")."
|
|
54546
|
+
},
|
|
54547
|
+
{
|
|
54548
|
+
"kind": "Reference",
|
|
54549
|
+
"text": "ComputedRef",
|
|
54550
|
+
"canonicalReference": "@vue/reactivity!ComputedRef:interface"
|
|
54551
|
+
},
|
|
54552
|
+
{
|
|
54553
|
+
"kind": "Content",
|
|
54554
|
+
"text": "<boolean>;\n}, {}, {}, {}, import(\"vue\")."
|
|
54546
54555
|
},
|
|
54547
54556
|
{
|
|
54548
54557
|
"kind": "Reference",
|
|
@@ -54686,7 +54695,7 @@
|
|
|
54686
54695
|
"name": "QueryPreview",
|
|
54687
54696
|
"variableTypeTokenRange": {
|
|
54688
54697
|
"startIndex": 1,
|
|
54689
|
-
"endIndex":
|
|
54698
|
+
"endIndex": 74
|
|
54690
54699
|
}
|
|
54691
54700
|
},
|
|
54692
54701
|
{
|
|
@@ -58924,6 +58933,62 @@
|
|
|
58924
58933
|
"endIndex": 42
|
|
58925
58934
|
}
|
|
58926
58935
|
},
|
|
58936
|
+
{
|
|
58937
|
+
"kind": "Variable",
|
|
58938
|
+
"canonicalReference": "@empathyco/x-components!relatedPromptQuery:var",
|
|
58939
|
+
"docComment": "/**\n * Default implementation for the related prompts query getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the related prompts' module.\n *\n * @returns The query with the selected related tags concatenated.\n *\n * @public\n */\n",
|
|
58940
|
+
"excerptTokens": [
|
|
58941
|
+
{
|
|
58942
|
+
"kind": "Content",
|
|
58943
|
+
"text": "query: "
|
|
58944
|
+
},
|
|
58945
|
+
{
|
|
58946
|
+
"kind": "Reference",
|
|
58947
|
+
"text": "RelatedPromptsXStoreModule",
|
|
58948
|
+
"canonicalReference": "@empathyco/x-components!RelatedPromptsXStoreModule:type"
|
|
58949
|
+
},
|
|
58950
|
+
{
|
|
58951
|
+
"kind": "Content",
|
|
58952
|
+
"text": "['getters']['query']"
|
|
58953
|
+
}
|
|
58954
|
+
],
|
|
58955
|
+
"fileUrlPath": "src/x-modules/related-prompts/store/getters/related-prompts-query.getter.ts",
|
|
58956
|
+
"isReadonly": true,
|
|
58957
|
+
"releaseTag": "Public",
|
|
58958
|
+
"name": "relatedPromptQuery",
|
|
58959
|
+
"variableTypeTokenRange": {
|
|
58960
|
+
"startIndex": 1,
|
|
58961
|
+
"endIndex": 3
|
|
58962
|
+
}
|
|
58963
|
+
},
|
|
58964
|
+
{
|
|
58965
|
+
"kind": "Variable",
|
|
58966
|
+
"canonicalReference": "@empathyco/x-components!relatedPromptRequest:var",
|
|
58967
|
+
"docComment": "/**\n * Default implementation for the {@link RelatedPromptsGetters.request} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the related prompts module.\n *\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the related prompts' module.\n *\n * @returns The related prompts request to fetch data from the API.\n *\n * @public\n */\n",
|
|
58968
|
+
"excerptTokens": [
|
|
58969
|
+
{
|
|
58970
|
+
"kind": "Content",
|
|
58971
|
+
"text": "request: "
|
|
58972
|
+
},
|
|
58973
|
+
{
|
|
58974
|
+
"kind": "Reference",
|
|
58975
|
+
"text": "RelatedPromptsXStoreModule",
|
|
58976
|
+
"canonicalReference": "@empathyco/x-components!RelatedPromptsXStoreModule:type"
|
|
58977
|
+
},
|
|
58978
|
+
{
|
|
58979
|
+
"kind": "Content",
|
|
58980
|
+
"text": "['getters']['request']"
|
|
58981
|
+
}
|
|
58982
|
+
],
|
|
58983
|
+
"fileUrlPath": "src/x-modules/related-prompts/store/getters/request.getter.ts",
|
|
58984
|
+
"isReadonly": true,
|
|
58985
|
+
"releaseTag": "Public",
|
|
58986
|
+
"name": "relatedPromptRequest",
|
|
58987
|
+
"variableTypeTokenRange": {
|
|
58988
|
+
"startIndex": 1,
|
|
58989
|
+
"endIndex": 3
|
|
58990
|
+
}
|
|
58991
|
+
},
|
|
58927
58992
|
{
|
|
58928
58993
|
"kind": "TypeAlias",
|
|
58929
58994
|
"canonicalReference": "@empathyco/x-components!RelatedPromptsActionContext:type",
|
|
@@ -72013,6 +72078,90 @@
|
|
|
72013
72078
|
}
|
|
72014
72079
|
]
|
|
72015
72080
|
},
|
|
72081
|
+
{
|
|
72082
|
+
"kind": "Variable",
|
|
72083
|
+
"canonicalReference": "@empathyco/x-components!semanticQueriesNormalizedQuery:var",
|
|
72084
|
+
"docComment": "/**\n * Default implementacion for the {@link SemanticQueriesGetters.normalizedQuery} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the semantic queries' module.\n *\n * @returns The normalized query.\n *\n * @public\n */\n",
|
|
72085
|
+
"excerptTokens": [
|
|
72086
|
+
{
|
|
72087
|
+
"kind": "Content",
|
|
72088
|
+
"text": "normalizedQuery: "
|
|
72089
|
+
},
|
|
72090
|
+
{
|
|
72091
|
+
"kind": "Reference",
|
|
72092
|
+
"text": "SemanticQueriesXStoreModule",
|
|
72093
|
+
"canonicalReference": "@empathyco/x-components!SemanticQueriesXStoreModule:type"
|
|
72094
|
+
},
|
|
72095
|
+
{
|
|
72096
|
+
"kind": "Content",
|
|
72097
|
+
"text": "['getters']['normalizedQuery']"
|
|
72098
|
+
}
|
|
72099
|
+
],
|
|
72100
|
+
"fileUrlPath": "src/x-modules/semantic-queries/store/getters/normalized-query.getter.ts",
|
|
72101
|
+
"isReadonly": true,
|
|
72102
|
+
"releaseTag": "Public",
|
|
72103
|
+
"name": "semanticQueriesNormalizedQuery",
|
|
72104
|
+
"variableTypeTokenRange": {
|
|
72105
|
+
"startIndex": 1,
|
|
72106
|
+
"endIndex": 3
|
|
72107
|
+
}
|
|
72108
|
+
},
|
|
72109
|
+
{
|
|
72110
|
+
"kind": "Variable",
|
|
72111
|
+
"canonicalReference": "@empathyco/x-components!semanticQueriesQuery:var",
|
|
72112
|
+
"docComment": "/**\n * Default implementation for the semantic queries query getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the semantic queries' module.\n *\n * @returns The query with the selected related tags concatenated.\n *\n * @public\n */\n",
|
|
72113
|
+
"excerptTokens": [
|
|
72114
|
+
{
|
|
72115
|
+
"kind": "Content",
|
|
72116
|
+
"text": "query: "
|
|
72117
|
+
},
|
|
72118
|
+
{
|
|
72119
|
+
"kind": "Reference",
|
|
72120
|
+
"text": "SemanticQueriesXStoreModule",
|
|
72121
|
+
"canonicalReference": "@empathyco/x-components!SemanticQueriesXStoreModule:type"
|
|
72122
|
+
},
|
|
72123
|
+
{
|
|
72124
|
+
"kind": "Content",
|
|
72125
|
+
"text": "['getters']['query']"
|
|
72126
|
+
}
|
|
72127
|
+
],
|
|
72128
|
+
"fileUrlPath": "src/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.ts",
|
|
72129
|
+
"isReadonly": true,
|
|
72130
|
+
"releaseTag": "Public",
|
|
72131
|
+
"name": "semanticQueriesQuery",
|
|
72132
|
+
"variableTypeTokenRange": {
|
|
72133
|
+
"startIndex": 1,
|
|
72134
|
+
"endIndex": 3
|
|
72135
|
+
}
|
|
72136
|
+
},
|
|
72137
|
+
{
|
|
72138
|
+
"kind": "Variable",
|
|
72139
|
+
"canonicalReference": "@empathyco/x-components!semanticQueriesRequest:var",
|
|
72140
|
+
"docComment": "/**\n * Default implementation for the {@link SemanticQueriesGetters.request} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the semantic queries module.\n *\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the semantic queries' module.\n *\n * @returns The semantic queries request to fetch data from the API.\n *\n * @public\n */\n",
|
|
72141
|
+
"excerptTokens": [
|
|
72142
|
+
{
|
|
72143
|
+
"kind": "Content",
|
|
72144
|
+
"text": "request: "
|
|
72145
|
+
},
|
|
72146
|
+
{
|
|
72147
|
+
"kind": "Reference",
|
|
72148
|
+
"text": "SemanticQueriesXStoreModule",
|
|
72149
|
+
"canonicalReference": "@empathyco/x-components!SemanticQueriesXStoreModule:type"
|
|
72150
|
+
},
|
|
72151
|
+
{
|
|
72152
|
+
"kind": "Content",
|
|
72153
|
+
"text": "['getters']['request']"
|
|
72154
|
+
}
|
|
72155
|
+
],
|
|
72156
|
+
"fileUrlPath": "src/x-modules/semantic-queries/store/getters/request.getter.ts",
|
|
72157
|
+
"isReadonly": true,
|
|
72158
|
+
"releaseTag": "Public",
|
|
72159
|
+
"name": "semanticQueriesRequest",
|
|
72160
|
+
"variableTypeTokenRange": {
|
|
72161
|
+
"startIndex": 1,
|
|
72162
|
+
"endIndex": 3
|
|
72163
|
+
}
|
|
72164
|
+
},
|
|
72016
72165
|
{
|
|
72017
72166
|
"kind": "Interface",
|
|
72018
72167
|
"canonicalReference": "@empathyco/x-components!SemanticQueriesState:interface",
|
|
@@ -5887,6 +5887,7 @@ instances: number;
|
|
|
5887
5887
|
status: RequestStatus;
|
|
5888
5888
|
} | undefined>;
|
|
5889
5889
|
queryPreviewElement: Ref<HTMLElement | null, HTMLElement | null>;
|
|
5890
|
+
showPlaceholder: ComputedRef<boolean>;
|
|
5890
5891
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("load" | "error")[], "load" | "error", PublicProps, Readonly<ExtractPropTypes< {
|
|
5891
5892
|
queryPreviewInfo: {
|
|
5892
5893
|
type: PropType<QueryPreviewInfo>;
|
|
@@ -6371,6 +6372,12 @@ PlusIcon: DefineComponent< {}, {}, any>;
|
|
|
6371
6372
|
typing: Directive<TypingHTMLElement, TypingOptions>;
|
|
6372
6373
|
}, string, ComponentProvideOptions, true, {}, any>;
|
|
6373
6374
|
|
|
6375
|
+
// @public
|
|
6376
|
+
export const relatedPromptQuery: RelatedPromptsXStoreModule['getters']['query'];
|
|
6377
|
+
|
|
6378
|
+
// @public
|
|
6379
|
+
export const relatedPromptRequest: RelatedPromptsXStoreModule['getters']['request'];
|
|
6380
|
+
|
|
6374
6381
|
// @public
|
|
6375
6382
|
export type RelatedPromptsActionContext = XActionContext<RelatedPromptsState, RelatedPromptsGetters, RelatedPromptsMutations, RelatedPromptsActions>;
|
|
6376
6383
|
|
|
@@ -7855,6 +7862,15 @@ export interface SemanticQueriesMutations extends QueryMutations, ConfigMutation
|
|
|
7855
7862
|
setTotalResults: (totalResults: number) => void;
|
|
7856
7863
|
}
|
|
7857
7864
|
|
|
7865
|
+
// @public
|
|
7866
|
+
export const semanticQueriesNormalizedQuery: SemanticQueriesXStoreModule['getters']['normalizedQuery'];
|
|
7867
|
+
|
|
7868
|
+
// @public
|
|
7869
|
+
export const semanticQueriesQuery: SemanticQueriesXStoreModule['getters']['query'];
|
|
7870
|
+
|
|
7871
|
+
// @public
|
|
7872
|
+
export const semanticQueriesRequest: SemanticQueriesXStoreModule['getters']['request'];
|
|
7873
|
+
|
|
7858
7874
|
// @public
|
|
7859
7875
|
export interface SemanticQueriesState extends QueryState {
|
|
7860
7876
|
config: SemanticQueriesConfig;
|
|
@@ -3,6 +3,9 @@ export { default as SemanticQuery } from '../js/x-modules/semantic-queries/compo
|
|
|
3
3
|
export { fetchAndSaveSemanticQuery } from '../js/x-modules/semantic-queries/store/actions/fetch-and-save-semantic-query.action.js';
|
|
4
4
|
export { fetchSemanticQuery } from '../js/x-modules/semantic-queries/store/actions/fetch-semantic-query.action.js';
|
|
5
5
|
export { semanticQueriesEmitters } from '../js/x-modules/semantic-queries/store/emitters.js';
|
|
6
|
+
export { normalizedQuery as semanticQueriesNormalizedQuery } from '../js/x-modules/semantic-queries/store/getters/normalized-query.getter.js';
|
|
7
|
+
export { request as semanticQueriesRequest } from '../js/x-modules/semantic-queries/store/getters/request.getter.js';
|
|
8
|
+
export { query as semanticQueriesQuery } from '../js/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.js';
|
|
6
9
|
export { semanticQueriesXStoreModule } from '../js/x-modules/semantic-queries/store/module.js';
|
|
7
10
|
export { clearQueryWire, fetchAndSaveSemanticQueryWire, semanticQueriesWiring, setQueryFromSearchResponseChangedWire, setQueryWire, setSemanticQueriesExtraParamsWire, setTotalResultsFromSearchResponseChangedWire, setTotalResultsWire } from '../js/x-modules/semantic-queries/wiring.js';
|
|
8
11
|
export { semanticQueriesXModule } from '../js/x-modules/semantic-queries/x-module.js';
|
|
@@ -59,6 +59,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
59
59
|
status: import("../../..").RequestStatus;
|
|
60
60
|
} | undefined>;
|
|
61
61
|
queryPreviewElement: Ref<HTMLElement | null, HTMLElement | null>;
|
|
62
|
+
showPlaceholder: import("vue").ComputedRef<boolean>;
|
|
62
63
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("load" | "error")[], "load" | "error", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
63
64
|
/** The information about the request of the query preview. */
|
|
64
65
|
queryPreviewInfo: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/queries-preview/components/query-preview.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAStD;;;;;;GAMG;;IAKC,8DAA8D;;cAE5C,QAAQ,CAAC,gBAAgB,CAAC;;;IAG5C,2CAA2C;;cAEzB,QAAQ,CAAC,YAAY,CAAC;;IAExC,sDAAsD;;;;IAItD;;OAEG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;OAGG
|
|
1
|
+
{"version":3,"file":"query-preview.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/queries-preview/components/query-preview.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAStD;;;;;;GAMG;;IAKC,8DAA8D;;cAE5C,QAAQ,CAAC,gBAAgB,CAAC;;;IAG5C,2CAA2C;;cAEzB,QAAQ,CAAC,YAAY,CAAC;;IAExC,sDAAsD;;;;IAItD;;OAEG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;OAGG;;;;;;;;;;;;;;;;;;;IAhCH,8DAA8D;;cAE5C,QAAQ,CAAC,gBAAgB,CAAC;;;IAG5C,2CAA2C;;cAEzB,QAAQ,CAAC,YAAY,CAAC;;IAExC,sDAAsD;;;;IAItD;;OAEG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;OAGG;;;;;;;;;;;;;AApCP,wBAuTE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './actions/fetch-and-save-related-prompts.action';
|
|
2
2
|
export * from './actions/fetch-related-prompts.action';
|
|
3
3
|
export * from './emitters';
|
|
4
|
+
export * from './getters';
|
|
4
5
|
export * from './module';
|
|
5
6
|
export * from './types';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/related-prompts/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAA;AAC/D,cAAc,wCAAwC,CAAA;AACtD,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/related-prompts/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAA;AAC/D,cAAc,wCAAwC,CAAA;AACtD,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/semantic-queries/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/semantic-queries/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|