@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 5.2 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../analysis/SliceAnalysis.js";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{ignoreAbortErrors as l}from"../core/promiseUtils.js";import{property as r,subclass as o}from"../core/accessorSupport/decorators.js";import n from"./Widget.js";import c from"./Slice/SliceViewModel.js";import{loadCalciteComponents as a}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{Heading as u}from"./support/Heading.js";import{messageBundle as p,tsx as m}from"./support/widget.js";const y="esri-slice",h={base:y,actions:`${y}__actions`,cancelButton:`${y}__cancel-button`,container:`${y}__container`,error:`${y}__error`,excludeButton:`${y}__exclude-button`,hint:`${y}__hint`,hintText:`${y}__hint-text`,layerItem:`${y}__layer-item`,layerList:`${y}__layer-list`,layerListHeading:`${y}__layer-list-title`,newSliceButton:`${y}__clear-button`};let v=class extends n{constructor(e,t){super(e,t),this.headingLevel=3,this.messages=null,this.viewModel=new c({suppressDeprecationWarning:!0}),this._onNewSliceClick=()=>{l(this.viewModel.start())},i(s.getLogger(this),"Slice","arcgis-slice",{version:"4.33"})}loadDependencies(){return a({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 m("div",{class:this.classes(h.base,d.widget,d.panel),role:"presentation"},this.visible?m("div",{class:h.container},this.viewModel.supported?[this._renderHint(),this._renderLayerList(),this._renderActions()]:this._renderUnsupported()):null)}_renderUnsupported(){return m("div",{class:h.error,key:"unsupported"},m("p",null,this.messages.unsupported))}_renderHint(){const{hasVoxelLayers:e,messages:t,viewModel:i}=this,{active:s,mode:l,state:r}=i;let o=null;return s&&("exclude"===l?o=t.excludeHint:"ready"===r&&(o=e?t.voxelHint:t.hint)),o?m("div",{class:h.hint,key:"hint"},m("p",{class:h.hintText},o),m("p",{class:h.hintText},t.verticalHint)):null}_renderLayerList(){const{excludedLayers:e,excludeGroundSurface:t,headingLevel:i,messages:s,viewModel:l}=this,{mode:r,state:o}=l,n="slicing"===o||"sliced"===o,c=e?e.toArray().map(e=>this._renderLayerItem({uid:e.uid,title:e.title,onClick:()=>(this.excludedLayers.remove(e),!1)})):[];return t&&c.push(this._renderLayerItem({uid:"ground",title:s.ground,onClick:()=>(this.excludeGroundSurface=!1,!1)})),"exclude"!==r&&n&&0!==c.length?m("div",{class:h.layerList,key:"settings"},m(u,{class:h.layerListHeading,level:i},s.excludedLayers),m("calcite-list",{label:s.excludedLayers,selectionMode:"none"},c)):null}_renderActions(){const{messages:e,viewModel:t}=this,{active:i,state:s}=t,l="disabled"===s,r="slicing"===s||"sliced"===s,o="exclude"===t.mode,n=[];return i&&!r||o||n.push(m("calcite-button",{class:h.newSliceButton,disabled:l,key:"new-slice",onclick:this._onNewSliceClick},e.newSlice)),r&&!o&&n.push(m("calcite-button",{appearance:"outline-fill",class:h.excludeButton,disabled:l,key:"exclude",onclick:()=>t.enterExcludeLayerMode()},e.excludeLayer)),i&&o&&n.push(m("calcite-button",{appearance:"outline-fill",class:h.cancelButton,disabled:l,key:"cancel-exclude",onclick:()=>t.exitExcludeLayerMode()},e.cancel)),0===n.length?null:m("div",{class:h.actions},n)}_renderLayerItem(e){const t=this.messages.includeLayer;return m("calcite-list-item",{class:h.layerItem,"data-testid":`list-item-${e.uid}`,key:e.uid,label:e.title??""},m("calcite-action",{icon:"x",onclick:e.onClick,slot:"actions-end",text:t,title:t}))}};e([r()],v.prototype,"active",null),e([r({type:t,nonNullable:!0})],v.prototype,"analysis",null),e([r()],v.prototype,"excludedLayers",null),e([r()],v.prototype,"excludeGroundSurface",null),e([r()],v.prototype,"headingLevel",void 0),e([r()],v.prototype,"icon",null),e([r()],v.prototype,"label",null),e([r(),p("esri/widgets/Slice/t9n/Slice")],v.prototype,"messages",void 0),e([r()],v.prototype,"view",null),e([r({type:c})],v.prototype,"viewModel",void 0),e([r()],v.prototype,"visible",null),e([r()],v.prototype,"hasVoxelLayers",null),v=e([o("esri.widgets.Slice")],v);const g=v;export{g as default};