UNPKG

@progress/kendo-react-gauges

Version:

React Gauges provide a set of React components for building beautiful and customizable gauges. KendoReact Gauges package

9 lines (8 loc) 1.72 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 u=require("react"),d=require("@progress/kendo-charts"),g=require("./GaugeContext.js");function h(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const l=h(u),c=class c extends l.Component{constructor(e){super(e),this.state={arcCenterStyles:null,arcCenterValue:{value:0,color:""}},this._element=null,this.gaugeObserver=new d.InstanceObserver(this,{render:"onRender"})}componentDidMount(){var e;(e=this.context)==null||e.observersStore.dispatch({type:"add",payload:this.gaugeObserver})}render(){const{render:e}=this.props,{arcCenterStyles:t,arcCenterValue:n}=this.state,o=t||{zIndex:-1};let s=null;return e&&(s=l.createElement("div",{className:"k-arcgauge-label",ref:i=>{this._element=i},style:o},e(n.value,n.color))),s}onRender(e){if(!this._element)return;const t=e.sender.gaugeInstance,n=this._element.offsetWidth,o=this._element.offsetHeight,s=t.centerLabelPosition(n,o);this.setState({arcCenterStyles:{left:s.left,top:s.top},arcCenterValue:{value:t.value(),color:t.currentColor()}})}};c.contextType=g.GaugeContext;let a=c;exports.ArcCenter=a;