@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.19 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{LEGEND_ITEM_CSS as l}from"../css.js";import{Statistics as a}from"./Statistics.js";import{getTranslatedLineTitle as c}from"../support/intlUtils.js";import"../../support/widgetUtils.js";import{messageBundle as n}from"../../support/decorators/messageBundle.js";import{tsx as d}from"../../support/jsxFactory.js";import{substitute as p}from"../../../intl/substitute.js";let h=class extends r{constructor(e,s){super(e,s),this.expanded=!1,this.checkboxVisible=!0,this._messages=null}initialize(){this._statistics=new a(this._statisticsProps),this.addHandles(t((()=>this._statisticsProps),(e=>this._statistics.set(e))))}destroy(){this._statistics=s(this._statistics)}render(){const e=this.expanded;return d("div",{key:this,class:this.classes(l.base,{[l.disabled]:this.disabled,[l.expanded]:e})},this._renderColorIndicator(),d("div",{key:"header",class:l.header},this._renderLabelWithCheckbox(),this._renderCollapseToggleButton()),e&&d("div",{key:"content",class:l.content},this._statistics.render()))}get disabled(){return!this.line.available}get _statisticsProps(){return{line:this.line,effectiveUnits:this.effectiveUnits}}_renderColorIndicator(){return d("div",{key:"color-indicator",class:l.colorIndicator,styles:{backgroundColor:this.line.color.toCss()}})}_renderCollapseToggleButton(){const e=this._messages,s=this.expanded?e.hideDetails:e.showDetails;return d("button",{key:"collapse-toggle",bind:this,class:l.collapseToggle,onclick:this._onCollapseToggleClick,title:s,"aria-label":s,type:"button"},d("span",{class:l.collapseToggleIcon}))}_onCollapseToggleClick(){this.onExpandedToggle()}_renderLabelWithCheckbox(){const{line:e,checkboxVisible:s,disabled:t}=this,i=`${l.base}__check-${e.id}`;return d("label",{key:"id",for:i,class:this.classes(l.label,{[l.labelDisabled]:t||!s})},s&&this._renderCheckbox(i),d("span",null,c(e,this._messages)))}_renderCheckbox(e){const s=this.line,t=s.visible,i=this.disabled,o=this._messages,r=t?o.hideProfile:o.showProfile,a=c(s,this._messages),n=p(r,{name:a});return d("input",{key:"checkbox",id:e,type:"checkbox",class:l.checkbox,title:n,checked:t,disabled:i,"aria-label":n,bind:this,onchange:e=>this._onCheckboxToggle(e,s)})}_onCheckboxToggle(e,s){e.stopPropagation(),s.toggleVisibility()}};e([i({nonNullable:!0})],h.prototype,"effectiveUnits",void 0),e([i({nonNullable:!0})],h.prototype,"line",void 0),e([i()],h.prototype,"expanded",void 0),e([i()],h.prototype,"disabled",null),e([i()],h.prototype,"checkboxVisible",void 0),e([i()],h.prototype,"onExpandedToggle",void 0),e([i()],h.prototype,"_statistics",void 0),e([i(),n("esri/widgets/ElevationProfile/t9n/ElevationProfile")],h.prototype,"_messages",void 0),h=e([o("esri.widgets.ElevationProfile.LegendItem")],h);export{h as LegendItem};