@arcgis/map-components
Version:
ArcGIS Map Components
50 lines (49 loc) • 2.28 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as m } from "../../chunks/runtime.js";
import { html as i } from "lit";
import { watch as r } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as f } from "@arcgis/lumina";
import { f as n } from "../../chunks/utils3.js";
class c extends f {
constructor() {
super(...arguments), this._formats = [];
}
static {
this.properties = { _formats: 16, viewModel: 0, messages: 0 };
}
loaded() {
this.manager.onLifecycle(() => [
r(() => [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 a = [...n.values()];
this._formats = t.format.choiceList.map((e) => {
const s = a.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 o = this._formats.some(({ value: a }) => new RegExp(`\\b${a}\\b`, "iu").test(this.viewModel.templateOptions.format));
if (t.format.defaultValue && !o) {
const a = this._formats.find(({ value: e }) => new RegExp(`\\b${e}\\b`, "iu").test(t.format.defaultValue))?.value;
a && (this.viewModel.templateOptions.format = a);
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 o = t.selectedItems[0]?.value;
this.viewModel.templateOptions.format = o ?? "pdf";
}}>${this._formats.map(({ value: t, label: o }) => i`<calcite-combobox-item .heading=${o} .selected=${t === this.viewModel.templateOptions.format} .value=${t}></calcite-combobox-item>`)}</calcite-combobox></calcite-label></div>`;
}
}
m("arcgis-print-format-select", c);
export {
c as PrintFormatSelect
};