UNPKG

@arcgis/map-components

Version:
70 lines (69 loc) 4.69 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { c as p } from "../../chunks/runtime.js"; import { css as m, html as s } from "lit"; import { addProxy as g } from "@arcgis/core/core/urlUtils.js"; import { LitElement as f, safeClassMap as h, nothing as v } from "@arcgis/lumina"; import { classes as x } from "@arcgis/toolkit/dom"; import { hasSameOrigin as u } from "@arcgis/toolkit/url"; import { i as $ } from "../../chunks/print-exports-panel-item-popover.js"; const w = m`.export-section{padding:var(--calcite-spacing-xxs)}.export-section-centered{text-align:center}.exported-files-empty{display:flex;flex-direction:column;align-items:center;padding:var(--calcite-spacing-lg) var(--calcite-spacing-sm);font-size:small}.exported-files-title{font-weight:700;font-size:var(--calcite-font-size)}.exported-file{display:flex;align-items:center;justify-content:space-between}.exported-file-link-title,.exported-file-link-description{word-wrap:break-word;word-break:break-all;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}`; function k(a) { const { state: e, extension: t } = a; switch (e) { case "pending": return "spinner"; case "error": return "exclamation-mark-circle"; default: return t?.toLowerCase()?.includes("pdf") ? "file-pdf" : "file"; } } class b extends f { constructor() { super(...arguments), this._handleLinkClick = (e) => { if (e?.state !== "ready" || !e.url) return; const t = e.url, i = document.createElement("a"); i.target = "_blank", i.href = t, i.rel = "noreferrer", i.download = e.formattedName ?? ""; { i.click(); return; } }; } static { this.properties = { showSaveAs: 5, viewModel: 0, messages: 0, allowedFormatsForSaving: 1, arcgisSaveAs: 0 }; } static { this.styles = w; } loaded() { this.manager.onLifecycle(() => [this.viewModel.exportedLinks.on("change", () => this.requestUpdate())]); } render() { const e = this.viewModel.exportedLinks, t = { "export-section-centered": !e.length }; return s`<section class=${h(x("export-section", t))}>${e.length === 0 ? s`<div class="exported-files-empty"><calcite-icon icon=file scale=l></calcite-icon><div><p class="exported-files-title">${this.messages.noExportedFiles}</p><div>${this.messages.exportHint}</div></div></div>` : s`<calcite-list .filterEnabled=${e.length > 10} .label=${this.messages.exportedLinksList} selection-mode=none>${e.map((i) => s`<calcite-list-item .label=${i.formattedName ?? ""}>${this._renderExportedLinkItemContent(i)}${this._renderExportedLinkItemIcon(i)}${this._renderExportedLinkItemAction(i)}</calcite-list-item><arcgis-print-exports-panel-item-popover .allowedFormatsForSaving=${this.allowedFormatsForSaving} .arcgisSaveAs=${this.arcgisSaveAs} .exportedLink=${i} .messages=${this.messages} .showSaveAs=${this.showSaveAs} .viewModel=${this.viewModel}></arcgis-print-exports-panel-item-popover>`)}</calcite-list>`}</section>`; } _renderExportedLinkItemContent(e) { const t = this.messages, { url: i, state: o, error: n } = e, l = e.formattedName ?? ""; let r = i || null; r && (r = g(r)); const c = u(r, document.location.href), d = o === "error" ? n?.name === "print-task:cim-symbol-unsupported" ? t.exportWebMapCIMError : t.exportWebMapError : null; return s`<div class="exported-file" slot=content @click=${() => this._handleLinkClick(e)}><div><div class="exported-file-link-title">${l}</div><div class="exported-file-link-description">${o === "pending" ? t.generatingExport : d || (c ? t.ready : t.linkReady)}</div></div>${o === "ready" ? s`<calcite-icon .ariaLabel=${`${l}. ${t.linkReady}`} .icon=${c ? "download-to" : "launch"} scale=s slot=content-end></calcite-icon>` : null}</div>`; } _renderExportedLinkItemIcon(e) { return e.state === "pending" ? s`<calcite-loader inline .label=${this.messages.generatingExport} scale=m slot=content-start></calcite-loader>` : s`<calcite-icon .icon=${k(e)} scale=s slot=content-start></calcite-icon>`; } _renderExportedLinkItemAction(e) { const { state: t } = e, i = e.formattedName ?? "", o = this.messages, n = this.showSaveAs && t !== "error" && $(this.allowedFormatsForSaving, e.extension); return t !== "pending" ? s`<calcite-action .icon=${n ? "ellipsis" : "x"} id=${(n ? `${i}-popover-button` : void 0) ?? v} @click=${n ? void 0 : () => { this.viewModel.exportedLinks.remove(e); }} slot=actions-end .text=${n ? o.options : o.delete}></calcite-action>` : null; } } p("arcgis-print-exports-panel", b); export { b as PrintExportsPanel };