@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.3 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";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,subclass as p}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{extractSubstitutionTemplatesFromString as a}from"../../layers/support/fieldUtils.js";import{prependExpressionPrefix as d,prependFieldPrefix as u,isExpressionReference as m,extractExpressionNameFromString as h,isLegacyFieldMapsExpressionReference as f}from"./featureFormUtils.js";import x from"./InputBase.js";import{assembleStringFromParts as c,splitStringIntoParts as _}from"./support/textElementInputUtils.js";import{compileTextElementMarkdownToHTML as g}from"./support/textManipulationUtils.js";let y=class extends x{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 l}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("")}destroy(){this._updatingHandles.destroy()}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(c(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=a(r[n])[0];if(m(p))this._expressionsUsed.add(h(p)),this._expressionReferences.set(p,null),i.push(e),o.push(p);else if(f(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 U=y;export{U as default};