@empathyco/x-components 6.0.0-alpha.2 → 6.0.0-alpha.20
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 +202 -1
- package/core/index.js +1 -0
- package/core/index.js.map +1 -1
- package/design-system/deprecated-full-theme.css +1555 -1555
- package/docs/API-reference/api/x-adapter-platform.md +9 -0
- package/docs/API-reference/api/x-adapter-platform.platformadapter.relatedprompts.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.md +22 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.nextqueries.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.suggestiontext.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.type.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptsrequest.md +15 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptsresponse.data.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptsresponse.md +21 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptsresponse.status.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformsearchresponse.catalog.md +6 -0
- package/docs/API-reference/api/x-adapter-platform.platformsearchresponse.md +1 -1
- package/docs/API-reference/api/x-adapter-platform.relatedpromptschema.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.relatedpromptsendpointadapter.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.relatedpromptsrequestmapper.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.relatedpromptsrequestschema.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.relatedpromptsresponsemapper.md +13 -0
- package/docs/API-reference/api/x-adapter-platform.relatedpromptsresponseschema.md +13 -0
- package/docs/API-reference/api/x-components.animationprop.md +6 -1
- package/docs/API-reference/api/x-components.bannerslist.md +3 -3
- package/docs/API-reference/api/x-components.basedropdown.md +5 -5
- package/docs/API-reference/api/x-components.baseeventsmodal.md +2 -2
- package/docs/API-reference/api/x-components.basegrid.md +3 -3
- package/docs/API-reference/api/x-components.baseheadertogglepanel.md +5 -5
- package/docs/API-reference/api/x-components.baseidmodal.md +2 -2
- package/docs/API-reference/api/x-components.baseidtogglepanel.md +5 -5
- package/docs/API-reference/api/x-components.basemodal.md +10 -10
- package/docs/API-reference/api/x-components.baseresultimage.md +9 -9
- package/docs/API-reference/api/x-components.baseslider.md +70 -0
- package/docs/API-reference/api/x-components.basesuggestions.md +3 -3
- package/docs/API-reference/api/x-components.basetabspanel.md +8 -8
- package/docs/API-reference/api/x-components.basetogglepanel.md +3 -3
- package/docs/API-reference/api/x-components.basevariablecolumngrid.md +3 -3
- package/docs/API-reference/api/x-components.cancelfetchandsaverelatedprompts.md +13 -0
- package/docs/API-reference/api/x-components.empathize.md +5 -5
- package/docs/API-reference/api/x-components.facets.md +3 -3
- package/docs/API-reference/api/x-components.fetchandsaverelatedprompts.md +13 -0
- package/docs/API-reference/api/x-components.fetchrelatedprompts.md +13 -0
- package/docs/API-reference/api/x-components.filterslist.md +3 -3
- package/docs/API-reference/api/x-components.globalxbus.md +6 -0
- package/docs/API-reference/api/x-components.hierarchicalfilter.md +5 -2
- package/docs/API-reference/api/x-components.identifierresults.md +3 -3
- package/docs/API-reference/api/x-components.itemslist.md +3 -3
- package/docs/API-reference/api/x-components.mainmodal.md +2 -2
- package/docs/API-reference/api/x-components.md +17 -0
- package/docs/API-reference/api/x-components.multicolumnmaxwidthlayout.md +5 -5
- package/docs/API-reference/api/x-components.myhistory.md +3 -3
- package/docs/API-reference/api/x-components.nextqueriesgroup.md +22 -0
- package/docs/API-reference/api/x-components.nextqueriesgroup.modelname.md +11 -0
- package/docs/API-reference/api/x-components.nextqueriesgroup.nextqueries.md +11 -0
- package/docs/API-reference/api/x-components.nextquerieslist.md +3 -3
- package/docs/API-reference/api/x-components.partialresultslist.md +3 -3
- package/docs/API-reference/api/x-components.promotedslist.md +3 -3
- package/docs/API-reference/api/x-components.querypreviewlist.md +3 -3
- package/docs/API-reference/api/x-components.recommendations.md +3 -3
- package/docs/API-reference/api/x-components.relatedprompt.md +38 -0
- package/docs/API-reference/api/x-components.relatedpromptrequest.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsactioncontext.md +15 -0
- package/docs/API-reference/api/x-components.relatedpromptsactions.cancelfetchandsaverelatedprompts.md +17 -0
- package/docs/API-reference/api/x-components.relatedpromptsactions.fetchandsaverelatedprompts.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsactions.fetchrelatedprompts.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsactions.md +22 -0
- package/docs/API-reference/api/x-components.relatedpromptsgetters.md +20 -0
- package/docs/API-reference/api/x-components.relatedpromptsgetters.request.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptslist.md +72 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.md +25 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.resetrelatedpromptsstate.md +17 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.setparams.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.setrelatedpromptsproducts.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.setselectedprompt.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.setselectedquery.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.params.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.relatedprompts.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.selectedprompt.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.selectedquery.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.md +22 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.relatedpromptsrequestupdated.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.userselectedarelatedprompt.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.userselectedarelatedpromptquery.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxmodule.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxstoremodule.md +15 -0
- package/docs/API-reference/api/x-components.relatedtags.md +3 -3
- package/docs/API-reference/api/x-components.resultslist.md +3 -3
- package/docs/API-reference/api/x-components.scrolltotop.md +5 -5
- package/docs/API-reference/api/x-components.searchinputplaceholder.md +3 -3
- package/docs/API-reference/api/x-components.searchmutations.md +1 -0
- package/docs/API-reference/api/x-components.searchmutations.setstats.md +24 -0
- package/docs/API-reference/api/x-components.searchstate.md +1 -0
- package/docs/API-reference/api/x-components.searchstate.stats.md +13 -0
- package/docs/API-reference/api/x-components.selectedfilterslist.md +3 -3
- package/docs/API-reference/api/x-components.simplefilter.md +3 -0
- package/docs/API-reference/api/x-components.singlecolumnlayout.md +3 -3
- package/docs/API-reference/api/x-components.snippetcallbacks.md +3 -0
- package/docs/API-reference/api/x-components.snippetconfigextraparams.md +1 -1
- package/docs/API-reference/api/x-components.sortdropdown.md +1 -1
- package/docs/API-reference/api/x-components.tagging.md +17 -4
- package/docs/API-reference/api/x-components.usealiasapi.md +1 -0
- package/docs/API-reference/api/x-components.usealiasapi.pricestats.md +16 -0
- package/docs/API-reference/api/x-components.xeventstypes.md +3 -3
- package/docs/API-reference/api/x-components.xmodulestree.md +1 -0
- package/docs/API-reference/api/x-components.xmodulestree.relatedprompts.md +11 -0
- package/docs/API-reference/api/x-types.md +4 -0
- package/docs/API-reference/api/x-types.relatedprompt.md +23 -0
- package/docs/API-reference/api/x-types.relatedprompt.nextqueries.md +13 -0
- package/docs/API-reference/api/x-types.relatedprompt.suggestiontext.md +13 -0
- package/docs/API-reference/api/x-types.relatedprompt.type.md +13 -0
- package/docs/API-reference/api/x-types.relatedpromptsrequest.md +15 -0
- package/docs/API-reference/api/x-types.relatedpromptsresponse.md +20 -0
- package/docs/API-reference/api/x-types.relatedpromptsresponse.relatedprompts.md +11 -0
- package/docs/API-reference/api/x-types.searchresponse.md +1 -0
- package/docs/API-reference/api/x-types.searchresponse.stats.md +11 -0
- package/docs/API-reference/api/x-types.stats.md +22 -0
- package/docs/API-reference/api/x-types.stats.price.md +14 -0
- package/docs/API-reference/api/x-types.xcomponentsadapter.md +1 -0
- package/docs/API-reference/api/x-types.xcomponentsadapter.relatedprompts.md +11 -0
- package/docs/API-reference/components/common/result/x-components.base-result-image.md +2 -2
- package/docs/API-reference/components/common/x-components.base-slider.md +189 -0
- package/docs/API-reference/components/common/x-components.items-list.md +1 -1
- package/docs/API-reference/components/facets/x-components.facets/facets.md +1 -1
- package/docs/API-reference/components/facets/x-components.lists/selected-filters-list.md +1 -1
- package/docs/API-reference/components/related-prompts/x-components.related-prompt.md +29 -0
- package/docs/API-reference/components/related-prompts/x-components.related-prompts-list.md +196 -0
- package/docs/API-reference/components/search/x-components.results-list.md +1 -1
- package/docs/API-reference/components/tagging/x-components.tagging.md +2 -2
- package/js/components/base-grid.vue.js.map +1 -1
- package/js/components/base-grid.vue2.js.map +1 -1
- package/js/components/base-grid.vue3.js +1 -1
- package/js/components/base-slider.vue.js +66 -0
- package/js/components/base-slider.vue.js.map +1 -0
- package/js/components/base-slider.vue2.js +109 -0
- package/js/components/base-slider.vue2.js.map +1 -0
- package/js/components/base-slider.vue3.js +7 -0
- package/js/components/base-slider.vue3.js.map +1 -0
- package/js/components/icons/cross-tiny.vue.js +2 -2
- package/js/components/icons/plus.vue.js +2 -2
- package/js/components/items-list.vue.js.map +1 -1
- package/js/components/items-list.vue2.js +2 -2
- package/js/components/items-list.vue2.js.map +1 -1
- package/js/components/result/base-result-image.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue2.js +3 -3
- package/js/components/result/base-result-image.vue2.js.map +1 -1
- package/js/components/scroll/use-scroll.js +1 -1
- package/js/components/scroll/use-scroll.js.map +1 -1
- package/js/components/sliding-panel.vue.js +2 -2
- package/js/composables/use-alias-api.js +3 -0
- package/js/composables/use-alias-api.js.map +1 -1
- package/js/index.js +10 -0
- package/js/index.js.map +1 -1
- package/js/types/animation-prop.js +5 -0
- package/js/types/animation-prop.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue2.js +2 -0
- package/js/x-modules/empathize/components/empathize.vue2.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue2.js +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue2.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue2.js +2 -2
- package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
- package/js/x-modules/facets/components/lists/selected-filters-list.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/selected-filters-list.vue2.js +2 -2
- package/js/x-modules/facets/components/lists/selected-filters-list.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-button.vue2.js +2 -0
- package/js/x-modules/queries-preview/components/query-preview-button.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-list.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-list.vue2.js +15 -2
- package/js/x-modules/queries-preview/components/query-preview-list.vue2.js.map +1 -1
- 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 +3 -1
- package/js/x-modules/queries-preview/components/query-preview.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/store/actions/fetch-and-save-query-preview.action.js +2 -1
- package/js/x-modules/queries-preview/store/actions/fetch-and-save-query-preview.action.js.map +1 -1
- package/js/x-modules/queries-preview/store/module.js +1 -1
- package/js/x-modules/queries-preview/store/module.js.map +1 -1
- package/js/x-modules/queries-preview/utils/get-hash-from-query-preview.js +6 -4
- package/js/x-modules/queries-preview/utils/get-hash-from-query-preview.js.map +1 -1
- package/js/x-modules/related-prompts/components/related-prompt.vue.js +90 -0
- package/js/x-modules/related-prompts/components/related-prompt.vue.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompt.vue2.js +54 -0
- package/js/x-modules/related-prompts/components/related-prompt.vue2.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompt.vue3.js +7 -0
- package/js/x-modules/related-prompts/components/related-prompt.vue3.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompts-list.vue.js +154 -0
- package/js/x-modules/related-prompts/components/related-prompts-list.vue.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompts-list.vue2.js +6 -0
- package/js/x-modules/related-prompts/components/related-prompts-list.vue2.js.map +1 -0
- package/js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js +29 -0
- package/js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js.map +1 -0
- package/js/x-modules/related-prompts/store/actions/fetch-related-prompts.action.js +20 -0
- package/js/x-modules/related-prompts/store/actions/fetch-related-prompts.action.js.map +1 -0
- package/js/x-modules/related-prompts/store/emitters.js +14 -0
- package/js/x-modules/related-prompts/store/emitters.js.map +1 -0
- package/js/x-modules/related-prompts/store/getters/request.getter.js +16 -0
- package/js/x-modules/related-prompts/store/getters/request.getter.js.map +1 -0
- package/js/x-modules/related-prompts/store/module.js +53 -0
- package/js/x-modules/related-prompts/store/module.js.map +1 -0
- package/js/x-modules/related-prompts/wiring.js +88 -0
- package/js/x-modules/related-prompts/wiring.js.map +1 -0
- package/js/x-modules/related-prompts/x-module.js +21 -0
- package/js/x-modules/related-prompts/x-module.js.map +1 -0
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js +2 -0
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
- package/js/x-modules/search/components/results-list.vue.js +2 -2
- package/js/x-modules/search/components/results-list.vue.js.map +1 -1
- package/js/x-modules/search/store/actions/save-search-response.action.js +2 -1
- package/js/x-modules/search/store/actions/save-search-response.action.js.map +1 -1
- package/js/x-modules/search/store/module.js +5 -1
- package/js/x-modules/search/store/module.js.map +1 -1
- package/js/x-modules/tagging/components/tagging.vue.js +8 -2
- package/js/x-modules/tagging/components/tagging.vue.js.map +1 -1
- package/package.json +7 -6
- package/related-prompts/index.d.ts +1 -0
- package/related-prompts/index.js +9 -0
- package/report/x-adapter-platform.api.json +575 -1
- package/report/x-components.api.json +4236 -7917
- package/report/x-components.api.md +445 -155
- package/report/x-types.api.json +334 -0
- package/tools/inject-css.js +5 -3
- package/types/adapter/e2e-adapter.d.ts.map +1 -1
- package/types/adapter/mocked-responses.d.ts +3 -0
- package/types/adapter/mocked-responses.d.ts.map +1 -1
- package/types/components/base-dropdown.vue.d.ts +5 -5
- package/types/components/base-grid.vue.d.ts +3 -3
- package/types/components/base-slider.vue.d.ts +74 -0
- package/types/components/base-slider.vue.d.ts.map +1 -0
- package/types/components/base-variable-column-grid.vue.d.ts +3 -3
- package/types/components/global-x-bus.vue.d.ts +6 -0
- package/types/components/global-x-bus.vue.d.ts.map +1 -1
- package/types/components/index.d.ts +1 -0
- package/types/components/index.d.ts.map +1 -1
- package/types/components/items-list.vue.d.ts +3 -3
- package/types/components/layouts/multi-column-max-width-layout.vue.d.ts +5 -5
- package/types/components/layouts/single-column-layout.vue.d.ts +3 -3
- package/types/components/modals/base-events-modal.vue.d.ts +2 -2
- package/types/components/modals/base-id-modal.vue.d.ts +2 -2
- package/types/components/modals/base-modal.vue.d.ts +10 -10
- package/types/components/modals/main-modal.vue.d.ts +2 -2
- package/types/components/panels/base-header-toggle-panel.vue.d.ts +5 -5
- package/types/components/panels/base-id-toggle-panel.vue.d.ts +5 -5
- package/types/components/panels/base-tabs-panel.vue.d.ts +8 -8
- package/types/components/panels/base-toggle-panel.vue.d.ts +3 -3
- package/types/components/result/base-result-image.vue.d.ts +10 -10
- package/types/components/result/base-result-image.vue.d.ts.map +1 -1
- package/types/components/snippet-callbacks.vue.d.ts +3 -0
- package/types/components/snippet-callbacks.vue.d.ts.map +1 -1
- package/types/components/suggestions/base-suggestions.vue.d.ts +3 -3
- package/types/composables/use-alias-api.d.ts +5 -0
- package/types/composables/use-alias-api.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/tailwind/plugin-options.d.ts +1 -2
- package/types/tailwind/plugin-options.d.ts.map +1 -1
- package/types/types/animation-prop.d.ts +6 -2
- package/types/types/animation-prop.d.ts.map +1 -1
- package/types/views/home/types.d.ts +3 -0
- package/types/views/home/types.d.ts.map +1 -1
- package/types/wiring/events.types.d.ts +3 -1
- package/types/wiring/events.types.d.ts.map +1 -1
- package/types/x-modules/empathize/components/empathize.vue.d.ts +5 -5
- package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts +1 -1
- package/types/x-modules/facets/components/facets/facets.vue.d.ts +3 -3
- package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +5 -2
- package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
- package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts +3 -0
- package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
- package/types/x-modules/facets/components/lists/filters-list.vue.d.ts +3 -3
- package/types/x-modules/facets/components/lists/selected-filters-list.vue.d.ts +3 -3
- package/types/x-modules/history-queries/components/my-history.vue.d.ts +3 -3
- package/types/x-modules/identifier-results/components/identifier-results.vue.d.ts +3 -3
- package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts +3 -3
- package/types/x-modules/next-queries/index.d.ts +1 -0
- package/types/x-modules/next-queries/index.d.ts.map +1 -1
- package/types/x-modules/queries-preview/components/query-preview-list.vue.d.ts +3 -3
- package/types/x-modules/queries-preview/components/query-preview-list.vue.d.ts.map +1 -1
- package/types/x-modules/queries-preview/components/query-preview.vue.d.ts.map +1 -1
- package/types/x-modules/queries-preview/store/actions/fetch-and-save-query-preview.action.d.ts.map +1 -1
- package/types/x-modules/queries-preview/store/module.d.ts.map +1 -1
- package/types/x-modules/queries-preview/utils/get-hash-from-query-preview.d.ts +4 -2
- package/types/x-modules/queries-preview/utils/get-hash-from-query-preview.d.ts.map +1 -1
- package/types/x-modules/recommendations/components/recommendations.vue.d.ts +3 -3
- package/types/x-modules/related-prompts/components/index.d.ts +3 -0
- package/types/x-modules/related-prompts/components/index.d.ts.map +1 -0
- package/types/x-modules/related-prompts/components/related-prompt.vue.d.ts +37 -0
- package/types/x-modules/related-prompts/components/related-prompt.vue.d.ts.map +1 -0
- package/types/x-modules/related-prompts/components/related-prompts-list.vue.d.ts +106 -0
- package/types/x-modules/related-prompts/components/related-prompts-list.vue.d.ts.map +1 -0
- package/types/x-modules/related-prompts/events.types.d.ts +26 -0
- package/types/x-modules/related-prompts/events.types.d.ts.map +1 -0
- package/types/x-modules/related-prompts/index.d.ts +6 -0
- package/types/x-modules/related-prompts/index.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.d.ts +17 -0
- package/types/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/actions/fetch-related-prompts.action.d.ts +13 -0
- package/types/x-modules/related-prompts/store/actions/fetch-related-prompts.action.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/emitters.d.ts +9 -0
- package/types/x-modules/related-prompts/store/emitters.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/getters/request.getter.d.ts +13 -0
- package/types/x-modules/related-prompts/store/getters/request.getter.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/index.d.ts +7 -0
- package/types/x-modules/related-prompts/store/index.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/module.d.ts +8 -0
- package/types/x-modules/related-prompts/store/module.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/types.d.ts +104 -0
- package/types/x-modules/related-prompts/store/types.d.ts.map +1 -0
- package/types/x-modules/related-prompts/types.d.ts +10 -0
- package/types/x-modules/related-prompts/types.d.ts.map +1 -0
- package/types/x-modules/related-prompts/wiring.d.ts +31 -0
- package/types/x-modules/related-prompts/wiring.d.ts.map +1 -0
- package/types/x-modules/related-prompts/x-module.d.ts +16 -0
- package/types/x-modules/related-prompts/x-module.d.ts.map +1 -0
- package/types/x-modules/related-tags/components/related-tags.vue.d.ts +3 -3
- package/types/x-modules/scroll/components/scroll-to-top.vue.d.ts +5 -5
- package/types/x-modules/search/components/banners-list.vue.d.ts +3 -3
- package/types/x-modules/search/components/partial-results-list.vue.d.ts +3 -3
- package/types/x-modules/search/components/promoteds-list.vue.d.ts +3 -3
- package/types/x-modules/search/components/results-list.vue.d.ts +3 -3
- package/types/x-modules/search/components/sort-dropdown.vue.d.ts +1 -1
- package/types/x-modules/search/store/actions/save-search-response.action.d.ts.map +1 -1
- package/types/x-modules/search/store/module.d.ts +2 -0
- package/types/x-modules/search/store/module.d.ts.map +1 -1
- package/types/x-modules/search/store/types.d.ts +9 -1
- package/types/x-modules/search/store/types.d.ts.map +1 -1
- package/types/x-modules/search-box/components/search-input-placeholder.vue.d.ts +3 -3
- package/types/x-modules/tagging/components/tagging.vue.d.ts +17 -4
- package/types/x-modules/tagging/components/tagging.vue.d.ts.map +1 -1
- package/types/x-modules/x-modules.types.d.ts +2 -0
- package/types/x-modules/x-modules.types.d.ts.map +1 -1
- package/js/utils/options-api.js +0 -4
- package/js/utils/options-api.js.map +0 -1
- package/types/utils/options-api.d.ts +0 -3
- package/types/utils/options-api.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { Facet } from '@empathyco/x-types';\n import { Dictionary, map, objectFilter } from '@empathyco/x-utils';\n import { computed, ComputedRef, defineComponent, PropType } from 'vue';\n import { useGetter } from '../../../../composables/use-getter';\n import { animationProp } from '../../../../utils/options-api';\n import { toKebabCase } from '../../../../utils/string';\n import { useFacets } from '../../composables/use-facets';\n import { facetsXModule } from '../../x-module';\n\n /**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\n interface RenderFacet {\n slotNameById: string;\n slotNameByModelName: string;\n facet: Facet;\n }\n\n /**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\n export default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: animationProp,\n default: 'ul'\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String\n },\n setup: function (props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props);\n\n const { facets } = useGetter('facets', ['facets']) as {\n /** Dictionary of facets in the state. */\n facets: ComputedRef<Record<Facet['id'], Facet>>;\n };\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = props.renderableFacets\n .split(',')\n .map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return filterFacetsToRender(included, excluded);\n }\n });\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet\n }));\n });\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length);\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name];\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\n import {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter\n } from '@empathyco/x-components/facets';\n\n import { BasePriceFilterLabel } from '@empathyco/x-components';\n\n export default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { Facet } from '@empathyco/x-types';\n import { Dictionary, map, objectFilter } from '@empathyco/x-utils';\n import { computed, ComputedRef, defineComponent, PropType } from 'vue';\n import { useGetter } from '../../../../composables/use-getter';\n import { toKebabCase } from '../../../../utils/string';\n import { useFacets } from '../../composables/use-facets';\n import { facetsXModule } from '../../x-module';\n import { AnimationProp } from '../../../../types';\n\n /**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\n interface RenderFacet {\n slotNameById: string;\n slotNameByModelName: string;\n facet: Facet;\n }\n\n /**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\n export default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul'\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String\n },\n setup: function (props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props);\n\n const { facets } = useGetter('facets', ['facets']) as {\n /** Dictionary of facets in the state. */\n facets: ComputedRef<Record<Facet['id'], Facet>>;\n };\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = props.renderableFacets\n .split(',')\n .map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return filterFacetsToRender(included, excluded);\n }\n });\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet\n }));\n });\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length);\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name];\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\n import {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter\n } from '@empathyco/x-components/facets';\n\n import { BasePriceFilterLabel } from '@empathyco/x-components';\n\n export default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AA4EE;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAG;AACb,SAAA;AACD;;;;;;;;;;;;;;;;;;AAkBE;AACF,QAAA,gBAAgB,EAAE,MAAK;AACxB,KAAA;AACD,IAAA,KAAK,EAAE,UAAU,KAAK,EAAE,EAAE,KAAM,EAAC,EAAA;QAC/B,MAAM,EAAE,sBAAuB,EAAA,GAAI,SAAS,CAAC,KAAK,CAAC,CAAA;AAEnD,QAAA,MAAM,EAAE,QAAS,GAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAGhD,CAAA;AAED;;;;;AAKE;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAAoB,MAAM;AACvD,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC3B,OAAO,MAAM,CAAC,KAAK,CAAA;AACnB,aAAA;AAAK,iBAAA;gBACL,MAAM,iBAAiB,IAAI,CAAA;AAC3B,gBAAA,MAAM,QAAQ,GAAa,KAAK,CAAC,gBAAe;qBAC7C,KAAK,CAAC,GAAG,CAAA;qBACT,GAAG,CAAC,OAAM,IAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;gBACjC,MAAM,QAAQ,GAAa,EAAE,CAAA;gBAC7B,MAAM,QAAQ,GAAa,EAAE,CAAA;AAC7B,gBAAA,QAAQ,CAAC,OAAO,CAAC,OAAQ,IAAG;AAC1B,oBAAA,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;AAChC,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAA;AAClD,qBAAA;AAAK,yBAAA;AACL,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACxB,qBAAA;AACF,iBAAC,CAAC,CAAA;AAEF,gBAAA,OAAO,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACjD,aAAA;AACF,SAAC,CAAC,CAAA;AAEF;;;;AAIE;AACF,QAAA,MAAM,YAAa,GAAE,QAAQ,CAA0B,MAAM;AAC3D,YAAA,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,MAAM;AACpD,gBAAA,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC;AAClC,gBAAA,mBAAmB,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjD,KAAI;AACL,aAAA,CAAC,CAAC,CAAA;AACL,SAAC,CAAC,CAAA;AAEF;;;;AAIE;QACF,MAAM,SAAQ,GAAI,QAAQ,CAAU,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAA;AAErF;;;;;;;AAOE;AACF,QAAA,SAAS,oBAAoB,CAAC,QAAkB,EAAE,QAAkB,EAAA;AAClE,YAAA,MAAM,sBAAsB,QAAQ,CAAC,MAAK,GAAI,CAAC,CAAA;YAC/C,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,QAAO,IAAK;gBAC5C,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;gBACtD,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEtD,gBAAA,OAAO,mBAAoB,GAAE,UAAS,IAAK,CAAC,UAAW,GAAE,CAAC,UAAU,CAAA;AACtE,aAAC,CAAC,CAAA;SACJ;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;SACtB;QAEA,OAAO;YACL,sBAAsB;YACtB,SAAS;YACT,YAAY;YACZ,OAAM;SACP,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selected-filters-list.vue.js","sources":["../../../../../../src/x-modules/facets/components/lists/selected-filters-list.vue"],"sourcesContent":["<template>\n <SelectedFilters\n v-slot=\"{ selectedFilters }\"\n :facetsIds=\"facetsIds\"\n :alwaysVisible=\"alwaysVisible\"\n >\n <component\n :is=\"animation\"\n class=\"x-selected-filters-list\"\n data-test=\"selected-filters-list\"\n tag=\"ul\"\n >\n <li\n v-for=\"{ slotName, selectedFilter } in mapSlot(selectedFilters)\"\n :key=\"selectedFilter.id\"\n class=\"x-selected-filters-list__item\"\n data-test=\"selected-filters-list-item\"\n >\n <!--\n @slot Custom filter rendering. Dynamic slot defined in the template with the filter\n facet id. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-if=\"hasSlot(slotName)\" :name=\"slotName\" :filter=\"selectedFilter\">\n <span class=\"x-tag\">{{ selectedFilter.label }}</span>\n </slot>\n\n <!--\n @slot Default filter rendering. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-else name=\"default\" :filter=\"selectedFilter\">\n {{ selectedFilter.label }}\n </slot>\n </li>\n </component>\n </SelectedFilters>\n</template>\n\n<script lang=\"ts\">\n import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import {
|
|
1
|
+
{"version":3,"file":"selected-filters-list.vue.js","sources":["../../../../../../src/x-modules/facets/components/lists/selected-filters-list.vue"],"sourcesContent":["<template>\n <SelectedFilters\n v-slot=\"{ selectedFilters }\"\n :facetsIds=\"facetsIds\"\n :alwaysVisible=\"alwaysVisible\"\n >\n <component\n :is=\"animation\"\n class=\"x-selected-filters-list\"\n data-test=\"selected-filters-list\"\n tag=\"ul\"\n >\n <li\n v-for=\"{ slotName, selectedFilter } in mapSlot(selectedFilters)\"\n :key=\"selectedFilter.id\"\n class=\"x-selected-filters-list__item\"\n data-test=\"selected-filters-list-item\"\n >\n <!--\n @slot Custom filter rendering. Dynamic slot defined in the template with the filter\n facet id. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-if=\"hasSlot(slotName)\" :name=\"slotName\" :filter=\"selectedFilter\">\n <span class=\"x-tag\">{{ selectedFilter.label }}</span>\n </slot>\n\n <!--\n @slot Default filter rendering. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-else name=\"default\" :filter=\"selectedFilter\">\n {{ selectedFilter.label }}\n </slot>\n </li>\n </component>\n </SelectedFilters>\n</template>\n\n<script lang=\"ts\">\n import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import { toKebabCase } from '../../../../utils/string';\n import { useFacets } from '../../composables/use-facets';\n import { facetsXModule } from '../../x-module';\n import { AnimationProp } from '../../../../types';\n import SelectedFilters from './selected-filters.vue';\n\n /**\n * Custom interface to provide a slot name to a Filter.\n *\n * @internal\n */\n interface RenderFilter {\n slotName: string;\n selectedFilter: Filter;\n }\n\n /**\n * This component renders a list of selected filters from every facet, or from the facet\n * ids passed as property. It uses the SelectedFilters component (state).\n *\n * It provides two slots: a scoped one which name is the filter facet id; and a default one.\n * Both exposes the filter and renders the filter label by default.\n *\n * The property \"alwaysVisible\" handles if the component is rendered if no filters are selected.\n *\n * @public\n */\n export default defineComponent({\n name: 'SelectedFiltersList',\n xModule: facetsXModule.name,\n components: { SelectedFilters },\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the selected filters list. */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup: function (props, { slots }) {\n const { selectedFilters } = useFacets(props);\n\n /**\n * Transforms a dictionary of Filters including the slot name.\n *\n * @param selectedFilters - A list of selected filters without slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n function mapSlot(selectedFilters: Filter[]): RenderFilter[] {\n return selectedFilters.map(filter => ({\n slotName: isFacetFilter(filter) ? toKebabCase(filter.facetId as string) : 'default',\n selectedFilter: filter\n }));\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name];\n }\n\n return {\n selectedFilters,\n mapSlot,\n hasSlot\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders a list of selected filters from every facet, or from the facets which facets\nids are passed as property. It uses the SelectedFilters component (state).\n\nIt provides two slots: a scoped one which name is the filter facet id; and a default one. Both\nexposes the filter and renders the filter label by default.\n\nThe property \"alwaysVisible\" handles if the component is rendered if no filters are selected.\n\n### Default usage\n\n```vue\n<template>\n <SelectedFiltersList />\n</template>\n\n<script>\n import { SelectedFiltersList } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFiltersList\n }\n };\n</script>\n```\n\n### Customized usage\n\n```vue\n<template>\n <SelectedFiltersList #default=\"{ filter }\">Default: {{ filter.label }}</SelectedFiltersList>\n</template>\n\n<script>\n import { SelectedFilters } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFilters\n }\n };\n</script>\n```\n\n```vue\n<template>\n <SelectedFiltersList>\n <template #default=\"{ filter }\">Default: {{ filter.label }}</template>\n <template #brand_facet=\"{ filter }\">Brand: {{ filter.label }}</template>\n <template #age_facet=\"{ filter }\">Age: {{ filter.label }}</template>\n <template #price_facet=\"{ filter }\">Price: {{ filter.label }}</template>\n </SelectedFiltersList>\n</template>\n\n<script>\n import { SelectedFilters } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFilters\n }\n };\n</script>\n```\n\n#### Always visible\n\nIf \"alwaysVisible\" is true, the component is rendered no matter if there are some filter selected.\nIf \"alwaysVisible\" is false (default), the component is rendered if there are some filter selected.\n\n```vue\n<SelectedFiltersList :alwaysVisible=\"true\" />\n```\n\nOutput:\n\n```html\n<div class=\"x-selected-filters\">\n <ul class=\"x-selected-filters-list\" data-test=\"selected-filters-list\"></ul>\n</div>\n```\n\n#### Providing an array of facet ids\n\nIn this example, the selected filters computed are the ones that match the facet ids passed as\nproperties.\n\n```vue\n<SelectedFilters :facetsIds=\"['brand_facet', 'gender_facet']\" />\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_withCtx","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","hasSlot","_toDisplayString","_createCommentVNode","_renderSlot"],"mappings":";;;;;;AAoCoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAhCf,EAAA,OAAAC,SAAA,EAA4B,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IAAA,SAAA,EAAA,IAAA,CAAA,SAAA;IAJjC,aAmCgB,EAAA,IAAA,CAAA,aAAA;AAAA,GAAA,EAAA;AA3BL,IAAA,OAAA,EAAAC,OAAA,CAAC,CAAyB,EAAA,eAAA,EAAA,KAAA;AAAA,OAAAF,SAAA,EACrB,EAAAC,WAAA;AAAA,QAAuBE,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA;AAAA,QAAA;AAAA,UACjC,KAAI,EAAA,yBAAA;AAAA,UAAA,WAAA,EAAA,uBAAA;AAVV,UAAA,GAAA,EAAA,IAAA;AAAA,SAAA;;;AAcc,aAAAH,SAAA,CAAA,IAAA,CAAA,EAAAI,kBAAA;AAAA,cAAiBC,QAAA;AAAA,cAAA,IAAA;AAAA,cAAAC,UAAA,CAAA,IAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,cAAA,EAAA,KAAA;AAClB,gBAAA,OAAAN,SAAA,EAAgC,EAAAI,kBAAA,CAAA,IAAA,EAAA;AAAA,kBACrC,GAAU,EAAA,cAAA,CAAA,EAAA;AAAA,kBAAA,KAAA,EAAA,+BAAA;AAEV,kBAAA,WAAA,EAAA,4BAAA;AAAA,iBAKYG,EAAAA;AAAAA,kBAAAA,kBAAAA,CAEL,oOAFuC,CAAA;AAAA,kBAAA,IAAA,CAvBtD,+BAuBiE,IAAc,CAAA,MAAA,EAAA,QAAA,EAAA;AAAA,oBAEhE,GAAA,EAAA,CAAA;AAAA,oBADL,MAAA,EAAA,cAAA;AAAA,mBAAA,EAAA,MAAA;;AAOF,sBAAA,MAAA;AAAA,sBAAA,UAAA;AAAA,sBAEOC,eAjCf,CAAA,cAAA,CAAA,KAAA,CAAA;AAAA,sBAAA,CAAA;AAAA;AAAA,qBAAA;AAAA,mBAAA,CAAA,IAAAR,SAAA,EAiCe,EAAAI,kBAAA;AAAA,oBAAAC,QAAA;AAAA,oBAF4B,EAAE,GAAA,EAAA,CAAA,EAAA;AAAA,oBAAA;AAAA,sBAAAI,kBAAA,CA/B7C,2JAgCiC,CAAA;AAAA,sBAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,MAAA,EAAA,cAAA,EAAA,EAAA,MAAA;;;;;;;;;;;;AAhCjC,eAAA,CAAA;AAAA,cAAA,GAAA;AAAA;AAAA,aAAA;AAAA,WAAA,CAAA;;;AAAA,SAAA;AAAA,QAAA,IAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isFacetFilter } from '@empathyco/x-types';
|
|
2
2
|
import { defineComponent } from 'vue';
|
|
3
|
-
import { animationProp } from '../../../../utils/options-api.js';
|
|
4
3
|
import { toKebabCase } from '../../../../utils/string.js';
|
|
5
4
|
import { useFacets } from '../../composables/use-facets.js';
|
|
6
5
|
import { facetsXModule } from '../../x-module.js';
|
|
6
|
+
import { AnimationProp } from '../../../../types/animation-prop.js';
|
|
7
7
|
import _sfc_main$1 from './selected-filters.vue.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -28,7 +28,7 @@ var _sfc_main = defineComponent({
|
|
|
28
28
|
alwaysVisible: Boolean,
|
|
29
29
|
/** Animation component that will be used to animate the selected filters list. */
|
|
30
30
|
animation: {
|
|
31
|
-
type:
|
|
31
|
+
type: AnimationProp,
|
|
32
32
|
default: 'ul'
|
|
33
33
|
}
|
|
34
34
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selected-filters-list.vue2.js","sources":["../../../../../../src/x-modules/facets/components/lists/selected-filters-list.vue"],"sourcesContent":["<template>\n <SelectedFilters\n v-slot=\"{ selectedFilters }\"\n :facetsIds=\"facetsIds\"\n :alwaysVisible=\"alwaysVisible\"\n >\n <component\n :is=\"animation\"\n class=\"x-selected-filters-list\"\n data-test=\"selected-filters-list\"\n tag=\"ul\"\n >\n <li\n v-for=\"{ slotName, selectedFilter } in mapSlot(selectedFilters)\"\n :key=\"selectedFilter.id\"\n class=\"x-selected-filters-list__item\"\n data-test=\"selected-filters-list-item\"\n >\n <!--\n @slot Custom filter rendering. Dynamic slot defined in the template with the filter\n facet id. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-if=\"hasSlot(slotName)\" :name=\"slotName\" :filter=\"selectedFilter\">\n <span class=\"x-tag\">{{ selectedFilter.label }}</span>\n </slot>\n\n <!--\n @slot Default filter rendering. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-else name=\"default\" :filter=\"selectedFilter\">\n {{ selectedFilter.label }}\n </slot>\n </li>\n </component>\n </SelectedFilters>\n</template>\n\n<script lang=\"ts\">\n import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import {
|
|
1
|
+
{"version":3,"file":"selected-filters-list.vue2.js","sources":["../../../../../../src/x-modules/facets/components/lists/selected-filters-list.vue"],"sourcesContent":["<template>\n <SelectedFilters\n v-slot=\"{ selectedFilters }\"\n :facetsIds=\"facetsIds\"\n :alwaysVisible=\"alwaysVisible\"\n >\n <component\n :is=\"animation\"\n class=\"x-selected-filters-list\"\n data-test=\"selected-filters-list\"\n tag=\"ul\"\n >\n <li\n v-for=\"{ slotName, selectedFilter } in mapSlot(selectedFilters)\"\n :key=\"selectedFilter.id\"\n class=\"x-selected-filters-list__item\"\n data-test=\"selected-filters-list-item\"\n >\n <!--\n @slot Custom filter rendering. Dynamic slot defined in the template with the filter\n facet id. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-if=\"hasSlot(slotName)\" :name=\"slotName\" :filter=\"selectedFilter\">\n <span class=\"x-tag\">{{ selectedFilter.label }}</span>\n </slot>\n\n <!--\n @slot Default filter rendering. It renders the filter label by default.\n @binding {Filter} filter - Filter to render.\n -->\n <slot v-else name=\"default\" :filter=\"selectedFilter\">\n {{ selectedFilter.label }}\n </slot>\n </li>\n </component>\n </SelectedFilters>\n</template>\n\n<script lang=\"ts\">\n import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\n import { defineComponent, PropType } from 'vue';\n import { toKebabCase } from '../../../../utils/string';\n import { useFacets } from '../../composables/use-facets';\n import { facetsXModule } from '../../x-module';\n import { AnimationProp } from '../../../../types';\n import SelectedFilters from './selected-filters.vue';\n\n /**\n * Custom interface to provide a slot name to a Filter.\n *\n * @internal\n */\n interface RenderFilter {\n slotName: string;\n selectedFilter: Filter;\n }\n\n /**\n * This component renders a list of selected filters from every facet, or from the facet\n * ids passed as property. It uses the SelectedFilters component (state).\n *\n * It provides two slots: a scoped one which name is the filter facet id; and a default one.\n * Both exposes the filter and renders the filter label by default.\n *\n * The property \"alwaysVisible\" handles if the component is rendered if no filters are selected.\n *\n * @public\n */\n export default defineComponent({\n name: 'SelectedFiltersList',\n xModule: facetsXModule.name,\n components: { SelectedFilters },\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the selected filters list. */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup: function (props, { slots }) {\n const { selectedFilters } = useFacets(props);\n\n /**\n * Transforms a dictionary of Filters including the slot name.\n *\n * @param selectedFilters - A list of selected filters without slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n function mapSlot(selectedFilters: Filter[]): RenderFilter[] {\n return selectedFilters.map(filter => ({\n slotName: isFacetFilter(filter) ? toKebabCase(filter.facetId as string) : 'default',\n selectedFilter: filter\n }));\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name];\n }\n\n return {\n selectedFilters,\n mapSlot,\n hasSlot\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders a list of selected filters from every facet, or from the facets which facets\nids are passed as property. It uses the SelectedFilters component (state).\n\nIt provides two slots: a scoped one which name is the filter facet id; and a default one. Both\nexposes the filter and renders the filter label by default.\n\nThe property \"alwaysVisible\" handles if the component is rendered if no filters are selected.\n\n### Default usage\n\n```vue\n<template>\n <SelectedFiltersList />\n</template>\n\n<script>\n import { SelectedFiltersList } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFiltersList\n }\n };\n</script>\n```\n\n### Customized usage\n\n```vue\n<template>\n <SelectedFiltersList #default=\"{ filter }\">Default: {{ filter.label }}</SelectedFiltersList>\n</template>\n\n<script>\n import { SelectedFilters } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFilters\n }\n };\n</script>\n```\n\n```vue\n<template>\n <SelectedFiltersList>\n <template #default=\"{ filter }\">Default: {{ filter.label }}</template>\n <template #brand_facet=\"{ filter }\">Brand: {{ filter.label }}</template>\n <template #age_facet=\"{ filter }\">Age: {{ filter.label }}</template>\n <template #price_facet=\"{ filter }\">Price: {{ filter.label }}</template>\n </SelectedFiltersList>\n</template>\n\n<script>\n import { SelectedFilters } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n SelectedFilters\n }\n };\n</script>\n```\n\n#### Always visible\n\nIf \"alwaysVisible\" is true, the component is rendered no matter if there are some filter selected.\nIf \"alwaysVisible\" is false (default), the component is rendered if there are some filter selected.\n\n```vue\n<SelectedFiltersList :alwaysVisible=\"true\" />\n```\n\nOutput:\n\n```html\n<div class=\"x-selected-filters\">\n <ul class=\"x-selected-filters-list\" data-test=\"selected-filters-list\"></ul>\n</div>\n```\n\n#### Providing an array of facet ids\n\nIn this example, the selected filters computed are the ones that match the facet ids passed as\nproperties.\n\n```vue\n<SelectedFilters :facetsIds=\"['brand_facet', 'gender_facet']\" />\n```\n</docs>\n"],"names":["SelectedFilters"],"mappings":";;;;;;;;AA0DE;;;;;;;;;;AAUE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE,aAAa,CAAC,IAAI;IAC3B,UAAU,EAAE,mBAAEA,WAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAG;AACd,SAAA;AACD,KAAA;AACD,IAAA,KAAK,EAAE,UAAU,KAAK,EAAE,EAAE,KAAM,EAAC,EAAA;QAC/B,MAAM,EAAE,eAAc,KAAM,SAAS,CAAC,KAAK,CAAC,CAAA;AAE5C;;;;;;AAME;QACF,SAAS,OAAO,CAAC,eAAyB,EAAA;YACxC,OAAO,eAAe,CAAC,GAAG,CAAC,MAAO,KAAI;AACpC,gBAAA,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAA,GAAI,WAAW,CAAC,MAAM,CAAC,OAAiB,CAAE,GAAE,SAAS;AACnF,gBAAA,cAAc,EAAE,MAAK;AACtB,aAAA,CAAC,CAAC,CAAA;SACL;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;SACtB;QAEA,OAAO;YACL,eAAe;YACf,OAAO;YACP,OAAM;SACP,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
|
|
@@ -82,6 +82,8 @@ import '../../../components/base-grid.vue3.js';
|
|
|
82
82
|
import '../../../components/base-keyboard-navigation.vue2.js';
|
|
83
83
|
import '../../../components/base-rating.vue2.js';
|
|
84
84
|
import '../../../components/base-rating.vue3.js';
|
|
85
|
+
import '../../../components/base-slider.vue2.js';
|
|
86
|
+
import '../../../components/base-slider.vue3.js';
|
|
85
87
|
import '../../../components/base-switch.vue2.js';
|
|
86
88
|
import '../../../components/base-switch.vue3.js';
|
|
87
89
|
import '../../../components/base-variable-column-grid.vue2.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview-button.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-button.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-query-preview-button x-button\"\n data-test=\"query-preview-button\"\n >\n <!-- @slot Button content with a text, an icon or both -->\n <slot :queryPreviewInfo=\"fullQueryPreviewInfo\">\n {{ queryPreviewInfo.query }}\n </slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { QueryPreviewInfo } from '../store/types';\n import { XEventsTypes } from '../../../wiring/events.types';\n import { BaseEventButton } from '../../../components';\n import { queriesPreviewXModule } from '../x-module';\n import { useState } from '../../../composables/use-state';\n import { WireMetadata } from '../../../wiring/index';\n\n /**\n * Component containing an event button that emits\n * {@link QueriesPreviewXEvents.UserAcceptedAQueryPreview} when clicked with\n * the full query preview info as payload.\n *\n * It has a default slot to customize its contents.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewButton',\n xModule: queriesPreviewXModule.name,\n components: { BaseEventButton },\n props: {\n /**\n * The information about the request of the query preview.\n *\n * @public\n */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true\n },\n /**\n * The metadata property for the request on each query preview.\n *\n * @public\n */\n metadata: {\n type: Object as PropType<Omit<WireMetadata, 'moduleName'>>\n }\n },\n setup(props) {\n /**\n * We use the module extra params to combine them with the query preview's extra params.\n */\n const { params } = useState('queriesPreview', ['params']);\n\n /**\n * The provided query preview with the base extra params from the module merged in.\n *\n * @returns The query preview info with the base extra params merged in.\n * @public\n */\n const fullQueryPreviewInfo = computed(\n (): QueryPreviewInfo => ({\n ...props.queryPreviewInfo,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams\n },\n filters: props.queryPreviewInfo.filters\n })\n );\n\n /**\n * List of events to emit by the BaseEventButton.\n *\n * @returns An object with the event and payload.\n *\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserAcceptedAQueryPreview: fullQueryPreviewInfo.value })\n );\n\n return {\n fullQueryPreviewInfo,\n events\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThe component content has the query preview query as default\n\n```vue\n<template>\n <div>\n <QueryPreviewButton queryPreviewInfo=\"queryPreviewInfo\" />\n </div>\n</template>\n\n<script>\n import { QueryPreviewButton } from '@empathyco/x-components/queries-preview';\n\n export default {\n components: {\n QueryPreviewButton\n },\n data: function () {\n return {\n queryPreviewInfo: {\n query: 'shoes'\n }\n };\n }\n };\n</script>\n```\n\n### Customizing slots\n\nThe content of the button is customizable via its default slot\n\n```vue\n<template>\n <div>\n <QueryPreviewButton queryPreviewInfo=\"queryPreviewInfo\">\n {{ `Search for: ${queryPreviewInfo.query}` }}\n </QueryPreviewButton>\n </div>\n</template>\n\n<script>\n import { QueryPreviewButton } from '@empathyco/x-components/queries-preview';\n\n export default {\n components: {\n QueryPreviewButton\n },\n data: function () {\n return {\n queryPreviewInfo: {\n query: 'shoes'\n }\n };\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserAcceptedAQueryPreview`: the event is emitted after the user clicks the button. The event\n payload is the `QueryPreviewInfo` of the query.\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-preview-button.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-button.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n :metadata=\"metadata\"\n class=\"x-query-preview-button x-button\"\n data-test=\"query-preview-button\"\n >\n <!-- @slot Button content with a text, an icon or both -->\n <slot :queryPreviewInfo=\"fullQueryPreviewInfo\">\n {{ queryPreviewInfo.query }}\n </slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { QueryPreviewInfo } from '../store/types';\n import { XEventsTypes } from '../../../wiring/events.types';\n import { BaseEventButton } from '../../../components';\n import { queriesPreviewXModule } from '../x-module';\n import { useState } from '../../../composables/use-state';\n import { WireMetadata } from '../../../wiring/index';\n\n /**\n * Component containing an event button that emits\n * {@link QueriesPreviewXEvents.UserAcceptedAQueryPreview} when clicked with\n * the full query preview info as payload.\n *\n * It has a default slot to customize its contents.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewButton',\n xModule: queriesPreviewXModule.name,\n components: { BaseEventButton },\n props: {\n /**\n * The information about the request of the query preview.\n *\n * @public\n */\n queryPreviewInfo: {\n type: Object as PropType<QueryPreviewInfo>,\n required: true\n },\n /**\n * The metadata property for the request on each query preview.\n *\n * @public\n */\n metadata: {\n type: Object as PropType<Omit<WireMetadata, 'moduleName'>>\n }\n },\n setup(props) {\n /**\n * We use the module extra params to combine them with the query preview's extra params.\n */\n const { params } = useState('queriesPreview', ['params']);\n\n /**\n * The provided query preview with the base extra params from the module merged in.\n *\n * @returns The query preview info with the base extra params merged in.\n * @public\n */\n const fullQueryPreviewInfo = computed(\n (): QueryPreviewInfo => ({\n ...props.queryPreviewInfo,\n extraParams: {\n ...params.value,\n ...props.queryPreviewInfo.extraParams\n },\n filters: props.queryPreviewInfo.filters\n })\n );\n\n /**\n * List of events to emit by the BaseEventButton.\n *\n * @returns An object with the event and payload.\n *\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserAcceptedAQueryPreview: fullQueryPreviewInfo.value })\n );\n\n return {\n fullQueryPreviewInfo,\n events\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThe component content has the query preview query as default\n\n```vue\n<template>\n <div>\n <QueryPreviewButton queryPreviewInfo=\"queryPreviewInfo\" />\n </div>\n</template>\n\n<script>\n import { QueryPreviewButton } from '@empathyco/x-components/queries-preview';\n\n export default {\n components: {\n QueryPreviewButton\n },\n data: function () {\n return {\n queryPreviewInfo: {\n query: 'shoes'\n }\n };\n }\n };\n</script>\n```\n\n### Customizing slots\n\nThe content of the button is customizable via its default slot\n\n```vue\n<template>\n <div>\n <QueryPreviewButton queryPreviewInfo=\"queryPreviewInfo\">\n {{ `Search for: ${queryPreviewInfo.query}` }}\n </QueryPreviewButton>\n </div>\n</template>\n\n<script>\n import { QueryPreviewButton } from '@empathyco/x-components/queries-preview';\n\n export default {\n components: {\n QueryPreviewButton\n },\n data: function () {\n return {\n queryPreviewInfo: {\n query: 'shoes'\n }\n };\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserAcceptedAQueryPreview`: the event is emitted after the user clicks the button. The event\n payload is the `QueryPreviewInfo` of the query.\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBE;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,qBAAqB,CAAC,IAAI;IACnC,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAAoC;AAC1C,YAAA,QAAQ,EAAE,IAAG;AACd,SAAA;AACD;;;;AAIE;AACF,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,MAAmD;AAC3D,SAAA;AACD,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;AAEE;AACF,QAAA,MAAM,EAAE,MAAK,KAAM,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEzD;;;;;AAKE;AACF,QAAA,MAAM,oBAAqB,GAAE,QAAQ,CACnC,OAAyB;YACvB,GAAG,KAAK,CAAC,gBAAgB;AACzB,YAAA,WAAW,EAAE;gBACX,GAAG,MAAM,CAAC,KAAK;AACf,gBAAA,GAAG,KAAK,CAAC,gBAAgB,CAAC,WAAU;AACrC,aAAA;AACD,YAAA,OAAO,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAM;AACvC,SAAA,CAAA,CACF,CAAA;AAED;;;;;;AAME;AACF,QAAA,MAAM,MAAO,GAAE,QAAQ,CACrB,OAA8B,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,OAAO,CAAA,CACxF,CAAA;QAED,OAAO;YACL,oBAAoB;YACpB,MAAK;SACN,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview-list.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n :debounceTimeMs=\"debounceTimeMs\"\n :maxItemsToRender=\"maxItemsToRender\"\n :persistInCache=\"persistInCache\"\n :queryFeature=\"queryFeature\"\n :queryPreviewInfo=\"queryPreview\"\n >\n <template v-for=\"(_, slotName) in $slots\" v-slot:[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType, ref, watch } from 'vue';\n import { RequestStatus } from '../../../store';\n import { queriesPreviewXModule } from '../x-module';\n import { QueryPreviewInfo } from '../store/types';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { AnimationProp, QueryFeature } from '../../../types';\n import QueryPreview from './query-preview.vue';\n\n interface QueryPreviewStatusRecord {\n [query: string]: RequestStatus;\n }\n\n /**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\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 all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup(props) {\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n let queriesStatus = ref<QueryPreviewStatusRecord>({});\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item => getHashFromQueryPreviewInfo(item))\n );\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item);\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n );\n });\n });\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value));\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading';\n }\n };\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key];\n }\n }\n loadNext();\n }\n },\n { immediate: true, deep: true }\n );\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success';\n loadNext();\n };\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error';\n loadNext();\n };\n\n return {\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemo',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewListDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreviewList,\n SlidingPanel\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemoOverridingResultSlot',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","animation","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","flagAsFailed","persistInCache","queryFeature","$slots","_withCtx"],"mappings":";;;;;AACE,EAAA,MAAA,uBAAA,GAAAA,gBAAA,CADF,cACkBC,CAAAA,CAAAA;SAA4CC,SAAI,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAA,KAAA,EAAA,sBAAA;AADlE,IAAA,GAAA,EAAA,IAAA;AAAA,GAAA,EAAA;;iBAIY,IAAK,CAAA,EAAAC,kBAAA;AAAA,QAAAC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,qBAAA,EAAA,CAAA,YAAA,EAAA,KAAA,KAAA;AACX,UAAA,OAAAL,SAAA,EAA8B,EAAAG,kBAAA,CAAA,IAAA,EAAA;AAAA,YAAA,GAAA,EAAA,KAAA;YAE9B,WAYe,EAAA,oBAAA;AAAA,WAAA,EAAA;wBAVLG,uBAAY,EAAA;AAAA,cACnB,MAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cACA,OAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cACA,cAAgBC,EAAAA,IAAAA,CAAAA,cAAAA;AAAAA,cAChB,gBAAcC,EAAAA,IAAAA,CAAAA,gBAAAA;AAAAA,cACd,gBAAgB,IAAE,CAAA,cAAA;AAAA,cAd3B,YAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cAgB0CC,gBAAAA,EAAAA,YAAAA;AAAAA,aAAAA,EAAAA,WAAAA,CAAAA;;;;yBAAe,IAAU,CAAA,MAAA,EAAA,CAAA,CAAA,EAAA,QAAA,KAAA;AAhBnE,gBAAA,OAAA;AAAA,kBAiBU,IAAA,EAAA,QAAA;AAAA,kBAAA,EAAA,EAAAC,OAAA,CAAA,CAAA,KAAA,KAAA;;;;;;;AAjBV,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"query-preview-list.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n :debounceTimeMs=\"debounceTimeMs\"\n :maxItemsToRender=\"maxItemsToRender\"\n :persistInCache=\"persistInCache\"\n :queryFeature=\"queryFeature\"\n :queryPreviewInfo=\"queryPreview\"\n >\n <template v-for=\"(_, slotName) in $slots\" v-slot:[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType, ref, watch } from 'vue';\n import { RequestStatus } from '../../../store';\n import { queriesPreviewXModule } from '../x-module';\n import { QueryPreviewInfo } from '../store/types';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { AnimationProp, QueryFeature } from '../../../types';\n import { useState } from '../../../composables/index';\n import QueryPreview from './query-preview.vue';\n\n interface QueryPreviewStatusRecord {\n [query: string]: RequestStatus;\n }\n\n /**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\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 all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup(props) {\n const { params } = useState('queriesPreview', ['params']);\n\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n let queriesStatus = ref<QueryPreviewStatusRecord>({});\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item =>\n getHashFromQueryPreviewInfo(item, params.value.lang as string)\n )\n );\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item, params.value.lang as string);\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n );\n });\n });\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value));\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading';\n }\n };\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key];\n }\n }\n loadNext();\n }\n },\n { immediate: true, deep: true }\n );\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success';\n loadNext();\n };\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error';\n loadNext();\n };\n\n return {\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemo',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewListDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreviewList,\n SlidingPanel\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemoOverridingResultSlot',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","animation","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","flagAsFailed","persistInCache","queryFeature","$slots","_withCtx"],"mappings":";;;;;AACE,EAAA,MAAA,uBAAA,GAAAA,gBAAA,CADF,cACkBC,CAAAA,CAAAA;SAA4CC,SAAI,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAA,KAAA,EAAA,sBAAA;AADlE,IAAA,GAAA,EAAA,IAAA;AAAA,GAAA,EAAA;;iBAIY,IAAK,CAAA,EAAAC,kBAAA;AAAA,QAAAC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,qBAAA,EAAA,CAAA,YAAA,EAAA,KAAA,KAAA;AACX,UAAA,OAAAL,SAAA,EAA8B,EAAAG,kBAAA,CAAA,IAAA,EAAA;AAAA,YAAA,GAAA,EAAA,KAAA;YAE9B,WAYe,EAAA,oBAAA;AAAA,WAAA,EAAA;wBAVLG,uBAAY,EAAA;AAAA,cACnB,MAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cACA,OAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cACA,cAAgBC,EAAAA,IAAAA,CAAAA,cAAAA;AAAAA,cAChB,gBAAcC,EAAAA,IAAAA,CAAAA,gBAAAA;AAAAA,cACd,gBAAgB,IAAE,CAAA,cAAA;AAAA,cAd3B,YAAA,EAAA,IAAA,CAAA,YAAA;AAAA,cAgB0CC,gBAAAA,EAAAA,YAAAA;AAAAA,aAAAA,EAAAA,WAAAA,CAAAA;;;;yBAAe,IAAU,CAAA,MAAA,EAAA,CAAA,CAAA,EAAA,QAAA,KAAA;AAhBnE,gBAAA,OAAA;AAAA,kBAiBU,IAAA,EAAA,QAAA;AAAA,kBAAA,EAAA,EAAAC,OAAA,CAAA,CAAA,KAAA,KAAA;;;;;;;AAjBV,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -2,6 +2,18 @@ import { defineComponent, ref, computed, watch } from 'vue';
|
|
|
2
2
|
import { queriesPreviewXModule } from '../x-module.js';
|
|
3
3
|
import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview.js';
|
|
4
4
|
import { AnimationProp } from '../../../types/animation-prop.js';
|
|
5
|
+
import '../../../composables/create-use-device.js';
|
|
6
|
+
import '@vue/devtools-api';
|
|
7
|
+
import '../../../plugins/devtools/timeline.devtools.js';
|
|
8
|
+
import '@empathyco/x-utils';
|
|
9
|
+
import 'rxjs/operators';
|
|
10
|
+
import 'rxjs';
|
|
11
|
+
import '../../../plugins/devtools/colors.utils.js';
|
|
12
|
+
import '../../../plugins/x-bus.js';
|
|
13
|
+
import '../../../plugins/x-plugin.js';
|
|
14
|
+
import 'vuex';
|
|
15
|
+
import '@vueuse/core';
|
|
16
|
+
import { useState } from '../../../composables/use-state.js';
|
|
5
17
|
import QueryPreview from './query-preview.vue.js';
|
|
6
18
|
|
|
7
19
|
/**
|
|
@@ -69,6 +81,7 @@ var _sfc_main = defineComponent({
|
|
|
69
81
|
}
|
|
70
82
|
},
|
|
71
83
|
setup(props) {
|
|
84
|
+
const { params } = useState('queriesPreview', ['params']);
|
|
72
85
|
/**
|
|
73
86
|
* Contains the status of the preview requests, indexed by query.
|
|
74
87
|
*/
|
|
@@ -79,7 +92,7 @@ var _sfc_main = defineComponent({
|
|
|
79
92
|
* @returns The list of queries in the queriesPreviewInfo list.
|
|
80
93
|
* @internal
|
|
81
94
|
*/
|
|
82
|
-
const queries = computed(() => props.queriesPreviewInfo.map(item => getHashFromQueryPreviewInfo(item)));
|
|
95
|
+
const queries = computed(() => props.queriesPreviewInfo.map(item => getHashFromQueryPreviewInfo(item, params.value.lang)));
|
|
83
96
|
/**
|
|
84
97
|
* Gets all the queries to render, that are those that don't have an `error` status.
|
|
85
98
|
*
|
|
@@ -88,7 +101,7 @@ var _sfc_main = defineComponent({
|
|
|
88
101
|
*/
|
|
89
102
|
const renderedQueryPreviews = computed(() => {
|
|
90
103
|
return props.queriesPreviewInfo.filter(item => {
|
|
91
|
-
const queryPreviewHash = getHashFromQueryPreviewInfo(item);
|
|
104
|
+
const queryPreviewHash = getHashFromQueryPreviewInfo(item, params.value.lang);
|
|
92
105
|
return (queriesStatus.value[queryPreviewHash] === 'success' ||
|
|
93
106
|
queriesStatus.value[queryPreviewHash] === 'loading');
|
|
94
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview-list.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n :debounceTimeMs=\"debounceTimeMs\"\n :maxItemsToRender=\"maxItemsToRender\"\n :persistInCache=\"persistInCache\"\n :queryFeature=\"queryFeature\"\n :queryPreviewInfo=\"queryPreview\"\n >\n <template v-for=\"(_, slotName) in $slots\" v-slot:[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType, ref, watch } from 'vue';\n import { RequestStatus } from '../../../store';\n import { queriesPreviewXModule } from '../x-module';\n import { QueryPreviewInfo } from '../store/types';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { AnimationProp, QueryFeature } from '../../../types';\n import QueryPreview from './query-preview.vue';\n\n interface QueryPreviewStatusRecord {\n [query: string]: RequestStatus;\n }\n\n /**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\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 all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup(props) {\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n let queriesStatus = ref<QueryPreviewStatusRecord>({});\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item => getHashFromQueryPreviewInfo(item))\n );\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item);\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n );\n });\n });\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value));\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading';\n }\n };\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key];\n }\n }\n loadNext();\n }\n },\n { immediate: true, deep: true }\n );\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success';\n loadNext();\n };\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error';\n loadNext();\n };\n\n return {\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemo',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewListDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreviewList,\n SlidingPanel\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemoOverridingResultSlot',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"query-preview-list.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n :debounceTimeMs=\"debounceTimeMs\"\n :maxItemsToRender=\"maxItemsToRender\"\n :persistInCache=\"persistInCache\"\n :queryFeature=\"queryFeature\"\n :queryPreviewInfo=\"queryPreview\"\n >\n <template v-for=\"(_, slotName) in $slots\" v-slot:[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType, ref, watch } from 'vue';\n import { RequestStatus } from '../../../store';\n import { queriesPreviewXModule } from '../x-module';\n import { QueryPreviewInfo } from '../store/types';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { AnimationProp, QueryFeature } from '../../../types';\n import { useState } from '../../../composables/index';\n import QueryPreview from './query-preview.vue';\n\n interface QueryPreviewStatusRecord {\n [query: string]: RequestStatus;\n }\n\n /**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\n export default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\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 all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n }\n },\n setup(props) {\n const { params } = useState('queriesPreview', ['params']);\n\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n let queriesStatus = ref<QueryPreviewStatusRecord>({});\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item =>\n getHashFromQueryPreviewInfo(item, params.value.lang as string)\n )\n );\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item, params.value.lang as string);\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n );\n });\n });\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value));\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading';\n }\n };\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key];\n }\n }\n loadNext();\n }\n },\n { immediate: true, deep: true }\n );\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success';\n loadNext();\n };\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error';\n loadNext();\n };\n\n return {\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemo',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewListDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreviewList,\n SlidingPanel\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script>\n import { QueryPreviewList } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewListDemoOverridingResultSlot',\n components: {\n QueryPreviewList\n },\n data() {\n return {\n queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\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</template>\n\n<script lang=\"ts\">\n import {\n computed,\n ComputedRef,\n defineComponent,\n inject,\n onBeforeUnmount,\n PropType,\n provide,\n Ref,\n watch\n } from 'vue';\n import { SearchRequest, Filter } from '@empathyco/x-types';\n import { deepEqual, Dictionary } from '@empathyco/x-utils';\n import { LIST_ITEMS_KEY } from '../../../components';\n import { QueryFeature, FeatureLocation } from '../../../types';\n import { QueryPreviewInfo, QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import {\n DebouncedFunction,\n debounceFunction,\n createOrigin,\n createRawFilters\n } from '../../../utils';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { useXBus, useState } from '../../../composables';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n export 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 * 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 const queriesPreviewState = useState('queriesPreview', [\n 'queriesPreview',\n 'params',\n 'config'\n ]);\n\n /**\n * The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n const previewResults: ComputedRef<Dictionary<QueryPreviewItem>> =\n queriesPreviewState.queriesPreview;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n const params: ComputedRef<Dictionary<unknown>> = queriesPreviewState.params;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const config: ComputedRef<QueriesPreviewConfig> = queriesPreviewState.config;\n\n /**\n * Query Preview key converted into a unique id.\n *\n * @returns The query hash.\n */\n const queryPreviewHash = computed(() => getHashFromQueryPreviewInfo(props.queryPreviewInfo));\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: location\n });\n const filters = props.queryPreviewInfo.filters?.reduce((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 }, {} as Record<string, Filter[]>);\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: 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)) {\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 {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value);\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 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 * If there are no results, 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 `default` slot or empty string if there are no results.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging\n };\n\n return hasResults.value ? slots.default?.(slotProps)[0] : '';\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 };\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps;\n }\n });\n</script>\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`QueryPreviewRequestUpdated`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted when the component is mounted and when the properties of the request object\n changes. The event payload is the `queryPreviewRequest` object.\n\n## Vue Events\n\nA list of vue events that the component will emit:\n\n- `load`: the event is emitted when the query results have been loaded.\n- `error`: the event is emitted if there is some error when retrieving the query results.\n\n## See it in action\n\nHere you have a basic example of how the QueryPreview is rendered. Keep in mind that this component\nis intended to be used overriding its default slot. By default it will only render the names of the\nresults.\n\n```vue live\n<template>\n <QueryPreview :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n QueryPreview\n },\n data() {\n return {\n queryPreviewInfo: { query: 'sandals' }\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreview :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>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreview,\n SlidingPanel\n },\n data() {\n return {\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreview :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemoOverridingResultSlot',\n components: {\n QueryPreview\n },\n data() {\n return {\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the query preview has been limited to render a maximum of 4 results.\n\n```vue\n<template>\n <QueryPreview\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>\n import { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components';\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n BaseGrid,\n BaseResultImage,\n BaseResultLink,\n QueryPreview\n },\n data() {\n return {\n maxItemsToRender: 4,\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createCommentVNode","_renderSlot"],"mappings":";;;;MACwB,UAAU,GAAA;AAAA,EAAgB,GAAK,EAAA,CAAA;AAAA,EAAA,WAAA,EAAA,eAAA;;;;AAArD,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAeK,QAfL,KAeK,EAAA,QAAA,EAAA;4DAdH,IAaK,EAAA,UAAA,EAAA;AAAA,KAAAA,SAAA,CAXG,IAAO,CAAE,EAAAC,kBAAA;AAAA,MAAAC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CAAA,IAAA,CAAA,mBAAA,EAAA,OAAA,EAAA,CAAA,MAAA,KAAA;AACV,QAAA,OAAAH,SAAA,EAAwB,EAAAC,kBAAA,CAAA,IAAA,EAAA;AAAA,UAC7B,GAAS,EAAA,MAAA,CAAA,EAAA;AAAA,UAAA,KAAA,EAAA,uBAAA;AAET,UAAA,WAAA,EAAA,oBAAA;AAAA,SAIA,EAAA;AAAA,UAAAG,kBAAA,CACE,+GAA4C,CAAA;AAAA,UAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,QAAA,EAAA,EAAA,MAAA,EAAA,EAAA,MAAA;;;;;;;;;;AAbpD,OAAA,CAAA;AAAA,MAAA,GAAA;AAAA;AAAA,KAAA;AAAA,GAAA,CAAA,IAAAD,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"query-preview.vue.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview.vue"],"sourcesContent":["<template>\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</template>\n\n<script lang=\"ts\">\n import {\n computed,\n ComputedRef,\n defineComponent,\n inject,\n onBeforeUnmount,\n PropType,\n provide,\n Ref,\n watch\n } from 'vue';\n import { SearchRequest, Filter } from '@empathyco/x-types';\n import { deepEqual, Dictionary } from '@empathyco/x-utils';\n import { LIST_ITEMS_KEY } from '../../../components';\n import { QueryFeature, FeatureLocation } from '../../../types';\n import { QueryPreviewInfo, QueryPreviewItem } from '../store/types';\n import { QueriesPreviewConfig } from '../config.types';\n import { queriesPreviewXModule } from '../x-module';\n import {\n DebouncedFunction,\n debounceFunction,\n createOrigin,\n createRawFilters\n } from '../../../utils';\n import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview';\n import { useXBus, useState } from '../../../composables';\n\n /**\n * Retrieves a preview of the results of a query and exposes them in the default slot,\n * along with the query preview and the totalResults of the search request.\n * By default, it renders the names of the results.\n *\n * @public\n */\n export 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 * 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 const queriesPreviewState = useState('queriesPreview', [\n 'queriesPreview',\n 'params',\n 'config'\n ]);\n\n /**\n * The results preview of the queries preview cacheable mounted.\n * It is a dictionary, indexed by the query preview query.\n */\n const previewResults: ComputedRef<Dictionary<QueryPreviewItem>> =\n queriesPreviewState.queriesPreview;\n\n /**\n * As the request is handled in this component, we need\n * the extra params that will be used in the request.\n */\n const params: ComputedRef<Dictionary<unknown>> = queriesPreviewState.params;\n\n /**\n * As the request is handled in this component, we need\n * the config that will be used in the request.\n */\n const config: ComputedRef<QueriesPreviewConfig> = queriesPreviewState.config;\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, params.value.lang as string)\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: location\n });\n const filters = props.queryPreviewInfo.filters?.reduce((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 }, {} as Record<string, Filter[]>);\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: 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)) {\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 {\n emitQueryPreviewRequestUpdated.value(queryPreviewRequest.value);\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 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 * If there are no results, 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 `default` slot or empty string if there are no results.\n */\n function renderDefaultSlot() {\n const slotProps = {\n queryPreviewInfo: props.queryPreviewInfo,\n results: queryPreviewResults.value?.results,\n totalResults: queryPreviewResults.value?.totalResults,\n displayTagging: queryPreviewResults.value?.displayTagging,\n queryTagging: queryPreviewResults.value?.queryTagging\n };\n\n return hasResults.value ? slots.default?.(slotProps)[0] : '';\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 };\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps;\n }\n });\n</script>\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`QueryPreviewRequestUpdated`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted when the component is mounted and when the properties of the request object\n changes. The event payload is the `queryPreviewRequest` object.\n\n## Vue Events\n\nA list of vue events that the component will emit:\n\n- `load`: the event is emitted when the query results have been loaded.\n- `error`: the event is emitted if there is some error when retrieving the query results.\n\n## See it in action\n\nHere you have a basic example of how the QueryPreview is rendered. Keep in mind that this component\nis intended to be used overriding its default slot. By default it will only render the names of the\nresults.\n\n```vue live\n<template>\n <QueryPreview :queryPreviewInfo=\"queryPreviewInfo\" />\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n QueryPreview\n },\n data() {\n return {\n queryPreviewInfo: { query: 'sandals' }\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreview :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>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n import { BaseResultImage, BaseResultLink, SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'QueryPreviewDemoOverridingSlot',\n components: {\n BaseResultImage,\n BaseResultLink,\n QueryPreview,\n SlidingPanel\n },\n data() {\n return {\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreview :queryPreviewInfo=\"queryPreviewInfo\" #result=\"{ result }\">\n <span>{{ result.id }}</span>\n <span>{{ result.name }}</span>\n </QueryPreview>\n</template>\n\n<script>\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemoOverridingResultSlot',\n components: {\n QueryPreview\n },\n data() {\n return {\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the query preview has been limited to render a maximum of 4 results.\n\n```vue\n<template>\n <QueryPreview\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>\n import { BaseGrid, BaseResultImage, BaseResultLink } from '@empathyco/x-components';\n import { QueryPreview } from '@empathyco/x-components/queries-preview';\n\n export default {\n name: 'QueryPreviewDemo',\n components: {\n BaseGrid,\n BaseResultImage,\n BaseResultLink,\n QueryPreview\n },\n data() {\n return {\n maxItemsToRender: 4,\n queryPreviewInfo: { query: 'flip-flops' }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createCommentVNode","_renderSlot"],"mappings":";;;;MACwB,UAAU,GAAA;AAAA,EAAgB,GAAK,EAAA,CAAA;AAAA,EAAA,WAAA,EAAA,eAAA;;;;AAArD,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAeK,QAfL,KAeK,EAAA,QAAA,EAAA;4DAdH,IAaK,EAAA,UAAA,EAAA;AAAA,KAAAA,SAAA,CAXG,IAAO,CAAE,EAAAC,kBAAA;AAAA,MAAAC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CAAA,IAAA,CAAA,mBAAA,EAAA,OAAA,EAAA,CAAA,MAAA,KAAA;AACV,QAAA,OAAAH,SAAA,EAAwB,EAAAC,kBAAA,CAAA,IAAA,EAAA;AAAA,UAC7B,GAAS,EAAA,MAAA,CAAA,EAAA;AAAA,UAAA,KAAA,EAAA,uBAAA;AAET,UAAA,WAAA,EAAA,oBAAA;AAAA,SAIA,EAAA;AAAA,UAAAG,kBAAA,CACE,+GAA4C,CAAA;AAAA,UAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,QAAA,EAAA,EAAA,MAAA,EAAA,EAAA,MAAA;;;;;;;;;;AAbpD,OAAA,CAAA;AAAA,MAAA,GAAA;AAAA;AAAA,KAAA;AAAA,GAAA,CAAA,IAAAD,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -84,6 +84,8 @@ import '../../../components/base-grid.vue3.js';
|
|
|
84
84
|
import '../../../components/base-keyboard-navigation.vue2.js';
|
|
85
85
|
import '../../../components/base-rating.vue2.js';
|
|
86
86
|
import '../../../components/base-rating.vue3.js';
|
|
87
|
+
import '../../../components/base-slider.vue2.js';
|
|
88
|
+
import '../../../components/base-slider.vue3.js';
|
|
87
89
|
import '../../../components/base-switch.vue2.js';
|
|
88
90
|
import '../../../components/base-switch.vue3.js';
|
|
89
91
|
import '../../../components/base-variable-column-grid.vue2.js';
|
|
@@ -176,7 +178,7 @@ var _sfc_main = defineComponent({
|
|
|
176
178
|
*
|
|
177
179
|
* @returns The query hash.
|
|
178
180
|
*/
|
|
179
|
-
const queryPreviewHash = computed(() => getHashFromQueryPreviewInfo(props.queryPreviewInfo));
|
|
181
|
+
const queryPreviewHash = computed(() => getHashFromQueryPreviewInfo(props.queryPreviewInfo, params.value.lang));
|
|
180
182
|
provide('queryPreviewHash', queryPreviewHash);
|
|
181
183
|
/**
|
|
182
184
|
* Gets from the state the results preview of the query preview.
|