@arcgis/coding-components
Version:
Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.
4 lines • 4.91 kB
JavaScript
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
v4.33.14 */
import{a as f}from"./TFGGM2BC.js";import{a as h,b as g}from"./ZWG62OP5.js";import{a as _}from"./KBSNSGW6.js";import"./FXJMBYDM.js";import b from"./65MFHPLU.js";import a from"./AJJYACDZ.js";import"./WODQNPAA.js";import"./ESHR3OJV.js";import"./FBTENGUV.js";import{C as p,a as n,b as e,l as c,n as d,y as l,z as s}from"./MOODF6RJ.js";import{h as r}from"./SWSGV34B.js";import"./GMVUIEZO.js";import"./HAP7XW5O.js";export default $arcgis.t(([,t])=>{var m=n`{arcgis-sql-expression-editor{display:flex;flex-direction:column;position:relative;overflow:hidden;border:var(--arcgis-coding-components-border)!important;box-sizing:border-box;background-color:var(--arcgis-coding-components-background-color);height:100%}}`,o=class extends l{constructor(){super(...arguments),this._codeEditorElt=h(),this.messages=_(),this._modelId=r(),this._preparing=!1,this.sideActionBarExpanded=!1,this.script="",this.hideSideBar=!1,this.arcgisScriptChange=c({bubbles:!1})}static{this.properties={_activeAction:16,_apiLibrary:16,_editorProfile:16,_preparing:16,sideActionBarExpanded:16,profile:0,script:1,hideSideBar:5}}static{this.shadowRootOptions=d}static{this.styles=[m,f]}async load(){await this._updateEditorProfile().catch(console.error)}willUpdate(i){(i.has("messages")||i.has("profile"))&&this._updateDataModelDeps()}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}async _updateEditorProfile(){this._preparing=!0;try{await t.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale}),this._editorProfile=t.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._preparing=!1}}_setActiveAction(i){if(this._activeAction===i){this._activeAction=void 0;return}this._activeAction=i}_handleActionClick(i){let a=i.target;this._setActiveAction(a.dataset.panelName)}_insertAsSnippet(i){this._codeEditorElt.value?.insertSnippet(i.detail).catch(console.error)}_insertAsText(i){this._codeEditorElt.value?.insertText(i.detail.replaceAll('"',"'")).catch(console.error)}async _updateApiLibrary(){this._apiLibrary=await t.getApiLibraryForModel(this._modelId)}_onCodeEditorValueChange(i){i.stopPropagation(),this.script=i.detail,this.arcgisScriptChange.emit(i.detail)}_getFeatureSetVariable(){let i,a=t.getEditorProfileForModel(this._modelId);return a?.variables?.length&&a?.variables?.[0]?.type!=="featureSet"?console.error("encountered unexpected editor profile"):i=a?.variables?.[0],i}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}render(){let i=this._getFeatureSetVariable();return e`<div class="flex-row flex-adjustable"><div class="flex-column flex-adjustable"><arcgis-code-editor language=arcgis-sql-expression .modelId=${this._modelId} .value=${this.script??""} =${this._onCodeEditorValueChange} ${g(this._codeEditorElt)}></arcgis-code-editor></div>${!this.hideSideBar&&e`<arcgis-editor-variables .variable=${i} .closed=${this._activeAction!=="fields"} class=${s(this._activeAction==="fields"&&"side-panel flex-panel border-inline-start")} .loading=${this._preparing} .modelId=${this._modelId} =${this._insertAsText} =${()=>this._setActiveAction(void 0)} data-panel-name=none></arcgis-editor-variables>`||""}${!this.hideSideBar&&e`<arcgis-language-api-panel class=${s(this._activeAction==="functions"&&"side-panel flex-panel border-inline-start")} .closed=${this._activeAction!=="functions"} =${this._insertAsSnippet} =${()=>this._setActiveAction(void 0)} .loading=${this._preparing} .apiLibrary=${this._apiLibrary} data-panel-name=none hide-documentation-actions .languageId=${t.languageId}></arcgis-language-api-panel>`||""}${!this.hideSideBar&&e`<calcite-action-bar class="side-action-bar border-inline-start" .expanded=${this.sideActionBarExpanded} position=end =${this._toggleSideActionBarExpanded}><calcite-action id=fields-action .text=${this.messages.fields??"Fields"} icon=profile-variables .active=${this._activeAction==="fields"} data-panel-name=fields =${this._handleActionClick}></calcite-action>${!this.sideActionBarExpanded&&e`<calcite-tooltip reference-element=fields-action><span>${this.messages.fields??"Fields"}</span></calcite-tooltip>`||""}<calcite-action id=functions-action .text=${this.messages.functions??"Functions"} icon=function .active=${this._activeAction==="functions"} data-panel-name=functions =${this._handleActionClick}></calcite-action>${!this.sideActionBarExpanded&&e`<calcite-tooltip reference-element=functions-action><span>${this.messages.functions??"Functions"}</span></calcite-tooltip>`||""}</calcite-action-bar>`||""}</div>`}};p("arcgis-sql-expression-editor",o);return o},a,b)