@arcgis/core 4.34.0-next.51 → 4.34.0-next.53
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/{beb77cdae0b1b6ad73da.js → 0445de3a8968c0734c91.js} +1 -1
- package/assets/esri/core/workers/chunks/{35fc8a64674005b1d1d7.js → 0a4357af5b8c0532b439.js} +1 -1
- package/assets/esri/core/workers/chunks/{b87ed14fde381f79bc9f.js → 17776d9d3558d45ea7b5.js} +1 -1
- package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +1 -0
- package/assets/esri/core/workers/chunks/{a69e885336eb5d2729fd.js → 3505988ce3839cdbbc98.js} +1 -1
- package/assets/esri/core/workers/chunks/{46ab551bd19e52e73649.js → 3800764932a1c32cb29f.js} +1 -1
- package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +1 -0
- package/assets/esri/core/workers/chunks/{77493aa2118d462612a0.js → 43bd338bb0de375b9bb7.js} +1 -1
- package/assets/esri/core/workers/chunks/{5a016dcd3192d42d363e.js → 5fc414fc2cfc68828c5b.js} +1 -1
- package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js → 659f7e99b2d524ef53fb.js} +2 -2
- package/assets/esri/core/workers/chunks/{037bc400257bc13b3ec8.js → 772e81e9162e2240a7a6.js} +1 -1
- package/assets/esri/core/workers/chunks/81e518dd62bd95611d00.js +1 -0
- package/assets/esri/core/workers/chunks/{f1de768b0a6d345f7e39.js → 8f6ff09e7d2f01b79faf.js} +1 -1
- package/assets/esri/core/workers/chunks/{cfa8b17cf1349f6ed355.js → 9e9be7f6ea32957f1088.js} +1 -1
- package/assets/esri/core/workers/chunks/9fef330b241f958b55df.js +1 -0
- package/assets/esri/core/workers/chunks/aab349d4624b78ef429f.js +1 -0
- package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +1 -0
- package/assets/esri/core/workers/chunks/bcc233a86e01ff1eac16.js +1 -0
- package/assets/esri/core/workers/chunks/cac060a187f3a27a19ba.js +1 -0
- package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +1 -0
- package/assets/esri/core/workers/chunks/{82a390be9500b629f6bc.js → d0bf1fc6e3c198bc565d.js} +1 -1
- package/assets/esri/core/workers/chunks/dd2b5f115d156b5b212e.js +1 -0
- package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +1 -0
- package/assets/esri/core/workers/chunks/f75ddd79be506423be09.js +1 -0
- package/assets/esri/core/workers/chunks/{c5b2a261d8c216ca4a10.js → f8505bf69795f5293a79.js} +1 -1
- package/assets/esri/core/workers/chunks/fae6030a81cb91a91b69.js +1 -0
- package/assets/esri/core/workers/chunks/ff7962063d132c1ec814.js +1 -0
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +23 -19
- package/assets/esri/themes/base/widgets/_Search.scss +12 -0
- 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/config.js +1 -1
- package/identity/OAuthCredential.js +1 -1
- package/interfaces.d.ts +3 -2
- package/kernel.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/sources/WFSSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/ExportImageParameters.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +3 -3
- package/portal/Portal.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/renderers/support/utils.js +1 -1
- package/request.js +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/print.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/draw/Draw.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/layers/support/popupUtils.js +1 -1
- package/views/support/PromiseQueue.js +5 -0
- package/views/support/Scheduler.js +1 -1
- package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
- package/widgets/FloorFilter/css.js +1 -1
- package/widgets/FloorFilter.js +1 -1
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/Search/css.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/support/ItemList.js +1 -1
- package/assets/esri/core/workers/chunks/0874b88d5ae7c2b78b3b.js +0 -1
- package/assets/esri/core/workers/chunks/0c129b78e5cfe96795e1.js +0 -1
- package/assets/esri/core/workers/chunks/1a3a4c2c642899be37a0.js +0 -1
- package/assets/esri/core/workers/chunks/30169cf969d36ea8654e.js +0 -1
- package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +0 -1
- package/assets/esri/core/workers/chunks/48e64f99720907017778.js +0 -1
- package/assets/esri/core/workers/chunks/4d544e3e19ce07c2c195.js +0 -1
- package/assets/esri/core/workers/chunks/8c1bd9bcfc59497de3b5.js +0 -1
- package/assets/esri/core/workers/chunks/8cc700da2ac58849a708.js +0 -1
- package/assets/esri/core/workers/chunks/9b7fee0adffeee8d45ae.js +0 -1
- package/assets/esri/core/workers/chunks/9d30fed26e0d84ef893b.js +0 -1
- package/assets/esri/core/workers/chunks/b29f0b32787edb4e75cf.js +0 -1
- package/assets/esri/core/workers/chunks/c87bb42f825c39f9cce3.js +0 -1
- package/assets/esri/core/workers/chunks/f667096ea325f690c4a6.js +0 -1
- package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +0 -1
- package/layers/graphics/data/executeQueryForSnapping.js +0 -5
- package/layers/support/PromiseQueue.js +0 -5
- /package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js.LICENSE.txt → 659f7e99b2d524ef53fb.js.LICENSE.txt} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as R}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as P}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";const Z=j.reshapeGraphics,X={vertices:{default:new b({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}},Y=Symbol();let q=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=X,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=P.fromGeometry(t,2)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.removeHandles(Y)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=K(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?Q(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,W(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=K(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=$(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=B(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=B(e);let p=G(r);const c=p[a].length-1,l=n.pointToArray(t);p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=G(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(Y),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=G(e.geometry),c=0===h?a+1:h,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=J(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=J(e);for(const a of n){const{x:e,y:t}=a.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[a,h]=s[n];e===a&&t===h&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),Y)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,R(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function K(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function B({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function J(e){return e instanceof t?[e]:[...e]}function Q(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function W(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function $(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],q.prototype,"_activeOperationInfo",void 0),e([y()],q.prototype,"_connectedReshapeManager",void 0),e([y()],q.prototype,"_coordinateHelper",null),e([y()],q.prototype,"_editGeometryOperations",void 0),e([y()],q.prototype,"tooltip",void 0),e([y()],q.prototype,"tooltipInfos",void 0),e([y()],q.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],q.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],q.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],q.prototype,"_selectedVertex",null),e([y()],q.prototype,"_tooltipsContext",null),e([y()],q.prototype,"callbacks",void 0),e([y()],q.prototype,"connectedReshapeProviders",void 0),e([y()],q.prototype,"enableMidpoints",void 0),e([y()],q.prototype,"enableMovement",void 0),e([y()],q.prototype,"enableVertices",void 0),e([y()],q.prototype,"graphic",void 0),e([y()],q.prototype,"highlightName",void 0),e([y()],q.prototype,"highlightsEnabled",void 0),e([y()],q.prototype,"layer",void 0),e([y({readOnly:!0})],q.prototype,"midpointGraphics",void 0),e([y()],q.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],q.prototype,"selectedVertices",void 0),e([y()],q.prototype,"snappingManager",void 0),e([y({readOnly:!0})],q.prototype,"state",null),e([y()],q.prototype,"symbols",void 0),e([y({type:z})],q.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],q.prototype,"type",void 0),e([y({readOnly:!0})],q.prototype,"vertexGraphics",void 0),e([y()],q.prototype,"view",void 0),q=e([_("esri.views.draw.support.Reshape")],q);const ee=q;export{ee as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as R}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as P}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";const Z=j.reshapeGraphics,X={vertices:{default:new b({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}},Y=Symbol();let q=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=X,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=P.fromGeometry(t,2)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=K(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?Q(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,W(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=K(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=$(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=B(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=B(e);let p=G(r);const c=p[a].length-1,l=n.pointToArray(t);p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=G(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(Y),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=G(e.geometry),c=0===h?a+1:h,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=J(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=J(e);for(const a of n){const{x:e,y:t}=a.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[a,h]=s[n];e===a&&t===h&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),Y)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,R(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function K(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function B({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function J(e){return e instanceof t?[e]:[...e]}function Q(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function W(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function $(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],q.prototype,"_activeOperationInfo",void 0),e([y()],q.prototype,"_connectedReshapeManager",void 0),e([y()],q.prototype,"_coordinateHelper",null),e([y()],q.prototype,"_editGeometryOperations",void 0),e([y()],q.prototype,"tooltip",void 0),e([y()],q.prototype,"tooltipInfos",void 0),e([y()],q.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],q.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],q.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],q.prototype,"_selectedVertex",null),e([y()],q.prototype,"_tooltipsContext",null),e([y()],q.prototype,"callbacks",void 0),e([y()],q.prototype,"connectedReshapeProviders",void 0),e([y()],q.prototype,"enableMidpoints",void 0),e([y()],q.prototype,"enableMovement",void 0),e([y()],q.prototype,"enableVertices",void 0),e([y()],q.prototype,"graphic",void 0),e([y()],q.prototype,"highlightName",void 0),e([y()],q.prototype,"highlightsEnabled",void 0),e([y()],q.prototype,"layer",void 0),e([y({readOnly:!0})],q.prototype,"midpointGraphics",void 0),e([y()],q.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],q.prototype,"selectedVertices",void 0),e([y()],q.prototype,"snappingManager",void 0),e([y({readOnly:!0})],q.prototype,"state",null),e([y()],q.prototype,"symbols",void 0),e([y({type:z})],q.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],q.prototype,"type",void 0),e([y({readOnly:!0})],q.prototype,"vertexGraphics",void 0),e([y()],q.prototype,"view",void 0),q=e([_("esri.views.draw.support.Reshape")],q);const ee=q;export{ee 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projectionUtils.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projectionUtils.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as v}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as S}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import j from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import E from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as C}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as I,makeGetGroundElevation as P}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as H}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as U}from"../../../support/Scheduler.js";const x="graphics-collections";let z=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type;if(!o||"map-notes"===t.type)return G();const r=async(o,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(o,r);return G(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return H(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&r?R(r,async(o,r)=>{const s=await e.whenLayerView(t);return i(r),s.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},r)}):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=s(P)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources(e=>this._destroySource(e)),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add(()=>this.getGraphicsLayers(),e=>{this._updatingHandles.removeHandles(x);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",e=>this._onGraphicUpdate(e)),this._updatingHandles.addOnCollectionChange(()=>t.graphics,e=>this._onGraphicsChanged(e))],x)},p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&e.elevationProvider&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()}),l(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),p),d(()=>t,["edits","apply-edits","graphic-update"],()=>this._symbologySnappingFetcher.notifySymbologyChange())])}async fetchCandidates(e,t){const{point:o,coordinateHelper:{spatialReference:r}}=e,s=await n(this._mapSources(o=>this._fetchCandidatesForSource(o,e,t)));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,r),p=s.flat().map(e=>I(e,a));return F(o,p),p}async _fetchCandidatesForSource(e,t,o){const r=A({parameters:t,mode:this.view?.type??"2d"}),s=await e.queryEngine.executeQueryForSnapping(r,o);i(o);const n=await this._snappingElevationAligner.alignCandidates(s.candidates,t.coordinateHelper.spatialReference,o);i(o);const a=await this._symbologySnappingFetcher.fetch(n,o);i(o);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some(t=>t.graphics.includes(e.graphic)))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),o.set(r.uid,r)):this._add(r));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const s=r(async o=>{await m(e.map(e=>({source:e,dest:this.spatialReference})),{signal:o}),this._markLoadedSpatialReferences(e);for(const e of t.values())this._add(e)});this._updatingHandles.addPromise(s.promise);const i={task:s,graphics:t},n=()=>o(this._pendingAdds,i);s.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const o=this._ensureSource(t.type);if(null==o)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(o.featureStore.add(r),C(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const o=f(_(t),this.spatialReference);if(!o)return null;const r=this._ensureGeometryHasZ(o),s=S(r,this._hasZ,!1);return new w(s,{[O]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach(e=>e.forEach(t));break;case"polygon":o.rings.forEach(e=>e.forEach(t))}return o}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=v.toJSON(e),o=this._hasZ,r=new j({geometryType:t,hasZ:o,hasM:!1});return{featureStore:r,queryEngine:new b({featureStore:r,fieldsIndex:E.fromLayerJSON({fields:[{name:O,type:"esriFieldTypeOID",alias:O}]}),geometryType:t,hasM:!1,hasZ:o,featureIdInfo:{type:"object-id",fieldName:O},spatialReference:this.spatialReference,priority:U.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources(t=>this._removeFromSource(t,e));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),C(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:r,multipoint:s}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),null!=s&&i.push(e(s)),i}};e([c()],z.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],z.prototype,"layerSource",void 0),e([c({constructOnly:!0})],z.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],z.prototype,"view",void 0),e([c({readOnly:!0})],z.prototype,"updating",null),e([c({readOnly:!0})],z.prototype,"availability",void 0),e([c()],z.prototype,"_hasZ",null),e([c()],z.prototype,"_snappingElevationAligner",null),e([c()],z.prototype,"_snappingElevationFilter",null),e([c()],z.prototype,"_symbologySnappingFetcher",null),e([c()],z.prototype,"_extrudedPolygonSymbolsCount",void 0),z=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],z);const O="OBJECTID";export{z as GraphicsSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as h}from"../../../../../geometry/support/jsonUtils.js";import
|
|
5
|
+
import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,sync as a,whenOnce as n}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../../core/support/UpdatingHandles.js";import d from"../../../../../geometry/SpatialReference.js";import{fromJSON as h}from"../../../../../geometry/support/jsonUtils.js";import c from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as p}from"../../../../../layers/graphics/data/QueryEngine.js";import f from"../../../../../layers/support/TileInfo.js";import m from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as y}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as _}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as S}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as F}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as v}from"./FeatureServiceTileStore.js";let I=class extends t{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=y(),this._elevationFilter=_(),this._symbologyCandidatesFetcher=S(),this._updatingHandles=new u,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this._isInitializing||this._updatingHandles.updating||this._featureFetcher.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=d.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new c({...e.serviceInfo,hasZ:o,hasM:!1}),this._featureStore.estimateFeatureUsedMemory=e=>e.usedMemory,this._queryEngine=new p({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,featureIdInfo:{type:"object-id",fieldName:i},timeInfo:r}),this._featureFetcher=new F({store:new v({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:d.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const u="3d"===e.configuration.viewType;return this._elevationAligner=y(u,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=_(u),this.addHandles([s(()=>this._featureFetcher.availability,e=>this.emit("notify-availability",{availability:e}),a),s(()=>this.updating,()=>this._notifyUpdating())]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=b(e,this._featureStore.hasZ),s=t?.signal,a=await this._queryEngine.executeQueryForSnapping(i,s);r(s);const n=await this._elevationAligner.alignCandidates(a.candidates,d.fromJSON(e.point.spatialReference)??d.WGS84,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(n,s);r(s);const l=0===o.length?n:n.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?f.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n(()=>!this.updating,t),r(t),j}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async handleEdits(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await this._updatingHandles.addPromise(this._featureFetcher.handleEdits(e)),r(t),j}async setHistoricMoment(e,t){return this._featureFetcher.setHistoricMoment(e.moment),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=S(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?m.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],I.prototype,"updating",null),e([o()],I.prototype,"_isInitializing",void 0),I=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],I);const w=I;function b(e,t){const i=!!t||void 0;if(!e.filter)return{...e,query:{where:"1=1",returnZ:i}};const{distance:r,units:s,spatialRel:a,where:n,timeExtent:o,objectIds:l}=e.filter,u={geometry:e.filter.geometry?h(e.filter.geometry):void 0,distance:r,units:s,spatialRel:a,timeExtent:o,objectIds:l,returnZ:i,where:n??"1=1"};return{...e,query:u}}const j={result:{}};export{w 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o
|
|
5
|
+
import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o?.forEach(e=>{const{keyField:l}=e;f&&l&&p.fieldsIndex?.has(l)&&!f.includes(l)&&f.push(l)}),f}function n(e,l){return e&&"object"==typeof e?l?.checkPopupEnabled&&"popupEnabled"in e&&!e.popupEnabled?null:"popupTemplate"in e&&e.popupTemplate?e.popupTemplate:null!=l&&l.defaultPopupTemplateEnabled&&"defaultPopupTemplate"in e&&e.defaultPopupTemplate?e.defaultPopupTemplate:null:null}function u(e,l){return null!=n(e,{defaultPopupTemplateEnabled:l})}export{n as getFetchPopupTemplate,p as getRequiredFields,u as hasPopupTemplate};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Logger.js";import{isAborted as s,createAbortError as r,isPromiseLike as o}from"../../core/promiseUtils.js";import{signal as a}from"../../core/signal.js";import{Yield as n}from"./Yield.js";class i{constructor(){this._tasks=new Array,this._numPendingTasks=a(0),this._readyToRun=a(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return n;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new p(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const o=this._tasks.shift();this._updateReadyToRun();try{if(s(o.signal))this._cancelTask(o,r());else switch(o.type){case 0:this._processSimple(o,e);break;case 1:this._processGenerator(o,e);break;case 2:this._processIterator(o,e);break;default:t(o)}}catch(a){o.reject(a)}return!0}cancelAll(){const t=r();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&c(t.iterator.return()),o(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&c(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);o(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new d(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);o(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function c(t){o(t)?t.then(h):h(t)}function h(t){t.done||e.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class l{constructor(t,e,s=void 0,r=void 0){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class u extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class p extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class d extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{i as PromiseQueue};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as h,when as _,isPromiseLike as u}from"../../core/promiseUtils.js";import{watch as o,initial as d,when as E}from"../../core/reactiveUtils.js";import{signal as l}from"../../core/signal.js";import{Milliseconds as c}from"../../core/time.js";import{PromiseQueue as T}from"../../layers/support/PromiseQueue.js";import m from"./debugFlags.js";import{Yield as g}from"./Yield.js";function R(){return new U}const I={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"Graphics3D filter visibility",SCALE_VISIBILITY:"Graphics3D scale visibility",FRUSTUM_VISIBILITY:"Graphics3D frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},p=0,f=new Map([[I.RESOURCE_CONTROLLER_IMMEDIATE,p],[I.RESOURCE_CONTROLLER,4],[I.SLIDE,p],[I.STREAM_DATA_LOADER,p],[I.ELEVATION_QUERY,p],[I.TERRAIN_SURFACE,1],[I.SURFACE_GEOMETRY_UPDATES,1],[I.LOD_RENDERER,2],[I.GRAPHICS_CORE,2],[I.I3S_CONTROLLER,2],[I.POINT_CLOUD_LAYER,2],[I.FEATURE_TILE_FETCHER,2],[I.STREAM_CONTROLLER,2],[I.CLOUDS_GENERATOR,2],[I.OVERLAY,4],[I.OVERLAY_RENDERER,4],[I.STAGE,4],[I.GRAPHICS_DECONFLICTOR,4],[I.FILTER_VISIBILITY,4],[I.SCALE_VISIBILITY,4],[I.FRUSTUM_VISIBILITY,4],[I.POINT_OF_INTEREST_FREQUENT,6],[I.POINT_OF_INTEREST_INFREQUENT,30],[I.LABELER,8],[I.FEATURE_QUERY_ENGINE,8],[I.FEATURE_TILE_TREE,16],[I.FEATURE_TILE_TREE_ACTIVE,p],[I.ELEVATION_ALIGNMENT,12],[I.ELEVATION_ALIGNMENT_SCENE,14],[I.TEXT_TEXTURE_ATLAS,12],[I.TEXTURE_UNLOAD,12],[I.LINE_OF_SIGHT_TOOL,16],[I.LINE_OF_SIGHT_TOOL_INTERACTIVE,p],[I.SNAPPING,p],[I.SHADOW_ACCUMULATOR,30],[I.FLOW_GENERATOR,12],[I.MAPVIEW_FETCH_QUEUE,p],[I.MAPVIEW_LAYERVIEW_UPDATE,2],[I.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,p]]);function L(e){return f.has(e)?f.get(e):"number"==typeof e?e:1}const A=c(6.5),O=c(1),b=c(30),N=c(1e3/30),S=c(100),k=.9;class U{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=l(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new P,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=o(()=>m.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,d);for(const e of Object.keys(I))this.performanceInfo.tasks.set(I[e],new a(String(I[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new C(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=A,s=e.frameDuration,r=O;switch(this.state){case 2:t=c(0),s=c(Math.max(S,e.frameDuration)),r=b;break;case 1:s=c(Math.max(N,e.frameDuration))}return s=c(s-e.elapsedFrameTime-t),2!==this.state&&s<O&&!this._forceTask?(this._forceTask=!0,!1):(s=c(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(c(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*k+e*(1-k)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===p&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==p&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===g&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,I.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(I))this._frameTaskTimes.set(I[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class C{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new T,this._handles=new s,this._basePriority=L(t),this.schedulePriority=this._basePriority,this._task=l(null!=r?r:this._queue),this._handles.add(E(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(F),this._scheduler.removeTask(this),this.schedule=G.schedule,this.reschedule=G.reschedule,this.scheduleGenerator=G.scheduleGenerator,this.rescheduleGenerator=G.rescheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=L(e);this._basePriority!==p&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}rescheduleGenerator(e,t,s){return this._queue.unshiftGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class P{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const F=new P;function y(e){const t=new P;return t.reset(e),t}F.enabled=!1;class w{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=h();return s?Promise.resolve(s(e)):Promise.reject(e)}return _(e(F))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(n(t)){const e=h();if(s)return s(e);throw e}const r=e(F);for(;;){const e=r.next(F),i=u(e)?await e:e;if(n(t)){const e=h();if(s)return s(e);throw e}if(i.done)return i.value}}rescheduleGenerator(e,t,s){return this.rescheduleGenerator(e,t,s)}}const G=new w;export{G as ImmediateTask,I as TaskPriority,L as getTaskPriority,y as makeBudget,R as newScheduler,F as noBudget,f as taskPriorities};
|
|
5
|
+
import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as _,when as h,isPromiseLike as u}from"../../core/promiseUtils.js";import{watch as o,initial as d,when as E}from"../../core/reactiveUtils.js";import{signal as l}from"../../core/signal.js";import{Milliseconds as T}from"../../core/time.js";import c from"./debugFlags.js";import{PromiseQueue as m}from"./PromiseQueue.js";import{Yield as g}from"./Yield.js";function R(){return new U}const I={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"Graphics3D filter visibility",SCALE_VISIBILITY:"Graphics3D scale visibility",FRUSTUM_VISIBILITY:"Graphics3D frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},p=0,f=new Map([[I.RESOURCE_CONTROLLER_IMMEDIATE,p],[I.RESOURCE_CONTROLLER,4],[I.SLIDE,p],[I.STREAM_DATA_LOADER,p],[I.ELEVATION_QUERY,p],[I.TERRAIN_SURFACE,1],[I.SURFACE_GEOMETRY_UPDATES,1],[I.LOD_RENDERER,2],[I.GRAPHICS_CORE,2],[I.I3S_CONTROLLER,2],[I.POINT_CLOUD_LAYER,2],[I.FEATURE_TILE_FETCHER,2],[I.STREAM_CONTROLLER,2],[I.CLOUDS_GENERATOR,2],[I.OVERLAY,4],[I.OVERLAY_RENDERER,4],[I.STAGE,4],[I.GRAPHICS_DECONFLICTOR,4],[I.FILTER_VISIBILITY,4],[I.SCALE_VISIBILITY,4],[I.FRUSTUM_VISIBILITY,4],[I.POINT_OF_INTEREST_FREQUENT,6],[I.POINT_OF_INTEREST_INFREQUENT,30],[I.LABELER,8],[I.FEATURE_QUERY_ENGINE,8],[I.FEATURE_TILE_TREE,16],[I.FEATURE_TILE_TREE_ACTIVE,p],[I.ELEVATION_ALIGNMENT,12],[I.ELEVATION_ALIGNMENT_SCENE,14],[I.TEXT_TEXTURE_ATLAS,12],[I.TEXTURE_UNLOAD,12],[I.LINE_OF_SIGHT_TOOL,16],[I.LINE_OF_SIGHT_TOOL_INTERACTIVE,p],[I.SNAPPING,p],[I.SHADOW_ACCUMULATOR,30],[I.FLOW_GENERATOR,12],[I.MAPVIEW_FETCH_QUEUE,p],[I.MAPVIEW_LAYERVIEW_UPDATE,2],[I.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,p]]);function L(e){return f.has(e)?f.get(e):"number"==typeof e?e:1}const A=T(6.5),O=T(1),b=T(30),N=T(1e3/30),S=T(100),k=.9;class U{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=l(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new P,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=o(()=>c.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,d);for(const e of Object.keys(I))this.performanceInfo.tasks.set(I[e],new a(String(I[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new C(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=A,s=e.frameDuration,r=O;switch(this.state){case 2:t=T(0),s=T(Math.max(S,e.frameDuration)),r=b;break;case 1:s=T(Math.max(N,e.frameDuration))}return s=T(s-e.elapsedFrameTime-t),2!==this.state&&s<O&&!this._forceTask?(this._forceTask=!0,!1):(s=T(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(T(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*k+e*(1-k)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===p&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==p&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===g&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,I.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(I))this._frameTaskTimes.set(I[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class C{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new m,this._handles=new s,this._basePriority=L(t),this.schedulePriority=this._basePriority,this._task=l(null!=r?r:this._queue),this._handles.add(E(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(F),this._scheduler.removeTask(this),this.schedule=D.schedule,this.reschedule=D.reschedule,this.scheduleGenerator=D.scheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=L(e);this._basePriority!==p&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class P{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const F=new P;function y(e){const t=new P;return t.reset(e),t}F.enabled=!1;class w{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(F))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(n(t)){const e=_();if(s)return s(e);throw e}const r=e(F);for(;;){const e=r.next(F),i=u(e)?await e:e;if(n(t)){const e=_();if(s){const t=s(e);return r.return(null),t}throw r.throw(e),e}if(i.done)return i.value}}}const D=new w;export{D as ImmediateTask,I as TaskPriority,L as getTaskPriority,y as makeBudget,R as newScheduler,F as noBudget,f as taskPriorities};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{renderingSanitizer as t}from"../../../../core/sanitizerUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../Widget.js";import i from"./ButtonMenuViewModel.js";import{loadCalciteComponents as r}from"../../../support/componentsUtils.js";import{globalCss as l}from"../../../support/globalCss.js";import{storeNode as a,isActivationKey as d}from"../../../support/widgetUtils.js";import{tsx as p}from"../../../support/jsxFactory.js";const c="esri-button-menu",m={base:c,content:`${c}__content`,itemWrapper:`${c}__item-wrapper`,icon:`${c}__icon`,item:`${c}__item`,itemLabel:`${c}__item-label`,itemLabelContent:`${c}__item-label-content`,selectableMenuItem:`${c}__item--selectable`,selectedMenuItem:`${c}__item--selected`,checkbox:`${c}__checkbox`,embeddedContentWrapper:`${c}__embedded-content-wrapper`,button:`${c}__button`,buttonSelected:`${c}__button--selected`};let u=class extends s{constructor(e,t){super(e,t),this._popover=null,this.disabled=!1,this.viewModel=new i}loadDependencies(){return r({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._popover=null}get items(){return this.viewModel.items}set items(e){this.viewModel.items=e}get open(){return this.viewModel.open}set open(e){this.viewModel.open=e}render(){const{open:e}=this,t=`${this.id}-button`;return p("div",{class:this.classes(m.base,l.widget),key:"menu"},p("calcite-button",{appearance:"transparent",bind:this,class:this.classes(m.button,e&&m.buttonSelected),disabled:this.disabled,iconStart:e?"x":"ellipsis",id:t,kind:"neutral",label:this.label||"button",onclick:()=>this._toggleOpen(e),tabIndex:0}),p("calcite-popover",{afterCreate:a,afterUpdate:()=>this._popover?.reposition(),autoClose:!0,bind:this,"data-node-ref":"_popover",label:this.label||"menu",open:e,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:t,onCalcitePopoverClose:this._onPopoverClose},this._renderMenuContent()))}_onPopoverClose(){this.open=!1}_renderMenuContent(){const{id:e,open:t}=this;return p("div",{afterCreate:this._afterMenuContentNodeCreate,bind:this,class:m.content,hidden:!t,key:"esri-button-menu-content"},p("ul",{"aria-labelledby":`${e}-button`,bind:this,class:m.itemWrapper,id:`${e}-menu`,role:"menu"},this.items?.length?this._renderItems():null))}_renderItems(){return this.items?.map((e,t)=>this._renderItem(e,t))}_renderItem(e,o,n){const s=null!=n?`${this.id}-menu-item-${o}-${n}`:`${this.id}-menu-item-${o}`,i=`${s}-label`,r=this.classes(m.item,e.selectionEnabled?m.selectableMenuItem:null,e.selectionEnabled&&e.selected?m.selectedMenuItem:null);return p("li",{afterCreate:this._afterMenuItemCreate,bind:this,class:r,"data-item-index":o,"data-item-subIndex":n,for:s,key:s,onclick:t=>this._handleMenuItemInteraction(t,e),onkeydown:t=>this._handleMenuItemKeydown(t,e),role:"menuitem",tabIndex:this.disabled?-1:0},p("input",{checked:e.selected,class:m.checkbox,disabled:!0,id:s,name:s,tabIndex:-1,type:"checkbox"}),p("label",{class:m.itemLabel,for:s,id:i},p("span",{"aria-hidden":"true",class:m.icon}),p("span",{class:m.itemLabelContent},t.sanitize(e.label))),p("ul",{"aria-labelledby":i,class:m.embeddedContentWrapper,id:`${this.id}-submenu`,role:"menu"},e?.items?.map((e,t)=>this._renderItem(e,o,t))))}_handleMenuItemInteraction(e,t){t.selected=!t.selected,t.open=!(!t.selected||!t.items),t.autoCloseMenu&&this.set("open",!1),t.clickFunction
|
|
5
|
+
import{__decorate as e}from"tslib";import{renderingSanitizer as t}from"../../../../core/sanitizerUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../Widget.js";import i from"./ButtonMenuViewModel.js";import{loadCalciteComponents as r}from"../../../support/componentsUtils.js";import{globalCss as l}from"../../../support/globalCss.js";import{storeNode as a,isActivationKey as d}from"../../../support/widgetUtils.js";import{tsx as p}from"../../../support/jsxFactory.js";const c="esri-button-menu",m={base:c,content:`${c}__content`,itemWrapper:`${c}__item-wrapper`,icon:`${c}__icon`,item:`${c}__item`,itemLabel:`${c}__item-label`,itemLabelContent:`${c}__item-label-content`,selectableMenuItem:`${c}__item--selectable`,selectedMenuItem:`${c}__item--selected`,checkbox:`${c}__checkbox`,embeddedContentWrapper:`${c}__embedded-content-wrapper`,button:`${c}__button`,buttonSelected:`${c}__button--selected`};let u=class extends s{constructor(e,t){super(e,t),this._popover=null,this.disabled=!1,this.viewModel=new i}loadDependencies(){return r({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._popover=null}get items(){return this.viewModel.items}set items(e){this.viewModel.items=e}get open(){return this.viewModel.open}set open(e){this.viewModel.open=e}render(){const{open:e}=this,t=`${this.id}-button`;return p("div",{class:this.classes(m.base,l.widget),key:"menu"},p("calcite-button",{appearance:"transparent",bind:this,class:this.classes(m.button,e&&m.buttonSelected),disabled:this.disabled,iconStart:e?"x":"ellipsis",id:t,kind:"neutral",label:this.label||"button",onclick:()=>this._toggleOpen(e),tabIndex:0}),p("calcite-popover",{afterCreate:a,afterUpdate:()=>this._popover?.reposition(),autoClose:!0,bind:this,"data-node-ref":"_popover",label:this.label||"menu",open:e,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:t,onCalcitePopoverClose:this._onPopoverClose},this._renderMenuContent()))}_onPopoverClose(){this.open=!1}_renderMenuContent(){const{id:e,open:t}=this;return p("div",{afterCreate:this._afterMenuContentNodeCreate,bind:this,class:m.content,hidden:!t,key:"esri-button-menu-content"},p("ul",{"aria-labelledby":`${e}-button`,bind:this,class:m.itemWrapper,id:`${e}-menu`,role:"menu"},this.items?.length?this._renderItems():null))}_renderItems(){return this.items?.map((e,t)=>this._renderItem(e,t))}_renderItem(e,o,n){const s=null!=n?`${this.id}-menu-item-${o}-${n}`:`${this.id}-menu-item-${o}`,i=`${s}-label`,r=this.classes(m.item,e.selectionEnabled?m.selectableMenuItem:null,e.selectionEnabled&&e.selected?m.selectedMenuItem:null);return p("li",{afterCreate:this._afterMenuItemCreate,bind:this,class:r,"data-item-index":o,"data-item-subIndex":n,for:s,key:s,onclick:t=>this._handleMenuItemInteraction(t,e),onkeydown:t=>this._handleMenuItemKeydown(t,e),role:"menuitem",tabIndex:this.disabled?-1:0},p("input",{checked:e.selected,class:m.checkbox,disabled:!0,id:s,name:s,tabIndex:-1,type:"checkbox"}),p("label",{class:m.itemLabel,for:s,id:i},p("span",{"aria-hidden":"true",class:m.icon}),p("span",{class:m.itemLabelContent},t.sanitize(e.label))),p("ul",{"aria-labelledby":i,class:m.embeddedContentWrapper,id:`${this.id}-submenu`,role:"menu"},e?.items?.map((e,t)=>this._renderItem(e,o,t))))}_handleMenuItemInteraction(e,t){t.selected=!t.selected,t.open=!(!t.selected||!t.items),t.autoCloseMenu&&this.set("open",!1),t.clickFunction?.({event:e,item:t}),e.stopPropagation()}_handleMenuItemKeydown(e,t){const{key:o}=e;d(o)&&this._handleMenuItemInteraction(e,t),"Escape"===o&&(this.open=!1,e.preventDefault(),e.stopPropagation())}_afterMenuContentNodeCreate(e){e.focus()}_toggleOpen(e){this.open=!e}_afterMenuItemCreate(e){0===e["data-item-index"]&&e.focus()}};e([o()],u.prototype,"disabled",void 0),e([o()],u.prototype,"items",null),e([o()],u.prototype,"open",null),e([o()],u.prototype,"viewModel",void 0),u=e([n("esri.widgets.FeatureTable.Grid.support.ButtonMenu")],u);const b=u;export{b 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-floor-filter",t=`${e}__filter-menu`,o={floorFilter:e,floorFilterLayout:`${e}__layout--`,floorFilterPosition:`${e}__position--`,buttonContainer:`${e}__button-container`,buttonContainerLevels:`${e}__button-container--levels`,buttonInfo:`${e}__button-info`,buttonLabel:`${e}__button-label`,browseButton:`${e}__browse-button`,closeLevelsButton:`${e}__close-levels-button`,zoomButton:`${e}__zoom-button`,zoomButtonLevels:`${e}__zoom-button--levels`,minimizeToggleButton:`${e}__minimize-toggle-button`,levelsContainer:`${e}__levels-container`,levelButton:`${e}__level-button`,levelButtonActive:`${e}__level-button--active`,iconFlip
|
|
5
|
+
const e="esri-floor-filter",t=`${e}__filter-menu`,o={floorFilter:e,floorFilterLayout:`${e}__layout--`,floorFilterPosition:`${e}__position--`,buttonContainer:`${e}__button-container`,buttonContainerLevels:`${e}__button-container--levels`,buttonInfo:`${e}__button-info`,buttonLabel:`${e}__button-label`,browseButton:`${e}__browse-button`,closeLevelsButton:`${e}__close-levels-button`,zoomButton:`${e}__zoom-button`,zoomButtonLevels:`${e}__zoom-button--levels`,minimizeToggleButton:`${e}__minimize-toggle-button`,levelsContainer:`${e}__levels-container`,levelButton:`${e}__level-button`,levelButtonActive:`${e}__level-button--active`,iconClose:`${e}__icon-close`,iconFlip:`${e}__icon-flip`,iconLeft:`${e}__icon-left`,iconRight:`${e}__icon-right`,separator:`${e}__separator`,filterMenu:t,filterMenuHeader:`${t}-header`,filterMenuHeaderTextGroup:`${t}-header-text-group`,filterMenuHeaderText:`${t}-header-text`,filterMenuHeaderSubtext:`${t}-header-subtext`,filterMenuHeaderBack:`${t}-header-back`,filterMenuSearch:`${t}-search`,filterMenuSearchInput:`${t}-search-input`,filterMenuItems:`${t}-items`,filterMenuItemName:`${t}-item-name`,filterMenuSelectedItem:`${t}-item-name--selected`,filterMenuSite:`${t}-site`,filterMenuFacility:`${t}-facility`,selectedItemCircle:`${e}__selected-item-circle`};export{o as css};
|
package/widgets/FloorFilter.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../intl.js";import{watch as t}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{css as o}from"./FloorFilter/css.js";import n from"./FloorFilter/FloorFilterViewModel.js";import{globalCss as r}from"./support/globalCss.js";import{Heading as a,incrementHeadingLevel as c}from"./support/Heading.js";import{legacyIcon as h}from"./support/legacyIcon.js";import{isRTL as d,storeNode as u}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{substitute as p}from"../intl/substitute.js";const M=new Set(["ArrowUp","ArrowDown","End","Home"]);let f=class extends l{constructor(e,s){super(e,s),this._activeMenu=null,this._activeMenuIndex={levels:-1,menuItems:-1},this._baseNode=null,this._facilitiesListNode=null,this._levelsListNode=null,this._sitesListNode=null,this._searchInput=null,this.viewModel=new n,this.messages=null,this.messagesCommon=null,this.headingLevel=2,this._resizeObserver=new ResizeObserver(()=>this.scheduleRender()),this.addHandles(t(()=>this._searchInput,()=>this._focusSearch()))}destroy(){this._resizeObserver?.disconnect()}get enabled(){return this.viewModel.enabled}set enabled(e){this.viewModel.enabled=e}get longNames(){return this.viewModel.longNames}set longNames(e){this.viewModel.longNames=e}get minimized(){return this.viewModel.minimized}set minimized(e){this.viewModel.minimized=e}get pinnedLevels(){return this.viewModel.pinnedLevels}set pinnedLevels(e){this.viewModel.pinnedLevels=e}get site(){return this.viewModel.site}set site(e){this.viewModel.site=e}get facility(){return this.viewModel.facility}set facility(e){this.viewModel.facility=e}get level(){return this.viewModel.level}set level(e){this.viewModel.level=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"floor-plan"}set icon(e){this._overrideIfSome("icon",e)}updateWebDocument(e){return this.viewModel.updateWebDocument(e)}render(){const{longNames:e}=this,t=e&&this.viewModel.isNormalMode?"expanded":"collapsed",s=this._renderButtons(),i=this._renderFilterMenu(),l=m("div",{class:this.classes(o.separator)}),n=this._getComponentPosition(),a=this._getPosition(n),c="top-right"===n||"bottom-right"===n,h="top-left"===n||"bottom-left"===n,u=d(this.container),v=u&&h||!u&&c?i:s,p=u&&h||!u&&c?s:i;return m("div",{afterCreate:this._afterBaseNodeCreate,class:this.classes(o.floorFilter,r.widget,`${o.floorFilterLayout}${t}`,`${o.floorFilterPosition}${a}`),key:"floor-filter-menu"},v,this.viewModel?.filterMenuOpen?l:null,p)}_renderButtons(){const e=this._getComponentPosition(),t=[];return"top"===this._getPosition(e)?(t.push(this._renderBrowseButton()),t.push(this._renderLevelButtons()),t.push(this._renderCloseLevelsButton()),t.push(this._renderZoomButton()),t.push(this._renderCollapseToggleButton())):(t.push(this._renderCollapseToggleButton()),t.push(this._renderZoomButton()),t.push(this._renderCloseLevelsButton()),t.push(this._renderLevelButtons()),t.push(this._renderBrowseButton())),m("div",{class:this.classes(r.widget,o.buttonContainer),key:"button-container"},t)}_renderBrowseButton(){const{longNames:e,messages:t}=this;return m("button",{"aria-expanded":this.viewModel.filterMenuOpen.toString(),"aria-label":t.buttons.browse,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,("loading"===this.viewModel.state||"disabled"===this.viewModel.state)&&r.buttonDisabled,o.browseButton,this.viewModel?.filterMenuOpen&&r.widgetButtonActive),key:"browse-button",onclick:this._toggleFilterMenu,title:t.buttons.browse,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.urbanModel)}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.browse:null)))}_renderLevelButtons(){if(!this.viewModel?.filterFeatures?.levels?.levelsInfo||!this.facility)return null;const{facility:e,messagesCommon:t,messages:s}=this,i=this.viewModel?.getFacility(e),l=this.viewModel?.getFacilityLevels(e),n=l.map(e=>this._renderLevelButton(e));if(!n.length)return null;const r=i&&p(s.selector.levelsLabel,{name:`"${i.name}"`});if(this._isWebScene(this.view?.map)&&n?.length>1){const s={id:`all--${e}`,facilityId:e,shortName:t.all,longName:t.all,levelNumber:null,verticalOrder:null},i=this._renderLevelButton(s);n.push(i)}return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.levelsContainer),"data-id":"levels","data-node-ref":"_levelsListNode",key:"levels-button-container",onkeydown:this._handleListKeydown},n)}_renderLevelButton(e){const{longNames:t}=this,{shortName:s,longName:i,id:l}=e,n=`levels--${l}`,a=this.level===l,c=t&&this.viewModel.isNormalMode?i:s;return this.viewModel.isNormalMode||a||this.viewModel.levelsExpanded?m("li",{key:n},m("button",{bind:this,class:this.classes(r.widgetButton,a?r.widgetButtonActive:null,r.interactive,o.levelButton),"data-id":l,"data-list-id":"levels",onclick:this._levelSelected,onfocus:this._onItemFocus,type:"button"},c)):null}_renderCloseLevelsButton(){if(!this.level||this.viewModel.isNormalMode||!this.viewModel.levelsExpanded)return null;const{messagesCommon:e}=this;return m("button",{"aria-label":e.close,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,o.closeLevelsButton),key:"close-levels-button",onclick:this._closeLevels,title:e.close,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.close)})))}_renderZoomButton(){const{longNames:e,messages:t,facility:s,site:i}=this,l=this.viewModel?.filterMenuType,n=this.viewModel?.filterMenuOpen,a=this.viewModel?.getSite(i),c=this.viewModel?.getFacility(s),d="site"===l&&n?!a:!c;return m("button",{"aria-label":t.buttons.zoomTo,bind:this,class:this.classes(r.widget,r.widgetButton,d&&r.buttonDisabled,r.interactive,this.viewModel?.getFacilityLevels(s).length>0?o.zoomButtonLevels:o.zoomButton),key:"zoom-button",onclick:this._zoomToClicked,title:t.buttons.zoomTo,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:this.classes(h.icon,h.zoomToObject)}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.zoomTo:null)))}_renderCollapseToggleButton(){const{longNames:e,messagesCommon:t}=this,s=e?h.collapse:h.expand,i=this.classes(h.icon,s,o.iconFlip),l=e?t.collapse:t.expand;return m("button",{"aria-label":l,bind:this,class:this.classes(r.widget,r.widgetButton,r.interactive,o.minimizeToggleButton),key:"minimize-toggle-button",onclick:this._toggleCollapsed,title:l,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("span",{class:i}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.collapse:null)))}_renderFilterMenu(){return this.viewModel?.filterMenuOpen?"site"===this.viewModel?.filterMenuType?this._renderSiteFilterMenu():"facility"===this.viewModel?.filterMenuType?this._renderFacilityFilterMenu():null:null}_renderSiteFilterMenu(){const{messages:e,messagesCommon:t}=this,s=this.site?this.viewModel?.getSite(this.site)?.name:e.selector.selectSite,i=m("div",{class:this.classes(`${o.filterMenuHeader}`),key:"filter-menu-site-header"},m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(a,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},s)),m("button",{bind:this,class:this.classes(h.icon,h.close),onclick:this._closeClicked,title:t.close,type:"button"})),l=this._renderSearchInput(),n=this._renderSiteItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-site"},i,l,n)}_renderFacilityFilterMenu(){const{messages:e,messagesCommon:t,site:s}=this,i=this.viewModel?.getSite(s)?.name,l=this.facility&&this.viewModel?.getFacility(this.facility)?.name||e.selector.selectFacility,n=this.viewModel.hasMultipleSites?m("button",{bind:this,class:this.classes(o.filterMenuHeaderBack),onclick:this._backClicked,title:t.back,type:"button"},m("span",{class:this.classes(d(this.container)?h.right:h.left)})):null,r=this.viewModel.hasMultipleSites?m(a,{class:this.classes(o.filterMenuHeaderSubtext),level:c(this.headingLevel)},i):null,u=m("div",{class:this.classes(o.filterMenuHeader),key:"filter-menu-site-header"},n,m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(a,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},l),r),m("button",{bind:this,class:this.classes(h.icon,h.close),onclick:this._closeClicked,title:t.close,type:"button"})),v=this._renderSearchInput(),p=this._renderFacilityItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-facility"},u,v,p)}_renderSearchInput(){const{messagesCommon:e}=this,t=!!(this.viewModel.searchTerm&&this.viewModel.searchTerm?.length>0);return m("div",{class:this.classes(o.filterMenuSearch),key:"filter-menu-search"},m("span",{class:this.classes(h.icon,h.search),key:"filter-menu-search-icon"}),m("input",{afterCreate:u,bind:this,class:this.classes(o.filterMenuSearchInput),"data-node-ref":"_searchInput",oninput:this._onSearchChange,onpaste:this._onSearchChange,placeholder:e.search,value:this.viewModel.searchTerm??void 0}),t?m("span",{bind:this,class:this.classes(h.icon,h.close),key:"filter-menu-search-clear",onclick:this._onSearchClear,title:e.clear}):null)}_renderBlueCircle(){return m("span",{class:this.classes(o.selectedItemCircle),key:"floor-filter__selected-item-circle"})}_renderSiteItems(){if(!this.viewModel?.filterFeatures?.sites?.sitesInfo)return null;const{messages:e}=this,t=this.viewModel.filterFeatures.sites.sitesInfo,s=this.viewModel.filterSites(t).map(e=>this._renderSiteItem(e)),i=0===s.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(r.empty)},e.noResults);return m("ul",{afterCreate:u,"aria-label":e.selector.sitesLabel,bind:this,class:this.classes(o.filterMenuItems),"data-id":"sites","data-node-ref":"_sitesListNode",key:"filter-menu-items--sites",onkeydown:this._handleListKeydown,tabIndex:-1},s,i)}_renderSiteItem(e){const{name:t,id:s}=e,i=`filter-menu-site--${s}`,l=this.site===s;return m("li",{key:i},m("button",{bind:this,class:this.classes(o.filterMenuSite),"data-id":s,"data-list-id":"sites",onclick:this._siteSelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t),m("span",{class:this.classes(d(this.container)?h.left:h.right)})))}_renderFacilityItems(){if(!this.viewModel?.filterFeatures?.facilities?.facilitiesInfo)return null;const{messages:e,site:t}=this,s=this.viewModel.getSite(t),i=this.viewModel.filterFeatures.facilities.facilitiesInfo,l=this.viewModel.filterFacilities(i).map(e=>this._renderFacilityItem(e)),n=0===l.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(r.empty)},e.noResults),a=s?p(e.selector.siteFacilitiesLabel,{name:`"${s.name}"`}):e.selector.facilitiesLabel;return m("ul",{afterCreate:u,"aria-label":a,bind:this,class:this.classes(o.filterMenuItems),"data-id":"facilities","data-node-ref":"_facilitiesListNode",key:"filter-menu-items--facilities",onkeydown:this._handleListKeydown,tabIndex:-1},l,n)}_renderFacilityItem(e){const{name:t,id:s}=e,i=`filter-menu-facility--${s}`,l=this.facility===s;return m("li",{key:i},m("button",{bind:this,class:this.classes(o.filterMenuFacility),"data-id":s,"data-list-id":"facilities",onclick:this._facilitySelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t)))}_afterBaseNodeCreate(e){this._baseNode&&this._resizeObserver?.unobserve(this._baseNode),this._baseNode=e,this._resizeObserver?.observe(this._baseNode)}_toggleCollapsed(){this.longNames=!this.longNames}_toggleFilterMenu(){const e=this.viewModel?.filterMenuOpen??!1;this.viewModel.filterMenuOpen=!e}_setFilterMenuType(e){this.viewModel.filterMenuType=e}_zoomToClicked(){if(this.site&&"site"===this.viewModel?.filterMenuType&&this.viewModel?.filterMenuOpen){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}else if(this.facility){const e=this.viewModel?.getFacility(this.facility);this.viewModel.goTo(e)}else if(this.site){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}}_onSearchChange(e){const t=e.target;""===t.value?this.viewModel.searchTerm=null:t.value&&this.viewModel?.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value)}_onSearchClear(){this.viewModel.searchTerm=null}_closeClicked(){this.viewModel.searchTerm=null,this.viewModel.filterMenuOpen=!1}_backClicked(){this._setFilterMenuType("site"),this.viewModel.searchTerm=null}_siteSelected(e){const t=e.currentTarget.getAttribute("data-id"),s=this.viewModel.getSite(t);let i=!1;this.site!==t&&(this.facility=null,this.level=null,i=!0,this.viewModel.levelsExpanded=!1),this.site=t,this.viewModel.searchTerm=null,this._setFilterMenuType("facility"),this.viewModel.goTo(s),i&&this.viewModel.setFloors(null)}_facilitySelected(e){const t=e.currentTarget.getAttribute("data-id"),s=this.viewModel.getFacility(t);let i=!1;if(this.facility!==t){if("base-floors"===this.viewModel.filterMode){const e=this.viewModel?.getBaseLevel(s);this.level=e?e.id:null}else this.level=null;i=!0,this.viewModel.levelsExpanded=!1}if(this.facility=t,this.viewModel.goTo(s),i){const e=this.viewModel.getLevel(this.level);this.viewModel.setFloors(e)}if(!this.viewModel.isNormalMode){const e=this.viewModel.getFacilityLevels(t);e?.length>1&&(this.viewModel.levelsExpanded=!0)}setTimeout(()=>this._focusActiveLevel(),50)}_levelSelected(e){const t=e.currentTarget.getAttribute("data-id");this.level=t}_closeLevels(){this.viewModel.levelsExpanded=!1}_isWebScene(e){return"esri.WebScene"===e?.declaredClass}_getComponentPosition(){return null!=this.container?this.view?.ui?.getPosition(this.container):null}_getPosition(e){switch(e){case"bottom-right":case"bottom-left":return"bottom";default:return"top"}}_handleListKeydown(e){const t=e.currentTarget.getAttribute("data-id");let s=null;"sites"===t||"facilities"===t?(this._activeMenu!==t&&(this._activeMenuIndex.menuItems=-1),this._activeMenu=t,s="menuItems"):"levels"===t&&(s="levels");const i="sites"===t?this._sitesListNode:"facilities"===t?this._facilitiesListNode:"levels"===t?this._levelsListNode:null,{key:l}=e,o="Tab"===l,n=M.has(l);n&&e.preventDefault();const r=i?.getElementsByTagName("li");r&&0!==r.length&&(n||o)&&this._handleItemNavigation(l,e.shiftKey,r,o,s)}_handleItemNavigation(e,t,s,i,l){if(!l)return;this._activeMenuIndex[l]===s.length&&this._activeMenuIndex[l]--,-1===this._activeMenuIndex[l]&&this._activeMenuIndex[l]++;const o=this._activeMenuIndex[l];switch(e){case"Home":this._activeMenuIndex[l]=0;break;case"End":this._activeMenuIndex[l]=s.length-1;break;case"ArrowUp":this._activeMenuIndex[l]=this._activeMenuIndex[l]<=0?s.length-1:this._activeMenuIndex[l]-1;break;case"ArrowDown":this._activeMenuIndex[l]=this._activeMenuIndex[l]===s.length-1?0:this._activeMenuIndex[l]+1}if("Tab"===e&&t&&this._activeMenuIndex[l]>=0&&this._activeMenuIndex[l]--,"Tab"===e&&!t&&this._activeMenuIndex[l]<s.length&&this._activeMenuIndex[l]++,o!==this._activeMenuIndex[l]&&this._activeMenuIndex[l]>-1&&this._activeMenuIndex[l]<s.length&&!i){const e=s[this._activeMenuIndex[l]].getElementsByTagName("button"),t=1===e?.length?e[0]:null;t?.focus()}}_focusSearch(){this._searchInput?.focus()}_focusActiveLevel(){const{level:e}=this,t=this._levelsListNode,s=t?.getElementsByTagName("li");if(!e||!t||!s)return;const i=this._facilitiesListNode?.getElementsByTagName("li");this._activeMenuIndex.menuItems=i?i.length-1:-1;const l=[];for(let o=0;o<s.length;o++){const e=s[o].getElementsByTagName("button");1===e?.length&&l.push(e[0])}l.forEach((t,s)=>{t.getAttribute("data-id")===e&&(t.focus(),this._activeMenuIndex.levels=s)})}_onItemFocus(e){const t=e.currentTarget,s=t.getAttribute("data-list-id"),i=t.getAttribute("data-id"),l="sites"===s?this._sitesListNode:"facilities"===s?this._facilitiesListNode:"levels"===s?this._levelsListNode:null;if(!l)return;const o=l?.getElementsByTagName("li");if(!o)return;const n=[];Array.from(o).forEach(e=>{const t=e.getElementsByTagName("button");1===t?.length&&n.push(t[0])});let r=null;switch(s){case"sites":case"facilities":r="menuItems";break;case"levels":r="levels"}if(!r)return;const a=r;n.forEach((e,t)=>{e.getAttribute("data-id")===i&&this._activeMenuIndex[a]!==t&&(this._activeMenuIndex[a]=t)})}};e([s()],f.prototype,"_searchInput",void 0),e([s()],f.prototype,"enabled",null),e([s()],f.prototype,"longNames",null),e([s()],f.prototype,"minimized",null),e([s()],f.prototype,"pinnedLevels",null),e([s()],f.prototype,"site",null),e([s()],f.prototype,"facility",null),e([s()],f.prototype,"level",null),e([s()],f.prototype,"view",null),e([s({type:n})],f.prototype,"viewModel",void 0),e([s(),v("esri/widgets/FloorFilter/t9n/FloorFilter")],f.prototype,"messages",void 0),e([s(),v("esri/t9n/common")],f.prototype,"messagesCommon",void 0),e([s()],f.prototype,"goToOverride",null),e([s()],f.prototype,"headingLevel",void 0),e([s()],f.prototype,"icon",null),f=e([i("esri.widgets.FloorFilter")],f);const g=f;export{g as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../intl.js";import{watch as t}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{css as o}from"./FloorFilter/css.js";import n from"./FloorFilter/FloorFilterViewModel.js";import{loadCalciteComponents as r}from"./support/componentsUtils.js";import{globalCss as a}from"./support/globalCss.js";import{Heading as c,incrementHeadingLevel as h}from"./support/Heading.js";import{isRTL as d,storeNode as u}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{substitute as M}from"../intl/substitute.js";const g=new Set(["ArrowUp","ArrowDown","End","Home"]);let f=class extends l{constructor(e,i){super(e,i),this._activeMenu=null,this._activeMenuIndex={levels:-1,menuItems:-1},this._baseNode=null,this._facilitiesListNode=null,this._levelsListNode=null,this._sitesListNode=null,this._searchInput=null,this.viewModel=new n,this.messages=null,this.messagesCommon=null,this.headingLevel=2,this._resizeObserver=new ResizeObserver(()=>this.scheduleRender()),this.addHandles(t(()=>this._searchInput,()=>this._focusSearch()))}loadDependencies(){return r({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")})}destroy(){this._resizeObserver?.disconnect()}get enabled(){return this.viewModel.enabled}set enabled(e){this.viewModel.enabled=e}get longNames(){return this.viewModel.longNames}set longNames(e){this.viewModel.longNames=e}get minimized(){return this.viewModel.minimized}set minimized(e){this.viewModel.minimized=e}get pinnedLevels(){return this.viewModel.pinnedLevels}set pinnedLevels(e){this.viewModel.pinnedLevels=e}get site(){return this.viewModel.site}set site(e){this.viewModel.site=e}get facility(){return this.viewModel.facility}set facility(e){this.viewModel.facility=e}get level(){return this.viewModel.level}set level(e){this.viewModel.level=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"urban-model"}set icon(e){this._overrideIfSome("icon",e)}updateWebDocument(e){return this.viewModel.updateWebDocument(e)}render(){const{longNames:e}=this,t=e&&this.viewModel.isNormalMode?"expanded":"collapsed",i=this._renderButtons(),s=this._renderFilterMenu(),l=m("div",{class:this.classes(o.separator)}),n=this._getComponentPosition(),r=this._getPosition(n),c="top-right"===n||"bottom-right"===n,h="top-left"===n||"bottom-left"===n,u=d(this.container),v=u&&h||!u&&c?s:i,M=u&&h||!u&&c?i:s;return m("div",{afterCreate:this._afterBaseNodeCreate,class:this.classes(o.floorFilter,a.widget,`${o.floorFilterLayout}${t}`,`${o.floorFilterPosition}${r}`),key:"floor-filter-menu"},v,this.viewModel?.filterMenuOpen?l:null,M)}_renderButtons(){const e=this._getComponentPosition(),t=[];return"top"===this._getPosition(e)?(t.push(this._renderBrowseButton()),t.push(this._renderLevelButtons()),t.push(this._renderCloseLevelsButton()),t.push(this._renderZoomButton()),t.push(this._renderCollapseToggleButton())):(t.push(this._renderCollapseToggleButton()),t.push(this._renderZoomButton()),t.push(this._renderCloseLevelsButton()),t.push(this._renderLevelButtons()),t.push(this._renderBrowseButton())),m("div",{class:this.classes(a.widget,o.buttonContainer),key:"button-container"},t)}_renderBrowseButton(){const{longNames:e,messages:t}=this;return m("button",{"aria-expanded":this.viewModel.filterMenuOpen.toString(),"aria-label":t.buttons.browse,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,("loading"===this.viewModel.state||"disabled"===this.viewModel.state)&&a.buttonDisabled,o.browseButton,this.viewModel?.filterMenuOpen&&a.widgetButtonActive),key:"browse-button",onclick:this._toggleFilterMenu,title:t.buttons.browse,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:this.icon,scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.browse:null)))}_renderLevelButtons(){if(!this.viewModel?.filterFeatures?.levels?.levelsInfo||!this.facility)return null;const{facility:e,messagesCommon:t,messages:i}=this,s=this.viewModel?.getFacility(e),l=this.viewModel?.getFacilityLevels(e),n=l.map(e=>this._renderLevelButton(e));if(!n.length)return null;const r=s&&M(i.selector.levelsLabel,{name:`"${s.name}"`});if(this._isWebScene(this.view?.map)&&n?.length>1){const i={id:`all--${e}`,facilityId:e,shortName:t.all,longName:t.all,levelNumber:null,verticalOrder:null},s=this._renderLevelButton(i);n.push(s)}return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.levelsContainer),"data-id":"levels","data-node-ref":"_levelsListNode",key:"levels-button-container",onkeydown:this._handleListKeydown},n)}_renderLevelButton(e){const{longNames:t}=this,{shortName:i,longName:s,id:l}=e,n=`levels--${l}`,r=this.level===l,c=t&&this.viewModel.isNormalMode?s:i;return this.viewModel.isNormalMode||r||this.viewModel.levelsExpanded?m("li",{key:n},m("button",{bind:this,class:this.classes(a.widgetButton,r?a.widgetButtonActive:null,a.interactive,o.levelButton),"data-id":l,"data-list-id":"levels",onclick:this._levelSelected,onfocus:this._onItemFocus,type:"button"},c)):null}_renderCloseLevelsButton(){if(!this.level||this.viewModel.isNormalMode||!this.viewModel.levelsExpanded)return null;const{messagesCommon:e}=this;return m("button",{"aria-label":e.close,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,o.closeLevelsButton),key:"close-levels-button",onclick:this._closeLevels,title:e.close,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:"x"})))}_renderZoomButton(){const{longNames:e,messages:t,facility:i,site:s}=this,l=this.viewModel?.filterMenuType,n=this.viewModel?.filterMenuOpen,r=this.viewModel?.getSite(s),c=this.viewModel?.getFacility(i),h="site"===l&&n?!r:!c;return m("button",{"aria-label":t.buttons.zoomTo,bind:this,class:this.classes(a.widget,a.widgetButton,h&&a.buttonDisabled,a.interactive,this.viewModel?.getFacilityLevels(i).length>0?o.zoomButtonLevels:o.zoomButton),key:"zoom-button",onclick:this._zoomToClicked,title:t.buttons.zoomTo,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{icon:"zoom-to-object",scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.buttons.zoomTo:null)))}_renderCollapseToggleButton(){const{longNames:e,messagesCommon:t}=this,i=e?"chevrons-right":"chevrons-left",s=e?t.collapse:t.expand;return m("button",{"aria-label":s,bind:this,class:this.classes(a.widget,a.widgetButton,a.interactive,o.minimizeToggleButton),key:"minimize-toggle-button",onclick:this._toggleCollapsed,title:s,type:"button"},m("div",{class:this.classes(o.buttonInfo)},m("calcite-icon",{class:this.classes(o.iconFlip),icon:i,scale:"s"}),m("span",{class:this.classes(o.buttonLabel)},e&&this.viewModel.isNormalMode?t.collapse:null)))}_renderFilterMenu(){return this.viewModel?.filterMenuOpen?"site"===this.viewModel?.filterMenuType?this._renderSiteFilterMenu():"facility"===this.viewModel?.filterMenuType?this._renderFacilityFilterMenu():null:null}_renderSiteFilterMenu(){const{messages:e,messagesCommon:t}=this,i=this.site?this.viewModel?.getSite(this.site)?.name:e.selector.selectSite,s=m("div",{class:this.classes(`${o.filterMenuHeader}`),key:"filter-menu-site-header"},m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(c,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},i)),m("button",{bind:this,class:this.classes(o.iconClose),onclick:this._closeClicked,title:t.close,type:"button"},m("calcite-icon",{icon:"x"}))),l=this._renderSearchInput(),n=this._renderSiteItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-site"},s,l,n)}_renderFacilityFilterMenu(){const{messages:e,messagesCommon:t,site:i}=this,s=this.viewModel?.getSite(i)?.name,l=this.facility&&this.viewModel?.getFacility(this.facility)?.name||e.selector.selectFacility,n=this.viewModel.hasMultipleSites?m("button",{bind:this,class:this.classes(o.filterMenuHeaderBack),onclick:this._backClicked,title:t.back,type:"button"},m("calcite-icon",{class:this.classes(d(this.container)?o.iconRight:o.iconLeft),icon:d(this.container)?"chevron-right":"chevron-left"})):null,r=this.viewModel.hasMultipleSites?m(c,{class:this.classes(o.filterMenuHeaderSubtext),level:h(this.headingLevel)},s):null,a=m("div",{class:this.classes(o.filterMenuHeader),key:"filter-menu-site-header"},n,m("div",{class:this.classes(o.filterMenuHeaderTextGroup)},m(c,{class:this.classes(o.filterMenuHeaderText),level:this.headingLevel},l),r),m("button",{bind:this,class:this.classes(o.iconClose),onclick:this._closeClicked,title:t.close,type:"button"},m("calcite-icon",{icon:"x"}))),u=this._renderSearchInput(),v=this._renderFacilityItems();return m("div",{class:this.classes(o.filterMenu),key:"filter-menu-facility"},a,u,v)}_renderSearchInput(){const{messagesCommon:e}=this,t=!!(this.viewModel.searchTerm&&this.viewModel.searchTerm?.length>0);return m("div",{class:this.classes(o.filterMenuSearch),key:"filter-menu-search"},m("calcite-icon",{icon:"search",key:"filter-menu-search-icon"}),m("input",{afterCreate:u,bind:this,class:this.classes(o.filterMenuSearchInput),"data-node-ref":"_searchInput",oninput:this._onSearchChange,onpaste:this._onSearchChange,placeholder:e.search,value:this.viewModel.searchTerm??void 0}),t?m("calcite-icon",{bind:this,class:this.classes(o.iconClose),icon:"x",key:"filter-menu-search-clear",onclick:this._onSearchClear,title:e.clear}):null)}_renderBlueCircle(){return m("span",{class:this.classes(o.selectedItemCircle),key:"floor-filter__selected-item-circle"})}_renderSiteItems(){if(!this.viewModel?.filterFeatures?.sites?.sitesInfo)return null;const{messages:e}=this,t=this.viewModel.filterFeatures.sites.sitesInfo,i=this.viewModel.filterSites(t).map(e=>this._renderSiteItem(e)),s=0===i.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(a.empty)},e.noResults);return m("ul",{afterCreate:u,"aria-label":e.selector.sitesLabel,bind:this,class:this.classes(o.filterMenuItems),"data-id":"sites","data-node-ref":"_sitesListNode",key:"filter-menu-items--sites",onkeydown:this._handleListKeydown,tabIndex:-1},i,s)}_renderSiteItem(e){const{name:t,id:i}=e,s=`filter-menu-site--${i}`,l=this.site===i;return m("li",{key:s},m("button",{bind:this,class:this.classes(o.filterMenuSite),"data-id":i,"data-list-id":"sites",onclick:this._siteSelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t),m("calcite-icon",{class:this.classes(d(this.container)?o.iconLeft:o.iconRight),icon:"chevron-right",scale:"s"})))}_renderFacilityItems(){if(!this.viewModel?.filterFeatures?.facilities?.facilitiesInfo)return null;const{messages:e,site:t}=this,i=this.viewModel.getSite(t),s=this.viewModel.filterFeatures.facilities.facilitiesInfo,l=this.viewModel.filterFacilities(s).map(e=>this._renderFacilityItem(e)),n=0===l.length&&this.viewModel?.searchTerm&&m("div",{class:this.classes(a.empty)},e.noResults),r=i?M(e.selector.siteFacilitiesLabel,{name:`"${i.name}"`}):e.selector.facilitiesLabel;return m("ul",{afterCreate:u,"aria-label":r,bind:this,class:this.classes(o.filterMenuItems),"data-id":"facilities","data-node-ref":"_facilitiesListNode",key:"filter-menu-items--facilities",onkeydown:this._handleListKeydown,tabIndex:-1},l,n)}_renderFacilityItem(e){const{name:t,id:i}=e,s=`filter-menu-facility--${i}`,l=this.facility===i;return m("li",{key:s},m("button",{bind:this,class:this.classes(o.filterMenuFacility),"data-id":i,"data-list-id":"facilities",onclick:this._facilitySelected,onfocus:this._onItemFocus,type:"button"},l?this._renderBlueCircle():null,m("span",{class:this.classes(l?o.filterMenuSelectedItem:o.filterMenuItemName)},t)))}_afterBaseNodeCreate(e){this._baseNode&&this._resizeObserver?.unobserve(this._baseNode),this._baseNode=e,this._resizeObserver?.observe(this._baseNode)}_toggleCollapsed(){this.longNames=!this.longNames}_toggleFilterMenu(){const e=this.viewModel?.filterMenuOpen??!1;this.viewModel.filterMenuOpen=!e}_setFilterMenuType(e){this.viewModel.filterMenuType=e}_zoomToClicked(){if(this.site&&"site"===this.viewModel?.filterMenuType&&this.viewModel?.filterMenuOpen){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}else if(this.facility){const e=this.viewModel?.getFacility(this.facility);this.viewModel.goTo(e)}else if(this.site){const e=this.viewModel?.getSite(this.site);this.viewModel.goTo(e)}}_onSearchChange(e){const t=e.target;""===t.value?this.viewModel.searchTerm=null:t.value&&this.viewModel?.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value)}_onSearchClear(){this.viewModel.searchTerm=null}_closeClicked(){this.viewModel.searchTerm=null,this.viewModel.filterMenuOpen=!1}_backClicked(){this._setFilterMenuType("site"),this.viewModel.searchTerm=null}_siteSelected(e){const t=e.currentTarget.getAttribute("data-id"),i=this.viewModel.getSite(t);let s=!1;this.site!==t&&(this.facility=null,this.level=null,s=!0,this.viewModel.levelsExpanded=!1),this.site=t,this.viewModel.searchTerm=null,this._setFilterMenuType("facility"),this.viewModel.goTo(i),s&&this.viewModel.setFloors(null)}_facilitySelected(e){const t=e.currentTarget.getAttribute("data-id"),i=this.viewModel.getFacility(t);let s=!1;if(this.facility!==t){if("base-floors"===this.viewModel.filterMode){const e=this.viewModel?.getBaseLevel(i);this.level=e?e.id:null}else this.level=null;s=!0,this.viewModel.levelsExpanded=!1}if(this.facility=t,this.viewModel.goTo(i),s){const e=this.viewModel.getLevel(this.level);this.viewModel.setFloors(e)}if(!this.viewModel.isNormalMode){const e=this.viewModel.getFacilityLevels(t);e?.length>1&&(this.viewModel.levelsExpanded=!0)}setTimeout(()=>this._focusActiveLevel(),50)}_levelSelected(e){const t=e.currentTarget.getAttribute("data-id");this.level=t}_closeLevels(){this.viewModel.levelsExpanded=!1}_isWebScene(e){return"esri.WebScene"===e?.declaredClass}_getComponentPosition(){return null!=this.container?this.view?.ui?.getPosition(this.container):null}_getPosition(e){switch(e){case"bottom-right":case"bottom-left":return"bottom";default:return"top"}}_handleListKeydown(e){const t=e.currentTarget.getAttribute("data-id");let i=null;"sites"===t||"facilities"===t?(this._activeMenu!==t&&(this._activeMenuIndex.menuItems=-1),this._activeMenu=t,i="menuItems"):"levels"===t&&(i="levels");const s="sites"===t?this._sitesListNode:"facilities"===t?this._facilitiesListNode:"levels"===t?this._levelsListNode:null,{key:l}=e,o="Tab"===l,n=g.has(l);n&&e.preventDefault();const r=s?.getElementsByTagName("li");r&&0!==r.length&&(n||o)&&this._handleItemNavigation(l,e.shiftKey,r,o,i)}_handleItemNavigation(e,t,i,s,l){if(!l)return;this._activeMenuIndex[l]===i.length&&this._activeMenuIndex[l]--,-1===this._activeMenuIndex[l]&&this._activeMenuIndex[l]++;const o=this._activeMenuIndex[l];switch(e){case"Home":this._activeMenuIndex[l]=0;break;case"End":this._activeMenuIndex[l]=i.length-1;break;case"ArrowUp":this._activeMenuIndex[l]=this._activeMenuIndex[l]<=0?i.length-1:this._activeMenuIndex[l]-1;break;case"ArrowDown":this._activeMenuIndex[l]=this._activeMenuIndex[l]===i.length-1?0:this._activeMenuIndex[l]+1}if("Tab"===e&&t&&this._activeMenuIndex[l]>=0&&this._activeMenuIndex[l]--,"Tab"===e&&!t&&this._activeMenuIndex[l]<i.length&&this._activeMenuIndex[l]++,o!==this._activeMenuIndex[l]&&this._activeMenuIndex[l]>-1&&this._activeMenuIndex[l]<i.length&&!s){const e=i[this._activeMenuIndex[l]].getElementsByTagName("button"),t=1===e?.length?e[0]:null;t?.focus()}}_focusSearch(){this._searchInput?.focus()}_focusActiveLevel(){const{level:e}=this,t=this._levelsListNode,i=t?.getElementsByTagName("li");if(!e||!t||!i)return;const s=this._facilitiesListNode?.getElementsByTagName("li");this._activeMenuIndex.menuItems=s?s.length-1:-1;const l=[];for(let o=0;o<i.length;o++){const e=i[o].getElementsByTagName("button");1===e?.length&&l.push(e[0])}l.forEach((t,i)=>{t.getAttribute("data-id")===e&&(t.focus(),this._activeMenuIndex.levels=i)})}_onItemFocus(e){const t=e.currentTarget,i=t.getAttribute("data-list-id"),s=t.getAttribute("data-id"),l="sites"===i?this._sitesListNode:"facilities"===i?this._facilitiesListNode:"levels"===i?this._levelsListNode:null;if(!l)return;const o=l?.getElementsByTagName("li");if(!o)return;const n=[];Array.from(o).forEach(e=>{const t=e.getElementsByTagName("button");1===t?.length&&n.push(t[0])});let r=null;switch(i){case"sites":case"facilities":r="menuItems";break;case"levels":r="levels"}if(!r)return;const a=r;n.forEach((e,t)=>{e.getAttribute("data-id")===s&&this._activeMenuIndex[a]!==t&&(this._activeMenuIndex[a]=t)})}};e([i()],f.prototype,"_searchInput",void 0),e([i()],f.prototype,"enabled",null),e([i()],f.prototype,"longNames",null),e([i()],f.prototype,"minimized",null),e([i()],f.prototype,"pinnedLevels",null),e([i()],f.prototype,"site",null),e([i()],f.prototype,"facility",null),e([i()],f.prototype,"level",null),e([i()],f.prototype,"view",null),e([i({type:n})],f.prototype,"viewModel",void 0),e([i(),v("esri/widgets/FloorFilter/t9n/FloorFilter")],f.prototype,"messages",void 0),e([i(),v("esri/t9n/common")],f.prototype,"messagesCommon",void 0),e([i()],f.prototype,"goToOverride",null),e([i()],f.prototype,"headingLevel",void 0),e([i()],f.prototype,"icon",null),f=e([s("esri.widgets.FloorFilter")],f);const p=f;export{p 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../Color.js";import{watch as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import o from"./Histogram.js";import n from"./Slider.js";import l from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as h}from"./smartMapping/support/utils.js";import{globalCss as u}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as p}from"./support/jsxFactory.js";const g="esri-histogram-range-slider",c={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends l{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t("#d7e5f0"),this.includedBarColor=new t("#599dd4"),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d}initialize(){const{average:e,bins:t,hasTimeData:r,max:s,min:a,viewModel:l}=this;this._updateBarFill=this._updateBarFill.bind(this),this._histogram=new o({average:e,bins:t,barCreatedFunction:(e,t)=>{0===e&&(this._barElements=[]),this._barElements.push(t),this._updateBarFill(e,t),this.barCreatedFunction
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../Color.js";import{watch as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import o from"./Histogram.js";import n from"./Slider.js";import l from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as h}from"./smartMapping/support/utils.js";import{globalCss as u}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as p}from"./support/jsxFactory.js";const g="esri-histogram-range-slider",c={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends l{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t("#d7e5f0"),this.includedBarColor=new t("#599dd4"),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d}initialize(){const{average:e,bins:t,hasTimeData:r,max:s,min:a,viewModel:l}=this;this._updateBarFill=this._updateBarFill.bind(this),this._histogram=new o({average:e,bins:t,barCreatedFunction:(e,t)=>{0===e&&(this._barElements=[]),this._barElements.push(t),this._updateBarFill(e,t),this.barCreatedFunction?.(e,t)},dataLines:this._getDataLines(),dataLineCreatedFunction:(e,t)=>{this.dataLineCreatedFunction?.(e,t)},labelFormatFunction:this.labelFormatFunction,layout:"horizontal",max:s,min:a}),this._slider=new n({labelFormatFunction:this.labelFormatFunction,layout:"horizontal",visibleElements:{labels:!0,rangeLabels:!0},rangeLabelInputsEnabled:!r,viewModel:l}),this.addHandles([this._slider.on("max-change",e=>this.emit("max-change",e)),this._slider.on("min-change",e=>this.emit("min-change",e)),this._slider.on("segment-drag",e=>{this._updateBarFills(),this.emit("segment-drag",e)}),this._slider.on("thumb-change",e=>{this._updateBarFills(),this.emit("thumb-change",e)}),this._slider.on("thumb-drag",e=>{this._updateBarFills(),this.emit("thumb-drag",e)}),i(()=>this.bins,e=>{if(e&&this._histogram.bins){const t=this._histogram.bins.length-e.length;this._barElements.splice(-t,t)}else this._barElements=[];this._histogram.set({bins:e}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.max,this.min,this.rangeType,this.values],([e,t])=>{this._histogram.set({max:e,min:t}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.average,this.dataLines,this.standardDeviation,this.standardDeviationCount],([e])=>{this._histogram.set({average:e,dataLines:this._getDataLines()})}),i(()=>this.labelFormatFunction,e=>{this._histogram.set({labelFormatFunction:e})}),i(()=>this.hasTimeData,e=>{this._slider.set({rangeLabelInputsEnabled:!e})})])}get average(){return this.viewModel.average}set average(e){this.viewModel.average=e}get bins(){return this.viewModel.bins}set bins(e){this.viewModel.bins=e}get hasTimeData(){return this.viewModel.hasTimeData}set hasTimeData(e){this.viewModel.hasTimeData=e}get icon(){return"arrow-double-horizontal"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get rangeType(){return this.viewModel.rangeType}set rangeType(e){this.viewModel.rangeType=e}get standardDeviation(){return this.viewModel.standardDeviation}set standardDeviation(e){this.viewModel.standardDeviation=e}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}generateWhereClause(e){return this.viewModel.generateWhereClause(e)}render(){const{rangeType:e,viewModel:t,label:i}=this,r=this.classes(c.base,u.widget,`${c.rangeTypePrefix}${e}`,"disabled"===t.state?u.disabled:null);return p("div",{"aria-label":i,class:r},"disabled"===t.state?null:this._renderContent())}_renderContent(){return[this._renderHistogram(),this._renderSlider()]}_renderSlider(){return p("div",{class:c.sliderContainer,key:`${this.id}-slider-container`},this._slider.render())}_renderHistogram(){return p("div",{class:c.histogramContainer},this._histogram.render())}_getDataLines(){return[...this._getStandardDeviationDataLines(),...this.dataLines||[]]}_getStandardDeviationDataLines(){const{average:e,standardDeviation:t,standardDeviationCount:i}=this;return h(t,e,i).map(e=>({value:e}))}_updateBarFills(){this._barElements.forEach((e,t)=>this._updateBarFill(t,e))}_updateBarFill(e,t){t.setAttribute("fill",this._getFillForBar(e)?.toHex()??"")}_getFillForBar(e){const{bins:t,rangeType:i,values:r}=this;if(-1===e||!t?.length||!i||!r?.length)return null;const s=t[e];if(!s)return null;const{maxValue:a,minValue:o}=s,n=a-o,l=r[0]>o&&r[0]<a;switch(i){case"equal":case"not-equal":return this.includedBarColor;case"less-than":case"at-most":return l?this._getBlendedColor((r[0]-o)/n):a<=r[0]?this.includedBarColor:this.excludedBarColor;case"greater-than":case"at-least":return l?this._getBlendedColor(1-(r[0]-o)/n):o>=r[0]?this.includedBarColor:this.excludedBarColor;case"between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor(1-(r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor((r[1]-o)/n):o>=r[0]&&a<=r[1]?this.includedBarColor:this.excludedBarColor;break;case"not-between":if(2===r.length)return r[0]>o&&r[0]<a?this._getBlendedColor((r[0]-o)/n):r[1]>o&&r[1]<a?this._getBlendedColor(1-(r[1]-o)/n):o>r[0]&&a<r[1]?this.excludedBarColor:this.includedBarColor}return this.includedBarColor}_getBlendedColor(e){return t.blendColors(this.excludedBarColor,this.includedBarColor,e)}};e([r()],v.prototype,"average",null),e([r()],v.prototype,"barCreatedFunction",void 0),e([r()],v.prototype,"bins",null),e([r()],v.prototype,"dataLines",void 0),e([r()],v.prototype,"dataLineCreatedFunction",void 0),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"excludedBarColor",void 0),e([r()],v.prototype,"hasTimeData",null),e([r({type:t,json:{type:[s],write:!0}})],v.prototype,"includedBarColor",void 0),e([r()],v.prototype,"icon",null),e([r()],v.prototype,"label",null),e([r()],v.prototype,"labelFormatFunction",null),e([r()],v.prototype,"max",null),e([r(),m("esri/widgets/HistogramRangeSlider/t9n/HistogramRangeSlider")],v.prototype,"messages",void 0),e([r()],v.prototype,"min",null),e([r()],v.prototype,"precision",null),e([r()],v.prototype,"rangeType",null),e([r()],v.prototype,"standardDeviation",null),e([r()],v.prototype,"standardDeviationCount",void 0),e([r()],v.prototype,"values",null),e([r({type:d})],v.prototype,"viewModel",void 0),v=e([a("esri.widgets.HistogramRangeSlider")],v);const b=v;export{b as default};
|
package/widgets/Search/css.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const o="esri-search",
|
|
5
|
+
const o="esri-search",t={base:o,autocomplete:`${o}__autocomplete`,dropdown:`${o}__dropdown`,container:`${o}__container`,form:`${o}__form`,submitButton:`${o}__submit-button`};export{t as css};
|