@arcgis/core 4.27.0-next.20230521 → 4.27.0-next.20230523
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/WebMap.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/030b43764f945cb1f8b0.js +1 -0
- package/assets/esri/core/workers/chunks/0d02856e55d20b99fc8b.js +1 -0
- package/assets/esri/core/workers/chunks/{69242c66492717c7388c.js → 0fcb8d408696075338e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{b91c155de9a89e4e6971.js → 187c3b971ed0fc4363ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{85c6ce93aa41e6b65997.js → 18db07d739a713cc0465.js} +1 -1
- package/assets/esri/core/workers/chunks/1b6177e23327be645c8c.js +1 -0
- package/assets/esri/core/workers/chunks/28286014a575042619ee.js +1 -0
- package/assets/esri/core/workers/chunks/{692dfeb2e255fdc0ade2.js → 39288fa69561d21f04f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2b9d3e60977934a6d471.js → 3bc6b5f0643364749ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/45e5ad704d18dd0857ce.js +1 -0
- package/assets/esri/core/workers/chunks/4d24efa01d1accc5a5f0.js +1 -0
- package/assets/esri/core/workers/chunks/{6312783626bacf52df7a.js → 55486c644e8b01326a0d.js} +1 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +1 -0
- package/assets/esri/core/workers/chunks/{62d9d15f0d00a75da42c.js → 571dac507622948ac03e.js} +1 -1
- package/assets/esri/core/workers/chunks/59063d6abf70f6598425.js +1 -0
- package/assets/esri/core/workers/chunks/5a4c04bf4f57e74457c5.js +1 -0
- package/assets/esri/core/workers/chunks/5bf04c32e0ac89dcbf9f.js +1 -0
- package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js +2 -0
- package/assets/esri/core/workers/chunks/{55ca6ba8b40921025181.js.LICENSE.txt → 6a3d611e8842afbb50ab.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/70d6e5edf05ef7079fa8.js +1 -0
- package/assets/esri/core/workers/chunks/71bdf8f10aee0077f681.js +1 -0
- package/assets/esri/core/workers/chunks/72b2c3c8e76da699690c.js +1 -0
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +1 -0
- package/assets/esri/core/workers/chunks/791f529e90135398b3d5.js +1 -0
- package/assets/esri/core/workers/chunks/8d3abfe6fdc5ac8d6cb7.js +1 -0
- package/assets/esri/core/workers/chunks/{1edc5c06874cb12c5478.js → 924e4a18d8403d1caea3.js} +1 -1
- package/assets/esri/core/workers/chunks/96d339abcd917f1f0ae1.js +1 -0
- package/assets/esri/core/workers/chunks/97cdbec7532cfcdf9ad2.js +1 -0
- package/assets/esri/core/workers/chunks/{f3f6035a17f7dcd19675.js → 9ab400a89dd701778d2c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1488b3d48232844b8bb4.js → 9fe349f43d5ff5a4ac2d.js} +1 -1
- package/assets/esri/core/workers/chunks/{22396dd3717d17a5d235.js → a1c31bb8c12831539328.js} +1 -1
- package/assets/esri/core/workers/chunks/b0571b9e602218cdc7aa.js +1 -0
- package/assets/esri/core/workers/chunks/b1d88f8e528bf7092f35.js +1 -0
- package/assets/esri/core/workers/chunks/b4e2dc6b3d06b426e596.js +1 -0
- package/assets/esri/core/workers/chunks/{48abcb2d88f22e6e9fde.js → c2cb9fa18c77f0c5104e.js} +1 -1
- package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +1 -0
- package/assets/esri/core/workers/chunks/d08800a30b1227591986.js +1 -0
- package/assets/esri/core/workers/chunks/d725dbbdeb05322e6d88.js +1 -0
- package/assets/esri/core/workers/chunks/df3e497d12ed77bae168.js +1 -0
- package/assets/esri/core/workers/chunks/fb080339bfaf32731ca6.js +1 -0
- package/assets/esri/core/workers/chunks/{56fc7924b4fb30239c19.js → fdf58386a67e54c09bfb.js} +1 -1
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +86 -96
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +6 -0
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +40 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip.json +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nb.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-TW.json +1 -1
- package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
- package/chunks/arcgis-knowledge-client-core.js +1 -1
- package/chunks/mat4.js +1 -1
- package/core/accessorSupport/write.js +1 -1
- package/core/fontUtils.js +1 -1
- package/core/libs/gl-matrix-2/math/mat4.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.js +5 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.js +5 -0
- package/geometry/support/MeshLocalVertexSpace.d.ts +4 -0
- package/geometry/support/MeshLocalVertexSpace.js +5 -0
- package/geometry/support/MeshTransform.d.ts +4 -0
- package/geometry/support/MeshTransform.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/centerAt.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/geographicUtils.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/offset.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/interfaces.d.ts +227 -25
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/CompositeBandFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +2 -2
- package/popup/FieldInfo.js +1 -1
- package/portal/Portal.js +1 -1
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/symbology/color.js +1 -1
- package/smartMapping/symbology/support/colors.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/symbolComplexity.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/helpMessageUtils.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/layers/StreamLayerView.js +1 -1
- package/widgets/BasemapGallery/css.js +1 -1
- package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +5 -0
- package/widgets/UtilityNetworkValidateTopology.js +5 -0
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/163bf2e13abbdd298374.js +0 -1
- package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +0 -1
- package/assets/esri/core/workers/chunks/2640204c4655aa535ccb.js +0 -1
- package/assets/esri/core/workers/chunks/2bf42d060f877566b989.js +0 -1
- package/assets/esri/core/workers/chunks/34ec9623a1bece86a82b.js +0 -1
- package/assets/esri/core/workers/chunks/3bf52139340827794c3b.js +0 -1
- package/assets/esri/core/workers/chunks/3cebdd77a8401495097f.js +0 -1
- package/assets/esri/core/workers/chunks/48cb634255e39711a720.js +0 -1
- package/assets/esri/core/workers/chunks/4d5f71d84c85f45c97ea.js +0 -1
- package/assets/esri/core/workers/chunks/52d02021e858820bc4fa.js +0 -1
- package/assets/esri/core/workers/chunks/55ca6ba8b40921025181.js +0 -2
- package/assets/esri/core/workers/chunks/64b8f65e2ef6cbf08380.js +0 -1
- package/assets/esri/core/workers/chunks/662e479c370c11bcb8a7.js +0 -1
- package/assets/esri/core/workers/chunks/78aede1e114deefacb54.js +0 -1
- package/assets/esri/core/workers/chunks/7ef100158ca28631fcaf.js +0 -1
- package/assets/esri/core/workers/chunks/93ad67930aa7d4a4b0ac.js +0 -1
- package/assets/esri/core/workers/chunks/964795dfb57f0d0635d0.js +0 -1
- package/assets/esri/core/workers/chunks/99ce0a202dcd3d7dc290.js +0 -1
- package/assets/esri/core/workers/chunks/abe6c99a1a719543dbe8.js +0 -1
- package/assets/esri/core/workers/chunks/c3bf44146fddfe8990f7.js +0 -1
- package/assets/esri/core/workers/chunks/cbe817e966b57599bafd.js +0 -1
- package/assets/esri/core/workers/chunks/e15b5d7e46a834eacc57.js +0 -1
- package/assets/esri/core/workers/chunks/e1e0b3580e2c3098c9f4.js +0 -1
- package/assets/esri/core/workers/chunks/e305d20e4424451cab5b.js +0 -1
- package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +0 -1
- package/assets/esri/core/workers/chunks/f924732902703233655e.js +0 -1
- package/assets/esri/core/workers/chunks/ff1c005eede0cf964332.js +0 -1
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},B={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function $(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...B},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.previous(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...B,...e,snappingControlsElements:{...B.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.data.edits.modified||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:$,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:o}=e,n=m(t);return n&&o[n]&&`${o[n]}`||S(this.messages.untitledFeatureTemplate,{id:o[s]})}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveAndResetWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.previous(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.data.edits.modified||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:o}=e,n=m(t);return n&&o[n]&&`${o[n]}`||`${s}: ${o[s]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveAndResetWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../intl.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,convertDateFormatToIntlOptions as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as u}from"../../../layers/support/layerUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,y=/(\{([^\{\r\n]+)\})/g,m=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,I=/[\u00A0-\u9999<>\&]/gim,b=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,F=/^(?:mailto:|tel:)/,w="relationships/",j=n("short-date-short-time");function N(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function E(e,t){return"function"==typeof e?e(t):e}function T(e=""){if(e)return!F.test(e.trim().toLowerCase())}function x(e){return!!e&&g.test(e)}function C(e,t){if(!x(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function q(e,t){const r=C(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function A(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function M(e){return e.replaceAll(p,"")}function R(e,t){const r=v(t,e);return r?r.name:e}function D(e,t){return e&&e.map((e=>R(e,t)))}function v(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function L(e){return`${e}`.trim()}function U({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?$({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function $({formattedAttributes:e,template:r,fieldInfoMap:n}){return L(M(t(t(r,(e=>A(e,n))),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(m,i);t[e]=o}}function S(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>O(e,r,t))),r}function G(e,r,n){const i=(r=L(r))&&"{"!==r[0];return t(e,S(n,i||!1))}function k(e,t){return e.replaceAll(y,((e,r,n)=>{const i=v(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=k(e,r);return n?n.replaceAll(b,((e,r,n)=>G(e,r||n,t))):n}function Q(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function _(e){return null!=e&&"object"==typeof e&&"type"in e&&"feature"===e.type}function z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function H(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function V(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&"feature"===e.type&&"when"in e}function Z(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function B(e){return V(e)&&Z(e)}function J(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u}=t,f=K(r,n),c=f?.clone(),d=v(u,n);if(c&&!a(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=c.format??new s;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!z(u)&&_(u)&&u.datesInUnknownTimezone||z(u)&&H(u.layer)&&u.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const p=c?.format;return"string"==typeof e&&a(n)&&p?p.formatRasterPixelValue(e):"string"==typeof(e=Q(e,p))||null==e||null==p?ne(e):l?i(e,{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}):p.formatNumber(e)}function K(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function W({fieldName:e,graphic:t,layer:r}){if(se(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function X({fieldName:e,value:t,graphic:r,layer:n}){if(se(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function Y(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,j),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,j),user:e}}return null}function ee(e,t){const r=new Map;return e?(e.forEach((e=>{const n=R(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function te(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function re(e){return e.replaceAll(I,(e=>`&#${e.charCodeAt(0)};`))}function ne(e){return"string"==typeof e?e.replaceAll(h,'<br class="esri-text-new-line" />'):e}function ie(e){const{value:t,fieldName:n,fieldInfos:i,fieldInfoMap:o,layer:a,graphic:l}=e;if(null==t)return"";const u=X({fieldName:n,value:t,graphic:l,layer:a});if(u)return u;const s=W({fieldName:n,graphic:l,layer:a});if(s)return s;if(o.get(n.toLowerCase()))return J(t,{fieldInfos:i||Array.from(o.values()),fieldName:n,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(n)?r(t,j):ne(t)}function oe({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>de({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=ie({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function ae(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,s=o[0];if("number"!=typeof s&&"string"!=typeof s){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:s,requiredFields:i};return d.warn(e,t),null}if(!u(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return d.warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function le(e){if(!e.expressionInfos?.length)return!1;const t=await f(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ue({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],u=await t.getRequiredFields(r.fieldsIndex),s=l(u,e),f=s?[]:u,c=t.returnGeometry||await le(t);if(s&&!c)return;const d=await ae({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function se(e=""){return!!e&&e.includes(w)}function fe(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function ce({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=fe({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=ie({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function de({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ce({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ce({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const pe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},ye=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;pe(n)||pe(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},me=({query:e,layer:t,method:r})=>{ye({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},ge=({queryPayload:e,layer:t,method:r})=>{ye({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function he(e,t,r){return e&&t&&r?Ie(e.allLayers,t,r)||Ie(e.allTables,t,r):null}function Ie(e,t,r){return e.filter(B).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{ne as applyTextFormattingHTML,ee as createfieldInfoMap,he as findRelatedLayer,k as fixTokens,oe as formatAttributes,Y as formatEditInfo,J as formatValueToFieldInfo,te as getAllFieldInfos,K as getFieldInfo,q as getFieldInfoLabel,R as getFixedFieldName,D as getFixedFieldNames,N as getSourceLayer,E as graphicCallback,re as htmlEntities,x as isExpressionField,V as isFeatureSupportedLayer,B as isRelatableFeatureSupportedLayer,Z as isRelatableLayer,se as isRelatedField,me as preLayerQueryCallback,ge as preRequestCallback,ae as querySourceLayer,ue as queryUpdatedFeature,T as shouldOpenInNewTab,$ as substituteAttributes,U as substituteFieldsInLinksAndAttributes};
|
|
5
|
+
import"../../../intl.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,convertDateFormatToIntlOptions as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as u}from"../../../layers/support/layerUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,y=/(\{([^\{\r\n]+)\})/g,m=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,I=/[\u00A0-\u9999<>\&]/gim,b=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,F=/^(?:mailto:|tel:)/,w="relationships/",j=n("short-date-short-time");function N(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function E(e,t){return"function"==typeof e?e(t):e}function T(e=""){if(e)return!F.test(e.trim().toLowerCase())}function x(e){return!!e&&g.test(e)}function C(e,t){if(!x(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function q(e,t){const r=C(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function A(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function M(e){return e.replaceAll(p,"")}function R(e,t){const r=v(t,e);return r?r.name:e}function D(e,t){return e&&e.map((e=>R(e,t)))}function v(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function L(e){return`${e}`.trim()}function U({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?$({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function $({formattedAttributes:e,template:r,fieldInfoMap:n}){return L(M(t(t(r,(e=>A(e,n))),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(m,i);t[e]=o}}function S(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>O(e,r,t))),r}function G(e,r,n){const i=(r=L(r))&&"{"!==r[0];return t(e,S(n,i||!1))}function k(e,t){return e.replaceAll(y,((e,r,n)=>{const i=v(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=k(e,r);return n?n.replaceAll(b,((e,r,n)=>G(e,r||n,t))):n}function Q(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function _(e){return null!=e&&"object"==typeof e&&"type"in e&&"feature"===e.type}function z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function H(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function V(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&"feature"===e.type&&"when"in e}function Z(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function B(e){return V(e)&&Z(e)}function J(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u}=t,f=K(r,n),c=f?.clone(),d=v(u,n);if(c&&!a(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=c.format??new s;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!z(u)&&_(u)&&u.datesInUnknownTimezone||z(u)&&H(u.layer)&&u.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const p=c?.format;return"string"==typeof e&&a(n)&&p?p.formatRasterPixelValue(e):"string"==typeof(e=Q(e,p))||null==e||null==p?ne(e):l?i(e,{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}):p.formatNumber(e)}function K(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function W({fieldName:e,graphic:t,layer:r}){if(se(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function X({fieldName:e,value:t,graphic:r,layer:n}){if(se(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function Y(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,j),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,j),user:e}}return null}function ee(e,t){const r=new Map;return e?(e.forEach((e=>{const n=R(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function te(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function re(e){return e.replaceAll(I,(e=>`&#${e.charCodeAt(0)};`))}function ne(e){return"string"==typeof e?e.replaceAll(h,'<br class="esri-text-new-line" />'):e}function ie(e){const{value:t,fieldName:n,fieldInfos:i,fieldInfoMap:o,layer:a,graphic:l}=e;if(null==t)return"";const u=X({fieldName:n,value:t,graphic:l,layer:a});if(u)return u;const s=W({fieldName:n,graphic:l,layer:a});if(s)return s;if(o.get(n.toLowerCase()))return J(t,{fieldInfos:i||Array.from(o.values()),fieldName:n,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(n)?r(t,j):ne(t)}function oe({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>de({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=ie({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function ae(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,s=o[0];if("number"!=typeof s&&"string"!=typeof s){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:s,requiredFields:i};return d.warn(e,t),null}if(!u(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return d.warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function le(e){if(!e.expressionInfos?.length)return!1;const t=await f(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ue({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],u=await t.getRequiredFields(r.fieldsIndex),s=l(u,e),f=s?[]:u,c=t.returnGeometry||await le(t);if(s&&!c)return;const d=await ae({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function se(e=""){return!!e&&e.includes(w)}function fe(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function ce({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=fe({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=ie({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function de({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ce({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ce({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const pe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},ye=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;pe(n)||pe(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},me=({query:e,layer:t,method:r})=>{ye({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},ge=({queryPayload:e,layer:t,method:r})=>{ye({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function he(e,t,r){return e&&t&&r?Ie(e.allLayers,t,r)||Ie(e.allTables,t,r):null}function Ie(e,t,r){return e.filter(B).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{ne as applyTextFormattingHTML,ee as createfieldInfoMap,he as findRelatedLayer,k as fixTokens,oe as formatAttributes,Y as formatEditInfo,J as formatValueToFieldInfo,te as getAllFieldInfos,K as getFieldInfo,q as getFieldInfoLabel,R as getFixedFieldName,D as getFixedFieldNames,N as getSourceLayer,E as graphicCallback,re as htmlEntities,x as isExpressionField,_ as isFeatureLayer,V as isFeatureSupportedLayer,B as isRelatableFeatureSupportedLayer,Z as isRelatableLayer,se as isRelatedField,me as preLayerQueryCallback,ge as preRequestCallback,ae as querySourceLayer,ue as queryUpdatedFeature,T as shouldOpenInNewTab,$ as substituteAttributes,U as substituteFieldsInLinksAndAttributes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{templateHasKey as t,replace as n}from"../../core/string.js";import{formatDate as r,formatDateOnly as i,convertDateFormatToIntlOptions as o,formatTimeOnly as a,formatTimestamp as
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{templateHasKey as t,replace as n}from"../../core/string.js";import{formatDate as r,formatDateOnly as i,convertDateFormatToIntlOptions as o,formatTimeOnly as a,formatTimestamp as s,systemTimeZone as l}from"../../intl/date.js";import{DomainValidationError as m,getDomainRange as u}from"../../layers/support/domainUtils.js";import{isDateField as p,NumericRangeValidationError as d,getFieldRange as f,TypeValidationError as c}from"../../layers/support/fieldUtils.js";import{substitute as y}from"../../intl/substitute.js";const T=e=>"field"===e?.type,h=e=>"group"===e?.type,O=e=>"relationship"===e?.type,b=e=>!h(e)&&null!=e.group,g=e=>"field"===e.type,E=e=>"group"===e.type,v=e=>"relationship"===e.type,j=e=>e.reduce(((e,t)=>h(t)?[...e,...t.inputs]:[...e,t]),[]),x=e=>j(e).filter(T),_=e=>j(e).filter(O),N=(e,t)=>null!=e&&e.input?.type===t,F=e=>null!=e&&(N(e,"text-box")||N(e,"text-area")),L=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),U=e=>"items"in e,A={typeFieldName:null,types:[]};function I(n,r,i){const o=Object.keys(r).filter((e=>t(n,e))),a=o.map((e=>r[e])),s=o.map((e=>i.get(e))).filter(e);return H(n,V(a,s))}function V(e,t){const n=t.map(((t,n)=>{let r=e[n];if(t.domain&&"coded-value"===t.domain.type){const e=t.domain.codedValues.find((e=>e.code===r));e?.name&&(r=e.name)}return p(t)&&(r=S(t,r)),[t.name,r]}));return Object.fromEntries(n)}function R(e){return r(e,o("short-date-short-time"))}function w(e){return i(e,o("short-date"))}function C(e){return a(e,o("short-time"))}function D(e){return s(e,{...o("short-date-short-time"),...l})}function S(e,t){if(!e||null==t)return null;switch(e.type){case"date":return R(t);case"date-only":return w(t);case"time-only":return C(t);case"timestamp-offset":return D(t);default:return null}}const G=new Set(["date-only","time-only","timestamp-offset"]);function H(e,t){return n(n(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const k=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:A:A;var q;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(q||(q={}));const B={type:"number"},P={type:"number",intlOptions:{notation:"scientific"}},Y={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};function $(e){return e>=1e7||e<=-1e7}const z=(e,t)=>{const{dataType:n,domain:r,error:i,field:o,minLength:a,value:s,required:l}=e;if(!t||!i)return null;if(l&&null===s)return t.validationErrors.cannotBeNull;if(i===m.VALUE_OUT_OF_RANGE||i===d.OUT_OF_RANGE){const e=u(r)||f(o);return y(t.validationErrors.outsideRange,e,{format:{max:"date"===n?Y:$(e.max)?P:B,min:"date"===n?Y:$(e.min)?P:B}})}return i===m.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===c.INVALID_TYPE?t.validationErrors.invalidType:i===q.TOO_SHORT?y(t.validationErrors.tooShort,{min:a}):null},J=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},K=e=>{const n=[];if(e.formTemplate){const{description:r,title:i}=e.formTemplate;e.fields?.forEach((e=>{const o=i&&t(i,e.name),a=r&&t(r,e.name);(o||a)&&n.push(e.name)}))}return n};function M(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(g)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}export{q as LengthValidationError,x as flattenFieldInputs,j as flattenInputs,_ as flattenRelationshipInputs,M as formTemplateHasInvalidFields,R as formatDateField,S as formatDateFieldValue,w as formatDateOnlyField,C as formatTimeOnlyField,D as formatTimestampOffsetField,V as getComputedAttributes,z as getErrorMessageForFieldInput,K as getFieldsInTitleAndDesc,J as getIconForFeature,k as getNormalizedFeatureTypeInfo,g as isFieldElement,N as isFieldElementWithInputType,F as isFieldElementWithTextInput,T as isFieldInput,E as isGroupElement,h as isGroupInput,b as isInputInGroupInput,L as isNumberFieldInput,v as isRelationshipElement,O as isRelationshipInput,U as isTemplateItemGroup,I as parseFormTemplateString,H as substituteFieldTemplatesInString,G as unsupportedDateFieldTypes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as l,formatNumber as a}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import m from"../FeatureForm/FieldInput.js";import h from"./Grid/EditorColumn.js";import f from"../support/DatePicker.js";import g from"../support/TimePicker.js";import{renderingSanitizer as y}from"../support/widgetUtils.js";const v={cancelEdit:"Escape"},b="esri-field-column",_={headerContent:`${b}__header-content`,headerLabel:`${b}__header-label`,input:`${b}__cell-input`,inputContainer:`${b}__cell__input-container`,dateInputContainer:`${b}__cell__date-input-container`,dateInputWrapper:`${b}__cell__date-input-wrapper`,button:`${b}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},F=r("short-date-short-time"),C=r("short-date"),E={useGrouping:!0,maximumFractionDigits:20};let I=class extends h{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:y.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(d(i)){const e=n?.format?l(n.format):E;return a(parseFloat(t),e)}return y.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(_.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(_.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),l=c(i),a=l?.operations.supportsUpdate;return!!(n.editable&&r&&a)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:l}=this,{domain:a}=this._inputField;let s;"coded-value"===a?.type?(s=this._createSelectElement(t,a.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(_.input),s.value=t,s.required=l;let u=!1;s.onkeydown=e=>{u=e.key===v.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(_.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(_.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:l}=this,a=e?new Date(e):new Date(Date.now()),s=new f({dateInputEnabled:!0,value:a}),u=new g({value:a});i.value=a.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),y=document.createElement("div");s.container=h,u.container=y;const v=document.createElement("button");v.classList.add(_.button,_.saveIcon),v.onclick=()=>c(),v.title=r?.save;const b=document.createElement("button");b.classList.add(_.button,_.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(_.dateInputWrapper),F.appendChild(h),(l&&l.input&&"datetime-picker"===l.input.type&&!1!==l.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(y);const C=document.createElement("div");C.classList.add(_.dateInputContainer),C.appendChild(F),C.appendChild(v),C.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(C),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new m({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,l=r===i,a=this.field.domain;if(l&&!a)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||a,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?C:F}};e([n({readOnly:!0})],I.prototype,"alias",null),e([n()],I.prototype,"cellValueFormatFunction",void 0),e([n()],I.prototype,"cellValueValidatorFunction",void 0),e([n()],I.prototype,"config",void 0),e([n({readOnly:!0})],I.prototype,"defaultValue",null),e([n({readOnly:!0})],I.prototype,"description",null),e([n({readOnly:!0})],I.prototype,"editable",null),e([n()],I.prototype,"editingEnabled",void 0),e([n()],I.prototype,"expressionInfos",void 0),e([n()],I.prototype,"field",void 0),e([n()],I.prototype,"formatFunction",void 0),e([n({readOnly:!0})],I.prototype,"header",null),e([n()],I.prototype,"hidden",null),e([n()],I.prototype,"headerRenderFunction",void 0),e([n()],I.prototype,"inputRenderFunction",void 0),e([n()],I.prototype,"layer",void 0),e([n({readOnly:!0})],I.prototype,"loadingMessage",null),e([n()],I.prototype,"maxLength",null),e([n()],I.prototype,"minLength",null),e([n({readOnly:!0})],I.prototype,"name",null),e([n({readOnly:!0})],I.prototype,"nullable",null),e([n()],I.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],I.prototype,"path",null),e([n({readOnly:!0})],I.prototype,"required",null),e([n()],I.prototype,"sortable",null),e([n()],I.prototype,"store",void 0),e([n()],I.prototype,"template",void 0),e([n()],I.prototype,"updateRowItemFunction",void 0),e([n()],I.prototype,"updateStoreItemFunction",void 0),I=e([i("esri.widgets.FeatureTable.FieldColumn")],I);const L=I;export{L as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
|
package/widgets/LayerList.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import has from"../core/has.js";import{on as s,watch as n,initial as o,syncAndInitial as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{cast as a}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import h from"./LayerList/LayerListViewModel.js";import u from"./LayerList/ListItem.js";import{findSelectedItem as g,sortLayersToIds as m,sortChildLayersToIds as p,canSortSublayers as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{accessibleHandler as y}from"./support/decorators/accessibleHandler.js";import{messageBundle as I}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import C from"sortablejs";function w(e,t,i){e.splice(i,0,e.splice(t,1)[0])}const A="esri-layerlist-new-ui",S=t.ofType(u),$="data-sort-filter",k="data-layer-uid",M="layerUid",T="esri-layer-list",L=`${T}__item`,E={base:`${T} esri-widget esri-widget--panel`,newUI:`${T}--new-ui`,noItems:`${T}__no-items`,list:`${T}__list`,listRoot:`${T}__list--root`,listExclusive:`${T}__list--exclusive`,listInherited:`${T}__list--inherited`,listIndependent:`${T}__list--independent`,item:L,itemContent:`${L}-content`,itemMessage:`${L}--has-message`,itemInvisible:`${L}--invisible`,itemInvisibleAtScale:`${L}--invisible-at-scale`,itemChildren:`${L}--has-children`,itemSelectable:`${L}--selectable`,itemContainer:`${L}-container`,actionsMenu:`${L}-actions-menu`,actionsMenuItem:`${L}-actions-menu-item`,actionsMenuItemActive:`${L}-actions-menu-item--active`,actions:`${L}-actions`,actionsList:`${L}-actions-list`,action:`${L}-action`,actionIcon:`${L}-action-icon`,actionImage:`${L}-action-image`,actionTitle:`${L}-action-title`,actionToggle:`${T}__action-toggle`,actionToggleOn:`${T}__action-toggle--on`,label:`${L}-label`,message:`${L}-message`,title:`${L}-title`,statusIndicator:`${T}__status-indicator`,publishing:`${T}__publishing`,updating:`${T}__updating`,connectionStatus:`${T}__connection-status`,connectionStatusConnected:`${T}__connection-status--connected`,toggleVisible:`${L}-toggle`,toggleVisibleIcon:`${L}-toggle-icon`,toggleIcon:`${L}-toggle-icon`,radioIcon:`${L}-radio-icon`,childToggle:`${T}__child-toggle`,childToggleOpen:`${T}__child-toggle--open`,childOpened:`${T}__child-toggle-icon--opened`,childClosed:`${T}__child-toggle-icon--closed`,childClosed_RTL:`${T}__child-toggle-icon--closed-rtl`,sortableChosen:`${T}--chosen`,disabled:"esri-disabled",disabledElement:"esri-disabled-element",hidden:"esri-hidden",rotating:"esri-rotating",iconEllipses:"esri-icon-handle-horizontal",iconVisible:"esri-icon-visible",iconInvisible:"esri-icon-non-visible",iconRadioSelected:"esri-icon-radio-checked",iconRadioUnselected:"esri-icon-radio-unchecked",iconNoticeTriangle:"esri-icon-notice-triangle",iconChildrenOpen:"esri-icon-down-arrow",iconDownArrow:"esri-icon-down-arrow",iconRightArrow:"esri-icon-right-triangle-arrow",iconLeftArrow:"esri-icon-left-triangle-arrow",iconLoading:"esri-icon-loading-indicator",iconDefaultAction:"esri-icon-default-action",widgetIcon:"esri-icon-layers"},R={actions:"actions",actionSection:"action-section",items:"items"},x={exclusive:"exclusive",inherited:"inherited",independent:"independent"};function U(e){const{actionsOpen:t,children:i}=e;t&&(e.actionsOpen=!1),i.forEach((e=>U(e)))}const N="root",O={statusIndicators:!0,errors:!1};let j=class extends d{constructor(e,t){super(e,t),this._sortableNodes=new Map,this._sortableMap=new Map,this._focusSortUid=null,this._newUI=has(A),this._tooltipReferenceMap=new Map,this.visibleItems=null,this.iconClass=E.widgetIcon,this.icon=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.multipleSelectionEnabled=!1,this.selectionEnabled=!1,this.selectedItems=new S,this.viewModel=new h,this.visibleElements={...O},this._onSortableSort=({to:e,from:t,item:i,newIndex:s})=>{t&&e&&(t===e?this._sortLayers(this._sortableMap.get(t.dataset.group)):this._moveLayerFromChildList({to:e,from:t,item:i,newIndex:s}))},this._sortableCanSort=(e,t)=>!(!e.el.dataset.group||!t.el.dataset.group),this._sortableCanPull=(e,t,i)=>{const{listItemCanGiveFunction:s}=this,n={selected:V(i),from:V(t.el),to:V(e.el)};return!this._sortableCanSort(e,t)||"function"!=typeof s||s.call(null,n)},this._sortableCanPut=(e,t,i)=>{const{listItemCanReceiveFunction:s}=this,n={selected:V(i),from:V(t.el),to:V(e.el)};return!this._sortableCanSort(e,t)||"function"!=typeof s||s.call(null,n)},this._onSortableEnd=({oldIndex:e,from:t,to:i,item:s})=>{t!==i&&t.insertBefore(s,t.children[e])}}initialize(){const e=this.operationalItems;this._setVisibleItems(e),this.addHandles([s((()=>this.operationalItems),"change",(()=>this._itemsChanged(e))),n((()=>this.visibleElements),(()=>this._itemsChanged(e))),n((()=>this.selectionEnabled),(()=>this._toggleAllSorting()),o)])}loadDependencies(){return _({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this.removeAllHandles(),this._destroySortables(),this._tooltipReferenceMap.clear()}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...O,...e}}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{visibleItems:e,_newUI:t}=this,i=this.viewModel?.state,s={[E.newUI]:t,[E.hidden]:"loading"===i,[E.disabled]:"disabled"===i},n=this.renderItemTooltips(),o=this.renderItems();return f("div",{class:this.classes(E.base,s)},e.length?[n,o]:this.renderNoItems())}renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?f("calcite-tooltip",{label:i.layerIncompatible,referenceElement:t.get(e.uid)},i.layerIncompatibleTooltip):null}renderItemTooltipNodes(e){const{incompatible:t,children:i}=e;return[t?this.renderItemTooltip(e):null,...!t&&i?i.toArray().map((e=>this.renderItemTooltipNodes(e))):[]]}renderItemTooltips(){return this.visibleItems.toArray().map((e=>this.renderItemTooltipNodes(e)))??[]}renderNoItems(){return f("div",{class:E.noItems},this.messages.noItemsToDisplay)}renderItems(){const{visibleItems:e,selectionEnabled:t,messages:i}=this;return f("ul",{"aria-label":i.widgetLabel,role:t?"listbox":void 0,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,afterRemoved:this._sortNodeRemoved,"data-group":N,bind:this,class:this.classes(E.list,E.listRoot,E.listIndependent)},e.map((e=>this.renderItem(e,null))).toArray())}renderActionsMenuIcon(e,t){const{messagesCommon:i}=this,s={[E.actionsMenuItemActive]:e.actionsOpen};return f("div",{key:"actions-menu-toggle","data-item":e,bind:this,onclick:this._toggleActionsOpen,onkeydown:this._toggleActionsOpen,class:this.classes(E.actionsMenuItem,s),tabindex:"0",role:"button","aria-controls":t,"aria-label":i.options,title:i.options},f("span",{"aria-hidden":"true",class:E.iconEllipses}))}renderActionsMenu(e,t,i,s){const{panel:n}=e,o=n&&n.visible?this.renderPanelButton(n):null,r=1===i&&this._getSingleActionButton(t),l=r?this.renderAction({item:e,action:r,singleAction:!0}):null,a=!r&&i?this.renderActionsMenuIcon(e,s):null;return a||o||r?f("div",{key:"actions-menu",class:E.actionsMenu},o,l,a):null}renderChildList(e,t){const{selectionEnabled:i}=this,{visibilityMode:s,children:n}=e,o=this._hasChildren(e),r=!o&&i&&"group"===e.layer?.type,{exclusive:l,inherited:a}=x,c={[E.listExclusive]:s===l,[E.listInherited]:s===a,[E.listIndependent]:s!==a&&s!==l};return o||r?f("ul",{bind:this,key:"list-items",id:t,"data-group":e.uid,"data-item":e,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,afterRemoved:this._sortNodeRemoved,class:this.classes(E.list,c),"aria-expanded":e.open?"true":"false",role:i?"listbox":s===l?"radiogroup":"group",hidden:!e.open&&!r||null},n?.map((t=>this.renderItem(t,e))).toArray()):null}renderChildrenToggle(e,t){const{messagesCommon:i}=this,s=this._hasChildren(e),n={[E.childToggleOpen]:e.open},o=e.open?i.collapse:i.expand;return s?f("span",{onclick:this._toggleChildrenClick,onkeydown:this._toggleChildrenClick,"data-item":e,key:"toggle-children",class:this.classes(E.childToggle,n),tabindex:"0",role:"button","aria-controls":t,"aria-label":o,title:o},f("span",{"aria-hidden":"true",class:this.classes(E.childClosed,E.iconRightArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childOpened,E.iconDownArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childClosed_RTL,E.iconLeftArrow)})):null}renderItemMessage(e){return e.error?f("div",{key:"esri-layer-list__error",class:E.message,role:"alert"},f("span",{"aria-hidden":"true",class:E.iconNoticeTriangle}),this.messages.layerError):e.incompatible?f("div",{key:"esri-layer-list__incompatible",class:E.message,role:"alert"},f("span",{bind:this,tabIndex:0,"aria-hidden":"true",class:E.iconNoticeTriangle,afterCreate:t=>this._setTooltipReference(t,e)}),this.messages.layerIncompatible):null}renderItemContent(e,t,i){const{id:s}=this,n=`${s}_${e.uid}`,o=`${n}_actions`,r=`${n}__list`,{panel:l}=e,a=this._filterActions(e.actionsSections),c=this._countActions(a);return[f("div",{key:"list-item-container",class:E.itemContainer},this.renderChildrenToggle(e,r),this.renderLabel(e,t,i),this.renderActionsMenu(e,a,c,o)),this.renderItemMessage(e),c?this.renderActionsSections(e,a,o):null,l&&l.open&&!l.disabled?l.render():null,this.renderChildList(e,r)]}renderItem(e,t){const{_newUI:i,id:s,selectionEnabled:n,selectedItems:o}=this,r=`${`${s}_${e.uid}`}__title`,l=this._hasMessage(e),a=this._hasChildren(e),c={[E.itemChildren]:a,[E.itemMessage]:!!l,[E.itemInvisible]:i&&!e.visible,[E.itemInvisibleAtScale]:!e.visibleAtCurrentScale,[E.itemSelectable]:n};if(n){const i={[k]:e.layer?.uid,[$]:(!e.sortable).toString()};return f("li",{key:`item-with-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,c),"aria-labelledby":r,onclick:this._toggleSelection,onkeydown:this._selectionKeydown,"data-item":e,"data-group":t?t.uid:N,tabIndex:0,"aria-selected":g(e,o)?"true":"false",role:"option",...i},this.renderItemContent(e,t,r))}return f("li",{key:`item-no-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,c),"aria-labelledby":r},this.renderItemContent(e,t,r))}renderConnectionIcon(e){const{connectionStatus:t}=e;return null!=t?f("calcite-icon",{icon:"connected"===t?"check-circle":"offline",scale:"s"}):null}renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,r=o&&!t,l=!!s;return f("span",{class:this.classes({[E.statusIndicator]:!0,[E.publishing]:n,[E.updating]:r,[E.connectionStatus]:l,[E.connectionStatusConnected]:l&&"connected"===s}),key:"layer-item-status"},this.renderConnectionIcon(e))}renderItemTitle(e,t){const{messages:i}=this;if(!e)return null;const s=e.title||i.untitledLayer,n=e.visibleAtCurrentScale?s:`${s} (${i.layerInvisibleAtScale})`;return f("span",{key:"layer-title-container",id:t,title:n,"aria-label":n,class:E.title},s)}renderItemToggleIcon(e,t){const{_newUI:i}=this,{exclusive:s}=x,n=t?.visibilityMode,o={[E.toggleVisibleIcon]:i,[E.toggleIcon]:i&&n!==s,[E.radioIcon]:i&&n===s,[E.iconRadioSelected]:n===s&&e.visible,[E.iconRadioUnselected]:n===s&&!e.visible,[E.iconVisible]:n!==s&&e.visible,[E.iconInvisible]:n!==s&&!e.visible};return f("span",{key:"item-toggle-icon",class:this.classes(o),"aria-hidden":"true"})}renderItemToggle(e,t,i){const{selectionEnabled:s,messages:n}=this,{exclusive:o}=x,r=t?.visibilityMode,l=r===o?"radio":"switch";return f("span",s?{key:"item-toggle-selection-enabled",class:E.toggleVisible,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":r,tabIndex:0,title:n.layerVisibility,"aria-checked":e.visible?"true":"false",role:l,"aria-labelledby":i}:{key:"item-toggle",class:E.toggleVisible},this.renderItemToggleIcon(e,t))}renderLabel(e,t,i){const{selectionEnabled:s,_newUI:n,messages:o}=this,{inherited:r,exclusive:l}=x,a=t?.visibilityMode,c=a===l?"radio":"switch",d=n?[this.renderItemTitle(e,i),this.renderItemStatus(e,t),this.renderItemToggle(e,t,i)]:[this.renderItemToggle(e,t,i),this.renderItemTitle(e,i),this.renderItemStatus(e,t)],h=f("div",s?{key:`item-label-no-selection-${e.uid}`,class:E.label}:{key:`item-label-with-selection-${e.uid}`,class:E.label,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":a,tabIndex:0,"aria-checked":e.visible?"true":"false",title:o.layerVisibility,role:c,"aria-labelledby":i},d);return a===r||e.error?f("div",{key:`item-label-container-${e.uid}`,class:E.label},this.renderItemTitle(e,i),this.renderItemStatus(e,t)):h}renderPanelButton(e){const{className:t,open:i,title:s,image:n,disabled:o}=e,r=n||t?t:E.iconDefaultAction,l=this._getIconImageStyles(e),a={[E.actionsMenuItemActive]:i&&!o},c={[E.actionImage]:!!l["background-image"],[E.disabledElement]:e.disabled};return r&&(c[r]=!!r),f("div",{"aria-disabled":e.disabled.toString(),key:`panel-${e.uid}`,bind:this,"data-panel":e,onclick:this._triggerPanel,onkeydown:this._triggerPanel,class:this.classes(E.actionsMenuItem,a),role:"button",tabindex:e.disabled?null:0,title:s,"aria-label":s},f("span",{class:this.classes(c),styles:l}))}renderActionsSections(e,t,i){const s=t.toArray().map(((t,i)=>f("ul",{key:`${e}-action-section-${i}`,class:E.actionsList},this.renderActionSection(e,t))));return f("div",{role:"group","aria-expanded":e.actionsOpen?"true":"false",key:"actions-section",id:i,class:E.actions,hidden:!e.actionsOpen||null},s)}renderActionSection(e,t){return(t&&t.toArray()).map((t=>this.renderAction({item:e,action:t})))}renderActionIcon(e){const{active:t,className:i}=e,s=this._getIconImageStyles(e),n="button"!==e.type||e.image||i?i:E.iconDefaultAction,o={[E.actionImage]:!t&&!!s["background-image"],[E.iconLoading]:t,[E.rotating]:t};return n&&!t&&(o[n]=!0),f("span",{key:"action-icon","aria-hidden":"true",class:this.classes(E.actionIcon,o),styles:s})}renderActionTitle(e,t){return t?null:f("span",{key:"action-title",class:E.actionTitle},e)}renderAction(e){const{item:t,action:i,singleAction:s}=e,{active:n,disabled:o,title:r}=i,l={[E.actionsMenuItem]:s&&"button"===i.type,[E.action]:n||!s&&"toggle"!==i.type,[E.actionToggle]:!n&&"toggle"===i.type,[E.actionToggleOn]:!n&&"toggle"===i.type&&i.value,[E.disabledElement]:o},a=[this.renderActionIcon(i),this.renderActionTitle(r,s)];return s?f("div",{bind:this,"data-item":t,"data-action":i,role:"button",key:`single-action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",title:r??void 0,"aria-label":r??void 0},a):f("li",{bind:this,"data-item":t,"data-action":i,key:`action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",role:"button",title:r??void 0,"aria-label":r??void 0},a)}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.uid,e),this.scheduleRender()}_hasMessage(e){return!!e.error||e.incompatible}_hasChildren(e){return!!e.children.length&&!this._hasMessage(e)}_sortNodeRemoved(e){const{_sortableMap:t}=this,i=e.dataset.group,s=t.get(i);s&&s.destroy(),t.delete(i)}_destroySortables(){const{_sortableMap:e,_sortableNodes:t}=this;e.forEach((e=>e&&e.destroy())),e.clear(),t.clear()}_moveLayerFromChildList({to:e,from:t,item:i,newIndex:s}){const n=V(i),o=V(e),r=V(t);this.viewModel.moveListItem(n,r,o,s)}_sortLayers(e){if(!e)return;const t=V(e.el),i=e.toArray();t?p(t,i):m(this.view?.map?.layers,i)}_toggleSorting(e,t){const{_sortableMap:i,selectionEnabled:s}=this,n=i.get(t),o=V(e),r=(t===N||o?.childrenSortable&&b(o))&&s;if(n)n.option("disabled",!r);else if(r){const s=C.create(e,{dataIdAttr:k,group:{name:t,pull:this._sortableCanPull,put:this._sortableCanPut},filter:`[${$}="true"]`,fallbackTolerance:4,onSort:this._onSortableSort,onEnd:this._onSortableEnd,disabled:!r,chosenClass:E.sortableChosen});i.set(t,s)}}_toggleAllSorting(){this._sortableNodes.forEach(((e,t)=>this._toggleSorting(e,t)))}_sortNodeCreated(e){const t=e.dataset.group;t&&(this._sortableNodes.set(t,e),this._toggleSorting(e,t))}_setVisibleItems(e){this.visibleItems=e.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_focusListItem(e){const{_focusSortUid:t}=this;if(!e||!t)return;const i=V(e);i?.layer?.uid===t&&(e.focus(),this._focusSortUid=null)}_watchActionSectionChanges(e){this.addHandles(e.on("change",this.scheduleRender.bind(this)),R.actionSection),e.forEach((e=>this._renderOnActionChanges(e)))}_renderOnActionChanges(e){"toggle"!==e.type?"slider"!==e.type?this.addHandles(n((()=>[e?.className,e?.image,e?.id,e?.title,e?.visible]),(()=>this.scheduleRender()),o),R.actions):this.addHandles(n((()=>[e?.className,e?.id,e?.title,e?.visible,e?.value,e?.displayValueEnabled,e?.max,e?.min,e?.step]),(()=>this.scheduleRender()),o),R.actions):this.addHandles(n((()=>[e?.className,e?.image,e?.id,e?.title,e?.visible,e?.value]),(()=>this.scheduleRender()),o),R.actions)}_renderOnItemChanges(e){this.addHandles([n((()=>[e?.actionsOpen,e?.visible,e?.open,e?.updating,e?.connectionStatus,e?.publishing,e?.title,e?.visibleAtCurrentScale,e?.error,e?.visibilityMode,e?.panel,e?.panel?.title,e?.panel?.content,e?.panel?.className,e?.sortable,e?.childrenSortable]),(()=>this.scheduleRender()),r),n((()=>[e?.hidden,e?.error]),(()=>this._setVisibleItems(this.operationalItems))),e.actionsSections.on("change",(()=>this.scheduleRender())),e.children.on("change",(()=>this.scheduleRender()))],R.items),e.children.forEach((e=>this._renderOnItemChanges(e))),e.actionsSections.forEach((e=>this._watchActionSectionChanges(e)))}_itemsChanged(e){this.removeHandles(R.items),this.removeHandles(R.actions),this.removeHandles(R.actionSection),e.forEach((e=>this._renderOnItemChanges(e))),this._tooltipReferenceMap.clear(),this._setVisibleItems(e),this.scheduleRender()}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_getIconImageStyles(e){const t="esri.widgets.LayerList.ListItemPanel"===e.declaredClass||"esri.support.Action.ActionButton"===e.declaredClass||"esri.support.Action.ActionToggle"===e.declaredClass?e.image:null;return{"background-image":t?`url("${t}")`:void 0}}_selectionKeydown(e){const t=["ArrowDown","ArrowUp"],s=i(e);if(!t.includes(s))return void this._toggleSelection(e);e.stopPropagation();const n=e.currentTarget,o=V(n),{_sortableMap:r,selectedItems:l}=this,a=n.dataset.group,c=r.get(a);if(!c||!o)return;const d=g(o,l),h=c.toArray(),u=e.target,m=h.indexOf(u.dataset[M]);if(-1!==m){if("ArrowDown"===s){const e=m+1;if(e>=h.length)return;d?(w(h,m,e),c.sort(h),this._sortLayers(c),this._focusSortUid=o.layer?.uid):(this._focusSortUid=o.layer?.uid,this.scheduleRender())}if("ArrowUp"===s){const e=m-1;if(e<=-1)return;d?(w(h,m,e),c.sort(h),this._sortLayers(c),this._focusSortUid=o.layer?.uid):(this._focusSortUid=o.layer?.uid,this.scheduleRender())}}}_toggleActionsOpen(e){const t=V(e.currentTarget);if(!t)return;const{actionsOpen:i}=t,s=!i;s&&this.operationalItems.forEach((e=>U(e))),t.actionsOpen=s,e.stopPropagation()}_triggerPanel(e){const t=P(e.currentTarget);e.stopPropagation(),t&&!t.disabled&&(t.open=!t.open)}_triggerAction(e){const t=e.currentTarget,i=F(t),s=V(t);i&&s&&("toggle"===i.type&&(i.value=!i.value),this.triggerAction(i,s),e.stopPropagation())}_toggleVisibility(e){const t=e.currentTarget,i=t.getAttribute("data-parent-visibility"),s=V(t);s&&(i===x.exclusive&&s.visible||(s.visible=!s.visible),e.stopPropagation())}_toggleChildrenClick(e){const t=V(e.currentTarget);t&&(t.open=!t.open,e.stopPropagation())}_toggleSelection(e){e.stopPropagation();const{multipleSelectionEnabled:t,selectedItems:i}=this,s=V(e.currentTarget);if(!s)return;const n=g(s,i),{length:o}=i;if(!t)return o&&!(n&&1===o)?(i.removeAll(),void i.add(s)):void(n?i.remove?.(n):i.add(s));n?i.remove?.(n):i.add(s)}get test(){return{visibleItems:this.visibleItems}}};function V(e){return e?.["data-item"]}function P(e){return e?.["data-panel"]}function F(e){return e?.["data-action"]}e([l()],j.prototype,"visibleItems",void 0),e([l()],j.prototype,"iconClass",void 0),e([l()],j.prototype,"icon",void 0),e([l()],j.prototype,"label",null),e([l()],j.prototype,"listItemCanGiveFunction",void 0),e([l()],j.prototype,"listItemCanReceiveFunction",void 0),e([l()],j.prototype,"listItemCreatedFunction",null),e([l(),I("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([l(),I("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([l()],j.prototype,"multipleSelectionEnabled",void 0),e([l()],j.prototype,"operationalItems",null),e([l()],j.prototype,"selectionEnabled",void 0),e([l()],j.prototype,"selectedItems",void 0),e([l()],j.prototype,"view",null),e([v("trigger-action"),l({type:h})],j.prototype,"viewModel",void 0),e([l()],j.prototype,"visibleElements",void 0),e([a("visibleElements")],j.prototype,"castVisibleElements",null),e([y()],j.prototype,"_toggleActionsOpen",null),e([y()],j.prototype,"_triggerPanel",null),e([y()],j.prototype,"_triggerAction",null),e([y()],j.prototype,"_toggleVisibility",null),e([y()],j.prototype,"_toggleChildrenClick",null),e([y()],j.prototype,"_toggleSelection",null),j=e([c("esri.widgets.LayerList")],j);const H=j;export{H as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import has from"../core/has.js";import{on as s,watch as n,initial as o,syncAndInitial as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{cast as a}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import h from"./LayerList/LayerListViewModel.js";import u from"./LayerList/ListItem.js";import{findSelectedItem as g,sortLayersToIds as m,sortChildLayersToIds as p,canSortSublayers as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{accessibleHandler as y}from"./support/decorators/accessibleHandler.js";import{messageBundle as I}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import C from"sortablejs";function w(e,t,i){e.splice(i,0,e.splice(t,1)[0])}const A="esri-layerlist-new-ui",S=t.ofType(u),$="data-sort-filter",k="data-layer-uid",M="layerUid",T="esri-layer-list",L=`${T}__item`,E={base:`${T} esri-widget esri-widget--panel`,newUI:`${T}--new-ui`,noItems:`${T}__no-items`,list:`${T}__list`,listRoot:`${T}__list--root`,listExclusive:`${T}__list--exclusive`,listInherited:`${T}__list--inherited`,listIndependent:`${T}__list--independent`,item:L,itemContent:`${L}-content`,itemMessage:`${L}--has-message`,itemInvisible:`${L}--invisible`,itemInvisibleAtScale:`${L}--invisible-at-scale`,itemChildren:`${L}--has-children`,itemSelectable:`${L}--selectable`,itemContainer:`${L}-container`,actionsMenu:`${L}-actions-menu`,actionsMenuItem:`${L}-actions-menu-item`,actionsMenuItemActive:`${L}-actions-menu-item--active`,actions:`${L}-actions`,actionsList:`${L}-actions-list`,action:`${L}-action`,actionIcon:`${L}-action-icon`,actionImage:`${L}-action-image`,actionTitle:`${L}-action-title`,actionToggle:`${T}__action-toggle`,actionToggleOn:`${T}__action-toggle--on`,label:`${L}-label`,message:`${L}-message`,title:`${L}-title`,statusIndicator:`${T}__status-indicator`,publishing:`${T}__publishing`,updating:`${T}__updating`,connectionStatus:`${T}__connection-status`,connectionStatusConnected:`${T}__connection-status--connected`,toggleVisible:`${L}-toggle`,toggleVisibleIcon:`${L}-toggle-icon`,toggleIcon:`${L}-toggle-icon`,radioIcon:`${L}-radio-icon`,childToggle:`${T}__child-toggle`,childToggleOpen:`${T}__child-toggle--open`,childOpened:`${T}__child-toggle-icon--opened`,childClosed:`${T}__child-toggle-icon--closed`,childClosed_RTL:`${T}__child-toggle-icon--closed-rtl`,sortableChosen:`${T}--chosen`,disabled:"esri-disabled",disabledElement:"esri-disabled-element",hidden:"esri-hidden",rotating:"esri-rotating",iconEllipses:"esri-icon-handle-horizontal",iconVisible:"esri-icon-visible",iconInvisible:"esri-icon-non-visible",iconRadioSelected:"esri-icon-radio-checked",iconRadioUnselected:"esri-icon-radio-unchecked",iconNoticeTriangle:"esri-icon-notice-triangle",iconChildrenOpen:"esri-icon-down-arrow",iconDownArrow:"esri-icon-down-arrow",iconRightArrow:"esri-icon-right-triangle-arrow",iconLeftArrow:"esri-icon-left-triangle-arrow",iconLoading:"esri-icon-loading-indicator",iconDefaultAction:"esri-icon-default-action",widgetIcon:"esri-icon-layers"},R={actions:"actions",actionSection:"action-section",items:"items"},x={exclusive:"exclusive",inherited:"inherited",independent:"independent"};function U(e){const{actionsOpen:t,children:i}=e;t&&(e.actionsOpen=!1),i.forEach((e=>U(e)))}const N="root",O={statusIndicators:!0,errors:!1};let j=class extends d{constructor(e,t){super(e,t),this._sortableNodes=new Map,this._sortableMap=new Map,this._focusSortUid=null,this._newUI=has(A),this._tooltipReferenceMap=new Map,this.visibleItems=null,this.iconClass=E.widgetIcon,this.icon=null,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.multipleSelectionEnabled=!1,this.selectionEnabled=!1,this.selectedItems=new S,this.viewModel=new h,this.visibleElements={...O},this._onSortableSort=({to:e,from:t,item:i,newIndex:s})=>{t&&e&&(t===e?this._sortLayers(this._sortableMap.get(t.dataset.group)):this._moveLayerFromChildList({to:e,from:t,item:i,newIndex:s}))},this._sortableCanSort=(e,t)=>!(!e.el.dataset.group||!t.el.dataset.group),this._sortableCanPull=(e,t,i)=>{const{listItemCanGiveFunction:s}=this,n={selected:V(i),from:V(t.el),to:V(e.el)};return!this._sortableCanSort(e,t)||"function"!=typeof s||s.call(null,n)},this._sortableCanPut=(e,t,i)=>{const{listItemCanReceiveFunction:s}=this,n={selected:V(i),from:V(t.el),to:V(e.el)};return!this._sortableCanSort(e,t)||"function"!=typeof s||s.call(null,n)},this._onSortableEnd=({oldIndex:e,from:t,to:i,item:s})=>{t!==i&&t.insertBefore(s,t.children[e])}}initialize(){const e=this.operationalItems;this._setVisibleItems(e),this.addHandles([s((()=>this.operationalItems),"change",(()=>this._itemsChanged(e))),n((()=>this.visibleElements),(()=>this._itemsChanged(e))),n((()=>this.selectionEnabled),(()=>this._toggleAllSorting()),o)])}loadDependencies(){return _({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this.removeAllHandles(),this._destroySortables(),this._tooltipReferenceMap.clear()}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...O,...e}}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{visibleItems:e,_newUI:t}=this,i=this.viewModel?.state,s={[E.newUI]:t,[E.hidden]:"loading"===i,[E.disabled]:"disabled"===i},n=this.renderItemTooltips(),o=this.renderItems();return f("div",{class:this.classes(E.base,s)},e.length?[n,o]:this.renderNoItems())}renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?f("calcite-tooltip",{label:i.layerIncompatible,referenceElement:t.get(e.uid)},i.layerIncompatibleTooltip):null}renderItemTooltipNodes(e){const{incompatible:t,children:i}=e;return[t?this.renderItemTooltip(e):null,...!t&&i?i.toArray().map((e=>this.renderItemTooltipNodes(e))):[]]}renderItemTooltips(){return this.visibleItems.toArray().map((e=>this.renderItemTooltipNodes(e)))??[]}renderNoItems(){return f("div",{class:E.noItems},this.messages.noItemsToDisplay)}renderItems(){const{visibleItems:e,selectionEnabled:t,messages:i}=this;return f("ul",{"aria-label":i.widgetLabel,role:t?"listbox":void 0,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,afterRemoved:this._sortNodeRemoved,"data-group":N,bind:this,class:this.classes(E.list,E.listRoot,E.listIndependent)},e.map((e=>this.renderItem(e,null))).toArray())}renderActionsMenuIcon(e,t){const{messagesCommon:i}=this,s={[E.actionsMenuItemActive]:e.actionsOpen};return f("div",{key:"actions-menu-toggle","data-item":e,bind:this,onclick:this._toggleActionsOpen,onkeydown:this._toggleActionsOpen,class:this.classes(E.actionsMenuItem,s),tabindex:"0",role:"button","aria-controls":t,"aria-label":i.options,title:i.options},f("span",{"aria-hidden":"true",class:E.iconEllipses}))}renderActionsMenu(e,t,i,s){const{panel:n}=e,o=n&&n.visible?this.renderPanelButton(n):null,r=1===i&&this._getSingleActionButton(t),l=r?this.renderAction({item:e,action:r,singleAction:!0}):null,a=!r&&i?this.renderActionsMenuIcon(e,s):null;return a||o||r?f("div",{key:"actions-menu",class:E.actionsMenu},o,l,a):null}renderChildList(e,t){const{selectionEnabled:i}=this,{visibilityMode:s,children:n}=e,o=this._hasChildren(e),r=!o&&i&&"group"===e.layer?.type,{exclusive:l,inherited:a}=x,c={[E.listExclusive]:s===l,[E.listInherited]:s===a,[E.listIndependent]:s!==a&&s!==l};return o||r?f("ul",{bind:this,key:"list-items",id:t,"data-group":e.uid,"data-item":e,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,afterRemoved:this._sortNodeRemoved,class:this.classes(E.list,c),"aria-expanded":e.open?"true":"false",role:i?"listbox":s===l?"radiogroup":"group",hidden:!e.open&&!r||null},n?.map((t=>this.renderItem(t,e))).toArray()):null}renderChildrenToggle(e,t){const{messagesCommon:i}=this,s=this._hasChildren(e),n={[E.childToggleOpen]:e.open},o=e.open?i.collapse:i.expand;return s?f("span",{onclick:this._toggleChildrenClick,onkeydown:this._toggleChildrenClick,"data-item":e,key:"toggle-children",class:this.classes(E.childToggle,n),tabindex:"0",role:"button","aria-controls":t,"aria-label":o,title:o},f("span",{"aria-hidden":"true",class:this.classes(E.childClosed,E.iconRightArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childOpened,E.iconDownArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childClosed_RTL,E.iconLeftArrow)})):null}renderItemMessage(e){return e.error?f("div",{key:"esri-layer-list__error",class:E.message,role:"alert"},f("span",{"aria-hidden":"true",class:E.iconNoticeTriangle}),this.messages.layerError):e.incompatible?f("div",{key:"esri-layer-list__incompatible",class:E.message,role:"alert"},f("span",{bind:this,tabIndex:0,"aria-hidden":"true",class:E.iconNoticeTriangle,afterCreate:t=>this._setTooltipReference(t,e)}),this.messages.layerIncompatible):null}renderItemContent(e,t,i){const{id:s}=this,n=`${s}_${e.uid}`,o=`${n}_actions`,r=`${n}__list`,{panel:l}=e,a=this._filterActions(e.actionsSections),c=this._countActions(a);return[f("div",{key:"list-item-container",class:E.itemContainer},this.renderChildrenToggle(e,r),this.renderLabel(e,t,i),this.renderActionsMenu(e,a,c,o)),this.renderItemMessage(e),c?this.renderActionsSections(e,a,o):null,l&&l.open&&!l.disabled?l.render():null,this.renderChildList(e,r)]}renderItem(e,t){const{_newUI:i,id:s,selectionEnabled:n,selectedItems:o}=this,r=`${`${s}_${e.uid}`}__title`,l=this._hasMessage(e),a=this._hasChildren(e),c={[E.itemChildren]:a,[E.itemMessage]:!!l,[E.itemInvisible]:i&&!e.visible,[E.itemInvisibleAtScale]:!e.visibleAtCurrentScale,[E.itemSelectable]:n};if(n){const i={[k]:e.layer?.uid,[$]:(!e.sortable).toString()};return f("li",{key:`item-with-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,c),"aria-labelledby":r,onclick:this._toggleSelection,onkeydown:this._selectionKeydown,"data-item":e,"data-group":t?t.uid:N,tabIndex:0,"aria-selected":g(e,o)?"true":"false",role:"option",...i},this.renderItemContent(e,t,r))}return f("li",{key:`item-no-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,c),"aria-labelledby":r},this.renderItemContent(e,t,r))}renderConnectionIcon(e){const{connectionStatus:t}=e;return null!=t?f("calcite-icon",{icon:"connected"===t?"beacon":"offline",scale:"s"}):null}renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,r=o&&!t,l=!!s;return f("span",{class:this.classes({[E.statusIndicator]:!0,[E.publishing]:n,[E.updating]:r,[E.connectionStatus]:l,[E.connectionStatusConnected]:l&&"connected"===s}),key:"layer-item-status"},this.renderConnectionIcon(e))}renderItemTitle(e,t){const{messages:i}=this;if(!e)return null;const s=e.title||i.untitledLayer,n=e.visibleAtCurrentScale?s:`${s} (${i.layerInvisibleAtScale})`;return f("span",{key:"layer-title-container",id:t,title:n,"aria-label":n,class:E.title},s)}renderItemToggleIcon(e,t){const{_newUI:i}=this,{exclusive:s}=x,n=t?.visibilityMode,o={[E.toggleVisibleIcon]:i,[E.toggleIcon]:i&&n!==s,[E.radioIcon]:i&&n===s,[E.iconRadioSelected]:n===s&&e.visible,[E.iconRadioUnselected]:n===s&&!e.visible,[E.iconVisible]:n!==s&&e.visible,[E.iconInvisible]:n!==s&&!e.visible};return f("span",{key:"item-toggle-icon",class:this.classes(o),"aria-hidden":"true"})}renderItemToggle(e,t,i){const{selectionEnabled:s,messages:n}=this,{exclusive:o}=x,r=t?.visibilityMode,l=r===o?"radio":"switch";return f("span",s?{key:"item-toggle-selection-enabled",class:E.toggleVisible,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":r,tabIndex:0,title:n.layerVisibility,"aria-checked":e.visible?"true":"false",role:l,"aria-labelledby":i}:{key:"item-toggle",class:E.toggleVisible},this.renderItemToggleIcon(e,t))}renderLabel(e,t,i){const{selectionEnabled:s,_newUI:n,messages:o}=this,{inherited:r,exclusive:l}=x,a=t?.visibilityMode,c=a===l?"radio":"switch",d=n?[this.renderItemTitle(e,i),this.renderItemStatus(e,t),this.renderItemToggle(e,t,i)]:[this.renderItemToggle(e,t,i),this.renderItemTitle(e,i),this.renderItemStatus(e,t)],h=f("div",s?{key:`item-label-no-selection-${e.uid}`,class:E.label}:{key:`item-label-with-selection-${e.uid}`,class:E.label,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":a,tabIndex:0,"aria-checked":e.visible?"true":"false",title:o.layerVisibility,role:c,"aria-labelledby":i},d);return a===r||e.error?f("div",{key:`item-label-container-${e.uid}`,class:E.label},this.renderItemTitle(e,i),this.renderItemStatus(e,t)):h}renderPanelButton(e){const{className:t,open:i,title:s,image:n,disabled:o}=e,r=n||t?t:E.iconDefaultAction,l=this._getIconImageStyles(e),a={[E.actionsMenuItemActive]:i&&!o},c={[E.actionImage]:!!l["background-image"],[E.disabledElement]:e.disabled};return r&&(c[r]=!!r),f("div",{"aria-disabled":e.disabled.toString(),key:`panel-${e.uid}`,bind:this,"data-panel":e,onclick:this._triggerPanel,onkeydown:this._triggerPanel,class:this.classes(E.actionsMenuItem,a),role:"button",tabindex:e.disabled?null:0,title:s,"aria-label":s},f("span",{class:this.classes(c),styles:l}))}renderActionsSections(e,t,i){const s=t.toArray().map(((t,i)=>f("ul",{key:`${e}-action-section-${i}`,class:E.actionsList},this.renderActionSection(e,t))));return f("div",{role:"group","aria-expanded":e.actionsOpen?"true":"false",key:"actions-section",id:i,class:E.actions,hidden:!e.actionsOpen||null},s)}renderActionSection(e,t){return(t&&t.toArray()).map((t=>this.renderAction({item:e,action:t})))}renderActionIcon(e){const{active:t,className:i}=e,s=this._getIconImageStyles(e),n="button"!==e.type||e.image||i?i:E.iconDefaultAction,o={[E.actionImage]:!t&&!!s["background-image"],[E.iconLoading]:t,[E.rotating]:t};return n&&!t&&(o[n]=!0),f("span",{key:"action-icon","aria-hidden":"true",class:this.classes(E.actionIcon,o),styles:s})}renderActionTitle(e,t){return t?null:f("span",{key:"action-title",class:E.actionTitle},e)}renderAction(e){const{item:t,action:i,singleAction:s}=e,{active:n,disabled:o,title:r}=i,l={[E.actionsMenuItem]:s&&"button"===i.type,[E.action]:n||!s&&"toggle"!==i.type,[E.actionToggle]:!n&&"toggle"===i.type,[E.actionToggleOn]:!n&&"toggle"===i.type&&i.value,[E.disabledElement]:o},a=[this.renderActionIcon(i),this.renderActionTitle(r,s)];return s?f("div",{bind:this,"data-item":t,"data-action":i,role:"button",key:`single-action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",title:r??void 0,"aria-label":r??void 0},a):f("li",{bind:this,"data-item":t,"data-action":i,key:`action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",role:"button",title:r??void 0,"aria-label":r??void 0},a)}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.uid,e),this.scheduleRender()}_hasMessage(e){return!!e.error||e.incompatible}_hasChildren(e){return!!e.children.length&&!this._hasMessage(e)}_sortNodeRemoved(e){const{_sortableMap:t}=this,i=e.dataset.group,s=t.get(i);s&&s.destroy(),t.delete(i)}_destroySortables(){const{_sortableMap:e,_sortableNodes:t}=this;e.forEach((e=>e&&e.destroy())),e.clear(),t.clear()}_moveLayerFromChildList({to:e,from:t,item:i,newIndex:s}){const n=V(i),o=V(e),r=V(t);this.viewModel.moveListItem(n,r,o,s)}_sortLayers(e){if(!e)return;const t=V(e.el),i=e.toArray();t?p(t,i):m(this.view?.map?.layers,i)}_toggleSorting(e,t){const{_sortableMap:i,selectionEnabled:s}=this,n=i.get(t),o=V(e),r=(t===N||o?.childrenSortable&&b(o))&&s;if(n)n.option("disabled",!r);else if(r){const s=C.create(e,{dataIdAttr:k,group:{name:t,pull:this._sortableCanPull,put:this._sortableCanPut},filter:`[${$}="true"]`,fallbackTolerance:4,onSort:this._onSortableSort,onEnd:this._onSortableEnd,disabled:!r,chosenClass:E.sortableChosen});i.set(t,s)}}_toggleAllSorting(){this._sortableNodes.forEach(((e,t)=>this._toggleSorting(e,t)))}_sortNodeCreated(e){const t=e.dataset.group;t&&(this._sortableNodes.set(t,e),this._toggleSorting(e,t))}_setVisibleItems(e){this.visibleItems=e.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_focusListItem(e){const{_focusSortUid:t}=this;if(!e||!t)return;const i=V(e);i?.layer?.uid===t&&(e.focus(),this._focusSortUid=null)}_watchActionSectionChanges(e){this.addHandles(e.on("change",this.scheduleRender.bind(this)),R.actionSection),e.forEach((e=>this._renderOnActionChanges(e)))}_renderOnActionChanges(e){"toggle"!==e.type?"slider"!==e.type?this.addHandles(n((()=>[e?.className,e?.image,e?.id,e?.title,e?.visible]),(()=>this.scheduleRender()),o),R.actions):this.addHandles(n((()=>[e?.className,e?.id,e?.title,e?.visible,e?.value,e?.displayValueEnabled,e?.max,e?.min,e?.step]),(()=>this.scheduleRender()),o),R.actions):this.addHandles(n((()=>[e?.className,e?.image,e?.id,e?.title,e?.visible,e?.value]),(()=>this.scheduleRender()),o),R.actions)}_renderOnItemChanges(e){this.addHandles([n((()=>[e?.actionsOpen,e?.visible,e?.open,e?.updating,e?.connectionStatus,e?.publishing,e?.title,e?.visibleAtCurrentScale,e?.error,e?.visibilityMode,e?.panel,e?.panel?.title,e?.panel?.content,e?.panel?.className,e?.sortable,e?.childrenSortable]),(()=>this.scheduleRender()),r),n((()=>[e?.hidden,e?.error]),(()=>this._setVisibleItems(this.operationalItems))),e.actionsSections.on("change",(()=>this.scheduleRender())),e.children.on("change",(()=>this.scheduleRender()))],R.items),e.children.forEach((e=>this._renderOnItemChanges(e))),e.actionsSections.forEach((e=>this._watchActionSectionChanges(e)))}_itemsChanged(e){this.removeHandles(R.items),this.removeHandles(R.actions),this.removeHandles(R.actionSection),e.forEach((e=>this._renderOnItemChanges(e))),this._tooltipReferenceMap.clear(),this._setVisibleItems(e),this.scheduleRender()}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_getIconImageStyles(e){const t="esri.widgets.LayerList.ListItemPanel"===e.declaredClass||"esri.support.Action.ActionButton"===e.declaredClass||"esri.support.Action.ActionToggle"===e.declaredClass?e.image:null;return{"background-image":t?`url("${t}")`:void 0}}_selectionKeydown(e){const t=["ArrowDown","ArrowUp"],s=i(e);if(!t.includes(s))return void this._toggleSelection(e);e.stopPropagation();const n=e.currentTarget,o=V(n),{_sortableMap:r,selectedItems:l}=this,a=n.dataset.group,c=r.get(a);if(!c||!o)return;const d=g(o,l),h=c.toArray(),u=e.target,m=h.indexOf(u.dataset[M]);if(-1!==m){if("ArrowDown"===s){const e=m+1;if(e>=h.length)return;d?(w(h,m,e),c.sort(h),this._sortLayers(c),this._focusSortUid=o.layer?.uid):(this._focusSortUid=o.layer?.uid,this.scheduleRender())}if("ArrowUp"===s){const e=m-1;if(e<=-1)return;d?(w(h,m,e),c.sort(h),this._sortLayers(c),this._focusSortUid=o.layer?.uid):(this._focusSortUid=o.layer?.uid,this.scheduleRender())}}}_toggleActionsOpen(e){const t=V(e.currentTarget);if(!t)return;const{actionsOpen:i}=t,s=!i;s&&this.operationalItems.forEach((e=>U(e))),t.actionsOpen=s,e.stopPropagation()}_triggerPanel(e){const t=P(e.currentTarget);e.stopPropagation(),t&&!t.disabled&&(t.open=!t.open)}_triggerAction(e){const t=e.currentTarget,i=F(t),s=V(t);i&&s&&("toggle"===i.type&&(i.value=!i.value),this.triggerAction(i,s),e.stopPropagation())}_toggleVisibility(e){const t=e.currentTarget,i=t.getAttribute("data-parent-visibility"),s=V(t);s&&(i===x.exclusive&&s.visible||(s.visible=!s.visible),e.stopPropagation())}_toggleChildrenClick(e){const t=V(e.currentTarget);t&&(t.open=!t.open,e.stopPropagation())}_toggleSelection(e){e.stopPropagation();const{multipleSelectionEnabled:t,selectedItems:i}=this,s=V(e.currentTarget);if(!s)return;const n=g(s,i),{length:o}=i;if(!t)return o&&!(n&&1===o)?(i.removeAll(),void i.add(s)):void(n?i.remove?.(n):i.add(s));n?i.remove?.(n):i.add(s)}get test(){return{visibleItems:this.visibleItems}}};function V(e){return e?.["data-item"]}function P(e){return e?.["data-panel"]}function F(e){return e?.["data-action"]}e([l()],j.prototype,"visibleItems",void 0),e([l()],j.prototype,"iconClass",void 0),e([l()],j.prototype,"icon",void 0),e([l()],j.prototype,"label",null),e([l()],j.prototype,"listItemCanGiveFunction",void 0),e([l()],j.prototype,"listItemCanReceiveFunction",void 0),e([l()],j.prototype,"listItemCreatedFunction",null),e([l(),I("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([l(),I("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([l()],j.prototype,"multipleSelectionEnabled",void 0),e([l()],j.prototype,"operationalItems",null),e([l()],j.prototype,"selectionEnabled",void 0),e([l()],j.prototype,"selectedItems",void 0),e([l()],j.prototype,"view",null),e([v("trigger-action"),l({type:h})],j.prototype,"viewModel",void 0),e([l()],j.prototype,"visibleElements",void 0),e([a("visibleElements")],j.prototype,"castVisibleElements",null),e([y()],j.prototype,"_toggleActionsOpen",null),e([y()],j.prototype,"_triggerPanel",null),e([y()],j.prototype,"_triggerAction",null),e([y()],j.prototype,"_toggleVisibility",null),e([y()],j.prototype,"_toggleChildrenClick",null),e([y()],j.prototype,"_toggleSelection",null),j=e([c("esri.widgets.LayerList")],j);const H=j;export{H as default};
|
package/widgets/Locate.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../core/deprecate.js";import t from"../core/Logger.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./Locate/LocateViewModel.js";import{accessibleHandler as n}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{vmEvent as d}from"./support/decorators/vmEvent.js";import{tsx as c}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const p={base:"esri-locate esri-widget--button esri-widget",text:"esri-icon-font-fallback-text",icon:"esri-icon",locate:"esri-icon-locate",loading:"esri-icon-loading-indicator",rotating:"esri-rotating",widgetIcon:"esri-icon-north-navigation",disabled:"esri-disabled",hidden:"esri-hidden"},g="esri.widgets.Locate",u=t.getLogger(g);let h=class extends r{constructor(e,o){super(e,o),this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.viewModel=new a}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get rotationEnabled(){return this.viewModel.rotationEnabled}set rotationEnabled(e){this.viewModel.rotationEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get useHeadingEnabled(){return o(u,"useHeadingEnabled",{replacement:"rotationEnabled",version:"4.27",warnOnce:!0}),this.viewModel.rotationEnabled}set useHeadingEnabled(e){o(u,"useHeadingEnabled",{replacement:"rotationEnabled",version:"4.27",warnOnce:!0}),this.viewModel.rotationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}cancelLocate(){this.viewModel.cancelLocate()}locate(){return this.viewModel.locate()}render(){const
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../core/deprecate.js";import t from"../core/Logger.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./Locate/LocateViewModel.js";import{accessibleHandler as n}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{vmEvent as d}from"./support/decorators/vmEvent.js";import{tsx as c}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const p={base:"esri-locate esri-widget--button esri-widget",text:"esri-icon-font-fallback-text",icon:"esri-icon",locate:"esri-icon-locate",loading:"esri-icon-loading-indicator",rotating:"esri-rotating",widgetIcon:"esri-icon-north-navigation",disabled:"esri-disabled",hidden:"esri-hidden"},g="esri.widgets.Locate",u=t.getLogger(g);let h=class extends r{constructor(e,o){super(e,o),this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.viewModel=new a}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get rotationEnabled(){return this.viewModel.rotationEnabled}set rotationEnabled(e){this.viewModel.rotationEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get useHeadingEnabled(){return o(u,"useHeadingEnabled",{replacement:"rotationEnabled",version:"4.27",warnOnce:!0}),this.viewModel.rotationEnabled}set useHeadingEnabled(e){o(u,"useHeadingEnabled",{replacement:"rotationEnabled",version:"4.27",warnOnce:!0}),this.viewModel.rotationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}cancelLocate(){this.viewModel.cancelLocate()}locate(){return this.viewModel.locate()}render(){const{state:e}=this.viewModel,o="locating"===e,t={[p.disabled]:"disabled"===e,[p.hidden]:"feature-unsupported"===e},i={[p.loading]:o,[p.rotating]:o,[p.locate]:!o},s="locating"===e?this.messagesCommon.cancel:this.messages.title;return c("div",{bind:this,class:this.classes(p.base,t),hidden:"feature-unsupported"===e,onclick:this._locate,onkeydown:this._locate,role:"button",tabIndex:0,"aria-label":s,title:s},c("span",{"aria-hidden":"true",class:this.classes(p.icon,i)}),c("span",{class:p.text},this.messages.title))}_locate(){const{viewModel:e}=this;"locating"===e.state?e.cancelLocate():e.locate()}};e([i()],h.prototype,"geolocationOptions",null),e([i()],h.prototype,"goToLocationEnabled",null),e([i()],h.prototype,"goToOverride",null),e([i()],h.prototype,"graphic",null),e([i()],h.prototype,"iconClass",void 0),e([i()],h.prototype,"icon",void 0),e([i()],h.prototype,"label",null),e([i(),l("esri/widgets/Locate/t9n/Locate")],h.prototype,"messages",void 0),e([i(),l("esri/t9n/common")],h.prototype,"messagesCommon",void 0),e([i()],h.prototype,"popupEnabled",null),e([i()],h.prototype,"rotationEnabled",null),e([i()],h.prototype,"scale",null),e([i()],h.prototype,"useHeadingEnabled",null),e([i()],h.prototype,"view",null),e([i({type:a}),d(["locate","locate-error"])],h.prototype,"viewModel",void 0),e([n()],h.prototype,"_locate",null),h=e([s(g)],h);const m=h;export{m 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function F(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function T(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._traceResults=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{const t=this.view?.popup;t&&(t.autoOpenEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this._traceResults.length>0&&this._traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this._traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this._traceResults];i.splice(t,0,s),this._traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this._traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this._traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this._traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view)return;let r=[];if(r="convexhull"===this.resultAreaProperties?.type?this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0),r&&r?.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this._traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this._traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&F(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(T(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&this._defaultDisplayField(s,r))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&this._defaultDisplayField(s,r))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&this._defaultDisplayField(r,t);else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&this._defaultDisplayField(r,t)}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"_traceResults",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function F(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function T(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._traceResults=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{const t=this.view?.popup;t&&(t.autoOpenEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this._traceResults.length>0&&this._traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this._traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this._traceResults];i.splice(t,0,s),this._traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this._traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this._traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this._traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view)return;let r=[];if(r="convexhull"===this.resultAreaProperties?.type?this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0),r&&r?.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this._traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this._traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&F(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(T(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t));else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t))}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"_traceResults",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../intl.js";import e from"../../core/Accessor.js";import i from"../../core/Collection.js";import r from"../../core/Error.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{watch as s,on as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Extent.js";import c from"../../rest/networks/support/ValidateNetworkTopologyParameters.js";import{isFeatureLayer as y}from"../Feature/support/featureUtils.js";import{onLocaleChange as p}from"../../intl/locale.js";import{fetchMessageBundle as m}from"../../intl/messages.js";const h={noDirtyAreasInExtent:-2147208940,noUtilityNetworkExtension:-2147208474,cannotAcquireVersionLock_v10:-2147217146,cannotAcquireVersionLock_v11:-2147220947};let u=class extends(o(e)){constructor(t){super(t),this._activeOperationDidSucceed=!1,this._dirtyAreasLayer=null,this.executionError="",this.extentToValidate="current",this.loadErrors=new i}initialize(){const t=async()=>{this.messages||(this.messages=await m("esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology"))};t().then((()=>{this.utilityNetwork||this.loadErrors.push(this.messages.info.noUtilityNetwork),this.addHandles([s((()=>this.utilityNetwork),(async t=>{t&&"utility"===t.type?(t.loaded||await t.load(),this._onUtilityNetworkLoad()):this.loadErrors.push(this.messages.info.noUtilityNetwork)}),{initial:!0}),a((()=>this.view?.map.layers),"change",(()=>{const{loadErrors:t,messages:e}=this,i=e.info,r=t.find((t=>t===i.noUtilityNetwork)),o=t.find((t=>t===i.noUtilityNetworkServiceUserTypeExtension));r||(t.removeAll(),o&&t.push(i.noUtilityNetworkServiceUserTypeExtension),this._setDirtyAreasLayer())})),p(t)])}))}get state(){return this.loadErrors.length?"disabled":this.executionError?"failed":this.updatingHandles.updating?"executing":this._activeOperationDidSucceed?"success":this.view.ready&&this.utilityNetwork.loaded?"ready":"loading"}set utilityNetwork(t){this.loadErrors.removeAll(),this._dirtyAreasLayer=null,this._set("utilityNetwork",t)}get view(){return this._get("view")}set view(t){this._set("view",t)}async validateTopology(){const{messages:t,utilityNetwork:e,view:i}=this;if(!this.loadErrors.length){let o;this._activeOperationDidSucceed=!1,this._set("executionError",""),o="current"===this.extentToValidate?{xmin:i.extent.xmin,ymin:i.extent.ymin,xmax:i.extent.xmax,ymax:i.extent.ymax,spatialReference:{wkid:i.spatialReference.wkid,latestWkid:i.spatialReference.latestWkid}}:{xmin:e.fullExtent?.xmin,ymin:e.fullExtent?.ymin,xmax:e.fullExtent?.xmax,ymax:e.fullExtent?.ymax,spatialReference:{wkid:e.spatialReference.wkid,latestWkid:e.spatialReference.latestWkid}},this.updatingHandles.addPromise(e.validateTopology(new c({gdbVersion:this._dirtyAreasLayer.gdbVersion,validateArea:new d(o)})).then((()=>{this._activeOperationDidSucceed=!0}),(e=>{let i="Error: "+e;e instanceof r&&e.details&&e.details.raw&&(e.details.raw.extendedCode===h.noDirtyAreasInExtent?i=t.info.noDirtyAreasInExtent:e.details.raw.extendedCode!==h.cannotAcquireVersionLock_v10&&e.details.raw.extendedCode!==h.cannotAcquireVersionLock_v11||(i=t.info.cannotAcquireVersionLock)),this._set("executionError",i)})))}}_setDirtyAreasLayer(){const t=this.view.map.layers;if(t){const e=t.items.filter((t=>y(t))).find((t=>t.parsedUrl?.path===this.utilityNetwork.networkSystemLayers.dirtyAreasLayerUrl));e?this._dirtyAreasLayer=e:this.loadErrors.push(this.messages.info.noDirtyAreasLayer)}}async _onUtilityNetworkLoad(){await this._checkUtilityNetworkExtension(),this._setDirtyAreasLayer()}async _checkUtilityNetworkExtension(){await this.utilityNetwork.queryNamedTraceConfigurations({globalIds:["{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}"]}).catch((t=>{t.details.raw.extendedCode===h.noUtilityNetworkExtension?this.loadErrors.push(this.messages.info.noUtilityNetworkServiceUserTypeExtension):this.loadErrors.push(t.message)}))}};t([n()],u.prototype,"_dirtyAreasLayer",void 0),t([n({readOnly:!0})],u.prototype,"executionError",void 0),t([n()],u.prototype,"extentToValidate",void 0),t([n()],u.prototype,"loadErrors",void 0),t([n()],u.prototype,"messages",void 0),t([n({readOnly:!0})],u.prototype,"state",null),t([n()],u.prototype,"utilityNetwork",null),t([n()],u.prototype,"view",null),u=t([l("esri.widgets.UtilityNetworkValidateTopology.UtilityNetworkValidateTopologyViewModel")],u);const w=u;export{w as default};
|