UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.67 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import{watch as s,initial as i}from"../../../core/reactiveUtils.js";import{property as r}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 p from"../../Widget.js";import{LEGEND_CSS as n}from"../css.js";import{LegendItem as d}from"./LegendItem.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let m=class extends p{constructor(e,s){super(e,s),this._items=new t,this._expandedLine=null}initialize(){this.addHandles([s((()=>this.profiles),(e=>{this._destroyItems(),this._items.addMany(e.map((e=>this._createItemForLine(e))))}),i),s((()=>this.effectiveUnits),(e=>{this._items.forEach((t=>{t.effectiveUnits=e}))}),i)])}destroy(){this._destroyItems()}render(){return a("div",{class:n.base},this._items.toArray().map((e=>e.render())))}_onExpandedToggle(e){this._expandedLine=e===this._expandedLine?null:e,this._items.forEach((e=>e.expanded=e.line===this._expandedLine))}_createItemForLine(e){return new d({line:e,effectiveUnits:this.effectiveUnits,expanded:e===this._expandedLine,checkboxVisible:this.profiles.length>1,onExpandedToggle:()=>this._onExpandedToggle(e)})}_destroyItems(){this._items.drain((e=>e.destroy()))}};e([r()],m.prototype,"profiles",void 0),e([r()],m.prototype,"effectiveUnits",void 0),e([r()],m.prototype,"_items",void 0),e([r()],m.prototype,"_expandedLine",void 0),m=e([o("esri.widgets.ElevationProfile.Legend")],m);export{m as Legend};