UNPKG

@arcgis/map-components

Version:
107 lines (106 loc) 5.17 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { c as r } from "../../chunks/runtime.js"; import { html as o } from "lit"; import { keyed as c } from "lit/directives/keyed.js"; import { createReactiveMap as u } from "@arcgis/core/applications/Components/featureUtils.js"; import { watch as l } from "@arcgis/core/core/reactiveUtils.js"; import { substitute as d } from "@arcgis/core/intl.js"; import { LitElement as h, safeClassMap as g } from "@arcgis/lumina"; import { createRef as v, ref as m } from "lit/directives/ref.js"; class F extends h { constructor() { super(...arguments), this._associationFeaturesIntersectionObserver = new IntersectionObserver(([t]) => { t?.isIntersecting && this._increaseFeaturePage(); }, { root: window.document }), this._associationFeaturesIntersectionObserverNode = v(), this._currentFeaturePage = 1, this._increaseFeaturePage = () => { const { state: t, showAllEnabled: e, associatedFeatureCount: i, featuresPerPage: s, currentFeaturePage: n } = this; t === "ready" && e && i >= s * n && this.currentFeaturePage++; }, this._isFeatureCountNoticeOpen = !0, this.associationViewModels = /* @__PURE__ */ new Map(), this.featuresPerPage = 50, this.maxFeatureCount = 1e3, this.showAllEnabled = !1, this.state = "ready", this.tooltipReferenceMap = u(); } static { this.properties = { associatedFeatureCount: 32, associationViewModels: 0, currentFeaturePage: 9, featuresPerPage: 9, maxFeatureCount: 9, messages: 0, parentFeatureViewModel: 0, selectedLayer: 0, showAllEnabled: 5, state: 1, tooltipReferenceMap: 0 }; } get associatedFeatureCount() { const t = this.associationViewModels, e = this.selectedLayer ? t.get(this.selectedLayer) : null; return e ? e.length : 0; } get currentFeaturePage() { return this._currentFeaturePage; } set currentFeaturePage(t) { const { featuresPerPage: e, associatedFeatureCount: i } = this, s = Math.ceil(i / e) || 1, n = Math.max(Math.min(t, s), 1); this._currentFeaturePage = n; } loaded() { this.manager.onLifecycle(() => [ l(() => [this.state, this.showAllEnabled, this._associationFeaturesIntersectionObserverNode], () => { this._handleAssociationFeaturesObserverChange(); }, { initial: !0 }) ]); } getConnectivityTooltip(t) { const { messages: e } = this; if (!e) return ""; switch (t) { case "connectivity": case "junction-junction-connectivity": return e.associationsJunctionJunction; case "junction-edge-from-connectivity": return e.associationsJunctionEdgeFrom; case "junction-edge-midspan-connectivity": return e.associationsJunctionEdgeMidspan; case "junction-edge-to-connectivity": return e.associationsJunctionEdgeTo; default: return ""; } } _handleAssociationFeaturesObserverChange() { this._unobserveAssociationFeaturesObserver(); const { state: t, showAllEnabled: e } = this; this._associationFeaturesIntersectionObserverNode.value && t === "ready" && e && this._associationFeaturesIntersectionObserver.observe(this._associationFeaturesIntersectionObserverNode.value); } _unobserveAssociationFeaturesObserver() { this._associationFeaturesIntersectionObserverNode.value && this._associationFeaturesIntersectionObserver.unobserve(this._associationFeaturesIntersectionObserverNode.value); } _renderConnectivityIcon(t, e) { const { tooltipReferenceMap: i } = this; let s; switch (t) { case "junction-edge-from-connectivity": s = "connection-end-left"; break; case "junction-edge-to-connectivity": s = "connection-end-right"; break; case "junction-edge-midspan-connectivity": s = "connection-middle"; break; default: s = "connection-to-connection"; } return o`<calcite-icon .icon=${s} @pointerover=${(n) => { i.set(e, n.currentTarget); }} scale=s slot=content-start></calcite-icon>`; } _renderFeatureCountWarning() { const { associatedFeatureCount: t, maxFeatureCount: e, messages: i } = this, s = d(i?.associationsLimitNoticeMessage ?? "", { number: e }), n = t > e, a = i?.associationsLimitNoticeTitle ?? ""; return n ? o`<calcite-notice class=${g(this._isFeatureCountNoticeOpen ? "notice-container" : "")} closable icon=information kind=info open scale=s width=full @calciteNoticeBeforeOpen=${() => this._isFeatureCountNoticeOpen = !0} @calciteNoticeClose=${() => this._isFeatureCountNoticeOpen = !1}><div slot=title>${a}</div><div slot=message>${s}</div></calcite-notice>` : null; } _renderFeatureObserver() { return o`<div class="feature-observer" ${m(this._associationFeaturesIntersectionObserverNode)}></div>`; } _renderLoading() { return c("loading-container", o`<div class="loading-container">${this._renderLoadingIcon()}</div>`); } _renderLoadingIcon() { const t = this.messages?.loading ?? ""; return o`<calcite-loader inline .label=${t}></calcite-loader>`; } } r("arcgis-utility-network-association-list", F); export { F as ArcgisUtilityNetworkAssociationList };