@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.45 kB
JavaScript
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as s,isNone as o}from"../../core/maybe.js";import{watch as l,initial as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{renderPreviewHTML as m}from"../../symbols/support/symbolUtils.js";var c;const u="esri.widgets.FeatureTemplates.TemplateItem";let h=c=class extends(i(r)){constructor(t){super(t),this._activeFetchInfo={id:null,request:null},this.layer=null,this.template=null,this.thumbnail=null}initialize(){this.handles.add(l((()=>{const{layer:t}=this;return[t&&"renderer"in t?t.renderer:null,this.template]}),(()=>{this._activeFetchInfo.id=null,this._activeFetchInfo.request=null,this._set("thumbnail",null)}),n))}get description(){return this.template?.description}set description(t){this.template&&(this.template.description=t)}get label(){return this.template?.name}set label(t){this.template&&(this.template.name=t)}get id(){return`${this.label??""}–${this.layer?.id}`}clone(){const t=s(this.thumbnail)?this.thumbnail.cloneNode(!0):null,e=new c({layer:this.layer,template:this.template});return e._set("thumbnail",t),e}static async fetchThumbnail(t,e){const r=await y(t,e);if(o(r))return null;const i={maxSize:36};"dictionary"===t.renderer?.type&&(i.fieldMap=t.renderer.fieldMap??void 0,i.feature={attributes:e.prototype.attributes??{}});return await m(r,i)}};async function y(t,r){const{renderer:i}=t;if(i){const t=new e({attributes:r.prototype.attributes}),s=await i.getSymbolAsync(t);if(s)return s}return d(t)}async function d(t){const{geometryType:e}=t,r="point"===e||"multipoint"===e?await import("../../symbols/SimpleMarkerSymbol.js"):"polyline"===e?await import("../../symbols/SimpleLineSymbol.js"):"polygon"===e||"mesh"===e||"multipatch"===e?await import("../../symbols/SimpleFillSymbol.js"):null;return r?new r.default:null}t([a()],h.prototype,"description",null),t([a()],h.prototype,"label",null),t([a()],h.prototype,"layer",void 0),t([a()],h.prototype,"template",void 0),t([a({readOnly:!0})],h.prototype,"thumbnail",void 0),t([a()],h.prototype,"id",null),h=c=t([p(u)],h);const b=h;export{b as default};