@visitscotland/component-library
Version:
VisitScotland Component Library
1 lines • 11.5 kB
JavaScript
(self.webpackChunk_visitscotland_component_library=self.webpackChunk_visitscotland_component_library||[]).push([[4249],{4249:function(e,t,a){"use strict";a.r(t);var s=a(95529),n=a(49937);a(10493);const i=(0,a(66262).A)(n.A,[["render",s.X]]);t.default=i},10493:function(e,t,a){"use strict";a(50881)},20729:function(e,t,a){"use strict";a.d(t,{X:function(){return f}});var s=a(20641),n=a(90033),i=a(53751),r={class:"vs-map-with-sidebar-panel__buttons d-lg-none"},l={key:0,class:"vs-map-with-sidebar-panel__back"},o={key:1,class:"vs-map-with-sidebar-panel__back"},c={class:"vs-map-with-sidebar-panel__close"},u={key:0,class:"vs-map-with-sidebar-panel__back d-none d-lg-block"},d={key:2,class:"vs-map-with-sidebar-panel__bottom-message"},p={class:"vs-map-with-sidebar-panel__list-container"},b={key:3,class:"vs-map-with-sidebar-panel__overlay"},g={key:0,class:"vs-map-with-sidebar-panel__overlay-box"},h={class:"vs-map-with-sidebar-panel__overlay-text"};function f(e,t,a,f,y,m){var v=(0,s.g2)("VsButton"),S=(0,s.g2)("VsHeading"),k=(0,s.g2)("VsMapWithSidebarSubcategory"),C=(0,s.g2)("VsMapWithSidebarControls"),w=(0,s.g2)("VsMapWithSidebarCategory"),_=(0,s.g2)("VsMapWithSidebarListItem"),L=(0,s.g2)("VsMapWithSidebarButtons"),F=(0,s.g2)("VsMapWithSidebarDetail");return(0,s.uX)(),(0,s.CE)("section",{"data-test":"vs-map-with-sidebar-panel",class:(0,n.normalizeClass)(["vs-map-with-sidebar-panel",m.panelClasses])},[(0,s.Lk)("div",{class:(0,n.normalizeClass)(["vs-map-with-sidebar-panel__header-section",m.headerClasses])},[(0,s.Lk)("div",r,[a.currentStage>1||a.selectedSubcategory?((0,s.uX)(),(0,s.CE)("div",l,[(0,s.bF)(v,{class:"vs-map-with-sidebar-panel_menu",icon:"vs-icon-control-menu",size:"sm",onClick:m.stageBack,"data-test":"vs-map-with-sidebar__menu-toggle",variant:"secondary"},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"menu-btn-text")]})),_:3},8,["onClick"])])):(0,s.Q3)("",!0),1===a.currentStage||a.selectedSubcategory?((0,s.uX)(),(0,s.CE)("div",o,[(0,s.bF)(v,{"icon-only":"",icon:"fa-regular fa-arrow-left",size:"md",variant:"subtle",onClick:m.stageBack,"data-test":"vs-map-with-sidebar-panel--btn-back"},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"back-btn-text")]})),_:3},8,["onClick"])])):(0,s.Q3)("",!0),(0,s.Lk)("div",c,[(0,s.bF)(v,{"icon-only":"",icon:"vs-icon-control-dismiss",size:"md",variant:"subtle",onClick:m.closePanel,"data-test":"vs-map-with-sidebar-panel--btn-close"},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"close-side-panel-text")]})),_:3},8,["onClick"])])]),a.currentStage>0||a.selectedSubcategory?((0,s.uX)(),(0,s.CE)("div",u,[(0,s.bF)(v,{"icon-only":"",icon:"fa-regular fa-arrow-left",size:"md",variant:"subtle",onClick:m.stageBack,"data-test":"vs-map-with-sidebar-panel--btn-back"},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"back-btn-text")]})),_:3},8,["onClick"])])):(0,s.Q3)("",!0),""!==m.currentHeading?((0,s.uX)(),(0,s.Wv)(S,{key:1,level:a.headingLevel,"heading-style":0===a.currentStage?"heading-m":"heading-xs",class:(0,n.normalizeClass)(["vs-map-with-sidebar-panel__heading text-center mt-200 mt-lg-0",2===a.currentStage?"d-none d-lg-block":""]),"data-test":"vs-map-with-sidebar-panel__heading"},{default:(0,s.k6)((function(){return[(0,s.eW)((0,n.toDisplayString)(m.currentHeading),1)]})),_:1},8,["level","heading-style","class"])):(0,s.Q3)("",!0),(0,s.Lk)("div",{class:(0,n.normalizeClass)(["vs-map-with-sidebar-panel__reset",a.currentStage<2?"d-lg-none":""])},[(0,s.bF)(v,{"icon-only":"",icon:"vs-icon-control-dismiss",size:"md",variant:"subtle",onClick:m.resetPanel,"data-test":"vs-map-with-sidebar-panel--btn-reset"},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"reset-side-panel-text")]})),_:3},8,["onClick"])],2)],2),0===a.currentStage?((0,s.uX)(),(0,s.CE)(s.FK,{key:0},[null!==a.selectedSubcategory?((0,s.uX)(),(0,s.CE)(s.FK,{key:0},[(0,s.bF)(k,{data:m.selectedSubcategoryData[0].subCategory,"selected-sub-category":a.selectedSubcategory},null,8,["data","selected-sub-category"]),(0,s.bF)(C)],64)):((0,s.uX)(!0),(0,s.CE)(s.FK,{key:1},(0,s.pI)(m.filtersWithLocations,(function(e){return(0,s.uX)(),(0,s.Wv)(w,{key:e.id,"category-name":e.label,type:e.id,"has-sub-cat":m.subCatExists(e)},null,8,["category-name","type","has-sub-cat"])})),128)),null!==a.panelMessage?((0,s.uX)(),(0,s.CE)("div",d,[(0,s.Lk)("p",null,(0,n.toDisplayString)(a.panelMessage),1)])):(0,s.Q3)("",!0)],64)):(0,s.Q3)("",!0),1===a.currentStage?((0,s.uX)(),(0,s.CE)(s.FK,{key:1},[null!==a.selectedSubcategory?((0,s.uX)(),(0,s.CE)(s.FK,{key:0},[(0,s.Lk)("div",p,[((0,s.uX)(!0),(0,s.CE)(s.FK,null,(0,s.pI)(a.subcategoryLocations,(function(t,n){return(0,s.uX)(),(0,s.Wv)(_,{key:t.id,"item-data":t,"from-endpoint":!0,focussed:n===a.currentListItemFocus,onShowItemDetail:function(a){return e.showDetail(t)}},null,8,["item-data","focussed","onShowItemDetail"])})),128)),m.showLoadMore?((0,s.uX)(),(0,s.Wv)(v,{key:0,class:"vs-map-with-sidebar-panel__load-more","data-test":"vs-map-with-sidebar-panel__load-more",onClick:t[0]||(t[0]=function(e){return m.loadMorePlaces()}),onKeyup:t[1]||(t[1]=(0,i.withKeys)((function(e){return m.loadMorePlaces()}),["enter"]))},{default:(0,s.k6)((function(){return[(0,s.RG)(e.$slots,"load-more-text")]})),_:3})):(0,s.Q3)("",!0)]),(0,s.bF)(L,{"content-data":{},"filter-count":e.subCatFilterCount,onClearFilters:m.clearSubCatFilters},null,8,["filter-count","onClearFilters"])],64)):((0,s.uX)(!0),(0,s.CE)(s.FK,{key:1},(0,s.pI)(m.currentData,(function(t){return(0,s.uX)(),(0,s.CE)("div",{key:t.id},[void 0!==t.properties&&t.properties.category.id===a.selectedCategory?((0,s.uX)(),(0,s.Wv)(_,{key:0,"item-data":t,onShowItemDetail:function(a){return e.showDetail(t)}},null,8,["item-data","onShowItemDetail"])):(0,s.Q3)("",!0)])})),128))],64)):(0,s.Q3)("",!0),2===a.currentStage?((0,s.uX)(),(0,s.CE)(s.FK,{key:2},[(0,s.bF)(F,{"heading-level":m.detailHeadingLevel,"content-data":m.currentPlaceData[0]},null,8,["heading-level","content-data"]),(0,s.bF)(L,{"content-data":m.currentPlaceData[0]},null,8,["content-data"])],64)):(0,s.Q3)("",!0),null!==a.panelStatus?((0,s.uX)(),(0,s.CE)("div",b,[e.$slots["panel-loading-message"]&&"map-loading"!==a.panelStatus?((0,s.uX)(),(0,s.CE)("div",g,[(0,s.Lk)("p",h,[(0,s.RG)(e.$slots,"panel-loading-message")])])):(0,s.Q3)("",!0)])):(0,s.Q3)("",!0)],2)}},49937:function(e,t,a){"use strict";a.d(t,{A:function(){return s.A}});var s=a(93013)},50881:function(e,t,a){"use strict";var s=a(85072),n=a.n(s),i=a(97825),r=a.n(i),l=a(77659),o=a.n(l),c=a(55056),u=a.n(c),d=a(10540),p=a.n(d),b=a(41113),g=a.n(b),h=a(79903),f=a.n(h),y={};y.styleTagTransform=g(),y.setAttributes=u(),y.insert=o().bind(null,"head"),y.domAPI=r(),y.insertStyleElement=p(),n()(f(),y),f()&&f().locals&&f().locals},79903:function(){},93013:function(e,t,a){"use strict";var s=a(64467),n=a(48836),i=a(13838),r=a(10810),l=a(79920),o=a(31101),c=a(91213),u=a(22552),d=a(23198),p=a(83844),b=a(63055);function g(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function h(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?g(Object(a),!0).forEach((function(t){(0,s.A)(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):g(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var f=null;t.A={name:"VsMapWithSidebarPanel",status:"prototype",release:"0.0.1",components:{VsButton:n.default,VsMapWithSidebarCategory:o.default,VsMapWithSidebarSubcategory:c.default,VsHeading:i.default,VsMapWithSidebarListItem:u.default,VsMapWithSidebarDetail:d.default,VsMapWithSidebarButtons:p.default,VsMapWithSidebarControls:b.default},inject:["filters","filtersWithLocations","placesData","regions","mapId","focussedListItem"],props:{categoryHeading:{type:String,default:""},headingLevel:{type:String,default:"2"},selectedCategory:{type:String,default:""},selectedSubcategory:{type:String,default:null},currentStage:{type:Number,required:!0},selectedItem:{type:Object,default:null},hovered:{type:String,default:""},subcategoryLocations:{type:Array,default:null},currentEndpointData:{type:Array,default:function(){return[]}},panelStatus:{type:String,default:null},panelMessage:{type:String,default:null},totalPins:{type:Number,default:0},currentListItemFocus:{type:Number,default:0}},emits:["close-panel","load-more-places","set-stage","set-subcategory"],data:function(){return{placesLoaded:1}},computed:h(h({currentHeading:function(){var e="";if(null!==this.selectedSubcategory)e=this.selectedSubcategoryData[0].label;else switch(this.currentStage){case 0:e=this.categoryHeading;break;case 1:case 2:e=this.currentFilter.label}return e},currentData:function(){return"regions"===this.selectedCategory?this.regions:this.placesData},panelClasses:function(){var e="";return 2===this.currentStage&&(e+=" vs-map-with-sidebar-panel--small-padding"),e},headerClasses:function(){return 1===this.currentStage?"vs-map-with-sidebar-panel__header-section--with-spacer":2===this.currentStage?"vs-map-with-sidebar-panel__header-section--overlapped":""},currentFilter:function(){var e=this,t="";return this.filters.forEach((function(a){a.id===e.selectedCategory&&(t=a)})),t},currentPlaceData:function(){var e=this,t=this.placesData;return"regions"===this.selectedCategory&&(t=this.regions),this.currentEndpointData.length>0?this.refineEndpointData(this.currentEndpointData):t.filter((function(t){return!(void 0===t.properties||!e.selectedItem)&&t.properties.id===e.selectedItem.properties.id}))},selectedSubcategoryData:function(){var e=this;return this.selectedSubcategory?this.filters.filter((function(t){return t.id===e.selectedSubcategory})):[]}},(0,r.aH)(l.A,{subCatFilterCount:function(e){return e.activeSubcatFilters.length}})),{},{detailHeadingLevel:function(){return(parseInt(this.headingLevel,10)+1).toString()},showLoadMore:function(){return!(this.subcategoryLocations.length>=this.totalPins||0===this.subcategoryLocations.length)}}),watch:{currentFilter:function(){this.placesLoaded=1}},mounted:function(){f=(0,l.A)()},methods:{closePanel:function(){this.$emit("close-panel"),window.innerWidth>=1292&&2===this.currentStage&&this.$emit("set-subcategory",null)},stageBack:function(){if(this.selectedSubcategory&&0===this.currentStage)this.$emit("set-subcategory",null);else if(null!==this.selectedSubcategory&&null===this.subcategoryLocations)this.setStage(0);else{var e=this.currentStage-1;this.setStage(e)}},resetPanel:function(){f.setSelectedSubcat(null),this.setStage(0)},setStage:function(e){0===e&&(this.placesLoaded=1),this.$emit("set-stage",e)},subCatExists:function(e){return void 0!==e.subCategory&&e.subCategory.length>0},refineEndpointData:function(e){var t=[{isEndpoint:!0,properties:{category:e[0].category[0].id,id:e[0].id,image:e[0].images[0].mediaUrl,placeTitle:e[0].name,description:e[0].description,link:{label:e[0].productLink.label,link:e[0].productLink.link,type:e[0].productLink.type},website:{label:e[0].website.label,link:e[0].website.link,type:e[0].website.type},address:{shortAddress:""}}}];return void 0!==e[0].address&&(t[0].properties.address.shortAddress=e[0].address.shortAddress),t},clearSubCatFilters:function(){f.setActiveSubcatFilters([]),this.setStage(0)},loadMorePlaces:function(){this.placesLoaded+=1,this.$emit("load-more-places",this.placesLoaded)}}}},95529:function(e,t,a){"use strict";a.d(t,{X:function(){return s.X}});var s=a(20729)}}]);