UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.84 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import{addMany as e}from"../../../core/arrayUtils.js";import{property as s,subclass as r}from"../../../core/accessorSupport/decorators.js";import{extractSubstitutionTemplatesFromString as i}from"../../../layers/support/fieldUtils.js";import{ElementTemplateBase as o}from"./ElementTemplateBase.js";import{splitStringIntoParts as l,isExpressionReference as p,extractExpressionNameFromString as a,isLegacyFieldMapsExpressionReference as n}from"./support/textElementTemplateUtils.js";let h=class extends o{constructor(t){super(t),this.compiledText=null,this.fieldsIndex=null,this.group=null,this.type="text",this._literalParts=[],this._expressionParts=[]}initialize(){this.compiledText?this._initializeTextParts(this.compiledText):this._literalParts.push("")}get expressionParts(){return this._expressionParts}get literalParts(){return this._literalParts}_initializeTextParts(t){const{literals:s,templates:r}=l(t),o=[],h=[];for(let e=0;e<r.length;e++){const t=s[e],l=i(r[e])[0];if(p(l)){const e=a(l);o.push(t),h.push(e)}else if(n(l))o.push(t),h.push(l);else if(this.fieldsIndex?.has(l)){const e=`$feature["${this.fieldsIndex.normalizeFieldName(l)}"]`;o.push(t),h.push(e)}else s[e+1]=t.concat(l,s[e+1])}o.push(s.at(-1)),e(this._literalParts,o),e(this._expressionParts,h)}};t([s()],h.prototype,"compiledText",void 0),t([s()],h.prototype,"expressionParts",null),t([s({constructOnly:!0})],h.prototype,"fieldsIndex",void 0),t([s({clonable:!1})],h.prototype,"group",void 0),t([s()],h.prototype,"literalParts",null),t([s()],h.prototype,"type",void 0),t([s()],h.prototype,"_literalParts",void 0),t([s()],h.prototype,"_expressionParts",void 0),h=t([r("esri.widgets.BatchAttributeForm.templates.TextElementTemplate")],h);export{h as TextElementTemplate};