@arcgis/map-components
Version:
ArcGIS Map Components
57 lines (56 loc) • 2.41 kB
JavaScript
import { c as t } from "../../chunks/runtime.js";
import { r as i, d as s, a as l } from "../../chunks/component-utils.js";
import { LitElement as r, createEvent as o, noShadowRoot as n } from "@arcgis/lumina";
import { css as c } from "@lit/reactive-element/css-tag.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
v4.32.13 */
const h = c` {arcgis-placement{display:flex;pointer-events:auto;box-shadow:none}.arcgis-placement__container{display:block}}`;
class a extends r {
//#endregion
//#region Lifecycle
constructor() {
super(), this._observer = void 0, this._moveChildren = () => {
if (this.el.childElem.parentElement !== this.el)
for (let e = this.el.firstElementChild; e !== null; e = this.el.firstElementChild)
this.el.childElem.append(e);
}, this.position = "bottom-left", this.arcgisReady = o(), this.el.childElem = document.createElement("div"), this.el.childElem.classList.add("arcgis-placement__container"), this.listen("arcgisReady", this._startObserving, { once: !0 });
}
static {
this.properties = { position: 1, referenceElement: 1 };
}
static {
this.shadowRootOptions = n;
}
static {
this.styles = h;
}
connectedCallback() {
super.connectedCallback(), this.el.view && this._startObserving();
}
willUpdate(e) {
e.has("referenceElement") && i(this, this.referenceElement), e.has("position") && this.el.childElem && this.position !== void 0 && this.el.view?.ui?.move(this.el.childElem, this.position);
}
loaded() {
s(this), l(this);
}
disconnectedCallback() {
super.disconnectedCallback(), this.el.childElem && this.el.view?.ui?.remove(this.el.childElem), this._observer?.disconnect();
}
//#endregion
//#region Private Methods
/**
* We only call this method once the view property is set. Because when that
* happens, the childElem contains is already attached to it's final
* destination. This is important as we don't want to call _moveChildren()
* prematurely (triggering needless disconnect & connect for them, and maybe
* even destroy()).
*/
_startObserving() {
this._moveChildren(), this._observer = new MutationObserver(this._moveChildren), this._observer.observe(this.el, { childList: !0 });
}
}
t("arcgis-placement", a);
export {
a as ArcgisPlacement
};