@visitscotland/component-library
Version:
VisitScotland Component Library
1 lines • 4.61 kB
JavaScript
(self.webpackChunk_visitscotland_component_library=self.webpackChunk_visitscotland_component_library||[]).push([[681],{4243:function(e,t,r){"use strict";r.d(t,{A:function(){return i.A}});var i=r(57255)},27135:function(){},30681:function(e,t,r){"use strict";r.r(t);var i=r(46119),n=r(4243);r(71133);const a=(0,r(66262).A)(n.A,[["render",i.X]]);t.default=a},44441:function(e,t,r){"use strict";var i=r(85072),n=r.n(i),a=r(97825),s=r.n(a),c=r(77659),o=r.n(c),u=r(55056),l=r.n(u),p=r(10540),h=r.n(p),d=r(41113),f=r.n(d),v=r(27135),m=r.n(v),g={};g.styleTagTransform=f(),g.setAttributes=l(),g.insert=o().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h(),n()(m(),g),m()&&m().locals&&m().locals},46119:function(e,t,r){"use strict";r.d(t,{X:function(){return c}});var i=r(20641),n=r(90033),a=r(53751),s=["aria-label"];function c(e,t,r,c,o,u){var l=(0,i.g2)("VsMapMarkerIcon");return(0,i.uX)(),(0,i.CE)("button",{type:"button",class:(0,n.normalizeClass)(["vs-map-marker",u.isActive?"vs-map-marker--active":""]),"data-test":"vs-map-marker",onClick:t[0]||(t[0]=function(){return u.markerClick&&u.markerClick.apply(u,arguments)}),onKeydown:t[1]||(t[1]=(0,a.withKeys)((function(){return u.markerClick&&u.markerClick.apply(u,arguments)}),["enter"])),onMouseover:t[2]||(t[2]=function(e){return u.handleHover(r.feature)}),onMouseleave:t[3]||(t[3]=function(e){return u.handleHover("")}),onFocusin:t[4]||(t[4]=function(e){return u.handleHover(r.feature)}),onFocusout:t[5]||(t[5]=function(e){return u.handleHover("")}),"aria-label":u.getMarkerIcon},[(0,i.bF)(l,{id:u.getMarkerIcon,"is-map-marker":!0,number:r.feature.properties.stopCount?r.feature.properties.stopCount:""},null,8,["id","number"])],42,s)}},57255:function(e,t,r){"use strict";var i=r(64467),n=r(10810),a=r(79920),s=r(32536);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){(0,i.A)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var u=null;t.A={name:"VsMapMarker",status:"prototype",release:"0.0.1",components:{VsMapMarkerIcon:s.default},props:{feature:{type:Object,required:!0},mapId:{type:String,required:!0},hasPopups:{type:Boolean,required:!0},selectedPlace:{type:String,default:null}},emits:["showDetail","setCategory"],setup:function(){u=(0,a.A)()},computed:o(o({isActive:function(){return!(!this.activePlace||!this.activePlace.properties||this.activePlace.properties.id!==this.feature.properties.id)||!(!this.highlightedPlace||!this.highlightedPlace.properties||this.highlightedPlace.properties.id!==this.feature.properties.id)}},(0,n.aH)(a.A,{highlightedPlace:function(e){return e.getHoveredStop(this.mapId)},activePlace:function(e){return e.getActivePlace(this.mapId)?e.getActivePlace(this.mapId):""},activeSubcat:function(e){return e.selectedSubCategory}})),{},{getMarkerIcon:function(){var e;return"null"===(e=""!==this.feature.properties.type?this.feature.properties.type:null!==this.activeSubcat?this.activeSubcat:"featured")&&(e=""),e}}),watch:{isActive:function(){return!!(this.activePlace&&this.activePlace.properties.id===this.feature.properties.id||this.highlightedPlace&&this.highlightedPlace.properties.id===this.feature.properties.id)||(this.activePlace&&this.activePlace.properties.id===this.feature.properties.id&&u.setActiveMarkerPos(this.feature.geometry.coordinates),!1)},activePlace:function(){this.activePlace&&this.activePlace.properties.id===this.feature.properties.id&&u.setActiveMarkerPos(this.feature.geometry.coordinates)}},mounted:function(){this.hasPopups&&document.body.addEventListener("click",this.handleClickEvent)},beforeUnmount:function(){document.body.removeEventListener("click",this.handleClickEvent)},methods:{markerClick:function(){u.setActiveMarkerPos(this.feature.geometry.coordinates),u.setActivePlace({mapId:this.mapId,activeFeature:this.feature}),this.$emit("showDetail",this.feature),this.$emit("setCategory",this.feature.properties.type)},handleHover:function(e){u.setHoveredPlace({mapId:this.mapId,hoveredFeature:e})},handleClickEvent:function(e){var t=document.getElementsByClassName("mapboxgl-canvas");e.target===t[0]&&u.setActivePlace({mapId:this.mapId,activeFeature:null})}}}},71133:function(e,t,r){"use strict";r(44441)}}]);