UNPKG

@arcgis/map-components

Version:
2 lines 2.81 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import{a as u}from"./UVXAJH7N.js";import{a as m}from"./HZFVK34O.js";import{a as d}from"./54VXNFQ4.js";import f from"./OAWV35F7.js";import{h as g}from"./AKBXFBDL.js";import"./LMBRORN7.js";import b from"./5E6WEUZS.js";import{d as h}from"./PBSJQPB2.js";import{O as r,P as c,R as n,U as l,a as s,b as a,x as e}from"./WUJCCZQC.js";import"./3TTFCHAA.js";export default $arcgis.t(([{watch:w},,{a:v}])=>{var f=s`.arcgis-button{--calcite-icon-color: var(--calcite-color-text-3);--calcite-button-background-color: var(--calcite-color-foreground-1);color:var(--calcite-color-text-3);line-height:var(--calcite-font-line-height-relative-tight);calcite-button{--calcite-offset-invert-focus: 1}display:flex;flex-flow:column;cursor:pointer;background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);:hover{--calcite-icon-color: var(--calcite-color-text-1);--calcite-button-background-color: var(--calcite-color-transparent-hover)}}:host{width:fit-content;height:fit-content}`,o=class extends r{constructor(){super(...arguments),this.messages=m(),this.#i=null,this.#t=null,this.view=v(this),this.autoDestroyDisabled=!1,this.icon="home",this.visualScale="m",this.arcgisGo=e(),this.arcgisPropertyChange=g()("state","viewpoint"),this.arcgisReady=e()}static{this.properties={view:0,autoDestroyDisabled:5,goToOverride:0,icon:1,label:1,messageOverrides:0,referenceElement:1,visualScale:1,state:32,viewpoint:0}}static{this.styles=f}#i;#e;#t;get state(){return this.view?.ready?this.#t?"going-home":"ready":"disabled"}get viewpoint(){return this.#i||this.#e}set viewpoint(t){this.#i=t}async cancelGo(){this.#t?.abort(),this.#t=null}async destroy(){await this.manager.destroy()}async go(){if(!this.view?.ready)throw new Error("View is not ready. Cannot go to viewpoint.");if(!this.viewpoint)throw new Error("Cannot go to an undefined viewpoint.");this.cancelGo(),this.arcgisGo.emit();let t=new AbortController;this.#t=t;try{await this.view?.when(),await u({target:this.viewpoint,options:{signal:t.signal}},this.view,this.goToOverride)}catch{}this.#t=null}async loaded(){this.manager.onLifecycle(()=>[w(()=>this.view,t=>{t?.when().then(()=>{this.view===t&&(this.#e=t.viewpoint.clone(),this.#i||this.arcgisPropertyChange.emit({name:"viewpoint"}))})},{initial:!0,sync:!0})])}_go(){this.state==="going-home"?this.cancelGo():this.go()}render(){let{messages:t,icon:p}=this,i=this.state==="going-home";return a`<div class=${c(h("root",d.arcgisButton))}><calcite-button .disabled=${this.state==="disabled"} .iconStart=${i?void 0:p??void 0} kind=neutral .label=${t.componentLabel} @click=${this._go} .scale=${this.visualScale} .loading=${i} title=${(i?t.cancel:t.title)??n}></calcite-button></div>`}};l("arcgis-home",o);return o},"core/reactiveUtils",b,f)