UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.56 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as i,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{convertTime as s}from"../../../core/timeUtils.js";import{generateUUID as r}from"../../../core/uuid.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import{formatNumber as n}from"../../../intl/number.js";import a from"../../Slider.js";import d from"../../Widget.js";import{thresholdConfiguratorCss as h}from"../css.js";import{DiscreteConfigurator as m}from"./DiscreteConfigurator.js";import{ColorPicker as p}from"../../support/ColorPicker.js";import{loadCalciteComponents as u}from"../../support/componentsUtils.js";import{onSecondaryTickCreated as b,onPrimaryTickCreated as v}from"../../support/timeWidgetUtils.js";import{messageBundle as g,tsx as _}from"../../support/widget.js";let k=class extends d{constructor(e){super(e),this.colorPickerVisible=!0,this.contextVisible=!0,this.contextToggleVisible=!0,this.contextTimeIntervalVisible=!0,this.contextColorPickerVisible=!0,this._valueSliderId=`value-slider-${r()}`,this._colorPickerId=`color-picker-${r()}`,this._discreteSwitchId=`discrete-switch-${r()}`,this._valueSlider=new a({suppressDeprecationWarning:!0,visibleElements:{labels:!1,rangeLabels:!1},steps:s(30,"minutes","milliseconds"),labelFormatFunction:(e,t)=>{const i=s(e,"milliseconds","hours");return"tick"===t?n(i,{maximumFractionDigits:0}):""}}),this._onColorChange=e=>{this.options.color=e},this._onDiscreteEnabledChange=()=>{this.options.contextEnabled=this._discreteBlockSwitch.checked}}initialize(){const e=({value:e})=>{this.options.value=e};this.addHandles([i(()=>{const{value:e,minValue:t,maxValue:i}=this.options;return{value:e,minValue:t,maxValue:i}},({value:e,minValue:t,maxValue:i})=>{const o=this._valueSlider;o.min=t,o.max=i,o.values=[e];const r=i-t,l=Math.floor(s(r,"milliseconds","hours"));o.tickConfigs=[{mode:"count",values:2*l+1,labelsVisible:!1,tickCreatedFunction:(e,t)=>b({tickElement:t})},{mode:"count",values:l+1,labelsVisible:!0,tickCreatedFunction:(e,t,i)=>v({tickElement:t,labelElement:i})}]},o),this._valueSlider.on("thumb-change",e),this._valueSlider.on("thumb-drag",e)])}loadDependencies(){return u({label:()=>import("@esri/calcite-components/dist/components/calcite-label"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._valueSlider=t(this._valueSlider)}render(){const e=this._messages.threshold,{color:t}=this.options;return _("div",{class:h.base},_("calcite-label",{class:h.valueLabel,for:this._valueSliderId,key:this._valueSliderId,scale:"s"},e.valueLabel,this._valueSlider.render()),this.colorPickerVisible?_("calcite-label",{for:this._colorPickerId,key:this._colorPickerId,layout:"inline",scale:"s"},_(p,{id:this._colorPickerId,value:t,onChange:this._onColorChange}),e.colorLabel):null,this.contextVisible?this._renderDiscrete():null)}get testData(){}_renderDiscrete(){const{_messages:{threshold:e},options:{contextEnabled:t},contextToggleVisible:i,contextColorPickerVisible:o,contextTimeIntervalVisible:s}=this,r=o||s;return i||t&&r?_("div",{class:h.discreteBlock},_("calcite-label",{classes:{[h.discreteLabel]:!0,[h.discreteLabelOpen]:t,[h.discreteLabelEmpty]:!r},for:this._discreteSwitchId,layout:i?"inline-space-between":"default",scale:"s"},_("span",{class:h.discreteLabelText},e.discreteLabel),i?_("calcite-switch",{afterCreate:e=>this._discreteBlockSwitch=e,bind:this,checked:t,id:this._discreteSwitchId,scale:"s",onCalciteSwitchChange:this._onDiscreteEnabledChange}):null),t?this._renderDiscreteConfigurator():null):null}_renderDiscreteConfigurator(){const{threshold:e}=this._messages,{contextColorPickerVisible:t,contextTimeIntervalVisible:i,options:{contextOptions:o}}=this;return _(m,{colorPickerLabel:e.discreteColorLabel,colorPickerVisible:t,options:o,timeIntervalVisible:i})}};e([l()],k.prototype,"options",void 0),e([l()],k.prototype,"colorPickerVisible",void 0),e([l()],k.prototype,"contextVisible",void 0),e([l()],k.prototype,"contextToggleVisible",void 0),e([l()],k.prototype,"contextTimeIntervalVisible",void 0),e([l()],k.prototype,"contextColorPickerVisible",void 0),e([l()],k.prototype,"testData",null),e([l()],k.prototype,"_valueSlider",void 0),e([l(),g("esri/widgets/ShadowCast/t9n/ShadowCast")],k.prototype,"_messages",void 0),k=e([c("esri.widgets.ShadowCast.components.ThresholdConfigurator")],k);export{k as ThresholdConfigurator};