UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.73 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{clone as t}from"../../core/lang.js";import{property as s,subclass as i}from"../../core/accessorSupport/decorators.js";import{supportsFieldConfiguration as l}from"../../layers/support/layerUtils.js";import r from"./SearchSource.js";import{getResults as a,getSuggestions as o}from"./support/layerSearchUtils.js";var h;let n=h=class extends r{constructor(e){super(e),this.displayField=null,this.exactMatch=null,this.orderByFields=null,this.searchFields=null,this.searchTemplate=null,this.suggestionTemplate=null,this.getResults=(e,t)=>a({source:this,...e},t),this.getSuggestions=(e,t)=>o({source:this,...e},t)}set layer(e){this._set("layer",e),e&&e.load().catch(()=>{})}get name(){return this._getLayerTitle()??""}set name(e){this._overrideIfSome("name",e)}clone(){return new h({autoNavigate:this.autoNavigate,filter:this.filter,maxResults:this.maxResults,maxSuggestions:this.maxSuggestions,minSuggestCharacters:this.minSuggestCharacters,outFields:this.outFields?t(this.outFields):null,placeholder:this.placeholder,popupEnabled:this.popupEnabled,prefix:this.prefix,resultGraphicEnabled:this.resultGraphicEnabled,resultSymbol:this.resultSymbol?this.resultSymbol.clone():null,suggestionsEnabled:this.suggestionsEnabled,suffix:this.suffix,withinViewEnabled:this.withinViewEnabled,displayField:this.displayField,exactMatch:this.exactMatch,layer:this.layer,searchFields:this.searchFields?t(this.searchFields):null,suggestionTemplate:this.suggestionTemplate,zoomScale:this.zoomScale})}_getFirstStringField(){return this.layer.fieldsIndex?.fields.find(e=>"string"===e.type)?.name??""}_getDisplayField(){return this.displayField||this.layer.displayField||this._getFirstStringField()}_getSearchFieldsString(){const{layer:e,searchFields:t}=this;if(!e.loaded)return"";const s=t||[this._getDisplayField()],i=l(e);return`: ${s.map(t=>{const s=e.getField(t);return(i?e.getFieldAlias(t):s?.alias)||t}).join(", ")}`}_getLayerTitle(){const{layer:e}=this;if(!e)return;const{title:t}=e;return t?`${t}${this._getSearchFieldsString()}`:void 0}};e([s({json:{read:{source:"field.name"},write:{target:"field.name"}}})],n.prototype,"displayField",void 0),e([s({json:{read:{source:"field.exactMatch"},write:{target:"field.exactMatch"}}})],n.prototype,"exactMatch",void 0),e([s({value:null})],n.prototype,"layer",null),e([s()],n.prototype,"name",null),e([s({type:[String],json:{write:!0}})],n.prototype,"orderByFields",void 0),e([s()],n.prototype,"searchFields",void 0),e([s()],n.prototype,"searchTemplate",void 0),e([s()],n.prototype,"suggestionTemplate",void 0),n=h=e([i("esri.widgets.Search.LayerSearchSource")],n);const d=n;export{d as default};