UNPKG

@arcgis/map-components

Version:
2 lines 3.78 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import{b as c,c as d}from"./JRIQGXS5.js";import{c as r,f as m}from"./AKBXFBDL.js";import{b as h}from"./PBSJQPB2.js";import{M as u,b as a,x as s,z as l}from"./WUJCCZQC.js";export default $arcgis.t(([{when:E,watch:w}])=>{var b=class extends l{constructor(o){super(o),this.direction=m(),this.popupRef=u(),this.slotGroupRefs=c(),this.attributionHeight=0,this._uiContainer=null,this.component.listen("arcgisViewClick",t=>{let e=t.detail.native;t.detail.button!==0||e?.ctrlKey||e?.metaKey||this._handleOpenPopup(t.detail)}),this.component.listenOn(globalThis,"unhandledrejection",t=>{let e=t.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)})]}async openPopup(o){if(this._assignDefaultPopup(),this.closePopup(),this.popupElement){await this.popupElement.componentOnReady(),this.popupElement.open=!0;let{fetchFeatures:t,shouldFocus:e,title:p,...n}=o;delete o.fetchFeatures,Object.assign(this.popupElement,n),p!==void 0&&(this.popupElement.heading=p),e&&await this.popupElement.setFocus(),t&&this.popupElement.fetchFeatures()}else await this.component.view.openPopup(o)}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(o){if(!(this.attributionHeight===o||!this.component.el.shadowRoot)){if(this.attributionHeight=o,!this._uiContainer){let t=this.component.el.shadowRoot.querySelector(".arcgis-map-container-ui");this._uiContainer=t}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(o){if(this._assignDefaultPopup(),!this.component.popupDisabled){if(this._maybeDisableViewPopup(),this.popupElement){let{location:t,promises:e}=await this.popupElement?.handleViewClick(o)??{};e?.length?this.openPopup({location:t,promises:e}):this.popupElement?.open&&this.closePopup()}this._maybeResetViewPopup()}}_handlePopupSlotChange(o){let t=h(o.target,"arcgis-popup");!this.popupElement&&t.length?this.popupElement=t[0]:t.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:o=>this._handlePopupSlotChange(o),webGLErrorElement:this._webGLErrorAlert(),popupElement:this.popupRef})}},R=r((i,o)=>{let t=s();return o.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,t.emit())})),t}),G=r((i,o)=>{let t=s();return o.onLifecycle(()=>w(()=>i.view?.readyState,e=>{(e==="map-content-error"||e==="rendering-error")&&t.emit()})),t});return{a:b,b:R,c:G}},"core/reactiveUtils")