UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.98 kB
/* 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{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import r from"../../../Widget.js";import i from"./ColorRamp.js";import{css as a}from"./css.js";import l from"./SizeRamp.js";import o from"./UnivariateAboveAndBelowRamp.js";import n from"./UnivariateColorSizeRamp.js";import{renderRelationshipRamp as m}from"../support/relationshipUtils.js";import{getLegendElementTitle as p}from"../support/utils.js";import{attachToNode as c,isImageryStretchedLegend as h,getTitle as d}from"../../support/styleUtils.js";import"../../../support/widgetUtils.js";import{tsx as y}from"../../../support/jsxFactory.js";var g;let f=g=class extends r{constructor(e,s){super(e,s),this.effectList=null,this.isChild=!1,this.legendElement=null}render(){const e=this._renderLegendElement(),s=p(this.legendElement,this.messages),t=this.isChild?a.layerChildTable:a.layerTable,r=s?y("div",{class:a.layerCaption},s):null,i={[a.layerTableSizeRamp]:"size-ramp"===this.legendElement.type||!this.isChild};return y("section",{class:this.classes(t,i),key:`${this.key}-table`},r,e)}_renderLegendElement(){switch(this.legendElement.type){case"symbol-table":return this._renderSymbolTable(this.legendElement);case"size-ramp":return y(l,{key:this.key,legendElement:this.legendElement,messages:this.messages});case"color-ramp":case"opacity-ramp":case"heatmap-ramp":case"stretch-ramp":return y(i,{key:this.key,legendElement:this.legendElement,messages:this.messages,opacity:this.layer.opacity});case"relationship-ramp":return m(this.legendElement,this.id,{opacity:this.layer.opacity,effectList:this.effectList,ariaLabel:this.messages.previewRelationshipRampAriaLabel,key:this.key});case"pie-chart-ramp":return y("div",{afterCreate:c,bind:this.legendElement.preview,key:`${this.key}-preview`});case"univariate-above-and-below-ramp":return y(o,{effectList:this.effectList,key:this.key,legendElement:this.legendElement,messages:this.messages,opacity:this.layer.opacity});case"univariate-color-size-ramp":return y(n,{effectList:this.effectList,key:this.key,legendElement:this.legendElement,messages:this.messages,opacity:this.layer.opacity});default:return null}}_renderSymbolTable(e){const s=e.infos.map((s=>this._renderElementInfo(s,e.legendType))).filter(Boolean);return s.length?y("div",{class:a.layerBody},s):null}_renderElementInfo(e,s){const{layer:t}=this,r="label"in e?e.label:null,i=`${this.key}-${r}`;if("type"in e&&e.type)return y(g,{effectList:this.effectList,isChild:!0,key:i,layer:t,legendElement:e,messages:this.messages});if(!("preview"in e&&e.preview||"src"in e&&e.src))return null;const l=h(t,s),o={[a.imageryLayerInfoStretched]:l},n={[a.imageryLayerInfoStretched]:l};return y("div",{class:a.layerRow,key:`${i}-row`},y("div",{class:this.classes(a.symbolContainer,n)},this._renderPreview(e,l)),y("div",{class:this.classes(a.layerInfo,o)},d(this.messages,r,!1)||""))}_renderPreview(e,s){const{layer:t}=this;return"preview"in e&&e.preview?y("div",{afterCreate:c,bind:e.preview,class:a.symbol}):"src"in e&&e.src?this._renderImage(e,t,s):null}_renderImage(e,s,t){const{label:r,src:i,opacity:l}=e,o={[a.imageryLayerStretchedImage]:t,[a.symbol]:!t},n={opacity:`${l??s.opacity}`},m=d(this.messages,r,!1);return y("img",{alt:m,"aria-label":m,border:0,class:this.classes(o),height:e.height,src:i,styles:n,width:e.width})}};e([s()],f.prototype,"effectList",void 0),e([s()],f.prototype,"isChild",void 0),e([s()],f.prototype,"layer",void 0),e([s()],f.prototype,"legendElement",void 0),e([s()],f.prototype,"messages",void 0),f=g=e([t("esri.widgets.Legend.styles.classic.LegendElement")],f);export{f as default};