UNPKG

@arcgis/map-components

Version:
5 lines (4 loc) 3.99 kB
/*! 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 */ import{a as E}from"./QKQNYHUC.js";import{a as C}from"./KWBN5CHV.js";import{b as a}from"./AX2MGWNF.js";import{A as _,B as b,C as $,E as l,G as M,g,i as v,j as c,o as y,q as u,r as w,s as f}from"./NIZJVZRG.js";var[P,{when:x},{signal:D}]=await $arcgis.l(["core/reactiveUtils","core/reactiveUtils","applications/Components/reactiveUtils"]);var k=n=>R(n),h=class extends v{constructor(t){super(t),this._view$=D(void 0),this._viewDestroyHandle=void 0,this._arcgisReadyEmitted=!1;let{el:e}=t,o=e.view;this.setProvisionalExports(void 0),Object.defineProperty(e,"view",{get:()=>this._view$.value,set:i=>{if(this.exports===i)return;let s=e.view;this._view$.value=i,this.exports=i,this.component.requestUpdate("view",s),!this._arcgisReadyEmitted&&i!=null&&(this._arcgisReadyEmitted=!0,this.component.arcgisReady.emit())},configurable:!0,enumerable:!0}),t!==e&&Object.defineProperty(t,"view",{get:()=>e.view,set:i=>{e.view=i}}),queueMicrotask(()=>{o&&(e.view=o)})}hostConnected(){this._viewDestroyHandle??=P.when(()=>this._view$.value?.destroyed,()=>void this.component.destroy?.().catch(console.error),{sync:!0}),this.component.manager.loadedCalled&&a(this.component)}hostLoad(){this.component.manager.destroyed||this._watchMetaProperties()}hostLoaded(){let{el:t}=this.component,e=t.shadowRoot?.firstElementChild??t.firstElementChild??void 0;t.childElem=e??t.childElem,t.isConnected&&a(this.component)}hostDisconnected(){typeof this.component.el.childElem=="object"&&this._view$.value?.ui?.remove(this.component.el.childElem)}hostDestroy(){this._viewDestroyHandle?.remove()}_watchMetaProperties(){c(this.component,"position",t=>{this.component.el.childElem!=null&&typeof t=="string"&&a(this.component)}),c(this.component,"referenceElement",()=>a(this.component))}},R=y(h),A="arcgis-navigation-toggle",N={base:A},j=w`@layer{.arcgis-navigation-toggle{display:flex;inline-size:fit-content;block-size:fit-content}}`,d={pan:"move",rotate:"rotate"},p=class extends b{constructor(){super(...arguments),this.view=k(this),this._messages=E(),this.autoDestroyDisabled=!1,this.icon=d.pan,this.layout="vertical",this.navigationMode="pan",this.position="top-left",this.state="disabled",this.arcgisPropertyChange=u()("layout","state"),this.arcgisReady=_()}static{this.properties={autoDestroyDisabled:5,icon:3,label:1,layout:3,navigationMode:3,position:1,referenceElement:1,state:3}}static{this.shadowRootOptions=g}static{this.styles=j}async destroy(){await this.manager.destroy()}async toggle(){this.state!=="disabled"&&(this.navigationMode=this.navigationMode!=="pan"?"pan":"rotate")}load(){this.manager.onLifecycle(()=>[x(()=>this.view?.navigation?.actionMap,()=>this._updateNavigationActionMap()),x(()=>{let{view:t}=this;return t?.ready&&t?.type==="3d"?"ready":"disabled"},t=>{this.state=t},{sync:!0,initial:!0})])}willUpdate(t){t.has("navigationMode")&&this._updateNavigationActionMap()}_onPanClick(){this.navigationMode="pan"}_onRotateClick(){this.navigationMode="rotate"}_updateNavigationActionMap(){let t=this.view?.navigation?.actionMap;if(!t)return;let e=this.navigationMode==="pan";t.dragPrimary=e?"pan":"rotate",t.dragSecondary=e?"rotate":"pan"}render(){let{_messages:t,navigationMode:e,state:o}=this,i=t.pan??"",s=t.rotate??"",r=o==="disabled",m=e==="pan";return f`<calcite-action-bar class=${$({[N.base]:!0,[C.disabled]:r})} expand-disabled .layout=${this.layout} scale=s><calcite-action .active=${m} appearance=solid data-testid=navigation-toggle-pan .disabled=${r} .icon=${d.pan} @click=${this._onPanClick} scale=s .text=${i} title=${i??l}></calcite-action><calcite-action .active=${!m} appearance=solid data-testid=navigation-toggle-rotate .disabled=${r} .icon=${d.rotate} @click=${this._onRotateClick} scale=s .text=${s} title=${s??l}></calcite-action></calcite-action-bar>`}};M("arcgis-navigation-toggle",p);export{p as ArcgisNavigationToggle};