@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.34 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import r from"./Slice/SliceViewModel.js";import{loadCalciteComponents as o}from"./support/componentsUtils.js";import{globalCss as n}from"./support/globalCss.js";import{Heading as c}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";const u="esri-slice",p={base:u,actions:`${u}__actions`,cancelButton:`${u}__cancel-button`,container:`${u}__container`,error:`${u}__error`,excludeButton:`${u}__exclude-button`,hint:`${u}__hint`,hintText:`${u}__hint-text`,layerItem:`${u}__layer-item`,layerList:`${u}__layer-list`,layerListHeading:`${u}__layer-list-title`,newSliceButton:`${u}__clear-button`};let m=class extends l{constructor(e,s){super(e,s),this.headingLevel=3,this.messages=null,this.viewModel=new r,this._onNewSliceClick=()=>{t(this.viewModel.start())}}loadDependencies(){return o({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get excludedLayers(){return this.viewModel.excludedLayers}set excludedLayers(e){this.viewModel.excludedLayers=e}get excludeGroundSurface(){return this.viewModel.excludeGroundSurface}set excludeGroundSurface(e){this.viewModel.excludeGroundSurface=e}get icon(){return"slice"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get hasVoxelLayers(){const e=this.viewModel?.view;return null!=e&&e.allLayerViews.some((e=>"voxel-3d"===e.type))}render(){return d("div",{class:this.classes(p.base,n.widget,n.panel),role:"presentation"},this.visible?d("div",{class:p.container},this.viewModel.supported?[this._renderHint(),this._renderLayerList(),this._renderActions()]:this._renderUnsupported()):null)}_renderUnsupported(){return d("div",{class:p.error,key:"unsupported"},d("p",null,this.messages.unsupported))}_renderHint(){const{hasVoxelLayers:e,messages:t,viewModel:s}=this,{active:i,layersMode:l,state:r}=s;let o=null;return i&&("exclude"===l?o=t.excludeHint:"ready"===r&&(o=e?t.voxelHint:t.hint)),o?d("div",{class:p.hint,key:"hint"},d("p",{class:p.hintText},o),d("p",{class:p.hintText},t.verticalHint)):null}_renderLayerList(){const{excludedLayers:e,excludeGroundSurface:t,headingLevel:s,messages:i,viewModel:l}=this,{layersMode:r,state:o}=l,n="slicing"===o||"sliced"===o,a=e?e.toArray().map((e=>this._renderLayerItem({uid:e.uid,title:e.title,onClick:()=>(this.excludedLayers.remove(e),!1)}))):[];return t&&a.push(this._renderLayerItem({uid:"ground",title:i.ground,onClick:()=>(this.excludeGroundSurface=!1,!1)})),"exclude"!==r&&n&&0!==a.length?d("div",{class:p.layerList,key:"settings"},d(c,{class:p.layerListHeading,level:s},i.excludedLayers),d("calcite-list",{label:i.excludedLayers,selectionMode:"none"},a)):null}_renderActions(){const{messages:e,viewModel:t}=this,{active:s,state:i}=t,l="disabled"===i,r="slicing"===i||"sliced"===i,o="exclude"===t.layersMode,n=[];return s&&!r||o||n.push(d("calcite-button",{class:p.newSliceButton,disabled:l,key:"new-slice",onclick:this._onNewSliceClick},e.newSlice)),r&&!o&&n.push(d("calcite-button",{appearance:"outline-fill",class:p.excludeButton,disabled:l,key:"exclude",onclick:()=>t.enterExcludeLayerMode()},e.excludeLayer)),s&&o&&n.push(d("calcite-button",{appearance:"outline-fill",class:p.cancelButton,disabled:l,key:"cancel-exclude",onclick:()=>t.exitExcludeLayerMode()},e.cancel)),0===n.length?null:d("div",{class:p.actions},n)}_renderLayerItem(e){const t=this.messages.includeLayer;return d("calcite-list-item",{class:p.layerItem,"data-testid":`list-item-${e.uid}`,key:e.uid,label:e.title??""},d("calcite-action",{icon:"x",onclick:e.onClick,scale:"s",slot:"actions-end",text:t,title:t}))}};e([s()],m.prototype,"active",null),e([s({constructOnly:!0,nonNullable:!0})],m.prototype,"analysis",null),e([s()],m.prototype,"excludedLayers",null),e([s()],m.prototype,"excludeGroundSurface",null),e([s()],m.prototype,"headingLevel",void 0),e([s()],m.prototype,"icon",null),e([s()],m.prototype,"label",null),e([s(),a("esri/widgets/Slice/t9n/Slice")],m.prototype,"messages",void 0),e([s()],m.prototype,"view",null),e([s({type:r})],m.prototype,"viewModel",void 0),e([s()],m.prototype,"visible",null),e([s()],m.prototype,"hasVoxelLayers",null),m=e([i("esri.widgets.Slice")],m);const y=m;export{y as default};