UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 5.37 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{destroyMaybe as t}from"../../core/maybe.js";import{watch as i,initial as o}from"../../core/reactiveUtils.js";import{stripHTML as s}from"../../core/string.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import c from"./support/FeatureElementInfo.js";import{loadCalciteComponents as d}from"../support/componentsUtils.js";import{globalCss as p}from"../support/globalCss.js";import"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as u}from"../support/jsxFactory.js";import h from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";const y="esri-feature-utility-network-associations",g=`${y}__loading-container`,f={base:y,listContainer:`${y}__list`,loadingContainer:g,loadingContainerSticky:`${g}--sticky`};let v=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.onSelectAssociationType=()=>{},this.flowType="feature-utility-network-associations",this.flowItems=null,this.parentFeatureViewModel=null,this.headingLevel=5,this.viewModel=new h,this.messages=null,this.messagesCommon=null,this.visibleElements=new l}initialize(){this._featureElementInfo=new c,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),o)])}loadDependencies(){return d({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._featureElementInfo=t(this._featureElementInfo)}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{state:e}=this.viewModel;return u("div",{class:this.classes(f.base,p.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderAssociationNotFound():this._renderContent())}_renderStickyLoading(){return"querying"===this.viewModel.state?u("div",{class:f.loadingContainerSticky,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return u("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderLoading(){return u("div",{class:f.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderAssociationNotFound(){return u("calcite-notice",{icon:"information",key:"association-not-found",kind:"info",open:!0,scale:"s",width:"full"},u("div",{slot:"message"},this.messages?.noAssociations))}_renderAssociationType(e){const{viewModel:t}=this,i=this._getAssociationTypeTitle(e);return u("calcite-list-item",{description:s(e.description),key:`association-type-${e.type}`,label:s(i),value:e.type,onCalciteListItemSelect:()=>this.onSelectAssociationType({viewModel:t,listType:e,title:i})},u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderAssociations(e){const{viewModel:t}=this;return"featureForm"===t.source||t.getFeatureCountForAssociationType(e.type)>0?this._renderAssociationType(e):void 0}_renderContent(){const{messages:e,viewModel:t}=this,{state:i,associationTypes:o}=t;return u("div",{class:f.listContainer,key:"list-container"},"ready"===i?u("div",null,u("calcite-list",{displayMode:"flat",label:e?.associationsList},o.map((e=>this._renderAssociations(e))))):null,this._renderStickyLoading())}_getAssociationTypeTitle(e){const{messages:t}=this;if(e.title)return e.title;switch(e.type){case"attachment":return t.associationsAttachments;case"connectivity":return t.associationsConnectivity;case"structure":return t.associationsStructure;case"content":return t.associationsContents;case"container":return t.associationsContainer}}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,i=t.description&&this.description,o=t.title&&this.title;this._featureElementInfo?.set({description:i,title:o,headingLevel:e})}};e([n({constructOnly:!0})],v.prototype,"onSelectAssociationType",void 0),e([n()],v.prototype,"flowType",void 0),e([n()],v.prototype,"flowItems",void 0),e([n()],v.prototype,"parentFeatureViewModel",void 0),e([n()],v.prototype,"featureVisibleElements",void 0),e([n()],v.prototype,"description",null),e([n()],v.prototype,"headingLevel",void 0),e([n()],v.prototype,"title",null),e([n({type:h})],v.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],v.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([n({type:l,nonNullable:!0})],v.prototype,"visibleElements",void 0),v=e([r("esri.widgets.Feature.FeatureUtilityNetworkAssociations")],v);export{v as default};