UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.88 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.js";import i from"../../Widget.js";import{css as s}from"../css.js";import{isSplitFeatureWorkflow as n,isCreateFeaturesWorkflow as a}from"../workflowUtils.js";import{CreateFeaturesWorkflowPendingFeatureListAdapter as l}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as c}from"./workflowAdapters/pendingFeatureList/SplitFeatureWorkflowPendingFeatureListAdapter.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import{Heading as m,incrementHeadingLevel as p}from"../../support/Heading.js";import{ItemList as u}from"../../support/ItemList.js";import{fetchThumbnail as h}from"../../support/symbolPreviewUtils.js";import{messageBundle as f,tsx as g,tsxFragment as w}from"../../support/widget.js";let b=class extends i{constructor(){super(...arguments),this.workflow=null,this.workflowAdapter=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver((e,r)=>{e.forEach(async e=>{if(e.isIntersecting){const o=e.target;if(I(o))return void r.unobserve(o);const i=v(o),{graphic:s}=i,n=s.sourceLayer??this.workflowAdapter?.layer;if(!n||!s)return;k(o,!0);const a=i.id?t(this.messages.previewTemplateAriaLabel,{label:i.id}):this.messagesCommon.preview,l=await h(s,n,{ariaLabel:a}).catch(()=>(k(o,!1),null));if(null==l)return;o.appendChild(l)}})}),this.messages=null,this.messagesCommon=null,this._renderActionEnd=({graphic:e})=>{const{workflowAdapter:t,messages:r}=this;if(!t)return;const o=e.geometry?g("calcite-action",{icon:"zoom-to-object",onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e),slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):void 0,i=t.allowCancel?g("calcite-action",{icon:"trash",onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e),slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard}):void 0;return g(w,null,o,i)},this._renderItemContentEnd=({graphic:e})=>{const{workflowAdapter:t}=this,r=t?.isSubmittable(e);return[r?void 0:g("calcite-icon",{class:s.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})]},this._renderItemIcon=e=>{if(null!=e?.graphic?.geometry)return g("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)}}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}initialize(){this.workflowAdapter=L(this.workflow)}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflowAdapter;if(!e)return g(w,null,void 0);const t=this.messages,r=e.features.filter(t=>e.isVisible(t)).map((r,o)=>{const i=e.isSubmittable(r),s=i?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.getFeatureTitle(r)??o}`,graphic:r,label:s,submittable:i}}),o=n(this.workflow)?t.result:t.createFeaturesSelectionList.heading;return g("div",null,g(m,{level:p(this.headingLevel)},o),g("calcite-list",{label:o},u({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:e=>this.workflowAdapter?.highlightFeature(e.graphic),onItemMouseLeave:()=>this.workflowAdapter?.clearHighlights(),onItemSelect:e=>this.workflowAdapter?.onSelectFeature(e.graphic),renderItemContentEnd:this._renderItemContentEnd,renderItemActionEnd:this._renderActionEnd})))}};function v(e){return e?.["data-item"]}function I(e){return!!e?.["data-has-icon"]}function k(e,t){e&&(e["data-has-icon"]=t)}function L(e){return a(e)?new l({workflow:e}):n(e)?new c({workflow:e}):null}e([r()],b.prototype,"workflow",void 0),e([r()],b.prototype,"workflowAdapter",void 0),e([r()],b.prototype,"headingLevel",void 0),e([r(),f("esri/widgets/Editor/t9n/Editor")],b.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],b.prototype,"messagesCommon",void 0),b=e([o("esri.widgets.Editor.components.PendingFeatureList")],b);const F=b;export{F as default};