UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.15 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{isSome as e}from"../../../core/arrayUtils.js";import{getDisplayFieldName as t}from"../../../layers/support/fieldUtils.js";import{loadPanelContentComponents as o,PanelContentSection as r,PanelContent as a}from"./PanelContent.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{ItemList as l}from"../../support/ItemList.js";import"../../support/widgetUtils.js";import{tsx as n}from"../../support/jsxFactory.js";const i=()=>Promise.all([o(),s({action:()=>import("@esri/calcite-components/dist/components/calcite-action")})]);function c({editorItems:t,filterText:o,id:s,messagesTemplates:i,onFilterTextChange:c,onSelectFeature:p,onZoomTo:u,workflow:f,editorMessages:y}){const j=new Map,I=f.data.candidates;let b=0;I.map((e=>({label:m(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((({label:e,data:r})=>{const a=o.toLowerCase(),{title:s}=r.layer,l=t.find((e=>e.layer===r.sourceLayer));return l?l.supportsUpdateWorkflow&&(!a||e?.toLowerCase().includes(a)||s?.toLowerCase().includes(a)):null})).filter(e).forEach((e=>{b++;const t=e.data.layer;j.has(t)?j.get(t)?.items.push(e):j.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const g=t.toArray().map((({layer:e})=>j.get(e))).filter(e),h=b>10||o.length>0;return n(a,{key:"feature-list"},n(r,null,l({enableListScroll:!1,filterEnabled:h,filterText:o,id:s,items:g,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>c(e),onItemMouseEnter:e=>p(e.data),onItemMouseLeave:()=>p(null),onItemSelect:e=>p(e.data,!0),renderItemActionEnd:e=>d(e.data,u,y.zoomTo)})))}function m(e){const o=e.layer;if(!o)return null;const r=o.fieldsIndex.get(o.objectIdField),a=r.alias||r.name,{attributes:s}=e,l=t(o);return l&&s[l]&&`${s[l]}`||`${a}: ${s[r.name]}`}function d(e,t,o){return n("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onclick:()=>t(e),scale:"s",slot:"actions-end",text:o,title:o})}export{c as FeatureList,i as loadFeatureListComponents};