UNPKG

@arcgis/map-components

Version:
5 lines (4 loc) 3.37 kB
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. v4.33.13 */ function b(n){n.el.childElem&&(n.el.childElem.ownedBy=n.el);let e=w(n);if(!e){let t=m(n);if(!t){p(n);return}return u(t,n,!0),t}return v(e,n.el.parent)||(n.el.parent=e,e.localName==="arcgis-expand"?y(e,n):e.localName==="arcgis-placement"?h(e,n):u(e,n,!1)),e}function w({el:n}){for(let e=n.parentElement;e;e=e?.parentElement??null){if(d.has(e.localName))return e;if("ownedBy"in e&&e.ownedBy instanceof HTMLElement&&d.has(e.ownedBy.localName))return e.ownedBy}}var d=new Set(["arcgis-map","arcgis-scene","arcgis-link-chart","arcgis-expand","arcgis-placement"]);function v(n,e){if(n!==e)return!1;let t=n.localName;return t==="arcgis-expand"||t==="arcgis-placement"}function r(n,e,t="arcgisReady"){let o=n;if(o.view)e(o.view);else{let i=function(c){c.target===n&&(r(n,e,t),n.removeEventListener(t,i))};n.addEventListener(t,i)}}var y=(n,e)=>r(n,t=>{e.el.childElem&&n.content!=null&&n.content.append(e.el.childElem),n.expandIcon=e.icon||e.widget?.icon||n.expandIcon,e.position=n.position,e.el.view=t}),h=(n,e)=>r(n,t=>{e.el.childElem&&e.el.append(e.el.childElem),e.position=n.position,e.el.view=t}),u=(n,e,t)=>r(n,o=>{t?p(e):e.el.childElem&&E(n,e),e.el.view=o},"arcgisViewReadyChange");function E(n,e){let t=e.el.childElem??e.el,o=n?.childElem,i=[...n.children],c={};for(let l of i){if(l===o)continue;let a=l.position??"manual";c[a]??=[],c[a].push({child:l,position:a,index:i.indexOf(l)})}let g=c[e.position??"manual"]?.findIndex(({child:l})=>l===e.el),s=n.view.ui;s.remove(t),s.add(t,{position:e.position,index:g})}function N(n){let e=!1,t=n.el.view,o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n.el),"view")??{get:()=>t,set:i=>t=i};Object.defineProperty(n.el,"view",{get:o.get.bind(n.el),set:i=>{o.set.call(n.el,i),i&&!e&&(e=!0,n.arcgisReady.emit())},configurable:!0,enumerable:!0}),t&&(n.el.view=t)}function O(n){return n==null||n===""}function B(n,e){return e!=null&&n?.position===e.position&&n?.heading===e.heading&&n?.tilt===e.tilt&&n?.fov===e.fov}function L(n,e){return e===void 0||n?.targetGeometry!==e?.targetGeometry||n?.rotation!==e?.rotation||n?.scale!==e?.scale}function R(n,e){return f(e?.center,n)}function f(n,e){if(typeof e=="string")return f(n,e.split(",").map(Number));if(!n)return e;if(Array.isArray(e)){let t=e[0],o=e[1],i=e.length>2?e[2]:void 0;if(t!==n.longitude||o!==n.latitude||i!==n.z)return e}else if(e&&!n?.equals(e))return e}async function P(n,e){e!=null&&(typeof e=="string"?n.el.view=await x(n,e):n.widget&&(n.el.view=e.view))}async function x(n,e){let t=m(n,e);return await new Promise(o=>{typeof t?.view?.ready=="boolean"?o(t.view):t&&t.addEventListener("arcgisViewReadyChange",()=>o(t.view),{once:!0})})}function p(n){n.el.childElem&&(n.el.shadowRoot??n.el).append(n.el.childElem)}function m(n,e){let t=e??n.referenceElement;if(typeof t!="string")return t??void 0;let o=t.includes("#")||t.includes(".")||t.includes("["),i=n.el.getRootNode();return(o?void 0:i.querySelector(`#${t}`))??i.querySelector(t)??void 0}var F=n=>n.el.childElem;async function S(n){let e=typeof n=="function"?n():n;e&&("setFocus"in e&&typeof e.setFocus=="function"?await e.setFocus():e instanceof HTMLElement&&e.focus())}export{b as a,N as b,O as c,B as d,L as e,R as f,f as g,P as h,F as i,S as j};