UNPKG

@arcgis/map-components

Version:
107 lines (106 loc) 2.8 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { watch as u } from "@arcgis/core/core/reactiveUtils.js"; import { resolveReferenceElement as g } from "@arcgis/toolkit/dom"; function N(t) { t.el.childElem && (t.el.childElem.ownedBy = t.el); const e = h(t); if (!e) { const i = g(t); if (!i) { o(t); return; } return l(i, t, !0), i; } return E(e, t.el.parent) || (t.el.parent = e, e.localName === "arcgis-expand" ? y(e, t) : l(e, t, !1)), e; } function h({ el: t }) { for (let e = t.parentElement; e; e = e?.parentElement ?? null) { if (a.has(e.localName)) return e; if ("ownedBy" in e && e.ownedBy instanceof HTMLElement && a.has(e.ownedBy.localName)) return e.ownedBy; } } const a = /* @__PURE__ */ new Set(["arcgis-map", "arcgis-scene", "arcgis-link-chart", "arcgis-expand"]); function E(t, e) { return t !== e ? !1 : t.localName === "arcgis-expand"; } function s(t, e, i = "arcgisReady") { const r = t; if (r.view) e(r.view); else { let n = function(d) { d.target === t && (s(t, e, i), t.removeEventListener(i, n)); }; t.addEventListener(i, n); } } const y = (t, e) => s(t, (i) => { const r = c(e); if (e.el.shadowRoot ? t.content = e.el : e.el.childElem && t.content != null && r.append(e.el.childElem), e.el.view = i, t.referenceElement) { e.referenceElement = t.referenceElement; return; } u( () => t.referenceElement, (n) => { e.referenceElement = n; }, { once: !0 } ); }), l = (t, e, i) => s( t, (r) => { i && o(e), e.el.view = r, e.referenceElement = t; }, "arcgisViewReadyChange" ); function T(t) { return t == null || t === ""; } function B(t, e) { return t?.position === e?.position && t?.heading === e.heading && t?.tilt === e.tilt && t?.fov === e.fov; } function F(t, e) { return e === void 0 || t?.targetGeometry !== e?.targetGeometry || t?.rotation !== e?.rotation || t?.scale !== e?.scale; } function L(t, e) { return f(e?.center, t); } function f(t, e) { if (typeof e == "string") return f(t, e.split(",").map(Number)); if (!t) return e; if (Array.isArray(e)) { const i = e[0], r = e[1], n = e.length > 2 ? e[2] : void 0; if (i !== t.longitude || r !== t.latitude || n !== t.z) return e; } else if (e && !t?.equals(e)) return e; } function o(t) { t.el.childElem && c(t).append(t.el.childElem); } function c(t) { return t.el.shadowRoot ?? t.el; } const P = (t) => t.el.childElem; async function b(t) { const e = typeof t == "function" ? t() : t; e && ("setFocus" in e && typeof e.setFocus == "function" ? await e.setFocus() : e instanceof HTMLElement && e.focus()); } export { N as a, B as b, f as c, T as d, P as g, F as i, L as p, b as s };