@arcgis/map-components
Version:
ArcGIS Map Components
2 lines • 3.75 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{b as c,c as d}from"./3KK53EGO.js";import{c as r,f as m}from"./G6XC3FF7.js";import{b as h}from"./56JX3YF3.js";import{M as u,b as a,x as s,z as l}from"./LOPSE7EQ.js";export default $arcgis.t(([{when:E,watch:w}])=>{var b=class extends l{constructor(t){super(t),this.direction=m(),this.popupRef=u(),this.slotGroupRefs=c(),this.attributionHeight=0,this._uiContainer=null,this.component.listenOn(globalThis,"unhandledrejection",o=>{let e=o.reason;if(e?.name==="webgl:required"){let{name:p}=e;this.webGLError={name:p}}})}hostLifecycle(){return[E(()=>this.component.view.ready,()=>{this._assignDefaultPopup()}),E(()=>this.component.view.popup?.visible,()=>{this.popupElement?.open&&(this.popupElement.open=!1)}),this.component.view.on("click",[],t=>{let o=t.native;t.button!==0||o?.ctrlKey||o?.metaKey||this._handleOpenPopup(t)},-2)]}async openPopup(t){if(this._assignDefaultPopup(),this.closePopup(),this.popupElement){await this.popupElement.componentOnReady(),this.popupElement.open=!0;let{fetchFeatures:o,shouldFocus:e,title:p,...n}=t;delete t.fetchFeatures,Object.assign(this.popupElement,n),p!==void 0&&(this.popupElement.heading=p),e&&await this.popupElement.setFocus(),o&&this.popupElement.fetchFeatures()}else await this.component.view.openPopup(t)}closePopup(){this.popupElement&&(this.popupElement.open=!1),this.component.view.closePopup()}_assignDefaultPopup(){this.popupRef.value&&!this.popupElement&&(this.popupElement=this.popupRef.value,this.popupElement.referenceElement=this.component.el,this.popupElement.view=this.component.view)}handleAttributionHeightChange(t){if(!(this.attributionHeight===t||!this.component.el.shadowRoot)){if(this.attributionHeight=t,!this._uiContainer){let o=this.component.el.shadowRoot.querySelector(".arcgis-map-container-ui");this._uiContainer=o}this._uiContainer?.style.setProperty("--arcgis-internal-attribution-space-top",`${this.attributionHeight}px`)}}_maybeDisableViewPopup(){this.component.view&&(this.component.popupComponentEnabled||this.popupElement)&&(this.previousViewPopupEnabled=this.component.view.popupEnabled,this.component.view.popupEnabled=!1)}_maybeResetViewPopup(){this.component.view&&this.previousViewPopupEnabled!==void 0&&(this.component.view.popupEnabled=this.previousViewPopupEnabled,this.previousViewPopupEnabled=void 0)}async _handleOpenPopup(t){if(this._assignDefaultPopup(),!this.component.popupDisabled){if(this._maybeDisableViewPopup(),this.popupElement){let{location:o,promises:e}=await this.popupElement?.handleViewClick(t)??{};e?.length?this.openPopup({location:o,promises:e}):this.popupElement?.open&&this.closePopup()}this._maybeResetViewPopup()}}_handlePopupSlotChange(t){let o=h(t.target,"arcgis-popup");!this.popupElement&&o.length?this.popupElement=o[0]:o.length||(this.popupElement=void 0)}_webGLErrorAlert(){return this.webGLError?a`<arcgis-webgl-error .errorName=${this.webGLError.name}></arcgis-webgl-error>`:null}render(){return d({direction:this.direction,popupComponentEnabled:this.component.popupComponentEnabled,slotGroupRefs:this.slotGroupRefs,handlePopupSlotChange:t=>this._handlePopupSlotChange(t),webGLErrorElement:this._webGLErrorAlert(),popupElement:this.popupRef})}},C=r((i,t)=>{let o=s();return t.onLifecycle(()=>w(()=>{let{map:e}=i;if(!e||e.destroyed)return[];let p=[];return e.loadError&&p.push(e),e.basemap?.loadError&&p.push(e.basemap),e.ground.loadError&&p.push(e.ground),[...e.allLayers,...e.allTables].forEach(n=>{n.loadError&&p.push(n)}),p},e=>{e.length&&(i.loadErrorSources=e,o.emit())})),o}),G=r((i,t)=>{let o=s();return t.onLifecycle(()=>w(()=>i.view?.readyState,e=>{(e==="map-content-error"||e==="rendering-error")&&o.emit()})),o});return{a:b,b:C,c:G}},"core/reactiveUtils")