UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 3.4 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import{deprecateWidget as r}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{property as t,subclass as s}from"../../core/accessorSupport/decorators.js";import{authoringInfoVariableSliderMinMax as o}from"../../renderers/support/authoringInfoUtils.js";import a from"./SmartMappingSliderBase.js";import l from"./ColorSlider/ColorSliderViewModel.js";import{globalCss as n}from"../support/globalCss.js";import{messageBundle as d,tsx as p}from"../support/widget.js";var m;const h="esri-color-slider",g={base:h,rampElement:`${h}__ramp`,sliderContainer:`${h}__slider-container`,histogramContainer:`${h}__histogram-container`,primaryHandle:`${h}--primary-handle`,track:`${h}--interactive-track`};let c=m=class extends a{constructor(e,t){super(e,t),this.messages=null,this.viewModel=new l,this._bgFillId=`${this.id}-bg-fill`,this._rampFillId=`${this.id}-linear-gradient`,this.announceDeprecation=()=>{r(i.getLogger(this),"Slider Color","arcgis-slider-color-legacy",{version:"5.0"})}}get handlesSyncedToPrimary(){return this.viewModel.handlesSyncedToPrimary}set handlesSyncedToPrimary(e){this.viewModel.handlesSyncedToPrimary=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get primaryHandleEnabled(){return this.viewModel.primaryHandleEnabled}set primaryHandleEnabled(e){this.viewModel.primaryHandleEnabled=e}get stops(){return this.viewModel.stops}set stops(e){this.viewModel.stops=e}static fromRendererResult(e,r){const{visualVariable:{stops:i},statistics:t}=e,{avg:s,stddev:a}=t,l=e.renderer.authoringInfo?.visualVariables.find(e=>"color"===e.type),[n,d]=o(l);return new m({max:d,min:n,stops:i,histogramConfig:{average:s??void 0,standardDeviation:a??void 0,bins:r?r.bins:[]},primaryHandleEnabled:"high-to-low"!==l?.theme})}updateFromRendererResult(e,r){const{visualVariable:{stops:i},statistics:t}=e,{avg:s,stddev:a}=t,l=e.renderer.authoringInfo?.visualVariables.find(e=>"color"===e.type),[n,d]=o(l);this.set({max:d,min:n,stops:i,histogramConfig:{...this.histogramConfig,average:s,standardDeviation:a,bins:r?r.bins:[]},primaryHandleEnabled:"high-to-low"!==l?.theme})}render(){const{label:e,primaryHandleEnabled:r,state:i,visibleElements:t}=this,s="disabled"===i,o=this.classes(g.base,n.widget,n.panel,{[n.disabled]:s,[g.primaryHandle]:r,[g.track]:!!t.interactiveTrack});return p("div",{"aria-label":e,class:o},s?null:this.renderContent(this._renderRamp(),g.sliderContainer,g.histogramContainer))}_renderRamp(){const{_bgFillId:e,_rampFillId:r,viewModel:i,zoomOptions:t}=this,s=i.getStopInfo();return p("div",{class:g.rampElement},p("svg",{xmlns:"http://www.w3.org/2000/svg"},p("defs",null,this.renderRampFillDefinition(r,s),this.renderBackgroundFillDefinition(e)),p("rect",{fill:`url(#${e})`,height:"100%",width:"100%",x:"0",y:"0"}),p("rect",{fill:`url(#${r})`,height:"100%",width:"100%",x:"0",y:"0"})),t?this.renderZoomCaps():null)}};e([t()],c.prototype,"handlesSyncedToPrimary",null),e([t()],c.prototype,"label",null),e([t(),d("esri/widgets/smartMapping/ColorSlider/t9n/ColorSlider")],c.prototype,"messages",void 0),e([t()],c.prototype,"primaryHandleEnabled",null),e([t()],c.prototype,"stops",null),e([t({type:l})],c.prototype,"viewModel",void 0),c=m=e([s("esri.widgets.smartMapping.ColorSlider")],c);const u=c;export{u as default};