UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 6.62 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.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 s}from"../core/accessorSupport/decorators/subclass.js";import{isTable as i}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 m from"./FeatureTemplates/VisibleElements.js";import{loadCalciteComponents as c}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";import{substitute as g}from"../intl/substitute.js";const y={base:"esri-feature-templates"};function I(e){return e.length>0&&a(e[0])}function C(e){return e.id}let w=class extends n{constructor(e,t){super(e,t),this.enableListScroll=!0,this.filterText="",this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesLegend=null,this.selectionMode="none",this.viewModel=new d,this.visibleElements=new m,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(j(o))return void t.unobserve(o);const r=L(o),{layer:s,template:i}=r;M(o,!0);const n=r.label?g(this.messagesLegend.previewTemplateAriaLabel,{label:r.label}):this.messagesCommon.preview,l=await h(i,s,{ariaLabel:n}).catch((()=>(M(o,!1),null)));if(null==l)return;o.appendChild(l)}}))})),this._renderItemIcon=e=>i(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 c({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:s,viewModel:{items:i,numberOfFeatureTemplates:n,selectedItem:d,state:m}}=this,c=this.visibleElements.filter&&n>1;if(I(i)){const e=i.find((e=>e.label===l.label));e&&(e.label=s.other)}return b("div",{"aria-label":s.widgetLabel,class:this.classes(y.base,p.widget)},"loading"===m?b("calcite-loader",{key:"loader",label:this.messagesCommon.loading,type:"indeterminate"}):"ready"===m?b(u,{disabled:e,enableListScroll:t,filterEnabled:c,filterText:o,headingLevel:r,id:this.id,identify:C,items:i,messages:{filterPlaceholder:s.filterPlaceholder,noItems:s.noItems,noMatches:s.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 L(e){return e?.["data-item"]}function j(e){return!!e?.["data-has-icon"]}function M(e,t){e&&(e["data-has-icon"]=t)}e([r()],w.prototype,"disabled",null),e([r()],w.prototype,"enableListScroll",void 0),e([r()],w.prototype,"filterFunction",null),e([r()],w.prototype,"filterText",void 0),e([r()],w.prototype,"groupBy",null),e([r()],w.prototype,"headingLevel",void 0),e([r()],w.prototype,"icon",null),e([r()],w.prototype,"label",null),e([r()],w.prototype,"layers",null),e([r(),f("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],w.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([r(),f("esri/widgets/Legend/t9n/Legend")],w.prototype,"messagesLegend",void 0),e([r({readOnly:!0})],w.prototype,"selectedItem",null),e([r()],w.prototype,"selectionMode",void 0),e([r(),v("select")],w.prototype,"viewModel",void 0),e([r({type:m,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([r()],w.prototype,"renderCustomItem",void 0),e([r()],w.prototype,"renderCustomGroupContent",void 0),e([r()],w.prototype,"renderItemLabel",void 0),e([r()],w.prototype,"renderItemDescription",void 0),e([r()],w.prototype,"renderItemContent",void 0),e([r()],w.prototype,"renderItemContentEnd",void 0),w=e([s("esri.widgets.FeatureTemplates")],w);const F=w;export{F as default};