UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.12 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{property as o,subclass as i}from"../../core/accessorSupport/decorators.js";import s from"../../views/interactive/sketch/SketchOptions.js";import{directionModeIcons as l}from"../../views/interactive/tooltip/components/directionModeIcons.js";import n from"../Widget.js";import{loadCalciteComponents as r}from"./componentsUtils.js";import{globalCss as a}from"./globalCss.js";import{loadLabeledSwitchComponents as c,LabeledSwitch as d}from"./LabeledSwitch.js";import{messageBundle as p,tsx as b}from"./widget.js";import h from"./SketchTooltipControls/VisibleElements.js";const m="esri-sketch-tooltip-controls",g={base:m,block:`${m}__block`,blockContent:`${m}__block-content`,radioButtonLabelWrapper:`${m}__radio-button-label-wrapper`};let u=class extends n{constructor(e,t){super(e,t),this.viewModel=null,this.visibleElements=new h,this.sketchOptions=new s,this.viewType=void 0,this._onTooltipsEnabledChange=e=>{this.sketchOptions.tooltips.enabled=e},this._onLabelsEnabledChange=e=>{this.sketchOptions.labels.enabled=e},this._onDirectionModeChange=e=>{this.sketchOptions.values.directionMode=e.currentTarget.selectedItem.value}}loadDependencies(){return Promise.all([r({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")}),c()])}render(){const{label:e,visibleElements:t}=this,o=this._renderContent();return b("div",{"aria-label":e,class:this.classes(g.base,a.widget)},o?b("calcite-block",{class:g.block,expanded:!0,heading:t.header?this.label:"",key:"content-block",label:this.label},b("div",{class:g.blockContent,key:"content"},o)):void 0)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}_renderContent(){const{visibleElements:e,viewType:o}=this,i=[e.tooltipsToggle?this._renderTooltipsToggle():null,e.labelsToggle&&"3d"===o?this._renderLabelsToggle():null,e.directionModePicker?this._renderDirectionModePicker():null].filter(t);return 0===i.length?null:i}_renderTooltipsToggle(){const{messages:e,sketchOptions:t}=this;return b(d,{checked:t.tooltips.effectiveEnabled,hint:e.tooltipsToggleHint,key:`${this.id}__tooltips`,label:e.tooltipsToggle,topLayerDisabled:this.topLayerDisabled,onChange:this._onTooltipsEnabledChange})}_renderLabelsToggle(){const{messages:e,sketchOptions:t}=this;return b(d,{checked:t.labels.enabled,hint:e.labelsToggleHint,key:`${this.id}__labels`,label:e.labelsToggle,topLayerDisabled:this.topLayerDisabled,onChange:this._onLabelsEnabledChange})}_renderDirectionModePicker(){const{messages:e,sketchOptions:t}=this,{directionMode:o}=t.values;return b("calcite-label",{key:"direction-mode",layout:"default",scale:"s"},e.directionModePicker,b("calcite-radio-button-group",{key:"radio-button-group",layout:"horizontal",name:this.id,scale:"s",value:o,onCalciteRadioButtonGroupChange:this._onDirectionModeChange},this._renderDirectionModeOption("relative",o,e.directionModeRelative),this._renderDirectionModeOption("absolute",o,e.directionModeAbsolute)))}_renderDirectionModeOption(e,t,o){return b("calcite-label",{key:e,layout:"inline",scale:"s"},b("calcite-radio-button",{checked:e===t,scale:"s",value:e}),b("div",{class:g.radioButtonLabelWrapper,key:"label-wrapper"},b("calcite-icon",{icon:l[e],scale:"s"}),o))}};e([o()],u.prototype,"label",null),e([o({type:h,nonNullable:!0})],u.prototype,"visibleElements",void 0),e([o(),p("esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls")],u.prototype,"messages",void 0),e([o({nonNullable:!0,type:s})],u.prototype,"sketchOptions",void 0),e([o({type:String})],u.prototype,"viewType",void 0),u=e([i("esri.widgets.support.SketchTooltipControls")],u);const k=u;export{k as default};