@arcgis/core 4.23.0-next.20220128 → 4.23.0-next.20220202
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/Graphic.js +1 -1
- package/TimeExtent.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/01a10fe5ad6941b0ee8c.js +1 -0
- package/assets/esri/core/workers/chunks/{7a5f5acfbd4ca1a5c1f3.js → 06116433eb6e669f146b.js} +1 -1
- package/assets/esri/core/workers/chunks/09a05d778b6fac710828.js +1 -0
- package/assets/esri/core/workers/chunks/{83d00afae4406ec78bc9.js → 0c6be307709523eb8a05.js} +1 -1
- package/assets/esri/core/workers/chunks/0e215fa28a0448169132.js +1 -0
- package/assets/esri/core/workers/chunks/{391e96192d1ec4e55ce2.js → 101b4f02f0572afb666f.js} +1 -1
- package/assets/esri/core/workers/chunks/11750e96065b4d7b926b.js +1 -0
- package/assets/esri/core/workers/chunks/{929c9b7cdab7c4ca3d87.js → 17c51f5a13f471e6656a.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed0bcc66fb1e0ee75a4b.js → 1f34957ef42e5b5977d0.js} +1 -1
- package/assets/esri/core/workers/chunks/2f4e425be3a3bdfd8d29.js +1 -0
- package/assets/esri/core/workers/chunks/34bed896b68993cabaa1.js +1 -0
- package/assets/esri/core/workers/chunks/3e1679b01429fd73cffe.js +1 -0
- package/assets/esri/core/workers/chunks/{99619fcb772807c74f3b.js → 444829a840b8ded16fd7.js} +1 -1
- package/assets/esri/core/workers/chunks/467b5faa1c90d9821609.js +1 -0
- package/assets/esri/core/workers/chunks/49353182a16218a84251.js +1 -0
- package/assets/esri/core/workers/chunks/4bfc2eeb0738c393d8ec.js +1 -0
- package/assets/esri/core/workers/chunks/4de996ebc432f5e149bc.js +1 -0
- package/assets/esri/core/workers/chunks/{422537fc3df707bb62c9.js → 5038935db9b1ebe61d02.js} +1 -1
- package/assets/esri/core/workers/chunks/50976921acf7bd636123.js +1 -0
- package/assets/esri/core/workers/chunks/50ef2622fd0d9a241979.js +1 -0
- package/assets/esri/core/workers/chunks/{5790d171072b3c7d108f.js → 53aa2ab4e569c994a32d.js} +1 -1
- package/assets/esri/core/workers/chunks/{7903a3e2e0faff0f86c0.js → 56657f890e0f79f5d2ad.js} +1 -1
- package/assets/esri/core/workers/chunks/{db3c729ce0c0b2690dc9.js → 574e33f28c106d607fe3.js} +1 -1
- package/assets/esri/core/workers/chunks/{952980635afc7ec81804.js → 5b02ba8ed152dba53155.js} +1 -1
- package/assets/esri/core/workers/chunks/60c06d1bb3f8a26cb5ac.js +1 -0
- package/assets/esri/core/workers/chunks/{c2253a9f29c1aabb2b75.js → 66c47983e93071de28b1.js} +1 -1
- package/assets/esri/core/workers/chunks/6be326edd9829781d926.js +1 -0
- package/assets/esri/core/workers/chunks/70d6bb3c7112cb702389.js +1 -0
- package/assets/esri/core/workers/chunks/{5bcb3240b3c005e5fe72.js → 7215af7810d15e89aa5a.js} +1 -1
- package/assets/esri/core/workers/chunks/7509c1693ffedc0fa018.js +1 -0
- package/assets/esri/core/workers/chunks/76c1d663f6d3f935c87f.js +1 -0
- package/assets/esri/core/workers/chunks/7ccbb923f113b3e21545.js +1 -0
- package/assets/esri/core/workers/chunks/810a763373d7f78ae398.js +1 -0
- package/assets/esri/core/workers/chunks/82194fec53054c37061f.js +1 -0
- package/assets/esri/core/workers/chunks/82c59a71b7f087148089.js +1 -0
- package/assets/esri/core/workers/chunks/84eee02122b56a22d49e.js +1 -0
- package/assets/esri/core/workers/chunks/{dd13772a5e2eccc6a2bc.js → 8598f762f15ca68d52b7.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c673495e5f507c4a9e5.js → 88458dcaff8edc50620c.js} +1 -1
- package/assets/esri/core/workers/chunks/{5ec98f4ddac707d0fbd1.js → 88815d533808aabb1fa9.js} +1 -1
- package/assets/esri/core/workers/chunks/{0463ba46df855a92b9c0.js → 8941f09329d9d39fb2fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{655b55ac0cd533d7e9d7.js → 8ad5dc818dc73f4b9a76.js} +1 -1
- package/assets/esri/core/workers/chunks/8e96cddb069b643d864a.js +1 -0
- package/assets/esri/core/workers/chunks/{f2124f4d0f2b8a91f0ea.js → 90c5edcd8a609224ce55.js} +1 -1
- package/assets/esri/core/workers/chunks/9230b20eba4304d421b4.js +1 -0
- package/assets/esri/core/workers/chunks/{bac9fc90e6756e211160.js → 94d9951509c0db09547a.js} +1 -1
- package/assets/esri/core/workers/chunks/996d6ae7f2e2273f9bce.js +1 -0
- package/assets/esri/core/workers/chunks/{37c03cfc19086ce631c6.js → 9bd603ec98d24cd918e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{c1135cb02ec46c491459.js → 9ce961bc390202c87941.js} +1 -1
- package/assets/esri/core/workers/chunks/9d4a35d4a85db80c4071.js +1 -0
- package/assets/esri/core/workers/chunks/9f0ad28e66862ba971a3.js +1 -0
- package/assets/esri/core/workers/chunks/{b3f5e91116112b0b612a.js → 9fd47b8fe25657ac0237.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9e9cb354822c6d995a4.js → a276e60209f3d877a8d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{aeaa1667c2d9f1b3366b.js → a85ed251d3d3668e474f.js} +1 -1
- package/assets/esri/core/workers/chunks/{44f0c3663b293afbd172.js → acf10f747215e9ff54dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{69fd99b7c76e9992ccf3.js → b32bf9808cb4be3a6bd0.js} +1 -1
- package/assets/esri/core/workers/chunks/b3dc80ddbfa81026e937.js +1 -0
- package/assets/esri/core/workers/chunks/b548e6b3add4154ac4e6.js +1 -0
- package/assets/esri/core/workers/chunks/b6c55bdd8c957b062bc1.js +1 -0
- package/assets/esri/core/workers/chunks/{9d77467aa71d345fc1b6.js → bcc01bbffaa3bb5f60a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f8c6a179e39fd4c5e6f.js → bd152e8b43cc4a6844dd.js} +1 -1
- package/assets/esri/core/workers/chunks/{0d02c6ad1f4688bfa374.js → bf7c44644fe7b0aa60cf.js} +1 -1
- package/assets/esri/core/workers/chunks/c0dc5882362479794224.js +1 -0
- package/assets/esri/core/workers/chunks/c8b574a76807f4ea7a70.js +1 -0
- package/assets/esri/core/workers/chunks/d09a0b2dc3a6fc10fa41.js +1 -0
- package/assets/esri/core/workers/chunks/{ec10151a2a95e95a0bb5.js → d304fe0ac836afd46e3d.js} +1 -1
- package/assets/esri/core/workers/chunks/{37a7bd30352b1309b8f8.js → d3f05b8e4bd53eb1eb9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{be588873c16770ceb9ef.js → d46b511bbb83e68f1ece.js} +1 -1
- package/assets/esri/core/workers/chunks/{17de7a324dfa7f57ad5d.js → d780e946149b1c3d1246.js} +1 -1
- package/assets/esri/core/workers/chunks/d80bcf5ed1f54e0c4f5a.js +1 -0
- package/assets/esri/core/workers/chunks/{8cbb04a9065aa3756638.js → dc04a8ba6c770bdc2bd4.js} +1 -1
- package/assets/esri/core/workers/chunks/{89820b200ee44e678af5.js → dd891a98105904f8a06b.js} +1 -1
- package/assets/esri/core/workers/chunks/e5ab037c2a90411c453b.js +1 -0
- package/assets/esri/core/workers/chunks/ef2df21e1af3aa7ced29.js +1 -0
- package/assets/esri/core/workers/chunks/f5a7281ae24e837efc61.js +1 -0
- package/assets/esri/core/workers/chunks/{ff6abdc72076f3994659.js → f7150547d7e3259a0f29.js} +1 -1
- package/assets/esri/core/workers/chunks/{2c607d30ff8ca1b61286.js → fe0c3b7c9b428d9c3f25.js} +1 -1
- package/assets/esri/images/portal/mediaservice16.png +0 -0
- package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
- package/assets/esri/widgets/Directions/t9n/Directions.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_en.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_nb.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
- package/chunks/Heatmap.glsl.js +10 -0
- package/chunks/HeatmapDensity.glsl.js +21 -0
- package/core/maybe.js +1 -1
- package/core/promiseUtils.js +1 -1
- package/interfaces.d.ts +455 -45
- package/layers/RouteLayer.d.ts +4 -0
- package/layers/RouteLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/optimizedFeatureQueryEngineAdapter.js +1 -1
- package/layers/graphics/featureConversionUtils.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/support/rasterFunctions/vectorFieldUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/support/rendererConversion.js +1 -1
- package/rest/support/DirectionLine.d.ts +4 -0
- package/rest/support/DirectionPoint.d.ts +4 -0
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/RouteInfo.d.ts +4 -0
- package/rest/support/RouteInfo.js +1 -1
- package/rest/support/RouteSolveResult.d.ts +4 -0
- package/support/featureFlags.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/TextSymbol3DLayer.js +1 -1
- package/symbols/support/Symbol3DHalo.js +1 -1
- package/symbols/support/Symbol3DTextBackground.js +5 -0
- package/views/2d/engine/RasterVFContainer.js +5 -0
- package/views/2d/engine/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/flow/AnimatedFlowView2D.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/brushes/raster/BrushVectorField.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLBaseTextTemplate.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/RouteLayerView2D.js +1 -1
- package/views/2d/layers/features/processors/HeatmapProcessor.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/ClusterStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryVFStrategy.js +5 -0
- package/views/2d/layers/imagery/ImageryView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +5 -0
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/CloudsComposition.js +1 -1
- package/views/3d/environment/CloudsGenerator.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/NoiseTextureAtlas.js +1 -1
- package/views/3d/environment/PanoramicAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/environment/SimpleAtmosphere.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/labelPlacement.js +1 -1
- package/views/3d/layers/i3s/I3SCrossfadeHelper.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/support/LaserLineRenderer.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +5 -0
- package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowHighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapDensity.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +5 -0
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/HighlightHelper.js +5 -0
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/layerUtils.js +1 -1
- package/webdoc/support/{Thumbnail.js → SlideThumbnail.js} +1 -1
- package/webmap/Bookmark.js +1 -1
- package/webmap/Version.js +1 -1
- package/webscene/Slide.js +1 -1
- package/webscene/Version.js +1 -1
- package/webscene/support/SlideVisibleLayer.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions/support/directionsUtils.js +1 -1
- package/widgets/Directions/support/resources.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/vnodeCache.js +5 -0
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0453fad5cb819797b4f6.js +0 -1
- package/assets/esri/core/workers/chunks/0cd0a6eef51fc5b9ea61.js +0 -1
- package/assets/esri/core/workers/chunks/0d684f16f37d5dc385dd.js +0 -1
- package/assets/esri/core/workers/chunks/16b6d0f8378582c051c3.js +0 -1
- package/assets/esri/core/workers/chunks/1877ab1b6a115dbba1c5.js +0 -1
- package/assets/esri/core/workers/chunks/1b2a961f776a0b57e57a.js +0 -1
- package/assets/esri/core/workers/chunks/1b3fd66577b19aa5f2b6.js +0 -1
- package/assets/esri/core/workers/chunks/1c733b7db092a2a88ef3.js +0 -1
- package/assets/esri/core/workers/chunks/27474b007988855bea9d.js +0 -1
- package/assets/esri/core/workers/chunks/357033117dfe61eb81ea.js +0 -1
- package/assets/esri/core/workers/chunks/483d5d8593d96d0f0b15.js +0 -1
- package/assets/esri/core/workers/chunks/4ba6de8aa7e2960bad49.js +0 -1
- package/assets/esri/core/workers/chunks/4be35af7d6babbfe9d84.js +0 -1
- package/assets/esri/core/workers/chunks/5457962a70bd3c557a75.js +0 -1
- package/assets/esri/core/workers/chunks/57856b4a9b8784a69844.js +0 -1
- package/assets/esri/core/workers/chunks/57b349d1dbc0bed75b79.js +0 -1
- package/assets/esri/core/workers/chunks/5d11b97b667921d67ae7.js +0 -1
- package/assets/esri/core/workers/chunks/5dbe555a5a662ff3d9ce.js +0 -1
- package/assets/esri/core/workers/chunks/64b7e8d812ea8fcf269e.js +0 -1
- package/assets/esri/core/workers/chunks/75d812955a473d0e8960.js +0 -1
- package/assets/esri/core/workers/chunks/96f148a556a2418038de.js +0 -1
- package/assets/esri/core/workers/chunks/9876a1bae350795fab36.js +0 -1
- package/assets/esri/core/workers/chunks/a8692bffb76444c34760.js +0 -1
- package/assets/esri/core/workers/chunks/ba762bcfd74af0bb8218.js +0 -1
- package/assets/esri/core/workers/chunks/c093dff4592832ac0973.js +0 -1
- package/assets/esri/core/workers/chunks/c984b3040e120e502b11.js +0 -1
- package/assets/esri/core/workers/chunks/cdbc005eebec1503b99d.js +0 -1
- package/assets/esri/core/workers/chunks/d1fe53b597351dc58305.js +0 -1
- package/assets/esri/core/workers/chunks/e218bde41ffbcc5194f5.js +0 -1
- package/assets/esri/core/workers/chunks/e287f49184d076af17e2.js +0 -1
- package/assets/esri/core/workers/chunks/e93dfdede0532a89ffa5.js +0 -1
- package/assets/esri/core/workers/chunks/e9e5196b44b6923be1a3.js +0 -1
- package/assets/esri/core/workers/chunks/ea595b0df5050eda2a13.js +0 -1
- package/assets/esri/core/workers/chunks/eb82ff10cef2bde6e57f.js +0 -1
- package/assets/esri/core/workers/chunks/ee6e0db58dc64410e687.js +0 -1
- package/assets/esri/core/workers/chunks/f0a9f161805fc7a30fc5.js +0 -1
- package/assets/esri/core/workers/chunks/fc7e31d87555beb63291.js +0 -1
- package/assets/esri/core/workers/chunks/fff6b0338f06dad0c45d.js +0 -1
- package/views/2d/layers/imagery/ImageryGraphicsView2D.js +0 -5
- package/widgets/Directions/support/CostSummary.js +0 -5
- package/widgets/Directions/support/RouteSection.js +0 -5
- package/widgets/Directions/support/RouteSections.js +0 -5
- package/widgets/Directions/support/maneuverUtils.js +0 -5
package/widgets/Bookmarks.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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import o from"../core/Handles.js";import{isSome as i,isNone as r}from"../core/maybe.js";import{init as s,on as a,watch as n}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import{property as k}from"../core/accessorSupport/decorators/property.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as u,convertDateFormatToIntlOptions as c}from"../intl/date.js";import h from"../webdoc/support/Thumbnail.js";import b from"./Widget.js";import _ from"./Bookmarks/BookmarksUserState.js";import p from"./Bookmarks/BookmarksViewModel.js";import g from"./FeatureTable/Grid/support/ButtonMenu.js";import B from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{Heading as v}from"./support/Heading.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as y}from"./support/jsxFactory.js";import w from"sortablejs";function S(t,e,o){t.splice(o,0,t.splice(e,1)[0])}const x="bookmarks",A="data-bookmark-uid",T={base:"esri-bookmarks esri-widget--panel",loaderContainer:"esri-bookmarks__loader-container",loader:"esri-bookmarks__loader",fadeIn:"esri-bookmarks--fade-in",bookmarkList:"esri-bookmarks__list",bookmarkListSortable:"esri-bookmarks__list--sortable",bookmark:"esri-bookmarks__bookmark",bookmarkButton:"esri-bookmarks__bookmark-button",bookmarkImageContainer:"esri-bookmarks__bookmark-image-container",bookmarkEditButtonContainer:"esri-bookmarks__bookmark-edit-button-container",bookmarkEditButton:"esri-bookmarks__bookmark-edit-button",bookmarkDragHandle:"esri-bookmarks_bookmark-drag-handle",bookmarkDragHandleIcon:"esri-bookmarks_bookmark-drag-handle-icon",bookmarkIcon:"esri-bookmarks__bookmark-icon",bookmarkImage:"esri-bookmarks__image",bookmarkLabel:"esri-bookmarks__bookmark-label",bookmarkName:"esri-bookmarks__bookmark-name",bookmarkTimeExtent:"esri-bookmarks__bookmark-time-extent",bookmarkActive:"esri-bookmarks__bookmark--active",noBookmarksContainer:"esri-widget__content--empty",noBookmarksHeader:"esri-bookmarks__no-bookmarks-heading",noBookmarksIcon:"esri-widget__no-bookmark-icon",noBookmarksDescription:"esri-bookmarks__no-bookmarks-description",addingBookmark:"esri-bookmarks__adding-bookmark",addBookmark:"esri-bookmarks__add-bookmark",addBookmarkButton:"esri-bookmarks__add-bookmark-button",addBookmarkIcon:"esri-bookmarks__add-bookmark-icon",authoringCard:"esri-bookmarks__authoring-card",authoringContainer:"esri-bookmarks__authoring-container",authoringForm:"esri-bookmarks__authoring-form",authoringLabel:"esri-bookmarks__authoring-label",authoringActions:"esri-bookmarks__authoring-actions",authoringInputInvalid:"esri-bookmarks__authoring-input--invalid",authoringDeleteButton:"esri-bookmarks__authoring-delete-button",authoringCancelButton:"esri-bookmarks__authoring-cancel-button",timeExtentContainer:"esri-bookmarks__time-extent-container",timeExtent:"esri-bookmarks__time-extent",timeExtentGroup:"esri-bookmarks__time-extent-group",timeExtentDate:"esri-bookmarks__time-extent-date",timeExtentTime:"esri-bookmarks__time-extent-time",esriWidget:"esri-widget",esriWidgetDisabled:"esri-widget--disabled",esriButton:"esri-button",esriButtonTertiary:"esri-button--tertiary",esriInput:"esri-input",iconHandle:"esri-icon-handle-vertical",iconPlus:"esri-icon-plus",iconEdit:"esri-icon-edit",iconHandleHorizontal:"esri-icon-handle-horizontal",iconRefresh:"esri-icon-refresh",iconLink:"esri-icon-link",iconRemove:"esri-icon-erase",widgetIcon:"esri-icon-bookmark",header:"esri-widget__heading",loading:"esri-icon-loading-indicator",rotating:"esri-rotating"},C={addBookmark:!0,thumbnail:!0,time:!0},U=/^https:\/\/.*/i,M="esri.widgets.Bookmarks";let N=class extends b{constructor(t,e){super(t,e),this._handles=new o,this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._addBookmarkButtonNode=null,this._focusAddBookmarkButton=!1,this._focusEditInputBox=!1,this._focusAddInputBox=!1,this._focusUrlEditInputBox=!1,this._sortable=null,this._sortableNode=null,this._focusSortUid=null,this._selectedSortUid=null,this._sortableSavedItems=null,this._editIncludeTimeExtent=null,this._userState=null,this.defaultCreateOptions=null,this.defaultEditOptions=null,this.bookmarks=null,this.disabled=!1,this.editingEnabled=!1,this.headingLevel=2,this.goToOverride=null,this.iconClass=T.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.view=null,this.viewModel=new p,this.visibleElements={...C}}initialize(){this.own([s(this,"viewModel.bookmarks",(()=>this._bookmarksInitialized())),s(this,"editingEnabled",(()=>this._toggleSorting()))])}destroy(){this._destroySortable(),this._handles.destroy(),this._handles=null,this._editMenu.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}get _editMenuItems(){var t,e;const{messages:o,_userState:i}=this,r=null==i||null==(t=i.editedBookmark)||null==(e=t.thumbnail)?void 0:e.url;return[new B({label:null==o?void 0:o.menu.refreshThumbnail,iconClass:T.iconRefresh,clickFunction:()=>this._refreshThumbnail()}),new B({label:U.test(r)?null==o?void 0:o.menu.editImageUrl:null==o?void 0:o.menu.useImageUrl,iconClass:T.iconLink,clickFunction:()=>this._startUseImageUrl()}),r?new B({label:null==o?void 0:o.menu.removeThumbnail,iconClass:T.iconRemove,clickFunction:()=>this._removeThumbnail()}):null].filter(Boolean)}get _editMenu(){const{_editMenuItems:t,messages:e}=this,o=this._get("_editMenu");o&&o.destroy();const i=new g({iconClass:T.iconHandleHorizontal,label:null==e?void 0:e.menu.label});return i.items=t,i}castVisibleElements(t){return{...C,...t}}endAddBookmark(){this._userState=null}goTo(t){return this.viewModel.goTo(t)}render(){const{state:t}=this.viewModel,e="loading"===t?this.renderLoading():this.renderBookmarks();return y("div",{class:this.classes(T.base,T.esriWidget,{[T.esriWidgetDisabled]:this.disabled})},e)}startAddBookmark(){this._userState=new _({state:"add"}),this._focusAddInputBox=!0,this.scheduleRender()}renderLoading(){return y("div",{class:T.loaderContainer,key:"loader"},y("div",{class:T.loader}))}renderNoBookmarksContainer(){const{messages:t}=this;return y("div",{class:T.noBookmarksContainer,key:"no-bookmarks"},y("span",{"aria-hidden":"true",class:this.classes(T.noBookmarksIcon,T.widgetIcon)}),y(v,{level:this.headingLevel,class:this.classes(T.header,T.noBookmarksHeader)},null==t?void 0:t.noBookmarksHeading),y("p",{class:T.noBookmarksDescription},null==t?void 0:t.noBookmarksDescription))}renderAddBookmarkLoading(){var t;return y("div",{key:"adding-bookmark",class:T.addingBookmark},y("span",{"aria-hidden":"true",class:this.classes(T.loading,T.rotating)}),null==(t=this.messages)?void 0:t.addingBookmark)}renderBookmarkItems(t){if(!t)return null;const{_userState:e,editingEnabled:o}=this;return t.map((t=>o&&t&&e&&("edit"===e.state||"edit-thumbnail"===e.state)&&e.bookmark===t?"edit-thumbnail"===e.state?this.renderEditingBookmarkUrl(e.editedBookmark):this.renderEditingBookmark(e.editedBookmark):this.renderBookmark(t))).toArray()}renderBookmarksContainer(t){var e;const{_userState:o,editingEnabled:i}=this,r="add"===(null==o?void 0:o.state),s=i&&!r?this.renderAddBookmarkButton():null,a=i?r&&o.loading?this.renderAddBookmarkLoading():"add"===(null==o?void 0:o.state)?this.renderAddingBookmark():null:null;return[y("ul",{key:"bookmark-list","aria-label":null==(e=this.messages)?void 0:e.widgetLabel,class:this.classes(T.bookmarkList,{[T.bookmarkListSortable]:this.editingEnabled}),afterCreate:this._sortNodeCreated,afterRemoved:this._destroySortable,"data-node-ref":"_sortableNode",bind:this},this.renderBookmarkItems(t)),s,a]}renderAddBookmarkButton(){var t;return this.visibleElements.addBookmark?y("div",{key:"add-bookmark-item",class:T.addBookmark},y("button",{class:this.classes(T.esriButton,T.esriButtonTertiary,T.addBookmarkButton),onclick:this.startAddBookmark,afterCreate:this._storeAddBookmarkButton,afterUpdate:this._storeAddBookmarkButton,"data-node-ref":"_addBookmarkButtonNode",bind:this,type:"button"},y("span",{"aria-hidden":"true",class:this.classes(T.addBookmarkIcon,T.iconPlus)}),null==(t=this.messages)?void 0:t.addBookmark)):null}renderBookmarks(){const{bookmarks:t}=this.viewModel,e=t&&t.filter(Boolean),o=e&&e.length,i=o||this.editingEnabled?this.renderBookmarksContainer(e):null;return[o?null:this.renderNoBookmarksContainer(),i]}renderEditContainer(t){const{messagesCommon:e}=this;return y("div",{class:T.bookmarkEditButtonContainer,key:"edit-container"},y("button",{title:null==e?void 0:e.edit,"aria-label":null==e?void 0:e.edit,"data-bookmark":t,onclick:this._showEditBookmarkForm,bind:this,class:T.bookmarkEditButton,type:"button"},y("span",{"aria-hidden":"true",class:T.iconEdit})))}renderDragHandle(t){const{messagesCommon:e}=this,o={[A]:t.uid};return y("div",{role:"button",tabIndex:0,key:"drag-handle",bind:this,class:T.bookmarkDragHandle,onkeydown:this._dragHandleKeydown,afterCreate:this._focusDragHandle,afterUpdate:this._focusDragHandle,onblur:this._dragHandleBlur,"aria-pressed":this._selectedSortUid===t.uid?"true":"false","aria-label":null==e?void 0:e.dragHandleLabel,title:null==e?void 0:e.dragHandleTitle,...o},y("span",{"aria-hidden":"true",class:this.classes(T.bookmarkDragHandleIcon,T.iconHandle)}))}renderBookmarkImageIcon(){return y("span",{"aria-hidden":"true",class:this.classes(T.bookmarkIcon,T.widgetIcon)})}renderBookmarkImage(t){const{visibleElements:e}=this,{thumbnail:o}=t,i=o&&o.url||"";return e.thumbnail&&i?y("img",{src:i,alt:"",class:T.bookmarkImage}):null}renderBookmarkTimeSwitch(t){const{messages:e}=this,{timeExtent:o}=t,{view:i}=this.viewModel;return i.timeExtent||o?y("calcite-label",{layout:"inline-space-between","disable-spacing":"true"},e.includeTimeExtent,y("calcite-switch",{scale:"s",checked:!!o,onCalciteSwitchChange:t=>this._editIncludeTimeExtent=!!t.detail.switched})):null}renderBookmarkTimeExtent(t){const{visibleElements:e}=this,{timeExtent:o}=t;return o?y("span",{class:T.timeExtent},[i(o.start)&&y("span",{key:"start-date-group",class:T.timeExtentGroup},y("span",{key:"start-date",class:T.timeExtentDate},this._formatDate(o.start)),e.time&&y("span",{key:"start-time",class:T.timeExtentTime},this._formatTime(o.start))),i(o.end)&&(r(o.start)||o.start.getTime()!==o.end.getTime())&&y("span",{key:"end-date-group",class:T.timeExtentGroup},y("span",{key:"end-date",class:T.timeExtentDate},this._formatDate(o.end)),e.time&&y("span",{key:"end-time",class:T.timeExtentTime},this._formatTime(o.end)))]):null}renderBookmarkButton(t){const{messagesCommon:e}=this,{name:o,timeExtent:i}=t,{abilities:r}=this.viewModel,s=o||(null==e?void 0:e.untitled),a=y("div",{class:T.bookmarkImageContainer},this.renderBookmarkImage(t)||this.renderBookmarkImageIcon()),n=r.time&&i?y("span",{key:"time-extent",class:T.bookmarkTimeExtent},this.renderBookmarkTimeExtent(t)):null;return y("button",{key:"bookmark-button",class:T.bookmarkButton,bind:this,"data-bookmark":t,onclick:this._goToBookmark,type:"button"},a,y("div",{class:T.bookmarkLabel},y("span",{key:"bookmark-title",class:T.bookmarkName},s),n))}renderBookmark(t){const{activeBookmark:e}=this.viewModel,o={[T.bookmarkActive]:e===t},i=this.editingEnabled?this.renderEditContainer(t):null,r={[A]:t.uid},s=this.editingEnabled?this.renderDragHandle(t):null;return y("li",{key:t,class:this.classes(T.bookmark,o),...r},s,this.renderBookmarkButton(t),i)}renderEditingBookmarkName(t){const{messages:e,_userState:o}=this,i="name-required"===o.validationState;return y("label",{class:T.authoringLabel},null==e?void 0:e.title,i?y("strong",null,null==e?void 0:e.invalidTitle):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,i?T.authoringInputInvalid:null),type:"text",value:t.name,afterCreate:this._storeEditInput,afterUpdate:this._focusEditInput,"data-bookmark":t,"data-node-ref":"_editInputNode",placeholder:null==e?void 0:e.titlePlaceholder}))}renderEditingBookmarkUrlActions(){const{messagesCommon:t}=this;return y("div",{class:T.authoringActions},y("input",{type:"button",value:null==t?void 0:t.back,class:this.classes(T.esriButton,T.esriButtonTertiary),onclick:this._closeUrlEditBookmarkForm,bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.add}))}renderEditingBookmarkActions(){const{messagesCommon:t}=this,{bookmark:e}=this._userState;return y("div",{class:T.authoringActions},y("input",{type:"button",value:null==t?void 0:t.delete,class:this.classes(T.esriButton,T.esriButtonTertiary,T.authoringDeleteButton),"data-bookmark":e,onclick:this._deleteBookmark,bind:this}),y("input",{type:"button",value:null==t?void 0:t.cancel,class:this.classes(T.esriButton,T.esriButtonTertiary),onclick:this._closeEditBookmarkForm,bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.save}))}renderEditingBookmarkUrlInput(t){var e;const{messages:o,_userState:i}=this,r=null==(e=t.thumbnail)?void 0:e.url,s=U.test(r)?r:null,a="absolute-url-required"===i.validationState;return y("label",{class:T.authoringLabel},a?y("strong",null,null==o?void 0:o.invalidImageUrl):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,a?T.authoringInputInvalid:null),type:"text",value:s,afterCreate:this._storeUrlEditInput,afterUpdate:this._focusUrlEditInput,"data-bookmark":t,"data-node-ref":"_urlEditInputNode",title:null==o?void 0:o.imageUrlTooltip,placeholder:o&&`https://<${o.imageUrlPlaceholder}>`}))}renderEditingBookmarkUrl(t){const e={[A]:t.uid};return y("li",{key:"edit-bookmark-url-form",class:T.authoringCard,...e},y("form",{class:T.authoringForm,onsubmit:this._editBookmarkUrlSubmit,bind:this},this.renderEditingBookmarkUrlInput(t),this.renderEditingBookmarkUrlActions()))}renderEditingBookmark(t){const e={[A]:t.uid},{abilities:o}=this.viewModel,i=o.time?y("div",{key:"edit-bookmark-time-container",class:T.timeExtentContainer},this.renderBookmarkTimeSwitch(t),this._editIncludeTimeExtent&&this.renderBookmarkTimeExtent(t)):null;return y("li",{key:"edit-bookmark-form",class:T.authoringCard,...e},y("form",{class:T.authoringForm,onsubmit:this._editBookmarkSubmit,bind:this},y("div",{class:T.authoringContainer},y("div",{class:T.bookmarkImageContainer},this.renderBookmarkImage(t),this._editMenu.render()),this.renderEditingBookmarkName(t)),i,this.renderEditingBookmarkActions()))}renderAddingBookmarkName(){const{_userState:t,messages:e}=this,o="name-required"===t.validationState;return y("label",{class:T.authoringLabel},null==e?void 0:e.title,o?y("strong",null,null==e?void 0:e.invalidTitle):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,o?T.authoringInputInvalid:null),type:"text",afterCreate:this._storeAddInput,afterUpdate:this._focusAddInput,"data-node-ref":"_addInputNode",value:"",placeholder:null==e?void 0:e.titlePlaceholder}))}renderAddingBookmarkActions(){const{messagesCommon:t}=this;return y("div",{class:this.classes(T.authoringActions)},y("input",{type:"button",value:null==t?void 0:t.cancel,class:this.classes(T.esriButton,T.esriButtonTertiary,T.authoringCancelButton),onclick:this._endAddBookmark.bind(this),bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.add}))}renderAddingBookmark(){return y("div",{key:"add-bookmark-form",class:T.authoringCard},y("form",{class:T.authoringForm,onsubmit:this._addBookmarkSubmit,bind:this},this.renderAddingBookmarkName(),this.renderAddingBookmarkActions()))}_formatDate(t){return t?u(t,c("short-date")):null}_formatTime(t){return t?u(t,c("long-time")):null}_dragHandleBlur(){this._selectedSortUid=null,this.scheduleRender()}_dragHandleKeydown(t){const{_sortableSavedItems:o}=this,i=["ArrowDown","ArrowUp","Escape","Tab"," ","Enter"],r=e(t);if(-1===i.indexOf(r))return;const{_sortable:s,_selectedSortUid:a}=this,n=s.toArray(),d=t.target.getAttribute(A),l=n.indexOf(d);if(f(r)){const t=a&&a===d;return this._selectedSortUid=t?null:d,this._sortableSavedItems=t?null:this._sortable.toArray(),void this.scheduleRender()}if("Tab"===r)return this._selectedSortUid=null,void this.scheduleRender();if("Escape"===r&&o)return t.stopPropagation(),this._selectedSortUid=null,this._updateSortItems(o,s,d),void this.scheduleRender();if(-1===l||!a)return;const k="ArrowUp"===r?l-1:l+1;k>=n.length||k<=-1||(S(n,l,k),this._updateSortItems(n,s,d))}_updateSortItems(t,e,o){e.sort(t),this._sortBookmarks(e),this._focusSortUid=o,this._selectedSortUid=o}_focusDragHandle(t){const{_focusSortUid:e}=this;if(!t||!e)return;t.getAttribute(A)===e&&(t.focus(),this._focusSortUid=null)}_toggleSorting(){const{_sortable:t,_sortableNode:e,editingEnabled:o}=this;if(e)if(t)t.option("disabled",!o);else{const t=w.create(e,{dataIdAttr:A,handle:`.${T.bookmarkDragHandle}`,group:x,disabled:!o,onSort:()=>this._sortBookmarks(t)});this._sortable=t}}_sortNodeCreated(t){this._sortableNode=t,this._toggleSorting()}_sortBookmarks(t){const{bookmarks:e}=this.viewModel;if(!e)return;const o=t.toArray();e.sort(((t,e)=>{const i=o.indexOf(t.uid),r=o.indexOf(e.uid);return i>r?1:i<r?-1:0}))}_destroySortable(){const{_sortable:t}=this;t&&t.destroy(),this._sortable=null}_endAddBookmark(){this._focusAddBookmarkButton=!0,this.endAddBookmark()}_bookmarksInitialized(){const t="bookmarks-init",{_handles:e}=this;e.remove(t),e.add(a(this,"viewModel.bookmarks","change",(()=>this._bookmarksChanged())),t)}_bookmarksChanged(){const t="bookmarks-change",{bookmarks:e}=this.viewModel,{_handles:o}=this;o.remove(t);const i=e.map((t=>n(t,["active","name","thumbnail.url"],(()=>this.scheduleRender()))));o.add(i,t),this.scheduleRender()}_showEditBookmarkForm(t){const e=t.currentTarget["data-bookmark"];this._editIncludeTimeExtent=!!e.timeExtent,this._focusEditInputBox=!0,this._userState=new _({bookmark:e,state:"edit"}),this.viewModel.goTo(e),this.scheduleRender()}_closeUrlEditBookmarkForm(){this._focusEditInputBox=!0,this._userState.state="edit"}_closeEditBookmarkForm(){this._userState=null}_addBookmarkSubmit(t){t.preventDefault();const{_addInputNode:e,_userState:o}=this,i=e&&e.value.trim();i?(o.loading=!0,this.viewModel.createBookmark().then((t=>{t.name=i,this.viewModel.bookmarks.add(t),this._endAddBookmark()}))):o.validationState="name-required"}async _editBookmarkAndClose(t,e){const{viewModel:o}=this;await o.editBookmark(t,{...o.defaultEditOptions,...e}),this._closeEditBookmarkForm()}_editBookmarkSubmit(t){t.preventDefault();const{_editInputNode:e,_userState:o,_editIncludeTimeExtent:i}=this,r=e&&e.value.trim();r?(o.bookmark.name=r,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null),this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})):o.validationState="name-required"}_storeAddBookmarkButton(t){this._addBookmarkButtonNode=t,this._focusAddBookmark()}_storeEditInput(t){this._editInputNode=t,this._focusEditInput()}_storeAddInput(t){this._addInputNode=t,this._focusAddInput()}_storeUrlEditInput(t){this._urlEditInputNode=t,this._focusUrlEditInput()}_focusUrlEditInput(){this._urlEditInputNode&&this._focusUrlEditInputBox&&(this._focusUrlEditInputBox=!1,this._urlEditInputNode.focus())}_focusAddInput(){this._addInputNode&&this._focusAddInputBox&&(this._focusAddInputBox=!1,this._addInputNode.focus())}_focusAddBookmark(){this._addBookmarkButtonNode&&this._focusAddBookmarkButton&&(this._focusAddBookmarkButton=!1,this._addBookmarkButtonNode.focus())}_focusEditInput(){this._editInputNode&&this._focusEditInputBox&&(this._focusEditInputBox=!1,this._editInputNode.focus())}_deleteBookmark(t){const e=t.currentTarget["data-bookmark"];this.viewModel.bookmarks.remove(e)}_goToBookmark(t){const e=t.currentTarget["data-bookmark"];this.endAddBookmark(),this._closeEditBookmarkForm(),this.viewModel.goTo(e)}async _refreshThumbnail(){const{_userState:t,_editMenu:e,viewModel:o}=this;t.validationState=void 0,await o.editBookmark(this._userState.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}),e.open=!1,this._focusEditInputBox=!0,this.scheduleRender()}_removeThumbnail(){const{_userState:t,_editMenu:e}=this;t.editedBookmark.thumbnail=null,t.validationState=void 0,e.open=!1,this._focusEditInputBox=!0,this.scheduleRender()}_startUseImageUrl(){this._userState.state="edit-thumbnail",this._editMenu.open=!1,this._focusUrlEditInputBox=!0,this.scheduleRender()}_editBookmarkUrlSubmit(t){t.preventDefault();const{_urlEditInputNode:e,_userState:o}=this,i=e.value;U.test(i)?(i&&(o.editedBookmark.thumbnail=new h({url:i})),this._closeUrlEditBookmarkForm()):o.validationState="absolute-url-required"}};t([k()],N.prototype,"_editIncludeTimeExtent",void 0),t([k({type:_})],N.prototype,"_userState",void 0),t([k({readOnly:!0})],N.prototype,"_editMenuItems",null),t([k({readOnly:!0})],N.prototype,"_editMenu",null),t([d("viewModel.defaultCreateOptions")],N.prototype,"defaultCreateOptions",void 0),t([d("viewModel.defaultEditOptions")],N.prototype,"defaultEditOptions",void 0),t([d("viewModel.bookmarks")],N.prototype,"bookmarks",void 0),t([k()],N.prototype,"disabled",void 0),t([k()],N.prototype,"editingEnabled",void 0),t([k()],N.prototype,"headingLevel",void 0),t([d("viewModel.goToOverride")],N.prototype,"goToOverride",void 0),t([k()],N.prototype,"iconClass",void 0),t([k({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],N.prototype,"label",void 0),t([k(),E("esri/widgets/Bookmarks/t9n/Bookmarks")],N.prototype,"messages",void 0),t([k(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),t([k(),E("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),t([k()],N.prototype,"uiStrings",void 0),t([d("viewModel.view")],N.prototype,"view",void 0),t([k({type:p}),I(["select-bookmark","bookmark-edit","bookmark-select"])],N.prototype,"viewModel",void 0),t([k()],N.prototype,"visibleElements",void 0),t([l("visibleElements")],N.prototype,"castVisibleElements",null),t([k()],N.prototype,"endAddBookmark",null),t([k()],N.prototype,"startAddBookmark",null),N=t([m(M)],N);const j=N;export{j as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import o from"../core/Handles.js";import{isSome as i,isNone as r}from"../core/maybe.js";import{init as s,on as a,watch as n}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import{property as k}from"../core/accessorSupport/decorators/property.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as u,convertDateFormatToIntlOptions as c}from"../intl/date.js";import{SlideThumbnail as h}from"../webdoc/support/SlideThumbnail.js";import b from"./Widget.js";import _ from"./Bookmarks/BookmarksUserState.js";import p from"./Bookmarks/BookmarksViewModel.js";import g from"./FeatureTable/Grid/support/ButtonMenu.js";import B from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{Heading as v}from"./support/Heading.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as y}from"./support/jsxFactory.js";import w from"sortablejs";function S(t,e,o){t.splice(o,0,t.splice(e,1)[0])}const x="bookmarks",A="data-bookmark-uid",T={base:"esri-bookmarks esri-widget--panel",loaderContainer:"esri-bookmarks__loader-container",loader:"esri-bookmarks__loader",fadeIn:"esri-bookmarks--fade-in",bookmarkList:"esri-bookmarks__list",bookmarkListSortable:"esri-bookmarks__list--sortable",bookmark:"esri-bookmarks__bookmark",bookmarkButton:"esri-bookmarks__bookmark-button",bookmarkImageContainer:"esri-bookmarks__bookmark-image-container",bookmarkEditButtonContainer:"esri-bookmarks__bookmark-edit-button-container",bookmarkEditButton:"esri-bookmarks__bookmark-edit-button",bookmarkDragHandle:"esri-bookmarks_bookmark-drag-handle",bookmarkDragHandleIcon:"esri-bookmarks_bookmark-drag-handle-icon",bookmarkIcon:"esri-bookmarks__bookmark-icon",bookmarkImage:"esri-bookmarks__image",bookmarkLabel:"esri-bookmarks__bookmark-label",bookmarkName:"esri-bookmarks__bookmark-name",bookmarkTimeExtent:"esri-bookmarks__bookmark-time-extent",bookmarkActive:"esri-bookmarks__bookmark--active",noBookmarksContainer:"esri-widget__content--empty",noBookmarksHeader:"esri-bookmarks__no-bookmarks-heading",noBookmarksIcon:"esri-widget__no-bookmark-icon",noBookmarksDescription:"esri-bookmarks__no-bookmarks-description",addingBookmark:"esri-bookmarks__adding-bookmark",addBookmark:"esri-bookmarks__add-bookmark",addBookmarkButton:"esri-bookmarks__add-bookmark-button",addBookmarkIcon:"esri-bookmarks__add-bookmark-icon",authoringCard:"esri-bookmarks__authoring-card",authoringContainer:"esri-bookmarks__authoring-container",authoringForm:"esri-bookmarks__authoring-form",authoringLabel:"esri-bookmarks__authoring-label",authoringActions:"esri-bookmarks__authoring-actions",authoringInputInvalid:"esri-bookmarks__authoring-input--invalid",authoringDeleteButton:"esri-bookmarks__authoring-delete-button",authoringCancelButton:"esri-bookmarks__authoring-cancel-button",timeExtentContainer:"esri-bookmarks__time-extent-container",timeExtent:"esri-bookmarks__time-extent",timeExtentGroup:"esri-bookmarks__time-extent-group",timeExtentDate:"esri-bookmarks__time-extent-date",timeExtentTime:"esri-bookmarks__time-extent-time",esriWidget:"esri-widget",esriWidgetDisabled:"esri-widget--disabled",esriButton:"esri-button",esriButtonTertiary:"esri-button--tertiary",esriInput:"esri-input",iconHandle:"esri-icon-handle-vertical",iconPlus:"esri-icon-plus",iconEdit:"esri-icon-edit",iconHandleHorizontal:"esri-icon-handle-horizontal",iconRefresh:"esri-icon-refresh",iconLink:"esri-icon-link",iconRemove:"esri-icon-erase",widgetIcon:"esri-icon-bookmark",header:"esri-widget__heading",loading:"esri-icon-loading-indicator",rotating:"esri-rotating"},C={addBookmark:!0,thumbnail:!0,time:!0},U=/^https:\/\/.*/i,M="esri.widgets.Bookmarks";let N=class extends b{constructor(t,e){super(t,e),this._handles=new o,this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._addBookmarkButtonNode=null,this._focusAddBookmarkButton=!1,this._focusEditInputBox=!1,this._focusAddInputBox=!1,this._focusUrlEditInputBox=!1,this._sortable=null,this._sortableNode=null,this._focusSortUid=null,this._selectedSortUid=null,this._sortableSavedItems=null,this._editIncludeTimeExtent=null,this._userState=null,this.defaultCreateOptions=null,this.defaultEditOptions=null,this.bookmarks=null,this.disabled=!1,this.editingEnabled=!1,this.headingLevel=2,this.goToOverride=null,this.iconClass=T.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.view=null,this.viewModel=new p,this.visibleElements={...C}}initialize(){this.own([s(this,"viewModel.bookmarks",(()=>this._bookmarksInitialized())),s(this,"editingEnabled",(()=>this._toggleSorting()))])}destroy(){this._destroySortable(),this._handles.destroy(),this._handles=null,this._editMenu.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}get _editMenuItems(){var t,e;const{messages:o,_userState:i}=this,r=null==i||null==(t=i.editedBookmark)||null==(e=t.thumbnail)?void 0:e.url;return[new B({label:null==o?void 0:o.menu.refreshThumbnail,iconClass:T.iconRefresh,clickFunction:()=>this._refreshThumbnail()}),new B({label:U.test(r)?null==o?void 0:o.menu.editImageUrl:null==o?void 0:o.menu.useImageUrl,iconClass:T.iconLink,clickFunction:()=>this._startUseImageUrl()}),r?new B({label:null==o?void 0:o.menu.removeThumbnail,iconClass:T.iconRemove,clickFunction:()=>this._removeThumbnail()}):null].filter(Boolean)}get _editMenu(){const{_editMenuItems:t,messages:e}=this,o=this._get("_editMenu");o&&o.destroy();const i=new g({iconClass:T.iconHandleHorizontal,label:null==e?void 0:e.menu.label});return i.items=t,i}castVisibleElements(t){return{...C,...t}}endAddBookmark(){this._userState=null}goTo(t){return this.viewModel.goTo(t)}render(){const{state:t}=this.viewModel,e="loading"===t?this.renderLoading():this.renderBookmarks();return y("div",{class:this.classes(T.base,T.esriWidget,{[T.esriWidgetDisabled]:this.disabled})},e)}startAddBookmark(){this._userState=new _({state:"add"}),this._focusAddInputBox=!0,this.scheduleRender()}renderLoading(){return y("div",{class:T.loaderContainer,key:"loader"},y("div",{class:T.loader}))}renderNoBookmarksContainer(){const{messages:t}=this;return y("div",{class:T.noBookmarksContainer,key:"no-bookmarks"},y("span",{"aria-hidden":"true",class:this.classes(T.noBookmarksIcon,T.widgetIcon)}),y(v,{level:this.headingLevel,class:this.classes(T.header,T.noBookmarksHeader)},null==t?void 0:t.noBookmarksHeading),y("p",{class:T.noBookmarksDescription},null==t?void 0:t.noBookmarksDescription))}renderAddBookmarkLoading(){var t;return y("div",{key:"adding-bookmark",class:T.addingBookmark},y("span",{"aria-hidden":"true",class:this.classes(T.loading,T.rotating)}),null==(t=this.messages)?void 0:t.addingBookmark)}renderBookmarkItems(t){if(!t)return null;const{_userState:e,editingEnabled:o}=this;return t.map((t=>o&&t&&e&&("edit"===e.state||"edit-thumbnail"===e.state)&&e.bookmark===t?"edit-thumbnail"===e.state?this.renderEditingBookmarkUrl(e.editedBookmark):this.renderEditingBookmark(e.editedBookmark):this.renderBookmark(t))).toArray()}renderBookmarksContainer(t){var e;const{_userState:o,editingEnabled:i}=this,r="add"===(null==o?void 0:o.state),s=i&&!r?this.renderAddBookmarkButton():null,a=i?r&&o.loading?this.renderAddBookmarkLoading():"add"===(null==o?void 0:o.state)?this.renderAddingBookmark():null:null;return[y("ul",{key:"bookmark-list","aria-label":null==(e=this.messages)?void 0:e.widgetLabel,class:this.classes(T.bookmarkList,{[T.bookmarkListSortable]:this.editingEnabled}),afterCreate:this._sortNodeCreated,afterRemoved:this._destroySortable,"data-node-ref":"_sortableNode",bind:this},this.renderBookmarkItems(t)),s,a]}renderAddBookmarkButton(){var t;return this.visibleElements.addBookmark?y("div",{key:"add-bookmark-item",class:T.addBookmark},y("button",{class:this.classes(T.esriButton,T.esriButtonTertiary,T.addBookmarkButton),onclick:this.startAddBookmark,afterCreate:this._storeAddBookmarkButton,afterUpdate:this._storeAddBookmarkButton,"data-node-ref":"_addBookmarkButtonNode",bind:this,type:"button"},y("span",{"aria-hidden":"true",class:this.classes(T.addBookmarkIcon,T.iconPlus)}),null==(t=this.messages)?void 0:t.addBookmark)):null}renderBookmarks(){const{bookmarks:t}=this.viewModel,e=t&&t.filter(Boolean),o=e&&e.length,i=o||this.editingEnabled?this.renderBookmarksContainer(e):null;return[o?null:this.renderNoBookmarksContainer(),i]}renderEditContainer(t){const{messagesCommon:e}=this;return y("div",{class:T.bookmarkEditButtonContainer,key:"edit-container"},y("button",{title:null==e?void 0:e.edit,"aria-label":null==e?void 0:e.edit,"data-bookmark":t,onclick:this._showEditBookmarkForm,bind:this,class:T.bookmarkEditButton,type:"button"},y("span",{"aria-hidden":"true",class:T.iconEdit})))}renderDragHandle(t){const{messagesCommon:e}=this,o={[A]:t.uid};return y("div",{role:"button",tabIndex:0,key:"drag-handle",bind:this,class:T.bookmarkDragHandle,onkeydown:this._dragHandleKeydown,afterCreate:this._focusDragHandle,afterUpdate:this._focusDragHandle,onblur:this._dragHandleBlur,"aria-pressed":this._selectedSortUid===t.uid?"true":"false","aria-label":null==e?void 0:e.dragHandleLabel,title:null==e?void 0:e.dragHandleTitle,...o},y("span",{"aria-hidden":"true",class:this.classes(T.bookmarkDragHandleIcon,T.iconHandle)}))}renderBookmarkImageIcon(){return y("span",{"aria-hidden":"true",class:this.classes(T.bookmarkIcon,T.widgetIcon)})}renderBookmarkImage(t){const{visibleElements:e}=this,{thumbnail:o}=t,i=o&&o.url||"";return e.thumbnail&&i?y("img",{src:i,alt:"",class:T.bookmarkImage}):null}renderBookmarkTimeSwitch(t){const{messages:e}=this,{timeExtent:o}=t,{view:i}=this.viewModel;return i.timeExtent||o?y("calcite-label",{layout:"inline-space-between","disable-spacing":"true"},e.includeTimeExtent,y("calcite-switch",{scale:"s",checked:!!o,onCalciteSwitchChange:t=>this._editIncludeTimeExtent=!!t.detail.switched})):null}renderBookmarkTimeExtent(t){const{visibleElements:e}=this,{timeExtent:o}=t;return o?y("span",{class:T.timeExtent},[i(o.start)&&y("span",{key:"start-date-group",class:T.timeExtentGroup},y("span",{key:"start-date",class:T.timeExtentDate},this._formatDate(o.start)),e.time&&y("span",{key:"start-time",class:T.timeExtentTime},this._formatTime(o.start))),i(o.end)&&(r(o.start)||o.start.getTime()!==o.end.getTime())&&y("span",{key:"end-date-group",class:T.timeExtentGroup},y("span",{key:"end-date",class:T.timeExtentDate},this._formatDate(o.end)),e.time&&y("span",{key:"end-time",class:T.timeExtentTime},this._formatTime(o.end)))]):null}renderBookmarkButton(t){const{messagesCommon:e}=this,{name:o,timeExtent:i}=t,{abilities:r}=this.viewModel,s=o||(null==e?void 0:e.untitled),a=y("div",{class:T.bookmarkImageContainer},this.renderBookmarkImage(t)||this.renderBookmarkImageIcon()),n=r.time&&i?y("span",{key:"time-extent",class:T.bookmarkTimeExtent},this.renderBookmarkTimeExtent(t)):null;return y("button",{key:"bookmark-button",class:T.bookmarkButton,bind:this,"data-bookmark":t,onclick:this._goToBookmark,type:"button"},a,y("div",{class:T.bookmarkLabel},y("span",{key:"bookmark-title",class:T.bookmarkName},s),n))}renderBookmark(t){const{activeBookmark:e}=this.viewModel,o={[T.bookmarkActive]:e===t},i=this.editingEnabled?this.renderEditContainer(t):null,r={[A]:t.uid},s=this.editingEnabled?this.renderDragHandle(t):null;return y("li",{key:t,class:this.classes(T.bookmark,o),...r},s,this.renderBookmarkButton(t),i)}renderEditingBookmarkName(t){const{messages:e,_userState:o}=this,i="name-required"===o.validationState;return y("label",{class:T.authoringLabel},null==e?void 0:e.title,i?y("strong",null,null==e?void 0:e.invalidTitle):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,i?T.authoringInputInvalid:null),type:"text",value:t.name,afterCreate:this._storeEditInput,afterUpdate:this._focusEditInput,"data-bookmark":t,"data-node-ref":"_editInputNode",placeholder:null==e?void 0:e.titlePlaceholder}))}renderEditingBookmarkUrlActions(){const{messagesCommon:t}=this;return y("div",{class:T.authoringActions},y("input",{type:"button",value:null==t?void 0:t.back,class:this.classes(T.esriButton,T.esriButtonTertiary),onclick:this._closeUrlEditBookmarkForm,bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.add}))}renderEditingBookmarkActions(){const{messagesCommon:t}=this,{bookmark:e}=this._userState;return y("div",{class:T.authoringActions},y("input",{type:"button",value:null==t?void 0:t.delete,class:this.classes(T.esriButton,T.esriButtonTertiary,T.authoringDeleteButton),"data-bookmark":e,onclick:this._deleteBookmark,bind:this}),y("input",{type:"button",value:null==t?void 0:t.cancel,class:this.classes(T.esriButton,T.esriButtonTertiary),onclick:this._closeEditBookmarkForm,bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.save}))}renderEditingBookmarkUrlInput(t){var e;const{messages:o,_userState:i}=this,r=null==(e=t.thumbnail)?void 0:e.url,s=U.test(r)?r:null,a="absolute-url-required"===i.validationState;return y("label",{class:T.authoringLabel},a?y("strong",null,null==o?void 0:o.invalidImageUrl):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,a?T.authoringInputInvalid:null),type:"text",value:s,afterCreate:this._storeUrlEditInput,afterUpdate:this._focusUrlEditInput,"data-bookmark":t,"data-node-ref":"_urlEditInputNode",title:null==o?void 0:o.imageUrlTooltip,placeholder:o&&`https://<${o.imageUrlPlaceholder}>`}))}renderEditingBookmarkUrl(t){const e={[A]:t.uid};return y("li",{key:"edit-bookmark-url-form",class:T.authoringCard,...e},y("form",{class:T.authoringForm,onsubmit:this._editBookmarkUrlSubmit,bind:this},this.renderEditingBookmarkUrlInput(t),this.renderEditingBookmarkUrlActions()))}renderEditingBookmark(t){const e={[A]:t.uid},{abilities:o}=this.viewModel,i=o.time?y("div",{key:"edit-bookmark-time-container",class:T.timeExtentContainer},this.renderBookmarkTimeSwitch(t),this._editIncludeTimeExtent&&this.renderBookmarkTimeExtent(t)):null;return y("li",{key:"edit-bookmark-form",class:T.authoringCard,...e},y("form",{class:T.authoringForm,onsubmit:this._editBookmarkSubmit,bind:this},y("div",{class:T.authoringContainer},y("div",{class:T.bookmarkImageContainer},this.renderBookmarkImage(t),this._editMenu.render()),this.renderEditingBookmarkName(t)),i,this.renderEditingBookmarkActions()))}renderAddingBookmarkName(){const{_userState:t,messages:e}=this,o="name-required"===t.validationState;return y("label",{class:T.authoringLabel},null==e?void 0:e.title,o?y("strong",null,null==e?void 0:e.invalidTitle):null,y("input",{required:!0,bind:this,class:this.classes(T.esriInput,o?T.authoringInputInvalid:null),type:"text",afterCreate:this._storeAddInput,afterUpdate:this._focusAddInput,"data-node-ref":"_addInputNode",value:"",placeholder:null==e?void 0:e.titlePlaceholder}))}renderAddingBookmarkActions(){const{messagesCommon:t}=this;return y("div",{class:this.classes(T.authoringActions)},y("input",{type:"button",value:null==t?void 0:t.cancel,class:this.classes(T.esriButton,T.esriButtonTertiary,T.authoringCancelButton),onclick:this._endAddBookmark.bind(this),bind:this}),y("input",{class:T.esriButton,type:"submit",value:null==t?void 0:t.add}))}renderAddingBookmark(){return y("div",{key:"add-bookmark-form",class:T.authoringCard},y("form",{class:T.authoringForm,onsubmit:this._addBookmarkSubmit,bind:this},this.renderAddingBookmarkName(),this.renderAddingBookmarkActions()))}_formatDate(t){return t?u(t,c("short-date")):null}_formatTime(t){return t?u(t,c("long-time")):null}_dragHandleBlur(){this._selectedSortUid=null,this.scheduleRender()}_dragHandleKeydown(t){const{_sortableSavedItems:o}=this,i=["ArrowDown","ArrowUp","Escape","Tab"," ","Enter"],r=e(t);if(-1===i.indexOf(r))return;const{_sortable:s,_selectedSortUid:a}=this,n=s.toArray(),d=t.target.getAttribute(A),l=n.indexOf(d);if(f(r)){const t=a&&a===d;return this._selectedSortUid=t?null:d,this._sortableSavedItems=t?null:this._sortable.toArray(),void this.scheduleRender()}if("Tab"===r)return this._selectedSortUid=null,void this.scheduleRender();if("Escape"===r&&o)return t.stopPropagation(),this._selectedSortUid=null,this._updateSortItems(o,s,d),void this.scheduleRender();if(-1===l||!a)return;const k="ArrowUp"===r?l-1:l+1;k>=n.length||k<=-1||(S(n,l,k),this._updateSortItems(n,s,d))}_updateSortItems(t,e,o){e.sort(t),this._sortBookmarks(e),this._focusSortUid=o,this._selectedSortUid=o}_focusDragHandle(t){const{_focusSortUid:e}=this;if(!t||!e)return;t.getAttribute(A)===e&&(t.focus(),this._focusSortUid=null)}_toggleSorting(){const{_sortable:t,_sortableNode:e,editingEnabled:o}=this;if(e)if(t)t.option("disabled",!o);else{const t=w.create(e,{dataIdAttr:A,handle:`.${T.bookmarkDragHandle}`,group:x,disabled:!o,onSort:()=>this._sortBookmarks(t)});this._sortable=t}}_sortNodeCreated(t){this._sortableNode=t,this._toggleSorting()}_sortBookmarks(t){const{bookmarks:e}=this.viewModel;if(!e)return;const o=t.toArray();e.sort(((t,e)=>{const i=o.indexOf(t.uid),r=o.indexOf(e.uid);return i>r?1:i<r?-1:0}))}_destroySortable(){const{_sortable:t}=this;t&&t.destroy(),this._sortable=null}_endAddBookmark(){this._focusAddBookmarkButton=!0,this.endAddBookmark()}_bookmarksInitialized(){const t="bookmarks-init",{_handles:e}=this;e.remove(t),e.add(a(this,"viewModel.bookmarks","change",(()=>this._bookmarksChanged())),t)}_bookmarksChanged(){const t="bookmarks-change",{bookmarks:e}=this.viewModel,{_handles:o}=this;o.remove(t);const i=e.map((t=>n(t,["active","name","thumbnail.url"],(()=>this.scheduleRender()))));o.add(i,t),this.scheduleRender()}_showEditBookmarkForm(t){const e=t.currentTarget["data-bookmark"];this._editIncludeTimeExtent=!!e.timeExtent,this._focusEditInputBox=!0,this._userState=new _({bookmark:e,state:"edit"}),this.viewModel.goTo(e),this.scheduleRender()}_closeUrlEditBookmarkForm(){this._focusEditInputBox=!0,this._userState.state="edit"}_closeEditBookmarkForm(){this._userState=null}_addBookmarkSubmit(t){t.preventDefault();const{_addInputNode:e,_userState:o}=this,i=e&&e.value.trim();i?(o.loading=!0,this.viewModel.createBookmark().then((t=>{t.name=i,this.viewModel.bookmarks.add(t),this._endAddBookmark()}))):o.validationState="name-required"}async _editBookmarkAndClose(t,e){const{viewModel:o}=this;await o.editBookmark(t,{...o.defaultEditOptions,...e}),this._closeEditBookmarkForm()}_editBookmarkSubmit(t){t.preventDefault();const{_editInputNode:e,_userState:o,_editIncludeTimeExtent:i}=this,r=e&&e.value.trim();r?(o.bookmark.name=r,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null),this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})):o.validationState="name-required"}_storeAddBookmarkButton(t){this._addBookmarkButtonNode=t,this._focusAddBookmark()}_storeEditInput(t){this._editInputNode=t,this._focusEditInput()}_storeAddInput(t){this._addInputNode=t,this._focusAddInput()}_storeUrlEditInput(t){this._urlEditInputNode=t,this._focusUrlEditInput()}_focusUrlEditInput(){this._urlEditInputNode&&this._focusUrlEditInputBox&&(this._focusUrlEditInputBox=!1,this._urlEditInputNode.focus())}_focusAddInput(){this._addInputNode&&this._focusAddInputBox&&(this._focusAddInputBox=!1,this._addInputNode.focus())}_focusAddBookmark(){this._addBookmarkButtonNode&&this._focusAddBookmarkButton&&(this._focusAddBookmarkButton=!1,this._addBookmarkButtonNode.focus())}_focusEditInput(){this._editInputNode&&this._focusEditInputBox&&(this._focusEditInputBox=!1,this._editInputNode.focus())}_deleteBookmark(t){const e=t.currentTarget["data-bookmark"];this.viewModel.bookmarks.remove(e)}_goToBookmark(t){const e=t.currentTarget["data-bookmark"];this.endAddBookmark(),this._closeEditBookmarkForm(),this.viewModel.goTo(e)}async _refreshThumbnail(){const{_userState:t,_editMenu:e,viewModel:o}=this;t.validationState=void 0,await o.editBookmark(this._userState.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}),e.open=!1,this._focusEditInputBox=!0,this.scheduleRender()}_removeThumbnail(){const{_userState:t,_editMenu:e}=this;t.editedBookmark.thumbnail=null,t.validationState=void 0,e.open=!1,this._focusEditInputBox=!0,this.scheduleRender()}_startUseImageUrl(){this._userState.state="edit-thumbnail",this._editMenu.open=!1,this._focusUrlEditInputBox=!0,this.scheduleRender()}_editBookmarkUrlSubmit(t){t.preventDefault();const{_urlEditInputNode:e,_userState:o}=this,i=e.value;U.test(i)?(i&&(o.editedBookmark.thumbnail=new h({url:i})),this._closeUrlEditBookmarkForm()):o.validationState="absolute-url-required"}};t([k()],N.prototype,"_editIncludeTimeExtent",void 0),t([k({type:_})],N.prototype,"_userState",void 0),t([k({readOnly:!0})],N.prototype,"_editMenuItems",null),t([k({readOnly:!0})],N.prototype,"_editMenu",null),t([d("viewModel.defaultCreateOptions")],N.prototype,"defaultCreateOptions",void 0),t([d("viewModel.defaultEditOptions")],N.prototype,"defaultEditOptions",void 0),t([d("viewModel.bookmarks")],N.prototype,"bookmarks",void 0),t([k()],N.prototype,"disabled",void 0),t([k()],N.prototype,"editingEnabled",void 0),t([k()],N.prototype,"headingLevel",void 0),t([d("viewModel.goToOverride")],N.prototype,"goToOverride",void 0),t([k()],N.prototype,"iconClass",void 0),t([k({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],N.prototype,"label",void 0),t([k(),E("esri/widgets/Bookmarks/t9n/Bookmarks")],N.prototype,"messages",void 0),t([k(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),t([k(),E("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),t([k()],N.prototype,"uiStrings",void 0),t([d("viewModel.view")],N.prototype,"view",void 0),t([k({type:p}),I(["select-bookmark","bookmark-edit","bookmark-select"])],N.prototype,"viewModel",void 0),t([k()],N.prototype,"visibleElements",void 0),t([l("visibleElements")],N.prototype,"castVisibleElements",null),t([k()],N.prototype,"endAddBookmark",null),t([k()],N.prototype,"startAddBookmark",null),N=t([m(M)],N);const j=N;export{j 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Handles.js";import l from"../../core/Logger.js";import{isNone as n}from"../../core/maybe.js";import{isAbortError as u,isPromiseLike as c}from"../../core/promiseUtils.js";import{on as p,init as h,watch as d}from"../../core/watchUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{graphicsExtent as g}from"../../geometry/support/graphicsUtils.js";import{getLocale as y}from"../../intl/locale.js";import w from"../../layers/GraphicsLayer.js";import{fetchServiceDescription as f}from"../../rest/networkService.js";import b from"../../rest/support/NetworkFeatureSet.js";import _ from"../../rest/support/RouteParameters.js";import T from"../../tasks/RouteTask.js";import{isWaypoint as S,isStopLocated as L,isFirstStop as C,isLastStop as R}from"./support/directionsUtils.js";import{GoToMixin as A}from"../support/GoTo.js";import D from"../../symbols/SimpleMarkerSymbol.js";import M from"../../symbols/PictureMarkerSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";const N=l.getLogger("esri.widgets.Directions.DirectionsViewModel"),z={first:new D({color:[105,220,255,1],size:19,outline:{color:[51,51,51,1],width:3}}),middle:new D({color:[51,51,51,1],size:12,outline:{color:[105,220,255,1],width:3}}),last:new M({width:23,height:23,url:`data:image/svg+xml;base64,${btoa('<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new M({height:18,width:18,url:`data:image/svg+xml;base64,${btoa('<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="#69DCFF" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>')}`}),waypoint:new D({color:[255,255,255,1],size:10,outline:{color:[20,89,127,1],width:2.5}})};var U;!function(e){e[e.Idle=0]="Idle",e[e.Active=1]="Active",e[e.Complete=2]="Complete",e[e.Failed=3]="Failed",e[e.Suspended=4]="Suspended"}(U||(U={}));let x=class extends(A(i.EventedAccessor)){constructor(e){super(e),this._handles=new a,this._routeLayer=new w({listMode:"hide"}),this._highlightLayer=new w({listMode:"hide"}),this._stopId=9999,this._stopLayer=new w({listMode:"hide"}),this._serviceDescriptionLoadStatus=U.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeSymbol=new j({color:[105,220,255,1],width:7,cap:"round",join:"round"}),this.routeParameters=new _({ignoreInvalidLocations:!0,directionsOutputType:"complete",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,restrictUTurns:"at-dead-ends-and-intersections",directionsLengthUnits:"kilometers",returnBarriers:!1,returnDirections:!0,returnPolygonBarriers:!1,returnPolylineBarriers:!1,returnRoutes:!1,returnStops:!0,returnZ:!0,startTime:null,startTimeIsUTC:!0,stops:null,useHierarchy:!0,useTimeWindows:!1}),this.routeServiceUrl="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",this.serviceDescription=null,this.error=null,this.stops=new s,this.view=null}initialize(){this._handles.add([p(this,"stops","change",(()=>{this.clearResults(),this._addStopsToLayer()})),h(this,"view.map",((e,t)=>{const r=[this._routeLayer,this._stopLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)})),d(this,"lastRoute",(()=>this._addRouteToLayer()))])}destroy(){this.stops.destroy();const e=this.get("view.map");e&&e.removeMany([this._routeLayer,this._stopLayer,this._highlightLayer])}get _directionsLanguage(){const{routeParameters:e,serviceDescription:t}=this,{directionsSupportedLanguages:r}=t;if(!r)return;const s=(e.directionsLanguage||y()).slice(0,2);return r.find((e=>e.toLowerCase().slice(0,2)===s))}get _routeTask(){return new T(this.routeServiceUrl)}get impedanceAttribute(){var e,t,r,s,o,i;const a=null!=(e=null!=(t=null==(r=this.routeParameters)||null==(s=r.travelMode)?void 0:s.impedanceAttributeName)?t:null==(o=this.routeParameters)?void 0:o.impedanceAttribute)?e:null==(i=this.serviceDescription)?void 0:i.impedance;return this.getCostAttribute(a)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get selectedTravelMode(){const{serviceDescription:e}=this;if(!e)return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;let s=null;for(let o=0;o<r.length;o++)r[o].id===t&&(s=r[o]);return s||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){const e=this._serviceDescriptionLoadStatus;return e===U.Suspended?"unauthenticated":e===U.Idle?"disabled":e===U.Active?"initializing":this._activeRouteController?"routing":e===U.Failed||this.error?"error":"ready"}set stopSymbols(e){const t={...z,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r,s,o,i;const a=null!=(e=null!=(t=null==(r=this.routeParameters)||null==(s=r.travelMode)?void 0:s.timeAttributeName)?t:null==(o=this.routeParameters)?void 0:o.directionsTimeAttribute)?e:null==(i=this.serviceDescription)?void 0:i.directionsTimeAttribute;return this.getCostAttribute(a)}get travelModes(){var e,t;return null!=(e=null==(t=this.serviceDescription)?void 0:t.supportedTravelModes)?e:[]}async load(){if(!this.serviceDescription)try{this._serviceDescriptionLoadStatus=U.Active,this.notifyChange("state"),await this._loadServiceDescription(),this._serviceDescriptionLoadStatus=U.Complete,this.notifyChange("state")}catch(e){const t="identity-manager:user-aborted"===e.name;if(this._serviceDescriptionLoadStatus=t?U.Suspended:U.Failed,this.notifyChange("state"),!t){const t=new o("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:e});throw this._set("error",t),t}}}highlightSegment(e){const{view:s,_highlightLayer:o}=this;if(!s||n(e.symbol))return;this.clearHighlights();const i=e.symbol.clone();i.color=new t([0,0,0,.8]),i.width=Math.ceil(i.width/2);const a=new r({geometry:e.geometry,symbol:i});o.graphics.add(a)}clearHighlights(){this._highlightLayer.graphics.removeAll()}centerAt(e){const{view:t}=this;t&&this.callGoTo({target:e})}clearResults(){this._set("lastRoute",null)}getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionLoadStatus===U.Failed)return Promise.reject(new o("directions-view-model:not-loaded","Cannot get directions until view model loads."));this._set("error",null),this._activeRouteController&&(this._activeRouteController.abort(),this._activeRouteController=null);const{apiKey:t,departureTime:r}=this,s="now"===r,i="now"===r?new Date:r;if(i&&!s){const e=60*i.getTimezoneOffset()*1e3;i.setTime(i.getTime()-e)}const a=this.routeParameters.clone();if(a.set({startTime:i,startTimeIsUTC:s,directionsLanguage:this._directionsLanguage,apiKey:t}),this.selectedTravelMode&&(a.travelMode=this.selectedTravelMode),this.stops.length<=1){const e=new o("directions-view-model:not-enough-stops","Not enough stops for routing");return this._set("error",e),Promise.reject(e)}const l=new AbortController,{signal:n}=l;this._activeRouteController=l;const c=this._enqueue((()=>{const e=this.stops.clone().toArray(),t={},r=r=>{const s=r&&r.routeResults&&r.routeResults[0]&&r.routeResults[0].stops||[];(r&&r.routeResults&&r.routeResults[0]&&r.routeResults[0].directions&&r.routeResults[0].directions.features||[]).map((r=>{for(let s=0;s<e.length;s++)if(r.attributes.text.indexOf(e[s].attributes.Name)>-1){const o=e[s].attributes.Name;r.attributes.text=r.attributes.text.replace(o,t[o]),r._associatedStop=e[s];break}})),e.map((e=>e.attributes.Name=t[e.attributes.Name])),s.map((e=>{e.attributes.Name=t[e.attributes.Name]}))},s=e=>{if(e&&e.routeResults&&e.routeResults[0]){const t=e.routeResults[0],r=t.stops||[],s=this.stops.clone().toArray();let o=t.directions&&t.directions.routeName||t.routeName||"";r.map(((e,t)=>{const r=e.attributes,i=s[t].attributes;o=o.replace(r.Name,i.Name),Object.keys(r).forEach((e=>{0===e.indexOf("Cumul_")&&(i[e]=r[e])})),i.ArriveCurbApproach=r.ArriveCurbApproach,i.ArriveTime=r.ArriveTime,i.ArriveTimeUTC=r.ArriveTimeUTC,i.DepartCurbApproach=r.DepartCurbApproach,i.DepartTime=r.DepartTime,i.DepartTimeUTC=r.DepartTimeUTC,i.Sequence=r.Sequence,i.Status=r.Status})),t.directions&&(t.directions.routeName=o),null!==t.route&&(t.route.attributes.Name=o),t.routeName=o}},o=e=>{const r=e&&e.routeResults&&e.routeResults[0]&&e.routeResults[0].stops||[],s=this.stops.toArray();let o=r.length===s.length,i=0;for(;o&&i<r.length;)o=o&&t[r[i].attributes.Name]===s[i++].attributes.Name;return o};return(()=>{e.map((e=>{const r=e.attributes,s=`${(r.Name||"[not yet geocoded]").substr(0,100)}_#${++this._stopId}`;t[s]=r.Name,r.Name=s}))})(),a.stops=new b({doNotLocateOnRestrictedElements:!0,features:e}),this._routeTask.solve(a,{signal:n}).then((e=>o(e)?(s(e),r(e),this._set("lastRoute",e),e):(N.warn("Response stops don't match current stops of the ViewModel, invalidating the results."),this._set("lastRoute",null),null))).catch((e=>{throw r(null),e}))})).then((e=>(this._activeRouteController=null,this.notifyChange("state"),this.zoomToRoute(),e))).catch((e=>{if(this._activeRouteController=null,this.notifyChange("state"),!u(e))throw e=new o("directions-view-model:unable-to-route","Unable to route to these addresses",{error:e}),this._set("error",e),e}));return this.notifyChange("state"),c}getCostAttribute(e){var t,r;const s=(null!=(t=null==(r=this.serviceDescription)?void 0:r.networkDataset.networkAttributes)?t:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=s?s:null}reset(){this.stops.removeAll(),this.clearHighlights(),this._set("lastRoute",null)}zoomToRoute(){const{directionLines:e,view:t}=this;if(!e||!t)return;const r=g(e),s=r.width>r.height;this.callGoTo({target:r.expand(s?2:1)})}async _loadServiceDescription(){const e=await f(this.routeServiceUrl,this.apiKey);this._set("serviceDescription",e)}_enqueue(e){this._requestQueueTail||(this._requestQueueTail=Promise.resolve());const t=new Promise(((t,r)=>{this._requestQueueTail.catch((()=>{})).then((()=>{try{const s=e.call(this);c(s)?s.then(t,r):t(s)}catch(s){r(s)}}))}));return this._requestQueueTail=t,t}_addStopsToLayer(){this._stopLayer.graphics.removeAll();const e=this.stops.clone().map(((e,t)=>{const{first:r,middle:s,last:o,unlocated:i,waypoint:a}=this.stopSymbols;return S(e)?e.symbol=a:void 0===e.attributes.Status?e.symbol=0===t?r:t===this.stops.length-1?o:s:e.symbol=S(e)?a:L(e)?C(e)?r:R(e)?o:s:i,e}));this._stopLayer.graphics.addMany(e)}_addRouteToLayer(){this._routeLayer.graphics.removeAll();const{directionLines:e}=this;e&&(e.forEach((e=>{e.symbol=this.routeSymbol})),this._routeLayer.graphics.addMany(e))}};e([m()],x.prototype,"_directionsLanguage",null),e([m({type:T})],x.prototype,"_routeTask",null),e([m()],x.prototype,"apiKey",void 0),e([m()],x.prototype,"departureTime",void 0),e([m({aliasOf:"lastRoute.routeResults.0.directions.features"})],x.prototype,"directionLines",void 0),e([m({readOnly:!0})],x.prototype,"impedanceAttribute",null),e([m({readOnly:!0})],x.prototype,"lastRoute",void 0),e([m({value:50})],x.prototype,"maxStops",null),e([m()],x.prototype,"routeSymbol",void 0),e([m({type:_})],x.prototype,"routeParameters",void 0),e([m()],x.prototype,"routeServiceUrl",void 0),e([m()],x.prototype,"selectedTravelMode",null),e([m({readOnly:!0})],x.prototype,"serviceDescription",void 0),e([m({readOnly:!0})],x.prototype,"state",null),e([m()],x.prototype,"error",void 0),e([m({type:s})],x.prototype,"stops",void 0),e([m({value:z})],x.prototype,"stopSymbols",null),e([m({readOnly:!0})],x.prototype,"timeAttribute",null),e([m()],x.prototype,"travelModes",null),e([m()],x.prototype,"view",void 0),e([m()],x.prototype,"getDirections",null),e([m()],x.prototype,"zoomToRoute",null),x=e([v("esri.widgets.Directions.DirectionsViewModel")],x);const P=x;export{P as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as l}from"../../core/HandleOwner.js";import{isNone as n,isSome as a}from"../../core/maybe.js";import{isAbortError as c}from"../../core/promiseUtils.js";import{on as u,watch as p,initial as d}from"../../core/reactiveUtils.js";import{aliasOf as h}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as m}from"../../core/accessorSupport/decorators/cast.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as g}from"../../intl/locale.js";import w from"../../layers/GraphicsLayer.js";import f from"../../layers/RouteLayer.js";import S from"../../layers/support/DefaultSymbols.js";import{fetchServiceDescription as b}from"../../rest/networkService.js";import _ from"../../rest/support/RouteParameters.js";import T from"../../rest/support/Stop.js";import{GoToMixin as D}from"../support/GoTo.js";import j from"../../symbols/SimpleLineSymbol.js";import M from"../../symbols/SimpleMarkerSymbol.js";import C from"../../symbols/PictureMarkerSymbol.js";function L(e){return e.length>0&&e.getItemAt(0)instanceof r}const A=o.ofType(T),z=[105,220,255],R=new j({color:z,width:7,cap:"round",join:"round"}),U={first:new M({color:z,size:19,outline:{color:[51,51,51],width:3}}),middle:new M({color:[51,51,51],size:12,outline:{color:z,width:3}}),last:new C({width:23,height:23,url:`data:image/svg+xml;base64,${btoa('<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new C({height:18,width:18,url:`data:image/svg+xml;base64,${btoa('<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="#69DCFF" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>')}`}),waypoint:new M({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})};var x;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(x||(x={}));let P=class extends(l(D(s.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new w({listMode:"hide"}),this._routeController=null,this._serviceDescriptionStatus=x.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeLayer=new f({listMode:"show",defaultSymbols:new S({directionLines:R,directionPoints:new M({size:0}),routeInfo:new j({width:0}),firstStop:U.first,middleStop:U.middle,lastStop:U.last,invalidStop:U.unlocated,waypointStop:U.waypoint,breakStop:U.waypoint})}),this.routeSymbol=R,this.routeParameters=new _({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.routeServiceUrl="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",this.serviceDescription=null,this.error=null,this.stops=new A,this.view=null}initialize(){this.handles.add([u((()=>this.stops),"change",(()=>{this.clearResults()})),p((()=>{var e;return null==(e=this.view)?void 0:e.map}),((e,t)=>{const r=[this.routeLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)}),d),p((()=>this.routeServiceUrl),(()=>{this.routeLayer.url=this.routeServiceUrl,this._set("serviceDescription",null),this.load()}),d)])}destroy(){var e;null==(e=this.view)||e.map.removeMany([this.routeLayer,this._highlightLayer])}get _directionsLanguage(){var e;if(n(this.serviceDescription))return;const t=this.serviceDescription.directionsSupportedLanguages;if(!t)return;const r=(null!=(e=this.routeParameters.directionsLanguage)?e:g()).slice(0,2);return t.find((e=>e.toLowerCase().slice(0,2)===r))}get impedanceAttribute(){var e,t,r;const o=a(this.serviceDescription)?this.serviceDescription.impedance:null,i=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.impedanceAttributeName)?t:this.routeParameters.impedanceAttribute)?e:o;return this.getCostAttribute(i)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get selectedTravelMode(){const{serviceDescription:e}=this;if(n(e))return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;return r.find((e=>e.id===t))||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){if(a(this._routeController))return"routing";if(a(this.error))return"error";switch(this._serviceDescriptionStatus){case x.Suspended:return"unauthenticated";case x.Idle:return"disabled";case x.Active:return"initializing";case x.Failed:return"error";default:return"ready"}}castStops(e){return L(e)?new o(e.map((e=>T.fromJSON(e.toJSON())))):e}set stopSymbols(e){const t={...U,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r;const o=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.timeAttributeName)?t:this.routeParameters.directionsTimeAttribute)?e:a(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null;return this.getCostAttribute(o)}get travelModes(){return a(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(!a(this.serviceDescription))try{this._serviceDescriptionStatus=x.Active;const e=await b(this.routeServiceUrl,this.apiKey);this._set("serviceDescription",e),this._serviceDescriptionStatus=x.Complete}catch(e){const t="identity-manager:user-aborted"===e.name;if(this._serviceDescriptionStatus=t?x.Suspended:x.Failed,!t){const t=new i("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:e});throw this._set("error",t),t}}}highlightSegment(e){const{geometry:o,symbol:i}=e;if(n(this.view)||n(o)||n(i))return;this.clearHighlights();const s=i.clone();s.color=new t([0,0,0,.8]),s.width=Math.ceil(s.width/2);const l=new r({geometry:o,symbol:s});this._highlightLayer.add(l)}clearHighlights(){this._highlightLayer.removeAll()}centerAt(e){this.view&&this.callGoTo({target:e})}clearResults(){this._set("lastRoute",null)}async getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionStatus===x.Failed)return Promise.reject(new i("directions-view-model:not-loaded","Cannot get directions until view model loads."));this._set("error",null),a(this._routeController)&&(this._routeController.abort(),this._routeController=null);const{apiKey:t,departureTime:r}=this,o="now"===r,s="now"===r?new Date:r;if(s&&!o){const e=60*s.getTimezoneOffset()*1e3;s.setTime(s.getTime()-e)}const l=this.routeParameters.clone();if(l.set({startTime:s,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:t}),a(this.selectedTravelMode)&&(l.travelMode=this.selectedTravelMode),this.stops.length<2){const e=new i("directions-view-model:not-enough-stops","Not enough stops for routing");return this._set("error",e),Promise.reject(e)}const n=new AbortController,{signal:u}=n;this._routeController=n;let p=null;try{p=await this.routeLayer.solve(l,{signal:u}),this.routeLayer.update(p),this._set("lastRoute",p)}catch(d){if(!c(d)){const e=new i("directions-view-model:unable-to-route","Unable to route to these addresses",{error:d});throw this._set("error",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),p}getCostAttribute(e){const t=(a(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=t?t:null}reset(){this.clearHighlights(),this.clearResults(),this.routeLayer.removeAll()}zoomToRoute(){const{view:e,lastRoute:t}=this;if(!e||n(t))return;const{routeInfo:r}=t;if(n(r))return;const{geometry:o}=r;if(n(o))return;const{extent:i}=o,s=i.width>i.height,l=i.clone().expand(s?2:1);this.callGoTo({target:l})}};e([v()],P.prototype,"_directionsLanguage",null),e([v()],P.prototype,"_routeController",void 0),e([v()],P.prototype,"_serviceDescriptionStatus",void 0),e([v()],P.prototype,"apiKey",void 0),e([v()],P.prototype,"departureTime",void 0),e([v({readOnly:!0})],P.prototype,"impedanceAttribute",null),e([v({readOnly:!0})],P.prototype,"lastRoute",void 0),e([v({value:50})],P.prototype,"maxStops",null),e([v()],P.prototype,"routeLayer",void 0),e([v()],P.prototype,"routeSymbol",void 0),e([v({type:_,nonNullable:!0})],P.prototype,"routeParameters",void 0),e([v({nonNullable:!0})],P.prototype,"routeServiceUrl",void 0),e([v()],P.prototype,"selectedTravelMode",null),e([v({readOnly:!0})],P.prototype,"serviceDescription",void 0),e([v({readOnly:!0})],P.prototype,"state",null),e([v()],P.prototype,"error",void 0),e([v({type:A,nonNullable:!0}),h("routeLayer.stops")],P.prototype,"stops",void 0),e([m("stops")],P.prototype,"castStops",null),e([v({value:U})],P.prototype,"stopSymbols",null),e([v({readOnly:!0})],P.prototype,"timeAttribute",null),e([v()],P.prototype,"travelModes",null),e([v()],P.prototype,"view",void 0),e([v()],P.prototype,"getDirections",null),e([v()],P.prototype,"zoomToRoute",null),P=e([y("esri.widgets.Directions.DirectionsViewModel")],P);const O=P;export{O 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../intl.js";import
|
|
5
|
+
import"../../../intl.js";import"../../../core/has.js";import{convertUnit as t}from"../../../core/unitUtils.js";import{substitute as r}from"../../../intl/substitute.js";function n(t){return"esriNAUSeconds"===t||"esriNAUMinutes"===t||"esriNAUHours"===t||"esriNAUDays"===t}function i(t,r){const n=s(t,r);if(n<1)return`${Math.floor(60*n)}m`;const i=n%1*60;return`${Math.floor(n)}:${String(Math.floor(i)).padStart(2,"0")}h`}function s(t,r){switch(r){case"days":return 24*t;case"hours":return t;case"minutes":return t/60;case"seconds":return t/60/60;default:return 0}}function e(n,i,s,e){const{fromUnits:o,toUnits:u}=e,a=t(s,o,u);if(!a)return"";const c=i.units[u],m=c?c.abbr:u.toLowerCase();return r(n.distanceTemplate,{distance:a,units:m},{format:{distance:{type:"number",intlOptions:{minimumFractionDigits:2,maximumFractionDigits:2}}}})}export{e as formatDistance,i as formatTime,n as isTimeUnits};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getAssetUrl as e}from"../../../assets.js";const
|
|
5
|
+
import{getAssetUrl as e}from"../../../assets.js";import{isNone as t}from"../../../core/maybe.js";const n="esri-directions",r={base:`${n} esri-widget esri-widget--panel`,directionsButton:`${n}__button`,clearRouteButton:`${n}__clear-route-button`,scroller:`${n}__scroller`,panelContent:`${n}__panel-content`,panelContentLoading:`${n}__panel-content--loading`,panelContentError:`${n}__panel-content--error`,panelContentSignIn:`${n}__panel-content--sign-in`,loader:`${n}__loader`,message:`${n}__message`,travelModeSelect:`${n}__travel-modes-select`,departureTime:`${n}__departure-time`,departureTimeSelect:`${n}__departure-time-select`,directionsSection:`${n}__directions-section`,departureTimeControls:`${n}__departure-time-controls`,section:`${n}__section`,summary:`${n}__summary`,stopIcon:`${n}__stop-icon`,interactiveStopIcon:`${n}__stop-icon--interactive`,removeStopButton:`${n}__remove-stop`,removeStop:`${n}__remove-stop-icon`,reverseStops:`${n}__reverse-stops`,stopIconContainer:`${n}__stop-icon-container`,lastStopIconContainer:`${n}__stop-icon-container--last`,stopHandle:`${n}__stop-handle`,stopInput:`${n}__stop-input`,stopOptions:`${n}__stop-options`,stopHandleIcon:`${n}__stop-handle-icon`,verticalSplitter:`${n}__vertical-splitter`,stopRow:`${n}__stop-row`,stopRowGhost:`${n}__stop-row-ghost`,validStopRow:`${n}__stop-row--valid`,stops:`${n}__stops`,addStop:`${n}__add-stop`,addStopText:`${n}__add-stop-text`,directionCosts:`${n}__costs`,costsDetails:`${n}__costs-details`,primaryCosts:`${n}__costs-value`,secondaryCosts:`${n}__other-costs-total`,routeActions:`${n}__route-actions`,maneuvers:`${n}__maneuvers`,maneuverList:`${n}__maneuver-list`,maneuverSection:`${n}__maneuver-section`,maneuverSectionHeader:`${n}__maneuver-section-header`,maneuverSectionHeaderButton:`${n}__maneuver-section-header-toggle-button`,maneuverSectionTitle:`${n}__maneuver-section-title`,collapsibleSection:`${n}__maneuver-section--collapsible`,maneuverSectionToggle:`${n}__maneuver-section-toggle`,maneuver:`${n}__maneuver`,maneuverActive:`${n}__maneuver--active`,maneuverCosts:`${n}__maneuver-costs`,maneuverCostsContainer:`${n}__maneuver-costs-container`,maneuverIcon:`${n}__maneuver-icon`,cumulativeCost:`${n}__cost--cumulative`,intermediateCost:`${n}__cost--intermediate`,horizontalSplitter:`${n}__horizontal-splitter`,sectionSplitter:`${n}__section-splitter`,disclaimer:`${n}__disclaimer`,signInContent:`${n}__sign-in-content`,signInButton:`${n}__sign-in-button`,contentTitle:`${n}__content-title`,warningCard:`${n}__warning-card`,warningHeader:`${n}__warning-header`,warningHeading:`${n}__warning-heading`,warningMessage:`${n}__warning-message`,stopsIcon:"esri-icon-radio-unchecked",lastStopIcon:"esri-icon-radio-checked",handleIcon:"esri-icon-handle-vertical",addStopIcon:"esri-icon-plus",removeStopIcon:"esri-icon-trash",reverseStopIcon:"esri-icon-up-down-arrows",openIcon:"esri-icon-down",closeIcon:"esri-icon-up",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-directions",anchor:"esri-widget__anchor",button:"esri-button",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",emptyContent:"esri-widget__content--empty",emptyIllustration:"esri-widget__content-illustration--empty",select:"esri-select",screenReaderText:"esri-icon-font-fallback-text"},o=new Map([["bear-left","bear-left"],["bear-right","bear-right"],["central-fork","fork-middle"],["door","walk-through-door"],["elevator","elevator"],["escalator","escalator"],["left-fork","fork-left"],["left-ramp","ramp-left"],["left-turn","left"],["left-turn-and-immediate-left-turn","left-left"],["left-turn-and-immediate-right-turn","left-right"],["off-ferry","disembark"],["on-ferry","embark"],["pedestrian-ramp","take-pedestrian-ramp"],["right-fork","fork-right"],["right-ramp","exit-highway-right"],["right-ramp","ramp-right"],["right-turn","right"],["right-turn-and-immediate-left-turn","right-left"],["right-turn-and-immediate-right-turn","right-right"],["roundabout","roundabout-left"],["sharp-left","sharp-left"],["sharp-right","sharp-right"],["stairs","stairs"],["straight","straight"],["u-turn","u-turn-left"]]);var i;!function(e){e.NOW="now",e.DEPART_BY="depart-by",e.UNSPECIFIED="unspecified"}(i||(i={}));const a=()=>e("esri/themes/base/images/maneuvers/");function s(e){if(t(e)||!o.has(e))return null;const n=o.get(e),r=2===window.devicePixelRatio?"@2x":"";return`${a()}${n}${r}.png`}export{r as CSS,i as DepartureTime,s as getIconPath,a as getManeuversIconDir};
|
package/widgets/Directions.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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{pausable as s,on as i}from"../core/events.js";import r from"../core/Handles.js";import{init as o,when as n,whenOnce as a,watch as l,on as c}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import p from"./Search.js";import m from"./Widget.js";import v from"./Directions/DirectionsViewModel.js";import _ from"./Directions/support/CostSummary.js";import{formatDistance as g,formatTime as S,getAssociatedStop as w,useSpatiallyLocalTime as M,toSpatiallyLocalTimeString as y}from"./Directions/support/directionsUtils.js";import{toIconName as T}from"./Directions/support/maneuverUtils.js";import{DepartureTime as C,CSS as b,getManeuversIconDir as f}from"./Directions/support/resources.js";import I from"./Directions/support/RouteSections.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as D}from"./Search/support/locatorUtils.js";import R from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as x}from"./support/Heading.js";import H from"./support/TimePicker.js";import{accessibleHandler as U}from"./support/decorators/accessibleHandler.js";import{messageBundle as j}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as E}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import L from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as A}from"../intl/date.js";import{formatNumber as O}from"../intl/number.js";const $={awaitingViewClickStop:"awaiting-view-click-stop"};function N(e){return e.results[0].results[0]}function B(){return[{},{}]}const F={hour:"numeric",minute:"numeric"},V={minimumIntegerDigits:2};function W(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",i=60,r=Math.abs(Math.floor(t/i)),o=Math.abs(Math.floor(t)%i);return`GMT${s}${O(r,V)}${O(o,V)}`}const K=100,q=500;function Y(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}let G=class extends m{constructor(e,s){super(e,s),this._autoStopRemovalDelay=K,this._costSummary=new _,this._departureTime=C.NOW,this._datePicker=new R,this._handles=new r,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._routeSections=new I,this._stops=new t(B()),this._stopsToSearches=new Map,this._timePicker=new H,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=b.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new v,this._setUpDragAndDropStops=e=>{this._sortable=L.create(e,{draggable:`.${b.validStopRow}`,ghostClass:b.stopRowGhost,handle:`.${b.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this._stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:i}=s,r=i[t],o=i[e],n=t-e<0;s.insertBefore(r,n?o.nextElementSibling:o);const a=this._stops;a.reorder(a.getItemAt(e),t),this._processStops()}}initialize(){this.own([o(this,"viewModel.lastRoute",(()=>{this._routeSections.routePath=this.get("viewModel.directionLines"),this._activeManeuver=null,this._focusedManeuver=null,this.scheduleRender()})),o(this,"viewModel.selectedTravelMode, viewModel.departureTime",(()=>{this.get("viewModel.stops.length")>1&&this.getDirections()})),n(this,"view",((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),s=this._prepViewClick();t.pause(),s.pause(),this._handles.add([i(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=q)),i(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=K)),t,s],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=s}})),a(this,"routeServiceUrl",(()=>this.viewModel.load())),l(this,"viewModel.stops.length",(e=>{0===e&&(this._stops.toArray().forEach((e=>this._removeStop(e,!0))),this._stops.addMany(B()),this.scheduleRender())}))])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return E("div",{class:this.classes(b.base,b.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{state:e}}=this,t="initializing"===e,s="error"===e&&!this.viewModel.serviceDescription,i="unauthenticated"===e,r={[b.panelContentLoading]:t,[b.panelContentError]:s,[b.panelContentSignIn]:i},o=t?"presentation":"group",n=i?this._renderSignIn():s?this._renderMessage(this._getErrorMessage()):t?this._renderLoader():this._renderReadyContent();return E("div",{class:this.classes(b.panelContent,r),role:o},n)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer(),this._renderDisclaimer()]}_renderSignIn(){return E("div",{key:"sign-in",class:b.signInContent},E(P,{class:b.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),E(P,{level:x(this.headingLevel)},this.messages.signInRequired),E("button",{class:this.classes(b.button,b.buttonSecondary,b.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){const{travelModes:e}=this.viewModel;if(0===e.length)return null;const{selectedTravelMode:t}=this.viewModel,s=t.name||this.messages.travelMode;return E("select",{"aria-label":s,bind:this,class:this.classes(b.travelModeSelect,b.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},e.map((e=>{const s=e.id===t.id;return E("option",{key:e,"data-mode":e,selected:s,value:e.id},e.name)})))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"]}_renderStopsContainer(){return E("div",{class:b.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return E("div",{class:b.departureTime,key:"esri-directions__departure-time-controls",role:"group"},E("select",{"aria-label":s,bind:this,class:this.classes(b.departureTimeSelect,b.select),onchange:this._handleDepartureOptionChange,title:s},E("option",{value:C.NOW,selected:e===C.NOW},t.leaveNow),E("option",{value:C.DEPART_BY,selected:e===C.DEPART_BY},t.departBy),E("option",{value:C.UNSPECIFIED,selected:e===C.UNSPECIFIED},t.timeUnspecified)),e===C.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this._stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,i)=>{const r=e.length,o=i>1&&!s.result,n={[b.stopsIcon]:i>=0&&i<r-1,[b.lastStopIcon]:i===r-1},a={[b.lastStopIconContainer]:i===r-1},l={[b.validStopRow]:!o},c=e.getItemAt(r-1),d=c&&c.result,h=e.getItemAt(i+1),u=h&&h.result,p=i===r-1,m=i===r-2,v=2===r&&0===i||r>2&&!p&&!m||r>2&&m&&u||r>2&&p&&!s.result,_=2===r||3===r&&!d||o,g=this._acquireSearch(s),{messages:S}=this,{removeStop:w,reverseStops:M,unlocated:y}=S,T=z(S.stopLabelTemplate,{number:i+1,label:s.result?s.result.name:y}),C=`${this.id}__stop--${i}`,f=!!g.searchTerm&&!!g.selectedResult&&!!s.result&&g.selectedResult===s.result,I={zIndex:"none"!==g.activeMenu?""+t--:""};return E("li",{"aria-label":T,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(b.stopRow,l),id:C,key:i,"data-stop-index":i,styles:I},E("div",{class:b.stopHandle},E("span",{"aria-hidden":"true",class:this.classes(b.stopIcon,b.handleIcon,b.stopHandleIcon,b.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),E("div",{bind:this,"aria-labelledby":C,class:this.classes(b.stopIconContainer,a),"data-stop-index":i,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},E("span",{class:this.classes(b.stopIcon,n),tabindex:f?"0":null}))),E("div",{class:b.stopInput},g.render()),E("div",{class:b.stopOptions,role:"group"},E("div",{"aria-label":w,class:b.removeStopButton,bind:this,"data-stop-index":i,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:w},E("span",{"aria-hidden":"true",class:this.classes(b.stopIcon,b.removeStop,b.removeStopIcon,b.interactiveStopIcon)}),E("span",{class:b.screenReaderText},"removeStopTitle")),E("div",{"aria-label":M,class:b.reverseStops,bind:this,hidden:v,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:M},E("span",{"aria-hidden":"true",class:this.classes(b.stopIcon,b.reverseStopIcon,b.interactiveStopIcon)}),E("span",{class:b.screenReaderText},"removeStopTitle"))))})),i=e.every((e=>{const t=this._stopsToSearches.get(e);return e.result&&t.selectedResult===e.result})),r=this._stops.length>=this.maxStops,o=this.messages.addStop,n=e.length>=2&&i&&!r?E("div",{"aria-label":o,bind:this,class:b.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},E("span",{"aria-hidden":"true",class:this.classes(b.addStopIcon,b.stopIcon,b.interactiveStopIcon)}),E("div",{"aria-hidden":"true",class:b.addStopText},o)):null;return E("div",null,E("ol",{class:b.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),n)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this._stops.getItemAt(t);s&&s.result&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e.result.feature)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],i=this._stops.getItemAt(s);if(t===i){const e=this._acquireSearch(i);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove($.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!t.result||e.selectedResult!==t.result)return"none"!==e.activeMenu||!e.searchTerm||e.selectedResult===t.result&&(e.selectedResult||t.result)?void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{if(this.destroyed)return;if(this._viewClickHandle.pause(),"searching"===e.viewModel.state)return void this._pointerDownUpHandle.pause();if(this._pointerPressedSearchSuggestionStop)return;this._removeStop(t);!!t.result&&(t.result=null,this._processStops()),this.scheduleRender()}),this._autoStopRemovalDelay))):(e.search(),void this._pointerDownUpHandle.pause());this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has($.awaitingViewClickStop))return;const{view:s,view:{cursor:i}}=this;this._previousCursor=i,this._handles.add(o(e,"searchTerm",(e=>{s.cursor=0===e.length?"copy":i})),$.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const e=this.get("viewModel.view"),t=s(e,"click",this._handleViewClick.bind(this)),i=s(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),i.pause()}));return{remove(){i.remove(),t.remove()},pause(){i.pause(),t.pause()},resume(){i.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=s(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=Y(e)?this._activeStop:null})),t=s(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=Y(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?this._activeStop:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=N(e),i=this._activeStop;i.result=s,i.result.feature.attributes.Name=s.name,t.searchTerm=s.name})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e={};this._stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this._stops.reverse(),this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this._stops.getItemAt(t)),this._processStops()}_removeStop(e,t=!1){this._stops.length<=2&&!t||(this._disposeSearch(e),this._stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===C.NOW?(this._departureTime=C.NOW,this.viewModel.departureTime=C.NOW,this._handles.remove("departure-time-controls")):s.value===C.DEPART_BY?(this._departureTime=C.DEPART_BY,this._handles.add([o(this._datePicker,"value",(()=>this._updateDepartureTime())),o(this._timePicker,"value",(()=>this._updateDepartureTime()))],"departure-time-controls")):(this._departureTime=C.UNSPECIFIED,this.viewModel.departureTime=null)}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes())}_renderTimeControls(){return E("div",{class:b.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return E("div",{class:b.sectionSplitter})}_renderDisclaimer(){const{messages:e}=this,t=`<a class="${b.anchor}" href="http://www.esri.com/legal/software-license" rel="noreferrer" target="_blank">${e.esriTerms}</a>`,s=z(e.disclaimer,{esriTerms:t});return E("div",{class:b.disclaimer,innerHTML:s,key:"esri-directions__disclaimer"})}_renderDirectionsContainer(){return E("div",{class:this.classes(b.directionsSection,b.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return E("div",{class:b.loader,key:"loader"})}_renderWarningCard(){return E("div",{class:b.warningCard,role:"alert"},E("div",{class:b.warningHeader},E("span",{class:b.warningIcon,"aria-hidden":"true"}),E(P,{class:b.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),E("div",{class:b.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,state:t}=this.viewModel,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():e?E("div",{class:b.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):E("div",{key:"esri-directions__placeholder",class:b.emptyContent},this._renderPlaceholder(),E(P,{class:b.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return E("svg",{class:b.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},E("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return E(P,{level:this.headingLevel},e)}_renderRouteActions(){return E("div",{class:b.routeActions},E("button",{"aria-label":this.messages.clearRoute,class:this.classes(b.clearRouteButton,b.button,b.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_renderManeuverSections(){const{sections:e}=this._routeSections;return E("div",{class:b.maneuvers,role:"group"},e.map(((t,s)=>{const{open:i}=t;let r;t.maneuvers.length>0&&i&&(r=E("ol",{class:b.maneuverList},t.maneuvers.map((e=>this._renderManeuver(e)))));const o=e.length>2,n=s===e.length-1,a={[b.collapsibleSection]:o},l={[b.openIcon]:!i,[b.closeIcon]:i};let c;if(o&&!n){const e=i?this.messagesCommon.open:this.messagesCommon.close;c=E("header",{class:this.classes(b.maneuverSectionHeader,b.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},E("div",{"aria-expanded":i.toString(),"aria-label":e,bind:this,class:b.maneuverSectionHeaderButton,"data-maneuver-section":t,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:e},E(P,{class:b.maneuverSectionTitle,level:this.headingLevel},t.name),E("span",{"aria-hidden":"true",class:this.classes(l)})))}else c=E("header",{class:b.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},E(P,{class:b.maneuverSectionTitle,level:this.headingLevel},t.name));return E("section",{class:this.classes(b.maneuverSection,a)},c,r)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const e=this.get("viewModel.directionLines"),t=e[e.length-1],s=new Date(t.attributes.arriveTimeUTC),i=this._costSummary.set({directionsViewModel:this.viewModel,messages:this.messages,messagesUnits:this.messagesUnits}),{messages:r}=this,o=r.zoomToRoute,n=A(s,F),a=z(r.etaTemplate,{time:`<strong>${n}</strong>`,gmt:`${W(s)}`}),l=r.primaryCosts,c=r.secondaryCosts,d=r.eta;return E("div",{"aria-label":o,bind:this,class:b.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:o},E("div",{class:b.costsDetails,role:"group"},E("div",{"aria-label":l,class:b.primaryCosts,title:l},i.primary),E("div",{class:b.verticalSplitter}),E("div",{"aria-label":c,class:b.secondaryCosts,title:c},i.secondary)),E("div",{"aria-label":d,innerHTML:a,title:d}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e}=this,{error:t}=this.viewModel;return"directions-view-model:unable-to-route"===t.name?e.errors.unableToRoute:"directions-view-model:service-metadata-unavailable"===t.name?e.errors.unableToLoadServiceMetadata:e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){0!==e.length&&e.forEach((e=>{"url"in e&&e.url&&(null===e.locationType&&(e.locationType="street"),k(e.url)&&this.apiKey&&null==e.apiKey&&(e.apiKey=this.apiKey,e.url=D))}))}_acquireSearch(e){const t=this.get("viewModel.view");if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new p({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([c(s,"allSources","change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.result=s.selectedResult,e.result.feature.attributes.Name=s.selectedResult.name,this._processStops(),this.scheduleRender()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e)))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this.viewModel;e.stops.removeAll(),e.stops.addMany(this._stops.filter((e=>!!e.result)).map((e=>e.result.feature))),e.stops.length>1&&e.getDirections()}_renderManeuver(e){const t="";let s;const{attributes:i}=e,r=this.get("viewModel.routeParameters.directionsLengthUnits"),{messages:o,messagesUnits:n}=this,a=g(o,n,i.length,{toUnits:r}),l=S(i.time),c=w(e);M(e,this.get("viewModel.routeParameters.startTime"))?s=y(o,i.arriveTimeUTC,i.ETA,this._departureTime===C.NOW):a&&(s=l?`${a} · ${l}`:a);const d=c,h=this._getFormattedManeuverText(e),u=this._getIconPath(i.maneuverType);if(d)return E("li",{class:b.maneuver,key:e},E("header",null,c.attributes.Name));const p=`esri-directions__maneuver-${e.uid}`,m=`esri-directions__cumulative-costs-${e.uid}`,v=`esri-directions__intermediate-costs-${e.uid}`,_={[b.maneuverActive]:this._activeManeuver===e};return E("li",{"aria-labelledby":`${p} ${m} ${v}`,bind:this,class:this.classes(b.maneuver,_),"data-maneuver":e,key:e,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},E("img",{alt:"",class:b.maneuverIcon,src:u}),E("div",{class:b.maneuverCostsContainer},E("span",{id:p,innerHTML:h}),E("div",{class:b.maneuverCosts},E("div",{class:b.horizontalSplitter}),E("div",{id:m,"aria-label":o.cumulativeCosts,class:b.cumulativeCost,innerHTML:t,title:o.cumulativeCosts}),E("div",{id:v,"aria-label":o.intermediateCosts,class:b.intermediateCost,innerHTML:s,title:o.intermediateCosts}))))}_getIconPath(e){const t=T(e),s=2===window.devicePixelRatio?"@2x":"";return`${f()}${t}${s}.png`}_handleManeuverClick(e){const t=e.currentTarget["data-maneuver"];if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t,this.viewModel.centerAt(t),this.viewModel.highlightSegment(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=e.currentTarget["data-maneuver"];this.viewModel.highlightSegment(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=e.currentTarget["data-maneuver"];this._focusedManeuver=t,this.viewModel.highlightSegment(t)}_getFormattedManeuverText(e){const{attributes:{text:t},strings:s}=e;if(!s)return t;let i=t;return s.forEach((e=>{i=i.replace(e.string,`<strong>${e.string}</strong>`)})),i}};e([d("viewModel.apiKey")],G.prototype,"apiKey",void 0),e([d("viewModel.goToOverride")],G.prototype,"goToOverride",void 0),e([h()],G.prototype,"headingLevel",void 0),e([h()],G.prototype,"iconClass",void 0),e([h({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],G.prototype,"label",void 0),e([d("viewModel.lastRoute")],G.prototype,"lastRoute",void 0),e([d("viewModel.maxStops")],G.prototype,"maxStops",void 0),e([h(),j("esri/widgets/Directions/t9n/Directions")],G.prototype,"messages",void 0),e([h(),j("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([h(),j("esri/core/t9n/Units")],G.prototype,"messagesUnits",void 0),e([d("viewModel.routeServiceUrl")],G.prototype,"routeServiceUrl",void 0),e([d("viewModel.routeSymbol")],G.prototype,"routeSymbol",void 0),e([h()],G.prototype,"searchProperties",void 0),e([d("viewModel.stopSymbols")],G.prototype,"stopSymbols",void 0),e([d("viewModel.view")],G.prototype,"view",void 0),e([h({type:v})],G.prototype,"viewModel",void 0),e([d("viewModel.getDirections")],G.prototype,"getDirections",null),e([d("viewModel.zoomToRoute")],G.prototype,"zoomToRoute",null),e([U()],G.prototype,"_handleStopIconClick",null),e([U()],G.prototype,"_handleClearRouteClick",null),e([U()],G.prototype,"_handleReverseStops",null),e([U()],G.prototype,"_handleRemoveStop",null),e([U()],G.prototype,"_handleSectionToggle",null),e([U()],G.prototype,"_handleSummaryInteraction",null),e([U()],G.prototype,"_handleManeuverClick",null),G=e([u("esri.widgets.Directions")],G);const J=G;export{J as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import"../intl.js";import s from"../core/Collection.js";import{on as i,pausable as o}from"../core/events.js";import r from"../core/Handles.js";import{isSome as n,isNone as a,unwrap as l,unwrapOrValue as c}from"../core/maybe.js";import{watch as d,initial as h,when as u,on as p}from"../core/reactiveUtils.js";import{aliasOf as m}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as v}from"../core/accessorSupport/decorators/property.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import g from"../rest/support/Stop.js";import S from"./Search.js";import w from"./Widget.js";import y from"./Directions/DirectionsViewModel.js";import{formatDistance as b,formatTime as M,isTimeUnits as f}from"./Directions/support/directionsUtils.js";import{DepartureTime as T,CSS as C,getIconPath as I}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import D from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as H}from"./support/decorators/accessibleHandler.js";import{messageBundle as U}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import A from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as O}from"../intl/date.js";import{formatNumber as $}from"../intl/number.js";function N(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",i=60,o=Math.abs(Math.floor(t/i)),r=Math.abs(Math.floor(t)%i),n={minimumIntegerDigits:2};return`GMT${s}${$(o,n)}${$(r,n)}`}function B(){return[{},{}]}function F(e){return e.results[0].results[0]}function V(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}const W={awaitingViewClickStop:"awaiting-view-click-stop"},K=100,q=500;let Y=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=K,this._departureTime=T.NOW,this._datePicker=new D,this._handles=new r,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._sections=null,this._stops=new s(B()),this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=C.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new y,this._setUpDragAndDropStops=e=>{this._sortable=A.create(e,{draggable:`.${C.validStopRow}`,ghostClass:C.stopRowGhost,handle:`.${C.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this._stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:i}=s,o=i[t],r=i[e],n=t-e<0;s.insertBefore(o,n?r.nextElementSibling:r);const a=this._stops;a.reorder(a.getItemAt(e),t),this._processStops()}}initialize(){this.own([d((()=>this.viewModel.lastRoute),(()=>{this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),h),d((()=>[this.viewModel.selectedTravelMode,this.viewModel.departureTime]),(()=>{this.viewModel.stops.length>1&&this.getDirections()}),h),u((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),s=this._prepViewClick();t.pause(),s.pause(),this._handles.add([i(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=q)),i(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=K)),t,s],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=s}}),h),u((()=>0===this.viewModel.stops.length),(()=>{this._stops.drain((e=>{this._disposeSearch(e)})),this._stops.addMany(B()),this.scheduleRender()}))])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return L("div",{class:this.classes(C.base,C.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{state:e}}=this,t="initializing"===e,s="error"===e&&!this.viewModel.serviceDescription,i="unauthenticated"===e,o={[C.panelContentLoading]:t,[C.panelContentError]:s,[C.panelContentSignIn]:i},r=t?"presentation":"group",n=i?this._renderSignIn():s?this._renderMessage(this._getErrorMessage()):t?this._renderLoader():this._renderReadyContent();return L("div",{class:this.classes(C.panelContent,o),role:r},n)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer(),this._renderDisclaimer()]}_renderSignIn(){return L("div",{key:"sign-in",class:C.signInContent},L(P,{class:C.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),L(P,{level:j(this.headingLevel)},this.messages.signInRequired),L("button",{class:this.classes(C.button,C.buttonSecondary,C.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=n(e)?e.name:this.messages.travelMode;return L("select",{"aria-label":s,bind:this,class:this.classes(C.travelModeSelect,C.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=n(e)&&t.id===e.id;return L("option",{key:t,"data-mode":t,selected:s,value:t.id},t.name)})))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"]}_renderStopsContainer(){return L("div",{class:C.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return L("div",{class:C.departureTime,key:"esri-directions__departure-time-controls",role:"group"},L("select",{"aria-label":s,bind:this,class:this.classes(C.departureTimeSelect,C.select),onchange:this._handleDepartureOptionChange,title:s},L("option",{value:T.NOW,selected:e===T.NOW},t.leaveNow),L("option",{value:T.DEPART_BY,selected:e===T.DEPART_BY},t.departBy),L("option",{value:T.UNSPECIFIED,selected:e===T.UNSPECIFIED},t.timeUnspecified)),e===T.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this._stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,i)=>{const o=e.length,r=i>1&&!s.result,n={[C.stopsIcon]:i>=0&&i<o-1,[C.lastStopIcon]:i===o-1},a={[C.lastStopIconContainer]:i===o-1},l={[C.validStopRow]:!r},c=e.getItemAt(o-1),d=c&&c.result,h=e.getItemAt(i+1),u=h&&h.result,p=i===o-1,m=i===o-2,v=2===o&&0===i||o>2&&!p&&!m||o>2&&m&&u||o>2&&p&&!s.result,_=2===o||3===o&&!d||r,g=this._acquireSearch(s),{messages:S}=this,{removeStop:w,reverseStops:y,unlocated:b}=S,M=z(S.stopLabelTemplate,{number:i+1,label:s.result?s.result.name:b}),f=`${this.id}__stop--${i}`,T=!!g.searchTerm&&!!g.selectedResult&&!!s.result&&g.selectedResult===s.result,I={zIndex:"none"!==g.activeMenu?""+t--:""};return L("li",{"aria-label":M,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(C.stopRow,l),id:f,key:i,"data-stop-index":i,styles:I},L("div",{class:C.stopHandle},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.handleIcon,C.stopHandleIcon,C.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),L("div",{bind:this,"aria-labelledby":f,class:this.classes(C.stopIconContainer,a),"data-stop-index":i,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},L("span",{class:this.classes(C.stopIcon,n),tabindex:T?"0":null}))),L("div",{class:C.stopInput},g.render()),L("div",{class:C.stopOptions,role:"group"},L("div",{"aria-label":w,class:C.removeStopButton,bind:this,"data-stop-index":i,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:w},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.removeStop,C.removeStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle")),L("div",{"aria-label":y,class:C.reverseStops,bind:this,hidden:v,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:y},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.reverseStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle"))))})),i=e.every((e=>{const t=this._stopsToSearches.get(e);return e.result&&t.selectedResult===e.result})),o=this._stops.length>=this.maxStops,r=this.messages.addStop,n=e.length>=2&&i&&!o?L("div",{"aria-label":r,bind:this,class:C.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},L("span",{"aria-hidden":"true",class:this.classes(C.addStopIcon,C.stopIcon,C.interactiveStopIcon)}),L("div",{"aria-hidden":"true",class:C.addStopText},r)):null;return L("div",null,L("ol",{class:C.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),n)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this._stops.getItemAt(t);s&&s.result&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e.result.feature)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],i=this._stops.getItemAt(s);if(t===i){const e=this._acquireSearch(i);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove(W.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!t.result||e.selectedResult!==t.result)return"none"!==e.activeMenu||!e.searchTerm||e.selectedResult===t.result&&(e.selectedResult||t.result)?void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{if(this.destroyed)return;if(this._viewClickHandle.pause(),"searching"===e.viewModel.state)return void this._pointerDownUpHandle.pause();if(this._pointerPressedSearchSuggestionStop)return;this._removeStop(t);!!t.result&&(t.result=null,this._processStops()),this.scheduleRender()}),this._autoStopRemovalDelay))):(e.search(),void this._pointerDownUpHandle.pause());this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(W.awaitingViewClickStop))return;const{view:s,view:{cursor:i}}=this;this._previousCursor=i,this._handles.add(d((()=>e.searchTerm),(e=>{s.cursor=0===e.length?"copy":i}),h),W.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=o(e,"click",this._handleViewClick.bind(this)),s=o(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=o(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=V(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=V(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?this._activeStop:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=F(e),i=this._activeStop;i.result=s,i.result.feature.attributes.Name=s.name,t.searchTerm=s.name})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e={};this._stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this._stops.reverse(),this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this._stops.getItemAt(t)),this._processStops()}_removeStop(e){this._stops.length<=2||(this._disposeSearch(e),this._stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===T.NOW?(this._departureTime=T.NOW,this.viewModel.departureTime=T.NOW,this._handles.remove("departure-time-controls")):s.value===T.DEPART_BY?(this._departureTime=T.DEPART_BY,this._handles.add([d((()=>this._datePicker.value),(()=>this._updateDepartureTime()),h),d((()=>this._timePicker.value),(()=>this._updateDepartureTime()),h)],"departure-time-controls")):(this._departureTime=T.UNSPECIFIED,this.viewModel.departureTime=null)}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return L("div",{class:C.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return L("div",{class:C.sectionSplitter})}_renderDisclaimer(){const{messages:e}=this,t=`<a class="${C.anchor}" href="http://www.esri.com/legal/software-license" rel="noreferrer" target="_blank">${e.esriTerms}</a>`,s=z(e.disclaimer,{esriTerms:t});return L("div",{class:C.disclaimer,innerHTML:s,key:"esri-directions__disclaimer"})}_renderDirectionsContainer(){return L("div",{class:this.classes(C.directionsSection,C.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return L("div",{class:C.loader,key:"loader"})}_renderWarningCard(){return L("div",{class:C.warningCard,role:"alert"},L("div",{class:C.warningHeader},L("span",{class:C.warningIcon,"aria-hidden":"true"}),L(P,{class:C.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),L("div",{class:C.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,viewModel:{state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():n(e)&&n(e.directionLines)?L("div",{class:C.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):L("div",{key:"esri-directions__placeholder",class:C.emptyContent},this._renderPlaceholder(),L(P,{class:C.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return L("svg",{class:C.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},L("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return L(P,{level:this.headingLevel},e)}_renderRouteActions(){return L("div",{class:C.routeActions},L("button",{"aria-label":this.messages.clearRoute,class:this.classes(C.clearRouteButton,C.button,C.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){if(a(this.lastRoute))return null;const{directionPoints:e,directionLines:t,stops:s}=this.lastRoute;if(a(e)||a(t))return null;const i=[];let o=null;for(const r of e){const{objectId:e,stopId:l}=r;if(n(l)){const e=s.find((e=>e.objectId===l)),t=0===i.length;(a(o)||o.stop!==e)&&(o={stop:e,directions:[],open:t},i.push(o));continue}if(a(o))continue;const c=t.find((t=>t.directionPointId===e));a(c)||o.directions.push({directionPoint:r,directionLine:c})}return i}_renderManeuverSections(){return a(this._sections)?null:L("div",{class:C.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let i;e.directions.length>0&&s&&(i=L("ol",{class:C.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const o=l(this._sections).length>2,r=t===l(this._sections).length-1,n={[C.collapsibleSection]:o},a={[C.openIcon]:!s,[C.closeIcon]:s};let c;if(o&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=L("header",{class:this.classes(C.maneuverSectionHeader,C.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},L("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:C.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name),L("span",{"aria-hidden":"true",class:this.classes(a)})))}else c=L("header",{class:C.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return L("section",{class:this.classes(C.maneuverSection,n),key:t},c,i)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const{lastRoute:e}=this;if(a(e))return null;const t=this._getCostSummary(),{directionPoints:s}=e;if(a(s)||a(t))return null;const i=s.getItemAt(s.length-1).arrivalTime,{primary:o,secondary:r}=t,{eta:l,etaTemplate:c,primaryCosts:d,secondaryCosts:h,zoomToRoute:u}=this.messages,p=O("short-time"),m=n(i)?`<strong>${E(i,p)}</strong>`:null,v=n(i)?`${N(i)}`:null,_=z(c,{time:m,gmt:v});return L("div",{"aria-label":u,bind:this,class:C.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},L("div",{class:C.costsDetails,role:"group"},L("div",{"aria-label":d,class:C.primaryCosts,title:d},o),L("div",{class:C.verticalSplitter}),L("div",{"aria-label":h,class:C.secondaryCosts,title:h},r)),L("div",{"aria-label":l,innerHTML:_,title:l}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{error:t}}=this;if(n(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){0!==e.length&&e.forEach((e=>{"url"in e&&e.url&&(null===e.locationType&&(e.locationType="street"),k(e.url)&&this.apiKey&&null==e.apiKey&&(e.apiKey=this.apiKey,e.url=R))}))}_acquireSearch(e){const t=this.get("viewModel.view");if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new S({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([p((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.result=s.selectedResult,e.result.feature.attributes.Name=s.selectedResult.name,this._processStops(),this.scheduleRender()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e)))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this._stops.filter((e=>!!e.result)).map((e=>g.fromJSON(e.result.feature.toJSON())));switch(e.length){case 0:break;case 1:e.getItemAt(0).symbol=this.stopSymbols.first;break;case 2:e.getItemAt(0).symbol=this.stopSymbols.first,e.getItemAt(1).symbol=this.stopSymbols.last;break;default:e.forEach(((t,s)=>{switch(s){case 0:t.symbol=this.stopSymbols.first;break;case e.length-1:t.symbol=this.stopSymbols.last;break;default:t.symbol=this.stopSymbols.middle}}))}this.viewModel.stops=e,e.length>1&&this.getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:i,directionLine:o}=e,{distance:r,duration:a}=o,{messages:l,messagesUnits:d}=this,h=b(l,d,c(r,0),{fromUnits:"meters",toUnits:s}),u=M(c(a,0),"minutes"),p=h&&u?`${h} · ${u}`:`${h}${u}`,m=this._getFormattedManeuverText(i),{objectId:v,directionPointType:_}=i,g=I(_),S=`esri-directions__maneuver-${v}`,w=`esri-directions__cumulative-costs-${v}`,y=`esri-directions__intermediate-costs-${v}`,f={[C.maneuverActive]:this._activeManeuver===o};return L("li",{"aria-labelledby":`${S} ${w} ${y}`,bind:this,class:this.classes(C.maneuver,f),"data-maneuver":o,key:o,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},n(g)&&L("img",{alt:"",class:C.maneuverIcon,src:g}),L("div",{class:C.maneuverCostsContainer},L("span",{id:S,innerHTML:c(m,"")}),L("div",{class:C.maneuverCosts},L("div",{class:C.horizontalSplitter}),L("div",{id:w,"aria-label":l.cumulativeCosts,class:C.cumulativeCost,innerHTML:t,title:l.cumulativeCosts}),L("div",{id:y,"aria-label":l.intermediateCosts,class:C.intermediateCost,innerHTML:p,title:l.intermediateCosts}))))}_handleManeuverClick(e){const s=e.currentTarget["data-maneuver"];if(this._activeManeuver===s)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=s;const{geometry:i,symbol:o}=s,r=new t({geometry:i,symbol:o});this.viewModel.centerAt(r),this.viewModel.highlightSegment(r)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const s=e.currentTarget["data-maneuver"],{geometry:i,symbol:o}=s,r=new t({geometry:i,symbol:o});this.viewModel.highlightSegment(r)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const s=e.currentTarget["data-maneuver"];this._focusedManeuver=s;const{geometry:i,symbol:o}=s,r=new t({geometry:i,symbol:o});this.viewModel.highlightSegment(r)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:i}=e;if(a(t))return"";let o=t;return n(s)&&o.includes(s)&&(o=o.replace(s,`<strong>${s}</strong>`)),n(i)&&o.includes(i)&&(o=o.replace(i,`<strong>${i}</strong>`)),o}_getCostSummary(){const{viewModel:{impedanceAttribute:e,routeParameters:t},lastRoute:s}=this;if(a(e)||a(s))return null;const{routeInfo:i}=s;let{totalDuration:o,totalDistance:r}=i;const{directionsLengthUnits:l}=t;r=n(r)?r:0,o=n(o)?o:0;const c=b(this.messages,this.messagesUnits,r,{fromUnits:"meters",toUnits:l}),d=M(o,"minutes"),[h,u]=f(e.units)?[d,c]:[c,d];return{primary:h,secondary:u}}};e([m("viewModel.apiKey")],Y.prototype,"apiKey",void 0),e([m("viewModel.goToOverride")],Y.prototype,"goToOverride",void 0),e([v()],Y.prototype,"headingLevel",void 0),e([v()],Y.prototype,"iconClass",void 0),e([v({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],Y.prototype,"label",void 0),e([m("viewModel.lastRoute")],Y.prototype,"lastRoute",void 0),e([m("viewModel.maxStops")],Y.prototype,"maxStops",void 0),e([v(),U("esri/widgets/Directions/t9n/Directions")],Y.prototype,"messages",void 0),e([v(),U("esri/t9n/common")],Y.prototype,"messagesCommon",void 0),e([v(),U("esri/core/t9n/Units")],Y.prototype,"messagesUnits",void 0),e([m("viewModel.routeServiceUrl")],Y.prototype,"routeServiceUrl",void 0),e([m("viewModel.routeSymbol")],Y.prototype,"routeSymbol",void 0),e([v()],Y.prototype,"searchProperties",void 0),e([m("viewModel.stopSymbols")],Y.prototype,"stopSymbols",void 0),e([m("viewModel.view")],Y.prototype,"view",void 0),e([v({type:y})],Y.prototype,"viewModel",void 0),e([m("viewModel.getDirections")],Y.prototype,"getDirections",null),e([m("viewModel.zoomToRoute")],Y.prototype,"zoomToRoute",null),e([H()],Y.prototype,"_handleStopIconClick",null),e([H()],Y.prototype,"_handleClearRouteClick",null),e([H()],Y.prototype,"_handleReverseStops",null),e([H()],Y.prototype,"_handleRemoveStop",null),e([H()],Y.prototype,"_handleSectionToggle",null),e([H()],Y.prototype,"_handleSummaryInteraction",null),e([H()],Y.prototype,"_handleManeuverClick",null),Y=e([_("esri.widgets.Directions")],Y);const G=Y;export{G 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Collection.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import r from"../../core/Handles.js";import{on as o,watch as l}from"../../core/watchUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as d}from"../../views/support/layerViewUtils.js";import h from"./AttachmentsColumn.js";import m from"./FieldColumn.js";import c from"./Grid/Grid.js";import g from"./Grid/GridViewModel.js";import u from"./support/FeatureStore.js";import{onLocaleChange as p}from"../../intl/locale.js";import{fetchMessageBundle as f}from"../../intl/messages.js";let y=class extends(i(g)){constructor(e){super(e),this._defaultHiddenFields=["CreationDate","Creator","EditDate","Editor","GlobalID"],this._highlights=new r,this.cellClassNameGenerator=(e,t)=>e.path||null,this.dataProvider=async(e,t)=>{const{store:s}=this,{page:i,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(s?(await s.set({orderByFields:l}),"loaded"!==s.state&&"loading"!==s.state&&await s.load(),t&&t(await s.fetchItems({page:i,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.hiddenFields=new s,this.highlightOnRowSelectEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.relatedRecordsEnabled=!1,this.store=null,this.view=null;const{hiddenFields:t,itemIdPath:i}=this;t.addMany(this._defaultHiddenFields),this._set("store",new u),this._set("grid",new c({itemIdPath:i,viewModel:this}))}initialize(){const e=async()=>{this.messages=await f("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await f("esri/t9n/common")};e(),this.handles.add([p(e),o(this,"grid.selectedItems","change",(e=>this._onSelectionChange(e))),l(this,"relatedRecordsEnabled",(e=>this.store.relatedRecordsEnabled=e)),l(this,["layer.loaded"],(()=>{var e;null!=(e=this.layer)&&e.loaded&&this._onLayerLoad()})),l(this.store,"state",(e=>{var t;"loaded"===e&&(null==(t=this.grid)||t.scrollToTop())})),l(this,["editingEnabled","messages"],(()=>{var e;return(null==(e=this.layer)?void 0:e.loaded)&&this._generateColumns()})),l(this,"layer.definitionExpression",((e,t)=>(e||t)&&"loaded"===this.store.state&&this.refresh()))])}destroy(){var e,t;this._resetColumns(),this.handles.removeAll(),this._highlights.removeAll(),this._highlights.destroy(),null==(e=this.grid)||e.destroy(),null==(t=this.columns)||t.destroy(),this.layer=null,this.view=null}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set fieldConfigs(e){var t;this._set("fieldConfigs",e),(null==(t=this.layer)?void 0:t.loaded)&&this._generateColumns()}set filterGeometry(e){(this.filterGeometry
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Collection.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import r from"../../core/Handles.js";import{on as o,watch as l}from"../../core/watchUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as d}from"../../views/support/layerViewUtils.js";import h from"./AttachmentsColumn.js";import m from"./FieldColumn.js";import c from"./Grid/Grid.js";import g from"./Grid/GridViewModel.js";import u from"./support/FeatureStore.js";import{onLocaleChange as p}from"../../intl/locale.js";import{fetchMessageBundle as f}from"../../intl/messages.js";let y=class extends(i(g)){constructor(e){super(e),this._defaultHiddenFields=["CreationDate","Creator","EditDate","Editor","GlobalID"],this._highlights=new r,this.activeFilters=new s,this.cellClassNameGenerator=(e,t)=>e.path||null,this.dataProvider=async(e,t)=>{const{store:s}=this,{page:i,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(s?(await s.set({orderByFields:l}),"loaded"!==s.state&&"loading"!==s.state&&await s.load(),t&&t(await s.fetchItems({page:i,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.hiddenFields=new s,this.highlightOnRowSelectEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.relatedRecordsEnabled=!1,this.store=null,this.view=null;const{hiddenFields:t,itemIdPath:i}=this;t.addMany(this._defaultHiddenFields),this._set("store",new u),this._set("grid",new c({itemIdPath:i,viewModel:this}))}initialize(){const e=async()=>{this.messages=await f("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await f("esri/t9n/common")};e(),this.handles.add([p(e),o(this,"grid.selectedItems","change",(e=>this._onSelectionChange(e))),l(this,"relatedRecordsEnabled",(e=>this.store.relatedRecordsEnabled=e)),l(this,["layer.loaded"],(()=>{var e;null!=(e=this.layer)&&e.loaded&&this._onLayerLoad()})),l(this.store,"state",(e=>{var t;"loaded"===e&&(null==(t=this.grid)||t.scrollToTop())})),l(this,["editingEnabled","messages"],(()=>{var e;return(null==(e=this.layer)?void 0:e.loaded)&&this._generateColumns()})),l(this,"layer.definitionExpression",((e,t)=>(e||t)&&"loaded"===this.store.state&&this.refresh()))])}destroy(){var e,t;this._resetColumns(),this.handles.removeAll(),this._highlights.removeAll(),this._highlights.destroy(),null==(e=this.grid)||e.destroy(),null==(t=this.columns)||t.destroy(),this.layer=null,this.view=null}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set fieldConfigs(e){var t;this._set("fieldConfigs",e),(null==(t=this.layer)?void 0:t.loaded)&&this._generateColumns()}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this.clearSelection(),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}set layer(e){var t;this._set("layer",e),null==(t=this.grid)||t.clearSort(),this._resetColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load()),this.notifyChange("state")}set messages(e){var t;null==(t=this.grid)||t.set("messages",e),this._set("messages",e)}clearHighlights(){this._highlights.removeAll()}clearSelection(){var e;null==(e=this.grid)||e.clearSelection()}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid.deselectRows(t)}getObjectIdIndex(e){var t;return null==(t=this.store)?void 0:t.getObjectIdIndex(e)}getValue(e,t){var s;const i=this.store.getItemByObjectId(e);return null==i||null==(s=i.feature)?void 0:s.attributes[t]}refresh(){var e;null==(e=this.grid)||e.refresh()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid.selectRows(t)}scrollToIndex(e){var t;null==(t=this.grid)||t.scrollToIndex(e)}filterBySelection(){const e=this.grid.selectedItems.map((e=>e.objectId));e.length&&(this.removeSelectionFilter(),e.length&&(this.store.objectIds=e.items,this.activeFilters.add({type:"selection",objectIds:e.items})))}removeSelectionFilter(){this.clearSelection(),this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}_onLayerLoad(){const e=this.layer.capabilities.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_generateColumns(){this._resetColumns(),this.columns.addMany([...this._createFieldColumns()]),this.attachmentsEnabled&&this.columns.push(this._createAttachmentsColumn())}_createFieldColumns(){return this.fieldConfigs&&this.fieldConfigs.length?this._createColumnsFromConfigs():this._createColumnsFromFields()}_createColumnsFromConfigs(){var e,t;const{editingEnabled:s,fieldConfigs:i,grid:r,hiddenFields:o,layer:l,messages:a,messagesCommon:n,store:d}=this,h=null!=(e=null==(t=this.layer)?void 0:t.fields)?e:[];return i.filter((e=>(h||[]).find((t=>e.name===t.name)))).map((e=>{const t=e.direction||null,i=e.formatFunction||null,c=e.textAlign||null,g=(h||[]).find((t=>e.name===t.name)),u=!1===e.visible||!0!==e.visible&&o.indexOf(g.name)>-1;return new m({config:e,direction:t,editingEnabled:s,field:g,formatFunction:i,grid:r,hidden:u,layer:l,store:d,messages:a,messagesCommon:n,textAlign:c})}))}_createColumnsFromFields(){var e,t;const{editingEnabled:s,grid:i,hiddenFields:r,layer:o,messages:l,messagesCommon:a,store:n}=this;return(null!=(e=null==(t=this.layer)?void 0:t.fields)?e:[]).map((e=>{const t=r.indexOf(e.name)>-1;return new m({editingEnabled:s,field:e,grid:i,hidden:t,layer:o,store:n,messages:l,messagesCommon:a})}))}_createAttachmentsColumn(){var e;return new h({header:null==(e=this.messages)?void 0:e.attachments})}_sortOrdersToLayerOrderByFields(e){return e&&e.length?e.filter(((e,t,s)=>s.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e.toUpperCase())):[]}_highlight(e){const{view:t}=this,s=t&&e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer));d(s)&&this._highlights.add(s.highlight(e),`feature-${e.getObjectId()}`)}_unhighlight(e){e&&this._highlights.remove(`feature-${e.getObjectId()}`)}_getStoreItemsFromSelectionParams(e){const s=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let i=e instanceof t?e:null;const r=i?i.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!i){const e=this.store.getItemByObjectId(r);e&&(i=e.feature)}s.push({objectId:r,feature:i})}})),s}_onSelectionChange(e){const{highlightOnRowSelectEnabled:t}=this,{added:s,removed:i}=e;t&&s.forEach((e=>this._highlight(e.feature))),t&&i.forEach((e=>this._unhighlight(e.feature)))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([a()],y.prototype,"attachmentsEnabled",null),e([a()],y.prototype,"cellClassNameGenerator",void 0),e([a()],y.prototype,"dataProvider",void 0),e([a()],y.prototype,"editingEnabled",void 0),e([a()],y.prototype,"fieldConfigs",null),e([a()],y.prototype,"filterGeometry",null),e([a({readOnly:!0})],y.prototype,"grid",void 0),e([a()],y.prototype,"hiddenFields",void 0),e([a()],y.prototype,"highlightOnRowSelectEnabled",void 0),e([a({readOnly:!0})],y.prototype,"itemIdPath",void 0),e([a()],y.prototype,"layer",null),e([a()],y.prototype,"messages",null),e([a()],y.prototype,"messagesCommon",void 0),e([a()],y.prototype,"relatedRecordsEnabled",void 0),e([a({readOnly:!0,type:u})],y.prototype,"store",void 0),e([a()],y.prototype,"view",void 0),y=e([n("esri.widgets.FeatureTable.FeatureTableViewModel")],y);const v=y;export{v as default};
|
|
@@ -956,4 +956,4 @@ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Col
|
|
|
956
956
|
<template class="header" id="headerTemplate">
|
|
957
957
|
<vaadin-grid-sorter path="[[path]]" direction="{{direction}}">[[_getHeader(header, path)]]</vaadin-grid-sorter>
|
|
958
958
|
</template>
|
|
959
|
-
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Ka.is,Ka);const Qa={selectionColumn:!0,columnMenus:!0},el={base:"esri-grid",content:"esri-grid__content",grid:"esri-grid__grid",noColumnMenu:"esri-grid--no-column-menu",widget:"esri-widget"};let tl=class extends(s(c)){constructor(e,i){super(e,i),this._grid=null,this._headerStyles="display: flex; font-weight: 400;",this._hostStyles='font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; background-color: inherit; color: inherit;',this._rowHoverStyles="background-color: var(--lumo-row-background-hover);",this._columnElements=[],this.cellClassNameGenerator=null,this.columnReorderingEnabled=!0,this.dataProvider=null,this.itemIdPath=null,this.label=void 0,this.messages=null,this.pageSize=50,this.selectedItems=new t,this.size=null,this.rowDetailsRenderer=null,this.store=null,this.viewModel=new u,this.visibleElements={...Qa}}initialize(){this.handles.add([this.columns.on("change",(()=>this._syncColumnRenderers())),n(this,"viewModel.size",(()=>this._updateGridSize())),n(this,"store.state",((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshCache()})),o(this,"_grid.$.table","scroll",(()=>{var e;null==(e=this.viewModel)||e.closeColumnMenus()}))])}destroy(){var e;this.handles.removeAll(),this.resetColumns(),null==(e=this.columns)||e.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}castVisibleElements(e){return{...Qa,...e}}render(){const{columnMenus:e}=this.visibleElements;return m("div",{bind:this,class:this.classes(el.base,el.widget,{[el.noColumnMenu]:!e})},m("div",{bind:this,class:el.content},this.renderGrid()))}renderGrid(){return m("vaadin-grid",{...this.getGridProps()},this.renderAllColumns())}renderAllColumns(){if("disabled"!==this.viewModel.state&&this.columns&&this.columns.length)return[this.renderSelectionColumn(),this.renderColumns()]}renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!p(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))}getGridProps(){const{columnReorderingEnabled:e,id:t,pageSize:i,size:s}=this;return{_safari:!1,class:el.grid,id:`${t}_grid`,theme:"compact column-borders",ref:"grid",bind:this,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,columnReorderingAllowed:e,pageSize:i,size:s}}getColumnProps(e,t){const{id:i}=this,{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${r(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid&&this._grid._sorters&&this._grid._sorters.length&&(this._grid._sorters=[],e=!0),this.columns&&this.columns.length){!!this.columns.find((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&this.scheduleRender()}deselectItem(e){this._deselectRowByItem(e)}deselectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._deselectRowByItem(t)}findColumn(){}generateCellClassNames(){var e;null==(e=this._grid)||e.generateCellClassNames()}getSlotElementByName(e){var t,i;return null==(t=this._grid)||null==(i=t.shadowRoot)?void 0:i.querySelector(`slot[name='${e}']`)}hideColumn(e){var t;null==(t=this.viewModel)||t.hideColumn(e),this.scheduleRender()}notifyResize(){var e;null==(e=this._grid)||e.notifyResize()}recalculateColumnWidths(){var e;null==(e=this._grid)||e.recalculateColumnWidths()}async refresh(){var e;this._clearSelection(),await(null==(e=this.store)?void 0:e.reset()),this.scrollToTop()}refreshCache(){var e;null==(e=this._grid)||e.clearCache()}selectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{t.findIndex((t=>t.objectId===e.objectId))<0&&this._grid.selectedItems.push(e)})),this._updateSelectionProps(),this._grid.render()}deselectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{const i=t.findIndex((t=>t.objectId===e.objectId));i>-1&&t.splice(i,1)})),this._grid.selectedItems=t,this._updateSelectionProps(),this._grid.render()}selectItem(e){this._selectRowByItem(e)}selectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._selectRowByItem(t)}showColumn(e){var t;null==(t=this.viewModel)||t.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){var i;null==(i=this.viewModel)||i.sortColumn(e,t)}scrollToIndex(e){var t;null==(t=this._grid)||t.scrollToIndex(e)}scrollToTop(){var e;null==(e=this._grid)||e.scrollToIndex(0)}_afterGridCreate(e){const{cellClassNameGenerator:t,dataProvider:i,itemIdPath:s,rowDetailsRenderer:r}=this;e.cellClassNameGenerator=t,e.dataProvider=i,e.rowDetailsRenderer=r,e.itemIdPath=s,this._grid=e,customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()}))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e)))}_appendStyles(){var e;const t=null==(e=this._grid)?void 0:e.shadowRoot,i=document.createElement("style");i.textContent=`\n :host { ${this._hostStyles} }\n [part~="header-cell"] ::slotted(vaadin-grid-cell-content) { ${this._headerStyles} }\n [part~="row"]:hover [part~="body-cell"] { ${this._rowHoverStyles} }\n `,null==t||t.appendChild(i)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const{_grid:e}=this;this.handles.add([i(e,"click",(e=>this._onRowClick(e))),i(e,"selected-items-changed",(e=>this._onSelectionChange(e)))])}_onRowClick(e){const{_grid:t}=this,i=t.getEventContext(e),{item:s,section:r}=i;s&&r&&"details"!==r&&"header"!==r&&this.emit("row-click",{context:i,native:e})}_selectRowByItem(e){var t;null==(t=this._grid)||t.selectItem(e)}_deselectRowByItem(e){var t;null==(t=this._grid)||t.deselectItem(e)}_clearSelection(){
|
|
959
|
+
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Ka.is,Ka);const Qa={selectionColumn:!0,columnMenus:!0},el={base:"esri-grid",content:"esri-grid__content",grid:"esri-grid__grid",noColumnMenu:"esri-grid--no-column-menu",widget:"esri-widget"};let tl=class extends(s(c)){constructor(e,i){super(e,i),this._grid=null,this._headerStyles="display: flex; font-weight: 400;",this._hostStyles='font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; background-color: inherit; color: inherit;',this._rowHoverStyles="background-color: var(--lumo-row-background-hover);",this._columnElements=[],this.cellClassNameGenerator=null,this.columnReorderingEnabled=!0,this.dataProvider=null,this.itemIdPath=null,this.label=void 0,this.messages=null,this.pageSize=50,this.selectedItems=new t,this.size=null,this.rowDetailsRenderer=null,this.store=null,this.viewModel=new u,this.visibleElements={...Qa}}initialize(){this.handles.add([this.columns.on("change",(()=>this._syncColumnRenderers())),n(this,"viewModel.size",(()=>this._updateGridSize())),n(this,"store.state",((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshCache()})),o(this,"_grid.$.table","scroll",(()=>{var e;null==(e=this.viewModel)||e.closeColumnMenus()}))])}destroy(){var e;this.handles.removeAll(),this.resetColumns(),null==(e=this.columns)||e.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}castVisibleElements(e){return{...Qa,...e}}render(){const{columnMenus:e}=this.visibleElements;return m("div",{bind:this,class:this.classes(el.base,el.widget,{[el.noColumnMenu]:!e})},m("div",{bind:this,class:el.content},this.renderGrid()))}renderGrid(){return m("vaadin-grid",{...this.getGridProps()},this.renderAllColumns())}renderAllColumns(){if("disabled"!==this.viewModel.state&&this.columns&&this.columns.length)return[this.renderSelectionColumn(),this.renderColumns()]}renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!p(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))}getGridProps(){const{columnReorderingEnabled:e,id:t,pageSize:i,size:s}=this;return{_safari:!1,class:el.grid,id:`${t}_grid`,theme:"compact column-borders",ref:"grid",bind:this,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,columnReorderingAllowed:e,pageSize:i,size:s}}getColumnProps(e,t){const{id:i}=this,{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${r(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid&&this._grid._sorters&&this._grid._sorters.length&&(this._grid._sorters=[],e=!0),this.columns&&this.columns.length){!!this.columns.find((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&this.scheduleRender()}deselectItem(e){this._deselectRowByItem(e)}deselectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._deselectRowByItem(t)}findColumn(){}generateCellClassNames(){var e;null==(e=this._grid)||e.generateCellClassNames()}getSlotElementByName(e){var t,i;return null==(t=this._grid)||null==(i=t.shadowRoot)?void 0:i.querySelector(`slot[name='${e}']`)}hideColumn(e){var t;null==(t=this.viewModel)||t.hideColumn(e),this.scheduleRender()}notifyResize(){var e;null==(e=this._grid)||e.notifyResize()}recalculateColumnWidths(){var e;null==(e=this._grid)||e.recalculateColumnWidths()}async refresh(){var e;this._clearSelection(),await(null==(e=this.store)?void 0:e.reset()),this.scrollToTop()}refreshCache(){var e;null==(e=this._grid)||e.clearCache()}selectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{t.findIndex((t=>t.objectId===e.objectId))<0&&this._grid.selectedItems.push(e)})),this._updateSelectionProps(),this._grid.render()}deselectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{const i=t.findIndex((t=>t.objectId===e.objectId));i>-1&&t.splice(i,1)})),this._grid.selectedItems=t,this._updateSelectionProps(),this._grid.render()}selectItem(e){this._selectRowByItem(e)}selectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._selectRowByItem(t)}showColumn(e){var t;null==(t=this.viewModel)||t.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){var i;null==(i=this.viewModel)||i.sortColumn(e,t)}scrollToIndex(e){var t;null==(t=this._grid)||t.scrollToIndex(e)}scrollToTop(){var e;null==(e=this._grid)||e.scrollToIndex(0)}_afterGridCreate(e){const{cellClassNameGenerator:t,dataProvider:i,itemIdPath:s,rowDetailsRenderer:r}=this;e.cellClassNameGenerator=t,e.dataProvider=i,e.rowDetailsRenderer=r,e.itemIdPath=s,this._grid=e,customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()}))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e)))}_appendStyles(){var e;const t=null==(e=this._grid)?void 0:e.shadowRoot,i=document.createElement("style");i.textContent=`\n :host { ${this._hostStyles} }\n [part~="header-cell"] ::slotted(vaadin-grid-cell-content) { ${this._headerStyles} }\n [part~="row"]:hover [part~="body-cell"] { ${this._rowHoverStyles} }\n `,null==t||t.appendChild(i)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const{_grid:e}=this;this.handles.add([i(e,"click",(e=>this._onRowClick(e))),i(e,"selected-items-changed",(e=>this._onSelectionChange(e)))])}_onRowClick(e){const{_grid:t}=this,i=t.getEventContext(e),{item:s,section:r}=i;s&&r&&"details"!==r&&"header"!==r&&this.emit("row-click",{context:i,native:e})}_selectRowByItem(e){var t;null==(t=this._grid)||t.selectItem(e)}_deselectRowByItem(e){var t;null==(t=this._grid)||t.deselectItem(e)}_clearSelection(){this._grid.selectedItems=[],this._updateSelectionProps(),this._grid.render()}_onSelectionChange(e){const t=e;if("selectedItems.splices"===t.detail.path){const{removed:e,index:i,object:s}=t.detail.value.indexSplices[0];this._updateSelectionProps(),this.emit("selection-change",{index:i,added:s,removed:e})}}_updateSelectionProps(){this.selectedItems.length&&this.selectedItems.removeAll(),this._grid&&this.selectedItems.addMany(this._grid.selectedItems)}_applyRenderersToColumnElement(e){const t=e.getAttribute("path"),i=this.viewModel.findColumn(t);if(i)try{i.renderFunction&&(e.renderer=(e,t,s)=>i.renderFunction({root:e,column:t,rowData:s})),i.footerRenderFunction&&(e.footerRenderer=(e,t)=>i.footerRenderFunction({root:e,column:t})),i.headerRenderFunction&&(e.headerRenderer=(e,t)=>i.headerRenderFunction({root:e,column:t}))}catch(s){}}};e([d()],tl.prototype,"_grid",void 0),e([a("viewModel.cellClassNameGenerator")],tl.prototype,"cellClassNameGenerator",void 0),e([a("viewModel.columns")],tl.prototype,"columns",void 0),e([a("viewModel.columnReorderingEnabled")],tl.prototype,"columnReorderingEnabled",void 0),e([a("viewModel.dataProvider")],tl.prototype,"dataProvider",void 0),e([d()],tl.prototype,"itemIdPath",void 0),e([d({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],tl.prototype,"label",void 0),e([d(),_("esri/widgets/FeatureTable/t9n/FeatureTable")],tl.prototype,"messages",void 0),e([a("viewModel.pageSize")],tl.prototype,"pageSize",void 0),e([d({readOnly:!0})],tl.prototype,"selectedItems",void 0),e([a("viewModel.size")],tl.prototype,"size",void 0),e([a("viewModel.rowDetailsRenderer")],tl.prototype,"rowDetailsRenderer",void 0),e([a("viewModel.store")],tl.prototype,"store",void 0),e([d()],tl.prototype,"viewModel",void 0),e([d()],tl.prototype,"visibleElements",void 0),e([l("visibleElements")],tl.prototype,"castVisibleElements",null),e([a("viewModel.findColumn")],tl.prototype,"findColumn",null),tl=e([h("esri.widgets.FeatureTable.Grid.Grid")],tl);const il=tl;export{il 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import h from"../../../core/Logger.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../rest/support/AttachmentQuery.js";const c="esri.widgets.FeatureTable.support.FeatureStore",d=h.getLogger(c);function p(e,t,r){d.error(new o(e,t,r))}let m=class extends r{constructor(e){super(e),this._loaded=!1,this._loadError=!1,this._loading=!1,this._editOperationQueue=[],this._queryOperationQueue=[],this._objectIdCache=new a,this._hasStaleCache=!1,this.count=0,this.failures=new a,this.itemCache=new a,this.relatedRecordsEnabled=!1}destroy(){this.layer=null,this.itemCache&&this.itemCache.destroy(),this.failures&&this.failures.destroy(),this._set("itemCache",null)}set attachmentsEnabled(e){this._reset(),this._set("attachmentsEnabled",e),this.notifyChange("state")}set filterGeometry(e){this._reset(),this._set("filterGeometry",e),this.notifyChange("state")}set layer(e){this._reset(),this._set("layer",e),this.notifyChange("state")}set objectIds(e){this._reset(),this._set("objectIds",e||null),this.notifyChange("state")}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}set returnGeometry(e){this._reset(),this._set("returnGeometry",e),this.notifyChange("state")}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return r?"error":!e||this.get("layer.loadError")?"disabled":s?"loading":"loaded"===this.get("layer.loadStatus")&&t?"loaded":"ready"}get syncing(){return this._editOperationQueue.length>0}get where(){return this._get("where")||null}set where(e){this._reset(),this._set("where",e),this.notifyChange("state")}async load(){this._reset();const{layer:e}=this;if(!e)return Promise.resolve();this._loading=!0,this.notifyChange("state");try{await e.when(),await this._syncLayerInfo(),this._loading=!1,this._loaded=!0,this.notifyChange("state")}catch(t){throw this._reset(),this._loadError=!0,this.notifyChange("state"),p("store:load-error","An error ocurred.",{error:t}),t}}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:a,state:o}=this;if(!a||"loaded"!==o)return Promise.resolve([]);this.notifyChange("querying");const n=await this._query({start:s,num:i,page:t,pageSize:r});return this.notifyChange("state"),n}async query(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];this.notifyChange("querying");const s=await this._query(e);return this.notifyChange("state"),s}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){return this._update(e)}getItemByObjectId(e){const{itemCache:t,layer:{objectIdField:r}}=this;return t.find((t=>t.feature.attributes[r]===e))}getLocalItemAt(e){return this.itemCache.getItemAt(e)}getItemAt(e){return Promise.resolve(this.itemCache.getItemAt(e))}getObjectIdIndex(e){const{itemCache:t,layer:{objectIdField:r}}=this;return t.findIndex((t=>t.feature.attributes[r]===e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue=[],this._queryOperationQueue=[],this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll(),this.notifyChange("querying"),this.notifyChange("syncing"),this.notifyChange("state")}_getIdsFromFeatures(e){return e.map((e=>e.attributes[this.layer.objectIdField]))}_toFeatureData(e,t){const{layer:{objectIdField:r}}=this;return e.map((e=>{const{attributes:s}=e,i=s[r];return{objectId:i,feature:e,attachments:t?t[i]:null,relatedRecords:null}}))}async _update(e){const{layer:r}=this,{operations:s}=r.capabilities;if(!s.supportsUpdate||"wfs"===r.type||"imagery"===r.type)throw new o("store:update-error","Update is not supported.");const{index:i,name:a,value:h}=e,u=await this.getItemAt(i);if(!u||!u.feature)throw new o("store:update-error","Feature with provided 'objectId' not found.");const{feature:y}=u,l=n(y.attributes);l[a]=h;const c=new t({attributes:l}),d=r.applyEdits({updateFeatures:[c]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(y.attributes=l),e}));return this._queueEditOperation((()=>d))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._updateIds(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){return this._queueQueryOperation((async()=>{const{features:t}=await this._queryFeatures(e),r=this._getIdsFromFeatures(t),s=await this._queryAttachments(r);return this._toFeatureData(t,s)||[]}))}async _syncLayerInfo(){await this._updateCount(),await this._updateIds()}async _updateCount(){await this._queryCount().then((e=>this._set("count",e)))}async _updateIds(){var e,t,r;null!=(e=this.layer)&&null!=(t=e.capabilities)&&null!=(r=t.query)&&r.supportsPagination||(this._objectIdCache.removeAll(),await this._queryObjectIds().then((e=>this._objectIdCache.addMany(e))))}_queryCount(){const{filterGeometry:e,layer:t,returnGeometry:r}=this,s=t.createQuery();return s.geometry=e,s.returnGeometry=r,s.where=this._getWhere(),s.objectIds=this.objectIds,t.queryFeatureCount(s)}_queryObjectIds(){const{filterGeometry:e,layer:t,orderByFields:r,returnGeometry:s}=this,{capabilities:{query:{supportsCacheHint:i,supportsOrderBy:a}}}=t;if("geojson"===t.type||"wfs"===t.type||"imagery"===t.type)return Promise.resolve([]);const o=t.createQuery();return o.geometry=e,o.outFields=[t.objectIdField],o.returnGeometry=s,o.where=this._getWhere(),o.objectIds=this.objectIds,a&&(o.orderByFields=r),i&&(o.cacheHint=!0),t.queryObjectIds(o)}async _queryFeatures(e){const{layer:t}=this;if(!t.capabilities.operations.supportsQuery)return Promise.reject(new o("store:query-error","Layer does not support query operation."));const{filterGeometry:r,layer:{capabilities:{query:{supportsCacheHint:s,supportsOrderBy:i,supportsPagination:a}}},orderByFields:n,returnGeometry:h}=this,{start:u,pageSize:y}=e,l=t.createQuery();return l.returnGeometry=h,a?(l.start=u,l.num=y,l.where=this._getWhere()):l.objectIds=this._getObjectIdsForPage(u,y),i&&(l.orderByFields=n),r&&(l.geometry=r),l.objectIds=this.objectIds,s&&(l.cacheHint=!0),t.queryFeatures(l)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{attachmentsEnabled:t,layer:r}=this,{capabilities:{data:{supportsAttachment:s},operations:{supportsQueryAttachments:i}}}=r;return t&&s&&i&&"geojson"!==r.type&&"wfs"!==r.type&&"imagery"!==r.type?r.queryAttachments(new l({objectIds:e,where:this._getWhere()})):Promise.resolve(null)}_queueQueryOperation(e){return this._queryOperationQueue.push(e),this.notifyChange("querying"),e().then((t=>this._queryOperationQueue.indexOf(e)>-1?(this.itemCache.addMany(t),t):[])).catch((t=>{p("store:query-error","An error ocurred.",{error:t});const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(i(this._queryOperationQueue,e),this.notifyChange("querying"),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),this.notifyChange("syncing"),e().then((()=>{i(this._editOperationQueue,e),this.notifyChange("syncing")})).catch((t=>{p("store:edit-error","An error ocurred.",{error:t});const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),i(this._editOperationQueue,e),this.notifyChange("syncing"),t}))}_getWhere(){return this.where||this.layer.definitionExpression||"1=1"}};e([u()],m.prototype,"attachmentsEnabled",null),e([u({readOnly:!0})],m.prototype,"count",void 0),e([u({readOnly:!0})],m.prototype,"failures",void 0),e([u()],m.prototype,"filterGeometry",null),e([u({readOnly:!0})],m.prototype,"itemCache",void 0),e([u({value:null})],m.prototype,"layer",null),e([u({value:null})],m.prototype,"objectIds",null),e([u()],m.prototype,"orderByFields",null),e([u({readOnly:!0})],m.prototype,"querying",null),e([u()],m.prototype,"relatedRecordsEnabled",void 0),e([u({value:!1})],m.prototype,"returnGeometry",null),e([u({readOnly:!0})],m.prototype,"state",null),e([u({readOnly:!0})],m.prototype,"syncing",null),e([u()],m.prototype,"where",null),m=e([y(c)],m);const _=m;export{_ as default};
|