@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 4.07 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../request.js";import{clone as s}from"../core/lang.js";import{property as i,subclass as r}from"../core/accessorSupport/decorators.js";import{collectArcadeFieldNames as o}from"../layers/support/fieldUtils.js";import l from"./Renderer.js";import{VisualVariablesMixin as n}from"./mixins/VisualVariablesMixin.js";import{DictionaryLoader as a}from"./support/DictionaryLoader.js";import{writer as y}from"../core/accessorSupport/decorators/writer.js";var p;let c=p=class extends(n(l)){constructor(e){super(e),this.config=null,this.fieldMap=null,this.scaleExpression=null,this.scaleExpressionTitle=null,this.url=null,this._styleName=null,this._styleVersion=null,this._styleSymbolFields=null,this._styleTextFields=null,this._styleConfigProperties=null,this._styleUISchema=null,this.type="dictionary"}get _loader(){const e=this.getDictionaryInfo();return e.then(e=>{this._styleName=e.dictionary_name,this._styleVersion=e.dictionary_version,this._styleConfigProperties=e.authoringInfo.configuration,this._styleSymbolFields=e.authoringInfo.symbol,this._styleTextFields=e.authoringInfo.text,this._styleUISchema=e.dictionary_ui_schema?JSON.parse(e.dictionary_ui_schema):null}),new a(this.url,this.config,this.fieldMap??{},e)}writeData(e,t){e&&(t.scalingExpressionInfo={expression:e,returnType:"number"})}get styleName(){return this._styleName}get styleVersion(){return this._styleVersion}get styleSymbolFields(){return this._styleSymbolFields}get styleTextFields(){return this._styleTextFields}get styleConfigProperties(){return this._styleConfigProperties}get styleUISchema(){return this._styleUISchema}writeVisualVariables(e,t,s,i){i?.origin||super.writeVisualVariables(e,t,s,i)}clone(){return new p({config:s(this.config),scaleExpression:this.scaleExpression,scaleExpressionTitle:this.scaleExpressionTitle,fieldMap:s(this.fieldMap),url:s(this.url),visualVariables:s(this.visualVariables)})}async getSymbolAsync(e,t,s=!0){return this._loader.getSymbolAsync(e,t,s)}async getSymbolForControlString(e,t,s){return this._loader.getSymbolForControlString(e,t,s)}getDictionaryInfo(){return this._dictionaryInfoPromise||(this._dictionaryInfoPromise=this._fetchDictionaryInfo()),this._dictionaryInfoPromise}async collectRequiredFields(e,t){await this.collectVVRequiredFields(e,t),this.scaleExpression&&await o(e,t,null,this.scaleExpression);for(const s in this.fieldMap){const i=this.fieldMap[s];t.has(i)&&e.add(i)}}get arcadeRequired(){return!0}getSymbol(){return null}get symbols(){return[]}getAttributeHash(){return this.visualVariables?.reduce((e,t)=>e+t.getAttributeHash(),"")??""}getMeshHash(){return`${this.url}-${JSON.stringify(this.fieldMap)}`}async _fetchDictionaryInfo(){const{data:e}=await t(this.url+"/resources/styles/dictionary-info.json",{responseType:"json",query:{f:"json"}});return e}};e([i({type:a})],c.prototype,"_loader",null),e([i({type:Object,json:{read:{source:"configuration"},write:{target:"configuration"}}})],c.prototype,"config",void 0),e([i({type:Object,json:{write:!0}})],c.prototype,"fieldMap",void 0),e([i({type:String,json:{read:{source:"scalingExpressionInfo.expression"},write:!0}})],c.prototype,"scaleExpression",void 0),e([y("scaleExpression")],c.prototype,"writeData",null),e([i({type:String,json:{read:{source:"scalingExpressionInfo.title"},write:{target:"scalingExpressionInfo.title",overridePolicy(e){return{enabled:!!e&&!!this.scaleExpression}}}}})],c.prototype,"scaleExpressionTitle",void 0),e([i({type:String,json:{write:!0}})],c.prototype,"url",void 0),e([i({type:String})],c.prototype,"styleName",null),e([i({type:String})],c.prototype,"styleVersion",null),e([i({type:[String]})],c.prototype,"styleSymbolFields",null),e([i({type:[String]})],c.prototype,"styleTextFields",null),e([i({type:[Object]})],c.prototype,"styleConfigProperties",null),e([i({type:Object})],c.prototype,"styleUISchema",null),e([y("visualVariables")],c.prototype,"writeVisualVariables",null),c=p=e([r("esri.renderers.DictionaryRenderer")],c);export{c as default};