@arcgis/map-components
Version:
ArcGIS Map Components
416 lines (415 loc) • 33.9 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as B } from "../../chunks/runtime.js";
import { css as R, html as o } from "lit";
import { keyed as y } from "lit/directives/keyed.js";
import O from "@arcgis/core/support/actions/ActionButton.js";
import E from "@arcgis/core/core/Collection.js";
import H from "@arcgis/core/popup/Features.js";
import { LitElement as P, createEvent as A, renderElement as z, nothing as p, safeClassMap as I } from "@arcgis/lumina";
import { usePropertyChange as Z, bypassReadOnly as k } from "@arcgis/lumina/controllers";
import { slotChangeHasContent as D, classes as x } from "@arcgis/toolkit/dom";
import { createRef as m, ref as f } from "lit/directives/ref.js";
import { g as S } from "../../chunks/feature-utils.js";
import { initializeProjection as V } from "@arcgis/core/applications/Components/featureUtils.js";
import { t as U, z as j } from "../../chunks/action-utils.js";
import { m as q } from "../../chunks/useViewModel.js";
import { renderingSanitizer as b } from "@arcgis/core/applications/Components/sanitizerUtils.js";
import { stripHTML as T } from "@arcgis/core/applications/Components/stringUtils.js";
import { substitute as g, formatNumber as C } from "@arcgis/core/intl.js";
import { u as G } from "../../chunks/useT9n.js";
import { watch as c } from "@arcgis/core/core/reactiveUtils.js";
import { a as N } from "../../chunks/maybe.js";
const K = R`:host{display:flex;overflow:hidden;flex:1 1 auto}.root{--calcite-color-background: var(--calcite-color-foreground-1);display:flex;overflow:hidden;flex:1 1 auto;flex-direction:column}.root img{image-orientation:from-image}.flow-item-collapsed{--calcite-flow-item-header-border-block-end: none}.container{display:flex;flex:1 1 auto;background-color:var(--calcite-color-foreground-1)}.container calcite-list{width:100%}.container:not(:empty,.content-hidden){padding:var(--arcgis-internal-padding-md, var(--calcite-spacing-md))}.root .arcgis-feature,.root .arcgis-feature-relationship,.root .arcgis-feature-utility-network-associations{background-color:transparent}.heading{word-break:break-word;word-wrap:break-word}.header,.footer{display:flex;align-items:center;justify-content:flex-end;background-color:var(--calcite-color-foreground-1)}.footer{flex:1}.pagination-text{padding-inline:var(--calcite-spacing-sm);color:var(--calcite-color-text-3);font-size:var(--calcite-font-size-sm)}.loader{align-self:center;padding-inline:var(--calcite-spacing-lg)}.pagination-action-bar{flex:1}.pagination-menu-button{padding-inline:var(--calcite-spacing-xxs);border-inline-start:var(--calcite-border-width-sm) solid var(--calcite-color-border-3)}.icon{display:inline-block;flex:0 0 var(--calcite-spacing-lg);width:var(--calcite-spacing-lg);height:var(--calcite-spacing-lg)}.action-image{flex:0 0 var(--calcite-spacing-lg);background-position:50% 50%;background-repeat:no-repeat;background-size:contain;width:var(--calcite-spacing-lg);height:var(--calcite-spacing-lg)}.header{border-block-end:var(--calcite-border-width-sm) solid var(--calcite-color-border-3)}.content-feature{--calcite-flow-item-footer-padding: 0}.feature-menu-observer{position:relative;bottom:var(--calcite-spacing-xxl);z-index:2;text-align:center}.action-exit{transform:scaleX(-1)}.flow-item-drill-in{--calcite-flow-item-footer-padding: 0}`;
function W(F) {
return F?.declaredClass.startsWith("esri.layers.") ?? !1;
}
function X(F) {
if (!(!F || !("featureReduction" in F)))
return F.featureReduction?.type;
}
const J = q(H);
class Q extends P {
constructor() {
super(...arguments), this._zoomToFeature = new O({
icon: "magnifying-glass-plus",
id: "zoom-to-feature",
title: "{messages.zoom}"
}), this._fetchFeaturesController = null, this._featureMenuIntersectionObserverCallback = ([e]) => {
e?.isIntersecting && this.viewModel.featurePage != null && this.viewModel.featurePage++;
}, this._featureMenuIntersectionObserver = new IntersectionObserver(this._featureMenuIntersectionObserverCallback, {
root: window.document
}), this._featureMenuIntersectionObserverNode = null, this._focusTrapNode = m(), this._focusTrapAnimationFrameId = null, this._rootFlowItemNode = m(), this._featureMenuViewportNode = m(), this._actionBarMenuNode = m(), this._flowContainerNode = m(), this._aggregatedFeaturesComponent = m(), this.messages = G(), this._selectedFeatureComponent = m(), this._cancelOpenRelatedFeature = () => {
this._openRelatedFeatureAbortController = N(this._openRelatedFeatureAbortController);
}, this._openRelatedFeatureAbortController = null, this.flowItems = new E(), this._aggregatedFeatureCount = 0, this._selectedAggregatedFeatureIndex = -1, this._aggregatedFeaturesLoading = !1, this._hasActionsStartSlotContent = !1, this._hasActionsEndSlotContent = !1, this.viewModel = J(this), this.actions = this.viewModel.actions, this.active = this.viewModel.active, this.autoDestroyDisabled = !1, this.focusTrapEnabled = !1, this.collapsed = !1, this.content = this.viewModel.content, this.defaultPopupTemplateEnabled = this.viewModel.defaultPopupTemplateEnabled, this.effectiveHeading = this.viewModel.effectiveHeading, this.featureCount = this.viewModel.featureCount, this.featureMenuOpen = !1, this.featureNavigationTop = !1, this.features = this.viewModel.features, this.featuresPerPage = this.viewModel.featuresPerPage, this.featureItemAbilities = this.viewModel.featureItemAbilities, this.goToOverride = this.viewModel.goToOverride, this.headerActions = new E(), this.heading = this.viewModel.heading, this.headingLevel = 2, this.hideActionBar = !1, this.hideCloseButton = !1, this.hideFeatureMenuHeading = !1, this.hideFeatureNavigation = !1, this.hideFeatureListLayerTitle = !1, this.hideHeading = !1, this.hideSelectFeature = !1, this.hideSpinner = !1, this.hideContent = !1, this.chartAnimationDisabled = this.viewModel.featureItemAbilities?.chartAnimation, this.hideAttachmentsContent = this.viewModel.featureItemAbilities?.attachmentsContent, this.hideCustomContent = this.viewModel.featureItemAbilities?.customContent, this.hideExpressionContent = !1, this.hideFieldsContent = this.viewModel.featureItemAbilities?.fieldsContent, this.hideMediaContent = this.viewModel.featureItemAbilities?.mediaContent, this.hideRelationshipContent = this.viewModel.featureItemAbilities?.relationshipContent, this.hideTextContent = this.viewModel.featureItemAbilities?.textContent, this.hideUtilityNetworkContent = this.viewModel.featureItemAbilities?.utilityNetworkAssociationsContent, this.hideLastEditedInfo = !1, this.highlightDisabled = this.viewModel.highlightEnabled, this.includeDefaultActionsDisabled = this.viewModel.includeDefaultActions, this.initialDisplayMode = this.viewModel.initialDisplayMode, this.location = this.viewModel.location, this.map = this.viewModel.map, this.open = this.viewModel.open, this.promises = this.viewModel.promises, this.responsiveActionsEnabled = !1, this.selectedFeature = this.viewModel.selectedFeature, this.selectedFeatureIndex = this.viewModel.selectedFeatureIndex, this.showCollapseButton = !1, this.spatialReference = this.viewModel.spatialReference, this.state = this.viewModel.state, this.timeZone = this.viewModel.timeZone, this.updateLocationEnabled = this.viewModel.updateLocationEnabled, this.view = this.viewModel.view, this.arcgisPropertyChange = Z()("active", "collapsed", "effectiveHeading", "featureCount", "featureMenuOpen", "features", "promises", "selectedDrillInFeature", "selectedFeature", "selectedFeatureComponent", "selectedFeatureIndex", "state", "open"), this.arcgisReady = A(), this.arcgisClose = A(), this.arcgisTriggerAction = A();
}
static {
this.properties = { _openRelatedFeatureAbortController: 16, flowItems: 16, _aggregatedFeatureCount: 16, _selectedAggregatedFeatureIndex: 16, _aggregatedFeaturesLoading: 16, _hasActionsStartSlotContent: 16, _hasActionsEndSlotContent: 16, _hideActionText: 16, _featureNavigationVisible: 16, _isCollapsed: 16, _collapseEnabled: 16, _featureFlowItemSelected: 16, viewModel: 0, actions: 0, active: 0, autoDestroyDisabled: 5, focusTrapEnabled: 5, collapseDirection: 1, collapsed: 5, content: 1, defaultPopupTemplateEnabled: 5, effectiveHeading: 32, featureCount: 9, featureMenuOpen: 5, featureMenuTitle: 1, featureNavigationTop: 5, features: 0, featuresPerPage: 9, featureItemAbilities: 0, goToOverride: 0, headerActions: 0, heading: 1, headingLevel: 9, hideActionBar: 5, hideCloseButton: 5, hideFeatureMenuHeading: 5, hideFeatureNavigation: 5, hideFeatureListLayerTitle: 5, hideHeading: 5, hideSelectFeature: 5, hideSpinner: 5, hideContent: 5, chartAnimationDisabled: 5, hideAttachmentsContent: 5, hideCustomContent: 5, hideExpressionContent: 5, hideFieldsContent: 5, hideMediaContent: 5, hideRelationshipContent: 5, hideTextContent: 5, hideUtilityNetworkContent: 5, hideLastEditedInfo: 5, highlightDisabled: 5, icon: 1, includeDefaultActionsDisabled: 5, initialDisplayMode: 1, label: 1, location: 0, map: 0, messageOverrides: 0, open: 5, referenceElement: 1, promises: 0, responsiveActionsEnabled: 5, selectedDrillInFeature: 32, selectedFeature: 0, selectedFeatureComponent: 32, selectedFeatureIndex: 9, showCollapseButton: 5, spatialReference: 0, state: 32, timeZone: 1, updateLocationEnabled: 5, view: 0 };
}
static {
this.styles = K;
}
get _hideActionText() {
if (!this.responsiveActionsEnabled)
return !1;
const e = this.viewModel.view?.widthBreakpoint;
return e === "xsmall" || e === "small" || e === "medium";
}
get _featureNavigationVisible() {
return this.viewModel.active && this.viewModel.featureCount > 1 && !!this.viewModel.selectedFeature && !this.hideFeatureNavigation;
}
get _isCollapsed() {
return this._collapseEnabled && this.collapsed;
}
get _collapseEnabled() {
return this.showCollapseButton && (this.initialDisplayMode === "list" || !!(this.heading || this.viewModel.selectedFeatureItem?.heading) && !!(this.content || this.viewModel.selectedFeatureItem?.content));
}
get _featureFlowItemSelected() {
return this.initialDisplayMode === "list" ? !!this.selectedFeature : !this.featureMenuOpen;
}
clear() {
this.viewModel.clear();
}
close() {
this.open = !1;
}
async destroy() {
await this.manager.destroy(), this._removeSpinner(this.referenceElement), this._cancelOpenRelatedFeature(), this._cancelToggleFocusTrapAnimationFrame(), this._removeFlowItems(), this._unobserveFeatureMenuObserver(), this._cancelFetchingFeatures(), this._featureMenuIntersectionObserver?.disconnect();
}
async fetchFeatures(e, t) {
this._cancelFetchingFeatures();
const { signal: a } = t ?? {}, i = new AbortController(), { signal: s } = i, n = a ? AbortSignal.any([s, a]) : s;
if (this._fetchFeaturesController = i, !e && this.view && this.location && (await V(this.location.spatialReference, this.view.spatialReference, null, {
signal: n
}), e = this.view.toScreen(this.location) ?? void 0), !e)
return;
const r = await this.viewModel.fetchFeatures(e, {
...t,
signal: n
});
this.location = r.location, this.promises = r.pendingFeatures;
}
next() {
this.viewModel.next();
}
previous() {
this.viewModel.previous();
}
async setFocus() {
await this._focusTrapNode.value?.setFocus();
}
connectedCallback() {
super.connectedCallback(), this._createSpinner();
}
disconnectedCallback() {
super.disconnectedCallback(), this._cancelToggleFocusTrapAnimationFrame(), this._removeSpinner(this.referenceElement);
}
loaded() {
this.manager.onLifecycle(() => [
c(() => this.viewModel?.active, () => this._toggleFocusTrap()),
c(() => this.viewModel?.selectedFeatureIndex, (e, t) => this._selectedFeatureIndexUpdated(e, t)),
c(() => this.viewModel?.view?.scale, () => this._viewScaleChange()),
c(() => this.viewModel?.view, (e, t) => t && this._viewChange()),
c(() => this._spinnerEl?.screenLocation, () => this._closeOpenActionMenu()),
c(() => this.selectedFeatureComponent?.viewModel, () => this._removeFlowItems()),
c(() => this.viewModel?.featureItems, () => this._featureMenuViewportScrollTop()),
c(() => this.flowItems.length, () => this._syncSelectedDrillInFeature()),
c(() => [this.flowItems?.length, this.featureMenuOpen], () => {
this.setFocus();
}),
c(() => this.viewModel.aggregatedFeaturesEnabled, (e) => {
e || (this._aggregatedFeatureCount = 0, this._selectedAggregatedFeatureIndex = -1, this._aggregatedFeaturesLoading = !1, this._removeFlowItems());
}),
c(() => this.referenceElement, (e, t) => {
this._removeSpinner(t), this._createSpinner();
}, { initial: !0 }),
c(() => [
this.hideSpinner,
this.viewModel?.view,
this.viewModel?.location,
this.viewModel?.waitingForResult,
this.viewModel?.open
], () => this._createSpinner(), { initial: !0 })
]);
}
updated() {
const e = this._selectedFeatureComponent.value ?? void 0;
this.selectedFeatureComponent !== e && k(() => this.selectedFeatureComponent = e);
}
_toggleFocusTrap() {
this._cancelToggleFocusTrapAnimationFrame(), this._focusTrapAnimationFrameId = requestAnimationFrame(() => {
this._focusTrapAnimationFrameId = null, this.viewModel.active ? this._focusTrapNode.value?.activate() : this._focusTrapNode.value?.deactivate();
});
}
_cancelToggleFocusTrapAnimationFrame() {
this._focusTrapAnimationFrameId != null && (cancelAnimationFrame(this._focusTrapAnimationFrameId), this._focusTrapAnimationFrameId = null);
}
_cancelFetchingFeatures() {
this._fetchFeaturesController = N(this._fetchFeaturesController);
}
_handleClose() {
this.close(), this.arcgisClose.emit();
}
_groupResultsByLayer() {
const { featureItems: e } = this.viewModel, t = /* @__PURE__ */ new Map();
return e.forEach((a) => {
const i = a?.graphic;
if (!i)
return;
const s = S(i), n = W(s) ? s : null;
let r = t.get(n);
r || (r = [], t.set(n, r)), r.push(a);
}), t;
}
_handleCollapseToggle() {
this.collapsed = !this.collapsed;
}
async _openRelatedFeature(e) {
this._cancelOpenRelatedFeature();
const t = new AbortController();
if (this._openRelatedFeatureAbortController = t, await e.updateGeometry(), t.signal.aborted)
return;
const a = e.graphic, i = a?.geometry;
if (i == null || a == null) {
this._openRelatedFeatureAbortController = null;
return;
}
if (this._removeFlowItems(), await this.viewModel.zoomTo({ target: i }), t.signal.aborted)
return;
const s = await import("@arcgis/core/geometry/operators/labelPointOperator.js");
if (t.signal.aborted)
return;
const n = s.execute(i);
n != null && (this.location = n), this.features = [a], this.open = !0, await this.setFocus(), this._openRelatedFeatureAbortController = null;
}
_handlePaginationMenuButton() {
this._updateFeatureMenu();
}
_openFeatureMenu() {
this._updateFeatureMenu(!0);
}
_closeFeatureMenu() {
this._updateFeatureMenu(!1);
}
_updateFeatureMenu(e = !this.featureMenuOpen) {
this.featureMenuOpen = e;
}
_previousFeature() {
this.viewModel.previous();
}
_nextFeature() {
this.viewModel.next();
}
_handleFeatureBack() {
this.initialDisplayMode === "list" ? (this.selectedFeatureIndex = -1, this.setFocus()) : this._openFeatureMenu();
}
_handleFeatureMenuBack() {
this.initialDisplayMode === "list" ? (this.selectedFeatureIndex = -1, this.setFocus()) : this.featureMenuOpen && this._closeFeatureMenu();
}
_setActiveFeature(e) {
const { viewModel: t } = this;
t.activeFeature = t.features?.[e] || null;
}
_removeActiveFeature() {
this.viewModel.activeFeature = null;
}
_selectFeature(e) {
this.viewModel.selectedFeatureIndex = e, this.initialDisplayMode === "feature" ? this._handleFeatureMenuBack() : this.setFocus();
}
_unobserveFeatureMenuObserver() {
this._featureMenuIntersectionObserverNode && this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode);
}
_featureMenuIntersectionObserverCreated(e) {
this._unobserveFeatureMenuObserver(), e && this._featureMenuIntersectionObserver.observe(e), this._featureMenuIntersectionObserverNode = e;
}
_getActionTitle(e) {
const { messages: t, selectedFeature: a } = this, { id: i } = e, s = a?.attributes, n = e.title ?? "", r = i === "zoom-to-feature" ? g(n, { messages: t }) : i === "remove-selected-feature" ? g(n, { messages: t }) : i === "zoom-to-clustered-features" ? g(n, { messages: t }) : i === "browse-aggregated-features" ? g(n, { messages: t }) : e.title;
return r && s ? g(r, s) : r ?? "";
}
_onMainKeydown(e) {
const { key: t } = e;
t === "ArrowLeft" && (e.stopPropagation(), this._handleFeatureMenuBack(), this.previous(), this.setFocus()), t === "ArrowRight" && (e.stopPropagation(), this._handleFeatureMenuBack(), this.next(), this.setFocus());
}
_featureMenuViewportScrollTop() {
this._featureMenuViewportNode.value?.scrollContentTo({ top: 0 });
}
_selectedFeatureIndexUpdated(e, t) {
const { featureCount: a, waitingForResult: i } = this.viewModel;
i || !a || e === t || e === -1 || (this._aggregatedFeatureCount = 0, this._selectedAggregatedFeatureIndex = -1, this._removeFlowItems(), this._rootFlowItemNode.value?.scrollContentTo({ top: 0 }));
}
_triggerAction(e) {
e.disabled || (e?.type === "toggle" && (e.value = !e.value), U(e, this.viewModel), this.arcgisTriggerAction.emit({ action: e }));
}
_viewScaleChange() {
const { selectedFeature: e } = this;
!e?.isAggregate || X(S(e)) !== "cluster" || (this.viewModel.aggregatedFeaturesEnabled = !1, this.open = !1, this.clear());
}
_viewChange() {
this.viewModel.clear(), this.open = !1, this._aggregatedFeatureCount = 0, this._removeFlowItems();
}
_handleAggregatedFeaturesPropertyChange({ detail: e, target: t }) {
e.name === "aggregatedFeatureCount" && (this._aggregatedFeatureCount = t.aggregatedFeatureCount), e.name === "selectedAggregatedFeatureIndex" && (this._selectedAggregatedFeatureIndex = t.selectedAggregatedFeatureIndex, this._syncSelectedDrillInFeature()), e.name === "loading" && (this._aggregatedFeaturesLoading = t.loading);
}
_closeOpenActionMenu() {
const { _actionBarMenuNode: e } = this;
e.value && (e.value.menuOpen = !1);
}
_syncSelectedDrillInFeature() {
const e = this.flowItems.getItemAt(this.flowItems.length - 1);
k(() => this.selectedDrillInFeature = e?.graphic ?? void 0);
}
_removeFlowItems() {
this.viewModel.aggregatedFeaturesEnabled = !1, this.flowItems?.destroyAll();
}
_getDrillInFlowItemDescription(e) {
switch (e.flowType) {
case "feature":
case "feature-association":
case "feature-utility-network-associations":
case "feature-utility-network-association-type":
return e.description;
case "feature-relationship":
return e.allItemsDescription;
}
}
_handleDrillInBackClick() {
this.flowItems?.pop()?.destroy();
}
_getHeading() {
const { effectiveHeading: e } = this.viewModel;
return !this.hideHeading && e ? e : "";
}
_handleActionsStartSlotChange(e) {
this._hasActionsStartSlotContent = D(e);
}
_handleActionsEndSlotChange(e) {
this._hasActionsEndSlotContent = D(e);
}
_removeSpinner(e) {
e?.manager?.component?.extraContent?.remove(this._spinnerEl), this._spinnerEl = void 0;
}
_createSpinner() {
const e = this.referenceElement;
e && (this._removeSpinner(e), this._spinnerEl = z(o`<arcgis-spinner .label=${this.messages.loading ?? ""} .trackLocation=${!this.hideSpinner && this.viewModel.open && this.viewModel?.waitingForResult} .location=${this.viewModel?.location ?? void 0} .view=${this.viewModel?.view ?? void 0}></arcgis-spinner>`), e.manager?.component?.extraContent?.add(this._spinnerEl));
}
render() {
return o`<div class="root" =${this._onMainKeydown}><calcite-focus-trap .focusTrapDisabled=${!this.focusTrapEnabled} ${f(this._focusTrapNode)}>${this._renderHeader()}${this._renderContentContainer()}</calcite-focus-trap></div>`;
}
_renderFeatureNavigation() {
return [
this._renderPagination(() => this._previousFeature(), () => this._nextFeature()),
this.initialDisplayMode === "list" ? this._renderFeaturePaginationText(this.viewModel.featureCount, this.viewModel.selectedFeatureIndex) : this._renderFeatureMenuButton()
];
}
_renderHeader() {
return this.featureNavigationTop && this._featureNavigationVisible ? o`<div class="header">${this._renderFeatureNavigation()}</div>` : null;
}
_renderFooter() {
return !this.featureNavigationTop && this._featureNavigationVisible ? o`<div class="footer" slot=footer>${this._renderFeatureNavigation()}</div>` : null;
}
_renderFeaturePaginationText(e, t) {
const { messages: a } = this;
return o`<div class="pagination-text">${g(a.pageText ?? "", {
index: C(t + 1),
total: C(e)
})}</div>`;
}
_renderFeatureMenuButton() {
const { messages: e, viewModel: t } = this, { featureCount: a, selectedFeatureIndex: i, pendingPromisesCount: s } = t;
return o`<calcite-action class="pagination-menu-button" icon=list .label=${e.selectFeature} .loading=${s > 0} =${this._handlePaginationMenuButton} .text=${g(e.pageText ?? "", {
index: C(i + 1),
total: C(a)
})} text-enabled title=${e.selectFeature ?? p}></calcite-action>`;
}
_renderPagination(e, t) {
const { previous: a, next: i } = this.messages;
return o`<calcite-action-bar class="pagination-action-bar" expand-disabled layout=horizontal overflow-actions-disabled scale=s><calcite-action-group scale=s><calcite-action class="pagination-previous" icon=chevron-left icon-flip-rtl .label=${a ?? ""} =${e} .text=${a ?? ""} title=${a ?? "" ?? p}></calcite-action><calcite-action icon=chevron-right icon-flip-rtl .label=${i ?? ""} =${t} .text=${i ?? ""} title=${i ?? "" ?? p}></calcite-action></calcite-action-group></calcite-action-bar>`;
}
_renderFeatureMenuItem(e, t) {
const { initialDisplayMode: a } = this, { selectedFeatureItem: i } = this.viewModel, s = e === i;
return o`<calcite-list-item =${this._removeActiveFeature} =${() => this._setActiveFeature(t)} =${this._removeActiveFeature} =${() => this._setActiveFeature(t)} .selected=${s} =${() => this._selectFeature(t)}><span .innerHTML=${(b.sanitize(e.heading) || this.messages.untitled) ?? ""} slot=content></span>${a === "list" ? o`<calcite-icon flip-rtl icon=chevron-right scale=s slot=content-end></calcite-icon>` : null}</calcite-list-item>`;
}
_renderFeatureMenu() {
const { messages: e, viewModel: t } = this, a = this._groupResultsByLayer(), i = /* @__PURE__ */ new Map();
t.featureItems.forEach((n, r) => i.set(n, r));
const s = this.initialDisplayMode === "list" ? "none" : "single";
return t.featureItems.length ? o`<calcite-list display-mode=flat .label=${e?.featuresList ?? ""} selection-appearance=icon .selectionMode=${s}>${Array.from(a.keys(), (n) => {
const r = a.get(n)?.map((l) => {
const h = i.get(l);
return h == null ? null : this._renderFeatureMenuItem(l, h);
}), d = n ? n.title ?? this.messages.untitled : null;
return !this.hideFeatureListLayerTitle && d !== null ? y(n ?? "map-graphics", o`<calcite-list-item-group .heading=${d}>${r}</calcite-list-item-group>`) : r;
})}</calcite-list>` : null;
}
_renderHeaderAction(e) {
const t = e.title || "";
return e.visible ? o`<calcite-action .active=${e.type === "toggle" ? e.value : !1} .disabled=${e.disabled} .icon=${e.icon ?? void 0} .indicator=${e.active} .loading=${e.active} =${() => this._triggerAction(e)} slot=header-actions-end .text=${t} title=${t ?? p}></calcite-action>` : null;
}
_renderHeaderActions() {
return this.headerActions.map((e) => this._renderHeaderAction(e)).toArray();
}
_renderContentFeature(e) {
const { headingLevel: t, hideCloseButton: a, _isCollapsed: i, _collapseEnabled: s, featureNavigationTop: n, initialDisplayMode: r, selectedFeature: d, hideHeading: l } = this, { active: h, selectedFeatureItem: v, content: _ } = this.viewModel, u = this._getHeading();
if (r === "list" && !d)
return null;
const w = v ? !v.content : !_;
return o`<calcite-flow-item class=${I(x({
"content-feature": !0,
"flow-item-collapsed": i
}))} .closable=${!a} .closed=${!h} .collapsed=${i} .collapseDirection=${this.collapseDirection ?? (n ? "down" : "up")} .collapsible=${s} .headingLevel=${t} .selected=${e} .messageOverrides=${{ collapse: this.messages.collapse, expand: this.messages.expand }} =${this._handleFeatureBack} .loading=${!!this._openRelatedFeatureAbortController} =${this._handleClose} =${this._handleCollapseToggle} .heading=${!l && u ? T(u) : void 0} ${f(this._rootFlowItemNode)}>${!l && u ? o`<div slot=heading><div .innerHTML=${b.sanitize(u ?? "") ?? ""}></div></div>` : null}${this._renderHeaderActions()}${this._renderActionBar()}<div class=${I(x("container", "content-container", {
"content-hidden": w
}))}>${this._renderContent()}</div>${this._renderFooter()}</calcite-flow-item>`;
}
_renderFeatureMenuContainer() {
const { viewModel: e, hideCloseButton: t, featureMenuTitle: a, messages: i, initialDisplayMode: s, featureMenuOpen: n, _featureFlowItemSelected: r, _collapseEnabled: d, _isCollapsed: l, featureNavigationTop: h, headingLevel: v } = this, { active: _, featureItems: u, pendingPromisesCount: w } = e, $ = a ?? i.selectFeature;
if (s === "feature" && !n)
return null;
const M = !r;
return o`<calcite-flow-item class=${I(x({
"flow-item-collapsed": l
}))} .closable=${s === "list" && !t} .closed=${!_} .collapsed=${s === "list" && l} .collapseDirection=${this.collapseDirection ?? (h ? "down" : "up")} .collapsible=${s === "list" && d} .messageOverrides=${{ collapse: this.messages.collapse, expand: this.messages.expand }} .description=${this.hideFeatureMenuHeading ? void 0 : g(i.total ?? "", {
total: u.length
})} .heading=${this.hideFeatureMenuHeading ? void 0 : $} .headingLevel=${v} .loading=${e.waitingForContents} .selected=${M} =${(L) => {
L.preventDefault(), this._handleFeatureMenuBack();
}} =${this._handleClose} =${this._handleCollapseToggle} ${f(this._featureMenuViewportNode)}>${s === "list" ? this._renderHeaderActions() : null}${w > 0 ? o`<calcite-loader class="loader" inline .label=${i.loading ?? ""} slot=header-actions-end></calcite-loader>` : null}<div class="container">${M ? this._renderFeatureMenu() : null}</div><div class="feature-menu-observer" ${f(this._featureMenuIntersectionObserverCreated)}></div>${s === "feature" ? o`<calcite-button scale=s appearance=transparent =${this._handleFeatureMenuBack} slot=footer-start width=full>${i.back}</calcite-button>` : null}</calcite-flow-item>`;
}
_renderFlowItem(e, t) {
const { messages: a, hideCloseButton: i, hideSelectFeature: s, active: n, hideHeading: r } = this, d = "graphic" in e && "isFeatureFromTable" in e && !e.isFeatureFromTable, l = d && !s, h = e.flowType === "feature-association", v = a.returnToInitialFeature ?? "", _ = a?.selectFeature, u = this._getActionTitle(this._zoomToFeature), w = !this.hideActionBar && h && d, $ = e.flowType === "feature" && this.viewModel.aggregatedFeaturesEnabled ? o`<div class="footer" slot=footer>${this._renderPagination(() => {
this._aggregatedFeaturesComponent.value?.previous();
}, () => {
this._aggregatedFeaturesComponent.value?.next();
})}${this._renderFeaturePaginationText(this._aggregatedFeatureCount, this._selectedAggregatedFeatureIndex)}</div>` : null;
return o`<calcite-flow-item .closable=${!i} .closed=${!n} class="flow-item-drill-in" .description=${T(this._getDrillInFlowItemDescription(e) ?? "")} .heading=${r ? void 0 : T(e.heading ?? "")} .selected=${t} =${(M) => {
M.preventDefault(), this._handleDrillInBackClick();
}} .loading=${!!this._openRelatedFeatureAbortController} =${this._handleClose}>${r ? null : o`<div slot=heading><div .innerHTML=${b.sanitize(e.heading ?? "") ?? ""}></div></div>`}<div slot=description><div .innerHTML=${b.sanitize(this._getDrillInFlowItemDescription(e) ?? "") ?? ""}></div></div><calcite-action class="action-exit" icon=move-up =${this._removeFlowItems} slot=header-actions-start .text=${v ?? ""} title=${v ?? "" ?? p}></calcite-action>${l ? o`<calcite-action icon=zoom-to-object =${() => this._openRelatedFeature(e)} slot=header-actions-end .text=${_ ?? ""} title=${_ ?? p}></calcite-action>` : null}${w ? o`<calcite-action-bar expand-disabled expanded scale=s slot=action-bar><calcite-action-group overlay-positioning=fixed scale=s><calcite-action .disabled=${this._zoomToFeature.disabled} .icon=${this._zoomToFeature.icon ?? void 0} .loading=${this._zoomToFeature.active} scale=s text-enabled .text=${u} title=${u ?? p} =${() => j(this.viewModel, this._zoomToFeature, e)}></calcite-action></calcite-action-group></calcite-action-bar>` : null}<div class="container">${e}</div>${$}</calcite-flow-item>`;
}
_renderContentContainer() {
const e = this.flowItems?.toArray(), t = e.length > 0, a = this.viewModel.aggregatedFeaturesEnabled && this.viewModel.selectedFeature?.isAggregate && !t, i = a && e.length === 0, s = e.length === 0 && this._featureFlowItemSelected && !a, n = e?.map((l, h) => this._renderFlowItem(l, this._featureFlowItemSelected && h === e.length - 1)), r = this._renderBrowseAggregateContainer(!!i), d = this.initialDisplayMode === "list" ? [this._renderFeatureMenuContainer(), this._renderContentFeature(s)] : [this._renderContentFeature(s), this._renderFeatureMenuContainer()];
return o`<calcite-flow ${f(this._flowContainerNode)}>${d}${r}${n}</calcite-flow>`;
}
_renderBrowseAggregateContainer(e) {
const { hideCloseButton: t, active: a, messages: i } = this, { selectedFeature: s } = this.viewModel;
return this.viewModel.aggregatedFeaturesEnabled && s?.isAggregate ? o`<calcite-flow-item .selected=${e} .closable=${!t} .closed=${!a} .description=${this._aggregatedFeatureCount ? g(i.total ?? "", {
total: this._aggregatedFeatureCount
}) : ""} .heading=${i.aggregatedFeatures} =${(r) => {
r.preventDefault(), this.viewModel.aggregatedFeaturesEnabled = !1;
}} .loading=${this._aggregatedFeaturesLoading} =${this._handleClose}><arcgis-aggregated-features .autoDestroyDisabled=${this.autoDestroyDisabled} .feature=${s ?? void 0} .flowItems=${this.flowItems} .map=${this.map ?? void 0} .messages=${i} =${this._handleAggregatedFeaturesPropertyChange} .spatialReference=${this.spatialReference ?? void 0} .timeZone=${this.timeZone ?? void 0} .view=${this.view ?? void 0} ${f(this._aggregatedFeaturesComponent)}></arcgis-aggregated-features><calcite-button appearance=transparent =${() => this.viewModel.aggregatedFeaturesEnabled = !1} slot=footer-start scale=s width=full>${i.back}</calcite-button></calcite-flow-item>` : null;
}
_renderActionBar() {
const e = this.viewModel.selectedFeatureItem?.isFeatureFromTable, t = this.viewModel.allActions.toArray(), a = e && !this.location ? t.filter((s) => s.id !== this._zoomToFeature.id) : t, i = !!a.length || this._hasActionsStartSlotContent || this._hasActionsEndSlotContent;
return !this._isCollapsed && !this.hideActionBar && i ? o`<calcite-action-bar expand-disabled .expanded=${!this._hideActionText} scale=s slot=action-bar><slot name=actions-start =${this._handleActionsStartSlotChange}></slot><calcite-action-group overlay-positioning=fixed scale=s ${f(this._actionBarMenuNode)}>${this._renderActions(a)}</calcite-action-group><slot name=actions-end =${this._handleActionsEndSlotChange}></slot></calcite-action-bar>` : null;
}
_renderActions(e) {
return e.map((t) => {
const a = this._getActionTitle(t);
return o`<calcite-action .active=${t.type === "toggle" ? t.value : !1} .disabled=${t.disabled} .icon=${t.icon ?? void 0} .loading=${t.active} scale=s .textEnabled=${!this._hideActionText} .text=${a ?? ""} title=${a ?? p} .hidden=${!t.visible} =${() => this._triggerAction(t)}></calcite-action>`;
});
}
_renderContent() {
const { content: e, selectedFeatureItem: t } = this.viewModel;
return t ? o`<arcgis-feature-next .autoDestroyDisabled=${this.autoDestroyDisabled} .chartAnimationDisabled=${this.chartAnimationDisabled} .defaultPopupTemplateEnabled=${this.defaultPopupTemplateEnabled} .flowItems=${this.flowItems} .graphic=${t.graphic} .headingLevel=${this.headingLevel + 1} .hideAttachmentsContent=${this.hideAttachmentsContent} .hideContent=${this.hideContent} .hideCustomContent=${this.hideCustomContent} .hideExpressionContent=${this.hideExpressionContent} .hideFieldsContent=${this.hideFieldsContent} hide-heading .hideLastEditedInfo=${this.hideLastEditedInfo} .hideMediaContent=${this.hideMediaContent} .hideTextContent=${this.hideTextContent} .location=${this.location} .map=${this.map} .referenceElement=${this.referenceElement} .showRelationshipContent=${!this.hideRelationshipContent} .showUtilityNetworkContent=${!this.hideUtilityNetworkContent} .spatialReference=${this.spatialReference} .timeZone=${this.timeZone} ${f(this._selectedFeatureComponent)}></arcgis-feature-next>` : typeof e == "string" ? y(e, o`<div .innerHTML=${b.sanitize(e) ?? ""}></div>`) : e ?? null;
}
}
B("arcgis-features-next", Q);
export {
Q as ArcgisFeaturesNext
};