12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Handles.js";import{destroyMaybe as s}from"../core/maybe.js";import{on as i,watch as r,initial as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as a}from"../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import h from"./Legend/LegendViewModel.js";import p from"./Legend/styles/Card.js";import c from"./Legend/styles/Classic.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{tsx as g}from"./support/jsxFactory.js";const v={base:"esri-legend",widget:"esri-widget",panel:"esri-widget--panel",widgetIcon:"esri-icon-layer-list"};let u=class extends d{constructor(e,s){super(e,s),this._handles=new t,this.headingLevel=3,this.iconClass=v.widgetIcon,this.messages=null,this.style=new c,this.viewModel=new h}initialize(){this.addHandles([i((()=>this.view),"resize",(()=>this.scheduleRender())),i((()=>this.activeLayerInfos),"change",(()=>this._refreshActiveLayerInfos(this.activeLayerInfos))),r((()=>this.headingLevel),(e=>{const{style:t}=this;t&&(t.headingLevel=e)})),r((()=>this.style),((e,t)=>{t&&e!==t&&t.destroy(),e&&(e.activeLayerInfos=this.activeLayerInfos,"card"===e.type&&(e.view=this.view),e.headingLevel=this.headingLevel)}),o)])}destroy(){this._handles=s(this._handles)}get activeLayerInfos(){return this.viewModel.activeLayerInfos}set activeLayerInfos(e){this.viewModel.activeLayerInfos=e}get basemapLegendVisible(){return this.viewModel.basemapLegendVisible}set basemapLegendVisible(e){this.viewModel.basemapLegendVisible=e}get groundLegendVisible(){return this.viewModel.groundLegendVisible}set groundLegendVisible(e){this.viewModel.groundLegendVisible=e}get hideLayersNotInCurrentView(){return this.viewModel.hideLayersNotInCurrentView}set hideLayersNotInCurrentView(e){this.viewModel.hideLayersNotInCurrentView=e}get keepCacheOnDestroy(){return this.viewModel.keepCacheOnDestroy}set keepCacheOnDestroy(e){this.viewModel.keepCacheOnDestroy=e}get respectLayerVisibility(){return this.viewModel.respectLayerVisibility}set respectLayerVisibility(e){this.viewModel.respectLayerVisibility=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}castStyle(e){if(e instanceof p||e instanceof c)return e;if("string"==typeof e)return"card"===e?new p:new c;if(e&&"string"==typeof e.type){const t={...e};delete t.type;return new("card"===e.type?p:c)(t)}return new c}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return g("div",{class:this.classes(v.base,v.widget,this.style instanceof c?v.panel:null)},this.style.render())}_refreshActiveLayerInfos(e){this._handles.removeAll(),e.forEach((e=>this._renderOnActiveLayerInfoChange(e))),this.scheduleRender()}_renderOnActiveLayerInfoChange(e){const t=r((()=>e.version),(()=>this.scheduleRender()));this._handles.add(t,`version_${e.layer.uid}`);const s=i((()=>e.children),"change",(()=>e.children.forEach((e=>this._renderOnActiveLayerInfoChange(e)))),o);this._handles.add(s,`children_${e.layer.uid}`),e.children.forEach((e=>this._renderOnActiveLayerInfoChange(e)))}};e([n()],u.prototype,"activeLayerInfos",null),e([n()],u.prototype,"basemapLegendVisible",null),e([n()],u.prototype,"groundLegendVisible",null),e([n()],u.prototype,"headingLevel",void 0),e([n()],u.prototype,"hideLayersNotInCurrentView",null),e([n()],u.prototype,"keepCacheOnDestroy",null),e([n()],u.prototype,"respectLayerVisibility",null),e([n()],u.prototype,"iconClass",void 0),e([n()],u.prototype,"label",null),e([n()],u.prototype,"layerInfos",null),e([n(),y("esri/widgets/Legend/t9n/Legend")],u.prototype,"messages",void 0),e([n()],u.prototype,"style",void 0),e([a("style")],u.prototype,"castStyle",null),e([n()],u.prototype,"view",null),e([n()],u.prototype,"viewModel",void 0),u=e([l("esri.widgets.Legend")],u);const w=u;export{w as default};
|