@arcgis/core 5.2.0-next.76 → 5.2.0-next.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{dbdd96e558936955acdb.js → 040a73b2a23577e1eabd.js} +1 -1
- package/assets/esri/core/workers/chunks/{bad2c7219e95750906e1.js → 05663093b1d2a268b953.js} +1 -1
- package/assets/esri/core/workers/chunks/{755b2d883fba90c4e688.js → 06c8547521ce9c97b258.js} +2 -2
- package/assets/esri/core/workers/chunks/{a014c17fc210620da738.js → 17e9324a02b69733307a.js} +2 -2
- package/assets/esri/core/workers/chunks/29a20a37e7837142fa6b.js +2 -0
- package/assets/esri/core/workers/chunks/{4945d6b0ca1812864185.js → 385b23d4bd5275031fb6.js} +1 -1
- package/assets/esri/core/workers/chunks/3958d92c737b3a2a3bc2.js +1 -0
- package/assets/esri/core/workers/chunks/{9c3e6325dc60bcaf44d7.js → 4115bab15c19b4f5ae08.js} +1 -1
- package/assets/esri/core/workers/chunks/{ff578f0ca68d652fece5.js → 57e26a86d46e02c89c4f.js} +1 -1
- package/assets/esri/core/workers/chunks/{8b980c6b92cc4ea68ede.js → 81cd0cb9ae1371765d32.js} +1 -1
- package/assets/esri/core/workers/chunks/{de927b1460bc384f5b87.js → 83556c9f6f85c2a46779.js} +1 -1
- package/assets/esri/core/workers/chunks/{f4aa6e90200f61e623e5.js → 8762da315cf5086167c3.js} +1 -1
- package/assets/esri/core/workers/chunks/{46e56fac44e0fd26ba1d.js → 95956d62591d689f1135.js} +1 -1
- package/assets/esri/core/workers/chunks/{9e2e4d197a7a57c2a691.js → ac2ba5c3d613d7d5183a.js} +1 -1
- package/assets/esri/core/workers/chunks/{94b9a61b4dbb83425a78.js → b2812279662f1a5f8d06.js} +1 -1
- package/assets/esri/core/workers/chunks/b82763e9401b16121f8d.js +2 -0
- package/assets/esri/core/workers/chunks/{83e54166ba634ec2bd89.js → c69cf08da4e4c2c824ee.js} +10 -10
- package/assets/esri/core/workers/chunks/{6c740c411b085d2d08c4.js → cd74de12005834244a47.js} +1 -1
- package/assets/esri/core/workers/chunks/{6e45ecf359bce3417f5d.js → ef803fb25741e9f2a0a1.js} +1 -1
- package/assets/esri/core/workers/chunks/f3bbebedad51f776bb98.js +1 -0
- package/assets/esri/core/workers/chunks/{a91c1d782346a9c7e1ef.js → f703bc002c732d1c045d.js} +1 -1
- package/assets/esri/core/workers/chunks/fdd4f78facec6387cdb0.js +1 -0
- package/assets/esri/core/workers/chunks/ffd5285c7b2c83208f87.js +2 -0
- package/config.js +1 -1
- package/geometry/support/webMercatorUtils.d.ts +38 -14
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VectorTileLayer.d.ts +40 -22
- package/layers/mixins/RasterJobHandlerMixin.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +4 -4
- package/support/revision.js +1 -1
- package/views/2d/engine/BitmapTile.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/flow/styles/Particles.js +1 -1
- package/views/2d/engine/flow/styles/Streamlines.js +1 -1
- package/views/2d/engine/imagery/RasterTile.js +1 -1
- package/views/2d/engine/imagery/RasterVFTile.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileRendererHelper3D.js +1 -1
- package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/RenderingDevice.js +1 -1
- package/views/2d/engine/webgl/TileContainer.js +1 -1
- package/views/2d/engine/webgl/TiledDisplayObject.js +1 -1
- package/views/2d/engine/webgl/normalizedTileUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/bitmap/BitmapTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPointShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/flow/FlowTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/LineTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/VectorFieldTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BitmapShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/HeatmapAccumulateShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/PatternFillShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TexturedLineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/Tile.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileInfo.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ViewInfo.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/MagDirShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/ScalarShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderBackground.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderCircle.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderFill.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderIcon.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderLine.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderOutline.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderText.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileDebugInfoTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileStencilTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/utility/DebugOverlayTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueCircle.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueSymbol.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/support/DisplayGL.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/state/HUDOccludedFragmentOpacity.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TerrainWaterproofnessDiagnostics.js +2 -0
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/parts/Model.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/support/waitForResources.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/UniformBufferLayout.js +1 -1
- package/views/webgl/UniformBufferObject.js +1 -1
- package/widgets/Feature/FeatureViewModel.d.ts +4 -3
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/Features/FeaturesViewModel.d.ts +4 -2
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Popup/PopupViewModel.d.ts +1 -0
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
- package/assets/esri/core/workers/chunks/0502641d9a214b37ff29.js +0 -1
- package/assets/esri/core/workers/chunks/4f8ce5887102971bfa34.js +0 -2
- package/assets/esri/core/workers/chunks/532e3a59888e4cc13bd3.js +0 -2
- package/assets/esri/core/workers/chunks/a19be304219808268039.js +0 -2
- package/assets/esri/core/workers/chunks/b950ddafba8125c84a5b.js +0 -1
- package/assets/esri/core/workers/chunks/de9a1cce70581920f248.js +0 -1
- package/views/2d/engine/webgl/shaderGraph/types.js +0 -2
- package/views/2d/engine/webgl/shaderGraph/uniformBufferUtils.js +0 -2
- /package/assets/esri/core/workers/chunks/{755b2d883fba90c4e688.js.LICENSE.txt → 06c8547521ce9c97b258.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{a014c17fc210620da738.js.LICENSE.txt → 17e9324a02b69733307a.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{4f8ce5887102971bfa34.js.LICENSE.txt → 29a20a37e7837142fa6b.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{a19be304219808268039.js.LICENSE.txt → b82763e9401b16121f8d.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{532e3a59888e4cc13bd3.js.LICENSE.txt → ffd5285c7b2c83208f87.js.LICENSE.txt} +0 -0
package/widgets/Features.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{loadActionUtilsComponents as v,substituteActionImage as m,getActionStyles as g,renderAction as w}from"../support/actions/actionUtils.js";import _ from"./Feature.js";import M from"./Spinner.js";import f from"./Widget.js";import{css as F}from"./Feature/resources.js";import{FeatureContentMixin as y}from"./Feature/support/FeatureContentMixin.js";import{css as b}from"./Features/css.js";import I from"./Features/FeaturesDrillIn.js";import C from"./Features/FeaturesViewModel.js";import A from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as x}from"./Popup/actions.js";import{zoomToLocation as T}from"./Popup/actionUtils.js";import{loadCalciteComponents as N}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import{Heading as O}from"./support/Heading.js";import{tsx as E,messageBundle as W,vmEvent as D}from"./support/widget.js";import{setFocus as L}from"./support/widgetUtils.js";const B="selected-index",S=0,j="features-spinner";function R(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let H=class extends(y(f)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new I({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new x,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new C,this.visibleElements=new A,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),S),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>T(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([v(),N({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new _({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=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}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(B);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return E("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(b.base,k.widget,k.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return E("div",{class:b.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r}=o;return E("calcite-action",{bind:this,class:b.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:r>0,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature,onclick:this._handlePaginationMenuButton})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return E("calcite-action-bar",{class:b.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},E("calcite-action-group",{scale:"s"},E("calcite-action",{class:b.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,text:e,title:e,onclick:this._previousFeature}),E("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,text:t,title:t,onclick:this._nextFeature})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return E("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onCalciteListItemSelect:this._selectFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature},E("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(R(o)?o:null)||(R(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?E("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?E("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?E("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return E("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[b.contentFeature]:!0,[b.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?E(O,{class:this.classes(b.featuresHeading,k.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),E("div",{class:this.classes(b.container,b.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m}=e,{featureMenuHeading:g}=i,w=o??s.selectFeature;if("feature"===r&&!l)return null;const _="list"===r?!a:l;return E("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[b.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:g?t(s.total,{total:v.length}):void 0,heading:g?w:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:_,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,m>0?E("calcite-loader",{class:b.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,E("div",{class:b.container},this._renderFeatureMenu()),E("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:b.featureMenuObserver}),"feature"===r?E("calcite-button",{appearance:"transparent",slot:"footer-start",width:"full",onclick:this._handleFeatureMenuBack},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?E("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=m({action:e,feature:this.selectedFeature}),s={[b.icon]:!!t,[b.actionImage]:!!o};return t&&(s[t]=!0),o||t?E("span",{"aria-hidden":"true",class:this.classes(b.icon,s),key:"icon",styles:g(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?E("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},E("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return w(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?E("div",{class:F.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=(await(import("../geometry/operators/labelPointOperator.js"))).execute(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");L(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,B)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new M({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],H.prototype,"_drillInFlowItems",void 0),e([h()],H.prototype,"_hideActionText",null),e([h()],H.prototype,"_featureNavigationVisible",null),e([h()],H.prototype,"_isCollapsed",null),e([h()],H.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],H.prototype,"active",null),e([h()],H.prototype,"collapsed",void 0),e([h()],H.prototype,"content",null),e([h()],H.prototype,"icon",null),e([h()],H.prototype,"featureMenuOpen",null),e([h()],H.prototype,"featureMenuTitle",null),e([h()],H.prototype,"featureNavigationTop",void 0),e([h()],H.prototype,"features",null),e([h()],H.prototype,"goToOverride",null),e([h({type:x})],H.prototype,"headerActions",void 0),e([h()],H.prototype,"headingLevel",void 0),e([h()],H.prototype,"initialDisplayMode",null),e([h()],H.prototype,"location",null),e([h()],H.prototype,"label",null),e([h()],H.prototype,"map",null),e([h(),W("esri/widgets/Features/t9n/Features")],H.prototype,"messages",void 0),e([h(),W("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([h()],H.prototype,"promises",null),e([h()],H.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],H.prototype,"selectedFeature",null),e([h({readOnly:!0})],H.prototype,"selectedDrillInFeature",null),e([h()],H.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],H.prototype,"selectedFeatureWidget",null),e([h()],H.prototype,"spatialReference",null),e([h()],H.prototype,"title",null),e([h()],H.prototype,"timeZone",null),e([h()],H.prototype,"updateLocationEnabled",null),e([h()],H.prototype,"view",null),e([h({type:C}),D(["triggerAction","trigger-action"])],H.prototype,"viewModel",void 0),e([h({type:A,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([h()],H.prototype,"visible",null),H=e([p("esri.widgets.Features")],H);export{H as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t,formatNumber as i}from"../intl.js";import o from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as l,initial as a,when as d}from"../core/reactiveUtils.js";import{waitAnimationFrame as c}from"../core/scheduling.js";import{throttle as u}from"../core/throttle.js";import{property as h,subclass as p}from"../core/accessorSupport/decorators.js";import{loadActionUtilsComponents as v,substituteActionImage as m,getActionStyles as g,renderAction as w}from"../support/actions/actionUtils.js";import _ from"./Feature.js";import M from"./Spinner.js";import f from"./Widget.js";import{css as F}from"./Feature/resources.js";import{FeatureContentMixin as y}from"./Feature/support/FeatureContentMixin.js";import{css as b}from"./Features/css.js";import I from"./Features/FeaturesDrillIn.js";import C from"./Features/FeaturesViewModel.js";import A from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as x}from"./Popup/actions.js";import{zoomToLocation as T}from"./Popup/actionUtils.js";import{loadCalciteComponents as N}from"./support/componentsUtils.js";import{globalCss as k}from"./support/globalCss.js";import{Heading as O}from"./support/Heading.js";import{tsx as E,messageBundle as W,vmEvent as D}from"./support/widget.js";import{setFocus as L}from"./support/widgetUtils.js";const B="selected-index",S=0,j="features-spinner";function R(e){return e?.declaredClass.startsWith("esri.layers.")??!1}let H=class extends(y(f)){constructor(e,t){super(e,t),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._spinner=null,this._feature=null,this._focusAbortController=null,this._drillInFlowItems=new o,this._drillInWidget=new I({flowItems:this._drillInFlowItems}),this._rootNode=null,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new x,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new C({suppressDeprecationWarning:!0}),this.visibleElements=new A,this._previousFeature=()=>{this.viewModel.previous()},this._nextFeature=()=>{this.viewModel.next()},this._handleFeatureBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this._openFeatureMenu()},this._handleFeatureMenuBack=()=>{"list"===this.initialDisplayMode?(this.selectedFeatureIndex=-1,this._focusFlowItemNode()):this.featureMenuOpen&&this._closeFeatureMenu()},this._storeRootNode=e=>{this._rootNode=e},this._displaySpinnerThrottled=u(()=>this._displaySpinner(),S),!0!==e?.suppressDeprecationWarning&&s(n.getLogger(this),"Features","arcgis-features",{version:"4.34"}),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,l(()=>this.viewModel?.active,()=>this._toggleScreenLocationEnabled()),l(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),l(()=>this.visibleElements?.closeButton,e=>this._drillInWidget.closable=e),l(()=>this.visibleElements?.spinner,e=>this._spinnerEnabledChange(e)),l(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),l(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),l(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),l(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),l(()=>this.selectedFeatureWidget?.viewModel,()=>this._destroyDrillInFlowItemWidgets()),l(()=>this.featureMenuOpen,()=>this._drillInWidget.selectLastFlowItem="list"===this.initialDisplayMode||!this.featureMenuOpen,a),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),l(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),l(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),l(()=>this._drillInFlowItems.length,()=>this._focusFlowItemNode()),this._drillInWidget.on("close",()=>this.close()),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>T(this.viewModel,e))])}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}loadDependencies(){return Promise.all([v(),N({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})])}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._drillInWidget?.destroy(),this._focusAbortController?.abort()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&!!this.viewModel.selectedFeature&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&("list"===this.initialDisplayMode||!!this.title&&!!this.content)}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get featureMenuTitle(){return this.viewModel.featureMenuTitle}set featureMenuTitle(e){this.viewModel.featureMenuTitle=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o,spatialReference:s,map:n}=this,{selectedFeatureViewModel:r}=this.viewModel,l={title:!1};return r?(e?(e.viewModel=r,e.visibleElements=l):this._feature=new _({flowItems:i,headingLevel:t+1,timeZone:o,spatialReference:s,map:n,viewModel:r,visibleElements:l,suppressDeprecationWarning:!0}),this._feature):null}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=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}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():n.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._focusFlowItemNode():n.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(B);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(d(()=>!this.viewModel.waitingForResult,()=>this._addSelectedFeatureIndexHandle(),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return E("div",{afterCreate:this._storeRootNode,bind:this,class:this.classes(b.base,k.widget,k.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),"list"===this.initialDisplayMode?this._renderFeaturePaginationText():this._renderFeatureMenuButton()]}_renderHeader(){return this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return!this.featureNavigationTop&&this._featureNavigationVisible?E("div",{class:b.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation()):null}_renderFeaturePaginationText(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n}=o;return E("div",{class:b.paginationText,key:"feature-pagination-text"},t(e.pageText,{index:i(n+1),total:i(s)}))}_renderFeatureMenuButton(){const{messages:e,viewModel:o}=this,{featureCount:s,selectedFeatureIndex:n,pendingPromisesCount:r}=o;return E("calcite-action",{bind:this,class:b.paginationMenuButton,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:r>0,text:t(e.pageText,{index:i(n+1),total:i(s)}),textEnabled:!0,title:e.selectFeature,onclick:this._handlePaginationMenuButton})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return E("calcite-action-bar",{class:b.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},E("calcite-action-group",{scale:"s"},E("calcite-action",{class:b.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,text:e,title:e,onclick:this._previousFeature}),E("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,label:t,text:t,title:t,onclick:this._nextFeature})))}_renderFeatureMenuItem(e){const{initialDisplayMode:t}=this,{selectedFeatureViewModel:i,featureViewModels:o}=this.viewModel,s=e===i,n=o.indexOf(e);return E("calcite-list-item",{bind:this,"data-feature-index":n,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onCalciteListItemSelect:this._selectFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature},E("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}),"list"===t?E("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}):null)}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach(e=>{const i=e?.graphic;if(!i)return;const{layer:o,sourceLayer:s}=i,n=(R(o)?o:null)||(R(s)?s:null),r=t.get(n)??[];t.set(n,[...r,e])}),t}_renderFeatureMenu(){const{messages:e,viewModel:t}=this,i=this._groupResultsByLayer(),o="list"===this.initialDisplayMode?"none":"single";return t.featureViewModels.length?E("calcite-list",{displayMode:"flat",label:e?.featuresList,selectionAppearance:"icon",selectionMode:o},Array.from(i.keys(),e=>{const t=i.get(e)?.map(e=>this._renderFeatureMenuItem(e)),o=e?e.title??this.messagesCommon.untitled:null;return this.visibleElements.featureListLayerTitle&&null!==o?E("calcite-list-item-group",{heading:o,key:e?.uid||"map-graphics"},t):t})):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?E("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-id":e.id,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s,_drillInFlowItems:n,initialDisplayMode:r,selectedFeature:l,featureMenuOpen:a}=this,{title:d,active:c}=this.viewModel,u=t.heading&&d?d:"";if("list"===r&&!l)return null;const h=0===n.length&&("list"===r?!!l:!a);return E("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,bind:this,class:this.classes({[b.contentFeature]:!0,[b.flowItemCollapsed]:i}),closable:t.closeButton,closed:!c,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",selected:h,onCalciteFlowItemBack:this._handleFeatureBack,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},u?E(O,{class:this.classes(b.featuresHeading,k.heading),innerHTML:u,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),E("div",{class:this.classes(b.container,b.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,visibleElements:i,featureMenuTitle:o,messages:s,messagesCommon:n,initialDisplayMode:r,featureMenuOpen:l,selectedFeature:a,_collapseEnabled:d,_isCollapsed:c,featureNavigationTop:u,headingLevel:h}=this,{active:p,featureViewModels:v,pendingPromisesCount:m}=e,{featureMenuHeading:g}=i,w=o??s.selectFeature;if("feature"===r&&!l)return null;const _="list"===r?!a:l;return E("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,bind:this,class:this.classes({[b.flowItemCollapsed]:c}),closable:"list"===r&&i.closeButton,closed:!p,collapsed:"list"===r&&c,collapseDirection:u?"down":"up",collapsible:"list"===r&&d,description:g?t(s.total,{total:v.length}):void 0,heading:g?w:void 0,headingLevel:h,key:"feature-menu",loading:e.waitingForContents,selected:_,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()},onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},"list"===r?this._renderHeaderActions():null,m>0?E("calcite-loader",{class:b.loader,inline:!0,key:"feature-menu-loader",label:n.loading,slot:"header-actions-end"}):null,E("div",{class:b.container},this._renderFeatureMenu()),E("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:b.featureMenuObserver}),"feature"===r?E("calcite-button",{appearance:"transparent",slot:"footer-start",width:"full",onclick:this._handleFeatureMenuBack},n.back):null)}_renderContentContainer(){const e="list"===this.initialDisplayMode?[this._renderFeatureMenuContainer(),this._renderContentFeature(),this._drillInWidget.render()]:[this._renderContentFeature(),this._drillInWidget.render(),this._renderFeatureMenuContainer()];return this.visibleElements.flow?E("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=m({action:e,feature:this.selectedFeature}),s={[b.icon]:!!t,[b.actionImage]:!!o};return t&&(s[t]=!0),o||t?E("span",{"aria-hidden":"true",class:this.classes(b.icon,s),key:"icon",styles:g(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?E("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},E("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map((e,t)=>{const i=this._getActionTitle(e);return w(e,{key:`action-${t}`,title:i,text:i,textEnabled:!this._hideActionText,onclick:this._triggerAction,bind:this},this._getFallbackIcon(e))})}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?E("div",{class:F.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=(await(import("../geometry/operators/labelPointOperator.js"))).execute(i);this.open({features:[t],location:null!=o?o:void 0}),this._focusFlowItemNode()}_handlePaginationMenuButton(){this._updateFeatureMenu()}_openFeatureMenu(){this._updateFeatureMenu(!0)}_closeFeatureMenu(){this._updateFeatureMenu(!1)}_updateFeatureMenu(e=!this.featureMenuOpen){this.featureMenuOpen=e,this._focusFlowItemNode()}async _focusFlowItemNode(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await r(c(e));const t=this._rootNode?.querySelector("calcite-flow-item[selected]");L(t)}_storeRootFlowItemNode(e){this._rootFlowItemNode=e}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),"feature"===this.initialDisplayMode?this._handleFeatureMenuBack():this._focusFlowItemNode()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=l(()=>this.viewModel?.selectedFeatureIndex,(e,t)=>this._selectedFeatureIndexUpdated(e,t));this.addHandles(e,B)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyDrillInFlowItemWidgets(),this._rootFlowItemNode?.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new M({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),"activeCategory"in e.viewModel&&(e.viewModel.activeCategory=null),e.viewModel=null,e.destroy()})}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e}=this;e&&(e.view?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([h()],H.prototype,"_drillInFlowItems",void 0),e([h()],H.prototype,"_hideActionText",null),e([h()],H.prototype,"_featureNavigationVisible",null),e([h()],H.prototype,"_isCollapsed",null),e([h()],H.prototype,"_collapseEnabled",null),e([h({readOnly:!0})],H.prototype,"active",null),e([h()],H.prototype,"collapsed",void 0),e([h()],H.prototype,"content",null),e([h()],H.prototype,"icon",null),e([h()],H.prototype,"featureMenuOpen",null),e([h()],H.prototype,"featureMenuTitle",null),e([h()],H.prototype,"featureNavigationTop",void 0),e([h()],H.prototype,"features",null),e([h()],H.prototype,"goToOverride",null),e([h({type:x})],H.prototype,"headerActions",void 0),e([h()],H.prototype,"headingLevel",void 0),e([h()],H.prototype,"initialDisplayMode",null),e([h()],H.prototype,"location",null),e([h()],H.prototype,"label",null),e([h()],H.prototype,"map",null),e([h(),W("esri/widgets/Features/t9n/Features")],H.prototype,"messages",void 0),e([h(),W("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([h()],H.prototype,"promises",null),e([h()],H.prototype,"responsiveActionsEnabled",void 0),e([h({readOnly:!0})],H.prototype,"selectedFeature",null),e([h({readOnly:!0})],H.prototype,"selectedDrillInFeature",null),e([h()],H.prototype,"selectedFeatureIndex",null),e([h({readOnly:!0})],H.prototype,"selectedFeatureWidget",null),e([h()],H.prototype,"spatialReference",null),e([h()],H.prototype,"title",null),e([h()],H.prototype,"timeZone",null),e([h()],H.prototype,"updateLocationEnabled",null),e([h()],H.prototype,"view",null),e([h({type:C}),D(["triggerAction","trigger-action"])],H.prototype,"viewModel",void 0),e([h({type:A,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([h()],H.prototype,"visible",null),H=e([p("esri.widgets.Features")],H);export{H as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{addEventListener as n}from"../../core/events.js";import{JSONMap as d}from"../../core/jsonMap.js";import h from"../../core/Logger.js";import{rad2deg as l,deg2rad as m}from"../../core/mathUtils.js";import{destroyMaybe as c}from"../../core/maybe.js";import{waitTick as p}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as g,when as v,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import V from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as H}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import{fixedImageSize as z}from"../OrientedImageryViewer/constants.js";import{createPanoramicMedia as b,extractHorizonAnglesFromMedia as P,logAndThrow as F,getMissingPropertyErrorName as S,getMissingPropertyErrorMessage as C}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as j,maxPanoramicViewerHFOV as O,minPanoramicViewerHFOV as x,humanBinocularHFOV as I}from"./constants.js";import A from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as G,meshToGraphic as L,createImageSphere as T}from"./utils.js";import{enumeration as D}from"../../core/accessorSupport/decorators/enumeration.js";const E={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action",videoHandles:"video-handles"};let W=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.media=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new w,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(E.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],E.navigation)},this._addHFOVHandles=()=>{this.removeHandles(E.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new A({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),E.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new A({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createMedia=(e,t)=>{this.media=b({type:"video",url:e,matrix:t.attributes.matrix,cameraHeading:t.attributes.cameraHeading})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=this.horizonAngles,i=H(e.mapPoint,this.imageSize[0],this.imageSize[1],t);this.emit("pixel-location",{...i,spatialReference:V.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._updateMedia=(e,t,i)=>{i.url=e,i.matrix=t.attributes.matrix,i.cameraHeading=t.attributes.cameraHeading},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearOverlayGraphics=()=>{const e=Array.from(this.oiViewModel.overlayedMapFeatures.values()).flatMap(e=>e.toArray()),t=[...this.oiViewModel.overlayedCameraLocations.toArray(),...e];t.length&&this.removeManyGraphics(t)},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:j},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:V.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},g),u(()=>this.fov,()=>{this._reloadCamera()},g),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),v(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),u(()=>this.clickAction,e=>{this.removeHandles(E.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),u(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};this.removeHandles(E.videoHandles);const i=n(e,"timeupdate",t),o=n(e,"play",()=>this._updateVideoIcon(e.paused)),a=n(e,"pause",()=>this._pauseVideoHandler(e));this.addHandles([i,o,a],E.videoHandles)}},g),u(()=>[this.videoSource,this.oiViewModel?.currentBestFeature,this.closestFeature],()=>{if(!this.videoSource||!this.oiViewModel.currentBestFeature)return;const e=this.closestFeature??this.oiViewModel.currentBestFeature;this.media?this._updateMedia(this.videoSource,e,this.media):this._createMedia(this.videoSource,e)},g)],E.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get horizonAngles(){return P(this.media)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?G(O,e/t):O}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?G(x,e/t):x}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){h.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=c(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const[i,o,a]=this.horizonAngles??[0,0,0];return this._imageGraphic=L(T({data:e,horizonPitch:i,horizonRoll:o,horizonYaw:a})),this._graphics.add(this._imageGraphic),this.state="image-loaded",y(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=G(I,e/t)}),this.imageSize=z,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t)}_updateVideoIcon(e){this.videoPaused=e,e||(this.clearOverlayGraphics(),this.oiViewModel.mapImageConversionToolState&&this.oiViewModel.setMapImageConversionToolState(!1))}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):F(this.declaredClass,new r(S("panoramic-viewer"),C("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}};e([_()],W.prototype,"_graphics",void 0),e([_()],W.prototype,"_imageGraphic",void 0),e([_()],W.prototype,"_imageRenderer",void 0),e([_()],W.prototype,"_loadController",void 0),e([_()],W.prototype,"_map",void 0),e([_()],W.prototype,"_zoomViewModel",void 0),e([_({type:Boolean})],W.prototype,"autoLoad",void 0),e([_({type:t})],W.prototype,"camera",null),e([D(new d({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],W.prototype,"clickAction",void 0),e([_()],W.prototype,"closestFeature",void 0),e([_()],W.prototype,"currentTime",void 0),e([_({type:Number})],W.prototype,"fov",null),e([_()],W.prototype,"horizonAngles",null),e([_({readOnly:!0})],W.prototype,"hfov",null),e([_({readOnly:!0})],W.prototype,"imageRenderer",null),e([_()],W.prototype,"imageSize",void 0),e([_()],W.prototype,"media",void 0),e([_()],W.prototype,"oiViewModel",void 0),e([_()],W.prototype,"videoSource",void 0),e([_()],W.prototype,"videoDuration",void 0),e([_()],W.prototype,"videoLoaded",void 0),e([_()],W.prototype,"videoPaused",void 0),e([_()],W.prototype,"videoMuted",void 0),e([_({readOnly:!0})],W.prototype,"maxHFOV",null),e([_({readOnly:!0})],W.prototype,"minHFOV",null),e([_({type:Number})],W.prototype,"pitch",void 0),e([_()],W.prototype,"state",void 0),e([_()],W.prototype,"updatingHandles",void 0),e([_()],W.prototype,"updating",null),e([_({readOnly:!0})],W.prototype,"vfov",null),e([_()],W.prototype,"video",void 0),e([_({type:Number})],W.prototype,"yaw",void 0),W=e([f("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],W);const N=W;export{N as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{addEventListener as n}from"../../core/events.js";import{JSONMap as d}from"../../core/jsonMap.js";import h from"../../core/Logger.js";import{rad2deg as l,deg2rad as m}from"../../core/mathUtils.js";import{destroyMaybe as c}from"../../core/maybe.js";import{waitTick as p}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as g,when as v,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import V from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as H}from"../../layers/orientedImagery/transformations/utils.js";import z from"../../views/SceneView.js";import{fixedImageSize as R}from"../OrientedImageryViewer/constants.js";import{createPanoramicMedia as b,extractHorizonAnglesFromMedia as P,logAndThrow as F,getMissingPropertyErrorName as S,getMissingPropertyErrorMessage as C}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as j,maxPanoramicViewerHFOV as O,minPanoramicViewerHFOV as x,humanBinocularHFOV as I}from"./constants.js";import A from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as G,meshToGraphic as L,createImageSphere as T}from"./utils.js";import{enumeration as D}from"../../core/accessorSupport/decorators/enumeration.js";const E={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action",videoHandles:"video-handles"};let W=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.media=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new w,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.freeze=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(E.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],E.navigation)},this._addHFOVHandles=()=>{this.removeHandles(E.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new A({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),E.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new A({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createMedia=(e,t)=>{this.media=b({type:"video",url:e,matrix:t.attributes.matrix,cameraHeading:t.attributes.cameraHeading})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=this.horizonAngles,i=H(e.mapPoint,this.imageSize[0],this.imageSize[1],t);this.emit("pixel-location",{...i,spatialReference:V.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._updateMedia=(e,t,i)=>{i.url=e,i.matrix=t.attributes.matrix,i.cameraHeading=t.attributes.cameraHeading},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearOverlayGraphics=()=>{const e=Array.from(this.oiViewModel.overlayedMapFeatures.values()).flatMap(e=>e.toArray()),t=[...this.oiViewModel.overlayedCameraLocations.toArray(),...e];t.length&&this.removeManyGraphics(t)},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new z({map:this._map,viewingMode:"local",camera:{position:j},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:V.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},g),u(()=>this.fov,()=>{this._reloadCamera()},g),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),v(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),u(()=>this.clickAction,e=>{this.removeHandles(E.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),u(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};this.removeHandles(E.videoHandles);const i=n(e,"timeupdate",t),o=n(e,"play",()=>this._updateVideoIcon(e.paused)),a=n(e,"pause",()=>this._pauseVideoHandler(e));this.addHandles([i,o,a],E.videoHandles)}},g),u(()=>[this.videoSource,this.oiViewModel?.currentBestFeature,this.closestFeature],()=>{if(!this.videoSource||!this.oiViewModel.currentBestFeature)return;const e=this.closestFeature??this.oiViewModel.currentBestFeature;this.media?this._updateMedia(this.videoSource,e,this.media):this._createMedia(this.videoSource,e)},g)],E.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get horizonAngles(){return P(this.media)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?G(O,e/t):O}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?G(x,e/t):x}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){h.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=c(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const[i,o,a]=this.horizonAngles??[0,0,0];return this._imageGraphic=L(T({data:e,horizonPitch:i,horizonRoll:o,horizonYaw:a})),this._graphics.add(this._imageGraphic),this.state="image-loaded",y(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=G(I,e/t)}),this.imageSize=R,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t)}_updateVideoIcon(e){this.videoPaused=e,e||(this.clearOverlayGraphics(),this.oiViewModel.mapImageConversionToolState&&this.oiViewModel.setMapImageConversionToolState(!1))}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):F(this.declaredClass,new r(S("panoramic-viewer"),C("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}};e([_()],W.prototype,"_graphics",void 0),e([_()],W.prototype,"_imageGraphic",void 0),e([_()],W.prototype,"_imageRenderer",void 0),e([_()],W.prototype,"_loadController",void 0),e([_()],W.prototype,"_map",void 0),e([_()],W.prototype,"_zoomViewModel",void 0),e([_({type:Boolean})],W.prototype,"autoLoad",void 0),e([_({type:t})],W.prototype,"camera",null),e([D(new d({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],W.prototype,"clickAction",void 0),e([_()],W.prototype,"closestFeature",void 0),e([_()],W.prototype,"currentTime",void 0),e([_({type:Number})],W.prototype,"fov",null),e([_()],W.prototype,"horizonAngles",null),e([_({readOnly:!0})],W.prototype,"hfov",null),e([_({readOnly:!0})],W.prototype,"imageRenderer",null),e([_()],W.prototype,"imageSize",void 0),e([_()],W.prototype,"media",void 0),e([_()],W.prototype,"oiViewModel",void 0),e([_()],W.prototype,"videoSource",void 0),e([_()],W.prototype,"videoDuration",void 0),e([_()],W.prototype,"videoLoaded",void 0),e([_()],W.prototype,"videoPaused",void 0),e([_()],W.prototype,"videoMuted",void 0),e([_({readOnly:!0})],W.prototype,"maxHFOV",null),e([_({readOnly:!0})],W.prototype,"minHFOV",null),e([_({type:Number})],W.prototype,"pitch",void 0),e([_()],W.prototype,"state",void 0),e([_()],W.prototype,"updatingHandles",void 0),e([_()],W.prototype,"updating",null),e([_({readOnly:!0})],W.prototype,"vfov",null),e([_()],W.prototype,"video",void 0),e([_({type:Number})],W.prototype,"yaw",void 0),W=e([f("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],W);const N=W;export{N as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import C from"../../views/SceneView.js";import{extractHorizonAnglesFromMedia as z}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as V,defaultImageSphereSize as H,maxPanoramicViewerHFOV as k,minPanoramicViewerHFOV as G,humanBinocularHFOV as O}from"./constants.js";import b from"./PanoramicZoomConditions.js";import j from"./PanoramicZoomViewModel.js";import{meshToGraphic as x,findDiagonalFOV as A}from"./utils.js";import I from"./support/PanoramicMedia.js";import{enumeration as S}from"../../core/accessorSupport/decorators/enumeration.js";const F={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:V},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new j({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=H/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(F.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,F.navigation)},this._addHFOVHandles=()=>{this.removeHandles(F.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),F.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new j({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(x);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint||!this.media)return void this.emit("pixel-location",null);const i=z(this.media),t=P(e.mapPoint,this.imageSize[0],this.imageSize[1],i);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,this._loadController).catch(()=>{}))},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this.media=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(F.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],F.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(k,e/i):k}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(G,e/i):G}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(x);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=x(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",y(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=A(O,e/i)},()=>{}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],L.prototype,"_graphics",void 0),e([_()],L.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],L.prototype,"currentGraphics",void 0),e([_()],L.prototype,"imagePyramid",void 0),e([_()],L.prototype,"imagePyramidLevel",void 0),e([_()],L.prototype,"_map",void 0),e([_()],L.prototype,"_imageRenderer",void 0),e([_()],L.prototype,"_loadController",void 0),e([_()],L.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],L.prototype,"autoLoad",void 0),e([_({type:i})],L.prototype,"camera",null),e([S(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([_()],L.prototype,"distanceFactor",null),e([_({type:Number})],L.prototype,"fov",null),e([_({readOnly:!0})],L.prototype,"hfov",null),e([_({type:I})],L.prototype,"media",void 0),e([_()],L.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],L.prototype,"imageRenderer",null),e([_()],L.prototype,"imageSize",void 0),e([_({readOnly:!0})],L.prototype,"maxHFOV",null),e([_({readOnly:!0})],L.prototype,"minHFOV",null),e([_({type:Number})],L.prototype,"pitch",void 0),e([_()],L.prototype,"state",void 0),e([_()],L.prototype,"updatingHandles",void 0),e([_()],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"vfov",null),e([_({type:Number})],L.prototype,"yaw",void 0),L=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const T=L;export{T as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as y,whenOnce as u}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import z from"../../views/SceneView.js";import{extractHorizonAnglesFromMedia as C}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as V,defaultImageSphereSize as H,maxPanoramicViewerHFOV as k,minPanoramicViewerHFOV as G,humanBinocularHFOV as O}from"./constants.js";import b from"./PanoramicZoomConditions.js";import j from"./PanoramicZoomViewModel.js";import{meshToGraphic as x,findDiagonalFOV as A}from"./utils.js";import I from"./support/PanoramicMedia.js";import{enumeration as S}from"../../core/accessorSupport/decorators/enumeration.js";const F={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new z({map:this._map,viewingMode:"local",camera:{position:V},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new j({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=H/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.freeze=!0,this.removeHandles(F.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,F.navigation)},this._addHFOVHandles=()=>{this.removeHandles(F.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),F.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new j({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(x);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint||!this.media)return void this.emit("pixel-location",null);const i=C(this.media),t=P(e.mapPoint,this.imageSize[0],this.imageSize[1],i);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,this._loadController).catch(()=>{}))},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this.media=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([y(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),y(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(F.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],F.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(k,e/i):k}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(G,e/i):G}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(x);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=x(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",u(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=A(O,e/i)},()=>{}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],L.prototype,"_graphics",void 0),e([_()],L.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],L.prototype,"currentGraphics",void 0),e([_()],L.prototype,"imagePyramid",void 0),e([_()],L.prototype,"imagePyramidLevel",void 0),e([_()],L.prototype,"_map",void 0),e([_()],L.prototype,"_imageRenderer",void 0),e([_()],L.prototype,"_loadController",void 0),e([_()],L.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],L.prototype,"autoLoad",void 0),e([_({type:i})],L.prototype,"camera",null),e([S(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([_()],L.prototype,"distanceFactor",null),e([_({type:Number})],L.prototype,"fov",null),e([_({readOnly:!0})],L.prototype,"hfov",null),e([_({type:I})],L.prototype,"media",void 0),e([_()],L.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],L.prototype,"imageRenderer",null),e([_()],L.prototype,"imageSize",void 0),e([_({readOnly:!0})],L.prototype,"maxHFOV",null),e([_({readOnly:!0})],L.prototype,"minHFOV",null),e([_({type:Number})],L.prototype,"pitch",void 0),e([_()],L.prototype,"state",void 0),e([_()],L.prototype,"updatingHandles",void 0),e([_()],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"vfov",null),e([_({type:Number})],L.prototype,"yaw",void 0),L=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const T=L;export{T as default};
|
|
@@ -9,6 +9,7 @@ export interface PopupViewModelProperties extends FeaturesViewModelProperties {}
|
|
|
9
9
|
* by providing users with a simple way to interact with and view attributes in a layer.
|
|
10
10
|
* They play an important role in relaying information to the user, which improves the storytelling capabilities of the application.
|
|
11
11
|
*
|
|
12
|
+
* @deprecated since 5.2. Use the [Popup component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-popup/) or the [FeatureContentCollection](https://developers.arcgis.com/javascript/latest/references/core/popup/FeatureContentCollection/) class instead.
|
|
12
13
|
* @since 4.0
|
|
13
14
|
* @see [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) widget - _Deprecated since 5.0. Use the [Popup component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-popup/) instead._
|
|
14
15
|
* @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import{deprecatedModule as o}from"../../core/deprecate.js";import r from"../../core/Logger.js";import{subclass as t}from"../../core/accessorSupport/decorators.js";import p from"../Features/FeaturesViewModel.js";let s=class extends p{constructor(e){super({...e,suppressDeprecationWarning:!0}),e?.suppressDeprecationWarning||o(r.getLogger(this),"esri.widgets.Popup.PopupViewModel",{version:"5.2",replacement:"Use the Popup component or the @arcgis/core/popup/FeatureContentCollection module instead.",warnOnce:!0})}};s=e([t("esri.widgets.Popup.PopupViewModel")],s);export{s as default};
|
package/widgets/Popup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{watch as i,initial as o,on as s}from"../core/reactiveUtils.js";import{stripHTML as n}from"../core/string.js";import{property as r,subclass as l}from"../core/accessorSupport/decorators.js";import a from"../geometry/Point.js";import d from"../support/actions/ActionButton.js";import c from"./Features.js";import u from"./Widget.js";import h from"./Features/FeaturesViewModel.js";import{ActionsCollection as p}from"./Popup/actions.js";import{css as g}from"./Popup/css.js";import v from"./Popup/PopupViewModel.js";import m from"./Popup/PopupVisibleElements.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{tsx as _,messageBundle as b,vmEvent as M}from"./support/widget.js";import{isRTL as k}from"./support/widgetUtils.js";const y={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let E=class extends u{constructor(e,t){super(e,t),this._dockAction=new d({id:"popup-dock-action"}),this._featuresWidget=new c({responsiveActionsEnabled:!0,suppressDeprecationWarning:!0}),this._containerNode=null,this._mainContainerNode=null,this._focusTrapNode=null,this._toggleFocusTrapFrameId=null,this._pointerOffsetInPx=16,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.shouldFocus=!1,this.viewModel=new v,this.visibleElements=new m}loadDependencies(){return f({"focus-trap":()=>import("@esri/calcite-components/dist/components/calcite-focus-trap")})}initialize(){this.addHandles([i(()=>[this.viewModel?.active,this.shouldFocus,this._focusTrapNode],()=>this._toggleFocusTrap()),i(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),o),i(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),o),i(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},o),i(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),i(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),i(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),i(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),i(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),i(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),i(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,o),i(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,o),i(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,o),i(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,o),i(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,o),i(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,o),i(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,o),i(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,o),i(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,o),i(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,o),i(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,o),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._cancelToggleFocusTrapFrame(),this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new h,this._featuresWidget.destroy())}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||y}set dockOptions(e){const t={...y},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const s={...t,...e},n={...t.breakpoint,...o},{breakpoint:r}=s;"object"==typeof r?s.breakpoint={...n,...r}:r&&(s.breakpoint=n),this._set("dockOptions",s),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=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}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._focusTrapNode?.setFocus()}next(){return this.viewModel.next()}open(e){const t=e?.featureMenuOpen??!1,i=e?.collapsed??!1,o=e?.shouldFocus??!1,s={collapsed:i,featureMenuOpen:t,shouldFocus:o};this.set(s),this.viewModel.open(e),o&&this._toggleFocusTrap()}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:s}=this.viewModel,r=o&&e,l=o&&!e,a=this.selectedFeature?.layer?.title,d=this.selectedFeature?.layer?.id,c={[g.alignTopCenter]:"top-center"===t,[g.alignBottomCenter]:"bottom-center"===t,[g.alignTopLeft]:"top-left"===t,[g.alignBottomLeft]:"bottom-left"===t,[g.alignTopRight]:"top-right"===t,[g.alignBottomRight]:"bottom-right"===t,[g.isDocked]:r,[g.shadow]:l,[g.isDockedTopLeft]:"top-left"===i,[g.isDockedTopCenter]:"top-center"===i,[g.isDockedTopRight]:"top-right"===i,[g.isDockedBottomLeft]:"bottom-left"===i,[g.isDockedBottomCenter]:"bottom-center"===i,[g.isDockedBottomRight]:"bottom-right"===i};return _("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":n(this.title??""),"aria-modal":"false",bind:this,class:this.classes(g.base,c,{[g.baseHidden]:!s&&!e}),"data-layer-id":d,"data-layer-title":a,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:_("div",{class:g.pointer,key:"popup-pointer",role:"presentation"},_("div",{class:this.classes(g.pointerDirection,g.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[g.shadow]:e};return _("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(g.main,w.widget,t)},_("calcite-focus-trap",{afterCreate:this._setFocusTrapNode,afterUpdate:this._setFocusTrapNode,bind:this},this._featuresWidget.render()))}_toggleFocusTrap(){this._cancelToggleFocusTrapFrame(),this._toggleFocusTrapFrameId=requestAnimationFrame(()=>{if(this._toggleFocusTrapFrameId=null,this.active&&this.shouldFocus){const e=this._focusTrapNode;if(!e)return;e.activate(),e.setFocus?.()}else this._focusTrapNode?.deactivate(),this.active||(this._focusTrapNode=null)})}_cancelToggleFocusTrapFrame(){null!==this._toggleFocusTrapFrameId&&(cancelAnimationFrame(this._toggleFocusTrapFrameId),this._toggleFocusTrapFrameId=null)}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:s,view:n}=e;if(isNaN(i)||isNaN(t)||!n||!o)return!1;const r=n.padding;return"right"===s&&o.x+i/2>n.width-r.right||("left"===s&&o.x-i/2<r.left||("top"===s&&o.y-t<r.top||"bottom"===s&&o.y+t>n.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:s}=this,{screenLocation:n,view:r}=s;if(null==n||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:u,width:h}=i.getBoundingClientRect(),p=h+t,g=Math.max(u,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return k(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=k(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},s=t.width-o.left-o.right,{breakpoints:n}=t;return n&&s<=n.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_setFocusTrapNode(e){this._focusTrapNode!==e&&(this._focusTrapNode=e,this.active&&this.shouldFocus&&this._toggleFocusTrap())}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:s,_pointerOffsetInPx:n}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===s?{top:t+n-r.top,left:e-l-r.left}:"top-left"===s?{bottom:a+n-r.bottom,right:d+n-r.right}:"bottom-left"===s?{top:t+n-r.top,right:d+n-r.right}:"top-right"===s?{bottom:a+n-r.bottom,left:e+n-r.left}:"bottom-right"===s?{top:t+n-r.top,left:e+n-r.left}:"top-center"===s?{bottom:a+n-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const s=this._calculateFullWidth(t),n=this._calculateAlignmentPosition(e.x,e.y,o,s);return n?{top:void 0!==n.top?`${n.top}px`:"auto",left:void 0!==n.left?`${n.left}px`:"auto",bottom:void 0!==n.bottom?`${n.bottom}px`:"auto",right:void 0!==n.right?`${n.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,s]=e,[n,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&n>l||o>l&&n<=l||s<=a&&r>a||s>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,s=i.top+i.bottom,n=[],r=[];n[0]=e[0]-o,n[1]=e[1]-s,r[0]=t[0]-o,r[1]=t[1]-s;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(n,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:s}=i;if(isNaN(o)||isNaN(s))return!1;if(!t)return!1;const n=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&s<=(t.height??0);return n||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([r()],E.prototype,"_containerNode",void 0),e([r()],E.prototype,"_focusTrapNode",void 0),e([r({readOnly:!0})],E.prototype,"_featureNavigationTop",null),e([r({type:p})],E.prototype,"actions",null),e([r({readOnly:!0})],E.prototype,"active",null),e([r()],E.prototype,"alignment",void 0),e([r()],E.prototype,"autoCloseEnabled",null),e([r()],E.prototype,"defaultPopupTemplateEnabled",null),e([r()],E.prototype,"content",null),e([r()],E.prototype,"collapsed",null),e([r({readOnly:!0})],E.prototype,"currentAlignment",null),e([r({readOnly:!0})],E.prototype,"currentDockPosition",null),e([r()],E.prototype,"dockOptions",null),e([r()],E.prototype,"dockEnabled",void 0),e([r({readOnly:!0})],E.prototype,"featureCount",null),e([r()],E.prototype,"featureMenuOpen",null),e([r()],E.prototype,"features",null),e([r()],E.prototype,"goToOverride",null),e([r()],E.prototype,"headingLevel",void 0),e([r()],E.prototype,"highlightEnabled",null),e([r()],E.prototype,"icon",null),e([r()],E.prototype,"initialDisplayMode",null),e([r({type:a})],E.prototype,"location",null),e([r()],E.prototype,"label",null),e([r(),b("esri/widgets/Popup/t9n/Popup")],E.prototype,"messages",void 0),e([r()],E.prototype,"promises",null),e([r({readOnly:!0})],E.prototype,"selectedFeature",null),e([r({readOnly:!0})],E.prototype,"selectedDrillInFeature",null),e([r()],E.prototype,"selectedFeatureIndex",null),e([r({readOnly:!0})],E.prototype,"selectedFeatureWidget",null),e([r()],E.prototype,"shouldFocus",void 0),e([r()],E.prototype,"title",null),e([r()],E.prototype,"updateLocationEnabled",null),e([r()],E.prototype,"view",null),e([r({type:v}),M(["triggerAction","trigger-action"])],E.prototype,"viewModel",void 0),e([r()],E.prototype,"visible",null),e([r({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),E=e([l("esri.widgets.Popup")],E);const F=E;export{F as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{watch as i,initial as o,on as s}from"../core/reactiveUtils.js";import{stripHTML as n}from"../core/string.js";import{property as r,subclass as l}from"../core/accessorSupport/decorators.js";import a from"../geometry/Point.js";import d from"../support/actions/ActionButton.js";import c from"./Features.js";import u from"./Widget.js";import h from"./Features/FeaturesViewModel.js";import{ActionsCollection as p}from"./Popup/actions.js";import{css as g}from"./Popup/css.js";import v from"./Popup/PopupViewModel.js";import m from"./Popup/PopupVisibleElements.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{tsx as _,messageBundle as b,vmEvent as M}from"./support/widget.js";import{isRTL as k}from"./support/widgetUtils.js";const y={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let E=class extends u{constructor(e,t){super(e,t),this._dockAction=new d({id:"popup-dock-action"}),this._featuresWidget=new c({responsiveActionsEnabled:!0,suppressDeprecationWarning:!0}),this._containerNode=null,this._mainContainerNode=null,this._focusTrapNode=null,this._toggleFocusTrapFrameId=null,this._pointerOffsetInPx=16,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.shouldFocus=!1,this.viewModel=new v({suppressDeprecationWarning:!0}),this.visibleElements=new m}loadDependencies(){return f({"focus-trap":()=>import("@esri/calcite-components/dist/components/calcite-focus-trap")})}initialize(){this.addHandles([i(()=>[this.viewModel?.active,this.shouldFocus,this._focusTrapNode],()=>this._toggleFocusTrap()),i(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),o),i(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),o),i(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},o),i(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),i(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),i(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),i(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),i(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),i(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),i(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,o),i(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,o),i(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,o),i(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,o),i(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,o),i(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,o),i(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,o),i(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,o),i(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,o),i(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,o),i(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,o),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._cancelToggleFocusTrapFrame(),this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new h({suppressDeprecationWarning:!0}),this._featuresWidget.destroy())}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||y}set dockOptions(e){const t={...y},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const s={...t,...e},n={...t.breakpoint,...o},{breakpoint:r}=s;"object"==typeof r?s.breakpoint={...n,...r}:r&&(s.breakpoint=n),this._set("dockOptions",s),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=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}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._focusTrapNode?.setFocus()}next(){return this.viewModel.next()}open(e){const t=e?.featureMenuOpen??!1,i=e?.collapsed??!1,o=e?.shouldFocus??!1,s={collapsed:i,featureMenuOpen:t,shouldFocus:o};this.set(s),this.viewModel.open(e),o&&this._toggleFocusTrap()}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:s}=this.viewModel,r=o&&e,l=o&&!e,a=this.selectedFeature?.layer?.title,d=this.selectedFeature?.layer?.id,c={[g.alignTopCenter]:"top-center"===t,[g.alignBottomCenter]:"bottom-center"===t,[g.alignTopLeft]:"top-left"===t,[g.alignBottomLeft]:"bottom-left"===t,[g.alignTopRight]:"top-right"===t,[g.alignBottomRight]:"bottom-right"===t,[g.isDocked]:r,[g.shadow]:l,[g.isDockedTopLeft]:"top-left"===i,[g.isDockedTopCenter]:"top-center"===i,[g.isDockedTopRight]:"top-right"===i,[g.isDockedBottomLeft]:"bottom-left"===i,[g.isDockedBottomCenter]:"bottom-center"===i,[g.isDockedBottomRight]:"bottom-right"===i};return _("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":n(this.title??""),"aria-modal":"false",bind:this,class:this.classes(g.base,c,{[g.baseHidden]:!s&&!e}),"data-layer-id":d,"data-layer-title":a,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:_("div",{class:g.pointer,key:"popup-pointer",role:"presentation"},_("div",{class:this.classes(g.pointerDirection,g.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[g.shadow]:e};return _("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(g.main,w.widget,t)},_("calcite-focus-trap",{afterCreate:this._setFocusTrapNode,afterUpdate:this._setFocusTrapNode,bind:this},this._featuresWidget.render()))}_toggleFocusTrap(){this._cancelToggleFocusTrapFrame(),this._toggleFocusTrapFrameId=requestAnimationFrame(()=>{if(this._toggleFocusTrapFrameId=null,this.active&&this.shouldFocus){const e=this._focusTrapNode;if(!e)return;e.activate(),e.setFocus?.()}else this._focusTrapNode?.deactivate(),this.active||(this._focusTrapNode=null)})}_cancelToggleFocusTrapFrame(){null!==this._toggleFocusTrapFrameId&&(cancelAnimationFrame(this._toggleFocusTrapFrameId),this._toggleFocusTrapFrameId=null)}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:s,view:n}=e;if(isNaN(i)||isNaN(t)||!n||!o)return!1;const r=n.padding;return"right"===s&&o.x+i/2>n.width-r.right||("left"===s&&o.x-i/2<r.left||("top"===s&&o.y-t<r.top||"bottom"===s&&o.y+t>n.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:s}=this,{screenLocation:n,view:r}=s;if(null==n||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:u,width:h}=i.getBoundingClientRect(),p=h+t,g=Math.max(u,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return k(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=k(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},s=t.width-o.left-o.right,{breakpoints:n}=t;return n&&s<=n.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_setFocusTrapNode(e){this._focusTrapNode!==e&&(this._focusTrapNode=e,this.active&&this.shouldFocus&&this._toggleFocusTrap())}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:s,_pointerOffsetInPx:n}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===s?{top:t+n-r.top,left:e-l-r.left}:"top-left"===s?{bottom:a+n-r.bottom,right:d+n-r.right}:"bottom-left"===s?{top:t+n-r.top,right:d+n-r.right}:"top-right"===s?{bottom:a+n-r.bottom,left:e+n-r.left}:"bottom-right"===s?{top:t+n-r.top,left:e+n-r.left}:"top-center"===s?{bottom:a+n-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const s=this._calculateFullWidth(t),n=this._calculateAlignmentPosition(e.x,e.y,o,s);return n?{top:void 0!==n.top?`${n.top}px`:"auto",left:void 0!==n.left?`${n.left}px`:"auto",bottom:void 0!==n.bottom?`${n.bottom}px`:"auto",right:void 0!==n.right?`${n.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,s]=e,[n,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&n>l||o>l&&n<=l||s<=a&&r>a||s>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,s=i.top+i.bottom,n=[],r=[];n[0]=e[0]-o,n[1]=e[1]-s,r[0]=t[0]-o,r[1]=t[1]-s;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(n,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:s}=i;if(isNaN(o)||isNaN(s))return!1;if(!t)return!1;const n=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&s<=(t.height??0);return n||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([r()],E.prototype,"_containerNode",void 0),e([r()],E.prototype,"_focusTrapNode",void 0),e([r({readOnly:!0})],E.prototype,"_featureNavigationTop",null),e([r({type:p})],E.prototype,"actions",null),e([r({readOnly:!0})],E.prototype,"active",null),e([r()],E.prototype,"alignment",void 0),e([r()],E.prototype,"autoCloseEnabled",null),e([r()],E.prototype,"defaultPopupTemplateEnabled",null),e([r()],E.prototype,"content",null),e([r()],E.prototype,"collapsed",null),e([r({readOnly:!0})],E.prototype,"currentAlignment",null),e([r({readOnly:!0})],E.prototype,"currentDockPosition",null),e([r()],E.prototype,"dockOptions",null),e([r()],E.prototype,"dockEnabled",void 0),e([r({readOnly:!0})],E.prototype,"featureCount",null),e([r()],E.prototype,"featureMenuOpen",null),e([r()],E.prototype,"features",null),e([r()],E.prototype,"goToOverride",null),e([r()],E.prototype,"headingLevel",void 0),e([r()],E.prototype,"highlightEnabled",null),e([r()],E.prototype,"icon",null),e([r()],E.prototype,"initialDisplayMode",null),e([r({type:a})],E.prototype,"location",null),e([r()],E.prototype,"label",null),e([r(),b("esri/widgets/Popup/t9n/Popup")],E.prototype,"messages",void 0),e([r()],E.prototype,"promises",null),e([r({readOnly:!0})],E.prototype,"selectedFeature",null),e([r({readOnly:!0})],E.prototype,"selectedDrillInFeature",null),e([r()],E.prototype,"selectedFeatureIndex",null),e([r({readOnly:!0})],E.prototype,"selectedFeatureWidget",null),e([r()],E.prototype,"shouldFocus",void 0),e([r()],E.prototype,"title",null),e([r()],E.prototype,"updateLocationEnabled",null),e([r()],E.prototype,"view",null),e([r({type:v}),M(["triggerAction","trigger-action"])],E.prototype,"viewModel",void 0),e([r()],E.prototype,"visible",null),e([r({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),E=e([l("esri.widgets.Popup")],E);const F=E;export{F as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../../intl.js";import i from"../../core/Collection.js";import{watch as o}from"../../core/reactiveUtils.js";import{throttle as s}from"../../core/throttle.js";import{property as n,subclass as r}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as l}from"../../graphic/graphicOriginUtils.js";import{fetchMessageBundle as a}from"../../intl/messages.js";import{isFeatureLayer as d,isSubtypeSublayer as c}from"../../layers/support/layerUtils.js";import{UtilityNetworkAssociationsContent as p}from"../../popup/content.js";import{substituteActionImage as u,getActionStyles as h}from"../../support/actions/actionUtils.js";import m from"../Feature.js";import g from"../Spinner.js";import w from"../Widget.js";import{css as v}from"../Feature/resources.js";import{FeatureContentMixin as _}from"../Feature/support/FeatureContentMixin.js";import{css as f}from"../Features/css.js";import y from"../Features/FeaturesViewModel.js";import{ActionsCollection as M}from"../Popup/actions.js";import{zoomToLocation as F}from"../Popup/actionUtils.js";import{loadCalciteComponents as A}from"../support/componentsUtils.js";import{globalCss as I}from"../support/globalCss.js";import{Heading as b}from"../support/Heading.js";import{tsx as k,messageBundle as T,vmEvent as C}from"../support/widget.js";import W from"./UtilityNetworkTraceFeaturesDrillIn.js";const N="selected-index",x=0,j="features-spinner",S="esri-utility-network-trace",U={blockContainer:`${S}__block-container`,blockContent:`${S}__block-content`,featureContent:`${S}__feature-content`,paddingBottom:`${S}__pad-bottom`,paddingTop:`${S}__pad-top`};let O=class extends(_(w)){constructor(e,t){super(e,t),this._actionBarMenuNode=null,this._drillInFlowItems=new i,this._drillInWidget=new W({flowItems:this._drillInFlowItems}),this._feature=null,this._featureMenuViewportNode=null,this._spinner=null,this._utilityNetworkTraceMessages=null,this.featureNavigationTop=!1,this.headerActions=new M,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new y,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:n,disabled:r,indicator:l}=e;return e.visible?k("calcite-action",{active:"toggle"===o&&e.value,bind:this,"data-action-uid":n,disabled:"zoom-to-feature"===e.id?!this.feature.geometry:r,icon:this._getActionIcon(e),indicator:l,key:`action-${t}`,loading:s,scale:"s",text:i,title:this._hideActionText?i:void 0,onclick:this._triggerAction},this._renderFallbackIcon(e)):null},this._renderAddNsoBlock=()=>{const{_utilityNetworkTraceMessages:e,messagesCommon:t}=this;return k("calcite-block",{class:U.blockContent,expanded:!this.feature,heading:e?.inputsStrings.addNonspatialOption},k("calcite-action",{icon:"x",slot:"actions-end",text:t.close,onclick:()=>this.emit("close-un-trace-feature-block")}),k("calcite-notice",{icon:"information",kind:"info",open:!this.feature},k("div",{slot:"message"},e?.inputsStrings.addNonspatialHint)))},this._renderNoPopupErrorBlock=()=>{const{_utilityNetworkTraceMessages:e,messagesCommon:t}=this;return k("calcite-block",{description:void 0,expanded:!0,heading:"show-feature-info"===this.mode?t.warning:void 0},k("calcite-notice",{class:this.classes(U.paddingBottom,U.paddingTop),icon:"exclamation-mark-triangle",kind:"danger",open:!0},k("div",{slot:"message"},e.alertsStrings.noPopupConfigured)),"show-feature-info"===this.mode?k("calcite-action",{icon:"x",slot:"actions-end",text:t.close,onclick:()=>this.emit("close-un-trace-feature-block")}):void 0)},this._displaySpinnerThrottled=s(()=>this._displaySpinner(),x),this.addHandles([this._displaySpinnerThrottled,o(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),o(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),o(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),o(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),o(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),o(()=>this.selectedFeatureWidget,()=>this._destroyDrillInFlowItemWidgets()),o(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),o(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),o(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),this._drillInWidget.on("close",()=>{this.emit("close")}),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>F(this.viewModel,e)),this._drillInWidget.on("add-nso-trace-location",({featureWidget:e})=>this.emit("add-nso-trace-location",{featureWidget:e}))])}initialize(){(async()=>{this._utilityNetworkTraceMessages=await a("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace")})(),this._drillInWidget.mode=this.mode,this._drillInWidget.closable=!1}loadDependencies(){return A({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._drillInWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get feature(){return this.viewModel.features.length?this.viewModel.features[0]:null}set feature(e){this.viewModel.features=e?[e]:[]}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get hasAssociationsPopupElement(){if(!this.feature)return!1;const e=l(this.feature),t=e&&d(e)?e:void 0,i=c(e)?e:void 0,o=t?.popupTemplate||i?.popupTemplate||null,s=o?.content;return!(Array.isArray(s)&&!s.some(e=>e instanceof p))}get hasPopupInfo(){const e=this.feature?l(this.feature):null,t=e&&d(e)?e:void 0,i=c(e)?e:void 0;return!(!t?.popupTemplate&&!i?.popupTemplate)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get mode(){return this._get("mode")||"add-nso"}set mode(e){this._set("mode",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o}=this,{selectedFeatureViewModel:s}=this.viewModel,n={title:!1};return s?(e?(e.viewModel=s,e.visibleElements=n):this._feature=new m({flowItems:i,headingLevel:t+1,timeZone:o,viewModel:s,visibleElements:n}),this._feature):null}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}open(e){this.removeHandles(N),this.viewModel.open({features:[e]})}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return k("div",{bind:this,class:this.classes(f.base,I.widget,I.panel,U.blockContainer)},"add-nso"===this.mode?this._renderAddNsoBlock():void 0,this.feature?this.hasPopupInfo?this._renderContentContainer():this._renderNoPopupErrorBlock():void 0)}_renderActionBar(){return this.viewModel.allActions?.length?k("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},k("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?k("div",{class:v.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._drillInWidget.render()];return k("calcite-flow",{key:"content-container"},e)}_renderContentFeature(){const{_drillInFlowItems:e,headingLevel:t,featureNavigationTop:i}=this,{title:o,active:s}=this.viewModel,n=o||"";return k("calcite-flow-item",{bind:this,class:this.classes({[f.contentFeature]:!0}),closed:!s,collapseDirection:i?"down":"up",headingLevel:t,key:"root-flow-item",loading:this.viewModel.waitingForContents,selected:0===e.length},"show-feature-info"===this.mode?k("calcite-action",{icon:"x",slot:"header-actions-end",text:this.messagesCommon.close,onclick:()=>{this.emit("close")}}):void 0,n?k(b,{class:this.classes(f.featuresHeading,I.heading),innerHTML:n,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),k("div",{class:"add-nso"===this.mode?this.classes(f.container,f.contentContainer):this.classes(f.container,f.contentContainer,U.featureContent)},this._renderContent()))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=u({action:e,feature:this.selectedFeature}),s={[f.icon]:!!t,[f.actionImage]:!!o};return t&&(s[t]=!0),o||t?k("span",{"aria-hidden":"true",class:this.classes(f.icon,s),key:"icon",styles:h(o)}):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?k("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-uid":e.uid,disabled:e.disabled||!this.feature.geometry,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_createSpinner(e){e&&(this._spinner=new g({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()})}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;null!=i&&null!=t&&(this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i}),this.open(t))}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_wireUpView(e){this._destroySpinner(),e&&this._createSpinner(e)}};e([n()],O.prototype,"_drillInFlowItems",void 0),e([n()],O.prototype,"_hideActionText",null),e([n({readOnly:!0})],O.prototype,"active",null),e([n()],O.prototype,"content",null),e([n()],O.prototype,"feature",null),e([n()],O.prototype,"featureNavigationTop",void 0),e([n()],O.prototype,"goToOverride",null),e([n()],O.prototype,"hasAssociationsPopupElement",null),e([n()],O.prototype,"hasPopupInfo",null),e([n({type:M})],O.prototype,"headerActions",void 0),e([n()],O.prototype,"headingLevel",void 0),e([n()],O.prototype,"location",null),e([n(),T("esri/widgets/Features/t9n/Features")],O.prototype,"messages",void 0),e([n(),T("esri/t9n/common")],O.prototype,"messagesCommon",void 0),e([n()],O.prototype,"mode",null),e([n()],O.prototype,"promises",null),e([n()],O.prototype,"responsiveActionsEnabled",void 0),e([n({readOnly:!0})],O.prototype,"selectedFeature",null),e([n({readOnly:!0})],O.prototype,"selectedDrillInFeature",null),e([n({readOnly:!0})],O.prototype,"selectedFeatureWidget",null),e([n()],O.prototype,"timeZone",null),e([n()],O.prototype,"view",null),e([n({type:y}),C(["triggerAction","trigger-action"])],O.prototype,"viewModel",void 0),O=e([r("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceFeature")],O);const H=O;export{H as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../../intl.js";import i from"../../core/Collection.js";import{watch as o}from"../../core/reactiveUtils.js";import{throttle as s}from"../../core/throttle.js";import{property as n,subclass as r}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as l}from"../../graphic/graphicOriginUtils.js";import{fetchMessageBundle as a}from"../../intl/messages.js";import{isFeatureLayer as d,isSubtypeSublayer as c}from"../../layers/support/layerUtils.js";import{UtilityNetworkAssociationsContent as p}from"../../popup/content.js";import{substituteActionImage as u,getActionStyles as h}from"../../support/actions/actionUtils.js";import m from"../Feature.js";import g from"../Spinner.js";import w from"../Widget.js";import{css as v}from"../Feature/resources.js";import{FeatureContentMixin as _}from"../Feature/support/FeatureContentMixin.js";import{css as f}from"../Features/css.js";import y from"../Features/FeaturesViewModel.js";import{ActionsCollection as M}from"../Popup/actions.js";import{zoomToLocation as F}from"../Popup/actionUtils.js";import{loadCalciteComponents as A}from"../support/componentsUtils.js";import{globalCss as I}from"../support/globalCss.js";import{Heading as b}from"../support/Heading.js";import{tsx as k,messageBundle as T,vmEvent as C}from"../support/widget.js";import W from"./UtilityNetworkTraceFeaturesDrillIn.js";const N="selected-index",x=0,j="features-spinner",S="esri-utility-network-trace",U={blockContainer:`${S}__block-container`,blockContent:`${S}__block-content`,featureContent:`${S}__feature-content`,paddingBottom:`${S}__pad-bottom`,paddingTop:`${S}__pad-top`};let O=class extends(_(w)){constructor(e,t){super(e,t),this._actionBarMenuNode=null,this._drillInFlowItems=new i,this._drillInWidget=new W({flowItems:this._drillInFlowItems}),this._feature=null,this._featureMenuViewportNode=null,this._spinner=null,this._utilityNetworkTraceMessages=null,this.featureNavigationTop=!1,this.headerActions=new M,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new y({suppressDeprecationWarning:!0}),this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:n,disabled:r,indicator:l}=e;return e.visible?k("calcite-action",{active:"toggle"===o&&e.value,bind:this,"data-action-uid":n,disabled:"zoom-to-feature"===e.id?!this.feature.geometry:r,icon:this._getActionIcon(e),indicator:l,key:`action-${t}`,loading:s,scale:"s",text:i,title:this._hideActionText?i:void 0,onclick:this._triggerAction},this._renderFallbackIcon(e)):null},this._renderAddNsoBlock=()=>{const{_utilityNetworkTraceMessages:e,messagesCommon:t}=this;return k("calcite-block",{class:U.blockContent,expanded:!this.feature,heading:e?.inputsStrings.addNonspatialOption},k("calcite-action",{icon:"x",slot:"actions-end",text:t.close,onclick:()=>this.emit("close-un-trace-feature-block")}),k("calcite-notice",{icon:"information",kind:"info",open:!this.feature},k("div",{slot:"message"},e?.inputsStrings.addNonspatialHint)))},this._renderNoPopupErrorBlock=()=>{const{_utilityNetworkTraceMessages:e,messagesCommon:t}=this;return k("calcite-block",{description:void 0,expanded:!0,heading:"show-feature-info"===this.mode?t.warning:void 0},k("calcite-notice",{class:this.classes(U.paddingBottom,U.paddingTop),icon:"exclamation-mark-triangle",kind:"danger",open:!0},k("div",{slot:"message"},e.alertsStrings.noPopupConfigured)),"show-feature-info"===this.mode?k("calcite-action",{icon:"x",slot:"actions-end",text:t.close,onclick:()=>this.emit("close-un-trace-feature-block")}):void 0)},this._displaySpinnerThrottled=s(()=>this._displaySpinner(),x),this.addHandles([this._displaySpinnerThrottled,o(()=>this.viewModel?.active,e=>this._drillInWidget.closed=!e),o(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),o(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),o(()=>[this.viewModel?.waitingForResult,this.viewModel?.location],()=>{this._hideSpinner(),this._displaySpinnerThrottled()}),o(()=>this.viewModel?.screenLocation,()=>this._closeOpenActionMenu()),o(()=>this.selectedFeatureWidget,()=>this._destroyDrillInFlowItemWidgets()),o(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]},()=>this._setTitleFromFeatureWidget()),o(()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]},()=>this._setContentFromFeatureWidget()),o(()=>this.viewModel?.featureViewModels,()=>this._featureMenuViewportScrollTop()),this._drillInWidget.on("close",()=>{this.emit("close")}),this._drillInWidget.on("exit",()=>this._destroyDrillInFlowItemWidgets()),this._drillInWidget.on("open-feature",({feature:e})=>this._openRelatedFeature(e)),this._drillInWidget.on("zoom-to-feature",({featureWidget:e})=>F(this.viewModel,e)),this._drillInWidget.on("add-nso-trace-location",({featureWidget:e})=>this.emit("add-nso-trace-location",{featureWidget:e}))])}initialize(){(async()=>{this._utilityNetworkTraceMessages=await a("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace")})(),this._drillInWidget.mode=this.mode,this._drillInWidget.closable=!1}loadDependencies(){return A({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._destroyDrillInFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._drillInWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get active(){return this.viewModel.active}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get feature(){return this.viewModel.features.length?this.viewModel.features[0]:null}set feature(e){this.viewModel.features=e?[e]:[]}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get hasAssociationsPopupElement(){if(!this.feature)return!1;const e=l(this.feature),t=e&&d(e)?e:void 0,i=c(e)?e:void 0,o=t?.popupTemplate||i?.popupTemplate||null,s=o?.content;return!(Array.isArray(s)&&!s.some(e=>e instanceof p))}get hasPopupInfo(){const e=this.feature?l(this.feature):null,t=e&&d(e)?e:void 0,i=c(e)?e:void 0;return!(!t?.popupTemplate&&!i?.popupTemplate)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get mode(){return this._get("mode")||"add-nso"}set mode(e){this._set("mode",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){const e=Array.from(this._drillInFlowItems).at(-1);if(!e)return null;const{flowType:t}=e;return"feature-association"===t||"feature-relationship"===t?e.graphic??null:null}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_drillInFlowItems:i,timeZone:o}=this,{selectedFeatureViewModel:s}=this.viewModel,n={title:!1};return s?(e?(e.viewModel=s,e.visibleElements=n):this._feature=new m({flowItems:i,headingLevel:t+1,timeZone:o,viewModel:s,visibleElements:n}),this._feature):null}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}open(e){this.removeHandles(N),this.viewModel.open({features:[e]})}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return k("div",{bind:this,class:this.classes(f.base,I.widget,I.panel,U.blockContainer)},"add-nso"===this.mode?this._renderAddNsoBlock():void 0,this.feature?this.hasPopupInfo?this._renderContentContainer():this._renderNoPopupErrorBlock():void 0)}_renderActionBar(){return this.viewModel.allActions?.length?k("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},k("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?k("div",{class:v.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._drillInWidget.render()];return k("calcite-flow",{key:"content-container"},e)}_renderContentFeature(){const{_drillInFlowItems:e,headingLevel:t,featureNavigationTop:i}=this,{title:o,active:s}=this.viewModel,n=o||"";return k("calcite-flow-item",{bind:this,class:this.classes({[f.contentFeature]:!0}),closed:!s,collapseDirection:i?"down":"up",headingLevel:t,key:"root-flow-item",loading:this.viewModel.waitingForContents,selected:0===e.length},"show-feature-info"===this.mode?k("calcite-action",{icon:"x",slot:"header-actions-end",text:this.messagesCommon.close,onclick:()=>{this.emit("close")}}):void 0,n?k(b,{class:this.classes(f.featuresHeading,I.heading),innerHTML:n,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),k("div",{class:"add-nso"===this.mode?this.classes(f.container,f.contentContainer):this.classes(f.container,f.contentContainer,U.featureContent)},this._renderContent()))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=u({action:e,feature:this.selectedFeature}),s={[f.icon]:!!t,[f.actionImage]:!!o};return t&&(s[t]=!0),o||t?k("span",{"aria-hidden":"true",class:this.classes(f.icon,s),key:"icon",styles:h(o)}):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?k("calcite-action",{active:"toggle"===e.type&&e.value,bind:this,"data-action-uid":e.uid,disabled:e.disabled||!this.feature.geometry,icon:e.icon??void 0,indicator:e.indicator,key:`header-action-${t}`,loading:e.active,slot:"header-actions-end",text:i,title:i,onclick:this._triggerHeaderAction}):null}_renderHeaderActions(){return this.headerActions.map((e,t)=>this._renderHeaderAction(e,t)).toArray()}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_createSpinner(e){e&&(this._spinner=new g({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_destroyDrillInFlowItemWidgets(){this._drillInFlowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()})}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_featureMenuViewportScrollTop(){this._featureMenuViewportNode?.scrollContentTo({top:0})}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:i,selectedFeature:o,messagesCommon:s}=this,{id:n}=e,r=o?.attributes,l=e.title??"",a="zoom-to-feature"===n?t(l,{messages:i}):"remove-selected-feature"===n?t(l,{messages:s}):"zoom-to-clustered-features"===n||"browse-clustered-features"===n?t(l,{messages:i}):e.title;return a&&r?t(a,r):a??""}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;null!=i&&null!=t&&(this._destroyDrillInFlowItemWidgets(),await this.viewModel.zoomTo({target:i}),this.open(t))}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex(e=>e.uid===i),n=o.at(s);"toggle"===n?.type&&(n.value=!n.value),this.viewModel.triggerAction(s)}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find(({uid:e})=>e===i);o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_wireUpView(e){this._destroySpinner(),e&&this._createSpinner(e)}};e([n()],O.prototype,"_drillInFlowItems",void 0),e([n()],O.prototype,"_hideActionText",null),e([n({readOnly:!0})],O.prototype,"active",null),e([n()],O.prototype,"content",null),e([n()],O.prototype,"feature",null),e([n()],O.prototype,"featureNavigationTop",void 0),e([n()],O.prototype,"goToOverride",null),e([n()],O.prototype,"hasAssociationsPopupElement",null),e([n()],O.prototype,"hasPopupInfo",null),e([n({type:M})],O.prototype,"headerActions",void 0),e([n()],O.prototype,"headingLevel",void 0),e([n()],O.prototype,"location",null),e([n(),T("esri/widgets/Features/t9n/Features")],O.prototype,"messages",void 0),e([n(),T("esri/t9n/common")],O.prototype,"messagesCommon",void 0),e([n()],O.prototype,"mode",null),e([n()],O.prototype,"promises",null),e([n()],O.prototype,"responsiveActionsEnabled",void 0),e([n({readOnly:!0})],O.prototype,"selectedFeature",null),e([n({readOnly:!0})],O.prototype,"selectedDrillInFeature",null),e([n({readOnly:!0})],O.prototype,"selectedFeatureWidget",null),e([n()],O.prototype,"timeZone",null),e([n()],O.prototype,"view",null),e([n({type:y}),C(["triggerAction","trigger-action"])],O.prototype,"viewModel",void 0),O=e([r("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceFeature")],O);const H=O;export{H as default};
|