@empathyco/x-components 6.0.0-alpha.6 → 6.0.0-alpha.60
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 +522 -0
- package/core/index.js +8 -1
- package/core/index.js.map +1 -1
- package/design-system/deprecated-full-theme.css +1647 -1648
- package/docs/API-reference/api/x-adapter-platform.md +12 -0
- package/docs/API-reference/api/x-adapter-platform.nextqueriesrelatedpromptsschema.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformadapter.relatedprompts.md +1 -1
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.md +23 -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.tagging.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompt.type.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptnextqueriestagging.md +22 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptnextqueriestagging.toolingdisplay.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptnextqueriestagging.toolingdisplayadd2cart.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedpromptnextqueriestagging.toolingdisplayclick.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.platformrelatedprompttagging.md +22 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompttagging.nextqueries.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompttagging.toolingdisplay.md +11 -0
- package/docs/API-reference/api/x-adapter-platform.platformrelatedprompttagging.toolingdisplayclick.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.baseaddtocart.md +1 -0
- 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.baseswitch.md +1 -1
- 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.configmutations.config.md +11 -0
- package/docs/API-reference/api/x-components.configmutations.md +29 -0
- package/docs/API-reference/api/x-components.configmutations.mergeconfig.md +24 -0
- package/docs/API-reference/api/x-components.configmutations.setconfig.md +24 -0
- package/docs/API-reference/api/x-components.createrelatedtagsquerygetter.md +26 -0
- package/docs/API-reference/api/x-components.createrelatedtagsquerygetteroptions.getrelatedtags.md +13 -0
- package/docs/API-reference/api/x-components.createrelatedtagsquerygetteroptions.md +20 -0
- package/docs/API-reference/api/x-components.createtrackrelatedprompttoolingdisplayclickwire.md +19 -0
- package/docs/API-reference/api/x-components.createtracktoolingadd2cartwire.md +19 -0
- package/docs/API-reference/api/x-components.createtracktoolingdisplaywire.md +19 -0
- package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice._constructor_.md → x-components.defaultexternaltaggingservice._constructor_.md} +3 -3
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.add_to_cart_id_key.md +13 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.instance.md +13 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.localstorageservice.md +11 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.md +43 -0
- package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.movetosessionstorage.md → x-components.defaultexternaltaggingservice.movetosessionstorage.md} +2 -2
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.result_clicked_id_key.md +13 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.sessionstorageservice.md +11 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storagekey.md +11 -0
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storagettlms.md +11 -0
- package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.store.md → x-components.defaultexternaltaggingservice.store.md} +2 -2
- package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storeaddtocart.md +24 -0
- package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.storeresultclicked.md → x-components.defaultexternaltaggingservice.storeresultclicked.md} +3 -3
- package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.trackaddtocart.md → x-components.defaultexternaltaggingservice.trackaddtocart.md} +3 -3
- package/docs/API-reference/api/x-components.displayclickprovider.md +66 -0
- package/docs/API-reference/api/x-components.empathize.md +6 -6
- package/docs/API-reference/api/x-components.empathizemutations.md +1 -1
- package/docs/API-reference/api/x-components.externaltaggingservice.md +23 -0
- package/docs/API-reference/api/{x-components.pdpaddtocartservice.movetosessionstorage.md → x-components.externaltaggingservice.movetosessionstorage.md} +2 -2
- package/docs/API-reference/api/x-components.externaltaggingservice.storeaddtocart.md +24 -0
- package/docs/API-reference/api/{x-components.pdpaddtocartservice.storeresultclicked.md → x-components.externaltaggingservice.storeresultclicked.md} +3 -3
- package/docs/API-reference/api/{x-components.pdpaddtocartservice.trackaddtocart.md → x-components.externaltaggingservice.trackaddtocart.md} +3 -3
- package/docs/API-reference/api/x-components.facets.md +3 -3
- package/docs/API-reference/api/x-components.facetsmutations.md +1 -1
- package/docs/API-reference/api/x-components.featurelocation.md +1 -1
- 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 +14 -0
- package/docs/API-reference/api/x-components.hierarchicalfilter.md +9 -2
- package/docs/API-reference/api/x-components.historyqueriesmutations.md +1 -1
- package/docs/API-reference/api/x-components.historyqueriesstate.md +1 -1
- package/docs/API-reference/api/x-components.identifierresults.md +3 -3
- package/docs/API-reference/api/x-components.identifierresultsmutations.md +1 -1
- package/docs/API-reference/api/x-components.identifierresultsstate.md +1 -1
- package/docs/API-reference/api/x-components.installxoptions.domelement.md +1 -1
- package/docs/API-reference/api/x-components.installxoptions.installextraplugins.md +2 -2
- package/docs/API-reference/api/x-components.installxoptions.md +1 -1
- 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 +38 -3
- package/docs/API-reference/api/x-components.mergeconfig.md +27 -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.nextqueriesmutations.md +1 -1
- package/docs/API-reference/api/x-components.nextqueriesstate.md +1 -1
- package/docs/API-reference/api/x-components.pageselector.md +80 -0
- package/docs/API-reference/api/x-components.partialresultslist.md +3 -3
- package/docs/API-reference/api/x-components.popularsearchesmutations.md +1 -1
- package/docs/API-reference/api/x-components.promotedslist.md +3 -3
- package/docs/API-reference/api/x-components.queriespreviewmutations.md +1 -1
- package/docs/API-reference/api/x-components.queryfeature.md +1 -1
- package/docs/API-reference/api/x-components.querymutations.md +20 -0
- package/docs/API-reference/api/x-components.querymutations.setquery.md +24 -0
- package/docs/API-reference/api/x-components.querypreviewlist.md +3 -3
- package/docs/API-reference/api/x-components.querystate.md +20 -0
- package/docs/API-reference/api/x-components.querystate.query.md +13 -0
- package/docs/API-reference/api/x-components.querysuggestionsmutations.md +1 -1
- package/docs/API-reference/api/x-components.querysuggestionsstate.md +1 -1
- package/docs/API-reference/api/x-components.recommendations.md +3 -3
- package/docs/API-reference/api/x-components.recommendationsmutations.md +1 -1
- package/docs/API-reference/api/x-components.relatedprompt.md +33 -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 +23 -0
- package/docs/API-reference/api/x-components.relatedpromptsactions.seturlparams.md +24 -0
- package/docs/API-reference/api/x-components.relatedpromptsgetters.md +21 -0
- package/docs/API-reference/api/x-components.relatedpromptsgetters.query.md +13 -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 +27 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.resetrelatedpromptsstate.md +17 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.resetselectedprompt.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.setrelatedpromptsrelatedtags.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 +25 -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.relatedtags.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.relatedpromptstaglist.md +72 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.md +25 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.relatedpromptsrequestupdated.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.selectedrelatedpromptchanged.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.userclickedarelatedpromptadd2cart.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsxevents.userclickedarelatedpromptresult.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.relatedtagsmutations.md +1 -1
- package/docs/API-reference/api/x-components.relatedtagsstate.md +1 -1
- package/docs/API-reference/api/x-components.resultfeature.md +1 -1
- 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.searchboxmutations.md +1 -1
- package/docs/API-reference/api/x-components.searchboxstate.md +1 -1
- package/docs/API-reference/api/x-components.searchconfig.md +1 -0
- package/docs/API-reference/api/x-components.searchconfig.pagemode.md +11 -0
- package/docs/API-reference/api/x-components.searchinputplaceholder.md +3 -3
- package/docs/API-reference/api/x-components.searchmutations.md +2 -1
- package/docs/API-reference/api/x-components.searchmutations.setstats.md +24 -0
- package/docs/API-reference/api/x-components.searchstate.md +2 -1
- package/docs/API-reference/api/x-components.searchstate.stats.md +13 -0
- package/docs/API-reference/api/x-components.searchxevents.md +1 -0
- package/docs/API-reference/api/x-components.searchxevents.userselectedapage.md +13 -0
- package/docs/API-reference/api/x-components.selectedfilterslist.md +3 -3
- package/docs/API-reference/api/x-components.semanticqueriesgetters.md +1 -0
- package/docs/API-reference/api/x-components.semanticqueriesgetters.query.md +13 -0
- package/docs/API-reference/api/x-components.semanticqueriesmutations.md +2 -1
- package/docs/API-reference/api/x-components.semanticqueriesmutations.setsemanticqueriesrelatedtags.md +24 -0
- package/docs/API-reference/api/x-components.semanticqueriesstate.md +2 -1
- package/docs/API-reference/api/x-components.semanticqueriesstate.relatedtags.md +13 -0
- package/docs/API-reference/api/x-components.setconfig.md +27 -0
- package/docs/API-reference/api/x-components.setquery.md +25 -0
- package/docs/API-reference/api/x-components.seturlprompt.md +13 -0
- package/docs/API-reference/api/x-components.simplefilter.md +7 -0
- package/docs/API-reference/api/x-components.singlecolumnlayout.md +3 -3
- package/docs/API-reference/api/x-components.slidingpanel.md +13 -5
- package/docs/API-reference/api/x-components.snippetcallbacks.md +7 -0
- package/docs/API-reference/api/x-components.sortdropdown.md +1 -1
- package/docs/API-reference/api/x-components.tagging.md +6 -6
- package/docs/API-reference/api/x-components.taggingconfig.md +2 -2
- package/docs/API-reference/api/{x-components.taggingconfig.clickedresultstoragekey.md → x-components.taggingconfig.storagekey.md} +3 -3
- package/docs/API-reference/api/x-components.taggingconfig.storagettlms.md +13 -0
- package/docs/API-reference/api/x-components.taggingmutations.md +1 -1
- package/docs/API-reference/api/x-components.taggingxevents.md +1 -1
- package/docs/API-reference/api/x-components.taggingxevents.resulturltrackingenabled.md +1 -1
- package/docs/API-reference/api/x-components.trackrelatedprompttoolingdisplayclickwire.md +13 -0
- package/docs/API-reference/api/x-components.tracktoolingadd2cartwire.md +13 -0
- package/docs/API-reference/api/x-components.tracktoolingdisplayclickedwire.md +13 -0
- package/docs/API-reference/api/x-components.typing.md +13 -0
- package/docs/API-reference/api/x-components.typingoptions.md +22 -0
- package/docs/API-reference/api/x-components.typingoptions.speed.md +13 -0
- package/docs/API-reference/api/x-components.typingoptions.targetattr.md +18 -0
- package/docs/API-reference/api/x-components.typingoptions.text.md +13 -0
- package/docs/API-reference/api/x-components.urlmutations.md +2 -1
- package/docs/API-reference/api/x-components.urlmutations.setprompt.md +24 -0
- package/docs/API-reference/api/x-components.urlparams.md +1 -0
- package/docs/API-reference/api/x-components.urlparams.prompt.md +11 -0
- package/docs/API-reference/api/x-components.urlstate.md +1 -1
- 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 +2 -0
- package/docs/API-reference/api/x-types.relatedprompt.md +4 -1
- package/docs/API-reference/api/x-types.relatedprompt.nextqueries.md +1 -1
- package/docs/API-reference/api/x-types.relatedprompt.relatedpromptnextqueries.md +13 -0
- package/docs/API-reference/api/x-types.relatedprompt.tagging.md +17 -0
- package/docs/API-reference/api/x-types.relatedprompt.toolingdisplaytagging.md +13 -0
- package/docs/API-reference/api/x-types.relatedpromptnextquery.md +23 -0
- package/docs/API-reference/api/x-types.relatedpromptnextquery.query.md +13 -0
- package/docs/API-reference/api/x-types.relatedpromptnextquery.toolingdisplayadd2carttagging.md +13 -0
- package/docs/API-reference/api/x-types.relatedpromptnextquery.toolingdisplayclicktagging.md +13 -0
- package/docs/API-reference/api/x-types.relatedpromptnextquery.toolingdisplaytagging.md +13 -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/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.display-click-provider.md +17 -0
- package/docs/API-reference/components/common/x-components.items-list.md +1 -1
- package/docs/API-reference/components/common/x-components.page-selector.md +136 -0
- package/docs/API-reference/components/common/x-components.sliding-panel.md +7 -7
- 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 +22 -0
- package/docs/API-reference/components/related-prompts/x-components.related-prompts-list.md +196 -0
- package/docs/API-reference/components/related-prompts/x-components.related-prompts-tag-list.md +32 -0
- package/docs/API-reference/components/search/x-components.results-list.md +1 -1
- package/docs/API-reference/components/tagging/x-components.tagging.md +15 -16
- package/js/components/animations/fade-and-slide.vue.js +1 -2
- package/js/components/animations/fade-and-slide.vue.js.map +1 -1
- package/js/components/base-dropdown.vue.js +1 -3
- package/js/components/base-dropdown.vue.js.map +1 -1
- package/js/components/base-dropdown.vue2.js +1 -7
- package/js/components/base-dropdown.vue2.js.map +1 -1
- package/js/components/base-event-button.vue.js +1 -2
- package/js/components/base-event-button.vue.js.map +1 -1
- package/js/components/base-grid.vue.js +11 -18
- 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-keyboard-navigation.vue.js +1 -2
- package/js/components/base-keyboard-navigation.vue.js.map +1 -1
- package/js/components/base-rating.vue.js +1 -3
- package/js/components/base-rating.vue.js.map +1 -1
- package/js/components/base-slider.vue.js +65 -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/base-switch.vue.js.map +1 -1
- package/js/components/base-switch.vue2.js +3 -7
- package/js/components/base-switch.vue2.js.map +1 -1
- package/js/components/base-variable-column-grid.vue.js +1 -2
- package/js/components/base-variable-column-grid.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-dropdown.vue.js +1 -3
- package/js/components/column-picker/base-column-picker-dropdown.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-list.vue.js +1 -3
- package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
- package/js/components/display-click-provider.vue.js +74 -0
- package/js/components/display-click-provider.vue.js.map +1 -0
- package/js/components/display-click-provider.vue2.js +6 -0
- package/js/components/display-click-provider.vue2.js.map +1 -0
- package/js/components/filters/labels/base-rating-filter-label.vue.js +1 -3
- package/js/components/filters/labels/base-rating-filter-label.vue.js.map +1 -1
- 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 +1 -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/layouts/fixed-header-and-asides-layout.vue.js +1 -7
- package/js/components/layouts/fixed-header-and-asides-layout.vue.js.map +1 -1
- package/js/components/layouts/multi-column-max-width-layout.vue.js +1 -9
- package/js/components/layouts/multi-column-max-width-layout.vue.js.map +1 -1
- package/js/components/layouts/single-column-layout.vue.js +1 -9
- package/js/components/layouts/single-column-layout.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-close.vue.js +1 -2
- package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue.js +1 -2
- package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-id-modal-close.vue.js +1 -2
- package/js/components/modals/base-id-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-id-modal-open.vue.js +1 -2
- package/js/components/modals/base-id-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-modal.vue.js +1 -2
- package/js/components/modals/base-modal.vue.js.map +1 -1
- package/js/components/modals/base-modal.vue2.js +13 -6
- package/js/components/modals/base-modal.vue2.js.map +1 -1
- package/js/components/page-loader-button.vue.js +8 -10
- package/js/components/page-loader-button.vue.js.map +1 -1
- package/js/components/page-loader-button.vue2.js.map +1 -1
- package/js/components/page-loader-button.vue3.js +7 -0
- package/js/components/page-loader-button.vue3.js.map +1 -0
- package/js/components/page-selector.vue.js +78 -0
- package/js/components/page-selector.vue.js.map +1 -0
- package/js/components/page-selector.vue2.js +128 -0
- package/js/components/page-selector.vue2.js.map +1 -0
- package/js/components/page-selector.vue3.js +7 -0
- package/js/components/page-selector.vue3.js.map +1 -0
- package/js/components/panels/base-header-toggle-panel.vue.js +1 -5
- package/js/components/panels/base-header-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel-button.vue.js +1 -2
- package/js/components/panels/base-id-toggle-panel-button.vue.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel.vue.js +1 -2
- package/js/components/panels/base-id-toggle-panel.vue.js.map +1 -1
- package/js/components/panels/base-tabs-panel.vue.js +1 -4
- package/js/components/panels/base-tabs-panel.vue.js.map +1 -1
- package/js/components/panels/base-toggle-panel.vue.js +1 -2
- package/js/components/panels/base-toggle-panel.vue.js.map +1 -1
- package/js/components/result/base-result-add-to-cart.vue.js +3 -3
- package/js/components/result/base-result-add-to-cart.vue.js.map +1 -1
- package/js/components/result/base-result-add-to-cart.vue2.js +19 -5
- package/js/components/result/base-result-add-to-cart.vue2.js.map +1 -1
- package/js/components/result/base-result-current-price.vue.js +1 -2
- package/js/components/result/base-result-current-price.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue.js +39 -59
- package/js/components/result/base-result-image.vue.js.map +1 -1
- package/js/components/result/base-result-image.vue2.js +5 -5
- package/js/components/result/base-result-image.vue2.js.map +1 -1
- package/js/components/result/base-result-link.vue.js +1 -2
- package/js/components/result/base-result-link.vue.js.map +1 -1
- package/js/components/result/base-result-previous-price.vue.js +1 -2
- package/js/components/result/base-result-previous-price.vue.js.map +1 -1
- package/js/components/result/base-result-rating.vue.js +1 -4
- package/js/components/result/base-result-rating.vue.js.map +1 -1
- package/js/components/result/result-variant-selector.vue.js +1 -3
- package/js/components/result/result-variant-selector.vue.js.map +1 -1
- package/js/components/sliding-panel.vue.js +3 -6
- package/js/components/sliding-panel.vue.js.map +1 -1
- package/js/components/sliding-panel.vue2.js +2 -2
- package/js/components/sliding-panel.vue2.js.map +1 -1
- package/js/components/suggestions/base-suggestion.vue.js +1 -2
- package/js/components/suggestions/base-suggestion.vue.js.map +1 -1
- package/js/components/suggestions/base-suggestions.vue.js +1 -2
- package/js/components/suggestions/base-suggestions.vue.js.map +1 -1
- package/js/composables/use-alias-api.js +4 -1
- package/js/composables/use-alias-api.js.map +1 -1
- package/js/composables/use-getter.js +1 -1
- package/js/composables/use-state.js +1 -1
- package/js/directives/typing.js +58 -0
- package/js/directives/typing.js.map +1 -0
- package/js/index.js +20 -4
- 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-installer/x-installer/x-installer.js +3 -3
- package/js/x-installer/x-installer/x-installer.js.map +1 -1
- package/js/x-modules/device/store/emitters.js +1 -0
- package/js/x-modules/device/store/emitters.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue.js +1 -2
- package/js/x-modules/empathize/components/empathize.vue.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue2.js +8 -3
- package/js/x-modules/empathize/components/empathize.vue2.js.map +1 -1
- package/js/x-modules/empathize/store/emitters.js +1 -0
- package/js/x-modules/empathize/store/emitters.js.map +1 -1
- package/js/x-modules/experience-controls/store/emitters.js +1 -0
- package/js/x-modules/experience-controls/store/emitters.js.map +1 -1
- package/js/x-modules/extra-params/components/extra-params.vue.js +1 -1
- package/js/x-modules/extra-params/components/extra-params.vue.js.map +1 -1
- package/js/x-modules/extra-params/store/emitters.js +1 -0
- package/js/x-modules/extra-params/store/emitters.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js +20 -33
- 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/filters/all-filter.vue.js +1 -2
- package/js/x-modules/facets/components/filters/all-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js +1 -6
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/number-range-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/number-range-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/simple-filter.vue.js +1 -3
- package/js/x-modules/facets/components/filters/simple-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-list.vue.js +1 -2
- package/js/x-modules/facets/components/lists/filters-list.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-search.vue.js +1 -3
- package/js/x-modules/facets/components/lists/filters-search.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/selected-filters-list.vue.js +11 -18
- 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/facets/components/lists/sliced-filters.vue.js +1 -4
- package/js/x-modules/facets/components/lists/sliced-filters.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/clear-history-queries.vue.js +1 -2
- package/js/x-modules/history-queries/components/clear-history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue.js +1 -10
- package/js/x-modules/history-queries/components/history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue.js +1 -6
- package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/my-history.vue.js +1 -4
- package/js/x-modules/history-queries/components/my-history.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/remove-history-query.vue.js +1 -2
- package/js/x-modules/history-queries/components/remove-history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/store/emitters.js +1 -0
- package/js/x-modules/history-queries/store/emitters.js.map +1 -1
- package/js/x-modules/identifier-results/components/identifier-results.vue.js +1 -2
- package/js/x-modules/identifier-results/components/identifier-results.vue.js.map +1 -1
- package/js/x-modules/identifier-results/store/emitters.js +1 -0
- package/js/x-modules/identifier-results/store/emitters.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue.js +1 -7
- package/js/x-modules/next-queries/components/next-queries.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-query-preview.vue.js +1 -3
- package/js/x-modules/next-queries/components/next-query-preview.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-query.vue.js +1 -4
- package/js/x-modules/next-queries/components/next-query.vue.js.map +1 -1
- package/js/x-modules/next-queries/store/emitters.js +1 -0
- package/js/x-modules/next-queries/store/emitters.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-search.vue.js +1 -4
- package/js/x-modules/popular-searches/components/popular-search.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue.js +1 -7
- package/js/x-modules/popular-searches/components/popular-searches.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-button.vue.js +1 -2
- package/js/x-modules/queries-preview/components/query-preview-button.vue.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-button.vue2.js +6 -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 +1 -2
- 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 +7 -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/emitters.js +1 -0
- package/js/x-modules/queries-preview/store/emitters.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/query-suggestions/components/query-suggestion.vue.js +1 -4
- package/js/x-modules/query-suggestions/components/query-suggestion.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js +1 -7
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/store/emitters.js +1 -0
- package/js/x-modules/query-suggestions/store/emitters.js.map +1 -1
- package/js/x-modules/recommendations/components/recommendations.vue.js +1 -2
- package/js/x-modules/recommendations/components/recommendations.vue.js.map +1 -1
- package/js/x-modules/recommendations/store/emitters.js +1 -0
- package/js/x-modules/recommendations/store/emitters.js.map +1 -1
- package/js/x-modules/related-prompts/components/related-prompt.vue.js +27 -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 +31 -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/components/related-prompts-tag-list.vue.js +101 -0
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +221 -0
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -0
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue3.js +7 -0
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue3.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/actions/set-url-params.action.js +15 -0
- package/js/x-modules/related-prompts/store/actions/set-url-params.action.js.map +1 -0
- package/js/x-modules/related-prompts/store/emitters.js +16 -0
- package/js/x-modules/related-prompts/store/emitters.js.map +1 -0
- package/js/x-modules/related-prompts/store/getters/related-prompts-query.getter.js +18 -0
- package/js/x-modules/related-prompts/store/getters/related-prompts-query.getter.js.map +1 -0
- package/js/x-modules/related-prompts/store/getters/request.getter.js +17 -0
- package/js/x-modules/related-prompts/store/getters/request.getter.js.map +1 -0
- package/js/x-modules/related-prompts/store/module.js +64 -0
- package/js/x-modules/related-prompts/store/module.js.map +1 -0
- package/js/x-modules/related-prompts/wiring.js +82 -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/related-tags/components/related-tag.vue.js +1 -2
- package/js/x-modules/related-tags/components/related-tag.vue.js.map +1 -1
- package/js/x-modules/related-tags/components/related-tags.vue.js +1 -4
- package/js/x-modules/related-tags/components/related-tags.vue.js.map +1 -1
- package/js/x-modules/related-tags/store/emitters.js +1 -0
- package/js/x-modules/related-tags/store/emitters.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue.js +1 -2
- package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js +6 -0
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
- package/js/x-modules/scroll/store/emitters.js +1 -0
- package/js/x-modules/scroll/store/emitters.js.map +1 -1
- package/js/x-modules/search/components/partial-results-list.vue.js +1 -2
- package/js/x-modules/search/components/partial-results-list.vue.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/components/sort-dropdown.vue.js +1 -3
- package/js/x-modules/search/components/sort-dropdown.vue.js.map +1 -1
- package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js +10 -3
- package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js.map +1 -1
- package/js/x-modules/search/store/actions/save-search-response.action.js +3 -1
- package/js/x-modules/search/store/actions/save-search-response.action.js.map +1 -1
- package/js/x-modules/search/store/emitters.js +1 -0
- package/js/x-modules/search/store/emitters.js.map +1 -1
- package/js/x-modules/search/store/module.js +9 -3
- package/js/x-modules/search/store/module.js.map +1 -1
- package/js/x-modules/search/wiring.js +4 -0
- package/js/x-modules/search/wiring.js.map +1 -1
- package/js/x-modules/search-box/components/clear-search-input.vue.js +1 -2
- package/js/x-modules/search-box/components/clear-search-input.vue.js.map +1 -1
- package/js/x-modules/search-box/components/search-button.vue.js +1 -2
- package/js/x-modules/search-box/components/search-button.vue.js.map +1 -1
- package/js/x-modules/search-box/store/emitters.js +1 -0
- package/js/x-modules/search-box/store/emitters.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-queries.vue.js +1 -3
- package/js/x-modules/semantic-queries/components/semantic-queries.vue.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-query.vue.js +1 -4
- package/js/x-modules/semantic-queries/components/semantic-query.vue.js.map +1 -1
- package/js/x-modules/semantic-queries/store/getters/normalized-query.getter.js +1 -1
- package/js/x-modules/semantic-queries/store/getters/normalized-query.getter.js.map +1 -1
- package/js/x-modules/semantic-queries/store/getters/request.getter.js +5 -4
- package/js/x-modules/semantic-queries/store/getters/request.getter.js.map +1 -1
- package/js/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.js +18 -0
- package/js/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.js.map +1 -0
- package/js/x-modules/semantic-queries/store/module.js +8 -2
- package/js/x-modules/semantic-queries/store/module.js.map +1 -1
- package/js/x-modules/semantic-queries/wiring.js +5 -0
- package/js/x-modules/semantic-queries/wiring.js.map +1 -1
- package/js/x-modules/tagging/components/tagging.vue.js +8 -7
- package/js/x-modules/tagging/components/tagging.vue.js.map +1 -1
- package/js/x-modules/tagging/service/{pdp-add-to-cart.service.js → external-tagging.service.js} +56 -25
- package/js/x-modules/tagging/service/external-tagging.service.js.map +1 -0
- package/js/x-modules/tagging/store/emitters.js +1 -1
- package/js/x-modules/tagging/store/emitters.js.map +1 -1
- package/js/x-modules/tagging/store/module.js +7 -3
- package/js/x-modules/tagging/store/module.js.map +1 -1
- package/js/x-modules/tagging/wiring.js +110 -9
- package/js/x-modules/tagging/wiring.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue2.js +4 -5
- package/js/x-modules/url/components/url-handler.vue2.js.map +1 -1
- package/js/x-modules/url/store/emitters.js +1 -0
- package/js/x-modules/url/store/emitters.js.map +1 -1
- package/js/x-modules/url/store/getters/url-params.getter.js +2 -3
- package/js/x-modules/url/store/getters/url-params.getter.js.map +1 -1
- package/js/x-modules/url/store/initial-state.js +2 -1
- package/js/x-modules/url/store/initial-state.js.map +1 -1
- package/js/x-modules/url/store/module.js +3 -0
- package/js/x-modules/url/store/module.js.map +1 -1
- package/js/x-modules/url/wiring.js +10 -1
- package/js/x-modules/url/wiring.js.map +1 -1
- package/package.json +50 -49
- package/related-prompts/index.d.ts +1 -0
- package/related-prompts/index.js +9 -0
- package/report/x-adapter-platform.api.json +895 -67
- package/report/x-components.api.json +16383 -17149
- package/report/x-components.api.md +834 -215
- package/report/x-types.api.json +320 -4
- package/tagging/index.js +2 -2
- 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-dropdown.vue.d.ts.map +1 -1
- 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-switch.vue.d.ts +2 -1
- package/types/components/base-switch.vue.d.ts.map +1 -1
- package/types/components/base-variable-column-grid.vue.d.ts +3 -3
- package/types/components/display-click-provider.vue.d.ts +61 -0
- package/types/components/display-click-provider.vue.d.ts.map +1 -0
- package/types/components/global-x-bus.vue.d.ts +14 -0
- package/types/components/global-x-bus.vue.d.ts.map +1 -1
- package/types/components/index.d.ts +3 -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/base-modal.vue.d.ts.map +1 -1
- package/types/components/modals/main-modal.vue.d.ts +2 -2
- package/types/components/page-selector.vue.d.ts +125 -0
- package/types/components/page-selector.vue.d.ts.map +1 -0
- 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-add-to-cart.vue.d.ts +2 -0
- package/types/components/result/base-result-add-to-cart.vue.d.ts.map +1 -1
- 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/sliding-panel.vue.d.ts +15 -5
- package/types/components/sliding-panel.vue.d.ts.map +1 -1
- package/types/components/snippet-callbacks.vue.d.ts +7 -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/composables/use-store.d.ts +2 -2
- package/types/composables/use-store.d.ts.map +1 -1
- package/types/directives/index.d.ts +1 -0
- package/types/directives/index.d.ts.map +1 -1
- package/types/directives/typing.d.ts +35 -0
- package/types/directives/typing.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/store/index.d.ts +4 -1
- package/types/store/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/types/origin.d.ts +3 -3
- package/types/types/origin.d.ts.map +1 -1
- package/types/types/page-mode.d.ts +2 -0
- package/types/types/page-mode.d.ts.map +1 -0
- package/types/types/url-params.d.ts +1 -0
- package/types/types/url-params.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-installer/x-installer/types.d.ts +2 -2
- package/types/x-installer/x-installer/types.d.ts.map +1 -1
- package/types/x-installer/x-installer/x-installer.d.ts +4 -4
- package/types/x-installer/x-installer/x-installer.d.ts.map +1 -1
- package/types/x-modules/empathize/components/empathize.vue.d.ts +6 -6
- package/types/x-modules/empathize/components/empathize.vue.d.ts.map +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 +9 -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 +7 -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 +4 -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 +28 -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/components/related-prompts-tag-list.vue.d.ts +131 -0
- package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts.map +1 -0
- package/types/x-modules/related-prompts/events.types.d.ts +41 -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/actions/set-url-params.action.d.ts +11 -0
- package/types/x-modules/related-prompts/store/actions/set-url-params.action.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/emitters.d.ts +10 -0
- package/types/x-modules/related-prompts/store/emitters.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/getters/index.d.ts +3 -0
- package/types/x-modules/related-prompts/store/getters/index.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/getters/related-prompts-query.getter.d.ts +13 -0
- package/types/x-modules/related-prompts/store/getters/related-prompts-query.getter.d.ts.map +1 -0
- package/types/x-modules/related-prompts/store/getters/request.getter.d.ts +14 -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 +6 -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 +125 -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 +42 -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/config.types.d.ts +2 -0
- package/types/x-modules/search/config.types.d.ts.map +1 -1
- package/types/x-modules/search/events.types.d.ts +4 -0
- package/types/x-modules/search/events.types.d.ts.map +1 -1
- package/types/x-modules/search/store/actions/fetch-and-save-search-response.action.d.ts.map +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/wiring.d.ts +4 -0
- package/types/x-modules/search/wiring.d.ts.map +1 -1
- package/types/x-modules/search-box/components/search-input-placeholder.vue.d.ts +3 -3
- package/types/x-modules/semantic-queries/store/getters/index.d.ts +1 -0
- package/types/x-modules/semantic-queries/store/getters/index.d.ts.map +1 -1
- package/types/x-modules/semantic-queries/store/getters/normalized-query.getter.d.ts +1 -1
- package/types/x-modules/semantic-queries/store/getters/request.getter.d.ts +2 -1
- package/types/x-modules/semantic-queries/store/getters/request.getter.d.ts.map +1 -1
- package/types/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.d.ts +13 -0
- package/types/x-modules/semantic-queries/store/getters/semanti-queries-query.getter.d.ts.map +1 -0
- package/types/x-modules/semantic-queries/store/module.d.ts.map +1 -1
- package/types/x-modules/semantic-queries/store/types.d.ts +13 -1
- package/types/x-modules/semantic-queries/store/types.d.ts.map +1 -1
- package/types/x-modules/semantic-queries/wiring.d.ts +3 -0
- package/types/x-modules/semantic-queries/wiring.d.ts.map +1 -1
- package/types/x-modules/tagging/components/tagging.vue.d.ts +14 -12
- package/types/x-modules/tagging/components/tagging.vue.d.ts.map +1 -1
- package/types/x-modules/tagging/config.types.d.ts +3 -3
- package/types/x-modules/tagging/config.types.d.ts.map +1 -1
- package/types/x-modules/tagging/events.types.d.ts +2 -2
- package/types/x-modules/tagging/service/{pdp-add-to-cart.service.d.ts → external-tagging.service.d.ts} +31 -13
- package/types/x-modules/tagging/service/external-tagging.service.d.ts.map +1 -0
- package/types/x-modules/tagging/service/index.d.ts +1 -1
- package/types/x-modules/tagging/service/index.d.ts.map +1 -1
- package/types/x-modules/tagging/service/types.d.ts +13 -4
- package/types/x-modules/tagging/service/types.d.ts.map +1 -1
- package/types/x-modules/tagging/store/module.d.ts.map +1 -1
- package/types/x-modules/tagging/wiring.d.ts +54 -2
- package/types/x-modules/tagging/wiring.d.ts.map +1 -1
- package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
- package/types/x-modules/url/store/getters/url-params.getter.d.ts +2 -3
- package/types/x-modules/url/store/getters/url-params.getter.d.ts.map +1 -1
- package/types/x-modules/url/store/initial-state.d.ts.map +1 -1
- package/types/x-modules/url/store/module.d.ts.map +1 -1
- package/types/x-modules/url/store/types.d.ts +6 -0
- package/types/x-modules/url/store/types.d.ts.map +1 -1
- package/types/x-modules/url/wiring.d.ts +9 -0
- package/types/x-modules/url/wiring.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/url/index.js +1 -1
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.clickedresultstoragekey.md +0 -11
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.clickedresultstoragettlms.md +0 -11
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.instance.md +0 -13
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.localstorageservice.md +0 -11
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.md +0 -41
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.result_clicked_id_key.md +0 -13
- package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.sessionstorageservice.md +0 -11
- package/docs/API-reference/api/x-components.pdpaddtocartservice.md +0 -22
- package/docs/API-reference/api/x-components.taggingconfig.clickedresultstoragettlms.md +0 -13
- package/docs/API-reference/api/x-components.usestore.md +0 -19
- package/docs/assets/features/overview-my-history.svg +0 -279
- package/docs/assets/features/overview-product-results-card.svg +0 -128
- package/docs/assets/interface/build-search-ui.svg +0 -167
- package/docs/assets/interface/experience-search-intro.svg +0 -1
- package/docs/assets/interface/integration-guide.svg +0 -1
- package/docs/assets/interface/integration-video.png +0 -0
- package/docs/assets/interface/x-architecture.svg +0 -1
- package/docs/assets/interface/x-empathize.gif +0 -0
- package/docs/assets/interface/x-facets.gif +0 -0
- package/docs/assets/interface/x-facets.svg +0 -189
- package/docs/assets/interface/x-history-queries.gif +0 -0
- package/docs/assets/interface/x-id-results.gif +0 -0
- package/docs/assets/interface/x-next-queries.gif +0 -0
- package/docs/assets/interface/x-popular-searches.gif +0 -0
- package/docs/assets/interface/x-query-suggestions.gif +0 -0
- package/docs/assets/interface/x-recommendations.gif +0 -0
- package/docs/assets/interface/x-recommendations.svg +0 -472
- package/docs/assets/interface/x-related-tags.gif +0 -0
- package/docs/assets/interface/x-results-layout.svg +0 -259
- package/docs/assets/interface/x-search-box-elements.svg +0 -1
- package/docs/assets/interface/x-search-box.svg +0 -60
- package/docs/build-search-ui/README.md +0 -127
- package/docs/build-search-ui/sidebar.js +0 -7
- package/docs/build-search-ui/web-archetype-development-guide.md +0 -186
- package/docs/build-search-ui/web-archetype-integration-guide.md +0 -458
- package/docs/build-search-ui/web-how-to-use-x-components-guide.md +0 -200
- package/docs/build-search-ui/web-x-architecture.md +0 -83
- package/docs/build-search-ui/web-x-components-development-guide.md +0 -157
- package/docs/experience-search-and-discovery/README.md +0 -132
- package/docs/experience-search-and-discovery/empathize.md +0 -119
- package/docs/experience-search-and-discovery/facets-and-filters.md +0 -154
- package/docs/experience-search-and-discovery/history-queries.md +0 -70
- package/docs/experience-search-and-discovery/id-results.md +0 -49
- package/docs/experience-search-and-discovery/my-history.md +0 -60
- package/docs/experience-search-and-discovery/next-queries.md +0 -72
- package/docs/experience-search-and-discovery/popular-searches.md +0 -50
- package/docs/experience-search-and-discovery/product-results-ui.md +0 -82
- package/docs/experience-search-and-discovery/query-suggestions.md +0 -48
- package/docs/experience-search-and-discovery/recommendations.md +0 -134
- package/docs/experience-search-and-discovery/related-tags.md +0 -66
- package/docs/experience-search-and-discovery/search-box.md +0 -99
- package/docs/experience-search-and-discovery/serp-ui.md +0 -125
- package/docs/experience-search-and-discovery/sidebar.js +0 -17
- package/docs/experience-search-and-discovery/web-local-storage.md +0 -30
- package/docs/input-status-machine-state.png +0 -0
- package/js/composables/use-store.js +0 -15
- package/js/composables/use-store.js.map +0 -1
- package/js/utils/options-api.js +0 -4
- package/js/utils/options-api.js.map +0 -1
- package/js/x-modules/tagging/service/pdp-add-to-cart.service.js.map +0 -1
- package/types/utils/options-api.d.ts +0 -3
- package/types/utils/options-api.d.ts.map +0 -1
- package/types/x-modules/tagging/service/pdp-add-to-cart.service.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-rating.vue.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n ref=\"el\"\n @click=\"emitClickedEvent\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, PropType, ref } from 'vue';\n import { Result } from '@empathyco/x-types';\n import BaseRating from '../base-rating.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\n export default defineComponent({\n components: {\n BaseRating\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n const el = ref<HTMLElement | null>(null);\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!\n });\n };\n\n return {\n emitClickedEvent\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-rating {\n color: inherit;\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nHere you have a basic example of how the result rating is rendered.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n },\n methods: {\n logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result);\n }\n }\n };\n</script>\n```\n\n## Extending the component\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nEven it is possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating, BaseRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating,\n BaseRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["result","_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","
|
|
1
|
+
{"version":3,"file":"base-result-rating.vue.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n ref=\"el\"\n @click=\"emitClickedEvent\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { defineComponent, PropType, ref } from 'vue';\n import { Result } from '@empathyco/x-types';\n import BaseRating from '../base-rating.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\n export default defineComponent({\n components: {\n BaseRating\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String\n }\n },\n setup(props) {\n const $x = use$x();\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n const el = ref<HTMLElement | null>(null);\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!\n });\n };\n\n return {\n emitClickedEvent\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-rating {\n color: inherit;\n text-decoration: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nHere you have a basic example of how the result rating is rendered.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with props\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n },\n methods: {\n logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result);\n }\n }\n };\n</script>\n```\n\n## Extending the component\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n\nEven it is possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script>\n import { BaseResultRating, BaseRating } from '@empathyco/x-components';\n\n export default {\n name: 'ResultRatingDemo',\n components: {\n BaseResultRating,\n BaseRating\n },\n data() {\n return {\n result: {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 }\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["result","_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_renderSlot","_createVNode","$attrs","_mergeProps","_createCommentVNode"],"mappings":";;;;;;AAG2BA,EAAAA,MAAAA,qBAAAA,GAAAA,gBAAAA,CAAa,YAAM,CAAA,CAAA;SAH9C,IAIY,CAAA,MAAA,CAAA,MAAA,IAAA,IAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA,IAAAC,SAAA,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,IAAA,GAAA,GAAA,GAAA,KAAA,CAAA,EAAA;AAAA,IACP,GAAA,EAAA,CAAA;AAAA,IACA,GAAI,EAAA,IAAA;AAAA,IACL,OAAM,EAAA,IAAA,CAAA,gBAAA;AAAA,IACN,IAAS,EAAA,IAAA,CAAA,IAAA;AAAA,IAAA,KAAA,EAAA,iBAAA;AARb,IAAA,WAAA,EAAA,eAAA;AAAA,GAAA,EAAA;AAaW,IAAA,OAAA,EAAAC,OAAA,CAAQJ,MAAO;AAAA,MAAAK,UAAA,CAAuBL,IAAM,CAAA,MAAA,EAAA,SAAA,EAAA;AAAA,QAgB5C,MAAA,EAAA,IAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA;AAAA,QAfL,MAca,EAAA,IAAA,CAAA,MAAA;AAAA,OAdK,EAAA,MAAA;AAAA,QAAAM,WAAA,CAA+BC,qBAAM,EAAAC,UAAA,CAAA;AAAA,UAC1C,YAAU,MAIO,CAAA,MAAA,CAAA,KAAA;AAAA,SAAA,EAAA,IAAA,CAA1B,MAA0B,CAAA,EAAA;AAAA,UAAA,YAAA,EAAAJ,OAAA,CAAA,MAAA;AAGjB,YAAAC,UAAA,CAAW,IAIO,CAAA,MAAA,EAAA,YAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,WAAA,CAAA;;AA1BrC,YAAAA,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,WAAA,CAAA;;;;AAAA,OAAA,EAAA,IAAA,CAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,EAAA,CAAA,EAAA,CAAA,SAAA,EAAA,MAAA,CAAA,CAAA,IAAAI,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './result-variant-selector.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, Fragment, renderList, normalizeClass,
|
|
2
|
+
import { openBlock, createElementBlock, Fragment, renderList, normalizeClass, renderSlot, createElementVNode, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
3
3
|
import './result-variant-selector.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -23,7 +23,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
23
|
"data-test": "variant-item"
|
|
24
24
|
},
|
|
25
25
|
[
|
|
26
|
-
createCommentVNode("\n @slot Variant item\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n @binding {() => void} selectVariant - Callback to select the variant\n "),
|
|
27
26
|
renderSlot(_ctx.$slots, "variant", {
|
|
28
27
|
variant,
|
|
29
28
|
isSelected: _ctx.variantIsSelected(variant),
|
|
@@ -34,7 +33,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
34
33
|
"data-test": "variant-button",
|
|
35
34
|
class: "x-button"
|
|
36
35
|
}, [
|
|
37
|
-
createCommentVNode("\n @slot Variant content\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n "),
|
|
38
36
|
renderSlot(_ctx.$slots, "variant-content", {
|
|
39
37
|
variant,
|
|
40
38
|
isSelected: _ctx.variantIsSelected(variant)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-variant-selector.vue.js","sources":["../../../../src/components/result/result-variant-selector.vue"],"sourcesContent":["<template>\n <ul v-if=\"result && variants\" class=\"x-result-variant-selector__list\" data-test=\"variants-list\">\n <li\n v-for=\"(variant, index) in variants\"\n :key=\"index\"\n class=\"x-result-variant-selector__item\"\n :class=\"{ 'x-result-variant-selector__item--is-selected': variantIsSelected(variant) }\"\n data-test=\"variant-item\"\n >\n <!--\n @slot Variant item\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n @binding {() => void} selectVariant - Callback to select the variant\n -->\n <slot\n name=\"variant\"\n :variant=\"variant\"\n :isSelected=\"variantIsSelected(variant)\"\n :selectVariant=\"() => selectVariant(variant)\"\n >\n <button @click=\"selectVariant(variant)\" data-test=\"variant-button\" class=\"x-button\">\n <!--\n @slot Variant content\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n -->\n <slot name=\"variant-content\" :variant=\"variant\" :isSelected=\"variantIsSelected(variant)\">\n {{ variant }}\n </slot>\n </button>\n </slot>\n </li>\n </ul>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, inject, Ref } from 'vue';\n import { Result, ResultVariant } from '@empathyco/x-types';\n import {\n RESULT_WITH_VARIANTS_KEY,\n SELECTED_VARIANTS_KEY,\n SELECT_RESULT_VARIANT_KEY\n } from '../decorators/injection.consts';\n\n /**\n * Component to show and select the available variants of a product for a given nest level.\n * TODO: Add logger warning on mount when result is not injected.\n *\n * @public\n */\n export default defineComponent({\n name: 'ResultVariantSelector',\n props: {\n /** The nest level of the variants to be rendered. */\n level: {\n type: Number,\n default: 0\n }\n },\n setup(props, { slots }) {\n /**\n * Callback to be called when a variant is selected.\n *\n * @public\n * @returns The 'selectResultVariant' injection key.\n */\n const selectResultVariant = inject<(variant: ResultVariant, level?: number) => void>(\n SELECT_RESULT_VARIANT_KEY as string\n );\n\n /** The original result, used to retrieve the available variants for the level. */\n const result = inject<Ref<Result>>(RESULT_WITH_VARIANTS_KEY as string);\n\n /** Array containing the selected variants. */\n const selectedVariants = inject<Ref<ResultVariant[]>>(SELECTED_VARIANTS_KEY as string);\n\n /**\n * It retrieves the available variants from the result.\n *\n * @returns - The variants of the result for the current level.\n */\n const variants = computed<ResultVariant[] | undefined>(() => {\n if (props.level === 0) {\n return result!.value?.variants;\n }\n return selectedVariants!.value[props.level - 1]?.variants;\n });\n\n /**\n * Gets the selected variant of the current level.\n *\n * @returns - The selected variant.\n */\n const selectedVariant = computed<ResultVariant | undefined>(() =>\n variants.value?.find(variant => variant === selectedVariants!.value[props.level])\n );\n\n /**\n * Calls the provided method to select a variant.\n *\n * @param variant - Variant to select.\n */\n const selectVariant = (variant: ResultVariant) => {\n selectResultVariant!(variant, props.level);\n };\n\n /**\n * Checks if a variant is selected.\n *\n * @param variant - Variant to check.\n * @returns True if the variant is selected, false if not.\n */\n const variantIsSelected = (variant: ResultVariant) => {\n return selectedVariant.value === variant;\n };\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no result or variants, 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\n * no result or variants.\n */\n function renderDefaultSlot() {\n const slotProps = {\n variants: variants.value,\n selectedVariant: selectedVariant.value,\n selectVariant\n };\n return result && variants.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 = { result, variants, variantIsSelected, selectVariant };\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps;\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-variant-selector__list {\n display: flex;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the `ResultVariantSelector` component is rendered.\n\nTake into account that this component **must** be a child of a `ResultVariantsProvider` component.\n\nAlso, the component is intended to be used overwriting the content with the slots.\n\nBy default it will render a list of buttons containing the available variants.\n\nThis component only has a required `level` prop, that indicates the level of the variants to be\nrendered.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <h1>Select color</h1>\n <ResultVariantSelector :level=\"0\" #variant=\"{ variant, selectVariant }\" />\n\n <h1>Select size</h1>\n <ResultVariantSelector :level=\"1\" #variant=\"{ variant, selectVariant }\" />\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red',\n variants: [\n {\n name: 'red XL'\n },\n {\n name: 'red L'\n }\n ]\n },\n {\n name: 'blue',\n variants: [\n {\n name: 'blue S'\n },\n {\n name: 'blue M'\n },\n {\n name: 'blue L'\n }\n ]\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example the default slot is used to customize the list.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector :level=\"0\" #default=\"{ variants, selectedVariant, selectVariant }\">\n <div>\n <p v-if=\"selectedVariant\">Selected variant: {{ selectedVariant.name }}</p>\n <ul class=\"x-flex\">\n <li v-for=\"(variant, index) in variants\" :key=\"index\">\n <button @click=\"selectVariant(variant)\">{{ variant.name }}</button>\n </li>\n </ul>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with variant-slot\n\nIn this example the variant-slot is used to customize the variant item.\n\nThe variant will be rendered inside a list.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector :level=\"0\" #variant=\"{ variant, isSelected, selectVariant }\">\n <div>\n <button @click=\"selectVariant\">\n {{ variant.name }}\n <span v-if=\"isSelected\">SELECTED!</span>\n </button>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with variant-content slot\n\nIn this example the variant-content slot is used to customize the content of the default variant\nbutton.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector #variant-content=\"{ variant, isSelected }\">\n <div>\n {{ variant.name }}\n <span v-if=\"isSelected\">SELECTED!</span>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","_createCommentVNode","_renderSlot","variantIsSelected","_createElementVNode","_toDisplayString"],"mappings":";;;;;MACgC,UAAM,GAAA;AAAA,EAAkC,GAAA,EAAA,CAAA;AAAA,EAAA,KAAA,EAAA,iCAAA;;;;AAAtE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAgCK,QAhCL,KAgCK,EAAA,QAAA,EAAA;6BA/BH,QA8BK,IAAAA,SAAA,EAAA,EAAAC,kBAAA,CAAA,IAAA,EAAA,UAAA,EAAA;AAAA,KAAAD,SAAA,CA5BG,IAAK,CAAA,EAAAC,kBAAA;AAAA,MAAAC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CAAA,IAAA,CAAA,QAAA,EAAA,CAAA,OAAA,EAAA,KAAA,KAAA;eACNH,SALX,EAAA,EAAAC,kBAAA;AAAA,UAKY,IAAA;AAAA,UAAA;AAAA,YAEN,GAAA,EAAA,KAAA;AAAA,YAAA,KAAA,EAAAG,cAAA,CAAA,CAAA,iCAAA,EAAA,EAAA,8CAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,OAAA,CAAA,EAAA,CAAA,CAAA;AAEA,YAAA,WAAA,EAAA,cAAA;AAAA,WAAA;AAMA,UAAA;AAAA,YAEmBC,kBAAA,CAAA,+PAAA,CAAA;AAAA,YAAAC,UAAA,CACN,KAAEC,MAAiB,EAAA,SAAA,EAAA;AAAA,cAC7B,OAAA;AAAA,cAYI,UAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,OAAA,CAAA;AAAA,cAVL,aASS,EAAA,MAAA,IAAA,CAAA,aAAA,CAAA,OAAA,CAAA;AAAA,aATA,EAAA,MAAA;AAAA,cAAyCC,kBAAA,CAAA,QAAA,EAAA;AAAA,gBAAiB,SAAM,CAAU,MAAA,KAAA,IAAA,CAAA,aAAA,CAAA,OAAA,CAAA;AAAA,gBAAA,WAAA,EAAA,gBAAA;AACjF,gBAAA,KAAA,EAAA,UAAA;AAAA,eAKA,EAAA;AAAA,gBAA8CH,kBAAA,CAAA,oMAAA,CAAA;AAAA,gBAAAC,UAAA,CAAa,KAAEC,MAAyB,EAAA,iBAAA,EAAA;AAAA,kBAAA,OAAA;AA3BhG,kBAAA,UAAA,EAAA,IAAA,CAAA,iBAAA,CA4Be,OAAO,CAAA;AAAA,iBAAA,EAAA,MAAA;;AA5BtB,oBAAAE,eAAA,CAAA,OAAA,CAAA;AAAA,oBAAA,CAAA;AAAA;AAAA,mBAAA;AAAA,iBAAA,EAAA,IAAA,CAAA;;;;;;;AAAA,OAAA,CAAA;AAAA,MAAA,GAAA;AAAA;AAAA,KAAA;AAAA,GAAA,CAAA,IAAAJ,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"result-variant-selector.vue.js","sources":["../../../../src/components/result/result-variant-selector.vue"],"sourcesContent":["<template>\n <ul v-if=\"result && variants\" class=\"x-result-variant-selector__list\" data-test=\"variants-list\">\n <li\n v-for=\"(variant, index) in variants\"\n :key=\"index\"\n class=\"x-result-variant-selector__item\"\n :class=\"{ 'x-result-variant-selector__item--is-selected': variantIsSelected(variant) }\"\n data-test=\"variant-item\"\n >\n <!--\n @slot Variant item\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n @binding {() => void} selectVariant - Callback to select the variant\n -->\n <slot\n name=\"variant\"\n :variant=\"variant\"\n :isSelected=\"variantIsSelected(variant)\"\n :selectVariant=\"() => selectVariant(variant)\"\n >\n <button @click=\"selectVariant(variant)\" data-test=\"variant-button\" class=\"x-button\">\n <!--\n @slot Variant content\n @binding {ResultVariant} variant - The variant item\n @binding {boolean} isSelected - Indicates if the variant is selected\n -->\n <slot name=\"variant-content\" :variant=\"variant\" :isSelected=\"variantIsSelected(variant)\">\n {{ variant }}\n </slot>\n </button>\n </slot>\n </li>\n </ul>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, inject, Ref } from 'vue';\n import { Result, ResultVariant } from '@empathyco/x-types';\n import {\n RESULT_WITH_VARIANTS_KEY,\n SELECTED_VARIANTS_KEY,\n SELECT_RESULT_VARIANT_KEY\n } from '../decorators/injection.consts';\n\n /**\n * Component to show and select the available variants of a product for a given nest level.\n * TODO: Add logger warning on mount when result is not injected.\n *\n * @public\n */\n export default defineComponent({\n name: 'ResultVariantSelector',\n props: {\n /** The nest level of the variants to be rendered. */\n level: {\n type: Number,\n default: 0\n }\n },\n setup(props, { slots }) {\n /**\n * Callback to be called when a variant is selected.\n *\n * @public\n * @returns The 'selectResultVariant' injection key.\n */\n const selectResultVariant = inject<(variant: ResultVariant, level?: number) => void>(\n SELECT_RESULT_VARIANT_KEY as string\n );\n\n /** The original result, used to retrieve the available variants for the level. */\n const result = inject<Ref<Result>>(RESULT_WITH_VARIANTS_KEY as string);\n\n /** Array containing the selected variants. */\n const selectedVariants = inject<Ref<ResultVariant[]>>(SELECTED_VARIANTS_KEY as string);\n\n /**\n * It retrieves the available variants from the result.\n *\n * @returns - The variants of the result for the current level.\n */\n const variants = computed<ResultVariant[] | undefined>(() => {\n if (props.level === 0) {\n return result!.value?.variants;\n }\n return selectedVariants!.value[props.level - 1]?.variants;\n });\n\n /**\n * Gets the selected variant of the current level.\n *\n * @returns - The selected variant.\n */\n const selectedVariant = computed<ResultVariant | undefined>(() =>\n variants.value?.find(variant => variant === selectedVariants!.value[props.level])\n );\n\n /**\n * Calls the provided method to select a variant.\n *\n * @param variant - Variant to select.\n */\n const selectVariant = (variant: ResultVariant) => {\n selectResultVariant!(variant, props.level);\n };\n\n /**\n * Checks if a variant is selected.\n *\n * @param variant - Variant to check.\n * @returns True if the variant is selected, false if not.\n */\n const variantIsSelected = (variant: ResultVariant) => {\n return selectedVariant.value === variant;\n };\n\n /**\n * Render function to execute the `default` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no result or variants, 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\n * no result or variants.\n */\n function renderDefaultSlot() {\n const slotProps = {\n variants: variants.value,\n selectedVariant: selectedVariant.value,\n selectVariant\n };\n return result && variants.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 = { result, variants, variantIsSelected, selectVariant };\n return (slots.default ? renderDefaultSlot : componentProps) as typeof componentProps;\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-result-variant-selector__list {\n display: flex;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the `ResultVariantSelector` component is rendered.\n\nTake into account that this component **must** be a child of a `ResultVariantsProvider` component.\n\nAlso, the component is intended to be used overwriting the content with the slots.\n\nBy default it will render a list of buttons containing the available variants.\n\nThis component only has a required `level` prop, that indicates the level of the variants to be\nrendered.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <h1>Select color</h1>\n <ResultVariantSelector :level=\"0\" #variant=\"{ variant, selectVariant }\" />\n\n <h1>Select size</h1>\n <ResultVariantSelector :level=\"1\" #variant=\"{ variant, selectVariant }\" />\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red',\n variants: [\n {\n name: 'red XL'\n },\n {\n name: 'red L'\n }\n ]\n },\n {\n name: 'blue',\n variants: [\n {\n name: 'blue S'\n },\n {\n name: 'blue M'\n },\n {\n name: 'blue L'\n }\n ]\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with the default slot\n\nIn this example the default slot is used to customize the list.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector :level=\"0\" #default=\"{ variants, selectedVariant, selectVariant }\">\n <div>\n <p v-if=\"selectedVariant\">Selected variant: {{ selectedVariant.name }}</p>\n <ul class=\"x-flex\">\n <li v-for=\"(variant, index) in variants\" :key=\"index\">\n <button @click=\"selectVariant(variant)\">{{ variant.name }}</button>\n </li>\n </ul>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with variant-slot\n\nIn this example the variant-slot is used to customize the variant item.\n\nThe variant will be rendered inside a list.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector :level=\"0\" #variant=\"{ variant, isSelected, selectVariant }\">\n <div>\n <button @click=\"selectVariant\">\n {{ variant.name }}\n <span v-if=\"isSelected\">SELECTED!</span>\n </button>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n\n### Play with variant-content slot\n\nIn this example the variant-content slot is used to customize the content of the default variant\nbutton.\n\n```vue\n<template>\n <ResultVariantsProvider :result=\"result\" #default=\"{ result }\">\n <p>Result name: {{ result.name }}</p>\n\n <ResultVariantSelector #variant-content=\"{ variant, isSelected }\">\n <div>\n {{ variant.name }}\n <span v-if=\"isSelected\">SELECTED!</span>\n </div>\n </ResultVariantSelector>\n </ResultVariantsProvider>\n</template>\n\n<script>\n import { ResultVariantsProvider, ResultVariantSelector } from '@empathyco/x-components';\n\n export default {\n name: 'ResultVariantSelectorDemo',\n components: {\n ResultVariantsProvider,\n ResultVariantSelector\n },\n data() {\n return {\n result: {\n id: 'jacket',\n modelName: 'Result',\n type: 'Product',\n isWishlisted: false,\n identifier: { value: 'jacket' },\n images: [],\n name: 'jacket',\n price: { hasDiscount: false, originalValue: 10, value: 10 },\n url: '/products/jacket',\n variants: [\n {\n name: 'red'\n },\n {\n name: 'blue'\n }\n ]\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","_renderSlot","variantIsSelected","_createElementVNode","_toDisplayString","_createCommentVNode"],"mappings":";;;;;MACgC,UAAM,GAAA;AAAA,EAAkC,GAAA,EAAA,CAAA;AAAA,EAAA,KAAA,EAAA,iCAAA;;;;AAAtE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAgCK,QAhCL,KAgCK,EAAA,QAAA,EAAA;6BA/BH,QA8BK,IAAAA,SAAA,EAAA,EAAAC,kBAAA,CAAA,IAAA,EAAA,UAAA,EAAA;AAAA,KAAAD,SAAA,CA5BG,IAAK,CAAA,EAAAC,kBAAA;AAAA,MAAAC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CAAA,IAAA,CAAA,QAAA,EAAA,CAAA,OAAA,EAAA,KAAA,KAAA;eACNH,SALX,EAAA,EAAAC,kBAAA;AAAA,UAKY,IAAA;AAAA,UAAA;AAAA,YAEN,GAAA,EAAA,KAAA;AAAA,YAAA,KAAA,EAAAG,cAAA,CAAA,CAAA,iCAAA,EAAA,EAAA,8CAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,OAAA,CAAA,EAAA,CAAA,CAAA;YAQA,WAgBO,EAAA,cAAA;AAAA,WAAA;;AAbM,YAAAC,UAAA,CAAA,IAAA,CAAEC,MAAiB,EAAA,SAAA,EAAA;AAAA,cAC7B,OAAA;AAAA,cAYI,UAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,OAAA,CAAA;AAAA,cAVL,aASS,EAAA,MAAA,IAAA,CAAA,aAAA,CAAA,OAAA,CAAA;AAAA,aATA,EAAA,MAAA;AAAA,cAAyCC,kBAAA,CAAA,QAAA,EAAA;AAAA,gBAAiB,SAAM,CAAU,MAAA,KAAA,IAAA,CAAA,aAAA,CAAA,OAAA,CAAA;AAAA,gBAAA,WAAA,EAAA,gBAAA;AAMjF,gBAAA,KAAA,EAAA,UAAA;AAAA,eAAA,EAAA;AAA2D,gBAAAF,UAAA,CAAA,IAAA,CAAEC,MAAyB,EAAA,iBAAA,EAAA;AAAA,kBAAA,OAAA;AA3BhG,kBAAA,UAAA,EAAA,IAAA,CAAA,iBAAA,CA4Be,OAAO,CAAA;AAAA,iBAAA,EAAA,MAAA;;AA5BtB,oBAAAE,eAAA,CAAA,OAAA,CAAA;AAAA,oBAAA,CAAA;AAAA;AAAA,mBAAA;AAAA,iBAAA,EAAA,IAAA,CAAA;;;;;;;AAAA,OAAA,CAAA;AAAA,MAAA,GAAA;AAAA;AAAA,KAAA;AAAA,GAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './sliding-panel.vue2.js';
|
|
2
|
-
import { openBlock, createElementBlock, normalizeClass,
|
|
2
|
+
import { openBlock, createElementBlock, normalizeClass, renderSlot, createTextVNode, createCommentVNode, createElementVNode } from 'vue';
|
|
3
3
|
import './sliding-panel.vue3.js';
|
|
4
4
|
import _export_sfc from '../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -21,7 +21,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
21
21
|
"data-test": "sliding-panel-left-button"
|
|
22
22
|
},
|
|
23
23
|
[
|
|
24
|
-
createCommentVNode(" @slot Left button content "),
|
|
25
24
|
renderSlot(_ctx.$slots, "sliding-panel-left-button", {}, () => [
|
|
26
25
|
createTextVNode("\u1438")
|
|
27
26
|
], true)
|
|
@@ -40,7 +39,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
40
39
|
"data-test": "sliding-panel-scroll"
|
|
41
40
|
},
|
|
42
41
|
[
|
|
43
|
-
createCommentVNode(" @slot (Required) Sliding panel content "),
|
|
44
42
|
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
45
43
|
],
|
|
46
44
|
34
|
|
@@ -55,7 +53,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
55
53
|
"data-test": "sliding-panel-right-button"
|
|
56
54
|
},
|
|
57
55
|
[
|
|
58
|
-
createCommentVNode(" @slot Right button content "),
|
|
59
56
|
renderSlot(_ctx.$slots, "sliding-panel-right-button", {}, () => [
|
|
60
57
|
createTextVNode("\u1433")
|
|
61
58
|
], true)
|
|
@@ -68,7 +65,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
68
65
|
/* CLASS */
|
|
69
66
|
)) : createCommentVNode("v-if", true);
|
|
70
67
|
}
|
|
71
|
-
var
|
|
68
|
+
var SlidingPanel = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-9402d5ce"]]);
|
|
72
69
|
|
|
73
|
-
export {
|
|
70
|
+
export { SlidingPanel as default };
|
|
74
71
|
//# sourceMappingURL=sliding-panel.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliding-panel.vue.js","sources":["../../../src/components/sliding-panel.vue"],"sourcesContent":["<template>\n <div v-if=\"slots.default\" class=\"x-sliding-panel\" :class=\"cssClasses\" data-test=\"sliding-panel\">\n <button\n v-if=\"showButtons\"\n @click=\"scrollLeft\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-left\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-left-button\"\n >\n <!-- @slot Left button content -->\n <slot name=\"sliding-panel-left-button\">ᐸ</slot>\n </button>\n <div\n ref=\"scrollContainerRef\"\n @scroll=\"debouncedUpdateScroll\"\n @transitionend=\"debouncedUpdateScroll\"\n @animationend=\"debouncedUpdateScroll\"\n :class=\"scrollContainerClass\"\n class=\"x-sliding-panel__scroll\"\n data-test=\"sliding-panel-scroll\"\n >\n <!-- @slot (Required) Sliding panel content -->\n <slot />\n </div>\n <button\n v-if=\"showButtons\"\n @click=\"scrollRight\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-right\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-right-button\"\n >\n <!-- @slot Right button content -->\n <slot name=\"sliding-panel-right-button\">ᐳ</slot>\n </button>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onBeforeUnmount, onMounted, ref, watch } from 'vue';\n import { useDebounce } from '../composables/use-debounce';\n\n /**\n * This component allows for any other component or element inside it to be horizontally\n * navigable. It also implements customizable buttons as well as other minor customizations to its\n * general behavior.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\n export default defineComponent({\n name: 'SlidingPanel',\n props: {\n /**\n * Scroll factor that will dictate how much the scroll moves when pressing a navigation button.\n */\n scrollFactor: {\n type: Number,\n default: 0.7\n },\n /** Would make the navigation buttons visible when they're needed or always hide them. */\n showButtons: {\n type: Boolean,\n default: true\n },\n /**\n * When true, whenever the DOM content in the sliding panel slot changes, it will reset\n * the scroll position to 0.\n */\n resetOnContentChange: {\n type: Boolean,\n default: true\n },\n buttonClass: String,\n scrollContainerClass: String\n },\n setup(props, { slots }) {\n /** Indicates if the scroll is at the start of the sliding panel. */\n const isScrollAtStart = ref(true);\n /** Indicates if the scroll is at the end of the sliding panel. */\n const isScrollAtEnd = ref(true);\n const scrollContainerRef = ref<HTMLDivElement>();\n\n /**\n * Updates the values of the scroll positions to show or hide the buttons depending on it.\n *\n * @remarks The 2px extra is to fix some cases in some resolutions where the scroll + client\n * size is less than the scroll width even when the scroll is at the end.\n */\n function updateScrollPosition() {\n if (scrollContainerRef.value) {\n const { scrollLeft, clientWidth, scrollWidth } = scrollContainerRef.value;\n isScrollAtStart.value = !scrollLeft;\n isScrollAtEnd.value = scrollLeft + clientWidth + 2 >= scrollWidth;\n }\n }\n\n /**\n * Debounced version of the {@link SlidingPanel.updateScrollPosition} method.\n */\n const debouncedUpdateScroll = useDebounce(updateScrollPosition, 50, { leading: true });\n\n /**\n * Resets the scroll and updates the values of the scroll for the buttons to react.\n */\n const debouncedRestoreAndUpdateScroll = useDebounce(\n () => {\n scrollContainerRef.value!.scroll({ left: 0, behavior: 'smooth' });\n updateScrollPosition();\n },\n 50,\n { leading: true }\n );\n\n /**\n * Scrolls the wrapper element towards the provided scroll value.\n *\n * @param scrollValue - The value the scroll will go towards.\n */\n function scrollTo(scrollValue: number) {\n scrollContainerRef.value!.scrollBy({\n left: scrollValue * props.scrollFactor,\n behavior: 'smooth'\n });\n }\n\n /** Scrolls the wrapper element to the left. */\n function scrollLeft() {\n scrollTo(-scrollContainerRef.value!.clientWidth);\n }\n\n /** Scrolls the wrapper element to the right. */\n function scrollRight() {\n scrollTo(scrollContainerRef.value!.clientWidth);\n }\n\n /** CSS classes to apply based on the scroll position. */\n const cssClasses = computed(() => ({\n 'x-sliding-panel-at-start': isScrollAtStart.value,\n 'x-sliding-panel-at-end': isScrollAtEnd.value\n }));\n\n let resizeObserver: ResizeObserver;\n let contentChangedObserver: MutationObserver;\n\n /**\n * Initialises browser platform code:\n * - Creates a mutation observer to detect content changes and reset scroll position.\n * - Stores initial size and scroll position values.\n */\n onMounted(() => {\n resizeObserver = new ResizeObserver(debouncedUpdateScroll);\n resizeObserver.observe(scrollContainerRef.value!);\n contentChangedObserver = new MutationObserver(debouncedRestoreAndUpdateScroll);\n\n watch(\n () => props.resetOnContentChange,\n shouldReset => {\n if (shouldReset) {\n contentChangedObserver.observe(scrollContainerRef.value!, {\n subtree: true,\n childList: true,\n attributes: false,\n characterData: false\n });\n } else {\n contentChangedObserver.disconnect();\n }\n },\n { immediate: true }\n );\n\n updateScrollPosition();\n });\n\n onBeforeUnmount(() => {\n contentChangedObserver.disconnect();\n resizeObserver.disconnect();\n });\n\n return {\n cssClasses,\n debouncedUpdateScroll,\n scrollContainerRef,\n scrollLeft,\n scrollRight,\n slots\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-sliding-panel {\n align-items: center;\n display: flex;\n flex-flow: row nowrap;\n position: relative;\n }\n\n .x-sliding-panel__button {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: all ease-out 0.2s;\n z-index: 2; /* To overlay the design system gradient with z-index:1 */\n }\n .x-sliding-panel-button-left {\n left: 0;\n }\n .x-sliding-panel-button-right {\n right: 0;\n }\n\n .x-sliding-panel__scroll {\n display: flex;\n flex: 100%;\n flex-flow: row nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE */\n }\n\n /* Chrome, Edge & Safari */\n .x-sliding-panel__scroll::-webkit-scrollbar {\n display: none;\n }\n\n .x-sliding-panel__scroll > * {\n flex: 0 0 auto;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-start) .x-sliding-panel-button-left {\n opacity: 1;\n pointer-events: all;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-end) .x-sliding-panel-button-right {\n opacity: 1;\n pointer-events: all;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\nSimplest implementation of the component, just a list-based component inside its slot.\n\n```vue\n<template>\n <SlidingPanel>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n### Play with props\n\n#### Modifying scroll buttons travel distance\n\nEdit how much the scroll travels when navigating with the buttons by changing the `scrollFactor`\nprop.\n\n```vue\n<template>\n <SlidingPanel :scrollFactor=\"1.5\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Hiding scroll buttons\n\nHide the navigational buttons completely by setting the `showButtons` prop to `false`. This is\nintended to be used when other scrolling options are available, like in mobile, where you can scroll\njust by swiping.\n\n```vue\n<template>\n <SlidingPanel :showButtons=\"false\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Customizing the content with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\nThe `scrollContainerClass` prop can be used to add classes to the scroll content.\n\n```vue\n<template>\n <SlidingPanel buttonClass=\"x-button--round\" scrollContainerClass=\"x-sliding-panel-fade\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Disabling reset the scroll when content changes\n\nBy default, whenever the content of the sliding panel changes, it auto resets its scroll position.\nYou can disable this behavior setting the `resetOnContentChange` prop to `false`.\n\n```vue\n<template>\n <div>\n <button @click=\"items++\">Add item</button>\n <label>\n <input type=\"checkbox\" v-model=\"resetOnContentChange\" />\n Reset content onchange\n </label>\n <SlidingPanel :resetOnContentChange=\"resetOnContentChange\">\n <div class=\"item\" v-for=\"item in items\" :key=\"item\">Item {{ item }}</div>\n </SlidingPanel>\n </div>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n },\n data() {\n return {\n items: 4,\n resetOnContentChange: false\n };\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n## Extending the component\n\n### Overriding Button content\n\nBy default the buttons show an arrow depicting the direction the scroll would go to when clicked,\nbut this content can be customized with anything, from characters to SVG and images.\n\n```vue\n<template>\n <SlidingPanel>\n <template #sliding-panel-left-button>Left</template>\n <template #default>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </template>\n <template #sliding-panel-right-button>Right</template>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","showButtons","_createCommentVNode","_renderSlot","_createElementVNode","scrollContainerClass"],"mappings":";;;;;qBACE,IAiCM,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AAlCR,EAAA,OAAA,IAAA,CAAA,KAAA,CAAA,OAAA,IAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IACkC,KAAA;AAAA,IAAA;AAAA,MAAsC,GAAA,EAAA,CAAA;AAAA,MAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,iBAAA,EAAA,IAAA,CAAA,UAAA,CAAA,CAAA;AAE5DC,MAAAA,WAAAA,EAAAA,eAAAA;AAAAA,KAAAA;;WAHZ,WAIY,IAAAH,SAAA,EAAA,EAAAC,kBAAA;AAAA,QAAA,QAAA;AAAA,QAAA;AAAA,UACN,GAAK,EAAA,CAAA;AAAA,UAEL,gBAAU,CAA2B,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,UAAA,IAAA,IAAA,CAAA,UAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,8DAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;AAErC,UAAA,WAAA,EAAA,2BAAA;AAAA,SAAA;AACA,QAAA;AAAA,UAAAE,kBAAA,CAAuC,6BAAC,CAAA;AAAA,UAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,EAAA,EAAA,EAAA,MAAA;;AAV9C,WAAA,EAAA,IAAA,CAAA;AAAA,SAYI;AAAA,QAAA,CAAA;AAAA;AAAA,OAWM,IAVJD,mBAAI,MAAoB,EAAA,IAAA,CAAA;AAAA,MAAAE,kBAAA;AACjB,QAAA,KAAA;AAAA,QAAA;AAAA,UACN,GAAA,EAAA,oBAAA;AAAA,UACA,iBAAY,CAAE,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UACd,eAAA,EAjBP,MAiBcC,CAAAA,CAAAA,CAAAA,KAAAA,MAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,GAAAA,IAAAA,KACF,IAAyB,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAC/B,gBAAU,MAAsB,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAL,cAAA,CAAA,CAAA,IAAA,CAAA,oBAAA,EAAA,yBAAA,CAAA,CAAA;AAEhC,UAAA,WAAA,EAAA,sBAAA;AAAA,SAAA;AACA,QAAA;AAAA,UAAAE,kBAAA,CAAA,0CAAA,CAAA;UAGMD,UAAW,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,SAAA;;;AADnB,OAAA;AAAA,MAAA,IAAA,CAxBJ,WA0BY,IAAAH,SAAA,EAAA,EAAAC,kBAAA;AAAA,QAAA,QAAA;AAAA,QAAA;AAAA,UACN,GAAK,EAAA,CAAA;AAAA,UAEL,gBAAU,CAA4B,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,WAAA,IAAA,IAAA,CAAA,WAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,+DAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;AAEtC,UAAA,WAAA,EAAA,4BAAA;AAAA,SAAA;AACA,QAAA;AAAA,UAAAE,kBAAA,CAAwC,8BAAC,CAAA;AAAA,UAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,4BAAA,EAAA,EAAA,EAAA,MAAA;;AAhC/C,WAAA,EAAA,IAAA,CAAA;AAAA,SAAA;;;AAAA,OAAA,IAAAD,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAAA,KAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sliding-panel.vue.js","sources":["../../../src/components/sliding-panel.vue"],"sourcesContent":["<template>\n <div v-if=\"slots.default\" class=\"x-sliding-panel\" :class=\"cssClasses\" data-test=\"sliding-panel\">\n <button\n v-if=\"showButtons\"\n @click=\"scrollLeft\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-left\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-left-button\"\n >\n <!-- @slot Left button content -->\n <slot name=\"sliding-panel-left-button\">ᐸ</slot>\n </button>\n <div\n ref=\"scrollContainerRef\"\n @scroll=\"debouncedUpdateScroll\"\n @transitionend=\"debouncedUpdateScroll\"\n @animationend=\"debouncedUpdateScroll\"\n :class=\"scrollContainerClass\"\n class=\"x-sliding-panel__scroll\"\n data-test=\"sliding-panel-scroll\"\n >\n <!-- @slot (Required) Sliding panel content -->\n <slot />\n </div>\n <button\n v-if=\"showButtons\"\n @click=\"scrollRight\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-right\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-right-button\"\n >\n <!-- @slot Right button content -->\n <slot name=\"sliding-panel-right-button\">ᐳ</slot>\n </button>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onBeforeUnmount, onMounted, PropType, ref, watch } from 'vue';\n import { useDebounce } from '../composables/use-debounce';\n import { VueCSSClasses } from '../utils/types';\n\n /**\n * This component allows for any other component or element inside it to be horizontally\n * navigable. It also implements customizable buttons as well as other minor customizations to its\n * general behavior.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\n export default defineComponent({\n name: 'SlidingPanel',\n props: {\n /**\n * Scroll factor that will dictate how much the scroll moves when pressing a navigation button.\n */\n scrollFactor: {\n type: Number,\n default: 0.7\n },\n /** Would make the navigation buttons visible when they're needed or always hide them. */\n showButtons: {\n type: Boolean,\n default: true\n },\n /**\n * When true, whenever the DOM content in the sliding panel slot changes, it will reset\n * the scroll position to 0.\n */\n resetOnContentChange: {\n type: Boolean,\n default: true\n },\n buttonClass: { type: [String, Object, Array] as PropType<VueCSSClasses> },\n scrollContainerClass: { type: [String, Object, Array] as PropType<VueCSSClasses> }\n },\n setup(props, { slots }) {\n /** Indicates if the scroll is at the start of the sliding panel. */\n const isScrollAtStart = ref(true);\n /** Indicates if the scroll is at the end of the sliding panel. */\n const isScrollAtEnd = ref(true);\n const scrollContainerRef = ref<HTMLDivElement>();\n\n /**\n * Updates the values of the scroll positions to show or hide the buttons depending on it.\n *\n * @remarks The 2px extra is to fix some cases in some resolutions where the scroll + client\n * size is less than the scroll width even when the scroll is at the end.\n */\n function updateScrollPosition() {\n if (scrollContainerRef.value) {\n const { scrollLeft, clientWidth, scrollWidth } = scrollContainerRef.value;\n isScrollAtStart.value = !scrollLeft;\n isScrollAtEnd.value = scrollLeft + clientWidth + 2 >= scrollWidth;\n }\n }\n\n /**\n * Debounced version of the {@link SlidingPanel.updateScrollPosition} method.\n */\n const debouncedUpdateScroll = useDebounce(updateScrollPosition, 50, { leading: true });\n\n /**\n * Resets the scroll and updates the values of the scroll for the buttons to react.\n */\n const debouncedRestoreAndUpdateScroll = useDebounce(\n () => {\n scrollContainerRef.value!.scroll({ left: 0, behavior: 'smooth' });\n updateScrollPosition();\n },\n 50,\n { leading: true }\n );\n\n /**\n * Scrolls the wrapper element towards the provided scroll value.\n *\n * @param scrollValue - The value the scroll will go towards.\n */\n function scrollTo(scrollValue: number) {\n scrollContainerRef.value!.scrollBy({\n left: scrollValue * props.scrollFactor,\n behavior: 'smooth'\n });\n }\n\n /** Scrolls the wrapper element to the left. */\n function scrollLeft() {\n scrollTo(-scrollContainerRef.value!.clientWidth);\n }\n\n /** Scrolls the wrapper element to the right. */\n function scrollRight() {\n scrollTo(scrollContainerRef.value!.clientWidth);\n }\n\n /** CSS classes to apply based on the scroll position. */\n const cssClasses = computed(() => ({\n 'x-sliding-panel-at-start': isScrollAtStart.value,\n 'x-sliding-panel-at-end': isScrollAtEnd.value\n }));\n\n let resizeObserver: ResizeObserver;\n let contentChangedObserver: MutationObserver;\n\n /**\n * Initialises browser platform code:\n * - Creates a mutation observer to detect content changes and reset scroll position.\n * - Stores initial size and scroll position values.\n */\n onMounted(() => {\n resizeObserver = new ResizeObserver(debouncedUpdateScroll);\n resizeObserver.observe(scrollContainerRef.value!);\n contentChangedObserver = new MutationObserver(debouncedRestoreAndUpdateScroll);\n\n watch(\n () => props.resetOnContentChange,\n shouldReset => {\n if (shouldReset) {\n contentChangedObserver.observe(scrollContainerRef.value!, {\n subtree: true,\n childList: true,\n attributes: false,\n characterData: false\n });\n } else {\n contentChangedObserver.disconnect();\n }\n },\n { immediate: true }\n );\n\n updateScrollPosition();\n });\n\n onBeforeUnmount(() => {\n contentChangedObserver.disconnect();\n resizeObserver.disconnect();\n });\n\n return {\n cssClasses,\n debouncedUpdateScroll,\n scrollContainerRef,\n scrollLeft,\n scrollRight,\n slots\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-sliding-panel {\n align-items: center;\n display: flex;\n flex-flow: row nowrap;\n position: relative;\n }\n\n .x-sliding-panel__button {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: all ease-out 0.2s;\n z-index: 2; /* To overlay the design system gradient with z-index:1 */\n }\n .x-sliding-panel-button-left {\n left: 0;\n }\n .x-sliding-panel-button-right {\n right: 0;\n }\n\n .x-sliding-panel__scroll {\n display: flex;\n flex: 100%;\n flex-flow: row nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE */\n }\n\n /* Chrome, Edge & Safari */\n .x-sliding-panel__scroll::-webkit-scrollbar {\n display: none;\n }\n\n .x-sliding-panel__scroll > * {\n flex: 0 0 auto;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-start) .x-sliding-panel-button-left {\n opacity: 1;\n pointer-events: all;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-end) .x-sliding-panel-button-right {\n opacity: 1;\n pointer-events: all;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\nSimplest implementation of the component, just a list-based component inside its slot.\n\n```vue\n<template>\n <SlidingPanel>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n### Play with props\n\n#### Modifying scroll buttons travel distance\n\nEdit how much the scroll travels when navigating with the buttons by changing the `scrollFactor`\nprop.\n\n```vue\n<template>\n <SlidingPanel :scrollFactor=\"1.5\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Hiding scroll buttons\n\nHide the navigational buttons completely by setting the `showButtons` prop to `false`. This is\nintended to be used when other scrolling options are available, like in mobile, where you can scroll\njust by swiping.\n\n```vue\n<template>\n <SlidingPanel :showButtons=\"false\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Customizing the content with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\nThe `scrollContainerClass` prop can be used to add classes to the scroll content.\n\n```vue\n<template>\n <SlidingPanel buttonClass=\"x-button--round\" scrollContainerClass=\"x-sliding-panel-fade\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Disabling reset the scroll when content changes\n\nBy default, whenever the content of the sliding panel changes, it auto resets its scroll position.\nYou can disable this behavior setting the `resetOnContentChange` prop to `false`.\n\n```vue\n<template>\n <div>\n <button @click=\"items++\">Add item</button>\n <label>\n <input type=\"checkbox\" v-model=\"resetOnContentChange\" />\n Reset content onchange\n </label>\n <SlidingPanel :resetOnContentChange=\"resetOnContentChange\">\n <div class=\"item\" v-for=\"item in items\" :key=\"item\">Item {{ item }}</div>\n </SlidingPanel>\n </div>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n },\n data() {\n return {\n items: 4,\n resetOnContentChange: false\n };\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n## Extending the component\n\n### Overriding Button content\n\nBy default the buttons show an arrow depicting the direction the scroll would go to when clicked,\nbut this content can be customized with anything, from characters to SVG and images.\n\n```vue\n<template>\n <SlidingPanel>\n <template #sliding-panel-left-button>Left</template>\n <template #default>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </template>\n <template #sliding-panel-right-button>Right</template>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","showButtons","_createCommentVNode","_createElementVNode","scrollContainerClass"],"mappings":";;;;;qBACE,IAiCM,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AAlCR,EAAA,OAAA,IAAA,CAAA,KAAA,CAAA,OAAA,IAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IACkC,KAAA;AAAA,IAAA;AAAA,MAAsC,GAAA,EAAA,CAAA;AAAA,MAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,iBAAA,EAAA,IAAA,CAAA,UAAA,CAAA,CAAA;AAE5DC,MAAAA,WAAAA,EAAAA,eAAAA;AAAAA,KAAAA;;WAHZ,WAIY,IAAAH,SAAA,EAAA,EAAAC,kBAAA;AAAA,QAAA,QAAA;AAAA,QAAA;AAAA,UACN,GAAK,EAAA,CAAA;AAAA,UAEL,gBAAU,CAA2B,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,UAAA,IAAA,IAAA,CAAA,UAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,8DAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;UAGrC,WAA+C,EAAA,2BAAA;AAAA,SAAA;;;;AAVrD,WAAA,EAAA,IAAA,CAAA;AAAA,SAYI;AAAA,QAAA,CAAA;AAAA;AAAA,OAWM,IAVJE,mBAAI,MAAoB,EAAA,IAAA,CAAA;AAAA,MAAAC,kBAAA;AACjB,QAAA,KAAA;AAAA,QAAA;AAAA,UACN,GAAA,EAAA,oBAAA;AAAA,UACA,iBAAY,CAAE,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UACd,eAAA,EAjBP,MAiBcC,CAAAA,CAAAA,CAAAA,KAAAA,MAAAA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,GAAAA,IAAAA,KACF,IAAyB,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAC/B,gBAAU,MAAsB,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAJ,cAAA,CAAA,CAAA,IAAA,CAAA,oBAAA,EAAA,yBAAA,CAAA,CAAA;UAGhC,WAAQ,EAAA,sBAAA;AAAA,SAAA;;UAGFC,UAAW,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAA,SAAA;;;AADnB,OAAA;AAAA,MAAA,IAAA,CAxBJ,WA0BY,IAAAH,SAAA,EAAA,EAAAC,kBAAA;AAAA,QAAA,QAAA;AAAA,QAAA;AAAA,UACN,GAAK,EAAA,CAAA;AAAA,UAEL,gBAAU,CAA4B,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,WAAA,IAAA,IAAA,CAAA,WAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,UAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,+DAAA,EAAA,IAAA,CAAA,WAAA,CAAA,CAAA;UAGtC,WAAgD,EAAA,4BAAA;AAAA,SAAA;;;;AAhCtD,WAAA,EAAA,IAAA,CAAA;AAAA,SAAA;;;AAAA,OAAA,IAAAE,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAAA,KAAA;;;;;;;;;"}
|
|
@@ -34,8 +34,8 @@ var _sfc_main = defineComponent({
|
|
|
34
34
|
type: Boolean,
|
|
35
35
|
default: true
|
|
36
36
|
},
|
|
37
|
-
buttonClass: String,
|
|
38
|
-
scrollContainerClass: String
|
|
37
|
+
buttonClass: { type: [String, Object, Array] },
|
|
38
|
+
scrollContainerClass: { type: [String, Object, Array] }
|
|
39
39
|
},
|
|
40
40
|
setup(props, { slots }) {
|
|
41
41
|
/** Indicates if the scroll is at the start of the sliding panel. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliding-panel.vue2.js","sources":["../../../src/components/sliding-panel.vue"],"sourcesContent":["<template>\n <div v-if=\"slots.default\" class=\"x-sliding-panel\" :class=\"cssClasses\" data-test=\"sliding-panel\">\n <button\n v-if=\"showButtons\"\n @click=\"scrollLeft\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-left\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-left-button\"\n >\n <!-- @slot Left button content -->\n <slot name=\"sliding-panel-left-button\">ᐸ</slot>\n </button>\n <div\n ref=\"scrollContainerRef\"\n @scroll=\"debouncedUpdateScroll\"\n @transitionend=\"debouncedUpdateScroll\"\n @animationend=\"debouncedUpdateScroll\"\n :class=\"scrollContainerClass\"\n class=\"x-sliding-panel__scroll\"\n data-test=\"sliding-panel-scroll\"\n >\n <!-- @slot (Required) Sliding panel content -->\n <slot />\n </div>\n <button\n v-if=\"showButtons\"\n @click=\"scrollRight\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-right\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-right-button\"\n >\n <!-- @slot Right button content -->\n <slot name=\"sliding-panel-right-button\">ᐳ</slot>\n </button>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onBeforeUnmount, onMounted, ref, watch } from 'vue';\n import { useDebounce } from '../composables/use-debounce';\n\n /**\n * This component allows for any other component or element inside it to be horizontally\n * navigable. It also implements customizable buttons as well as other minor customizations to its\n * general behavior.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\n export default defineComponent({\n name: 'SlidingPanel',\n props: {\n /**\n * Scroll factor that will dictate how much the scroll moves when pressing a navigation button.\n */\n scrollFactor: {\n type: Number,\n default: 0.7\n },\n /** Would make the navigation buttons visible when they're needed or always hide them. */\n showButtons: {\n type: Boolean,\n default: true\n },\n /**\n * When true, whenever the DOM content in the sliding panel slot changes, it will reset\n * the scroll position to 0.\n */\n resetOnContentChange: {\n type: Boolean,\n default: true\n },\n buttonClass: String,\n scrollContainerClass: String\n },\n setup(props, { slots }) {\n /** Indicates if the scroll is at the start of the sliding panel. */\n const isScrollAtStart = ref(true);\n /** Indicates if the scroll is at the end of the sliding panel. */\n const isScrollAtEnd = ref(true);\n const scrollContainerRef = ref<HTMLDivElement>();\n\n /**\n * Updates the values of the scroll positions to show or hide the buttons depending on it.\n *\n * @remarks The 2px extra is to fix some cases in some resolutions where the scroll + client\n * size is less than the scroll width even when the scroll is at the end.\n */\n function updateScrollPosition() {\n if (scrollContainerRef.value) {\n const { scrollLeft, clientWidth, scrollWidth } = scrollContainerRef.value;\n isScrollAtStart.value = !scrollLeft;\n isScrollAtEnd.value = scrollLeft + clientWidth + 2 >= scrollWidth;\n }\n }\n\n /**\n * Debounced version of the {@link SlidingPanel.updateScrollPosition} method.\n */\n const debouncedUpdateScroll = useDebounce(updateScrollPosition, 50, { leading: true });\n\n /**\n * Resets the scroll and updates the values of the scroll for the buttons to react.\n */\n const debouncedRestoreAndUpdateScroll = useDebounce(\n () => {\n scrollContainerRef.value!.scroll({ left: 0, behavior: 'smooth' });\n updateScrollPosition();\n },\n 50,\n { leading: true }\n );\n\n /**\n * Scrolls the wrapper element towards the provided scroll value.\n *\n * @param scrollValue - The value the scroll will go towards.\n */\n function scrollTo(scrollValue: number) {\n scrollContainerRef.value!.scrollBy({\n left: scrollValue * props.scrollFactor,\n behavior: 'smooth'\n });\n }\n\n /** Scrolls the wrapper element to the left. */\n function scrollLeft() {\n scrollTo(-scrollContainerRef.value!.clientWidth);\n }\n\n /** Scrolls the wrapper element to the right. */\n function scrollRight() {\n scrollTo(scrollContainerRef.value!.clientWidth);\n }\n\n /** CSS classes to apply based on the scroll position. */\n const cssClasses = computed(() => ({\n 'x-sliding-panel-at-start': isScrollAtStart.value,\n 'x-sliding-panel-at-end': isScrollAtEnd.value\n }));\n\n let resizeObserver: ResizeObserver;\n let contentChangedObserver: MutationObserver;\n\n /**\n * Initialises browser platform code:\n * - Creates a mutation observer to detect content changes and reset scroll position.\n * - Stores initial size and scroll position values.\n */\n onMounted(() => {\n resizeObserver = new ResizeObserver(debouncedUpdateScroll);\n resizeObserver.observe(scrollContainerRef.value!);\n contentChangedObserver = new MutationObserver(debouncedRestoreAndUpdateScroll);\n\n watch(\n () => props.resetOnContentChange,\n shouldReset => {\n if (shouldReset) {\n contentChangedObserver.observe(scrollContainerRef.value!, {\n subtree: true,\n childList: true,\n attributes: false,\n characterData: false\n });\n } else {\n contentChangedObserver.disconnect();\n }\n },\n { immediate: true }\n );\n\n updateScrollPosition();\n });\n\n onBeforeUnmount(() => {\n contentChangedObserver.disconnect();\n resizeObserver.disconnect();\n });\n\n return {\n cssClasses,\n debouncedUpdateScroll,\n scrollContainerRef,\n scrollLeft,\n scrollRight,\n slots\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-sliding-panel {\n align-items: center;\n display: flex;\n flex-flow: row nowrap;\n position: relative;\n }\n\n .x-sliding-panel__button {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: all ease-out 0.2s;\n z-index: 2; /* To overlay the design system gradient with z-index:1 */\n }\n .x-sliding-panel-button-left {\n left: 0;\n }\n .x-sliding-panel-button-right {\n right: 0;\n }\n\n .x-sliding-panel__scroll {\n display: flex;\n flex: 100%;\n flex-flow: row nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE */\n }\n\n /* Chrome, Edge & Safari */\n .x-sliding-panel__scroll::-webkit-scrollbar {\n display: none;\n }\n\n .x-sliding-panel__scroll > * {\n flex: 0 0 auto;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-start) .x-sliding-panel-button-left {\n opacity: 1;\n pointer-events: all;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-end) .x-sliding-panel-button-right {\n opacity: 1;\n pointer-events: all;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\nSimplest implementation of the component, just a list-based component inside its slot.\n\n```vue\n<template>\n <SlidingPanel>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n### Play with props\n\n#### Modifying scroll buttons travel distance\n\nEdit how much the scroll travels when navigating with the buttons by changing the `scrollFactor`\nprop.\n\n```vue\n<template>\n <SlidingPanel :scrollFactor=\"1.5\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Hiding scroll buttons\n\nHide the navigational buttons completely by setting the `showButtons` prop to `false`. This is\nintended to be used when other scrolling options are available, like in mobile, where you can scroll\njust by swiping.\n\n```vue\n<template>\n <SlidingPanel :showButtons=\"false\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Customizing the content with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\nThe `scrollContainerClass` prop can be used to add classes to the scroll content.\n\n```vue\n<template>\n <SlidingPanel buttonClass=\"x-button--round\" scrollContainerClass=\"x-sliding-panel-fade\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Disabling reset the scroll when content changes\n\nBy default, whenever the content of the sliding panel changes, it auto resets its scroll position.\nYou can disable this behavior setting the `resetOnContentChange` prop to `false`.\n\n```vue\n<template>\n <div>\n <button @click=\"items++\">Add item</button>\n <label>\n <input type=\"checkbox\" v-model=\"resetOnContentChange\" />\n Reset content onchange\n </label>\n <SlidingPanel :resetOnContentChange=\"resetOnContentChange\">\n <div class=\"item\" v-for=\"item in items\" :key=\"item\">Item {{ item }}</div>\n </SlidingPanel>\n </div>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n },\n data() {\n return {\n items: 4,\n resetOnContentChange: false\n };\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n## Extending the component\n\n### Overriding Button content\n\nBy default the buttons show an arrow depicting the direction the scroll would go to when clicked,\nbut this content can be customized with anything, from characters to SVG and images.\n\n```vue\n<template>\n <SlidingPanel>\n <template #sliding-panel-left-button>Left</template>\n <template #default>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </template>\n <template #sliding-panel-right-button>Right</template>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n</docs>\n"],"names":[],"mappings":";;;AAyCE;;;;;;;;;AASE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;AACL;;AAEE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,GAAE;AACZ,SAAA;;AAED,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAG;AACb,SAAA;AACD;;;AAGE;AACF,QAAA,oBAAoB,EAAE;AACpB,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAG;AACb,SAAA;AACD,QAAA,WAAW,EAAE,MAAM;AACnB,QAAA,oBAAoB,EAAE,MAAK;AAC5B,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;;AAEpB,QAAA,MAAM,eAAgB,GAAE,GAAG,CAAC,IAAI,CAAC,CAAA;;AAEjC,QAAA,MAAM,aAAc,GAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AAC/B,QAAA,MAAM,qBAAqB,GAAG,EAAkB,CAAA;AAEhD;;;;;AAKE;AACF,QAAA,SAAS,oBAAoB,GAAA;YAC3B,IAAI,kBAAkB,CAAC,KAAK,EAAE;gBAC5B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAY,EAAA,GAAI,kBAAkB,CAAC,KAAK,CAAA;AACzE,gBAAA,eAAe,CAAC,KAAM,GAAE,CAAC,UAAU,CAAA;gBACnC,aAAa,CAAC,KAAM,GAAE,UAAW,GAAE,WAAY,GAAE,KAAK,WAAW,CAAA;AACnE,aAAA;SACF;AAEA;;AAEE;AACF,QAAA,MAAM,qBAAoB,GAAI,WAAW,CAAC,oBAAoB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAG,EAAG,CAAC,CAAA;AAEtF;;AAEE;AACF,QAAA,MAAM,+BAA8B,GAAI,WAAW,CACjD,MAAM;AACJ,YAAA,kBAAkB,CAAC,KAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAS,EAAC,CAAC,CAAA;AACjE,YAAA,oBAAoB,EAAE,CAAA;SACvB,EACD,EAAE,EACF,EAAE,OAAO,EAAE,IAAK,EAAA,CACjB,CAAA;AAED;;;;AAIE;QACF,SAAS,QAAQ,CAAC,WAAmB,EAAA;AACnC,YAAA,kBAAkB,CAAC,KAAM,CAAC,QAAQ,CAAC;AACjC,gBAAA,IAAI,EAAE,WAAY,GAAE,KAAK,CAAC,YAAY;AACtC,gBAAA,QAAQ,EAAE,QAAO;AAClB,aAAA,CAAC,CAAA;SACJ;;AAGA,QAAA,SAAS,UAAU,GAAA;YACjB,QAAQ,CAAC,CAAC,kBAAkB,CAAC,KAAM,CAAC,WAAW,CAAC,CAAA;SAClD;;AAGA,QAAA,SAAS,WAAW,GAAA;AAClB,YAAA,QAAQ,CAAC,kBAAkB,CAAC,KAAM,CAAC,WAAW,CAAC,CAAA;SACjD;;AAGA,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,OAAO;YACjC,0BAA0B,EAAE,eAAe,CAAC,KAAK;YACjD,wBAAwB,EAAE,aAAa,CAAC,KAAI;AAC7C,SAAA,CAAC,CAAC,CAAA;AAEH,QAAA,IAAI,cAA8B,CAAA;AAClC,QAAA,IAAI,sBAAwC,CAAA;AAE5C;;;;AAIE;QACF,SAAS,CAAC,MAAM;AACd,YAAA,iBAAiB,IAAI,cAAc,CAAC,qBAAqB,CAAC,CAAA;AAC1D,YAAA,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAA;AACjD,YAAA,sBAAqB,GAAI,IAAI,gBAAgB,CAAC,+BAA+B,CAAC,CAAA;YAE9E,KAAK,CACH,MAAM,KAAK,CAAC,oBAAoB,EAChC,WAAY,IAAG;AACb,gBAAA,IAAI,WAAW,EAAE;AACf,oBAAA,sBAAsB,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAM,EAAE;AACxD,wBAAA,OAAO,EAAE,IAAI;AACb,wBAAA,SAAS,EAAE,IAAI;AACf,wBAAA,UAAU,EAAE,KAAK;AACjB,wBAAA,aAAa,EAAE,KAAI;AACpB,qBAAA,CAAC,CAAA;AACF,iBAAA;AAAK,qBAAA;oBACL,sBAAsB,CAAC,UAAU,EAAE,CAAA;AACrC,iBAAA;AACF,aAAC,EACD,EAAE,SAAS,EAAE,IAAK,EAAA,CACnB,CAAA;AAED,YAAA,oBAAoB,EAAE,CAAA;AACxB,SAAC,CAAC,CAAA;QAEF,eAAe,CAAC,MAAM;YACpB,sBAAsB,CAAC,UAAU,EAAE,CAAA;YACnC,cAAc,CAAC,UAAU,EAAE,CAAA;AAC7B,SAAC,CAAC,CAAA;QAEF,OAAO;YACL,UAAU;YACV,qBAAqB;YACrB,kBAAkB;YAClB,UAAU;YACV,WAAW;YACX,KAAI;SACL,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"sliding-panel.vue2.js","sources":["../../../src/components/sliding-panel.vue"],"sourcesContent":["<template>\n <div v-if=\"slots.default\" class=\"x-sliding-panel\" :class=\"cssClasses\" data-test=\"sliding-panel\">\n <button\n v-if=\"showButtons\"\n @click=\"scrollLeft\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-left\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-left-button\"\n >\n <!-- @slot Left button content -->\n <slot name=\"sliding-panel-left-button\">ᐸ</slot>\n </button>\n <div\n ref=\"scrollContainerRef\"\n @scroll=\"debouncedUpdateScroll\"\n @transitionend=\"debouncedUpdateScroll\"\n @animationend=\"debouncedUpdateScroll\"\n :class=\"scrollContainerClass\"\n class=\"x-sliding-panel__scroll\"\n data-test=\"sliding-panel-scroll\"\n >\n <!-- @slot (Required) Sliding panel content -->\n <slot />\n </div>\n <button\n v-if=\"showButtons\"\n @click=\"scrollRight\"\n class=\"x-sliding-panel__button x-button x-sliding-panel-button-right\"\n :class=\"buttonClass\"\n data-test=\"sliding-panel-right-button\"\n >\n <!-- @slot Right button content -->\n <slot name=\"sliding-panel-right-button\">ᐳ</slot>\n </button>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onBeforeUnmount, onMounted, PropType, ref, watch } from 'vue';\n import { useDebounce } from '../composables/use-debounce';\n import { VueCSSClasses } from '../utils/types';\n\n /**\n * This component allows for any other component or element inside it to be horizontally\n * navigable. It also implements customizable buttons as well as other minor customizations to its\n * general behavior.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\n export default defineComponent({\n name: 'SlidingPanel',\n props: {\n /**\n * Scroll factor that will dictate how much the scroll moves when pressing a navigation button.\n */\n scrollFactor: {\n type: Number,\n default: 0.7\n },\n /** Would make the navigation buttons visible when they're needed or always hide them. */\n showButtons: {\n type: Boolean,\n default: true\n },\n /**\n * When true, whenever the DOM content in the sliding panel slot changes, it will reset\n * the scroll position to 0.\n */\n resetOnContentChange: {\n type: Boolean,\n default: true\n },\n buttonClass: { type: [String, Object, Array] as PropType<VueCSSClasses> },\n scrollContainerClass: { type: [String, Object, Array] as PropType<VueCSSClasses> }\n },\n setup(props, { slots }) {\n /** Indicates if the scroll is at the start of the sliding panel. */\n const isScrollAtStart = ref(true);\n /** Indicates if the scroll is at the end of the sliding panel. */\n const isScrollAtEnd = ref(true);\n const scrollContainerRef = ref<HTMLDivElement>();\n\n /**\n * Updates the values of the scroll positions to show or hide the buttons depending on it.\n *\n * @remarks The 2px extra is to fix some cases in some resolutions where the scroll + client\n * size is less than the scroll width even when the scroll is at the end.\n */\n function updateScrollPosition() {\n if (scrollContainerRef.value) {\n const { scrollLeft, clientWidth, scrollWidth } = scrollContainerRef.value;\n isScrollAtStart.value = !scrollLeft;\n isScrollAtEnd.value = scrollLeft + clientWidth + 2 >= scrollWidth;\n }\n }\n\n /**\n * Debounced version of the {@link SlidingPanel.updateScrollPosition} method.\n */\n const debouncedUpdateScroll = useDebounce(updateScrollPosition, 50, { leading: true });\n\n /**\n * Resets the scroll and updates the values of the scroll for the buttons to react.\n */\n const debouncedRestoreAndUpdateScroll = useDebounce(\n () => {\n scrollContainerRef.value!.scroll({ left: 0, behavior: 'smooth' });\n updateScrollPosition();\n },\n 50,\n { leading: true }\n );\n\n /**\n * Scrolls the wrapper element towards the provided scroll value.\n *\n * @param scrollValue - The value the scroll will go towards.\n */\n function scrollTo(scrollValue: number) {\n scrollContainerRef.value!.scrollBy({\n left: scrollValue * props.scrollFactor,\n behavior: 'smooth'\n });\n }\n\n /** Scrolls the wrapper element to the left. */\n function scrollLeft() {\n scrollTo(-scrollContainerRef.value!.clientWidth);\n }\n\n /** Scrolls the wrapper element to the right. */\n function scrollRight() {\n scrollTo(scrollContainerRef.value!.clientWidth);\n }\n\n /** CSS classes to apply based on the scroll position. */\n const cssClasses = computed(() => ({\n 'x-sliding-panel-at-start': isScrollAtStart.value,\n 'x-sliding-panel-at-end': isScrollAtEnd.value\n }));\n\n let resizeObserver: ResizeObserver;\n let contentChangedObserver: MutationObserver;\n\n /**\n * Initialises browser platform code:\n * - Creates a mutation observer to detect content changes and reset scroll position.\n * - Stores initial size and scroll position values.\n */\n onMounted(() => {\n resizeObserver = new ResizeObserver(debouncedUpdateScroll);\n resizeObserver.observe(scrollContainerRef.value!);\n contentChangedObserver = new MutationObserver(debouncedRestoreAndUpdateScroll);\n\n watch(\n () => props.resetOnContentChange,\n shouldReset => {\n if (shouldReset) {\n contentChangedObserver.observe(scrollContainerRef.value!, {\n subtree: true,\n childList: true,\n attributes: false,\n characterData: false\n });\n } else {\n contentChangedObserver.disconnect();\n }\n },\n { immediate: true }\n );\n\n updateScrollPosition();\n });\n\n onBeforeUnmount(() => {\n contentChangedObserver.disconnect();\n resizeObserver.disconnect();\n });\n\n return {\n cssClasses,\n debouncedUpdateScroll,\n scrollContainerRef,\n scrollLeft,\n scrollRight,\n slots\n };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-sliding-panel {\n align-items: center;\n display: flex;\n flex-flow: row nowrap;\n position: relative;\n }\n\n .x-sliding-panel__button {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: all ease-out 0.2s;\n z-index: 2; /* To overlay the design system gradient with z-index:1 */\n }\n .x-sliding-panel-button-left {\n left: 0;\n }\n .x-sliding-panel-button-right {\n right: 0;\n }\n\n .x-sliding-panel__scroll {\n display: flex;\n flex: 100%;\n flex-flow: row nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE */\n }\n\n /* Chrome, Edge & Safari */\n .x-sliding-panel__scroll::-webkit-scrollbar {\n display: none;\n }\n\n .x-sliding-panel__scroll > * {\n flex: 0 0 auto;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-start) .x-sliding-panel-button-left {\n opacity: 1;\n pointer-events: all;\n }\n\n /* prettier-ignore */\n .x-sliding-panel:not(.x-sliding-panel-show-buttons-on-hover):not(.x-sliding-panel-at-end) .x-sliding-panel-button-right {\n opacity: 1;\n pointer-events: all;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\nSimplest implementation of the component, just a list-based component inside its slot.\n\n```vue\n<template>\n <SlidingPanel>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n### Play with props\n\n#### Modifying scroll buttons travel distance\n\nEdit how much the scroll travels when navigating with the buttons by changing the `scrollFactor`\nprop.\n\n```vue\n<template>\n <SlidingPanel :scrollFactor=\"1.5\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Hiding scroll buttons\n\nHide the navigational buttons completely by setting the `showButtons` prop to `false`. This is\nintended to be used when other scrolling options are available, like in mobile, where you can scroll\njust by swiping.\n\n```vue\n<template>\n <SlidingPanel :showButtons=\"false\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Customizing the content with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\nThe `scrollContainerClass` prop can be used to add classes to the scroll content.\n\n```vue\n<template>\n <SlidingPanel buttonClass=\"x-button--round\" scrollContainerClass=\"x-sliding-panel-fade\">\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n#### Disabling reset the scroll when content changes\n\nBy default, whenever the content of the sliding panel changes, it auto resets its scroll position.\nYou can disable this behavior setting the `resetOnContentChange` prop to `false`.\n\n```vue\n<template>\n <div>\n <button @click=\"items++\">Add item</button>\n <label>\n <input type=\"checkbox\" v-model=\"resetOnContentChange\" />\n Reset content onchange\n </label>\n <SlidingPanel :resetOnContentChange=\"resetOnContentChange\">\n <div class=\"item\" v-for=\"item in items\" :key=\"item\">Item {{ item }}</div>\n </SlidingPanel>\n </div>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n },\n data() {\n return {\n items: 4,\n resetOnContentChange: false\n };\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n\n## Extending the component\n\n### Overriding Button content\n\nBy default the buttons show an arrow depicting the direction the scroll would go to when clicked,\nbut this content can be customized with anything, from characters to SVG and images.\n\n```vue\n<template>\n <SlidingPanel>\n <template #sliding-panel-left-button>Left</template>\n <template #default>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n <div class=\"item\">Item 4</div>\n </template>\n <template #sliding-panel-right-button>Right</template>\n </SlidingPanel>\n</template>\n\n<script>\n import { SlidingPanel } from '@empathyco/x-components';\n\n export default {\n name: 'SlidingPanelDemo',\n components: {\n SlidingPanel\n }\n };\n</script>\n\n<style>\n .x-sliding-panel {\n width: 200px;\n }\n\n .item {\n display: inline-block;\n width: 100px;\n }\n</style>\n```\n</docs>\n"],"names":[],"mappings":";;;AA0CE;;;;;;;;;AASE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;AACL;;AAEE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,GAAE;AACZ,SAAA;;AAED,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAG;AACb,SAAA;AACD;;;AAGE;AACF,QAAA,oBAAoB,EAAE;AACpB,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAG;AACb,SAAA;QACD,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAA8B;QACzE,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAA6B,EAAA;AAClF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;;AAEpB,QAAA,MAAM,eAAgB,GAAE,GAAG,CAAC,IAAI,CAAC,CAAA;;AAEjC,QAAA,MAAM,aAAc,GAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AAC/B,QAAA,MAAM,qBAAqB,GAAG,EAAkB,CAAA;AAEhD;;;;;AAKE;AACF,QAAA,SAAS,oBAAoB,GAAA;YAC3B,IAAI,kBAAkB,CAAC,KAAK,EAAE;gBAC5B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAY,EAAA,GAAI,kBAAkB,CAAC,KAAK,CAAA;AACzE,gBAAA,eAAe,CAAC,KAAM,GAAE,CAAC,UAAU,CAAA;gBACnC,aAAa,CAAC,KAAM,GAAE,UAAW,GAAE,WAAY,GAAE,KAAK,WAAW,CAAA;AACnE,aAAA;SACF;AAEA;;AAEE;AACF,QAAA,MAAM,qBAAoB,GAAI,WAAW,CAAC,oBAAoB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAG,EAAG,CAAC,CAAA;AAEtF;;AAEE;AACF,QAAA,MAAM,+BAA8B,GAAI,WAAW,CACjD,MAAM;AACJ,YAAA,kBAAkB,CAAC,KAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAS,EAAC,CAAC,CAAA;AACjE,YAAA,oBAAoB,EAAE,CAAA;SACvB,EACD,EAAE,EACF,EAAE,OAAO,EAAE,IAAK,EAAA,CACjB,CAAA;AAED;;;;AAIE;QACF,SAAS,QAAQ,CAAC,WAAmB,EAAA;AACnC,YAAA,kBAAkB,CAAC,KAAM,CAAC,QAAQ,CAAC;AACjC,gBAAA,IAAI,EAAE,WAAY,GAAE,KAAK,CAAC,YAAY;AACtC,gBAAA,QAAQ,EAAE,QAAO;AAClB,aAAA,CAAC,CAAA;SACJ;;AAGA,QAAA,SAAS,UAAU,GAAA;YACjB,QAAQ,CAAC,CAAC,kBAAkB,CAAC,KAAM,CAAC,WAAW,CAAC,CAAA;SAClD;;AAGA,QAAA,SAAS,WAAW,GAAA;AAClB,YAAA,QAAQ,CAAC,kBAAkB,CAAC,KAAM,CAAC,WAAW,CAAC,CAAA;SACjD;;AAGA,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,OAAO;YACjC,0BAA0B,EAAE,eAAe,CAAC,KAAK;YACjD,wBAAwB,EAAE,aAAa,CAAC,KAAI;AAC7C,SAAA,CAAC,CAAC,CAAA;AAEH,QAAA,IAAI,cAA8B,CAAA;AAClC,QAAA,IAAI,sBAAwC,CAAA;AAE5C;;;;AAIE;QACF,SAAS,CAAC,MAAM;AACd,YAAA,iBAAiB,IAAI,cAAc,CAAC,qBAAqB,CAAC,CAAA;AAC1D,YAAA,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAA;AACjD,YAAA,sBAAqB,GAAI,IAAI,gBAAgB,CAAC,+BAA+B,CAAC,CAAA;YAE9E,KAAK,CACH,MAAM,KAAK,CAAC,oBAAoB,EAChC,WAAY,IAAG;AACb,gBAAA,IAAI,WAAW,EAAE;AACf,oBAAA,sBAAsB,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAM,EAAE;AACxD,wBAAA,OAAO,EAAE,IAAI;AACb,wBAAA,SAAS,EAAE,IAAI;AACf,wBAAA,UAAU,EAAE,KAAK;AACjB,wBAAA,aAAa,EAAE,KAAI;AACpB,qBAAA,CAAC,CAAA;AACF,iBAAA;AAAK,qBAAA;oBACL,sBAAsB,CAAC,UAAU,EAAE,CAAA;AACrC,iBAAA;AACF,aAAC,EACD,EAAE,SAAS,EAAE,IAAK,EAAA,CACnB,CAAA;AAED,YAAA,oBAAoB,EAAE,CAAA;AACxB,SAAC,CAAC,CAAA;QAEF,eAAe,CAAC,MAAM;YACpB,sBAAsB,CAAC,UAAU,EAAE,CAAA;YACnC,cAAc,CAAC,UAAU,EAAE,CAAA;AAC7B,SAAC,CAAC,CAAA;QAEF,OAAO;YACL,UAAU;YACV,qBAAqB;YACrB,kBAAkB;YAClB,UAAU;YACV,WAAW;YACX,KAAI;SACL,CAAA;KACH;AACD,CAAA,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-suggestion.vue2.js';
|
|
2
|
-
import { resolveComponent, openBlock, createElementBlock, normalizeClass,
|
|
2
|
+
import { resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, normalizeProps, guardReactiveProps, createVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
3
3
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
const _hoisted_1 = {
|
|
@@ -16,7 +16,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
16
16
|
class: normalizeClass(_ctx.dynamicCSSClasses)
|
|
17
17
|
},
|
|
18
18
|
[
|
|
19
|
-
createCommentVNode("\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n "),
|
|
20
19
|
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ query: _ctx.query, suggestion: _ctx.suggestion, filter: _ctx.filter })), () => [
|
|
21
20
|
createVNode(_component_Highlight, {
|
|
22
21
|
class: "x-suggestion__query",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-suggestion.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" @click=\"emitEvents\" :class=\"dynamicCSSClasses\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n export default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: ''\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean\n }\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null);\n\n const $x = use$x();\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter\n );\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {};\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent\n };\n });\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature\n });\n });\n };\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated\n );\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value\n }));\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## See it in action\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" />\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facet: {\n namedModel: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10\n }\n ]\n }\n }\n };\n }\n };\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </BaseSuggestion>\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak'\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createElementBlock","_normalizeClass","
|
|
1
|
+
{"version":3,"file":"base-suggestion.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" @click=\"emitEvents\" :class=\"dynamicCSSClasses\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n export default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: ''\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean\n }\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null);\n\n const $x = use$x();\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter\n );\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {};\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent\n };\n });\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature\n });\n });\n };\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated\n );\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value\n }));\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## See it in action\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" />\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facet: {\n namedModel: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10\n }\n ]\n }\n }\n };\n }\n };\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </BaseSuggestion>\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak'\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createElementBlock","_normalizeClass","_normalizeProps","_guardReactiveProps","_createVNode","suggestion","filter"],"mappings":";;;;MAU0B,UAAM,GAAA;AAAA,EAAA,GAAA,EAAA,CAAA;;;;+BAT9BA,gBAWS,CAAA,WAAA,CAAA,CAAA;SAXSC,SAAK,EAAA,EAAAC,kBAAA;AAAA,IAAA,QAAA;AAAA,IAAE;AAAA,MAAa,GAAK,EAAA,IAAA;AAAA,MAAA,OAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAA,IAAA,CAAA,UAAA,IAAA,IAAA,CAAA,UAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAOzC,MAAA,KAAA,EAAAC,cAAA,CAGO,IAXX,CAAA,iBAAA,CAAA;AAAA,KAAA;;iBASuB,IAAqB,CAAA,MAAA,EAAA,SAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,KAAA,EAAA,IAAA,CAAA,KAAA,EAAA,UAAA,EAAA,IAAA,CAAA,UAAA,EAAA,MAAA,EAAA,IAAA,CAAA,MAAA,EAAA,CAAA,CAAA,EAAA,MAAA;AAAA,QAAAC,WAAA,CAAQC,oBAAgB,EAAA;AAAA,UAAG,KAAA,EAAA,qBAAA;AAAA,UAAA,IAAA,EAAA,IAAA,CAAA,UAAA,CAAA,KAAA;UACrDC,SAAM,EAAA,IAAA,CAAA,KAAA;AAAA,SAAA,EAAA,IAAA,EAAA,CAAA,EAAlB,CAA0E,MAAA,EAAA,WAAA,CAAA,CAAA;AAAA,QAVhF,IAAA,CAAA,MAAA,IAAAP,SAAA,EAAA,EAAAC,kBAAA;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sfc_main from './base-suggestions.vue2.js';
|
|
2
|
-
import { openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, normalizeClass,
|
|
2
|
+
import { openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, normalizeClass, renderSlot, mergeProps, createCommentVNode } from 'vue';
|
|
3
3
|
import './base-suggestions.vue3.js';
|
|
4
4
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
@@ -22,7 +22,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
22
22
|
"data-test": "suggestion-item"
|
|
23
23
|
},
|
|
24
24
|
[
|
|
25
|
-
createCommentVNode("\n @slot (Required) List item content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {number} index - Suggestion index\n @binding {Filter | undefined} filter - Suggestion's filter\n "),
|
|
26
25
|
renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, { suggestion, index, filter: _ctx.getSuggestionFilter(suggestion) }), void 0, true)
|
|
27
26
|
],
|
|
28
27
|
2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-suggestions.vue.js","sources":["../../../../src/components/suggestions/base-suggestions.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"suggestions.length\" tag=\"ul\" class=\"x-suggestions\">\n <li\n v-for=\"(suggestion, index) in suggestionsToRender\"\n :key=\"suggestionsKeys[index]\"\n class=\"x-suggestions__item\"\n :class=\"suggestionItemClass\"\n data-test=\"suggestion-item\"\n >\n <!--\n @slot (Required) List item content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {number} index - Suggestion index\n @binding {Filter | undefined} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ suggestion, index, filter: getSuggestionFilter(suggestion) }\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { Suggestion, Facet } from '@empathyco/x-types';\n import { isArrayEmpty } from '../../utils/array';\n import { AnimationProp } from '../../types';\n\n /**\n * Paints a list of suggestions passed in by prop. Requires a component for a single suggestion\n * in the default slot for working.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseSuggestions',\n props: {\n /**\n * The list of suggestions to render.\n *\n * @public\n */\n suggestions: {\n type: Array as PropType<Suggestion[]>,\n required: true\n },\n /**\n * Animation component that will be used to animate the suggestion.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n },\n /**\n * Number of suggestions to be rendered.\n *\n * @public\n */\n maxItemsToRender: Number,\n /**\n * Boolean value to indicate if the facets should be rendered.\n *\n * @public\n */\n showFacets: {\n type: Boolean,\n default: false\n },\n /**\n * When `showFacets` property of `BaseSuggestions` component is true, it indicates if the suggestion without\n * filter should be rendered.\n *\n * @public\n */\n showPlainSuggestion: {\n type: Boolean,\n default: false\n },\n /** Class inherited by content element. */\n suggestionItemClass: String\n },\n setup: function (props) {\n /**\n * Creates a suggestion for each one of the filter inside each facet.\n *\n * @param suggestion - Suggestion to expand.\n * @returns A list of suggestions, each one with a single filter.\n *\n * @internal\n */\n const expandSuggestionFilters = (suggestion: Suggestion): Suggestion[] => {\n return (\n suggestion.facets?.flatMap(facet =>\n facet.filters.map(filter => ({\n ...suggestion,\n facets: [{ ...facet, filters: [filter] }]\n }))\n ) ?? []\n );\n };\n\n /**\n * Creates a list of suggestions to render based on the configuration of this component.\n *\n * @returns - The list of suggestions to be rendered by this component.\n *\n * @internal\n */\n const suggestionsToRender = computed(() =>\n props.suggestions\n .flatMap(suggestion =>\n props.showFacets && suggestion.facets?.length\n ? props.showPlainSuggestion\n ? [{ ...suggestion, facets: [] }, ...expandSuggestionFilters(suggestion)]\n : expandSuggestionFilters(suggestion)\n : { ...suggestion, facets: [] }\n )\n .slice(0, props.maxItemsToRender)\n );\n\n /**\n * Generates a string from the given facet.\n *\n * @param facet - The facet to reduce to a string.\n * @returns - A string representing the facet.\n * @internal\n */\n const getFacetKey = (facet: Facet) => facet.filters.map(filter => filter.id).join('&');\n\n /**\n * Generates a string from the given facets.\n *\n * @param facets - The list of facets to reduce to a string.\n * @returns - A string representing the list of facets.\n * @internal\n */\n const getFacetsKey = (facets: Facet[]) => facets.map(getFacetKey).join('&');\n\n /**\n * An array with the unique keys for each suggestion. Required by the `v-for` loop.\n *\n * @returns An array with the unique keys of the suggestions.\n * @internal\n */\n const suggestionsKeys = computed(() =>\n suggestionsToRender.value.map(suggestion =>\n isArrayEmpty(suggestion.facets)\n ? suggestion.query\n : `${suggestion.query}-in-${getFacetsKey(suggestion.facets)}`\n )\n );\n\n /**\n * Returns the filter contained by the suggestion.\n *\n * @param suggestion - Suggestion containing the filter.\n * @returns The suggestion filter.\n * @internal\n */\n const getSuggestionFilter = (suggestion: Suggestion) => suggestion.facets?.[0]?.filters[0];\n\n return { suggestionsToRender, suggestionsKeys, getSuggestionFilter };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-suggestions {\n list-style-type: none;\n }\n\n .x-suggestions,\n .x-suggestions__item {\n display: flex;\n flex-flow: column nowrap;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nFor this component to work, you will need to set a list of suggestions as prop, and also to\nimplement the component for single suggestion, which handles the click event. In the following\nexample, the suggestions are retrieved from a property called `suggestions`, and the implementation\nof the suggestion component is a simple `button`, that calls the `emitSuggestionSelected` method\nwhen clicked.\n\n```vue\n<BaseSuggestions :suggestions=\"suggestions\">\n <template #default=\"{ suggestion }\">\n <button @click=\"emitSuggestionSelected($event, suggestion)\">\n {{ suggestion.query }}\n </button>\n </template>\n</BaseSuggestions>\n```\n\nFollowing the previous example, the component options object could be something like this:\n\n```js\nexport default {\n computed: {\n ...mapGetters(['x', 'querySuggestions'], { suggestions: 'suggestions' })\n },\n methods: {\n emitSuggestionSelected(event, suggestion) {\n this.$x.emit('UserAcceptedAQuery', suggestion.query, { target: event.target });\n this.$x.emit('UserSelectedAQuerySuggestion', suggestion, { target: event.target });\n }\n }\n};\n```\n\n### Play with props\n\nIn this example, the suggestions has been limited to render a maximum of 3 items. _Type \"puzzle\" or\nanother toy in the input field to try it out!_\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" :maxItemsToRender=\"3\" />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n\nIn this example, the filters of the suggestion will be rendered along with the query.\n\nThe `showPlainSuggestion` prop can be used to indicate if the suggestion without filter must be\nrendered along with the suggestion with filters.\n\nThis will render:\n\n- Chips //If `showPlainSuggestion` is true\n- Chips EXAMPLE\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" showFacets showPlainSuggestion />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [\n {\n id: 'exampleFacet',\n label: 'exampleFacet',\n modelName: 'SimpleFacet',\n filters: [\n {\n facetId: 'exampleFacet',\n id: '{!tag=exampleFacet}exampleFacet_60361120_64009600:\"EXAMPLE\"',\n label: 'EXAMPLE',\n selected: false,\n totalResults: 10,\n modelName: 'SimpleFilter'\n }\n ]\n }\n ],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n\nIn this example, the `contentClass` prop can be used to add classes to the suggestion item.\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" suggestionItemClass=\"x-custom-class\" />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["animation","_openBlock","_createBlock","_resolveDynamicComponent","suggestionsKeys","_Fragment","_renderList","_createElementBlock","_normalizeClass","_createCommentVNode"],"mappings":";;;;;AACE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EADF,MACkBA,EAAAA,MAAAA,EAAAA,KAAAA,EAAAA,QAAAA,EAAAA;SADlB,IAC+D,CAAA,WAAA,CAAA,MAAA,IAAAC,SAAA,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAC,GAAK,EAAA,CAAA;AAAA,IAAA,GAAA,EAAA,IAAA;AADrE,IAAA,KAAA,EAAA,eAAA;AAAA,GAAA,EAAA;;AAIYC,OAAAA,SAAAA,CAAAA,IAAAA,CAAAA,EAAAA,kBAAAA;AAAAA,QAAqBC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,mBAAA,EAAA,CAAA,UAAA,EAAA,KAAA,KAAA;iBACtBL,SALX,EAAA,EAAAM,kBAAA;AAAA,YAKY,IAAA;AAAA,YAAqB;AAAA,cAE3B,0BAAU,KAAiB,CAAA;AAAA,cAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,qBAAA,EAAA,IAAA,CAAA,mBAAA,CAAA,CAAA;AAE3B,cAAA,WAAA,EAAA,iBAAA;AAAA,aAAA;AAMA,YAAA;AAAA,cAAAC,kBAAA,CAAA,uPAAA,CAAA;;;;;;AAfN,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,CAAA,IAAAA,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"base-suggestions.vue.js","sources":["../../../../src/components/suggestions/base-suggestions.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"suggestions.length\" tag=\"ul\" class=\"x-suggestions\">\n <li\n v-for=\"(suggestion, index) in suggestionsToRender\"\n :key=\"suggestionsKeys[index]\"\n class=\"x-suggestions__item\"\n :class=\"suggestionItemClass\"\n data-test=\"suggestion-item\"\n >\n <!--\n @slot (Required) List item content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {number} index - Suggestion index\n @binding {Filter | undefined} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ suggestion, index, filter: getSuggestionFilter(suggestion) }\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { Suggestion, Facet } from '@empathyco/x-types';\n import { isArrayEmpty } from '../../utils/array';\n import { AnimationProp } from '../../types';\n\n /**\n * Paints a list of suggestions passed in by prop. Requires a component for a single suggestion\n * in the default slot for working.\n *\n * @public\n */\n export default defineComponent({\n name: 'BaseSuggestions',\n props: {\n /**\n * The list of suggestions to render.\n *\n * @public\n */\n suggestions: {\n type: Array as PropType<Suggestion[]>,\n required: true\n },\n /**\n * Animation component that will be used to animate the suggestion.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul'\n },\n /**\n * Number of suggestions to be rendered.\n *\n * @public\n */\n maxItemsToRender: Number,\n /**\n * Boolean value to indicate if the facets should be rendered.\n *\n * @public\n */\n showFacets: {\n type: Boolean,\n default: false\n },\n /**\n * When `showFacets` property of `BaseSuggestions` component is true, it indicates if the suggestion without\n * filter should be rendered.\n *\n * @public\n */\n showPlainSuggestion: {\n type: Boolean,\n default: false\n },\n /** Class inherited by content element. */\n suggestionItemClass: String\n },\n setup: function (props) {\n /**\n * Creates a suggestion for each one of the filter inside each facet.\n *\n * @param suggestion - Suggestion to expand.\n * @returns A list of suggestions, each one with a single filter.\n *\n * @internal\n */\n const expandSuggestionFilters = (suggestion: Suggestion): Suggestion[] => {\n return (\n suggestion.facets?.flatMap(facet =>\n facet.filters.map(filter => ({\n ...suggestion,\n facets: [{ ...facet, filters: [filter] }]\n }))\n ) ?? []\n );\n };\n\n /**\n * Creates a list of suggestions to render based on the configuration of this component.\n *\n * @returns - The list of suggestions to be rendered by this component.\n *\n * @internal\n */\n const suggestionsToRender = computed(() =>\n props.suggestions\n .flatMap(suggestion =>\n props.showFacets && suggestion.facets?.length\n ? props.showPlainSuggestion\n ? [{ ...suggestion, facets: [] }, ...expandSuggestionFilters(suggestion)]\n : expandSuggestionFilters(suggestion)\n : { ...suggestion, facets: [] }\n )\n .slice(0, props.maxItemsToRender)\n );\n\n /**\n * Generates a string from the given facet.\n *\n * @param facet - The facet to reduce to a string.\n * @returns - A string representing the facet.\n * @internal\n */\n const getFacetKey = (facet: Facet) => facet.filters.map(filter => filter.id).join('&');\n\n /**\n * Generates a string from the given facets.\n *\n * @param facets - The list of facets to reduce to a string.\n * @returns - A string representing the list of facets.\n * @internal\n */\n const getFacetsKey = (facets: Facet[]) => facets.map(getFacetKey).join('&');\n\n /**\n * An array with the unique keys for each suggestion. Required by the `v-for` loop.\n *\n * @returns An array with the unique keys of the suggestions.\n * @internal\n */\n const suggestionsKeys = computed(() =>\n suggestionsToRender.value.map(suggestion =>\n isArrayEmpty(suggestion.facets)\n ? suggestion.query\n : `${suggestion.query}-in-${getFacetsKey(suggestion.facets)}`\n )\n );\n\n /**\n * Returns the filter contained by the suggestion.\n *\n * @param suggestion - Suggestion containing the filter.\n * @returns The suggestion filter.\n * @internal\n */\n const getSuggestionFilter = (suggestion: Suggestion) => suggestion.facets?.[0]?.filters[0];\n\n return { suggestionsToRender, suggestionsKeys, getSuggestionFilter };\n }\n });\n</script>\n\n<style lang=\"css\" scoped>\n .x-suggestions {\n list-style-type: none;\n }\n\n .x-suggestions,\n .x-suggestions__item {\n display: flex;\n flex-flow: column nowrap;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nFor this component to work, you will need to set a list of suggestions as prop, and also to\nimplement the component for single suggestion, which handles the click event. In the following\nexample, the suggestions are retrieved from a property called `suggestions`, and the implementation\nof the suggestion component is a simple `button`, that calls the `emitSuggestionSelected` method\nwhen clicked.\n\n```vue\n<BaseSuggestions :suggestions=\"suggestions\">\n <template #default=\"{ suggestion }\">\n <button @click=\"emitSuggestionSelected($event, suggestion)\">\n {{ suggestion.query }}\n </button>\n </template>\n</BaseSuggestions>\n```\n\nFollowing the previous example, the component options object could be something like this:\n\n```js\nexport default {\n computed: {\n ...mapGetters(['x', 'querySuggestions'], { suggestions: 'suggestions' })\n },\n methods: {\n emitSuggestionSelected(event, suggestion) {\n this.$x.emit('UserAcceptedAQuery', suggestion.query, { target: event.target });\n this.$x.emit('UserSelectedAQuerySuggestion', suggestion, { target: event.target });\n }\n }\n};\n```\n\n### Play with props\n\nIn this example, the suggestions has been limited to render a maximum of 3 items. _Type \"puzzle\" or\nanother toy in the input field to try it out!_\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" :maxItemsToRender=\"3\" />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n\nIn this example, the filters of the suggestion will be rendered along with the query.\n\nThe `showPlainSuggestion` prop can be used to indicate if the suggestion without filter must be\nrendered along with the suggestion with filters.\n\nThis will render:\n\n- Chips //If `showPlainSuggestion` is true\n- Chips EXAMPLE\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" showFacets showPlainSuggestion />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [\n {\n id: 'exampleFacet',\n label: 'exampleFacet',\n modelName: 'SimpleFacet',\n filters: [\n {\n facetId: 'exampleFacet',\n id: '{!tag=exampleFacet}exampleFacet_60361120_64009600:\"EXAMPLE\"',\n label: 'EXAMPLE',\n selected: false,\n totalResults: 10,\n modelName: 'SimpleFilter'\n }\n ]\n }\n ],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n\nIn this example, the `contentClass` prop can be used to add classes to the suggestion item.\n\n```vue\n<template>\n <BaseSuggestions :suggestions=\"suggestions\" suggestionItemClass=\"x-custom-class\" />\n</template>\n\n<script>\n import { BaseSuggestions } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionsDemo',\n components: {\n BaseSuggestions\n },\n data() {\n return {\n suggestions: [\n {\n facets: [],\n key: 'chips',\n query: 'Chips',\n totalResults: 10,\n results: [],\n modelName: 'PopularSearch'\n }\n ]\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":["animation","_openBlock","_createBlock","_resolveDynamicComponent","suggestionsKeys","_Fragment","_renderList","_createElementBlock","_normalizeClass","_createCommentVNode"],"mappings":";;;;;AACE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EADF,MACkBA,EAAAA,MAAAA,EAAAA,KAAAA,EAAAA,QAAAA,EAAAA;SADlB,IAC+D,CAAA,WAAA,CAAA,MAAA,IAAAC,SAAA,EAAA,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAC,GAAK,EAAA,CAAA;AAAA,IAAA,GAAA,EAAA,IAAA;AADrE,IAAA,KAAA,EAAA,eAAA;AAAA,GAAA,EAAA;;AAIYC,OAAAA,SAAAA,CAAAA,IAAAA,CAAAA,EAAAA,kBAAAA;AAAAA,QAAqBC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,mBAAA,EAAA,CAAA,UAAA,EAAA,KAAA,KAAA;iBACtBL,SALX,EAAA,EAAAM,kBAAA;AAAA,YAKY,IAAA;AAAA,YAAqB;AAAA,cAE3B,0BAAU,KAAiB,CAAA;AAAA,cAAA,KAAA,EAAAC,cAAA,CAAA,CAAA,qBAAA,EAAA,IAAA,CAAA,mBAAA,CAAA,CAAA;cAQ3B,WAAgF,EAAA,iBAAA;AAAA,aAAA;;;;;;;AAftF,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -7,7 +7,7 @@ import '../plugins/devtools/colors.utils.js';
|
|
|
7
7
|
import '../plugins/x-bus.js';
|
|
8
8
|
import '../plugins/x-plugin.js';
|
|
9
9
|
import { getGetterPath } from '../plugins/x-plugin.utils.js';
|
|
10
|
-
import { useStore } from '
|
|
10
|
+
import { useStore } from 'vuex';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates an object containing the alias part of {@link XComponentAPI}.
|
|
@@ -134,6 +134,9 @@ function useAliasApi() {
|
|
|
134
134
|
},
|
|
135
135
|
get selectedSort() {
|
|
136
136
|
return store.state.x.search?.sort ?? '';
|
|
137
|
+
},
|
|
138
|
+
get priceStats() {
|
|
139
|
+
return store.state.x.search?.stats?.price ?? {};
|
|
137
140
|
}
|
|
138
141
|
};
|
|
139
142
|
}
|