@empathyco/x-components 7.1.1 → 7.2.1
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 +14 -0
- package/docs/API-reference/api/x-components.usealiasapi.md +21 -0
- package/docs/API-reference/api/x-components.usealiasapi.selectedprompt.md +13 -0
- package/js/composables/use-alias-api.js +3 -0
- package/js/composables/use-alias-api.js.map +1 -1
- package/js/x-modules/recommendations/components/recommendations.vue.js.map +1 -1
- package/js/x-modules/recommendations/components/recommendations.vue2.js +2 -0
- package/js/x-modules/recommendations/components/recommendations.vue2.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +27 -0
- package/report/x-components.api.md +1 -0
- package/types/src/composables/use-alias-api.d.ts +2 -0
- package/types/src/composables/use-alias-api.d.ts.map +1 -1
- package/types/src/x-modules/recommendations/components/recommendations.vue.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.2.1](https://github.com/empathyco/x/compare/@empathyco/x-components@7.2.0...@empathyco/x-components@7.2.1) (2026-06-26)
|
|
7
|
+
|
|
8
|
+
### Code Refactoring
|
|
9
|
+
|
|
10
|
+
* **recommendations:** provide `LIST_ITEMS_KEY` injection token (#2124)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [7.2.0](https://github.com/empathyco/x/compare/@empathyco/x-components@7.1.1...@empathyco/x-components@7.2.0) (2026-06-18)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **alias:** add selectedPrompt to useAliasApi and update tests for related prompts (#2121)
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
## [7.1.1](https://github.com/empathyco/x/compare/@empathyco/x-components@7.1.0...@empathyco/x-components@7.1.1) (2026-06-17)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @empathyco/x-components
|
|
@@ -580,6 +580,27 @@ Filter\[\]
|
|
|
580
580
|
The [FacetsXModule](./x-components.facetsxmodule.md) selected filters.
|
|
581
581
|
|
|
582
582
|
|
|
583
|
+
</td></tr>
|
|
584
|
+
<tr><td>
|
|
585
|
+
|
|
586
|
+
[selectedPrompt](./x-components.usealiasapi.selectedprompt.md)
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
</td><td>
|
|
590
|
+
|
|
591
|
+
`readonly`
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
</td><td>
|
|
595
|
+
|
|
596
|
+
number
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
</td><td>
|
|
600
|
+
|
|
601
|
+
The [RelatedPromptsXModule](./x-components.relatedpromptsxmodule.md) selected prompt.
|
|
602
|
+
|
|
603
|
+
|
|
583
604
|
</td></tr>
|
|
584
605
|
<tr><td>
|
|
585
606
|
|
|
@@ -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) > [UseAliasAPI](./x-components.usealiasapi.md) > [selectedPrompt](./x-components.usealiasapi.selectedprompt.md)
|
|
4
|
+
|
|
5
|
+
## UseAliasAPI.selectedPrompt property
|
|
6
|
+
|
|
7
|
+
The [RelatedPromptsXModule](./x-components.relatedpromptsxmodule.md) selected prompt.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
readonly selectedPrompt: number;
|
|
13
|
+
```
|
|
@@ -123,6 +123,9 @@ function useAliasApi() {
|
|
|
123
123
|
get selectedRelatedTags() {
|
|
124
124
|
return store.state.x.relatedTags?.selectedRelatedTags ?? [];
|
|
125
125
|
},
|
|
126
|
+
get selectedPrompt() {
|
|
127
|
+
return store.state.x.relatedPrompts?.selectedPrompt ?? -1;
|
|
128
|
+
},
|
|
126
129
|
get semanticQueries() {
|
|
127
130
|
return store.state.x.semanticQueries?.semanticQueries ?? [];
|
|
128
131
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-alias-api.js","sources":["../../../src/composables/use-alias-api.ts"],"sourcesContent":["import type {\n Facet,\n Filter,\n HistoryQuery,\n NextQuery,\n PartialResult,\n Redirection,\n RelatedPrompt,\n RelatedTag,\n Result,\n SemanticQuery,\n Suggestion,\n} from '@empathyco/x-types'\nimport type { RequestStatus } from '../store/utils/status-store.utils'\nimport type { ScrollComponentState } from '../x-modules/scroll/store/types'\nimport type { InputStatus } from '../x-modules/search-box/store/types'\nimport { useStore } from 'vuex'\nimport { getGetterPath } from '../plugins/index'\n\n/* eslint-disable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function useAliasApi(): UseAliasAPI {\n const queryModules = [\n 'facets',\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search',\n ] as const\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search',\n ] as const\n\n const store = useStore()\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return store.state.x[moduleName]?.query ?? ''\n },\n enumerable: true,\n })\n }, {} as UseAliasQueryAPI)\n\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return store.state.x[moduleName]?.status\n },\n enumerable: true,\n })\n }, {} as UseAliasStatusAPI)\n\n return {\n query,\n status,\n get device() {\n return store.state.x.device?.name ?? null\n },\n get facets() {\n return store.getters[getGetterPath('facets', 'facets')] ?? {}\n },\n get historyQueries() {\n return store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? []\n },\n get historyQueriesWithResults() {\n return store.getters[getGetterPath('historyQueries', 'historyQueriesWithResults')] ?? []\n },\n get fullHistoryQueries() {\n return store.state.x.historyQueries?.historyQueries ?? []\n },\n get isHistoryQueriesEnabled() {\n return store.state.x.historyQueries?.isEnabled ?? false\n },\n get fromNoResultsWithFilters() {\n return store.state.x.search?.fromNoResultsWithFilters ?? false\n },\n get identifierResults() {\n return store.state.x.identifierResults?.identifierResults ?? []\n },\n get searchBoxStatus() {\n return store.state.x.searchBox?.inputStatus ?? undefined\n },\n get isEmpathizeOpen() {\n return store.state.x.empathize?.isOpen ?? false\n },\n get nextQueries() {\n return store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? []\n },\n get noResults() {\n return store.state.x.search?.isNoResults ?? false\n },\n get lowResults() {\n return (\n store.state.x.search?.totalResults > 0 &&\n store.state.x.search?.totalResults < store.state.x.search?.config?.threshold\n )\n },\n get partialResults() {\n return store.state.x.search?.partialResults ?? []\n },\n get popularSearches() {\n return store.state.x.popularSearches?.popularSearches ?? []\n },\n get querySuggestions() {\n return store.getters[getGetterPath('querySuggestions', 'querySuggestions')] ?? []\n },\n get fullQuerySuggestions() {\n return store.state.x.querySuggestions?.suggestions ?? []\n },\n get recommendations() {\n return store.state.x.recommendations?.recommendations ?? []\n },\n get redirections() {\n return store.state.x.search?.redirections ?? []\n },\n get relatedTags() {\n return store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? []\n },\n get results() {\n return store.state.x.search?.results ?? []\n },\n get scroll() {\n return store.state.x.scroll?.data ?? {}\n },\n get selectedFilters() {\n return store.getters[getGetterPath('facets', 'selectedFilters')] ?? []\n },\n get selectedRelatedTags() {\n return store.state.x.relatedTags?.selectedRelatedTags ?? []\n },\n get semanticQueries() {\n return store.state.x.semanticQueries?.semanticQueries ?? []\n },\n get relatedPrompts() {\n return store.state.x.relatedPrompts?.relatedPrompts ?? []\n },\n get spellcheckedQuery() {\n return store.state.x.search?.spellcheckedQuery ?? null\n },\n get totalResults() {\n return store.state.x.search?.totalResults ?? 0\n },\n get selectedSort() {\n return store.state.x.search?.sort ?? ''\n },\n get priceStats() {\n return store.state.x.search?.stats?.price ?? {}\n },\n }\n}\n\n/**\n * Alias to facilitate retrieving values from the store.\n *\n * @public\n */\nexport interface UseAliasAPI {\n /** The {@link DeviceXModule} detected device. */\n readonly device: string | null\n /** The {@link FacetsXModule} facets. */\n readonly facets: Record<Facet['id'], Facet>\n /** The {@link HistoryQueriesXModule} history queries matching the query. */\n readonly historyQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries with 1 or more results. */\n readonly historyQueriesWithResults: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries. */\n readonly fullHistoryQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries enabled flag. */\n readonly isHistoryQueriesEnabled: Readonly<boolean>\n /** The {@link SearchXModule} no results with filters flag. */\n readonly fromNoResultsWithFilters: Readonly<boolean>\n /** The {@link IdentifierResultsXModule} results. */\n readonly identifierResults: ReadonlyArray<Result>\n /** The {@link SearchBoxXModule } input status. */\n readonly searchBoxStatus: InputStatus | undefined\n /** The {@link Empathize} is open state. */\n readonly isEmpathizeOpen: boolean\n /** The {@link NextQueriesXModule} next queries. */\n readonly nextQueries: ReadonlyArray<NextQuery>\n /** The {@link SearchXModule} no results situation. */\n readonly noResults: boolean\n /** The {@link SearchXModule} low results situation. */\n readonly lowResults: boolean\n /** The {@link SearchXModule} partial results. */\n readonly partialResults: ReadonlyArray<PartialResult>\n /** The {@link PopularSearchesXModule} popular searches. */\n readonly popularSearches: ReadonlyArray<Suggestion>\n /** The query value of the different modules. */\n readonly query: UseAliasQueryAPI\n /** The {@link QuerySuggestionsXModule} query suggestions that should be displayed. */\n readonly querySuggestions: ReadonlyArray<Suggestion>\n /** The {@link QuerySuggestionsXModule} query suggestions. */\n readonly fullQuerySuggestions: ReadonlyArray<Suggestion>\n /** The {@link RecommendationsXModule} recommendations. */\n readonly recommendations: ReadonlyArray<Result>\n /** The {@link SearchXModule} redirections. */\n readonly redirections: ReadonlyArray<Redirection>\n /** The {@link RelatedTagsXModule} related tags (Both selected and deselected). */\n readonly relatedTags: ReadonlyArray<RelatedTag>\n /** The {@link SearchXModule} search results. */\n readonly results: ReadonlyArray<Result>\n /** The {@link ScrollXModule} data state. */\n readonly scroll: Record<string, ScrollComponentState>\n /** The {@link FacetsXModule} selected filters. */\n readonly selectedFilters: Filter[]\n /** The {@link RelatedTagsXModule} selected related tags. */\n readonly selectedRelatedTags: ReadonlyArray<RelatedTag>\n /** The {@link SemanticQueriesXModule} queries. */\n readonly semanticQueries: ReadonlyArray<SemanticQuery>\n /** The {@link RelatedPromptsXModule} related prompts. */\n readonly relatedPrompts: ReadonlyArray<RelatedPrompt>\n /** The {@link SearchXModule} spellchecked query. */\n readonly spellcheckedQuery: string | null\n /** The status value of the different modules. */\n readonly status: UseAliasStatusAPI\n /** The {@link SearchXModule} total results. */\n readonly totalResults: number\n /** The {@link SearchXModule} selected sort. */\n readonly selectedSort: string\n /** The {@link SearchXModule} price specific stats. */\n readonly priceStats: { min: number; max: number }\n}\n\n/**\n * Alias to facilitate retrieving the modules with query.\n *\n * @public\n */\nexport interface UseAliasQueryAPI {\n /** The {@link FacetsXModule} query. */\n readonly facets: string\n /** The {@link SearchBoxXModule} query. */\n readonly searchBox: string\n /** The {@link NextQueriesXModule} query. */\n readonly nextQueries: string\n /** The {@link QuerySuggestionsXModule} query. */\n readonly querySuggestions: string\n /** The {@link RelatedTagsXModule} query. */\n readonly relatedTags: string\n /** The {@link SearchXModule} query. */\n readonly search: string\n}\n\n/**\n * Alias to facilitate retrieving the modules with status.\n *\n * @public\n */\nexport interface UseAliasStatusAPI {\n /** The {@link IdentifierResultsXModule} status. */\n readonly identifierResults: RequestStatus | undefined\n /** The {@link NextQueriesXModule} status. */\n readonly nextQueries: RequestStatus | undefined\n /** The {@link PopularSearchesXModule} status. */\n readonly popularSearches: RequestStatus | undefined\n /** The {@link QuerySuggestionsXModule} status. */\n readonly querySuggestions: RequestStatus | undefined\n /** The {@link RecommendationsXModule} status. */\n readonly recommendations: RequestStatus | undefined\n /** The {@link RelatedTagsXModule} status. */\n readonly relatedTags: RequestStatus | undefined\n /** The {@link SearchXModule} status. */\n readonly search: RequestStatus | undefined\n}\n\n/* eslint-enable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n"],"names":[],"mappings":";;;;;;AAmBA;AAEA;;;;;;AAMG;SACa,WAAW,GAAA;AACzB,IAAA,MAAM,YAAY,GAAG;QACnB,QAAQ;QACR,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,QAAQ;KACA;AACV,IAAA,MAAM,aAAa,GAAG;QACpB,mBAAmB;QACnB,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,QAAQ;KACA;AAEV,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;IAExB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,KAAI;AACpD,QAAA,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG,GAAA;AACD,gBAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,IAAI,EAAE;YAC/C,CAAC;AACD,YAAA,UAAU,EAAE,IAAI;AACjB,SAAA,CAAC;IACJ,CAAC,EAAE,EAAsB,CAAC;IAE1B,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,KAAI;AACtD,QAAA,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG,GAAA;gBACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,MAAM;YAC1C,CAAC;AACD,YAAA,UA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K,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC;QAChD,CAAC;AACD,QAAA,IAAI,YAAY,GAAA;YACd,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE;QACzC,CAAC;AACD,QAAA,IAAI,UAAU,GAAA;AACZ,YAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE;QACjD,CAAC;KACF;AACH;AAoHA;;;;"}
|
|
1
|
+
{"version":3,"file":"use-alias-api.js","sources":["../../../src/composables/use-alias-api.ts"],"sourcesContent":["import type {\n Facet,\n Filter,\n HistoryQuery,\n NextQuery,\n PartialResult,\n Redirection,\n RelatedPrompt,\n RelatedTag,\n Result,\n SemanticQuery,\n Suggestion,\n} from '@empathyco/x-types'\nimport type { RequestStatus } from '../store/utils/status-store.utils'\nimport type { ScrollComponentState } from '../x-modules/scroll/store/types'\nimport type { InputStatus } from '../x-modules/search-box/store/types'\nimport { useStore } from 'vuex'\nimport { getGetterPath } from '../plugins/index'\n\n/* eslint-disable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function useAliasApi(): UseAliasAPI {\n const queryModules = [\n 'facets',\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search',\n ] as const\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search',\n ] as const\n\n const store = useStore()\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return store.state.x[moduleName]?.query ?? ''\n },\n enumerable: true,\n })\n }, {} as UseAliasQueryAPI)\n\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return store.state.x[moduleName]?.status\n },\n enumerable: true,\n })\n }, {} as UseAliasStatusAPI)\n\n return {\n query,\n status,\n get device() {\n return store.state.x.device?.name ?? null\n },\n get facets() {\n return store.getters[getGetterPath('facets', 'facets')] ?? {}\n },\n get historyQueries() {\n return store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? []\n },\n get historyQueriesWithResults() {\n return store.getters[getGetterPath('historyQueries', 'historyQueriesWithResults')] ?? []\n },\n get fullHistoryQueries() {\n return store.state.x.historyQueries?.historyQueries ?? []\n },\n get isHistoryQueriesEnabled() {\n return store.state.x.historyQueries?.isEnabled ?? false\n },\n get fromNoResultsWithFilters() {\n return store.state.x.search?.fromNoResultsWithFilters ?? false\n },\n get identifierResults() {\n return store.state.x.identifierResults?.identifierResults ?? []\n },\n get searchBoxStatus() {\n return store.state.x.searchBox?.inputStatus ?? undefined\n },\n get isEmpathizeOpen() {\n return store.state.x.empathize?.isOpen ?? false\n },\n get nextQueries() {\n return store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? []\n },\n get noResults() {\n return store.state.x.search?.isNoResults ?? false\n },\n get lowResults() {\n return (\n store.state.x.search?.totalResults > 0 &&\n store.state.x.search?.totalResults < store.state.x.search?.config?.threshold\n )\n },\n get partialResults() {\n return store.state.x.search?.partialResults ?? []\n },\n get popularSearches() {\n return store.state.x.popularSearches?.popularSearches ?? []\n },\n get querySuggestions() {\n return store.getters[getGetterPath('querySuggestions', 'querySuggestions')] ?? []\n },\n get fullQuerySuggestions() {\n return store.state.x.querySuggestions?.suggestions ?? []\n },\n get recommendations() {\n return store.state.x.recommendations?.recommendations ?? []\n },\n get redirections() {\n return store.state.x.search?.redirections ?? []\n },\n get relatedTags() {\n return store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? []\n },\n get results() {\n return store.state.x.search?.results ?? []\n },\n get scroll() {\n return store.state.x.scroll?.data ?? {}\n },\n get selectedFilters() {\n return store.getters[getGetterPath('facets', 'selectedFilters')] ?? []\n },\n get selectedRelatedTags() {\n return store.state.x.relatedTags?.selectedRelatedTags ?? []\n },\n get selectedPrompt() {\n return store.state.x.relatedPrompts?.selectedPrompt ?? -1\n },\n get semanticQueries() {\n return store.state.x.semanticQueries?.semanticQueries ?? []\n },\n get relatedPrompts() {\n return store.state.x.relatedPrompts?.relatedPrompts ?? []\n },\n get spellcheckedQuery() {\n return store.state.x.search?.spellcheckedQuery ?? null\n },\n get totalResults() {\n return store.state.x.search?.totalResults ?? 0\n },\n get selectedSort() {\n return store.state.x.search?.sort ?? ''\n },\n get priceStats() {\n return store.state.x.search?.stats?.price ?? {}\n },\n }\n}\n\n/**\n * Alias to facilitate retrieving values from the store.\n *\n * @public\n */\nexport interface UseAliasAPI {\n /** The {@link DeviceXModule} detected device. */\n readonly device: string | null\n /** The {@link FacetsXModule} facets. */\n readonly facets: Record<Facet['id'], Facet>\n /** The {@link HistoryQueriesXModule} history queries matching the query. */\n readonly historyQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries with 1 or more results. */\n readonly historyQueriesWithResults: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries. */\n readonly fullHistoryQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries enabled flag. */\n readonly isHistoryQueriesEnabled: Readonly<boolean>\n /** The {@link SearchXModule} no results with filters flag. */\n readonly fromNoResultsWithFilters: Readonly<boolean>\n /** The {@link IdentifierResultsXModule} results. */\n readonly identifierResults: ReadonlyArray<Result>\n /** The {@link SearchBoxXModule } input status. */\n readonly searchBoxStatus: InputStatus | undefined\n /** The {@link Empathize} is open state. */\n readonly isEmpathizeOpen: boolean\n /** The {@link NextQueriesXModule} next queries. */\n readonly nextQueries: ReadonlyArray<NextQuery>\n /** The {@link SearchXModule} no results situation. */\n readonly noResults: boolean\n /** The {@link SearchXModule} low results situation. */\n readonly lowResults: boolean\n /** The {@link SearchXModule} partial results. */\n readonly partialResults: ReadonlyArray<PartialResult>\n /** The {@link PopularSearchesXModule} popular searches. */\n readonly popularSearches: ReadonlyArray<Suggestion>\n /** The query value of the different modules. */\n readonly query: UseAliasQueryAPI\n /** The {@link QuerySuggestionsXModule} query suggestions that should be displayed. */\n readonly querySuggestions: ReadonlyArray<Suggestion>\n /** The {@link QuerySuggestionsXModule} query suggestions. */\n readonly fullQuerySuggestions: ReadonlyArray<Suggestion>\n /** The {@link RecommendationsXModule} recommendations. */\n readonly recommendations: ReadonlyArray<Result>\n /** The {@link SearchXModule} redirections. */\n readonly redirections: ReadonlyArray<Redirection>\n /** The {@link RelatedTagsXModule} related tags (Both selected and deselected). */\n readonly relatedTags: ReadonlyArray<RelatedTag>\n /** The {@link SearchXModule} search results. */\n readonly results: ReadonlyArray<Result>\n /** The {@link ScrollXModule} data state. */\n readonly scroll: Record<string, ScrollComponentState>\n /** The {@link FacetsXModule} selected filters. */\n readonly selectedFilters: Filter[]\n /** The {@link RelatedTagsXModule} selected related tags. */\n readonly selectedRelatedTags: ReadonlyArray<RelatedTag>\n /** The {@link RelatedPromptsXModule} selected prompt. */\n readonly selectedPrompt: number\n /** The {@link SemanticQueriesXModule} queries. */\n readonly semanticQueries: ReadonlyArray<SemanticQuery>\n /** The {@link RelatedPromptsXModule} related prompts. */\n readonly relatedPrompts: ReadonlyArray<RelatedPrompt>\n /** The {@link SearchXModule} spellchecked query. */\n readonly spellcheckedQuery: string | null\n /** The status value of the different modules. */\n readonly status: UseAliasStatusAPI\n /** The {@link SearchXModule} total results. */\n readonly totalResults: number\n /** The {@link SearchXModule} selected sort. */\n readonly selectedSort: string\n /** The {@link SearchXModule} price specific stats. */\n readonly priceStats: { min: number; max: number }\n}\n\n/**\n * Alias to facilitate retrieving the modules with query.\n *\n * @public\n */\nexport interface UseAliasQueryAPI {\n /** The {@link FacetsXModule} query. */\n readonly facets: string\n /** The {@link SearchBoxXModule} query. */\n readonly searchBox: string\n /** The {@link NextQueriesXModule} query. */\n readonly nextQueries: string\n /** The {@link QuerySuggestionsXModule} query. */\n readonly querySuggestions: string\n /** The {@link RelatedTagsXModule} query. */\n readonly relatedTags: string\n /** The {@link SearchXModule} query. */\n readonly search: string\n}\n\n/**\n * Alias to facilitate retrieving the modules with status.\n *\n * @public\n */\nexport interface UseAliasStatusAPI {\n /** The {@link IdentifierResultsXModule} status. */\n readonly identifierResults: RequestStatus | undefined\n /** The {@link NextQueriesXModule} status. */\n readonly nextQueries: RequestStatus | undefined\n /** The {@link PopularSearchesXModule} status. */\n readonly popularSearches: RequestStatus | undefined\n /** The {@link QuerySuggestionsXModule} status. */\n readonly querySuggestions: RequestStatus | undefined\n /** The {@link RecommendationsXModule} status. */\n readonly recommendations: RequestStatus | undefined\n /** The {@link RelatedTagsXModule} status. */\n readonly relatedTags: RequestStatus | undefined\n /** The {@link SearchXModule} status. */\n readonly search: RequestStatus | undefined\n}\n\n/* eslint-enable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n"],"names":[],"mappings":";;;;;;AAmBA;AAEA;;;;;;AAMG;SACa,WAAW,GAAA;AACzB,IAAA,MAAM,YAAY,GAAG;QACnB,QAAQ;QACR,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,QAAQ;KACA;AACV,IAAA,MAAM,aAAa,GAAG;QACpB,mBAAmB;QACnB,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,QAAQ;KACA;AAEV,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;IAExB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,KAAI;AACpD,QAAA,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG,GAAA;AACD,gBAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,IAAI,EAAE;YAC/C,CAA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,CAAC,cAAc,EAAE,cAAc,IAAI,EAAE;QAC3D,CAAC;AACD,QAAA,IAAI,eAAe,GAAA;YACjB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,EAAE,eAAe,IAAI,EAAE;QAC7D,CAAC;AACD,QAAA,IAAI,cAAc,GAAA;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,cAAc,IAAI,EAAE;QAC3D,CAAC;AACD,QAAA,IAAI,iBAAiB,GAAA;YACnB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,iBAAiB,IAAI,IAAI;QACxD,CAAC;AACD,QAAA,IAAI,YAAY,GAAA;YACd,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC;QAChD,CAAC;AACD,QAAA,IAAI,YAAY,GAAA;YACd,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE;QACzC,CAAC;AACD,QAAA,IAAI,UAAU,GAAA;AACZ,YAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE;QACjD,CAAC;KACF;AACH;AAsHA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommendations.vue.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\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 `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_renderSlot"],"mappings":";;;;;;SAGU,IAAA,CAAA,eAAA,CAAgB,MAAA,IAAAA,SAAA,EAAA,EAFxBC,WAAA,CAmBYC,uBAAA,CAlBL,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;IAEd,GAAA,EAAI,IAAA;AAAA,IACJ,WAAA,EAAU,iBAAA;AAAA,IACV,KAAA,EAAM;AAAA,GAAA,EAAA;qBAGJ,MAAyC;AAAA,OAAAF,SAAA,CAAA,IAAA,CAAA,EAD3CG,kBAAA;AAAA,QAWKC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAVsB,IAAA,CAAA,eAAA,EAAe,CAAjC,cAAA,KAAc;8BADvBF,kBAAA,CAWK,IAAA,EAAA;AAAA,YATF,KAAK,cAAA,CAAe,EAAA;AAAA,YACrB,KAAA,EAAM,yBAAA;AAAA,YACN,WAAA,EAAU;AAAA,WAAA,EAAA;AAMV,YAAAG,UAAA,CAAyC,0BAAlC,cAAA,EAA8B,EAAA,MAAA,EAAA,IAAA;AAAA,WAAA,CAAA;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"recommendations.vue.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n provide(LIST_ITEMS_KEY as string, recommendations)\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\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 `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_renderSlot"],"mappings":";;;;;;SAGU,IAAA,CAAA,eAAA,CAAgB,MAAA,IAAAA,SAAA,EAAA,EAFxBC,WAAA,CAmBYC,uBAAA,CAlBL,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;IAEd,GAAA,EAAI,IAAA;AAAA,IACJ,WAAA,EAAU,iBAAA;AAAA,IACV,KAAA,EAAM;AAAA,GAAA,EAAA;qBAGJ,MAAyC;AAAA,OAAAF,SAAA,CAAA,IAAA,CAAA,EAD3CG,kBAAA;AAAA,QAWKC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAVsB,IAAA,CAAA,eAAA,EAAe,CAAjC,cAAA,KAAc;8BADvBF,kBAAA,CAWK,IAAA,EAAA;AAAA,YATF,KAAK,cAAA,CAAe,EAAA;AAAA,YACrB,KAAA,EAAM,yBAAA;AAAA,YACN,WAAA,EAAU;AAAA,WAAA,EAAA;AAMV,YAAAG,UAAA,CAAyC,0BAAlC,cAAA,EAA8B,EAAA,MAAA,EAAA,IAAA;AAAA,WAAA,CAAA;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, provide, computed } from 'vue';
|
|
2
|
+
import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts.js';
|
|
2
3
|
import '../../../composables/create-use-device.js';
|
|
3
4
|
import 'vuex';
|
|
4
5
|
import '../../../plugins/x-bus.js';
|
|
@@ -45,6 +46,7 @@ var _sfc_main = defineComponent({
|
|
|
45
46
|
* @returns - The list of recommendations slice by the number of items to render.
|
|
46
47
|
*/
|
|
47
48
|
const recommendations = computed(() => storedRecommendations.value.slice(0, props.maxItemsToRender));
|
|
49
|
+
provide(LIST_ITEMS_KEY, recommendations);
|
|
48
50
|
/**
|
|
49
51
|
* Render function to execute the `layout` slot, binding `slotsProps` and getting only the
|
|
50
52
|
* first `vNode` to avoid Fragments and Text root nodes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommendations.vue2.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\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 `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recommendations.vue2.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n provide(LIST_ITEMS_KEY as string, recommendations)\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\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 `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiCA;;;;;;;;;AASE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,sBAAsB,CAAC,IAAI;AACpC,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;;QAEpB,MAAM,qBAAoB,GAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC,eAAc;;QAGxE,OAAO,CAAwC,wBAAwB,EAAE;YACvE,4BAA4B;AAC7B,SAAA,CAAA;AAED;;;;AAIE;QACF,MAAM,eAAc,GAAI,QAAQ,CAAW,MACzC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAC9D;AAEA,QAAA,OAAO,CAAC,cAAwB,EAAE,eAAe,CAAA;AAEjD;;;;;;;;;;AAUE;AACF,QAAA,SAAS,gBAAgB,GAAA;AACvB,YAAA,MAAM,YAAY;gBAChB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,eAAe,EAAE,eAAe,CAAC,KAAK;aACxC;YACA,OAAO,eAAe,CAAC,KAAK,CAAC,MAAK,GAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA,GAAI,EAAC;QACxE;AAEA;AAC+E;AAC/E,QAAA,MAAM,cAAa,GAAI,EAAE,eAAc,EAAE;AACzC,QAAA,QAAQ,KAAK,CAAC,MAAK,GAAI,gBAAe,GAAI,cAAc;IAC1D,CAAC;AACF,CAAA,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.1",
|
|
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": "4971259f9f1246043a8d342e9d1b057e1ba6268c"
|
|
121
121
|
}
|
|
@@ -83239,6 +83239,33 @@
|
|
|
83239
83239
|
"endIndex": 3
|
|
83240
83240
|
}
|
|
83241
83241
|
},
|
|
83242
|
+
{
|
|
83243
|
+
"kind": "PropertySignature",
|
|
83244
|
+
"canonicalReference": "@empathyco/x-components!UseAliasAPI#selectedPrompt:member",
|
|
83245
|
+
"docComment": "/**\n * The {@link RelatedPromptsXModule} selected prompt.\n */\n",
|
|
83246
|
+
"excerptTokens": [
|
|
83247
|
+
{
|
|
83248
|
+
"kind": "Content",
|
|
83249
|
+
"text": "readonly selectedPrompt: "
|
|
83250
|
+
},
|
|
83251
|
+
{
|
|
83252
|
+
"kind": "Content",
|
|
83253
|
+
"text": "number"
|
|
83254
|
+
},
|
|
83255
|
+
{
|
|
83256
|
+
"kind": "Content",
|
|
83257
|
+
"text": ";"
|
|
83258
|
+
}
|
|
83259
|
+
],
|
|
83260
|
+
"isReadonly": true,
|
|
83261
|
+
"isOptional": false,
|
|
83262
|
+
"releaseTag": "Public",
|
|
83263
|
+
"name": "selectedPrompt",
|
|
83264
|
+
"propertyTypeTokenRange": {
|
|
83265
|
+
"startIndex": 1,
|
|
83266
|
+
"endIndex": 2
|
|
83267
|
+
}
|
|
83268
|
+
},
|
|
83242
83269
|
{
|
|
83243
83270
|
"kind": "PropertySignature",
|
|
83244
83271
|
"canonicalReference": "@empathyco/x-components!UseAliasAPI#selectedRelatedTags:member",
|
|
@@ -8908,6 +8908,7 @@ export interface UseAliasAPI {
|
|
|
8908
8908
|
// Warning: (ae-incompatible-release-tags) The symbol "searchBoxStatus" is marked as @public, but its signature references "InputStatus" which is marked as @internal
|
|
8909
8909
|
readonly searchBoxStatus: InputStatus | undefined;
|
|
8910
8910
|
readonly selectedFilters: Filter[];
|
|
8911
|
+
readonly selectedPrompt: number;
|
|
8911
8912
|
readonly selectedRelatedTags: ReadonlyArray<RelatedTag_2>;
|
|
8912
8913
|
readonly selectedSort: string;
|
|
8913
8914
|
readonly semanticQueries: ReadonlyArray<SemanticQuery_2>;
|
|
@@ -66,6 +66,8 @@ export interface UseAliasAPI {
|
|
|
66
66
|
readonly selectedFilters: Filter[];
|
|
67
67
|
/** The {@link RelatedTagsXModule} selected related tags. */
|
|
68
68
|
readonly selectedRelatedTags: ReadonlyArray<RelatedTag>;
|
|
69
|
+
/** The {@link RelatedPromptsXModule} selected prompt. */
|
|
70
|
+
readonly selectedPrompt: number;
|
|
69
71
|
/** The {@link SemanticQueriesXModule} queries. */
|
|
70
72
|
readonly semanticQueries: ReadonlyArray<SemanticQuery>;
|
|
71
73
|
/** The {@link RelatedPromptsXModule} related prompts. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-alias-api.d.ts","sourceRoot":"","sources":["../../../../src/composables/use-alias-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,EACV,MAAM,EACN,aAAa,E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,iBAAiB;IAChC,mDAAmD;IACnD,QAAQ,CAAC,iBAAiB,EAAE,aAAa,GAAG,SAAS,CAAA;IACrD,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,EAAE,aAAa,GAAG,SAAS,CAAA;IAC/C,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,aAAa,GAAG,SAAS,CAAA;IACnD,kDAAkD;IAClD,QAAQ,CAAC,gBAAgB,EAAE,aAAa,GAAG,SAAS,CAAA;IACpD,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,aAAa,GAAG,SAAS,CAAA;IACnD,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,EAAE,aAAa,GAAG,SAAS,CAAA;IAC/C,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAA;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommendations.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/recommendations/components/recommendations.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"recommendations.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/recommendations/components/recommendations.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAShD;;;;;;;;;GASG;;IAKC,4EAA4E;;;;;IAK5E,gDAAgD;;;;;IALhD,4EAA4E;;;;;IAK5E,gDAAgD;;;;;AATpD,wBAwDE"}
|