12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{isNone as r}from"../core/maybe.js";import{watch as s,initial as i}from"../core/reactiveUtils.js";import{aliasOf as o}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import c from"./Widget.js";import d from"./FeatureTemplates/FeatureTemplatesViewModel.js";import{ItemList as m}from"./FeatureTemplates/ItemList.js";import p from"./FeatureTemplates/TemplateItem.js";import"./support/widgetUtils.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{vmEvent as h}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";const v={base:"esri-feature-templates",loader:"esri-feature-templates__loader",widget:"esri-widget"};function b(e){return"items"in e}function I(e){return e.length>0&&b(e[0])}function y(e){const{label:t}=e;return b(e)?t:`${t}–${e.layer.id}`}const g={filter:!0};let w=class extends(t(c)){constructor(e,t){super(e,t),this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const s=e.target;if(s["data-has-icon"])return void t.unobserve(s);const i=s["data-item"],{layer:o,template:l}=i;s["data-has-icon"]=!0;const n=await p.fetchThumbnail(o,l).catch((()=>(s["data-has-icon"]=!1,null)));if(r(n))return;s.appendChild(n)}}))})),this.enableListScroll=!0,this.filterFunction=null,this.filterText="",this.groupBy=null,this.headingLevel=4,this.label=void 0,this.layers=null,this.messages=null,this.selectedItem=null,this.viewModel=new d,this.visibleElements={...g},this.renderItemIcon=this.renderItemIcon.bind(this),this._afterItemCreateOrUpdate=this._afterItemCreateOrUpdate.bind(this),this._afterItemRemoved=this._afterItemRemoved.bind(this)}initialize(){const e=({label:e})=>!this.filterText||e.toLowerCase().includes(this.filterText.toLowerCase());this.own(s((()=>this.viewModel),((t,r)=>{t&&!t.filterFunction&&(this.filterFunction=e),r&&r!==t&&r.filterFunction===e&&(r.filterFunction=null)}),i))}destroy(){this._iconIntersectionObserver&&(this._iconIntersectionObserver.disconnect(),this._iconIntersectionObserver=null)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-input.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js"),import("@esri/calcite-components/dist/components/calcite-progress.js")])}castVisibleElements(e){return{...g,...e}}select(e){return null}render(){const{enableListScroll:e,filterText:t,headingLevel:r,messages:s,viewModel:{items:i,selectedItem:o,state:l}}=this,n=this.visibleElements.filter;if(I(i)){const e=i.find((e=>e.label===d.nullGroupBy.label));e&&(e.label=s.other)}return f("div",{class:this.classes(v.base,v.widget),"aria-label":s.widgetLabel},"loading"===l?this.renderLoader():"ready"===l?f(m,{id:this.id,identify:y,filterText:t,items:i,headingLevel:r,messages:{filterPlaceholder:s.filterPlaceholder,noItems:s.noItems,noMatches:s.noMatches},filterEnabled:n,onItemSelect:e=>{this.viewModel.select(e)},onFilterChange:e=>{this.filterText=e,this.viewModel.refresh()},renderIcon:this.renderItemIcon,selectedItem:o,enableListScroll:e}):null)}renderItemIcon({item:e}){return f("span",{key:"icon",afterCreate:this._afterItemCreateOrUpdate,afterUpdate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,"data-item":e,"data-has-icon":!1})}renderLoader(){return f("div",{class:v.loader,key:"loader"})}_afterItemCreateOrUpdate(e){this._iconIntersectionObserver?.observe(e)}_afterItemRemoved(e){this._iconIntersectionObserver?.unobserve(e)}};e([n()],w.prototype,"enableListScroll",void 0),e([o("viewModel.filterFunction")],w.prototype,"filterFunction",void 0),e([n()],w.prototype,"filterText",void 0),e([o("viewModel.groupBy")],w.prototype,"groupBy",void 0),e([n()],w.prototype,"headingLevel",void 0),e([n({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],w.prototype,"label",void 0),e([o("viewModel.layers")],w.prototype,"layers",void 0),e([n(),u("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],w.prototype,"messages",void 0),e([o("viewModel.selectedItem")],w.prototype,"selectedItem",void 0),e([n(),h("select")],w.prototype,"viewModel",void 0),e([n()],w.prototype,"visibleElements",void 0),e([l("visibleElements")],w.prototype,"castVisibleElements",null),e([o("viewModel.select")],w.prototype,"select",null),w=e([a("esri.widgets.FeatureTemplates")],w);const j=w;export{j as default};
|