@arcgis/map-components
Version:
ArcGIS Map Components
274 lines (273 loc) • 15 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as $ } from "../../chunks/runtime.js";
import { css as w, html as r } from "lit";
import { ref as y } from "lit/directives/ref.js";
import { u as I } from "../../chunks/useT9n.js";
import { classes as M } from "@arcgis/toolkit/dom";
import { usePropertyChange as C } from "@arcgis/lumina/controllers";
import { m as x } from "../../chunks/useViewModel.js";
import { LitElement as b, createEvent as F, nothing as _, safeClassMap as L } from "@arcgis/lumina";
import { substitute as T } from "@arcgis/core/intl.js";
import { renderingSanitizer as A } from "@arcgis/core/applications/Components/sanitizerUtils.js";
import { a as R, g as D, c as V, b as k, s as d, i as E, d as B } from "../../chunks/feature-utils.js";
import N from "@arcgis/core/core/Collection.js";
import { watch as H } from "@arcgis/core/core/reactiveUtils.js";
import { stripHTML as P } from "@arcgis/core/applications/Components/stringUtils.js";
import Z from "@arcgis/core/popup/Feature.js";
const z = w`:host{display:flex;flex:1 1 auto;background-color:var(--calcite-color-foreground-1);--calcite-color-background: var(--calcite-color-foreground-1)}.root{flex:1 1 auto}.root calcite-icon{box-sizing:content-box}.loading-container{display:flex;justify-content:center;padding:var(--calcite-spacing-md) 0;width:100%}.content-element{margin-bottom:var(--calcite-spacing-lg);padding:0 var(--calcite-spacing-sm);display:flex;flex-direction:column}.content-element:only-child,.content-element:last-child{margin-bottom:var(--calcite-spacing-xxs)}.last-edited-info{padding-top:var(--calcite-spacing-xs);font-size:var(--calcite-font-size-sm)}`, U = x(Z);
class S extends b {
constructor() {
super(...arguments), this.messages = I(), this._rootFlowNode = null, this.internalFlowItems = new N(), this.flowType = "feature", this.viewModel = U(this), this.view = this.viewModel.view, this.icon = "icon", this.isFeatureFromTable = this.viewModel.isFeatureFromTable, this.graphic = this.viewModel.graphic, this.defaultPopupTemplateEnabled = this.viewModel.defaultPopupTemplateEnabled, this.headingLevel = 2, this.spatialReference = this.viewModel.spatialReference, this.timeZone = this.viewModel.timeZone, this.heading = this.viewModel.heading, this.map = this.viewModel.map, this.chartAnimationDisabled = this.viewModel.abilities.chartAnimation, this.hideHeading = !1, this.hideContent = !1, this.hideAttachmentsContent = !1, this.hideCustomContent = !1, this.hideExpressionContent = !1, this.hideFieldsContent = !1, this.hideMediaContent = !1, this.showRelationshipContent = !1, this.hideTextContent = !1, this.showUtilityNetworkContent = !1, this.hideLastEditedInfo = !1, this.autoDestroyDisabled = !1, this.location = this.viewModel.location, this.state = this.viewModel.state, this.arcgisPropertyChange = C()("flowItems", "state"), this.arcgisReady = F();
}
static {
this.properties = { popupTemplate: 16, sourceLayer: 16, fieldInfoMap: 16, values: 16, globalValues: 16, internalFlowItems: 16, flowType: 1, viewModel: 0, view: 0, flowItems: 0, referenceElement: 1, icon: 1, isFeatureFromTable: 36, graphic: 0, defaultPopupTemplateEnabled: 5, headingLevel: 9, spatialReference: 0, timeZone: 1, heading: 0, map: 0, chartAnimationDisabled: 5, hideHeading: 5, hideContent: 5, hideAttachmentsContent: 5, hideCustomContent: 5, hideExpressionContent: 5, hideFieldsContent: 5, hideMediaContent: 5, showRelationshipContent: 5, hideTextContent: 5, showUtilityNetworkContent: 5, hideLastEditedInfo: 5, autoDestroyDisabled: 5, messageOverrides: 0, label: 1, location: 0, state: 32 };
}
static {
this.styles = z;
}
get popupTemplate() {
return R(this.graphic, this.defaultPopupTemplateEnabled) ?? void 0;
}
get sourceLayer() {
return D(this.graphic);
}
get fieldInfoMap() {
return V(k(this.popupTemplate), this.sourceLayer);
}
get values() {
return this.graphic?.attributes ?? {};
}
get globalValues() {
return this.viewModel.formattedAttributes?.global ?? {};
}
async destroy() {
this._removeFlowItems(), await this.manager.destroy();
}
nextMedia(e) {
this._pageContentElementMedia(e, 1);
}
previousMedia(e) {
this._pageContentElementMedia(e, -1);
}
setActiveMedia(e, t) {
const i = this.viewModel.content;
if (!Array.isArray(i))
return;
const s = i[e];
if (s?.type !== "media")
return;
const a = s;
this._setContentElementMedia(a, t);
}
async updateGeometry() {
return await this.viewModel.updateGeometry();
}
loaded() {
this.manager.onLifecycle(() => [
H(() => [this.internalFlowItems?.length], () => this._setFocus())
]);
}
_setContentElementMedia(e, t) {
const i = e.mediaInfos?.length ?? 0, s = (t + i) % i;
e.activeMediaInfoIndex = s;
}
_pageContentElementMedia(e, t) {
const i = this.viewModel.content;
if (!Array.isArray(i))
return;
const s = i[e];
if (s?.type !== "media")
return;
const a = s, { activeMediaInfoIndex: o } = a, n = (o ?? 0) + t;
this._setContentElementMedia(a, n);
}
_removeFlowItems() {
this.internalFlowItems?.destroyAll();
}
_storeRootFlowNode(e) {
this._rootFlowNode = e;
}
_setFocus() {
this._rootFlowNode?.setFocus();
}
_handleDrillInBackClick() {
this.internalFlowItems?.pop()?.destroy();
}
render() {
const { state: e } = this.viewModel, t = r`<div class="container">${e === "error" ? this._renderError() : this._renderContentContainer()}</div>`;
return r`<div class="root">${t}</div>`;
}
_renderError() {
const { messages: e, hideHeading: t } = this;
return r`<calcite-notice icon=exclamation-mark-circle kind=danger open scale=s>${t ? null : r`<div slot=title>${e.error}</div>`}<div slot=message>${e.loadingError}</div></calcite-notice>`;
}
_renderAttachments(e) {
const { values: t, fieldInfoMap: i, sourceLayer: s, globalValues: a } = this, o = d({
values: t,
fieldInfoMap: i,
globalValues: a,
layer: s,
text: e.title
}), n = d({
values: t,
fieldInfoMap: i,
globalValues: a,
layer: s,
text: e.description
});
return r`<arcgis-feature-attachments .headingLevel=${this.headingLevel} .heading=${o} class="content-element" .displayType=${e.displayType} .attachmentKeywords=${e.attachmentKeywords ?? void 0} .attachmentTypes=${e.attachmentTypes ?? void 0} .orderByFields=${e.orderByFields ?? void 0} .graphic=${this.graphic ?? void 0} .description=${n} hide-preview-image-attachment-name .messages=${this.messages}></arcgis-feature-attachments>`;
}
_renderCustom(e) {
return r`<arcgis-feature-content .creator=${e.creator} .destroyer=${e.destroyer ?? void 0} .graphic=${this.graphic ?? void 0} class="content-element"></arcgis-feature-content>`;
}
_renderFields(e, t) {
const i = this.viewModel.formattedAttributes, { values: s, fieldInfoMap: a, sourceLayer: o, popupTemplate: n, globalValues: l, graphic: c } = this, h = !!e?.fieldInfos, u = (e.fieldInfos ?? n?.fieldInfos ?? [])?.filter(({ fieldName: g }) => !!g && (E(g) || B(g) || g in s)), f = n?.expressionInfos, m = d({
values: s,
fieldInfoMap: a,
globalValues: l,
layer: o,
text: e.title
}), v = d({
values: s,
fieldInfoMap: a,
globalValues: l,
layer: o,
text: e.description
});
return r`<arcgis-feature-fields .headingLevel=${this.headingLevel} .heading=${m} class="content-element" .messages=${this.messages} .graphic=${c ?? void 0} .isContentFieldInfos=${h} .layer=${o} .description=${v} .values=${{
...i?.global,
...i?.content?.[t]
}} .fieldInfos=${u} .expressionInfos=${f ?? void 0}></arcgis-feature-fields>`;
}
_renderMedia(e, t) {
const { values: i, graphic: s, fieldInfoMap: a, sourceLayer: o, popupTemplate: n, globalValues: l } = this, { formattedAttributes: c, relatedInfos: h, expressionAttributes: p } = this.viewModel, u = {
...c?.global,
...c?.content?.[t]
}, f = d({
values: i,
fieldInfoMap: a,
globalValues: l,
layer: o,
text: e.title
}), m = d({
values: i,
fieldInfoMap: a,
globalValues: l,
layer: o,
text: e.description
});
return r`<arcgis-feature-media .activeMediaInfoIndex=${e.activeMediaInfoIndex ?? 0} .chartAnimationDisabled=${this.chartAnimationDisabled} .headingLevel=${this.headingLevel} .heading=${f} class="content-element" .description=${m} .values=${i} .expressionValues=${p} .layer=${o} .graphic=${s ?? void 0} .messages=${this.messages} .fieldInfoMap=${a} .mediaInfos=${e.mediaInfos ?? []} .popupTemplate=${n ?? void 0} .relatedInfos=${h} .formattedValues=${u}></arcgis-feature-media>`;
}
_renderText(e) {
const { values: t, fieldInfoMap: i, sourceLayer: s, globalValues: a } = this;
return r`<arcgis-feature-content .creator=${d({
values: t,
fieldInfoMap: i,
globalValues: a,
layer: s,
text: e.text
})} .graphic=${this.graphic ?? void 0} class="content-element"></arcgis-feature-content>`;
}
_renderExpression(e, t) {
const i = this.viewModel.formattedAttributes, { fieldInfoMap: s } = this;
return r`<arcgis-feature-expression .expressionInfo=${e.expressionInfo} .map=${this.map ?? void 0} .spatialReference=${this.spatialReference ?? void 0} .view=${this.viewModel.view ?? void 0} .graphic=${this.graphic ?? void 0} .location=${this.location ?? void 0} .headingLevel=${this.headingLevel} class="content-element" .interceptor=${this.viewModel.interceptor} .messages=${this.messages} .fieldInfoMap=${s} .values=${{
...i?.global,
...i?.content?.[t]
}}></arcgis-feature-expression>`;
}
_renderRelationship(e, t) {
const { values: i, graphic: s, fieldInfoMap: a, sourceLayer: o, globalValues: n } = this, { displayCount: l, orderByFields: c, relationshipId: h } = e, { formattedAttributes: p, view: u } = this.viewModel, f = {
...p?.global,
...p?.content?.[t]
}, m = d({
values: i,
fieldInfoMap: a,
globalValues: n,
layer: o,
text: e.title
}), v = d({
values: i,
fieldInfoMap: a,
globalValues: n,
layer: o,
text: e.description
});
return r`<arcgis-feature-relationship .autoDestroyDisabled=${this.autoDestroyDisabled} class="content-element" .flowItems=${this.flowItems ?? this.internalFlowItems} .description=${v} .layer=${o} .map=${this.map ?? void 0} .displayCount=${l} .graphic=${s ?? void 0} .heading=${m} .headingLevel=${this.headingLevel} .messages=${this.messages} .orderByFields=${c ?? void 0} .relationshipId=${h ?? void 0} .spatialReference=${this.spatialReference ?? void 0} .timeZone=${this.timeZone ?? void 0} use-feature-next-flow-item .values=${f} .view=${u ?? void 0}></arcgis-feature-relationship>`;
}
_renderAssociation(e) {
const { fieldInfoMap: t, globalValues: i, graphic: s, messages: a, sourceLayer: o, values: n } = this, l = d({
values: n,
fieldInfoMap: t,
globalValues: i,
layer: o,
text: e.title
}), c = d({
values: n,
fieldInfoMap: t,
globalValues: i,
layer: o,
text: e.description
});
return r`<arcgis-feature-utility-network-associations .autoDestroyDisabled=${this.autoDestroyDisabled} .associationTypes=${e.associationTypes} class="content-element" .description=${c} .flowItems=${this.flowItems ?? this.internalFlowItems} .graphic=${s ?? void 0} .heading=${l} .headingLevel=${this.headingLevel} .layer=${o} .map=${this.map ?? void 0} .messages=${a} .parentFeatureViewModel=${this.viewModel} .referenceElement=${this.referenceElement} .spatialReference=${this.spatialReference ?? void 0} .timeZone=${this.timeZone ?? void 0} use-feature-next-flow-item .view=${this.viewModel.view ?? void 0}></arcgis-feature-utility-network-associations>`;
}
_renderContentElement(e, t) {
switch (e.type) {
case "attachments":
return this.hideAttachmentsContent ? null : this._renderAttachments(e);
case "custom":
return this.hideCustomContent ? null : this._renderCustom(e);
case "fields":
return this.hideFieldsContent ? null : this._renderFields(e, t);
case "media":
return this.hideMediaContent ? null : this._renderMedia(e, t);
case "text":
return this.hideTextContent ? null : this._renderText(e);
case "expression":
return this.hideExpressionContent ? null : this._renderExpression(e, t);
case "relationship":
return this.showRelationshipContent ? this._renderRelationship(e, t) : null;
case "utility-network-associations":
return this.showUtilityNetworkContent ? this._renderAssociation(e) : null;
default:
return null;
}
}
_renderContent() {
const { content: e, graphic: t } = this.viewModel;
if (!e)
return null;
if (Array.isArray(e) && e.length)
return e.length ? e.map(this._renderContentElement, this) : null;
if (typeof e == "string") {
const { values: i, fieldInfoMap: s, sourceLayer: a, globalValues: o } = this;
return r`<arcgis-feature-content .creator=${d({
values: i,
fieldInfoMap: s,
globalValues: o,
layer: a,
text: e
})} .graphic=${t ?? void 0} class="content-element"></arcgis-feature-content>`;
}
return e instanceof HTMLElement ? e : null;
}
_renderContentContainer() {
const { flowItems: e, hideContent: t, internalFlowItems: i, headingLevel: s, state: a, messages: o, heading: n, hideHeading: l } = this, c = t ? null : r`<div class="main">${[this._renderContent(), this._renderLastEditInfo()]}</div>`, h = o.returnToInitialFeature ?? "";
return e ? c : r`<calcite-flow ${y(this._storeRootFlowNode)}><calcite-flow-item .loading=${a === "loading"} .headingLevel=${s} .heading=${l ? void 0 : P(n)} .selected=${!i.length}>${!l && n ? r`<div slot=heading><div .innerHTML=${A.sanitize(n ?? "") ?? ""}></div></div>` : null}${c}</calcite-flow-item>${i.toArray().map((p, u) => r`<calcite-flow-item =${(f) => {
f.preventDefault(), this._handleDrillInBackClick();
}} .loading=${a === "loading"} .headingLevel=${s} .selected=${u === i.length - 1}><calcite-action icon=move-up =${this._removeFlowItems} slot=header-actions-start .text=${h} title=${h ?? _}></calcite-action>${p}</calcite-flow-item>`)}</calcite-flow>`;
}
_renderLastEditInfo() {
const { hideLastEditedInfo: e, messages: t } = this, { lastEditInfo: i } = this.viewModel;
if (!i || e)
return null;
const { date: s, user: a } = i, o = i.type === "edit" ? a ? t.lastEditedByUser : t.lastEdited : a ? t.lastCreatedByUser : t.lastCreated, n = T(o ?? "", {
date: s,
user: a
});
return r`<div class=${L(M("last-edited-info", "content-element"))}>${n}</div>`;
}
}
$("arcgis-feature-next", S);
export {
S as ArcgisFeatureNext
};