@arcgis/core 4.24.0-next.20220511 → 4.24.0-next.20220512
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/components/assets/icon/compactness16.json +1 -0
- package/assets/components/assets/icon/compactness24.json +1 -0
- package/assets/components/assets/icon/compactness32.json +1 -0
- package/assets/components/assets/icon/configure16.json +1 -0
- package/assets/components/assets/icon/configure24.json +1 -0
- package/assets/components/assets/icon/configure32.json +1 -0
- package/assets/components/assets/icon/debugScript16.json +1 -0
- package/assets/components/assets/icon/debugScript24.json +1 -0
- package/assets/components/assets/icon/debugScript32.json +1 -0
- package/assets/components/assets/icon/dissolveFeatures16.json +1 -0
- package/assets/components/assets/icon/dissolveFeatures24.json +1 -0
- package/assets/components/assets/icon/dissolveFeatures32.json +1 -0
- package/assets/components/assets/icon/distanceType16.json +1 -0
- package/assets/components/assets/icon/distanceType24.json +1 -0
- package/assets/components/assets/icon/distanceType32.json +1 -0
- package/assets/components/assets/icon/gridDiamond16.json +1 -0
- package/assets/components/assets/icon/gridDiamond24.json +1 -0
- package/assets/components/assets/icon/gridDiamond32.json +1 -0
- package/assets/components/assets/icon/gridHexagon16.json +1 -0
- package/assets/components/assets/icon/gridHexagon24.json +1 -0
- package/assets/components/assets/icon/gridHexagon32.json +1 -0
- package/assets/components/assets/icon/gridTriangle16.json +1 -0
- package/assets/components/assets/icon/gridTriangle24.json +1 -0
- package/assets/components/assets/icon/gridTriangle32.json +1 -0
- package/assets/components/assets/icon/insets16.json +1 -0
- package/assets/components/assets/icon/insets24.json +1 -0
- package/assets/components/assets/icon/insets32.json +1 -0
- package/assets/components/assets/icon/maximumTerritoryDistance16.json +1 -0
- package/assets/components/assets/icon/maximumTerritoryDistance24.json +1 -0
- package/assets/components/assets/icon/maximumTerritoryDistance32.json +1 -0
- package/assets/components/assets/icon/minDistanceBetweenCenters16.json +1 -0
- package/assets/components/assets/icon/minDistanceBetweenCenters24.json +1 -0
- package/assets/components/assets/icon/minDistanceBetweenCenters32.json +1 -0
- package/assets/components/assets/icon/numberOfTerritories16.json +1 -0
- package/assets/components/assets/icon/numberOfTerritories24.json +1 -0
- package/assets/components/assets/icon/numberOfTerritories32.json +1 -0
- package/assets/components/assets/icon/overlapFeatures16.json +1 -0
- package/assets/components/assets/icon/overlapFeatures24.json +1 -0
- package/assets/components/assets/icon/overlapFeatures32.json +1 -0
- package/assets/components/assets/icon/profileVariables16.json +1 -0
- package/assets/components/assets/icon/profileVariables24.json +1 -0
- package/assets/components/assets/icon/profileVariables32.json +1 -0
- package/assets/components/assets/icon/rasterAnalysis16.json +1 -0
- package/assets/components/assets/icon/rasterAnalysis24.json +1 -0
- package/assets/components/assets/icon/rasterAnalysis32.json +1 -0
- package/assets/components/assets/icon/recurrence16.json +1 -0
- package/assets/components/assets/icon/recurrence24.json +1 -0
- package/assets/components/assets/icon/recurrence32.json +1 -0
- package/assets/components/assets/icon/splitFeatures16.json +1 -0
- package/assets/components/assets/icon/splitFeatures24.json +1 -0
- package/assets/components/assets/icon/splitFeatures32.json +1 -0
- package/assets/components/assets/icon/territoryBufferDistance16.json +1 -0
- package/assets/components/assets/icon/territoryBufferDistance24.json +1 -0
- package/assets/components/assets/icon/territoryBufferDistance32.json +1 -0
- package/assets/components/assets/icon/testData16.json +1 -0
- package/assets/components/assets/icon/testData24.json +1 -0
- package/assets/components/assets/icon/testData32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/07eda3e958d29f86b37e.js +1 -0
- package/assets/esri/core/workers/chunks/0ecaa28b8bff1d779d66.js +1 -0
- package/assets/esri/core/workers/chunks/{adae54f116f311d72d97.js → 1aba8c73c62a64e0658c.js} +1 -1
- package/assets/esri/core/workers/chunks/1d109cd048170e2d529a.js +1 -0
- package/assets/esri/core/workers/chunks/366e5c1abd1ab6d3e548.js +1 -0
- package/assets/esri/core/workers/chunks/3e94e35f44aadbb332ff.js +1 -0
- package/assets/esri/core/workers/chunks/46411f32b29a0e783105.js +1 -0
- package/assets/esri/core/workers/chunks/4d1c87e3e0a02efcc082.js +1 -0
- package/assets/esri/core/workers/chunks/{b089058b64db3912478f.js → 5e46e60fab93ad034d3a.js} +1 -1
- package/assets/esri/core/workers/chunks/6281b15009712a5dee3c.js +1 -0
- package/assets/esri/core/workers/chunks/66f627d68dbb0fdb725f.js +1 -0
- package/assets/esri/core/workers/chunks/672da24bbf86718bf48d.js +1 -0
- package/assets/esri/core/workers/chunks/733625d85602127d62cd.js +1 -0
- package/assets/esri/core/workers/chunks/{c51c9b5da855f84b9a48.js → 7391422fc51acb96a25d.js} +1 -1
- package/assets/esri/core/workers/chunks/{f435dc615fdc8917f6ca.js → 7cf3cff7b28ff007dbad.js} +1 -1
- package/assets/esri/core/workers/chunks/7ea06c86adfc827fda08.js +1 -0
- package/assets/esri/core/workers/chunks/{a054a52712a118c6d505.js → 82bc24bdc9c6ebaf58c0.js} +1 -1
- package/assets/esri/core/workers/chunks/8965ab74e03506e3475e.js +1 -0
- package/assets/esri/core/workers/chunks/{5405f478af3563580926.js → 8b497d9c37a8f577a467.js} +1 -1
- package/assets/esri/core/workers/chunks/919d0d8b1c2176760973.js +1 -0
- package/assets/esri/core/workers/chunks/ab2a0480dc2b608deda3.js +1 -0
- package/assets/esri/core/workers/chunks/ab97a35f7a7d5cf1da19.js +2 -0
- package/assets/esri/core/workers/chunks/{dcd0653191cd4a1ccaae.js.LICENSE.txt → ab97a35f7a7d5cf1da19.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/ae554c88e862a5761f2e.js +1 -0
- package/assets/esri/core/workers/chunks/ae5ce55cd1a32525f101.js +1 -0
- package/assets/esri/core/workers/chunks/b597c04a4abb98e29d1c.js +1 -0
- package/assets/esri/core/workers/chunks/{287c484fd40eee643f3a.js → b78c3e9d31c4a562cdf0.js} +1 -1
- package/assets/esri/core/workers/chunks/be4bf1e4cbe2a593f8b3.js +1 -0
- package/assets/esri/core/workers/chunks/{b7572b0921b23aef8b9d.js → c40d9caf5189be2c698e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b28539c5a6bedb71b038.js → d63f736b3560c577a8a4.js} +1 -1
- package/assets/esri/core/workers/chunks/d869dabe937d3b60504e.js +1 -0
- package/assets/esri/core/workers/chunks/dd6c9a114ad38cf622ba.js +1 -0
- package/assets/esri/core/workers/chunks/e6b0f74226b9394bfa7a.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +3 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip.json +1 -0
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -0
- package/chunks/EdgeShader.glsl.js +3 -4
- package/interfaces.d.ts +463 -30
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeoJSONLayer.js +1 -1
- package/layers/OGCFeatureLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/WFSLayer.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/support/AggregateField.d.ts +4 -0
- package/layers/support/AggregateField.js +1 -1
- package/layers/support/FeatureReductionBinning.d.ts +4 -0
- package/layers/support/FeatureReductionBinning.js +1 -1
- package/layers/support/OutStatistic.d.ts +4 -0
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/package.json +3 -3
- package/portal/support/portalItemUtils.js +1 -1
- package/renderers/PieChartRenderer.d.ts +4 -0
- package/renderers/PieChartRenderer.js +5 -0
- package/renderers/Renderer.js +1 -1
- package/renderers/support/AuthoringInfo.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/clickToleranceUtils.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/renderers/support/types.js +1 -1
- package/renderers/support/utils.js +1 -1
- package/renderers.js +1 -1
- package/request.js +1 -1
- package/rest/imageService/fetchRasterInfo.js +5 -0
- package/rest/imageService/getCatalogItemRasterInfo.js +5 -0
- package/rest/print.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/dotDensity.js +1 -1
- package/smartMapping/renderers/heatmap.js +1 -1
- package/smartMapping/renderers/location.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/CurveHelper.js +1 -1
- package/symbols/cim/ExpandedCIM.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/views/2d/engine/brushes.js +1 -1
- package/views/2d/engine/vectorTiles/GlyphSource.js +1 -1
- package/views/2d/engine/vectorTiles/style/Filter.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/Utils.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushPieChart.js +5 -0
- package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushMarker.js +1 -1
- package/views/2d/engine/webgl/color.js +1 -1
- package/views/2d/engine/webgl/definitions.js +1 -1
- package/views/2d/engine/webgl/enums.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLBaseFillTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLBaseLineTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLDynamicFillTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLFillTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/techniques/dotDensity/TechniqueDotDensity.js +1 -1
- package/views/2d/engine/webgl/techniques/pieChart/TechniquePieChart.js +5 -0
- package/views/2d/engine/webgl/techniques/utils.js +1 -1
- package/views/2d/engine/webgl/util/Matcher.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
- package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/analysis/Dimensioning/DimensioningTool.js +1 -1
- package/views/3d/analysis/Dimensioning/LengthDimensionVisualization.js +1 -1
- package/views/3d/environment/SnowyWeather.d.ts +4 -0
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +5 -5
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +37 -31
- package/views/draw/DrawOperation.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/SceneSnappingEngine.js +5 -0
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/snappingFactory.js +5 -0
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup/actionUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0564f1cfa3d17ff1aad3.js +0 -1
- package/assets/esri/core/workers/chunks/0806d5d706a864542bfb.js +0 -1
- package/assets/esri/core/workers/chunks/52478ee2d2a1354b6900.js +0 -1
- package/assets/esri/core/workers/chunks/5759af97f96f24c40105.js +0 -1
- package/assets/esri/core/workers/chunks/7bc828fbdd54c0b28aac.js +0 -1
- package/assets/esri/core/workers/chunks/875f26ee040f3d75c0db.js +0 -1
- package/assets/esri/core/workers/chunks/88384e7cafbfd2348598.js +0 -1
- package/assets/esri/core/workers/chunks/89acd5f888d6b8df4aad.js +0 -1
- package/assets/esri/core/workers/chunks/9d7533aaeac3b8d145c4.js +0 -1
- package/assets/esri/core/workers/chunks/a3bb600bfcb0282622f1.js +0 -1
- package/assets/esri/core/workers/chunks/b50ae3dc7e43ff452568.js +0 -1
- package/assets/esri/core/workers/chunks/b5b7bcbc19b3430903ee.js +0 -1
- package/assets/esri/core/workers/chunks/b758f3c419edc2306784.js +0 -1
- package/assets/esri/core/workers/chunks/cf47b605c31063e88357.js +0 -1
- package/assets/esri/core/workers/chunks/cfbb332d144e65a4a55d.js +0 -1
- package/assets/esri/core/workers/chunks/db937849b2c1af87b481.js +0 -1
- package/assets/esri/core/workers/chunks/dc3ed59f450283d97a19.js +0 -1
- package/assets/esri/core/workers/chunks/dcd0653191cd4a1ccaae.js +0 -2
- package/assets/esri/core/workers/chunks/dfb6a28039e5d5ce6fd4.js +0 -1
- package/assets/esri/core/workers/chunks/e4fdd1eaf987977d0a51.js +0 -1
- package/assets/esri/core/workers/chunks/f7e0bb11ba3677069c94.js +0 -1
- package/assets/esri/core/workers/chunks/f7f3dde4c8f9c687cc1e.js +0 -1
- package/assets/esri/core/workers/chunks/fc6beaf9466ea3898549.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as o}from"../../core/lang.js";import{isNone as n,isSome as r,destroyMaybe as s,removeMaybe as a,abortMaybe as p,unwrap as l,unwrapOr as h,applySome as c}from"../../core/maybe.js";import{debounce as d,ignoreAbortErrors as g}from"../../core/promiseUtils.js";import{createLength as m,createArea as u}from"../../core/quantityUtils.js";import{watch as _,syncAndInitial as y,initial as v}from"../../core/reactiveUtils.js";import{createScreenPoint as x}from"../../core/screenUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{pointEquals as V}from"../../layers/graphics/dehydratedFeatureComparison.js";import{ViewingMode as w}from"../ViewingMode.js";import{defaultDrawingMode as b}from"./DrawingMode.js";import{DrawManipulator as S}from"./DrawManipulator.js";import{createCoordinateHelper as C}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as M}from"../interactive/dragEventPipeline.js";import{EditGeometry as D,Component as O}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as I}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{SnappingPipeline as k}from"../interactive/snapping/SnappingDragPipelineStep.js";import{DrawPointTooltipInfo as A}from"../interactive/tooltip/DrawPointTooltipInfo.js";import{DrawPolygonTooltipInfo as E}from"../interactive/tooltip/DrawPolygonTooltipInfo.js";import{DrawPolylineTooltipInfo as j}from"../interactive/tooltip/DrawPolylineTooltipInfo.js";import{Tooltip as G}from"../interactive/tooltip/Tooltip.js";import{TooltipOptions as H}from"../interactive/tooltip/TooltipOptions.js";import{computeAreaWithStagedVertex as L,computeLengthWithStagedVertex as Z}from"../interactive/tooltip/support/measurements.js";import{TaskPriority as z,ImmediateTask as U}from"../support/Scheduler.js";let R=class extends(e.EventedMixin(i)){constructor(t){super(t),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._snappingPipeline=new k,this._snappingAbortController=null,this._tooltip=null,this._tooltipContext={calculateElevation:null,calculateTotalLength:null,calculateArea:null},this._stagedVertex=null,this.snapToSceneEnabled=null,this.tooltipOptions=new H,this._snap=d((async({snappingManager:t,mapPoint:e,context:i},o)=>{const n=await this._frameTask.schedule((()=>t.snap(e,i,o)),o);n.valid&&await this._frameTask.schedule((()=>{this.stagedVertex=n.apply(),e!==this._snapMapPoint&&(this.stagedVertex=t.update(this._snapMapPoint,i))}),o)})),n(t.elevationInfo)&&(this.elevationInfo={mode:t.hasZ?"absolute-height":"on-the-ground",offset:0})}initialize(){const{geometryType:t,view:e}=this,i="3d"===e.type?e?.resourceController?.scheduler:null;this._frameTask=i?i.registerTask(z.SNAPPING):U;const{spatialReference:o}=e,n="viewingMode"in e.state?e.state.viewingMode:w.Local,a="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=C(this.hasZ,this.hasM,o),this._editGeometryOperations=new I(new D(a,this.coordinateHelper,n)),this._activeComponent=new O(o,n),this._editGeometryOperations.data.components.push(this._activeComponent);const p=this.segmentLabels;r(p)&&(p.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo},this.handles.add([_((()=>!0===c(this.tooltipOptions,(t=>t.show))),(t=>{p.visible=t}),y),this.on("cursor-update",(()=>{const t=this._activeComponent.getLastVertex(),e=this._stagedVertex;p.stagedEdge=r(t)&&r(e)?[t.pos,this.coordinateHelper.pointToVector(e)]:null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates));switch(t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}))),this._manipulator=new S({grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==t,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(t=>this._onImmediateClick(t))),this._manipulator.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),_((()=>this.tooltipOptions.show),(t=>{this._tooltip=t?new G({view:e,info:this._getTooltipInfo()}):s(this._tooltip)}),v)])}destroy(){s(this.segmentLabels),this._editGeometryOperations=s(this._editGeometryOperations),this._frameTask=a(this._frameTask),this._tooltip=s(this._tooltip)}get _snappingEnabled(){return r(this.snappingManager)&&this.snappingManager.options.effectiveEnabled}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}set drawingMode(t){this._set("drawingMode",t??b)}get hasStagedVertex(){return r(this._stagedVertex)}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return r(this._stagedVertex)?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get stagedVertex(){return this._stagedVertex}set stagedVertex(t){if(n(t))this.discardStagedVertex();else{if(n(this._stagedVertex))this._stagedVertex=o(t);else{if(V(this._stagedVertex,t))return;this._stagedVertex.x=t.x,this._stagedVertex.y=t.y,this._stagedVertex.z=t.z,this._stagedVertex.m=t.m,this._stagedVertex.hasZ=t.hasZ,this._stagedVertex.hasM=t.hasM,this._stagedVertex.spatialReference=t.spatialReference}this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(t)}],operation:"apply",type:"vertex-update"})}}get updating(){return this.updatingHandles.updating}get vertices(){const t=this.committedVertices;return r(this._stagedVertex)&&t.push(this.coordinateHelper.pointToArray(this._stagedVertex)),t}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingAbortController=p(this._snappingAbortController),r(this._stagedVertex)){const t=this._stagedVertex;this._stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}}complete(t){const e=t&&t.aborted||!1;this._snappingAbortController=p(this._snappingAbortController),r(this.snappingManager)&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.discardStagedVertex();const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||e)&&this.emit("complete",{vertices:this.vertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"})}discardStagedVertex(){this._stagedVertex=null}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){r(this.snappingManager)&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(t){const e=this._activeComponent;if("polygon"===this.geometryType&&e.vertices.length>2){if(this._vertexWithinPointerDistance(e.vertices[0].pos,t))return 0;if(this._vertexWithinPointerDistance(e.vertices[e.vertices.length-1].pos,t))return e.vertices.length-1}return null}_createManipulatorDragPipeline(t){switch(l(this.drawingMode)){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return M(t,((t,e,i,o)=>{const n="touch"===o&&this._snappingEnabled;!this.isCompleted&&n&&(e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this.stagedVertex=t.mapStart,("segment"===this.geometryType||n&&0===this.numVertices)&&this.commitStagedVertex()),t))).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>n,cancel:i,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:o,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next((t=>(n&&(this.stagedVertex=t.mapEnd,"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))),i.next((()=>{n&&r(this.snappingManager)&&this.snappingManager.doneSnapping()})))}))}_createManipulatorDragPipelineFreehand(t){return M(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return M(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}_getDrawSurface(){if(n(this.elevationDrawSurface))return this.drawSurface;if(!this.coordinateHelper.hasZ)return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let t=this.defaultZ,e=!1;r(this.elevationInfo)&&"absolute-height"===this.elevationInfo.mode&&(e=!0),r(this.snapToSceneEnabled)&&(e=this.snapToSceneEnabled),r(this.elevationInfo)&&"on-the-ground"===this.elevationInfo.mode&&(e=!1);const i=this._activeComponent.vertices.length;return("segment"===this.geometryType||"polygon"===this.geometryType)&&i>0&&(t=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),e=!1),e?this.drawSurface:(this.elevationDrawSurface.defaultZ=t,this.elevationDrawSurface)}_mapToScreen(t){return this._getDrawSurface().mapToScreen(t)}_onHold(t){this._snappingAbortController=p(this._snappingAbortController),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&(this.stagedVertex=t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging)return;const e=this._activeComponent,i=this._closeOnClickVertexIndex(t.screenPoint);if(r(i))return t.stopPropagation(),void this.complete();const o=this._screenToMap(t.screenPoint);if(r(o))switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(this.hasStagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),this.complete());break;case"click":case"hybrid":this._snappingAbortController=p(this._snappingAbortController),this.hasStagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),("point"===this.geometryType||"segment"===this.geometryType&&2===e.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===e.vertices.length)&&this.complete()}t.stopPropagation()}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){if(this._manipulator.dragging||this._pointerDownStates.has(t.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive)return void(this._snappingAbortController=p(this._snappingAbortController));t.stopPropagation();const e=x(t.x,t.y);r(this._tooltip)&&(this._tooltip.screenPoint=e,this._updateTooltipInfo());const i=this._closeOnClickVertexIndex(e);if(r(i))return this._closeOnVertex(i),void(this._snappingAbortController=p(this._snappingAbortController));const o=this._screenToMap(e);if(this._manipulator.cursor=r(o)?"crosshair":null,n(o))return void(this._snappingAbortController=p(this._snappingAbortController));if(n(this.snappingManager))return this.stagedVertex=o,void(this._snappingAbortController=p(this._snappingAbortController));const s=this.snappingManager,a=new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t.pointerType,visualizer:this.snappingVisualizer});this.stagedVertex=s.update(o,a),this._snapMapPoint=o,n(this._snappingAbortController)&&(this._snappingAbortController=new AbortController),this.updatingHandles.addPromise(g(this._snap({snappingManager:s,mapPoint:o,context:a},this._snappingAbortController.signal)))}_closeOnVertex(t){this.discardStagedVertex();const e={componentIndex:0,vertexIndex:t,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[t].pos)};this.emit("cursor-update",{updated:null,vertices:[e],operation:"apply",type:"vertex-update"})}_screenToMap(t){return this._getDrawSurface().screenToMap(t)}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),n(t))return null;const i=this._screenToMap(e.screenEnd);return r(i)?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,o=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return!!r(o)&&F(o,e,i)}_getTooltipInfo(){this._tooltipContext.calculateElevation=t=>m(r(t)&&t.hasZ?t.z:this.defaultZ,"meters");const{stagedVertex:t}=this,e=this._elevationTooltipDetail(t);switch(this.geometryType){case"point":return new A({elevation:e});case"polyline":return this._tooltipContext.calculateTotalLength=t=>Z(this._editGeometryOperations.data.geometry)(t),new j({elevation:e,totalLength:this._totalLengthTooltipDetail(t)});case"polygon":return this._tooltipContext.calculateArea=t=>L(this._editGeometryOperations.data.geometry)(t),new E({elevation:e,area:this._areaTooltipDetail(t)});default:return null}}_elevationTooltipDetail(t){return{title:"Elevation",mode:this.elevationInfo.mode,...l(this._tooltipContext.calculateElevation)(t)}}_totalLengthTooltipDetail(t){return{title:"Total Length",...h(l(this._tooltipContext.calculateTotalLength)(t),m(0,"meters"))}}_areaTooltipDetail(t){return{title:"Area",...h(l(this._tooltipContext.calculateArea)(t),u(0,"square-meters"))}}_updateTooltipInfo(){const t=this._tooltip;if(n(t))return;const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":t.info.elevation=i;break;case"polyline":{const o=t.info;o.elevation=i,o.totalLength=this._totalLengthTooltipDetail(e);break}case"polygon":{const o=t.info;o.elevation=i,o.area=this._areaTooltipDetail(e);break}}}};function F(t,e,i){const o=t.x-e.x,n=t.y-e.y;return o*o+n*n<=i}t([f()],R.prototype,"defaultZ",void 0),t([f({value:b})],R.prototype,"drawingMode",null),t([f({constructOnly:!0})],R.prototype,"elevationDrawSurface",void 0),t([f({constructOnly:!0})],R.prototype,"elevationInfo",void 0),t([f({constructOnly:!0})],R.prototype,"geometryType",void 0),t([f({constructOnly:!0})],R.prototype,"hasM",void 0),t([f({constructOnly:!0})],R.prototype,"hasZ",void 0),t([f({constructOnly:!0})],R.prototype,"manipulators",void 0),t([f({constructOnly:!0})],R.prototype,"drawSurface",void 0),t([f({constructOnly:!0})],R.prototype,"segmentLabels",void 0),t([f({constructOnly:!0})],R.prototype,"snappingManager",void 0),t([f({constructOnly:!0})],R.prototype,"snappingVisualizer",void 0),t([f()],R.prototype,"snapToSceneEnabled",void 0),t([f({constructOnly:!0})],R.prototype,"tooltipOptions",void 0),t([f()],R.prototype,"updating",null),t([f({constructOnly:!0})],R.prototype,"view",void 0),R=t([T("esri.views.draw.DrawOperation")],R);export{R as DrawOperation};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as o}from"../../core/lang.js";import{isNone as n,isSome as r,destroyMaybe as s,removeMaybe as a,abortMaybe as p,unwrap as l,unwrapOr as h,applySome as c}from"../../core/maybe.js";import{debounce as d,ignoreAbortErrors as g}from"../../core/promiseUtils.js";import{createLength as m,createArea as u}from"../../core/quantityUtils.js";import{watch as _,syncAndInitial as y,initial as v}from"../../core/reactiveUtils.js";import{createScreenPoint as x}from"../../core/screenUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{pointEquals as V}from"../../layers/graphics/dehydratedFeatureComparison.js";import{ViewingMode as w}from"../ViewingMode.js";import{defaultDrawingMode as b}from"./DrawingMode.js";import{DrawManipulator as S}from"./DrawManipulator.js";import{createCoordinateHelper as C}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as M}from"../interactive/dragEventPipeline.js";import{EditGeometry as D,Component as O}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as I}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{SnappingPipeline as k}from"../interactive/snapping/SnappingDragPipelineStep.js";import{DrawPointTooltipInfo as A}from"../interactive/tooltip/DrawPointTooltipInfo.js";import{DrawPolygonTooltipInfo as E}from"../interactive/tooltip/DrawPolygonTooltipInfo.js";import{DrawPolylineTooltipInfo as j}from"../interactive/tooltip/DrawPolylineTooltipInfo.js";import{Tooltip as G}from"../interactive/tooltip/Tooltip.js";import{TooltipOptions as H}from"../interactive/tooltip/TooltipOptions.js";import{computeAreaWithStagedVertex as L,computeLengthWithStagedVertex as Z}from"../interactive/tooltip/support/measurements.js";import{TaskPriority as z,ImmediateTask as U}from"../support/Scheduler.js";let R=class extends(e.EventedMixin(i)){constructor(t){super(t),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._snappingPipeline=new k,this._snappingAbortController=null,this._tooltip=null,this._tooltipContext={calculateElevation:null,calculateTotalLength:null,calculateArea:null},this._stagedVertex=null,this.snapToSceneEnabled=null,this.tooltipOptions=new H,this._snap=d((async({snappingManager:t,mapPoint:e,context:i},o)=>{const n=await this._frameTask.schedule((()=>t.snap(e,i,o)),o);n.valid&&await this._frameTask.schedule((()=>{this.stagedVertex=n.apply(),e!==this._snapMapPoint&&(this.stagedVertex=t.update(this._snapMapPoint,i))}),o)})),n(t.elevationInfo)&&(this.elevationInfo={mode:t.hasZ?"absolute-height":"on-the-ground",offset:0})}initialize(){const{geometryType:t,view:e}=this,i="3d"===e.type?e?.resourceController?.scheduler:null;this._frameTask=i?i.registerTask(z.SNAPPING):U;const{spatialReference:o}=e,n="viewingMode"in e.state?e.state.viewingMode:w.Local,a="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=C(this.hasZ,this.hasM,o),this._editGeometryOperations=new I(new D(a,this.coordinateHelper,n)),this._activeComponent=new O(o,n),this._editGeometryOperations.data.components.push(this._activeComponent);const p=this.segmentLabels;r(p)&&(p.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo},this.handles.add([_((()=>!0===c(this.tooltipOptions,(t=>t.show))),(t=>{p.visible=t}),y),this.on("cursor-update",(()=>{const t=this._activeComponent.getLastVertex(),e=this._stagedVertex;p.stagedEdge=r(t)&&r(e)?[t.pos,this.coordinateHelper.pointToVector(e)]:null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates));switch(t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}))),this._manipulator=new S({grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==t,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(t=>this._onImmediateClick(t))),this._manipulator.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),_((()=>this.tooltipOptions.show),(t=>{this._tooltip=t?new G({view:e,info:this._getTooltipInfo()}):s(this._tooltip)}),v)])}destroy(){s(this.segmentLabels),this._editGeometryOperations=s(this._editGeometryOperations),this._frameTask=a(this._frameTask),this._tooltip=s(this._tooltip)}get _snappingEnabled(){return r(this.snappingManager)&&this.snappingManager.options.effectiveEnabled}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}set drawingMode(t){this._set("drawingMode",t??b)}get hasStagedVertex(){return r(this._stagedVertex)}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return r(this._stagedVertex)?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get stagedVertex(){return this._stagedVertex}set stagedVertex(t){if(n(t))this.discardStagedVertex();else{if(n(this._stagedVertex))this._stagedVertex=o(t);else{if(V(this._stagedVertex,t))return;this._stagedVertex.x=t.x,this._stagedVertex.y=t.y,this._stagedVertex.z=t.z,this._stagedVertex.m=t.m,this._stagedVertex.hasZ=t.hasZ,this._stagedVertex.hasM=t.hasM,this._stagedVertex.spatialReference=t.spatialReference}this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(t)}],operation:"apply",type:"vertex-update"})}}get updating(){return this.updatingHandles.updating}get vertices(){const t=this.committedVertices;return r(this._stagedVertex)&&t.push(this.coordinateHelper.pointToArray(this._stagedVertex)),t}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingAbortController=p(this._snappingAbortController),r(this._stagedVertex)){const t=this._stagedVertex;this._stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}}complete(t){const e=t&&t.aborted||!1;this._snappingAbortController=p(this._snappingAbortController),r(this.snappingManager)&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.discardStagedVertex();const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||e)&&this.emit("complete",{vertices:this.vertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"})}discardStagedVertex(){this._stagedVertex=null}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){r(this.snappingManager)&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(t){const e=this._activeComponent;if("polygon"===this.geometryType&&e.vertices.length>2){if(this._vertexWithinPointerDistance(e.vertices[0].pos,t))return 0;if(this._vertexWithinPointerDistance(e.vertices[e.vertices.length-1].pos,t))return e.vertices.length-1}return null}_createManipulatorDragPipeline(t){switch(l(this.drawingMode)){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return M(t,((t,e,i,o)=>{const n="touch"===o&&this._snappingEnabled;!this.isCompleted&&n&&(e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this.stagedVertex=t.mapStart,("segment"===this.geometryType||n&&0===this.numVertices)&&this.commitStagedVertex()),t))).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>n,cancel:i,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:o,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next((t=>(n&&(this.stagedVertex=t.mapEnd,"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))),i.next((()=>{n&&r(this.snappingManager)&&this.snappingManager.doneSnapping()})))}))}_createManipulatorDragPipelineFreehand(t){return M(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return M(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}_getDrawSurface(){if(n(this.elevationDrawSurface))return this.drawSurface;if(!this.coordinateHelper.hasZ)return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let t=this.defaultZ,e=!1;r(this.elevationInfo)&&"absolute-height"===this.elevationInfo.mode&&(e=!0),r(this.snapToSceneEnabled)&&(e=this.snapToSceneEnabled),r(this.elevationInfo)&&"on-the-ground"===this.elevationInfo.mode&&(e=!1);const i=this._activeComponent.vertices.length;return("segment"===this.geometryType||"polygon"===this.geometryType)&&i>0&&(t=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),e=!1),e?this.drawSurface:(this.elevationDrawSurface.defaultZ=t,this.elevationDrawSurface)}_mapToScreen(t){return this._getDrawSurface().mapToScreen(t)}_onHold(t){this._snappingAbortController=p(this._snappingAbortController),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&(this.stagedVertex=t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging)return;const e=this._activeComponent,i=this._closeOnClickVertexIndex(t.screenPoint);if(r(i))return t.stopPropagation(),void this.complete();const o=this._screenToMap(t.screenPoint);if(r(o))switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(this.hasStagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),this.complete());break;case"click":case"hybrid":this._snappingAbortController=p(this._snappingAbortController),this.hasStagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),("point"===this.geometryType||"segment"===this.geometryType&&2===e.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===e.vertices.length)&&this.complete()}t.stopPropagation()}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=x(t.x,t.y);if(r(this._tooltip)&&(this._tooltip.screenPoint=e,this._updateTooltipInfo()),this._manipulator.dragging||this._pointerDownStates.has(t.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive)return void(this._snappingAbortController=p(this._snappingAbortController));t.stopPropagation();const i=this._closeOnClickVertexIndex(e);if(r(i))return this._closeOnVertex(i),void(this._snappingAbortController=p(this._snappingAbortController));const o=this._screenToMap(e);if(this._manipulator.cursor=r(o)?"crosshair":null,n(o))return void(this._snappingAbortController=p(this._snappingAbortController));if(n(this.snappingManager))return this.stagedVertex=o,void(this._snappingAbortController=p(this._snappingAbortController));const s=this.snappingManager,a=new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t.pointerType,visualizer:this.snappingVisualizer});this.stagedVertex=s.update(o,a),this._snapMapPoint=o,n(this._snappingAbortController)&&(this._snappingAbortController=new AbortController),this.updatingHandles.addPromise(g(this._snap({snappingManager:s,mapPoint:o,context:a},this._snappingAbortController.signal)))}_closeOnVertex(t){this.discardStagedVertex();const e={componentIndex:0,vertexIndex:t,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[t].pos)};this.emit("cursor-update",{updated:null,vertices:[e],operation:"apply",type:"vertex-update"})}_screenToMap(t){return this._getDrawSurface().screenToMap(t)}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),n(t))return null;const i=this._screenToMap(e.screenEnd);return r(i)?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,o=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return!!r(o)&&F(o,e,i)}_getTooltipInfo(){this._tooltipContext.calculateElevation=t=>m(r(t)&&t.hasZ?t.z:this.defaultZ,"meters");const{stagedVertex:t}=this,e=this._elevationTooltipDetail(t);switch(this.geometryType){case"point":return new A({elevation:e});case"polyline":return this._tooltipContext.calculateTotalLength=t=>Z(this._editGeometryOperations.data.geometry)(t),new j({elevation:e,totalLength:this._totalLengthTooltipDetail(t)});case"polygon":return this._tooltipContext.calculateArea=t=>L(this._editGeometryOperations.data.geometry)(t),new E({elevation:e,area:this._areaTooltipDetail(t)});default:return null}}_elevationTooltipDetail(t){return{mode:this.elevationInfo.mode,...l(this._tooltipContext.calculateElevation)(t)}}_totalLengthTooltipDetail(t){return{...h(l(this._tooltipContext.calculateTotalLength)(t),m(0,"meters"))}}_areaTooltipDetail(t){return{...h(l(this._tooltipContext.calculateArea)(t),u(0,"square-meters"))}}_updateTooltipInfo(){const t=this._tooltip;if(n(t))return;const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":t.info.elevation=i;break;case"polyline":{const o=t.info;o.elevation=i,o.totalLength=this._totalLengthTooltipDetail(e);break}case"polygon":{const o=t.info;o.elevation=i,o.area=this._areaTooltipDetail(e);break}}}};function F(t,e,i){const o=t.x-e.x,n=t.y-e.y;return o*o+n*n<=i}t([f()],R.prototype,"defaultZ",void 0),t([f({value:b})],R.prototype,"drawingMode",null),t([f({constructOnly:!0})],R.prototype,"elevationDrawSurface",void 0),t([f({constructOnly:!0})],R.prototype,"elevationInfo",void 0),t([f({constructOnly:!0})],R.prototype,"geometryType",void 0),t([f({constructOnly:!0})],R.prototype,"hasM",void 0),t([f({constructOnly:!0})],R.prototype,"hasZ",void 0),t([f({constructOnly:!0})],R.prototype,"manipulators",void 0),t([f({constructOnly:!0})],R.prototype,"drawSurface",void 0),t([f({constructOnly:!0})],R.prototype,"segmentLabels",void 0),t([f({constructOnly:!0})],R.prototype,"snappingManager",void 0),t([f({constructOnly:!0})],R.prototype,"snappingVisualizer",void 0),t([f()],R.prototype,"snapToSceneEnabled",void 0),t([f({constructOnly:!0})],R.prototype,"tooltipOptions",void 0),t([f()],R.prototype,"updating",null),t([f({constructOnly:!0})],R.prototype,"view",void 0),R=t([T("esri.views.draw.DrawOperation")],R);export{R as DrawOperation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as i}from"../../../core/MapUtils.js";import{isSome as o,
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as i}from"../../../core/MapUtils.js";import{isSome as o,isNone as s,unwrap as n}from"../../../core/maybe.js";import{eachAlwaysValues as a,throwIfAborted as c}from"../../../core/promiseUtils.js";import{sync as u,watch as p,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{c as g}from"../../../chunks/vec3f64.js";import{SnappingTypes as f}from"../../../layers/graphics/data/QueryEngineResult.js";import{RayConstraint as y}from"./SnappingConstraint.js";import{sortCandidatesInPlace as S}from"./snappingUtils.js";import{EdgeSnappingCandidate as m}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as v}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as w,OtherVertexType as _}from"./candidates/RightAngleSnappingCandidate.js";import{anyMapPointToRender as j,anyMapPointToScreenPoint as x}from"../support/viewUtils.js";let C=class extends t{constructor(e){super(e),this.options=null,this.sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null}}}get updating(){return i(this.snappingSources,(({snappingSource:e})=>e.updating))||this.updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(o(this.options)&&o(this.options.featureSources))for(const r of this.options.featureSources.items){const i=r.layer.uid,s=e.get(i);if(s){e.delete(i),t.set(i,s);continue}if(!r.layer.loaded){this.updatingHandles.addPromise(r.layer.load());continue}const n=this._createSourceInfo(r);o(n)&&t.set(i,n)}for(const[,r]of e)r.destroy();return t}initialize(){this.updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),u),o(this.view)&&this.handles.add([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy()}async fetchCandidates(e,t,r){if(s(this.options)||!this.options.effectiveFeatureEnabled)return[];const i=[],n=this._computeScreeenSizeDistanceParameters(e,t),u={distance:n,point:e,coordinateHelper:t.coordinateHelper,types:this.types,filter:null};for(const[,{snappingSource:s,layerView:a}]of this.snappingSources)!s.layerSource.enabled||o(a)&&a.suspended||i.push(s.fetchCandidates(u,r).then((e=>e.filter((e=>!this._candidateIsExcluded(s,e,t.excludeFeature))))));const p=(await a(i)).flat();return this._addRightAngleCandidates(p,e,n,t),c(r),S(e,p),p}_addRightAngleCandidates(e,t,r,i){const s=o(i.vertexHandle)?i.vertexHandle.rightEdge?.rightVertex?.pos:o(i.editGeometryOperations)&&"polygon"===i.editGeometryOperations.data.type?n(i.editGeometryOperations.data.components[0]?.getFirstVertex())?.pos:null,a=o(i.vertexHandle)?i.vertexHandle.leftEdge?.leftVertex?.pos:o(i.editGeometryOperations)?n(i.editGeometryOperations.data.components[0]?.getLastVertex())?.pos:null,c=e.length;for(let o=0;o<c;o++)this._addRightAngleCandidate(e[o],a,t,r,i,e),this._addRightAngleCandidate(e[o],s,t,r,i,e)}_addRightAngleCandidate(e,t,r,i,o,n){if(s(t)||!(e instanceof m))return;const a=e.constraint.closestTo(t),c=(a[0]-r[0])/i.x,u=(a[1]-r[1])/i.y;if(c*c+u*u<=1){const r=o.coordinateHelper;n.push(new w({coordinateHelper:r,targetPoint:a,otherVertex:t,otherVertexType:_.NEXT,previousVertex:e.constraint.start,constraint:new y(r,t,a),objectId:e.objectId,elevationInfo:e.elevationInfo}))}}_computeScreeenSizeDistanceParameters(e,t){const r=o(this.options)?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;if(s(this.view))return{x:r,y:r,pixelSize:r};if("2d"===this.view.type){const e=r*this.view.resolution;return{x:e,y:e,pixelSize:e}}return this._computeScreeenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreeenSizeDistanceParameters3D(e,t,r,i){const{coordinateHelper:o,elevationInfo:s}=i,n=r.state.camera.computeScreenPixelSizeAt(j(e,o,s,r,M)),a=n*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,c=t*a;return{x:c/this._computeScreenMagnitudeOfMapOffset(e,a,0,r,i),y:c/this._computeScreenMagnitudeOfMapOffset(e,0,a,r,i),pixelSize:n}}_computeScreenMagnitudeOfMapOffset(e,t,r,i,{coordinateHelper:o,elevationInfo:s}){const n=o.clone(e);n[0]+=t,n[1]+=r;const a=x(e,o,s,i),c=x(n,o,s,i),u=c.x-a.x,p=c.y-a.y;return Math.sqrt(u*u+p*p)}get types(){return f.EDGE|f.VERTEX}_candidateIsExcluded(e,t,r){if(s(r))return!1;const i=this._getCandidateObjectId(t);if(s(i))return!1;const o=e.layerSource.layer;return"graphics"===o.type?r.uid===i:r.sourceLayer===o&&(!(!r.attributes||!("objectIdField"in o))&&r.attributes[o.objectIdField]===i)}_getCandidateObjectId(e){return e instanceof v?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(s(t))return null;if("loading"in t)return this.updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=o(this.view)?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new H(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e)}return null}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source.type){case"feature-layer":{const t=this._getSourceModule("featureService");return o(t.module)?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return o(t.module)?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return o(t.module)?{source:new t.module.GraphicsSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this.sourceModules[e];if(s(t.loader)){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){switch(e){case"featureService":return this.updatingHandles.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return this.updatingHandles.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":return this.updatingHandles.addPromise(import("./featureSources/GraphicsSnappingSource.js"))}return null}};e([d({constructOnly:!0})],C.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],C.prototype,"view",void 0),e([d()],C.prototype,"options",void 0),e([d({readOnly:!0})],C.prototype,"updating",null),e([d({readOnly:!0})],C.prototype,"snappingSources",null),C=e([h("esri.views.interactive.snapping.FeatureSnappingEngine")],C);class H{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const i=this.snappingSource.layerSource.layer;if("refresh"in i){const t=i;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([p((()=>e.updating),(t=>e.layerSource.updating=t),l),p((()=>e.availability),(t=>e.layerSource.availability=t),l)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}const M=g();export{C as FeatureSnappingEngine};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import{isSome as o}from"../../../core/maybe.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{sv3d as p}from"../../../geometry/support/vectorStacks.js";import{SnappingTypes as n}from"../../../layers/graphics/data/QueryEngineResult.js";import a from"./FeatureSnappingLayerSource.js";import{sortCandidatesInPlace as c}from"./snappingUtils.js";import{SceneLayerSnappingSource as u}from"./featureSources/SceneLayerSnappingSource.js";import{anyMapPointToRender as l}from"../support/viewUtils.js";let m=class extends r{constructor(e){super(e),this.options=null,this._snappingSources=new t}initialize(){this.own([this.view.on("layerview-create",(({layerView:e})=>this._createSource(e))),this.view.on("layerview-destroy",(({layerView:e})=>this._removeSource(e)))]);for(const e of this.view.allLayerViews.items)this._createSource(e)}destroy(){this.options=null,this._snappingSources.drain((e=>e.destroy()))}get updating(){return this._snappingSources.some((e=>e.updating))}get _types(){return n.EDGE|n.VERTEX}async fetchCandidates(e,r,t){const{view:s,options:i}=this,{coordinateHelper:n,elevationInfo:a}=r,u=o(i)?i.distance:1,m=l(e,n,a,s,p.get()),y=u*s.state.camera.computeScreenPixelSizeAt(m),S=this._types,d=this._snappingSources.items.map((r=>r.fetchCandidates({point:e,coordinateHelper:n,distance:y,types:S},t))),h=(await Promise.all(d)).flat();return c(e,h),h}_createSource(e){if("scene-layer-3d"!==e.type)return;const r=new u({layerSource:new a({layer:e.layer}),view:this.view});this._snappingSources.push(r)}_removeSource(e){const r=this._snappingSources.findIndex((r=>r.layerSource.layer===e.layer));-1!==r&&this._snappingSources.removeAt(r).destroy()}};e([s({constructOnly:!0})],m.prototype,"view",void 0),e([s()],m.prototype,"updating",null),e([s()],m.prototype,"options",void 0),e([s()],m.prototype,"_snappingSources",void 0),m=e([i("esri.views.interactive.snapping.SceneSnappingEngine")],m);export{m as SceneSnappingEngine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Evented.js";import{HandleOwner as i}from"../../../core/HandleOwner.js";import{
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Evented.js";import{HandleOwner as i}from"../../../core/HandleOwner.js";import{equalsShallow as n}from"../../../core/lang.js";import{isSome as s}from"../../../core/maybe.js";import{isAborted as r}from"../../../core/promiseUtils.js";import{watch as o,sync as a}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{s as h}from"../../../chunks/vec2.js";import{defaultSnappingEnginesFactory as p}from"./snappingFactory.js";import l from"./SnappingOptions.js";import{squareDistance as u,sortCandidatesInPlace as f}from"./snappingUtils.js";import{IntersectionSnappingCandidate as v}from"./candidates/IntersectionSnappingCandidate.js";import{anyMapPointToScreenPoint as g}from"../support/viewUtils.js";var _;!function(t){t[t.NONE=0]="NONE",t[t.SELF=1]="SELF",t[t.FEATURES=2]="FEATURES",t[t.SCENE=4]="SCENE"}(_||(_={}));let m=class extends(e.EventedMixin(i)){constructor(t){super(t),this.options=new l,this.snappingEnginesFactory=p,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[]}initialize(){this.handles.add([o((()=>{const{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:i,distance:n}=this.options;return{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:i,distance:n}}),(()=>{this.doneSnapping(),this.emit("changed")}),a),o((()=>this.options),(t=>{for(const e of this._engines)e.options=t}),a),o((()=>({viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,snappingEnginesFactory:this.snappingEnginesFactory})),(({viewReady:t,snappingEnginesFactory:e})=>this._recreateEngines(t,e)),{sync:!0,initial:!0,equals:n})])}destroy(){this._destroyEngines()}get updating(){return this._engines.some((t=>t.updating))}_recreateEngines(t,e){if(this._destroyEngines(),!t)return;const{view:i,options:n}=this;this._engines=e(i,n)}_destroyEngines(){for(const t of this._engines)t.destroy();this._engines=[]}get squaredMouseProximityTreshold(){return this.options.distance*this.options.distance}get squaredTouchProximityThreshold(){const{distance:t,touchSensitivityMultiplier:e}=this.options,i=t*e;return i*i}async snap(t,e,i){const n=e.coordinateHelper.pointToVector(t),o=await this._fetchCandidates(n,e,i);return{get valid(){return!r(i)},apply:()=>{const{snappedPoint:t,hints:i}=this._processCandidates(n,o,e);return this._removeVisualization(),s(e.visualizer)&&this.handles.add(e.visualizer.draw(i,{coordinateHelper:e.coordinateHelper,elevationInfo:e.elevationInfo,view:this.view}),y),t}}}update(t,e){this._removeVisualization();let i=t;const n=[];if(s(this._currentMainCandidate)){const s=e.coordinateHelper,r=s.pointToVector(t),o=this._currentMainCandidate.constraint.closestTo(r);if(u(g(r,s,e.elevationInfo,this.view),g(o,s,e.elevationInfo,this.view))<this._squaredPointProximityThreshold(e.pointer)){i=s.vectorToDehydratedPoint(o),this._currentMainCandidate.targetPoint=o,n.push(...this._currentMainCandidate.hints);for(const t of this._currentOtherActiveCandidates)t.targetPoint=o,n.push(...t.hints)}else this._currentMainCandidate=null,this._currentOtherActiveCandidates=[]}return s(e.visualizer)&&this.handles.add(e.visualizer.draw(n,{coordinateHelper:e.coordinateHelper,elevationInfo:e.elevationInfo,view:this.view}),y),i}doneSnapping(){this._removeVisualization(),this._currentMainCandidate=null,this._currentOtherActiveCandidates=[]}_removeVisualization(){this.handles.remove(y)}async _fetchCandidates(t,e,i){return(await Promise.all(this._engines.map((n=>n.fetchCandidates(t,e,i))))).flat()}_processCandidates(t,e,i){if(e.length<1)return this.doneSnapping(),{snappedPoint:i.coordinateHelper.vectorToDehydratedPoint(t),hints:[]};f(t,e);const n=this._currentMainCandidate;if(s(n)){const s=this._findOldConstraintInNewCandidates(n,e);if(s>=0){if(!(e[s]instanceof v))return this._intersectWithOtherCandidates(s,e,t,i);if(h(t,n.targetPoint)<this._squaredPointProximityThreshold(i.pointer))return this._updateSnappingCandidate(n,e,i)}}return this._intersectWithOtherCandidates(0,e,t,i)}_findOldConstraintInNewCandidates(t,e){return t instanceof v?this._findOldCandidateIndex(e,t.first)>=0&&this._findOldCandidateIndex(e,t.second)>=0?0:-1:this._findOldCandidateIndex(e,t)}_intersectWithOtherCandidates(t,e,i,n){const s=e[t],r=[],o=n.coordinateHelper;for(let a=0;a<e.length;++a){if(a===t)continue;const d=e[a];for(const t of s.constraint.intersect(d.constraint)){const e=o.fromXYZ(t.intersection,s.targetPoint[2]);r.push([new v(o,e,s,d,d.elevationInfo),u(g(i,n.coordinateHelper,n.elevationInfo,this.view),g(e,n.coordinateHelper,n.elevationInfo,this.view))])}}return r.length>0&&(r.sort(((t,e)=>t[1]-e[1])),r[0][1]<this._squaredPointProximityThreshold(n.pointer))?this._updateSnappingCandidate(r[0][0],e,n):this._updateSnappingCandidate(s,e,n)}_updateSnappingCandidate(t,e,i){this.doneSnapping(),this._currentMainCandidate=t;const n=this._currentMainCandidate.targetPoint,s=[];s.push(...t.hints);for(const r of e){if(t instanceof v){if(r.constraint.objectEqual(t.first.constraint)||r.constraint.objectEqual(t.second.constraint))continue}else if(r.constraint.objectEqual(t.constraint))continue;r.constraint.check(n)&&(r.targetPoint=n,this._currentOtherActiveCandidates.push(r),s.push(...r.hints))}return{snappedPoint:i.coordinateHelper.vectorToDehydratedPoint(n),hints:s}}_squaredPointProximityThreshold(t){return"touch"===t?this.squaredTouchProximityThreshold:this.squaredMouseProximityTreshold}_findOldCandidateIndex(t,e){let i=-1;for(let n=0;n<t.length;++n)if(e.constraint.objectEqual(t[n].constraint)){i=n;break}return i}get test(){return{visualizationsActive:this.handles.has(y),engines:this._engines}}};t([d({constructOnly:!0})],m.prototype,"view",void 0),t([d()],m.prototype,"options",void 0),t([d({readOnly:!0})],m.prototype,"updating",null),t([d()],m.prototype,"snappingEnginesFactory",void 0),t([d()],m.prototype,"_engines",void 0),t([d()],m.prototype,"squaredMouseProximityTreshold",null),t([d()],m.prototype,"squaredTouchProximityThreshold",null),m=t([c("esri.views.interactive.snapping.SnappingManager")],m);const y="visualization-handle";export{_ as SnappingEngineTypes,m as SnappingManager};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{FeatureSnappingEngine as e}from"./FeatureSnappingEngine.js";import{SelfSnappingEngine as n}from"./SelfSnappingEngine.js";function i(i,p){return[new n({view:i,options:p}),new e({view:i,options:p,spatialReference:i.spatialReference})]}export{i as defaultSnappingEnginesFactory};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import{formatLength as s,formatVerticalLength as
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import{formatLength as s,formatVerticalLength as o,formatArea as e}from"../../../../core/quantityFormatUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import n from"../../../../widgets/Widget.js";import"../../../../widgets/support/widgetUtils.js";import{messageBundle as p}from"../../../../widgets/support/decorators/messageBundle.js";let a=class extends n{constructor(){super(...arguments),this._messagesUnits=null,this._messagesTooltip=null}get _units(){return this.tooltip.units}_formatLength(t){return s(this._messagesUnits,t,this._units.length)}_formatVerticalLength(t){return o(this._messagesUnits,t,this._units.verticalLength)}_formatTotalLength(t){return s(this._messagesUnits,t,this._units.length)}_formatArea(t){return e(this._messagesUnits,t,this._units.area)}};t([r()],a.prototype,"info",void 0),t([r()],a.prototype,"tooltip",void 0),t([r()],a.prototype,"_units",null),t([p("esri/core/t9n/Units"),r()],a.prototype,"_messagesUnits",void 0),t([p("esri/views/interactive/tooltip/t9n/Tooltip"),r()],a.prototype,"_messagesTooltip",void 0),a=t([i("esri.views.interactive.tooltip.content.TooltipContent")],a);export{a as TooltipContent};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as o}from"../../../../chunks/tslib.es6.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{CONTENT as s}from"../css.js";import{TooltipContent as r}from"./TooltipContent.js";import{TooltipField as e}from"../support/TooltipField.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as i}from"../../../../widgets/support/jsxFactory.js";const p={base:`${s} ${`${s}--draw-point`}`};let c=class extends r{render(){const{elevation:o}=this.info;return i("div",{class:p.base},i(e,{title:this._messagesTooltip?.numericalFeedback.elevation??"",value:this._formatVerticalLength(o)}))}};c=o([t("esri.views.interactive.tooltip.content.TooltipContentDrawPoint")],c);export{c as TooltipContentDrawPoint};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as o}from"../../../../chunks/tslib.es6.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{CONTENT as s}from"../css.js";import{TooltipContent as e}from"./TooltipContent.js";import{TooltipField as r}from"../support/TooltipField.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as i}from"../../../../widgets/support/jsxFactory.js";const a={base:`${s} ${`${s}--draw-polygon`}`};let p=class extends e{render(){const{area:o,elevation:t}=this.info;return i("div",{class:a.base},i(r,{title:this._messagesTooltip?.numericalFeedback.elevation??"",value:this._formatVerticalLength(t)}),i(r,{title:this._messagesTooltip?.numericalFeedback.area??"",value:this._formatArea(o)}))}};p=o([t("esri.views.interactive.tooltip.content.TooltipContentDrawPolygon")],p);export{p as TooltipContentDrawPolygon};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{CONTENT as
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{CONTENT as e}from"../css.js";import{TooltipContent as s}from"./TooltipContent.js";import{TooltipField as r}from"../support/TooltipField.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as i}from"../../../../widgets/support/jsxFactory.js";const p={base:`${e} ${`${e}--draw-polyline`}`};let a=class extends s{render(){const{elevation:t,totalLength:o}=this.info;return i("div",{class:p.base},i(r,{title:this._messagesTooltip?.numericalFeedback.elevation??"",value:this._formatVerticalLength(t)}),i(r,{title:this._messagesTooltip?.numericalFeedback.totalLength??"",value:this._formatLength(o)}))}};a=t([o("esri.views.interactive.tooltip.content.TooltipContentDrawPolyline")],a);export{a as TooltipContentDrawPolyline};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import{isNone as e}from"../../../../core/maybe.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{CONTENT as o}from"../css.js";import{TooltipContent as r}from"./TooltipContent.js";import{TooltipField as i}from"../support/TooltipField.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as a}from"../../../../widgets/support/jsxFactory.js";const l={base:`${o} ${`${o}--translate-vertex`}`};let p=class extends r{render(){if(e(this._messagesTooltip))return null;const{translation:t,elevation:s,totalLength:o}=this.info;return a("div",{class:l.base},a(i,{title:this._messagesTooltip.numericalFeedback.translation,value:this._formatLength(t)}),a(i,{title:this._messagesTooltip.numericalFeedback.elevation,value:this._formatVerticalLength(s)}),a(i,{title:this._messagesTooltip.numericalFeedback.totalLength,value:this._formatLength(o)}))}};p=t([s("esri.views.interactive.tooltip.content.TooltipContentTranslateVertex")],p);export{p as TooltipContentTranslateVertex};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Graphic.js";import"../../core/has.js";import{handlesGroup as t}from"../../core/handleUtils.js";import{isSome as r,isNone as i,removeMaybe as a}from"../../core/maybe.js";import{whenOrAbort as n,eachAlways as s}from"../../core/promiseUtils.js";import{watch as o,initial as l,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as y}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as d,TransformationType as m}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as g}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as b}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{GraphicState as v}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as S}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as j}from"../../views/support/hitTestSelectUtils.js";function I(e){const t=e.sourceLayer;if("feature"!==t.type||!x(t.renderer))return{rotation:null,size:null};let i=null,a=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&r(h(t,e))));1===n.length&&(i=V(n[0],t));const s=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&d(t)===m.RealWorldSize&&r(g(t,e))));return 1===s.length&&(a=F(s[0],t)),{rotation:i,size:a}}function V(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,L((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function U(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function z(e,t,r){if(i(t))return 0;const{symbol:a}=b(t);if(i(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(W.icon,(await e(n,W.icon))[0])||W.icon}case"text":return n.size||W.text;case"line":return n.size||W.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return U(await t(n,e.scale/W.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/W.viewScaleSizeFactor;case"extrude":return n.size||e.scale/W.viewScaleSizeFactor;default:return 0}}function F(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=f[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>L(l(await z(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,L(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function L(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function x(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function M(e){const t=await w(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=p(e.symbol,t);r(i)&&(e.symbol=t)}function R(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function E(e,t,r){await T(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return T(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function T(e,t){const r=t.layer,i={...t.template.prototype.attributes};await k(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(R(r.geometryType),a)}async function k(t,r,a){const n=new e({sourceLayer:r,attributes:a}),{rotation:s,size:o}=I(n);let l=await w(n,{useSourceLayer:!0}),c=!1;for(const e of[o,s]){if(i(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(l,t.view),c=!0)}switch(c&&(l=await w(n,{useSourceLayer:!0})),l?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=l;break;case"simple-line":case"line-3d":t.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=l}}function A(e,t){return e&&e.find((e=>e.layer===t))}async function G(e,t,r,i){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await r.async((async()=>{const{results:a}=await n(j(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};a.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.includes("update")&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return n(s(a.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function P(e,t,r,i){if(0===e.length)return[];let a=null;const o=await r.async((async()=>{const{results:s}=await n(t.hitTest(r),i);if(0===s.length)return[];const o=new Set;a=s,a.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.includes("update")&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return n(s(o.map((({layer:e})=>{const{objectIdField:n,displayField:s}=e,o=[n];e.fieldsIndex.has(s)&&o.push(s);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?y({renderer:e.renderer,event:r}):0;return l.geometry=S(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(a.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[n]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function q(e,t,r,i){switch(t.type){case"3d":return G(e,t,r,i);case"2d":return P(e,t,r,i)}}async function D(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function Z(e,t,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(i(a))return;const n=t.attributes[a.field];if(r(n))a.initValue(n);else{const r=await a.getDefault(t.symbol,e.view);a.initValue(r),t.setAttribute(a.field,r),s=!0}})),s&&await M(t);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=r(o),c.enableScaling=r(l)),e.layer.elevationInfo=a.elevationInfo,e.update(t,c)}function Q(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function B(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function C(e,t,i,a){if(!r(t.geometry)||"point"!==t.geometry?.type)return;const n=a.rotation,s=Q(i.toolEventInfo);if(r(n)&&r(s))if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:i}=n;t.attributes[r]=i(s.angle,e)}const o=a.size,l=B(i.toolEventInfo);if(r(o)&&r(l))if("scale-stop"===l.type)o.isUpdatingInteractively=!1,o.initValue();else{o.isUpdatingInteractively=!0;const{field:r,getValue:i}=o;t.attributes[r]=i(l.xScale,e)}await M(t)}async function O(e,n,s,u,p){const y=e.clone();await M(y),u.map.add(s.layer),s.layer.add(y);const f=e.sourceLayer,d=u.whenLayerView(f),m=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return d.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){d.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let h=null,g=null;if("3d"===u.type){const e=new v({graphic:y});h=t([u.trackGraphicState(e),o((()=>e.displaying),(e=>{g=e?m():a(g)}),l)])}else g=m();await Z(s,y,f,n);let b=null;d.then((e=>b=e),(()=>{}));const w=n.size,S=n.rotation,j=o((()=>e.attributes),(async e=>{let t=!1;for(const a in e){const n=e[a];n!==y.attributes[a]&&(y.setAttribute(a,n),r(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),r(S)&&!S.isUpdatingInteractively&&S.field===a&&S.initValue(n),(i(b)||b.requiredFields.includes(a))&&(t=!0))}t&&await M(y)})),I=s.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return Z(s,t,f,n);await C(u,t,e,n),p(t.clone())})),V=s.on(["undo","redo"],(async e=>{p(e.graphics[0].clone())})),U=()=>{};return{interactive:{remove(){V.remove(),I.remove(),s.cancel(),j&&j.remove(),this.remove=U}},visual:{remove(){a(g),u.whenLayerView(f).then((e=>c((()=>!e.updating)))).then((()=>{a(h),s.layer.remove(y),this.remove=U}))}}}}const W={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function H(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function J(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function K(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=J(e.viewModel.featureTemplatesViewModel.items);r(i)&&(e.creationInfo={layer:i.layer,template:i.template},t.shift())}return t}export{K as avoidFeatureTemplateSelectionWithOnlyOneItem,H as createWorkflowSteps,q as fetchCandidates,D as fetchFullFeature,A as findLayerInfo,I as getVisualVariableAttributes,E as setUpFeatureAdd,O as setUpGeometryUpdate,W as sizeDefaults,T as startCreatingNewFeature,Z as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,C as visualVariableInteractiveUpdate};
|
|
5
|
+
import e from"../../Graphic.js";import"../../core/has.js";import{handlesGroup as t}from"../../core/handleUtils.js";import{isSome as r,isNone as i,removeMaybe as a}from"../../core/maybe.js";import{whenOrAbort as n,eachAlways as s}from"../../core/promiseUtils.js";import{watch as o,initial as l,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as y}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as d,TransformationType as m}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as g}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as b}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{GraphicState as v}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as S}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as j}from"../../views/support/hitTestSelectUtils.js";function I(e){const t=e.sourceLayer;if("feature"!==t.type||!x(t.renderer))return{rotation:null,size:null};let i=null,a=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&r(h(t,e))));1===n.length&&(i=V(n[0],t));const s=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&d(t)===m.RealWorldSize&&r(g(t,e))));return 1===s.length&&(a=F(s[0],t)),{rotation:i,size:a}}function V(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,L((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function U(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function z(e,t,r){if(i(t))return 0;const{symbol:a}=b(t);if(i(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(W.icon,(await e(n,W.icon))[0])||W.icon}case"text":return n.size||W.text;case"line":return n.size||W.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return U(await t(n,e.scale/W.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/W.viewScaleSizeFactor;case"extrude":return n.size||e.scale/W.viewScaleSizeFactor;default:return 0}}function F(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=f[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>L(l(await z(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,L(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function L(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function x(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function M(e){const t=await w(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=p(e.symbol,t);r(i)&&(e.symbol=t)}function R(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function E(e,t,r){await T(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return T(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function T(e,t){const r=t.layer,i={...t.template.prototype.attributes};await k(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(R(r.geometryType),a)}async function k(t,r,a){const n=new e({sourceLayer:r,attributes:a}),{rotation:s,size:o}=I(n);let l=await w(n,{useSourceLayer:!0}),c=!1;for(const e of[o,s]){if(i(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(l,t.view),c=!0)}switch(c&&(l=await w(n,{useSourceLayer:!0})),l?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=l;break;case"simple-line":case"line-3d":t.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=l}}function A(e,t){return e&&e.find((e=>e.layer===t))}async function G(e,t,r,i){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await r.async((async()=>{const{results:a}=await n(j(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};a.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.includes("update")&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return n(s(a.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function P(e,t,r,i){if(0===e.length)return[];let a=null;const o=await r.async((async()=>{const{results:s}=await n(t.hitTest(r),i);if(0===s.length)return[];const o=new Set;a=s,a.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.includes("update")&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return n(s(o.map((({layer:e})=>{const{objectIdField:n,displayField:s}=e,o=[n];e.fieldsIndex.has(s)&&o.push(s);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?y({renderer:e.renderer,event:r}):0;return l.geometry=S(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(a.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[n]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function q(e,t,r,i){switch(t.type){case"3d":return G(e,t,r,i);case"2d":return P(e,t,r,i)}}async function D(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function Z(e,t,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(i(a))return;const n=t.attributes[a.field];if(r(n))a.initValue(n);else{const r=await a.getDefault(t.symbol,e.view);a.initValue(r),t.setAttribute(a.field,r),s=!0}})),s&&await M(t);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=r(o),c.enableScaling=r(l)),e.layer.elevationInfo=a.elevationInfo,e.update(t,c)}function Q(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function B(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function C(e,t,i,a){if(!r(t.geometry)||"point"!==t.geometry?.type)return;const n=a.rotation,s=Q(i.toolEventInfo);if(r(n)&&r(s))if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:i}=n;t.attributes[r]=i(s.angle,e)}const o=a.size,l=B(i.toolEventInfo);if(r(o)&&r(l))if("scale-stop"===l.type)o.isUpdatingInteractively=!1,o.initValue();else{o.isUpdatingInteractively=!0;const{field:r,getValue:i}=o;t.attributes[r]=i(l.xScale,e)}await M(t)}async function O(e,n,s,u,p){const y=e.clone();await M(y),u.map.add(s.layer),s.layer.add(y);const f=e.sourceLayer,d=u.whenLayerView(f),m=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return d.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){d.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let h=null,g=null;if("3d"===u.type){const e=new v({graphic:y});h=t([u.trackGraphicState(e),o((()=>e.displaying),(e=>{g=e?m():a(g)}),l)])}else g=m();await Z(s,y,f,n);let b=null;d.then((e=>b=e),(()=>{}));const w=n.size,S=n.rotation,j=o((()=>e.attributes),(async e=>{let t=!1;for(const a in e){const n=e[a];n!==y.attributes[a]&&(y.setAttribute(a,n),r(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),r(S)&&!S.isUpdatingInteractively&&S.field===a&&S.initValue(n),(i(b)||b.requiredFields.includes(a))&&(t=!0))}t&&await M(y)})),I=s.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return Z(s,t,f,n);await C(u,t,e,n),p(t.clone())})),V=s.on(["undo","redo"],(async e=>{p(e.graphics[0].clone())})),U=()=>{};return{interactive:{remove(){V.remove(),I.remove(),s.cancel(),j&&j.remove(),this.remove=U}},visual:{remove(){a(g),u.whenLayerView(f).then((e=>c((()=>!e.updating)))).then((()=>{a(h),s.layer.remove(y),this.remove=U}))}}}}const W={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function H(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function J(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function K(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=J(e.viewModel.featureTemplatesViewModel.items);r(i)&&(e.creationInfo={layer:i.layer,template:i.template},t.shift())}return t}export{K as avoidFeatureTemplateSelectionWithOnlyOneItem,H as createWorkflowSteps,q as fetchCandidates,D as fetchFullFeature,A as findLayerInfo,I as getVisualVariableAttributes,E as setUpFeatureAdd,O as setUpGeometryUpdate,W as sizeDefaults,T as startCreatingNewFeature,Z as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,C as visualVariableInteractiveUpdate};
|
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a,on as r,when as o,initial as n}from"../core/reactiveUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/snapping/SnappingOptions.js";import u from"./Attachments.js";import g from"./FeatureForm.js";import v from"./FeatureTemplates.js";import _ from"./Spinner.js";import w from"./Widget.js";import{workflowDeprecation as f}from"./Editor/deprecationUtils.js";import k from"./Editor/EditorViewModel.js";import{ItemList as y}from"./FeatureTemplates/ItemList.js";import{Heading as b,incrementHeadingLevel as C}from"./support/Heading.js";import M from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{classes as S}from"./support/widgetUtils.js";import{substitute as E}from"../intl/substitute.js";const B={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},P={undoRedoButtons:!1};function j(e){e.focus()}const L="esri.widgets.Editor",U=s.getLogger(L);let V=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new g,this._stateStack=[],this._attachments=new u({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new v({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new _,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=B.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new m,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new k,this.visibleElements={...P},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new M({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([a((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=C(e),this._featureTemplates.headingLevel=C(e)}),n),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),n),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),n),r((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),r((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),a((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),n),a((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),a((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:E(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),a((()=>this.viewModel?.state),(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),a((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),o((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...P,...e}}startCreateWorkflowAtFeatureTypeSelection(){return f(U,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return f(U,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return f(U,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return T("div",{class:B.base});const{state:a}=s,r=i(t)?T("calcite-scrim",null,this.renderPrompt(t)):null;return T("div",{class:B.base},s.syncing||e.submitting?this.renderProgressBar():null,T("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return T("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?E(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),T(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},T("div",{class:B.panelContentSection},T("div",{class:B.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(E(i.clickToFinishTemplate,{button:m})),v?T("div",{key:"attachments"},T("div",null,i.attachments),this._attachments.render()):null)),T("div",{class:this._prompt?"":B.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return T(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return T(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return T("div",{class:B.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return T(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(h)))}renderControls(e){return T("div",{class:B.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(B.controlButton,B.button,"secondary"===s?B.buttonSecondary:"tertiary"===s?B.buttonTertiary:null,e?B.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=T("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:j},i.primary.label),o=a?T("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return T("div",{class:`${B.promptContainer}--${s}`},T("div",{class:B.promptHeader},T("calcite-icon",{icon:"exclamation-mark-triangle"}),T(b,{class:B.promptHeading,level:this.headingLevel},e)),T("div",{class:B.promptMessage},t),T("div",{class:B.promptDivider}),T("div",{class:B.promptActions},o,r))}renderProgressBar(){return T("div",{class:this.classes(B.progressBar),key:"progress-bar"})}renderButton(e){return T("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return T(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},T("div",{key:"edit-actions",class:B.panelContentSection},this.renderUpdateActions()),T("div",{key:"create-actions",class:B.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.editFeatures),T("div",{class:B.updateFeaturesActionButtons},T("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:B.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.createFeatures),T("div",{key:"templates",class:B.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=E(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return T(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},y({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return T("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:d??!0,beforeBack:i??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},T("calcite-popover-manager",{autoClose:s,class:B.panelToolbar},T("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},T("div",{class:B.snappingControlsPopover},h.render())),T("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:B.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[T("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),T("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),T("div",{class:S(B.panelContent,B.scroller)},t,c?T("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=h(t);return a&&i[a]&&`${i[a]}`||E(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],V.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],V.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],V.prototype,"allowedWorkflows",void 0),e([c()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],V.prototype,"headingLevel",void 0),e([c()],V.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],V.prototype,"label",void 0),e([l("viewModel.layerInfos")],V.prototype,"layerInfos",void 0),e([c(),F("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([c(),F("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([c(),F("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([c()],V.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],V.prototype,"view",void 0),e([c(),W(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([c()],V.prototype,"visibleElements",void 0),e([d("visibleElements")],V.prototype,"castVisibleElements",null),e([A()],V.prototype,"_handleDelete",null),e([A()],V.prototype,"_handleAttachmentAdd",null),e([A()],V.prototype,"_handleAttachmentUpdate",null),e([A()],V.prototype,"_handleAttachmentDelete",null),e([A()],V.prototype,"_handleAdd",null),e([A()],V.prototype,"_handleEdit",null),e([A()],V.prototype,"_handleDone",null),V=e([p(L)],V);const x=V;export{x as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a,on as r,when as o,initial as n}from"../core/reactiveUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/snapping/SnappingOptions.js";import u from"./Attachments.js";import g from"./FeatureForm.js";import v from"./FeatureTemplates.js";import _ from"./Spinner.js";import w from"./Widget.js";import{workflowDeprecation as f}from"./Editor/deprecationUtils.js";import k from"./Editor/EditorViewModel.js";import{ItemList as y}from"./FeatureTemplates/ItemList.js";import{Heading as b,incrementHeadingLevel as C}from"./support/Heading.js";import M from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{classes as S}from"./support/widgetUtils.js";import{substitute as E}from"../intl/substitute.js";const B={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},P={undoRedoButtons:!1};function j(e){e.focus()}const L="esri.widgets.Editor",U=s.getLogger(L);let V=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new g,this._stateStack=[],this._attachments=new u({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new v({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new _,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=B.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new m,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new k,this.visibleElements={...P},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new M({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([a((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=C(e),this._featureTemplates.headingLevel=C(e)}),n),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),n),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),n),r((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),r((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),a((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),n),a((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),a((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:E(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),a((()=>this.viewModel?.state),(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),a((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),o((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...P,...e}}startCreateWorkflowAtFeatureTypeSelection(){return f(U,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return f(U,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return f(U,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return T("div",{class:B.base});const{state:a}=s,r=i(t)?T("calcite-scrim",null,this.renderPrompt(t)):null;return T("div",{class:B.base},s.syncing||e.submitting?this.renderProgressBar():null,T("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return T("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?E(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),T(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},T("div",{class:B.panelContentSection},T("div",{class:B.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(E(i.clickToFinishTemplate,{button:m})),v?T("div",{key:"attachments"},T("div",null,i.attachments),this._attachments.render()):null),u?T("calcite-scrim",null):null),T("div",{class:this._prompt?"":B.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return T(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return T(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return T("div",{class:B.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return T(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(h)))}renderControls(e){return T("div",{class:B.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(B.controlButton,B.button,"secondary"===s?B.buttonSecondary:"tertiary"===s?B.buttonTertiary:null,e?B.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=T("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:j},i.primary.label),o=a?T("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return T("div",{class:`${B.promptContainer}--${s}`},T("div",{class:B.promptHeader},T("calcite-icon",{icon:"exclamation-mark-triangle"}),T(b,{class:B.promptHeading,level:this.headingLevel},e)),T("div",{class:B.promptMessage},t),T("div",{class:B.promptDivider}),T("div",{class:B.promptActions},o,r))}renderProgressBar(){return T("div",{class:this.classes(B.progressBar),key:"progress-bar"})}renderButton(e){return T("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return T(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},T("div",{key:"edit-actions",class:B.panelContentSection},this.renderUpdateActions()),T("div",{key:"create-actions",class:B.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.editFeatures),T("div",{class:B.updateFeaturesActionButtons},T("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:B.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.createFeatures),T("div",{key:"templates",class:B.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=E(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return T(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},y({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,sketchViewModel:c,snappingControls:p}=e;return T("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:d??!0,beforeBack:i??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},T("calcite-popover-manager",{autoClose:s,class:B.panelToolbar},T("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},T("div",{class:B.snappingControlsPopover},p.render())),T("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:B.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[T("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!c.canUndo(),onclick:c.undo.bind(c)}),T("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!c.canRedo(),onclick:c.redo.bind(c)})]:null),T("div",{class:S(B.scroller,B.panelContent)},t))}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=h(t);return a&&i[a]&&`${i[a]}`||E(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],V.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],V.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],V.prototype,"allowedWorkflows",void 0),e([c()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],V.prototype,"headingLevel",void 0),e([c()],V.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],V.prototype,"label",void 0),e([l("viewModel.layerInfos")],V.prototype,"layerInfos",void 0),e([c(),F("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([c(),F("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([c(),F("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([c()],V.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],V.prototype,"view",void 0),e([c(),W(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([c()],V.prototype,"visibleElements",void 0),e([d("visibleElements")],V.prototype,"castVisibleElements",null),e([A()],V.prototype,"_handleDelete",null),e([A()],V.prototype,"_handleAttachmentAdd",null),e([A()],V.prototype,"_handleAttachmentUpdate",null),e([A()],V.prototype,"_handleAttachmentDelete",null),e([A()],V.prototype,"_handleAdd",null),e([A()],V.prototype,"_handleEdit",null),e([A()],V.prototype,"_handleDone",null),V=e([p(L)],V);const x=V;export{x as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Handles.js";import o from"../../core/Logger.js";import{unwrap as n,isNone as a}from"../../core/maybe.js";import{watch as l,when as h,initial as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import g from"../../layers/Layer.js";import f from"../../support/actions/ActionBase.js";import m from"../../support/actions/ActionButton.js";import y from"../../support/actions/ActionToggle.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{zoomToClusteredFeatures as b,browseClusteredFeatures as C,zoomToFeature as P}from"./actions.js";import{triggerAction as E,getSelectedTarget as A,removeClusteredFeaturesForBrowsing as M,displayClusterExtent as V,browseAggregateFeatures as j}from"./actionUtils.js";import L from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import I from"../../geometry/Point.js";const T=i.ofType({key:"type",defaultKeyValue:"button",base:f,typeMap:{button:m,toggle:y}}),S=()=>[P.clone()],B=()=>[b.clone(),C.clone()],R="esri.widgets.Popup.PopupViewModel",G=o.getLogger(R);let z=class extends(O(L)){constructor(e){super(e),this._handles=new r,this._pendingPromises=new Set,this._fetchFeaturesController=null,this._selectedClusterFeature=null,this.featurePage=null,this.actions=new T,this.activeFeature=null,this.defaultPopupTemplateEnabled=!1,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.featuresPerPage=20,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}get isLoadingFeature(){return this.featureViewModels.some((e=>e.waitingForContent))}initialize(){this._handles.add([l((()=>[this.autoOpenEnabled,this.view]),(()=>this._autoOpenEnabledChange()),u),this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>E({event:e,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange())),l((()=>[this.features,this.view?.map,this.view?.spatialReference]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._handles.destroy(),this._handles=null,this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new T;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,n=r?i.concat(t):t,a=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=a&&a.actions,h=a&&a.overwriteActions?l:l?l.concat(n):n;return h&&h.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new T;return e.removeAll(),e.addMany(this.selectedFeature?.isAggregate?B():S()),e}get featureCount(){return this.features.length}get features(){return this._get("features")||[]}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}get location(){return this._get("location")||null}set location(e){const t=this.get("view.spatialReference.isWebMercator");e&&e.get("spatialReference.isWGS84")&&t&&(e=p(e)),this._set("location",e)}get pendingPromisesCount(){return this._pendingPromises.size}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){if(this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length)return this._set("promises",[]),void this.notifyChange("pendingPromisesCount");this._set("promises",e),(e=e.slice(0)).forEach((e=>{this._pendingPromises.add(e);const t=t=>{this._pendingPromises.has(e)&&this._updateFeatures(t),this._updatePendingPromises(e)},i=()=>this._updatePendingPromises(e);e.then(t,i)})),this.notifyChange("pendingPromisesCount")}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.get("view.ready")?"ready":"disabled"}centerAtLocation(){const{view:e}=this,t=A(this);if(!t){const i=new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e});return G.error(i),Promise.reject(i)}return this.callGoTo({target:{target:t,scale:e.scale}})}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e){const t=new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return G.error(t),Promise.reject(t)}return i.fetchPopupFeatures(e,{event:t&&t.event,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t&&t.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed","featureMenuOpen"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.getItemAt(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this.selectedFeatureIndex+1,this}previous(){return this.selectedFeatureIndex=this.selectedFeatureIndex-1,this}disableClusterBrowsing(){M(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){await V(this),await j(this)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=this.view?.graphics;e&&(e.remove(this.selectedClusterBoundaryFeature),e.remove(this._selectedClusterFeature)),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(this.selectedFeature?.isAggregate)return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.browseClusterEnabled=!1,this.features=[this.selectedFeature])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,n=o+s;r.slice(o,n).forEach(((t,i)=>{t&&!t.graphic&&(t.graphic=e[o+i])}))}async _selectedFeatureChange(e){if(!e)return;const{location:t,updateLocationEnabled:i,view:s}=this;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),e.isAggregate)return;return e.symbol=await w(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}!i&&t||!e.geometry?i&&!e.geometry&&this.centerAtLocation().then((()=>{this.location=s.center.clone()})):this.location=n(this._getPointFromGeometry(e.geometry))}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}_setFetchFeaturesPromises(e){return this._fetchFeaturesWithController(this._getScreenPoint(e||this.location)).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:i}=e,s=Promise.resolve(t),r=i.map((e=>e.promise));this.promises=[s,...r]}))}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i}=this;if(e?.isAggregate||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t||!t.length)return;const s=i.slice(0),r=[];t.forEach(((t,i)=>{if(!t)return;let o=null;if(s.some(((e,i)=>(e&&e.graphic===t&&(o=e,s.splice(i,1)),!!o))),o)r[i]=o;else{const s=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:this.view?.spatialReference,graphic:t===e?t:null,map:this.view?.map,view:this.view});r[i]=s}})),s.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",r)}_getScreenPoint(e){const{view:t}=this;return t&&e&&"function"==typeof t.toScreen?t.toScreen(e):null}_autoOpenEnabledChange(){const e="auto-fetch-features",{_handles:t,autoOpenEnabled:i}=this;if(t.remove(e),i&&this.view){const i=this.view.on("click",(e=>{"mouse"===e.pointerType&&0!==e.button||this._fetchFeaturesAndOpen(e)}),F.WIDGET);t.add(i,e)}}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null,this.notifyChange("waitingForResult")}_fetchFeaturesWithController(e,t){this._cancelFetchingFeatures();const i=new AbortController,{signal:s}=i;this._fetchFeaturesController=i,this.notifyChange("waitingForResult");const r=this.fetchFeatures(e,{signal:s,event:t});return r.catch((()=>{})).then((()=>{this._fetchFeaturesController=null,this.notifyChange("waitingForResult")})),r}_fetchFeaturesAndOpen(e){const{screenPoint:t,mapPoint:i}=e,{view:s}=this;this._fetchFeaturesWithController(t,e).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:r,location:o}=e,n=[Promise.resolve(t),...r.map((e=>e.promise))];return s.popup.open({location:o||i,promises:n}),e}))}_updatePendingPromises(e){e&&this._pendingPromises.has(e)&&(this._pendingPromises.delete(e),this.notifyChange("pendingPromisesCount"))}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}_getPointFromGeometry(e){return a(e)?null:"point"===e.type?e:"extent"===e.type?e.center:"polygon"===e.type?e.centroid:"multipoint"===e.type||"polyline"===e.type?e.extent.center:null}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t){const i="imagery"===t.type?void 0:"objectIdField"in t&&t.objectIdField,s=e.attributes;return s&&i&&s[i]||e}async _highlightActiveFeature(){const e="highlight-active-feature";this._handles.remove(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof g))return;const n=this._getLayerView(i,o);this._highlightActiveFeaturePromise=n;const a=await n;if(!(a&&v(a)&&this._highlightActiveFeaturePromise===n&&this.activeFeature&&this.highlightEnabled))return;const l=a.highlight(this._getHighlightTarget(s,o));this._handles.add(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this._handles.remove(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof g))return;const n=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=n;const a=await n;if(!(a&&v(a)&&this._highlightSelectedFeaturePromise===n&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=a.highlight(this._getHighlightTarget(t,o));this._handles.add(l,e)}_updateFeatures(e){const{features:t}=this;if(!e||!e.length)return;if(!t.length)return void(this.features=e);const i=e.filter((e=>!t.includes(e)));this.features=t.concat(i)}};e([c()],z.prototype,"featurePage",void 0),e([c()],z.prototype,"isLoadingFeature",null),e([c({type:T})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"autoOpenEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:T,readOnly:!0})],z.prototype,"defaultActions",null),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c({type:I})],z.prototype,"location",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([d(R)],z);const H=z;export{H as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Handles.js";import o from"../../core/Logger.js";import{unwrap as n,isNone as a}from"../../core/maybe.js";import{watch as l,when as h,initial as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import g from"../../layers/Layer.js";import f from"../../support/actions/ActionBase.js";import m from"../../support/actions/ActionButton.js";import y from"../../support/actions/ActionToggle.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{zoomToClusteredFeatures as b,browseClusteredFeatures as C,zoomToFeature as P}from"./actions.js";import{triggerAction as E,isClusterFeature as A,getSelectedTarget as M,removeClusteredFeaturesForBrowsing as V,displayClusterExtent as j,browseAggregateFeatures as L}from"./actionUtils.js";import O from"../support/AnchorElementViewModel.js";import{GoToMixin as x}from"../support/GoTo.js";import I from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const S=i.ofType({key:"type",defaultKeyValue:"button",base:f,typeMap:{button:m,toggle:y}}),B=()=>[P.clone()],R=()=>[b.clone(),C.clone()],G="esri.widgets.Popup.PopupViewModel",z=o.getLogger(G);let H=class extends(x(O)){constructor(e){super(e),this._handles=new r,this._pendingPromises=new Set,this._fetchFeaturesController=null,this._selectedClusterFeature=null,this.featurePage=null,this.actions=new S,this.activeFeature=null,this.defaultPopupTemplateEnabled=!1,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.featuresPerPage=20,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new I({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}get isLoadingFeature(){return this.featureViewModels.some((e=>e.waitingForContent))}initialize(){this._handles.add([l((()=>[this.autoOpenEnabled,this.view]),(()=>this._autoOpenEnabledChange()),u),this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>E({event:e,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange())),l((()=>[this.features,this.view?.map,this.view?.spatialReference]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._handles.destroy(),this._handles=null,this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new S;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,n=r?i.concat(t):t,a=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=a&&a.actions,h=a&&a.overwriteActions?l:l?l.concat(n):n;return h&&h.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new S;return e.removeAll(),e.addMany(A(this.selectedFeature)?R():B()),e}get featureCount(){return this.features.length}get features(){return this._get("features")||[]}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}get location(){return this._get("location")||null}set location(e){const t=this.get("view.spatialReference.isWebMercator");e&&e.get("spatialReference.isWGS84")&&t&&(e=p(e)),this._set("location",e)}get pendingPromisesCount(){return this._pendingPromises.size}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){if(this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length)return this._set("promises",[]),void this.notifyChange("pendingPromisesCount");this._set("promises",e),(e=e.slice(0)).forEach((e=>{this._pendingPromises.add(e);const t=t=>{this._pendingPromises.has(e)&&this._updateFeatures(t),this._updatePendingPromises(e)},i=()=>this._updatePendingPromises(e);e.then(t,i)})),this.notifyChange("pendingPromisesCount")}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.get("view.ready")?"ready":"disabled"}centerAtLocation(){const{view:e}=this,t=M(this);if(!t){const i=new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e});return z.error(i),Promise.reject(i)}return this.callGoTo({target:{target:t,scale:e.scale}})}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e){const t=new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return z.error(t),Promise.reject(t)}return i.fetchPopupFeatures(e,{event:t&&t.event,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t&&t.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed","featureMenuOpen"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.getItemAt(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this.selectedFeatureIndex+1,this}previous(){return this.selectedFeatureIndex=this.selectedFeatureIndex-1,this}disableClusterBrowsing(){V(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){await j(this),await L(this)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=this.view?.graphics;e&&(e.remove(this.selectedClusterBoundaryFeature),e.remove(this._selectedClusterFeature)),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.browseClusterEnabled=!1,this.features=[this.selectedFeature])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,n=o+s;r.slice(o,n).forEach(((t,i)=>{t&&!t.graphic&&(t.graphic=e[o+i])}))}async _selectedFeatureChange(e){if(!e)return;const{location:t,updateLocationEnabled:i,view:s}=this;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await w(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}!i&&t||!e.geometry?i&&!e.geometry&&this.centerAtLocation().then((()=>{this.location=s.center.clone()})):this.location=n(this._getPointFromGeometry(e.geometry))}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}_setFetchFeaturesPromises(e){return this._fetchFeaturesWithController(this._getScreenPoint(e||this.location)).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:i}=e,s=Promise.resolve(t),r=i.map((e=>e.promise));this.promises=[s,...r]}))}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i}=this;if(A(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t||!t.length)return;const s=i.slice(0),r=[];t.forEach(((t,i)=>{if(!t)return;let o=null;if(s.some(((e,i)=>(e&&e.graphic===t&&(o=e,s.splice(i,1)),!!o))),o)r[i]=o;else{const s=new _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:this.view?.spatialReference,graphic:t===e?t:null,map:this.view?.map,view:this.view});r[i]=s}})),s.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",r)}_getScreenPoint(e){const{view:t}=this;return t&&e&&"function"==typeof t.toScreen?t.toScreen(e):null}_autoOpenEnabledChange(){const e="auto-fetch-features",{_handles:t,autoOpenEnabled:i}=this;if(t.remove(e),i&&this.view){const i=this.view.on("click",(e=>{"mouse"===e.pointerType&&0!==e.button||this._fetchFeaturesAndOpen(e)}),F.WIDGET);t.add(i,e)}}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null,this.notifyChange("waitingForResult")}_fetchFeaturesWithController(e,t){this._cancelFetchingFeatures();const i=new AbortController,{signal:s}=i;this._fetchFeaturesController=i,this.notifyChange("waitingForResult");const r=this.fetchFeatures(e,{signal:s,event:t});return r.catch((()=>{})).then((()=>{this._fetchFeaturesController=null,this.notifyChange("waitingForResult")})),r}_fetchFeaturesAndOpen(e){const{screenPoint:t,mapPoint:i}=e,{view:s}=this;this._fetchFeaturesWithController(t,e).then((e=>{const{clientOnlyGraphics:t,promisesPerLayerView:r,location:o}=e,n=[Promise.resolve(t),...r.map((e=>e.promise))];return s.popup.open({location:o||i,promises:n}),e}))}_updatePendingPromises(e){e&&this._pendingPromises.has(e)&&(this._pendingPromises.delete(e),this.notifyChange("pendingPromisesCount"))}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}_getPointFromGeometry(e){return a(e)?null:"point"===e.type?e:"extent"===e.type?e.center:"polygon"===e.type?e.centroid:"multipoint"===e.type||"polyline"===e.type?e.extent.center:null}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t){const i="imagery"===t.type?void 0:"objectIdField"in t&&t.objectIdField,s=e.attributes;return s&&i&&s[i]||e}async _highlightActiveFeature(){const e="highlight-active-feature";this._handles.remove(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof g))return;const n=this._getLayerView(i,o);this._highlightActiveFeaturePromise=n;const a=await n;if(!(a&&v(a)&&this._highlightActiveFeaturePromise===n&&this.activeFeature&&this.highlightEnabled))return;const l=a.highlight(this._getHighlightTarget(s,o));this._handles.add(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this._handles.remove(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof g))return;const n=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=n;const a=await n;if(!(a&&v(a)&&this._highlightSelectedFeaturePromise===n&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=a.highlight(this._getHighlightTarget(t,o));this._handles.add(l,e)}_updateFeatures(e){const{features:t}=this;if(!e||!e.length)return;if(!t.length)return void(this.features=e);const i=e.filter((e=>!t.includes(e)));this.features=t.concat(i)}};e([c()],H.prototype,"featurePage",void 0),e([c()],H.prototype,"isLoadingFeature",null),e([c({type:S})],H.prototype,"actions",void 0),e([c({readOnly:!0})],H.prototype,"active",null),e([c()],H.prototype,"activeFeature",void 0),e([c({readOnly:!0})],H.prototype,"allActions",null),e([c({type:Boolean})],H.prototype,"defaultPopupTemplateEnabled",void 0),e([c()],H.prototype,"autoCloseEnabled",void 0),e([c()],H.prototype,"autoOpenEnabled",void 0),e([c()],H.prototype,"browseClusterEnabled",void 0),e([c()],H.prototype,"content",void 0),e([c({type:S,readOnly:!0})],H.prototype,"defaultActions",null),e([c({readOnly:!0})],H.prototype,"featureCount",null),e([c()],H.prototype,"features",null),e([c()],H.prototype,"featuresPerPage",void 0),e([c()],H.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],H.prototype,"featureViewModels",void 0),e([c()],H.prototype,"highlightEnabled",void 0),e([c()],H.prototype,"includeDefaultActions",void 0),e([c({type:T})],H.prototype,"location",null),e([c({readOnly:!0})],H.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],H.prototype,"selectedClusterBoundaryFeature",void 0),e([c({readOnly:!0})],H.prototype,"waitingForResult",null),e([c({readOnly:!0})],H.prototype,"promiseCount",null),e([c()],H.prototype,"promises",null),e([c({value:null,readOnly:!0})],H.prototype,"selectedFeature",null),e([c({value:-1})],H.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],H.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],H.prototype,"state",null),e([c()],H.prototype,"title",void 0),e([c()],H.prototype,"updateLocationEnabled",void 0),e([c()],H.prototype,"view",void 0),e([c()],H.prototype,"visible",void 0),e([c()],H.prototype,"zoomFactor",void 0),e([c()],H.prototype,"zoomToLocation",void 0),e([c()],H.prototype,"centerAtLocation",null),H=e([d(G)],H);const U=H;export{U as default};
|