UNPKG

@progress/kendo-react-map

Version:
9 lines (8 loc) 2.25 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),d=require("@progress/kendo-charts"),m=require("./Popup.js"),y=require("../MapContext.js");function f(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const s=f(h),i=class i extends s.Component{constructor(){super(...arguments),this.context=null,this.state={popupShown:!1}}componentDidMount(){this.mapObserver=new d.InstanceObserver(this,{showTooltip:"onShowTooltip",hideTooltip:"onHideTooltip"}),this.context.observersStore.dispatch({type:"add",payload:this.mapObserver})}render(){const{popupContext:t,shared:e,className:n,...r}=this.state;if(!t||!this.state.popupShown)return null;const c=t.layerIndex,a=this.findRenderFunctionByLayer(c);if(!a)return null;const l=()=>s.createElement("div",{className:"k-tooltip-content"},a(t)),u=`k-map-${t.type}-tooltip`;return s.createElement(m.TooltipPopup,{...r,popupContent:l,className:u})}componentWillUnmount(){this.context.observersStore.dispatch({type:"remove",payload:this.mapObserver})}onShowTooltip(t){const{anchor:e,className:n}=t,r=this.createTooltipContext(t);this.setState({popupShown:!0,popupAlign:{vertical:"bottom",horizontal:"center"},popupOffset:e,popupContext:r,popupStyles:{position:"relative"},className:n})}onHideTooltip(){this.setState({popupShown:!1,popupStyles:{},className:void 0})}createTooltipContext(t){return t}findRenderFunctionByLayer(t){const e=this.context.optionsStore.getState().layers;return e!==void 0&&Array.isArray(e)&&e[t]!==void 0&&e[t].hasOwnProperty("tooltip")&&e[t].tooltip.hasOwnProperty("render")?e[t].tooltip.render:null}};i.contextType=y.MapContext;let p=i;exports.MapTooltip=p;