@arcgis/core 4.29.0-next.20231021 → 4.29.0-next.20231024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/a6c6998874c44c7623ad.js +1 -0
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentMove.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/widgets/Attribution.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/assets/esri/core/workers/chunks/f66f0ab764e0cda412bb.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import{watch as a,initial as o}from"../../../../../core/reactiveUtils.js";import{
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import{watch as a,initial as o}from"../../../../../core/reactiveUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/has.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import{containsXY as r}from"../../../../../geometry/support/aaBoundingRect.js";import{sm4d as p}from"../../../../../geometry/support/vectorStacks.js";import{calculateBoundedPlaneTranslateRotate as l,resizeNormal as h,resizeOutlineOnly as c}from"../../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as d}from"../../Manipulator3D.js";import{getGraphicAttachmentOrigin as u}from"../../manipulatorUtils.js";import{ManipulatorType as m}from"../ManipulatorType.js";import{canMoveZ as g}from"../manipulatorUtils.js";import{createVisualElements as _}from"../visualElementUtils.js";import{ExtentMove as v}from"./ExtentMove.js";import{ExtentRotate as y}from"./ExtentRotate.js";import{ExtentScale as b}from"./ExtentScale.js";import{TransformBounds as f}from"./extentUtils.js";import{PreserveAspectRatio as M}from"./PreserveAspectRatio.js";import{OutlineVisualElement as S}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as E}from"../../../layers/graphics/GraphicState.js";import{InteractiveToolBase as O}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as x}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{unapply as A,apply as R}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import j from"../../../../interactive/sketch/SketchTooltipOptions.js";import{Tooltip as T}from"../../../../interactive/tooltip/Tooltip.js";let w=class extends(e.EventedMixin(O)){constructor(t){super(t),this.enableZ=!0,this.enableScaling=!0,this.enableRotation=!0,this.tooltipOptions=new j,this._preserveAspectRatio=new M,this.grabbing=!1,this.inputState=null,this._attachmentOrigin=null,this.type="transform-3d",this._outlineVisualElement=null}initialize(){const{view:t,graphic:e}=this,s=this._graphicState=new E({graphic:e}),n=e.geometry,r=this._editGeometryOperations=x.fromGeometry(n,t.state.viewingMode),p=this._bounds=new f(this,(()=>this._updateManipulators()),r.data);this._extentMove=new v(this,s,r,p),this._extentScale=new b(this,s,r,p,(()=>this._preserveAspectRatio.createDragEventPipelineStep())),this._extentRotate=new y(this,r,p),this.addHandles([a((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this._extentMove.moveZManipulator,m.TRANSLATE_Z))),a((()=>this.enableScaling),(()=>this._extentScale.forEachManipulator((t=>this._updateManipulatorAvailability(t,m.SCALE))))),a((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this._extentRotate.rotateManipulator,m.ROTATE)))]),this._updateAllManipulatorAvailability();const l=_({view:t,graphic:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>i()});if(null!=l){const{visualElement:t}=l;t instanceof S&&(this._outlineVisualElement=t,this.addHandles(t.events.on("attachment-origin-changed",(()=>this._bounds.updateDisplayBounds())))),this.addHandles(l)}this.addHandles([s.on("changed",(()=>this._onGeometryChanged())),a((()=>s.displaying),(()=>this._updateAllManipulatorAvailability())),a((()=>s.isDraped),(()=>this._graphicDrapedChanged()),o),a((()=>t.pointsOfInterest?.centerOnSurfaceFrequent.location),(()=>p.updateDisplayBounds())),t.trackGraphicState(s)]);const h=t=>{this.addHandles(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(h);const c=(t,i)=>{this.addHandles(t.events.on("immediate-click",(t=>{i===m.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:e}),t.stopPropagation()})))};this._forEachManipulator(c),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._extentMove.destroy(),this._extentScale.destroy(),this._extentRotate.destroy(),this._editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{view:t}=this,e=this._tooltip=new T({view:t}),i=()=>{e.info=this._getUpdatedTooltipInfo()};this.addHandles([a((()=>this.tooltipOptions.enabled),i),this.on("graphic-translate-start",i),this.on("graphic-translate",i),this.on("graphic-translate-stop",(()=>{this._tooltip.clear()})),this.on("graphic-rotate-start",i),this.on("graphic-rotate",i),this.on("graphic-rotate-stop",i),this.on("graphic-scale-start",i),this.on("graphic-scale",i),this.on("graphic-scale-stop",i)]),this._forEachManipulator((t=>{this.addHandles([t.events.on("focus-changed",i),t.events.on("grab-changed",i),t.events.on("drag",(t=>{"cancel"===t.action?this._tooltip.clear():i()}))])}))}_getUpdatedTooltipInfo(){return this.tooltipOptions.enabled?this._extentMove.getUpdatedTooltipInfo()??this._extentScale.getUpdatedTooltipInfo()??this._extentRotate.getUpdatedTooltipInfo():null}_onGeometryChanged(){this._bounds.updateDisplayBounds()}_graphicDrapedChanged(){this.removeHandles(G),this._bounds.updateDisplayBounds(),this._graphicState.isDraped&&this.addHandles(this.view.elevationProvider.on("elevation-change",(t=>{null!=this._attachmentOrigin&&r(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._bounds.updateDisplayBounds()})),G)}_updateManipulators(){if(!this.visible)return;const t=this._bounds.displayBounds,e=l(t,p.get());this._extentMove.updateManipulators(e,t),this._extentScale.updateManipulators(e,t),this._extentRotate.updateManipulators(e,t)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof d){const a=this._graphicState.displaying,o=this.enableZ&&g(this.graphic);switch(e){case m.ROTATE:t.available=a&&this.enableRotation;break;case m.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||o),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?h:c;break;case m.TRANSLATE_Z:t.available=a&&o;break;default:t.available=a}}}_forEachManipulator(t){this._extentMove.forEachManipulator(t),this._extentScale.forEachManipulator(t),this._extentRotate.forEachManipulator(t)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get attachmentOrigin(){const t=this.graphic.geometry,e=this._graphicState.isDraped?null:this._outlineVisualElement?.attachmentOrigin;return this._attachmentOrigin=e??u(this.view,this.graphic)??t?.extent?.center,this._attachmentOrigin}reset(){}cancel(){if(this.canUndo){const t=this._editGeometryOperations.undo();A(t,this._bounds.mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry}this.inputState=null}get canUndo(){return this._editGeometryOperations.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this._editGeometryOperations.undo();A(t,this._bounds.mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry}}get canRedo(){return this._editGeometryOperations.canRedo}redo(){if(this.canRedo){const t=this._editGeometryOperations.redo();R(t,this._bounds.mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry}}get test(){return{moveZManipulator:this._extentMove.moveZManipulator,resizeManipulators:this._extentScale.resizeManipulators,rotateManipulator:this._extentRotate.rotateManipulator,tooltip:this._tooltip}}};t([s({constructOnly:!0,nonNullable:!0})],w.prototype,"view",void 0),t([s({constructOnly:!0,nonNullable:!0})],w.prototype,"graphic",void 0),t([s()],w.prototype,"enableZ",void 0),t([s()],w.prototype,"enableScaling",void 0),t([s()],w.prototype,"enableRotation",void 0),t([s({constructOnly:!0,type:j})],w.prototype,"tooltipOptions",void 0),t([s()],w.prototype,"preserveAspectRatio",null),t([s()],w.prototype,"grabbing",void 0),t([s()],w.prototype,"inputState",void 0),t([s({readOnly:!0})],w.prototype,"type",void 0),w=t([n("esri.views.3d.interactive.editingTools.transformGraphic.ExtentTransformTool")],w);const G="draped-elevation-changes";export{w as ExtentTransformTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import"../../core/Error.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import i from"./DrawAction.js";import{DrawTool as o}from"./DrawTool.js";import{CursorUpdateEvent as r,DrawCompleteEvent as s}from"./input/DrawEvents.js";import{ViewEventPriorities as n}from"../input/InputManager.js";import{sketchKeys as a}from"../interactive/keybindings.js";import{createScreenPointFromEvent as d}from"../support/screenUtils.js";import p from"../../geometry/Point.js";let h=class extends i{constructor(e){super(e),this._addVertexOnPointerUp=!1,this._drawTool=null}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}complete(){this._completeDrawing()}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles([this.view.on("key-down",(e=>{e.key===a.complete&&(this._drawTool?this.complete():(this._abortSnapping(),this._vertexAddHandler(e)))}),n.TOOL)])}_addViewHandles2DOnly(){"2d"===this.view.type&&this.addHandles([this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=d(e),"touch"===e.pointerType&&this._updateCursor())}),n.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._cursorScreenPoint=d(e),"touch"!==e.pointerType&&this._updateCursor()}),n.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._addVertexOnPointerUp=!1)}),n.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp)e.stopPropagation(),this._vertexAddHandler(e);else{const t="touch"===e.pointerType;this._updateCursor(t)}}),n.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),n.TOOL)])}_addDrawTool(){const e=new o({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"point",mode:"click"});this._drawTool=e,this.view.addAndActivateTool(e),this.addHandles([e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new r(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new s(e.getVertexCoords())),this._removeDrawTool()}))])}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t),this.notifyChange("vertices"),this._completeDrawing())}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new r(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new p(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return this._drawTool.completeCreateOperation()
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import"../../core/Error.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import i from"./DrawAction.js";import{DrawTool as o}from"./DrawTool.js";import{CursorUpdateEvent as r,DrawCompleteEvent as s}from"./input/DrawEvents.js";import{ViewEventPriorities as n}from"../input/InputManager.js";import{sketchKeys as a}from"../interactive/keybindings.js";import{createScreenPointFromEvent as d}from"../support/screenUtils.js";import p from"../../geometry/Point.js";let h=class extends i{constructor(e){super(e),this._addVertexOnPointerUp=!1,this._drawTool=null}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}complete(){this._completeDrawing()}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles([this.view.on("key-down",(e=>{e.key===a.complete&&(this._drawTool?this.complete():(this._abortSnapping(),this._vertexAddHandler(e)))}),n.TOOL)])}_addViewHandles2DOnly(){"2d"===this.view.type&&this.addHandles([this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=d(e),"touch"===e.pointerType&&this._updateCursor())}),n.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._cursorScreenPoint=d(e),"touch"!==e.pointerType&&this._updateCursor()}),n.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._addVertexOnPointerUp=!1)}),n.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp)e.stopPropagation(),this._vertexAddHandler(e);else{const t="touch"===e.pointerType;this._updateCursor(t)}}),n.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),n.TOOL)])}_addDrawTool(){const e=new o({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"point",mode:"click"});this._drawTool=e,this.view.addAndActivateTool(e),this.addHandles([e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new r(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new s(e.getVertexCoords())),this._removeDrawTool(),this.removeAllHandles()}))])}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t),this.notifyChange("vertices"),this._completeDrawing())}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new r(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new p(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return void this._drawTool.completeCreateOperation();this._activePointerId=null,this._popCursorVertex(),this._abortSnapping(),null!=this._snappingManager&&this._snappingManager.doneSnapping();const e=new s(this.vertices);this.emit("draw-complete",e),e.defaultPrevented||this.removeAllHandles()}};h=e([t("esri.views.draw.PointDrawAction")],h);export{h as PointDrawAction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"./DrawAction.js";import{defaultDrawingMode as r,drawingModes as s}from"./DrawingMode.js";import{DrawTool as n}from"./DrawTool.js";import{VertexRemoveEvent as a,VertexAddEvent as d,CursorUpdateEvent as h,DrawCompleteEvent as p}from"./input/DrawEvents.js";import{ViewEventPriorities as l}from"../input/InputManager.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as _}from"../support/screenUtils.js";import v from"../../geometry/Point.js";let u=class extends o{constructor(e){super(e),this._panEnabled=!1,this._popVertexOnPointerMove=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.mode=r}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}get _dragEnabled(){return"freehand"===this.mode||"hybrid"===this.mode}get _clickEnabled(){return"click"===this.mode||"hybrid"===this.mode}undo(){this._drawTool?this._drawTool.undo():(super.undo(),this.notifyChange("vertices"))}redo(){this._drawTool?this._drawTool.redo():(super.redo(),this.notifyChange("vertices"))}canUndo(){return this._drawTool?.canUndo()??super.canUndo()}canRedo(){return this._drawTool?.canRedo()??super.canRedo()}complete(){this._completeDrawing()}_getGeometryZValue(){return this.hasZ&&this.vertices.length>0?this.vertices[0][2]:this.defaultZ}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles(this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.vertexAdd||i?t!==c.complete||i?t!==c.undo||this.interactiveUndoDisabled||i?t!==c.redo||this.interactiveUndoDisabled||i||(e.stopPropagation(),this.redo()):(e.stopPropagation(),this.undo()):(e.stopPropagation(),this._drawCompleteHandler(e)):(e.stopPropagation(),this._handleVertexAddKey(e))}),l.TOOL))}_addViewHandles2DOnly(){"2d"===this.view.type&&(this.addHandles([this.view.on("click",(e=>{e.stopPropagation()}),l.TOOL),this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=_(e),"touch"===e.pointerType&&this._updateCursor())}),l.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._popVertexOnPointerMove&&(this.undo(),this._popVertexOnPointerMove=!1),this._cursorScreenPoint=_(e),"touch"!==e.pointerType&&this._updateCursor()}),l.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._cursorScreenPoint=_(e),this._dragEnabled&&!this._panEnabled?this._vertexAddHandler(e):this._addVertexOnPointerUp=!1)}),l.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp){if(!this._clickEnabled)return 1===this.vertices.length&&this.vertices.pop(),void this._drawCompleteHandler(e);this._vertexAddHandler(e)}else{const t="touch"===e.pointerType;this._updateCursor(t)}}),l.TOOL),this.view.on("drag",(e=>{this._dragEnabled&&null!=this._activePointerId&&!this._panEnabled&&e.stopPropagation()}),l.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),l.TOOL),this.view.on("double-click",(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("double-click",["Control"],(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.pan||i||(e.stopPropagation(),this._panEnabled=!0)}),l.TOOL),this.view.on("key-up",(e=>{e.key===c.pan&&(e.stopPropagation(),this._panEnabled=!1)}),l.TOOL)]),this._addUndoRedoHandles())}_handleVertexAddKey(e){this._drawTool?this._drawTool.drawOperation.commitStagedVertex():this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}_addUndoRedoHandles(){this.addHandles([this._editGeometryOperations.on("vertex-remove",(e=>{if(this.notifyChange("vertices"),"undo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("undo",new a(this.view,e.vertices[0].index,t))}})),this._editGeometryOperations.on("vertex-add",(e=>{if(this.notifyChange("vertices"),"apply"===e.operation){const e=this._committedVertices.length-1,t=new d(this.view,e,this.vertices);this.emit("vertex-add",t),t.defaultPrevented&&(this._popVertexOnPointerMove=!0)}else if("redo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("redo",new d(this.view,e.vertices[0].index,t))}}))])}_addDrawTool(){const e=new n({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"polygon",mode:this.mode});this._drawTool=e,this.view.addAndActivateTool(e),e.on("vertex-add",(t=>{if(1===t.vertices.length){const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-add",new d(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new d(i,o,r))}})),e.on("vertex-remove",(t=>{if(1===t.vertices.length){const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-remove",new a(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new a(i,o,r))}})),e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new h(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new p(e.getVertexCoords())),this._removeDrawTool()}))}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t))}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new h(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new v(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return this._drawTool.completeCreateOperation()
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"./DrawAction.js";import{defaultDrawingMode as r,drawingModes as s}from"./DrawingMode.js";import{DrawTool as n}from"./DrawTool.js";import{VertexRemoveEvent as a,VertexAddEvent as d,CursorUpdateEvent as h,DrawCompleteEvent as p}from"./input/DrawEvents.js";import{ViewEventPriorities as l}from"../input/InputManager.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as _}from"../support/screenUtils.js";import v from"../../geometry/Point.js";let u=class extends o{constructor(e){super(e),this._panEnabled=!1,this._popVertexOnPointerMove=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.mode=r}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}get _dragEnabled(){return"freehand"===this.mode||"hybrid"===this.mode}get _clickEnabled(){return"click"===this.mode||"hybrid"===this.mode}undo(){this._drawTool?this._drawTool.undo():(super.undo(),this.notifyChange("vertices"))}redo(){this._drawTool?this._drawTool.redo():(super.redo(),this.notifyChange("vertices"))}canUndo(){return this._drawTool?.canUndo()??super.canUndo()}canRedo(){return this._drawTool?.canRedo()??super.canRedo()}complete(){this._completeDrawing()}_getGeometryZValue(){return this.hasZ&&this.vertices.length>0?this.vertices[0][2]:this.defaultZ}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles(this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.vertexAdd||i?t!==c.complete||i?t!==c.undo||this.interactiveUndoDisabled||i?t!==c.redo||this.interactiveUndoDisabled||i||(e.stopPropagation(),this.redo()):(e.stopPropagation(),this.undo()):(e.stopPropagation(),this._drawCompleteHandler(e)):(e.stopPropagation(),this._handleVertexAddKey(e))}),l.TOOL))}_addViewHandles2DOnly(){"2d"===this.view.type&&(this.addHandles([this.view.on("click",(e=>{e.stopPropagation()}),l.TOOL),this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=_(e),"touch"===e.pointerType&&this._updateCursor())}),l.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._popVertexOnPointerMove&&(this.undo(),this._popVertexOnPointerMove=!1),this._cursorScreenPoint=_(e),"touch"!==e.pointerType&&this._updateCursor()}),l.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._cursorScreenPoint=_(e),this._dragEnabled&&!this._panEnabled?this._vertexAddHandler(e):this._addVertexOnPointerUp=!1)}),l.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp){if(!this._clickEnabled)return 1===this.vertices.length&&this.vertices.pop(),void this._drawCompleteHandler(e);this._vertexAddHandler(e)}else{const t="touch"===e.pointerType;this._updateCursor(t)}}),l.TOOL),this.view.on("drag",(e=>{this._dragEnabled&&null!=this._activePointerId&&!this._panEnabled&&e.stopPropagation()}),l.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),l.TOOL),this.view.on("double-click",(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("double-click",["Control"],(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.pan||i||(e.stopPropagation(),this._panEnabled=!0)}),l.TOOL),this.view.on("key-up",(e=>{e.key===c.pan&&(e.stopPropagation(),this._panEnabled=!1)}),l.TOOL)]),this._addUndoRedoHandles())}_handleVertexAddKey(e){this._drawTool?this._drawTool.drawOperation.commitStagedVertex():this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}_addUndoRedoHandles(){this.addHandles([this._editGeometryOperations.on("vertex-remove",(e=>{if(this.notifyChange("vertices"),"undo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("undo",new a(this.view,e.vertices[0].index,t))}})),this._editGeometryOperations.on("vertex-add",(e=>{if(this.notifyChange("vertices"),"apply"===e.operation){const e=this._committedVertices.length-1,t=new d(this.view,e,this.vertices);this.emit("vertex-add",t),t.defaultPrevented&&(this._popVertexOnPointerMove=!0)}else if("redo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("redo",new d(this.view,e.vertices[0].index,t))}}))])}_addDrawTool(){const e=new n({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"polygon",mode:this.mode});this._drawTool=e,this.view.addAndActivateTool(e),e.on("vertex-add",(t=>{if(1===t.vertices.length){const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-add",new d(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new d(i,o,r))}})),e.on("vertex-remove",(t=>{if(1===t.vertices.length){const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-remove",new a(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new a(i,o,r))}})),e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new h(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new p(e.getVertexCoords())),this._removeDrawTool(),this.removeAllHandles()}))}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t))}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new h(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new v(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return void this._drawTool.completeCreateOperation();if(this._activePointerId=null,this._popCursorVertex(),this._committedVertices.length<3)return;this._abortSnapping(),null!=this._snappingManager&&this._snappingManager.doneSnapping();const e=new p(this.vertices);this.emit("draw-complete",e),e.defaultPrevented||this.removeAllHandles()}};e([t()],u.prototype,"_dragEnabled",null),e([t()],u.prototype,"_clickEnabled",null),e([t({type:s})],u.prototype,"mode",void 0),u=e([i("esri.views.draw.PolygonDrawAction")],u);export{u as PolygonDrawAction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"./DrawAction.js";import{defaultDrawingMode as r,drawingModes as s}from"./DrawingMode.js";import{DrawTool as n}from"./DrawTool.js";import{VertexRemoveEvent as d,VertexAddEvent as a,CursorUpdateEvent as h,DrawCompleteEvent as p}from"./input/DrawEvents.js";import{ViewEventPriorities as l}from"../input/InputManager.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as _}from"../support/screenUtils.js";import v from"../../geometry/Point.js";let u=class extends o{constructor(e){super(e),this._panEnabled=!1,this._popVertexOnPointerMove=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.mode=r}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}get _clickEnabled(){return"click"===this.mode||"hybrid"===this.mode}get _dragEnabled(){return"freehand"===this.mode||"hybrid"===this.mode}undo(){this._drawTool?this._drawTool.undo():(super.undo(),this.notifyChange("vertices"))}redo(){this._drawTool?this._drawTool.redo():(super.redo(),this.notifyChange("vertices"))}canUndo(){return this._drawTool?.canUndo()??super.canUndo()}canRedo(){return this._drawTool?.canRedo()??super.canRedo()}complete(){this._completeDrawing()}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles([this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.vertexAdd||i?t!==c.complete||i?t!==c.undo||this.interactiveUndoDisabled||i?t!==c.redo||this.interactiveUndoDisabled||i||(e.stopPropagation(),this.redo()):(e.stopPropagation(),this.undo()):(e.stopPropagation(),this._drawCompleteHandler(e)):(e.stopPropagation(),this._handleVertexAddKey(e))}),l.TOOL)])}_addViewHandles2DOnly(){"2d"===this.view.type&&(this.addHandles([this.view.on("click",(e=>{e.stopPropagation()}),l.TOOL),this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&!this._panEnabled&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=_(e),"touch"===e.pointerType&&this._updateCursor())}),l.TOOL),this.view.on("pointer-move",(e=>{this._popVertexOnPointerMove&&(this.undo(),this._popVertexOnPointerMove=!1),this._abortSnapping(),this._cursorScreenPoint=_(e),"touch"!==e.pointerType&&this._updateCursor()}),l.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._cursorScreenPoint=_(e),this._dragEnabled&&!this._panEnabled?this._vertexAddHandler(e):this._addVertexOnPointerUp=!1)}),l.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp){if(!this._clickEnabled)return 1===this.vertices.length&&this.vertices.pop(),void this._drawCompleteHandler(e);this._vertexAddHandler(e)}else{const t="touch"===e.pointerType;this._updateCursor(t)}}),l.TOOL),this.view.on("drag",(e=>{this._dragEnabled&&null!=this._activePointerId&&!this._panEnabled&&e.stopPropagation()}),l.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),l.TOOL),this.view.on("double-click",(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("double-click",["Control"],(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.pan||i||(e.stopPropagation(),this._panEnabled=!0)}),l.TOOL),this.view.on("key-up",(e=>{e.key===c.pan&&(e.stopPropagation(),this._panEnabled=!1)}),l.TOOL)]),this._addUndoRedoHandles())}_handleVertexAddKey(e){this._drawTool?this._drawTool.drawOperation.commitStagedVertex():this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}_addUndoRedoHandles(){this.addHandles([this._editGeometryOperations.on("vertex-remove",(e=>{if(this.notifyChange("vertices"),"undo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("undo",new d(this.view,e.vertices[0].index,t))}})),this._editGeometryOperations.on("vertex-add",(e=>{if(this.notifyChange("vertices"),"apply"===e.operation){const e=this._committedVertices.length-1,t=new a(this.view,e,this.vertices);this.emit("vertex-add",t),t.defaultPrevented&&(this._popVertexOnPointerMove=!0)}else if("redo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("redo",new a(this.view,e.vertices[0].index,t))}}))])}_addDrawTool(){const e=new n({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"polyline",mode:this.mode});this._drawTool=e,this.view.addAndActivateTool(e),this.addHandles([e.on("vertex-add",(t=>{if(1!==t.vertices.length)return;const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-add",new a(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new a(i,o,r))})),e.on("vertex-remove",(t=>{if(1!==t.vertices.length)return;const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-remove",new d(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new d(i,o,r))})),e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new h(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new p(e.getVertexCoords())),this._removeDrawTool()}))])}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t))}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new h(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new v(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return this._drawTool.completeCreateOperation()
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/RandomLCG.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"./DrawAction.js";import{defaultDrawingMode as r,drawingModes as s}from"./DrawingMode.js";import{DrawTool as n}from"./DrawTool.js";import{VertexRemoveEvent as d,VertexAddEvent as a,CursorUpdateEvent as h,DrawCompleteEvent as p}from"./input/DrawEvents.js";import{ViewEventPriorities as l}from"../input/InputManager.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as _}from"../support/screenUtils.js";import v from"../../geometry/Point.js";let u=class extends o{constructor(e){super(e),this._panEnabled=!1,this._popVertexOnPointerMove=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.mode=r}initialize(){this._addViewHandles(),"3d"===this.view.type&&this._addDrawTool()}destroy(){this._removeDrawTool(),this.emit("destroy")}get _clickEnabled(){return"click"===this.mode||"hybrid"===this.mode}get _dragEnabled(){return"freehand"===this.mode||"hybrid"===this.mode}undo(){this._drawTool?this._drawTool.undo():(super.undo(),this.notifyChange("vertices"))}redo(){this._drawTool?this._drawTool.redo():(super.redo(),this.notifyChange("vertices"))}canUndo(){return this._drawTool?.canUndo()??super.canUndo()}canRedo(){return this._drawTool?.canRedo()??super.canRedo()}complete(){this._completeDrawing()}_addViewHandles(){this._addViewHandles2DOnly(),this.addHandles([this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.vertexAdd||i?t!==c.complete||i?t!==c.undo||this.interactiveUndoDisabled||i?t!==c.redo||this.interactiveUndoDisabled||i||(e.stopPropagation(),this.redo()):(e.stopPropagation(),this.undo()):(e.stopPropagation(),this._drawCompleteHandler(e)):(e.stopPropagation(),this._handleVertexAddKey(e))}),l.TOOL)])}_addViewHandles2DOnly(){"2d"===this.view.type&&(this.addHandles([this.view.on("click",(e=>{e.stopPropagation()}),l.TOOL),this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&!this._panEnabled&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=_(e),"touch"===e.pointerType&&this._updateCursor())}),l.TOOL),this.view.on("pointer-move",(e=>{this._popVertexOnPointerMove&&(this.undo(),this._popVertexOnPointerMove=!1),this._abortSnapping(),this._cursorScreenPoint=_(e),"touch"!==e.pointerType&&this._updateCursor()}),l.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._cursorScreenPoint=_(e),this._dragEnabled&&!this._panEnabled?this._vertexAddHandler(e):this._addVertexOnPointerUp=!1)}),l.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp){if(!this._clickEnabled)return 1===this.vertices.length&&this.vertices.pop(),void this._drawCompleteHandler(e);this._vertexAddHandler(e)}else{const t="touch"===e.pointerType;this._updateCursor(t)}}),l.TOOL),this.view.on("drag",(e=>{this._dragEnabled&&null!=this._activePointerId&&!this._panEnabled&&e.stopPropagation()}),l.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),l.TOOL),this.view.on("double-click",(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("double-click",["Control"],(e=>{e.stopPropagation(),this._drawCompleteHandler(e)}),l.TOOL),this.view.on("key-down",(e=>{const{key:t,repeat:i}=e;t!==c.pan||i||(e.stopPropagation(),this._panEnabled=!0)}),l.TOOL),this.view.on("key-up",(e=>{e.key===c.pan&&(e.stopPropagation(),this._panEnabled=!1)}),l.TOOL)]),this._addUndoRedoHandles())}_handleVertexAddKey(e){this._drawTool?this._drawTool.drawOperation.commitStagedVertex():this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}_addUndoRedoHandles(){this.addHandles([this._editGeometryOperations.on("vertex-remove",(e=>{if(this.notifyChange("vertices"),"undo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("undo",new d(this.view,e.vertices[0].index,t))}})),this._editGeometryOperations.on("vertex-add",(e=>{if(this.notifyChange("vertices"),"apply"===e.operation){const e=this._committedVertices.length-1,t=new a(this.view,e,this.vertices);this.emit("vertex-add",t),t.defaultPrevented&&(this._popVertexOnPointerMove=!0)}else if("redo"===e.operation){const t=[...this._committedVertices];null!=this._stagedVertex&&t.push(this._coordinateHelper.pointToArray(this._stagedVertex)),this.emit("redo",new a(this.view,e.vertices[0].index,t))}}))])}_addDrawTool(){const e=new n({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"polyline",mode:this.mode});this._drawTool=e,this.view.addAndActivateTool(e),this.addHandles([e.on("vertex-add",(t=>{if(1!==t.vertices.length)return;const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-add",new a(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new a(i,o,r))})),e.on("vertex-remove",(t=>{if(1!==t.vertices.length)return;const{view:i}=this,o=t.vertices[0].vertexIndex,r=e.getVertexCoords();this.emit("vertex-remove",new d(i,o,r)),"undo"!==t.operation&&"redo"!==t.operation||this.emit(t.operation,new d(i,o,r))})),e.on("cursor-update",(t=>{1===t.vertices.length&&this.emit("cursor-update",new h(this.view,t.vertices[0].vertexIndex,e.getVertexCoords()))})),e.on("complete",(t=>{this.emit("draw-complete",new p(e.getVertexCoords())),this._removeDrawTool(),this.removeAllHandles()}))])}_removeDrawTool(){this._drawTool&&(this.view.tools.remove(this._drawTool),this._drawTool=null)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t))}_updateCursor(e=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const t=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==t||e||this._pushCursorVertex(t.vertex,(()=>this.emit("cursor-update",new h(this.view,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new v(this._stagedVertex):null))))}_completeDrawing(){if(this._drawTool)return void this._drawTool.completeCreateOperation();if(this._activePointerId=null,this._popCursorVertex(),this._committedVertices.length<2)return;this._abortSnapping(),null!=this._snappingManager&&this._snappingManager.doneSnapping();const e=new p(this.vertices);this.emit("draw-complete",e),e.defaultPrevented||this.removeAllHandles()}};e([t()],u.prototype,"_clickEnabled",null),e([t()],u.prototype,"_dragEnabled",null),e([t({type:s})],u.prototype,"mode",void 0),u=e([i("esri.views.draw.PolylineDrawAction")],u);export{u as PolylineDrawAction};
|
package/widgets/Attribution.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{on as t}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import s from"./Widget.js";import o from"./Attribution/AttributionViewModel.js";import{globalCss as n}from"./support/globalCss.js";import{legacyIcon as p}from"./support/legacyIcon.js";import{accessibleHandler as c}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const a="esri-attribution",h={base:a,poweredBy:`${a}__powered-by`,sources:`${a}__sources`,open:`${a}--open`,sourcesOpen:`${a}__sources--open`,link:`${a}__link`,widgetIcon:p.description};let u=class extends s{constructor(e,t){super(e,t),this._isOpen=!1,this._attributionTextOverflowed=!1,this._prevSourceNodeHeight=0,this._resizeObserver=new ResizeObserver((e=>e.forEach((({target:e})=>this._checkSourceTextOverflow(e))))),this.iconClass=h.widgetIcon,this.icon=null,this.itemDelimiter=" | ",this.messages=null,this.viewModel=new o}initialize(){this.addHandles(t((()=>this.viewModel?.items),"change",(()=>this.scheduleRender())))}destroy(){this._resizeObserver?.disconnect()}get _isInteractive(){return this._isOpen||this._attributionTextOverflowed}get attributionText(){return this.viewModel.items.reduce(((e,t)=>(e.includes(t.text)||e.push(t.text),e)),[]).join(this.itemDelimiter)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e={[h.open]:this._isOpen};return d("div",{bind:this,class:this.classes(h.base,n.widget,e),dir:"ltr",onclick:this._toggleState,onkeydown:this._toggleState},this._renderSourcesNode(),this._renderPoweredBy())}_renderPoweredBy(){return d("div",{class:h.poweredBy},"Powered by"," ",d("a",{class:h.link,href:"
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{on as t}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import s from"./Widget.js";import o from"./Attribution/AttributionViewModel.js";import{globalCss as n}from"./support/globalCss.js";import{legacyIcon as p}from"./support/legacyIcon.js";import{accessibleHandler as c}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const a="esri-attribution",h={base:a,poweredBy:`${a}__powered-by`,sources:`${a}__sources`,open:`${a}--open`,sourcesOpen:`${a}__sources--open`,link:`${a}__link`,widgetIcon:p.description};let u=class extends s{constructor(e,t){super(e,t),this._isOpen=!1,this._attributionTextOverflowed=!1,this._prevSourceNodeHeight=0,this._resizeObserver=new ResizeObserver((e=>e.forEach((({target:e})=>this._checkSourceTextOverflow(e))))),this.iconClass=h.widgetIcon,this.icon=null,this.itemDelimiter=" | ",this.messages=null,this.viewModel=new o}initialize(){this.addHandles(t((()=>this.viewModel?.items),"change",(()=>this.scheduleRender())))}destroy(){this._resizeObserver?.disconnect()}get _isInteractive(){return this._isOpen||this._attributionTextOverflowed}get attributionText(){return this.viewModel.items.reduce(((e,t)=>(e.includes(t.text)||e.push(t.text),e)),[]).join(this.itemDelimiter)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e={[h.open]:this._isOpen};return d("div",{bind:this,class:this.classes(h.base,n.widget,e),dir:"ltr",onclick:this._toggleState,onkeydown:this._toggleState},this._renderSourcesNode(),this._renderPoweredBy())}_renderPoweredBy(){return d("div",{class:h.poweredBy},"Powered by"," ",d("a",{class:h.link,href:"https://www.esri.com/",rel:"noreferrer",target:"_blank"},"Esri"))}_renderSourcesNode(){const e=this._isOpen,t=this._isInteractive,i=t?0:void 0,{attributionText:r}=this,s={[h.sourcesOpen]:e,[n.interactive]:t};return d("div",{afterCreate:this._afterSourcesNodeCreate,bind:this,class:this.classes(h.sources,s),innerHTML:r,tabIndex:i})}_afterSourcesNodeCreate(e){this._prevSourceNodeHeight=e.clientWidth,this._resizeObserver.observe(e)}_checkSourceTextOverflow(e){let t=!1;const{clientHeight:i,clientWidth:r,scrollWidth:s}=e,o=s>r,n=this._attributionTextOverflowed!==o;if(this._attributionTextOverflowed=o,n&&(t=!0),this._isOpen){const e=i<this._prevSourceNodeHeight;this._prevSourceNodeHeight=i,e&&(this._isOpen=!1,t=!0)}t&&this.scheduleRender()}_toggleState(){this._isInteractive&&(this._isOpen=!this._isOpen)}};e([i()],u.prototype,"_isOpen",void 0),e([i()],u.prototype,"_isInteractive",null),e([i()],u.prototype,"_attributionTextOverflowed",void 0),e([i()],u.prototype,"_prevSourceNodeHeight",void 0),e([i({readOnly:!0,dependsOn:["viewModel.items.length","itemDelimiter"]})],u.prototype,"attributionText",null),e([i()],u.prototype,"iconClass",void 0),e([i()],u.prototype,"icon",void 0),e([i()],u.prototype,"itemDelimiter",void 0),e([i()],u.prototype,"label",null),e([i(),l("esri/widgets/Attribution/t9n/Attribution")],u.prototype,"messages",void 0),e([i()],u.prototype,"view",null),e([i({type:o})],u.prototype,"viewModel",void 0),e([c()],u.prototype,"_toggleState",null),u=e([r("esri.widgets.Attribution")],u);const _=u;export{_ 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as M}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{data:e}=this,{sketchViewModel:t}=e.viewModel,{activeComponent:a}=t,i=t.createGraphic?.geometry;if(("polyline"===i?.type||"polygon"===i?.type||"multipoint"===i?.type)&&("draw-2d"===a?.type||"draw-3d"===a?.type)&&a.drawOperation.committedVertices.length>0)return!0;const{upload:r}=e;return!(!r||"pending"!==r.state&&"success"!==r.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:p,sketchViewModel:u,view:h}=r;if(!h||!i)return;const f=i.layer,m=k(p,f),g=m?.formTemplate,y=h.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:h.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===h.type?h.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===h.type){const a=c((()=>h.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===h.type?h.scale:null)})),u.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:u,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await M({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const p=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const u=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&p.push(e._fadeExistingFeatures(i.creationInfo.layer)),p.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const p=e._visualVariableAttributes;await E(o,l,a,p,t);const u=l.attributes,{rotation:h,size:f}=p;if(null!=h){const{field:e}=h;n.setValue(e,u[e])}if(null!=f){const{field:e}=f;n.setValue(e,u[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(p),afterCommit:r((()=>{l.updateOnGraphicClick=u}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],p=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const u=D(o);d.push(u);const h=w(e?.layer);try{if(b(e)&&p.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),h){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),p.push(t.afterCommit),e?.initialFeature&&(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)),await this._startCreating(l)}}finally{u.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...p,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([h({constructOnly:!0})],N.prototype,"isNested",void 0),e([h()],N.prototype,"hasPendingEdits",null),e([h()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([h()],N.prototype,"helpMessage",null),e([h()],N.prototype,"parent",null),e([h()],N.prototype,"keyboardCancellationEnabled",null),e([h()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],N.prototype,"shouldShowAttachments",null),e([h()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as M}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{data:e}=this,{sketchViewModel:t}=e.viewModel,{activeComponent:a}=t,i=t.createGraphic?.geometry;if(("polyline"===i?.type||"polygon"===i?.type||"multipoint"===i?.type)&&("draw-2d"===a?.type||"draw-3d"===a?.type)&&a.drawOperation.committedVertices.length>0)return!0;const{upload:r}=e;return!(!r||"pending"!==r.state&&"success"!==r.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:p,sketchViewModel:u,view:h}=r;if(!h||!i)return;const f=i.layer,m=k(p,f),g=m?.formTemplate,y=h.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:h.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===h.type?h.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===h.type){const a=c((()=>h.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===h.type?h.scale:null)})),u.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:u,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await M({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const p=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const u=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&p.push(e._fadeExistingFeatures(i.creationInfo.layer)),p.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const p=e._visualVariableAttributes;await E(o,l,a,p,t);const u=l.attributes,{rotation:h,size:f}=p;if(null!=h){const{field:e}=h;n.setValue(e,u[e])}if(null!=f){const{field:e}=f;n.setValue(e,u[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(p),afterCommit:r((()=>{l.updateOnGraphicClick=u}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],p=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const u=D(o);d.push(u);const h=w(e?.layer);try{if(b(e)&&p.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),h){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),p.push(t.afterCommit),e?.initialFeature?(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)):await this._startCreating(l)}}finally{u.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...p,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([h({constructOnly:!0})],N.prototype,"isNested",void 0),e([h()],N.prototype,"hasPendingEdits",null),e([h()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([h()],N.prototype,"helpMessage",null),e([h()],N.prototype,"parent",null),e([h()],N.prototype,"keyboardCancellationEnabled",null),e([h()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],N.prototype,"shouldShowAttachments",null),e([h()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|