You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
7.9 KiB
19 lines
7.9 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../../chunks/tslib.es6 ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/Logger ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../Widget ./ClassicCSS ./support/relationshipUtils ./support/univariateUtils ../support/styleUtils ../../support/globalCss ../../support/Heading ../../support/widgetUtils ../../support/decorators/messageBundle ../../support/jsxFactory".split(" "),function(w,y,u,L,M,C,D,b,E,q,p,F,G,N,H,c){const I=`${b.legend}__`, |
|
B={display:"flex",alignItems:"flex-start"},z={marginLeft:"3px"},v={display:"table-cell",verticalAlign:"middle"};u=class extends D{constructor(a,d){super(a,d);this.activeLayerInfos=null;this.headingLevel=3;this.messages=null;this.type="classic"}render(){const a=this.activeLayerInfos?.toArray().map(d=>this._renderLegendForLayer(d)).filter(d=>!!d);return c.tsx("div",null,a?.length?a:c.tsx("div",{class:b.css.message},this.messages.noLegend))}_renderLegendForLayer(a){if(!a.ready)return null;var d=!!a.children.length; |
|
const e=`${I}${a.layer.uid}-version-${a.version}`,g=a.title?G.Heading({level:this.headingLevel,class:this.classes(F.globalCss.heading,b.css.label)},a.title):null;if(d)return d=a.children.map(f=>this._renderLegendForLayer(f)).toArray(),c.tsx("div",{class:this.classes(b.css.service,b.css.groupLayer),key:e},g,d);if((d=a.legendElements)&&!d.length)return null;d=d.map(f=>this._renderLegendForElement(f,a.layer,a.effectList)).filter(f=>!!f);return d.length?c.tsx("div",{class:this.classes(b.css.service,{[b.css.groupLayerChild]:!!a.parent}), |
|
key:e},g,c.tsx("div",{class:b.css.layer},d)):null}_renderLegendForElement(a,d,e,g){var f="color-ramp"===a.type,h="opacity-ramp"===a.type;const m="size-ramp"===a.type;let n=null;if("symbol-table"===a.type||m){var k=a.infos.map(x=>this._renderLegendForElementInfo(x,d,e,m,a.legendType)).filter(x=>!!x);k.length&&(n=c.tsx("div",{class:b.css.layerBody},k))}else"color-ramp"===a.type||"opacity-ramp"===a.type||"heatmap-ramp"===a.type||"stretch-ramp"===a.type?n=this._renderLegendForRamp(a,d.opacity):"relationship-ramp"=== |
|
a.type?n=E.renderRelationshipRamp(a,this.id,{opacity:d.opacity,effectList:e,ariaLabel:this.messages.previewRelationshipRampAriaLabel}):"pie-chart-ramp"===a.type?n=this._renderPieChartRamp(a):"univariate-above-and-below-ramp"===a.type?n=this._renderUnivariateAboveAndBelowRamp(a,d.opacity,e):"univariate-color-size-ramp"===a.type&&(n=this._renderUnivariateColorSizeRamp(a,d.opacity,e));if(!n)return null;k=a.title;var l=null;"string"===typeof k?l=k:k&&(l=p.getTitle(this.messages,k,f||h),l=p.isRendererTitle(k, |
|
f||h)&&k.title?`${k.title} (${l})`:l);f=g?b.css.layerChildTable:b.css.layerTable;h=l?c.tsx("div",{class:b.css.layerCaption},l):null;return c.tsx("div",{class:this.classes(f,{[b.css.layerTableSizeRamp]:m||!g})},h,n)}_renderPieChartRamp(a){return c.tsx("div",{afterCreate:p.attachToNode,bind:a.preview})}_renderUnivariateAboveAndBelowRamp(a,d,e){const {sizeRampElement:g,colorRampElement:f}=q.getUnivariateAboveAndBelowRampElements(a,d);if(!g)return null;var h=this.messages?.previewColorRampAriaLabel,m= |
|
q.getUnivariateColorRampSize(g,"above",!0);a=q.getUnivariateColorRampSize(g,"below",!0);const n=q.getUnivariateColorRampPreview(f,{width:12,height:m,rampAlignment:"vertical",opacity:d,type:"above",effectList:e,ariaLabel:h});d=q.getUnivariateColorRampPreview(f,{width:12,height:a,rampAlignment:"vertical",opacity:d,type:"below",effectList:e,ariaLabel:h});var k=q.getUnivariateColorRampMargin(g);const l=g.infos.map(t=>t.label);e=l.map((t,r)=>{const A=2===r;return 0===r?c.tsx("div",{class:t?n?b.css.univariateAboveAndBelowLabel: |
|
b.css.rampLabel:void 0,key:r},t):A?c.tsx("div",null):null});const x=l.length-1,J=Math.floor(l.length/2);h=l.map((t,r)=>{const A=r===x;return r===J||A?c.tsx("div",{class:t?n?b.css.univariateAboveAndBelowLabel:b.css.rampLabel:void 0,key:r},t):null});const K={display:"table-cell",verticalAlign:"middle"};k={marginTop:`${k}px`};m={height:`${m}px`};a={height:`${a}px`};return c.tsx("div",{key:"univariate-above-and-below-ramp-preview",styles:B},c.tsx("div",{class:b.css.layerBody},g.infos.map((t,r)=>c.tsx("div", |
|
{class:this.classes(b.css.layerRow,b.css.sizeRamp)},c.tsx("div",{afterCreate:p.attachToNode,bind:t.preview,class:b.css.symbol,styles:K}),n||0!==r%2?null:c.tsx("div",{class:b.css.layerInfo},l[r])))),n?c.tsx("div",{key:"color-ramp-preview",styles:k},c.tsx("div",{styles:z},c.tsx("div",{styles:v},c.tsx("div",{afterCreate:p.attachToNode,bind:n,class:b.css.rampContainer})),c.tsx("div",{styles:v},c.tsx("div",{class:b.css.rampLabelsContainer,styles:m},e))),c.tsx("div",{styles:z},c.tsx("div",{styles:v},c.tsx("div", |
|
{afterCreate:p.attachToNode,bind:d,class:b.css.rampContainer})),c.tsx("div",{styles:v},c.tsx("div",{class:b.css.rampLabelsContainer,styles:a},h)))):null)}_renderUnivariateColorSizeRamp(a,d,e){const {sizeRampElement:g,colorRampElement:f}=q.getUnivariateColorSizeRampElements(a);if(!g)return null;var h=q.getUnivariateColorRampMargin(g);a=q.getUnivariateColorRampSize(g,"full",!1);d=q.getUnivariateColorRampPreview(f,{width:12,height:a,rampAlignment:"vertical",opacity:d,type:"full",effectList:e,ariaLabel:this.messages?.previewColorRampAriaLabel}); |
|
const m=g.infos.length-1;e=g.infos.map((k,l)=>0===l||l===m?c.tsx("div",{class:k.label?f?b.css.univariateAboveAndBelowLabel:b.css.rampLabel:void 0,key:l},k.label):null);const n={display:"table-cell",verticalAlign:"middle"};h={marginTop:`${h}px`};a={height:`${a}px`};return c.tsx("div",{key:"univariate-above-and-below-ramp-preview",styles:B},c.tsx("div",{class:b.css.layerBody},g.infos.map(k=>c.tsx("div",{class:this.classes(b.css.layerRow,b.css.sizeRamp)},c.tsx("div",{afterCreate:p.attachToNode,bind:k.preview, |
|
class:b.css.symbol,styles:n})))),c.tsx("div",{key:"color-ramp-preview",styles:h},c.tsx("div",{styles:z},c.tsx("div",{styles:v},c.tsx("div",{afterCreate:p.attachToNode,bind:d,class:b.css.rampContainer})),c.tsx("div",{styles:v},c.tsx("div",{class:b.css.rampLabelsContainer,styles:a},e)))))}_renderLegendForRamp(a,d){const e=a.infos,g="heatmap-ramp"===a.type,f="stretch-ramp"===a.type,h=a.preview;h.className=`${b.css.colorRamp} ${"opacity-ramp"===a.type?b.css.opacityRamp:""}`;null!=d&&(h.style.opacity= |
|
d.toString());a=e.map(m=>c.tsx("div",{class:m.label?b.css.rampLabel:void 0},g?this.messages[m.label]||m.label:f?p.getStretchStopLabel(m,this.messages):m.label));d={height:h.style.height};return c.tsx("div",{class:b.css.layerRow},c.tsx("div",{class:b.css.symbolContainer,styles:{width:"24px"}},c.tsx("div",{afterCreate:p.attachToNode,bind:h,class:b.css.rampContainer})),c.tsx("div",{class:b.css.layerInfo},c.tsx("div",{class:b.css.rampLabelsContainer,styles:d},a)))}_renderLegendForElementInfo(a,d,e,g, |
|
f){if(a.type)return this._renderLegendForElement(a,d,e,!0);e=null;f=p.isImageryStretchedLegend(d,f);a.preview?e=c.tsx("div",{afterCreate:p.attachToNode,bind:a.preview,class:b.css.symbol}):a.src&&(e=this._renderImage(a,d,f));if(!e)return null;d={[b.css.imageryLayerInfoStretched]:f};return c.tsx("div",{class:b.css.layerRow},c.tsx("div",{class:this.classes(b.css.symbolContainer,{[b.css.imageryLayerInfoStretched]:f,[b.css.sizeRamp]:!f&&g})},e),c.tsx("div",{class:this.classes(b.css.layerInfo,d)},p.getTitle(this.messages, |
|
a.label,!1)||""))}_renderImage(a,d,e){const {label:g,src:f,opacity:h}=a;e={[b.css.imageryLayerStretchedImage]:e,[b.css.symbol]:!e};d={opacity:`${null!=h?h:d.opacity}`};return c.tsx("img",{alt:p.getTitle(this.messages,g,!1),"aria-label":p.getTitle(this.messages,g,!1),border:0,class:this.classes(e),height:a.height,src:f,styles:d,width:a.width})}};w.__decorate([y.property()],u.prototype,"activeLayerInfos",void 0);w.__decorate([y.property()],u.prototype,"headingLevel",void 0);w.__decorate([y.property(), |
|
H.messageBundle("esri/widgets/Legend/t9n/Legend")],u.prototype,"messages",void 0);w.__decorate([y.property({readOnly:!0})],u.prototype,"type",void 0);return u=w.__decorate([C.subclass("esri.widgets.Legend.styles.Classic")],u)}); |