@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 6.33 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../chunks/tslib.es6.js";import{watch as t,initial as o}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{isTable as s}from"../layers/support/layerUtils.js";import n from"./Widget.js";import{nullGroupBy as l,isTemplateItemGroup as a}from"./FeatureTemplates/featureTemplatesUtils.js";import d from"./FeatureTemplates/FeatureTemplatesViewModel.js";import c from"./FeatureTemplates/VisibleElements.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as p}from"./support/globalCss.js";import{ItemList as u}from"./support/ItemList.js";import{fetchThumbnail as h}from"./support/symbolPreviewUtils.js";import"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as b}from"./support/jsxFactory.js";const y={base:"esri-feature-templates"};function I(e){return e.length>0&&a(e[0])}function g(e){return e.id}let C=class extends n{constructor(e,t){super(e,t),this.enableListScroll=!0,this.filterText="",this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.selectionMode="none",this.viewModel=new d,this.visibleElements=new c,this.renderCustomItem=e=>null,this.renderCustomGroupContent=e=>null,this.renderItemLabel=()=>null,this.renderItemDescription=()=>null,this.renderItemContent=e=>null,this.renderItemContentEnd=e=>null,this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const o=e.target;if(M(o))return void t.unobserve(o);const r=w(o),{layer:i,template:s}=r;j(o,!0);const n=await h(s,i).catch((()=>(j(o,!1),null)));if(null==n)return;o.appendChild(n)}}))})),this._renderItemIcon=e=>s(e.layer)?b("span",{"data-has-icon":!0,"data-item":e,key:"icon"},b("calcite-icon",{icon:"table"})):b("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"}),this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}initialize(){const e=({label:e})=>!this.filterText||!!e?.toLowerCase().includes(this.filterText.toLowerCase());this.addHandles(t((()=>this.viewModel),((t,o)=>{t&&!t.filterFunction&&(this.filterFunction=e),o&&o!==t&&o.filterFunction===e&&(o.filterFunction=null)}),o))}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}loadDependencies(){return m({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get filterFunction(){return this.viewModel.filterFunction}set filterFunction(e){this.viewModel.filterFunction=e}get groupBy(){return this.viewModel.groupBy}set groupBy(e){this.viewModel.groupBy=e}get icon(){return"list-rectangle"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get selectedItem(){return this.viewModel.selectedItem}select(e,t){return this.viewModel.select(e,t)}render(){const{disabled:e,enableListScroll:t,filterText:o,headingLevel:r,messages:i,viewModel:{items:s,numberOfFeatureTemplates:n,selectedItem:d,state:c}}=this,m=this.visibleElements.filter&&n>1;if(I(s)){const e=s.find((e=>e.label===l.label));e&&(e.label=i.other)}return b("div",{"aria-label":i.widgetLabel,class:this.classes(y.base,p.widget)},"loading"===c?b("calcite-loader",{key:"loader",label:this.messagesCommon.loading,type:"indeterminate"}):"ready"===c?b(u,{disabled:e,enableListScroll:t,filterEnabled:m,filterText:o,headingLevel:r,id:this.id,identify:g,items:s,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},renderCustomGroupContent:this.renderCustomGroupContent,renderCustomItem:this.renderCustomItem,renderIcon:this._renderItemIcon,renderItemContent:this.renderItemContent,renderItemContentEnd:this.renderItemContentEnd,renderItemDescription:this.renderItemDescription,renderItemLabel:this.renderItemLabel,selectedItem:d??void 0,selectionMode:this.selectionMode??void 0,onFilterChange:e=>{this.filterText=e},onItemSelect:e=>!a(e)&&this.viewModel.select(e)}):null)}};function w(e){return e?.["data-item"]}function M(e){return!!e?.["data-has-icon"]}function j(e,t){e&&(e["data-has-icon"]=t)}e([r()],C.prototype,"disabled",null),e([r()],C.prototype,"enableListScroll",void 0),e([r()],C.prototype,"filterFunction",null),e([r()],C.prototype,"filterText",void 0),e([r()],C.prototype,"groupBy",null),e([r()],C.prototype,"headingLevel",void 0),e([r()],C.prototype,"icon",null),e([r()],C.prototype,"label",null),e([r()],C.prototype,"layers",null),e([r(),f("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],C.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([r({readOnly:!0})],C.prototype,"selectedItem",null),e([r()],C.prototype,"selectionMode",void 0),e([r(),v("select")],C.prototype,"viewModel",void 0),e([r({type:c,nonNullable:!0})],C.prototype,"visibleElements",void 0),e([r()],C.prototype,"renderCustomItem",void 0),e([r()],C.prototype,"renderCustomGroupContent",void 0),e([r()],C.prototype,"renderItemLabel",void 0),e([r()],C.prototype,"renderItemDescription",void 0),e([r()],C.prototype,"renderItemContent",void 0),e([r()],C.prototype,"renderItemContentEnd",void 0),C=e([i("esri.widgets.FeatureTemplates")],C);const F=C;export{F as default};