@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.87 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../../chunks/tslib.es6.js";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}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as a}from"../../../intl/number.js";import n from"../../Slider.js";import d from"../../Widget.js";import{thresholdConfiguratorCss as m}from"../css.js";import{DiscreteConfigurator as p}from"./DiscreteConfigurator.js";import{ColorPicker as h}from"../../support/ColorPicker.js";import{loadCalciteComponents as u}from"../../support/componentsUtils.js";import{onSecondaryTickCreated as b,onPrimaryTickCreated as v}from"../../support/timeWidgetUtils.js";import"../../support/widgetUtils.js";import{messageBundle as g}from"../../support/decorators/messageBundle.js";import{tsx as _}from"../../support/jsxFactory.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 n({visibleElements:{labels:!1,rangeLabels:!1},steps:s(30,"minutes","milliseconds"),labelFormatFunction:(e,t)=>{const i=s(e,"milliseconds","hours");return"tick"===t?a(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:m.base},_("calcite-label",{class:m.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"},_(h,{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:m.discreteBlock},_("calcite-label",{classes:{[m.discreteLabel]:!0,[m.discreteLabelOpen]:t,[m.discreteLabelEmpty]:!r},for:this._discreteSwitchId,layout:i?"inline-space-between":"default",scale:"s"},_("span",{class:m.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 _(p,{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};