UNPKG

@arcgis/map-components

Version:
47 lines (46 loc) 3.52 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { c as n } from "../../chunks/runtime.js"; import { css as c, html as a } from "lit"; import { LitElement as d, safeClassMap as o } from "@arcgis/lumina"; import { classes as g } from "@arcgis/toolkit/dom"; import { H as m } from "../../chunks/heading.js"; const h = c`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}:host{display:block}.layers{display:flex;flex-direction:column;gap:var(--arcgis-internal-legend-layer-gap)}.layers>.layer{position:relative}.layers>.layer:not(:last-child):after{content:"";position:absolute;left:0;right:0;bottom:calc(var(--arcgis-internal-legend-layer-gap) / -2);border-bottom:1px solid var(--calcite-color-border-2)}.layers>.layer:last-child{padding-bottom:var(--arcgis-internal-legend-layer-gap)}.layer>.esri-widget__heading{margin:var(--arcgis-internal-legend-heading-margin)}.no-legend{padding:var(--calcite-spacing-sm) var(--calcite-spacing-md)}.layer{padding:var(--arcgis-internal-legend-layer-padding);word-wrap:break-word}.layer-elements{margin-left:var(--calcite-spacing-sm);display:flex;flex-direction:column;gap:var(--arcgis-internal-legend-layer-element-gap);overflow:auto}.layer-children{display:flex;flex-direction:column;gap:var(--arcgis-internal-legend-layer-gap)}.layer-children>.layer{position:relative}.layer-children>.layer:not(:last-child):after{content:"";position:absolute;left:0;right:0;bottom:calc(var(--arcgis-internal-legend-layer-gap) / -2);border-bottom:1px solid var(--calcite-color-border-2)}.layer-child{margin-left:var(--calcite-spacing-sm);padding:0}:dir(rtl) .layer-elements,:dir(rtl) .layer-child{margin-right:var(--calcite-spacing-sm);margin-left:0;overflow:auto}`; class y extends d { constructor() { super(...arguments), this.headingLevel = 3, this.type = "classic"; } static { this.properties = { activeLayerInfos: 0, headingLevel: 9, type: 32, messages: 0 }; } static { this.styles = h; } render() { const r = this.activeLayerInfos?.toArray().map((l) => this._renderLegendForLayer(l)).filter(Boolean); return r?.length ? a`<section class="layers">${r}</section>` : a`<div class="no-legend">${this.messages.noLegend}</div>`; } _renderLegendForLayer(e) { if (!e.ready) return null; const r = e.title ? m({ level: this.headingLevel, children: e.title }) : null; if (e.children.length) { const l = e.children.toArray().map((i) => this._renderLegendForLayer(i)); return a`<section class="layer">${r}<div class="layer-children">${l}</div></section>`; } return this._renderLegendElementsForLayer(e, r); } _renderLegendElementsForLayer(e, r) { const l = e.legendElements?.filter(Boolean); if (!l?.length) return null; const i = l.map((s) => a`<arcgis-legend-classic-element .cssEffectFilter=${e.cssEffectFilter ?? void 0} .layer=${e.layer} .legendElement=${s} .messages=${this.messages}></arcgis-legend-classic-element>`), t = { "layer-child": !!e.parent }; return a`<section class=${o(g("layer", t))}>${r}<div class="layer-elements">${i}</div></section>`; } } n("arcgis-legend-classic-view", y); export { y as LegendClassicView };