UNPKG

@arcgis/map-components

Version:
56 lines (55 loc) 2.53 kB
import { c as m } from "../../chunks/runtime.js"; import { html as i } from "lit-html"; import { keyed as r } from "lit-html/directives/keyed.js"; import { watch as f } from "@arcgis/core/core/reactiveUtils.js"; import { LitElement as n, noShadowRoot as p } from "@arcgis/lumina"; import { f as c } from "../../chunks/utils.js"; /*! All material copyright Esri, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. v4.33.13 */ class d extends n { constructor() { super(...arguments), this._formats = []; } static { this.properties = { _formats: 16, viewModel: 0, messages: 0 }; } static { this.shadowRootOptions = p; } loaded() { this.manager.onLifecycle(() => [ f(() => [this.viewModel.templateOptions.format, this.viewModel.templatesInfo?.format], () => { const t = this.viewModel.templatesInfo; if (!t) return; if (this._formats.length !== t.format.choiceList.length) { const o = [...c.values()]; this._formats = t.format.choiceList.map((e) => { const s = o.find((l) => new RegExp(`\\b${l}\\b`, "iu").test(e)) ?? e; return { value: s, label: e === s ? e.toUpperCase() : e }; }).sort((e, s) => e.label.localeCompare(s.label)); } const a = this._formats.some(({ value: o }) => new RegExp(`\\b${o}\\b`, "iu").test(this.viewModel.templateOptions.format)); if (t.format.defaultValue && !a) { const o = this._formats.find(({ value: e }) => new RegExp(`\\b${e}\\b`, "iu").test(t.format.defaultValue))?.value; o && (this.viewModel.templateOptions.format = o); return; } }, { initial: !0 }) ]); } render() { return i`<div><calcite-label>${this.messages.fileFormatTitle}<calcite-combobox clear-disabled .label=${this.messages.formatDefaultOption} max-items=6 .placeholder=${this.messages.formatDefaultOption} selection-mode=single-persist @calciteComboboxChange=${({ currentTarget: t }) => { const a = t.selectedItems[0]?.value; this.viewModel.templateOptions.format = a ?? "pdf"; }}>${this._formats.map(({ value: t, label: a }, o) => r(`file-format-${o}`, i`<calcite-combobox-item .heading=${a} .selected=${t === this.viewModel.templateOptions.format} .value=${t}></calcite-combobox-item>`))}</calcite-combobox></calcite-label></div>`; } } m("arcgis-print-format-select", d); export { d as PrintFormatSelect };