UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.52 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import s from"../../core/ReactiveMap.js";import r from"../../core/ReactiveSet.js";import{renderingSanitizer as i}from"../../core/sanitizerUtils.js";import{generateUID as o}from"../../core/uid.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../core/support/UpdatingHandles.js";import{extractSubstitutionTemplatesFromString as l}from"../../layers/support/fieldUtils.js";import{prependExpressionPrefix as d,prependFieldPrefix as u,isExpressionReference as m,extractExpressionNameFromString as h,isLegacyFieldMapsExpressionReference as c}from"./featureFormUtils.js";import f from"./InputBase.js";import{assembleStringFromParts as x,splitStringIntoParts as _}from"./support/textElementInputUtils.js";import{compileTextElementMarkdownToHTML as g}from"./support/textManipulationUtils.js";let y=class extends f{constructor(e){super(e),this.group=null,this.id=`TextElementInput-${o()}`,this.type="text",this._expressionReferences=new s,this._expressionsUsed=new r,this._fieldsUsed=new r,this._literalParts=new t,this._templateParts=new t,this._updatingHandles=new a}initialize(){const{rawText:e}=this;e?"markdown"===this.textFormat?this._updatingHandles.addPromise(g(e).then((e=>this._initializeTextParts(e)))):this._initializeTextParts(e):this._literalParts.push("")}get expressionsUsed(){return Array.from(this._expressionsUsed)}get fieldsIndex(){return this.layer.fieldsIndex}set fieldsIndex(e){this._overrideIfSome("fieldsIndex",e)}get fieldsUsed(){return Array.from(this._fieldsUsed)}get rawText(){return this.element.text}get text(){const e=this._templateParts.map((e=>`${this._expressionReferences.get(e)?.lastEvaluatedValue??""}`));return i.sanitize(x(this._literalParts,e))}get textFormat(){return this.element.textFormat}get updating(){return this._updatingHandles.updating||Array.from(this._expressionReferences.values()).some((e=>e?.updating))}setExpressionExecutor(e,t){this._expressionReferences.set(d(e),t)}setFieldExecutor(e,t){this._expressionReferences.set(u(e),t)}_initializeTextParts(e){const{fieldsIndex:t}=this,{literals:s,templates:r}=_(e),i=[],o=[];for(let n=0;n<r.length;n++){const e=s[n],p=l(r[n])[0];if(m(p))this._expressionsUsed.add(h(p)),this._expressionReferences.set(p,null),i.push(e),o.push(p);else if(c(p)){this._expressionsUsed.add(p);const t=d(p);this._expressionReferences.set(t,null),i.push(e),o.push(t)}else if(t?.has(p)){const s=t.normalizeFieldName(p);this._fieldsUsed.add(s);const r=u(s);this._expressionReferences.set(r,null),i.push(e),o.push(r)}else s[n+1]=e.concat(p,s[n+1])}i.push(s.at(-1)),this._literalParts.addMany(i),this._templateParts.addMany(o)}};e([n()],y.prototype,"expressionsUsed",null),e([n()],y.prototype,"fieldsIndex",null),e([n()],y.prototype,"fieldsUsed",null),e([n()],y.prototype,"group",void 0),e([n()],y.prototype,"id",void 0),e([n()],y.prototype,"rawText",null),e([n()],y.prototype,"text",null),e([n()],y.prototype,"textFormat",null),e([n()],y.prototype,"type",void 0),e([n()],y.prototype,"updating",null),y=e([p("esri.widgets.FeatureForm.TextElementInput")],y);const j=y;export{j as default};