UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 906 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{formatField as r}from"../../../../../layers/support/labelFormatUtils.js";import{sqlToTemplateString as e}from"../../../../../layers/support/labelUtils.js";import{isBadArcadeResult as t}from"../../../arcade/callExpressionWithCursor.js";import{AComputedField as s}from"./AComputedField.js";class a extends s{static async create(t,s){const l=e(t);return new a((e=>l.replaceAll(/{[^}]*}/g,(t=>{const s=t.slice(1,-1),a=e.metadata.fieldsIndex.get(s);if(null==a)return t;const l=e.readAttribute(s);return null==l?"":r(l,a)}))))}constructor(r){super(),this._evaluator=r}resize(r){}read(r,e){return this._evaluator(r)}readWithDefault(r,e,s){const a=this._evaluator(r);return t(a)?s:a}hasArcadeDependency(r){return!1}}export{a as ComputedLegacyLabelExpression};