@arcgis/core 4.34.0-next.43 → 4.34.0-next.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0494e1212dd94d927287.js +1 -0
- package/assets/esri/core/workers/chunks/08840c4d3df711065571.js +1 -0
- package/assets/esri/core/workers/chunks/{42c5d957813080143e5a.js → 09268dc856c3d5ce178f.js} +1 -1
- package/assets/esri/core/workers/chunks/092cb42b88ecfb9c4a07.js +1 -0
- package/assets/esri/core/workers/chunks/0f20c0eec850a39620a1.js +1 -0
- package/assets/esri/core/workers/chunks/129144cbdb3fcbb87baf.js +1 -0
- package/assets/esri/core/workers/chunks/{b40845b45f8d7cd347a1.js → 17df0f766ee1e323d3fa.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf474c055a85bdbfa8d0.js → 19f1bfe815896d4983af.js} +1 -1
- package/assets/esri/core/workers/chunks/2370ff6c3006691ac688.js +1 -0
- package/assets/esri/core/workers/chunks/28a5a7c6b3d6902146f6.js +1 -0
- package/assets/esri/core/workers/chunks/{bb23371335ac049861e6.js → 28a85997c9003cacdefb.js} +1 -1
- package/assets/esri/core/workers/chunks/2942ab268f24cea2e722.js +1 -0
- package/assets/esri/core/workers/chunks/{3a2cbfb03103c402c6c5.js → 2b75212c31145cc07d16.js} +1 -1
- package/assets/esri/core/workers/chunks/{5958598da96464128aed.js → 2f65081bfedeab44d6cb.js} +1 -1
- package/assets/esri/core/workers/chunks/33f3e3d05429f845c139.js +1 -0
- package/assets/esri/core/workers/chunks/{68a69d3fcad6febf55f6.js → 349da65a8793f7873366.js} +6 -6
- package/assets/esri/core/workers/chunks/379a4f664e77ad1fffe9.js +1 -0
- package/assets/esri/core/workers/chunks/45b450c045d5fadf71b6.js +1 -0
- package/assets/esri/core/workers/chunks/4622a3e64d3c4aafa56b.js +1 -0
- package/assets/esri/core/workers/chunks/{9aa84b86262fa8334bc4.js → 48514235c32917e43a3f.js} +44 -44
- package/assets/esri/core/workers/chunks/4c6862ad3af947c704f7.js +1 -0
- package/assets/esri/core/workers/chunks/4d544e3e19ce07c2c195.js +1 -0
- package/assets/esri/core/workers/chunks/{6759319f3fd2d03c446b.js → 5c556468e2a598ab793a.js} +1 -1
- package/assets/esri/core/workers/chunks/64c31c90e4c589ca2f04.js +1 -0
- package/assets/esri/core/workers/chunks/709dc98379f4ce18a0b5.js +1 -0
- package/assets/esri/core/workers/chunks/73140c5c0beda7ea3703.js +1 -0
- package/assets/esri/core/workers/chunks/7b560ac0be93c6aa9940.js +1 -0
- package/assets/esri/core/workers/chunks/{ff34fdda7899e784ac73.js → 7c7338af011b8f0d7218.js} +1 -1
- package/assets/esri/core/workers/chunks/838998bfda90f099c6e9.js +1 -0
- package/assets/esri/core/workers/chunks/84f3e1ce25c36e46fd2a.js +1 -0
- package/assets/esri/core/workers/chunks/863e87ac982d7727b435.js +1 -0
- package/assets/esri/core/workers/chunks/{c6da9ba188b627ab3b79.js → 8aa77a5e82c033512b45.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1c2e5e0a70fb5d27da5.js → 8bab4c59c9b644224ecb.js} +1 -1
- package/assets/esri/core/workers/chunks/{f4b145feab275b268c2e.js → 8cc700da2ac58849a708.js} +1 -1
- package/assets/esri/core/workers/chunks/{28d71e1b866113650c75.js → 8e36693e5213c20158d7.js} +1 -1
- package/assets/esri/core/workers/chunks/{1acc620bfd2983d6853f.js → 8fae35af98c29bef8500.js} +1 -1
- package/assets/esri/core/workers/chunks/914eaed113dda727eb47.js +1 -0
- package/assets/esri/core/workers/chunks/98175b454e807b1a3c5f.js +1 -0
- package/assets/esri/core/workers/chunks/9a20be3b02c9d6349b8d.js +1 -0
- package/assets/esri/core/workers/chunks/9d30fed26e0d84ef893b.js +1 -0
- package/assets/esri/core/workers/chunks/a1ff4c252012d5026133.js +1 -0
- package/assets/esri/core/workers/chunks/{ddeaf688d72b2873c4ac.js → a2a13dd95238bb144479.js} +1 -1
- package/assets/esri/core/workers/chunks/a34d98abcf958a632b0f.js +1 -0
- package/assets/esri/core/workers/chunks/a3a23a56df4e5ee86bb2.js +1 -0
- package/assets/esri/core/workers/chunks/{5ae6e2b3557fe8730072.js → b287624909578d307e07.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b91a49202129eedaf00.js → b4304673696fc0774bff.js} +1 -1
- package/assets/esri/core/workers/chunks/b45772b72f2b8f4fd53f.js +1 -0
- package/assets/esri/core/workers/chunks/c645009f3d2576494bfc.js +1 -0
- package/assets/esri/core/workers/chunks/ce569860b170700e9b31.js +1 -0
- package/assets/esri/core/workers/chunks/cf5db995ba88912cf6b7.js +1 -0
- package/assets/esri/core/workers/chunks/{b85dbefdb09bc6c99e0d.js → cff15600d0ec7b19dffb.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e99fc78bd0f40a8ba81.js → d1c97fdcba6eb443cb1c.js} +1 -1
- package/assets/esri/core/workers/chunks/{615915e7c48f0a3d0060.js → d547b27ac750953a998f.js} +1 -1
- package/assets/esri/core/workers/chunks/d70e1b8b8bee88a7a5b8.js +353 -0
- package/assets/esri/core/workers/chunks/da396fdbd6f213042aa7.js +1 -0
- package/assets/esri/core/workers/chunks/dbc9bb3011f16ce33f71.js +1 -0
- package/assets/esri/core/workers/chunks/dd0f1e06b7df953ea223.js +1 -0
- package/assets/esri/core/workers/chunks/dd79d3aa6e1a8aee6881.js +1 -0
- package/assets/esri/core/workers/chunks/e1272db232194cbe102c.js +1 -0
- package/assets/esri/core/workers/chunks/{14b536e0c1de6c7422bc.js → e408ccee12bfe089c913.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f2bdb8da5c9ffd7d05e.js → e58336aafe8c95bb6831.js} +1 -1
- package/assets/esri/core/workers/chunks/{30b9c131b69297ee186f.js → e59e09766b130a05c617.js} +1 -1
- package/assets/esri/core/workers/chunks/e65fc26f4384a328a753.js +1 -0
- package/assets/esri/core/workers/chunks/{e3f5afdf133c58b3d161.js → ea262087938335fed19f.js} +1 -1
- package/assets/esri/core/workers/chunks/eafc4da265469e9e5e0b.js +1 -0
- package/assets/esri/core/workers/chunks/{aaab7694eb333ad480f5.js → ec9fd49e0252797f7f6a.js} +1 -1
- package/assets/esri/core/workers/chunks/{655b8d24ffe5405f8ba1.js → f2a2d3cda4a3dc0a8caf.js} +1 -1
- package/assets/esri/core/workers/chunks/f67997250569069ee2ef.js +1 -0
- package/assets/esri/core/workers/chunks/fc3a6f2f99629e57dbbd.js +1 -0
- package/assets/esri/core/workers/chunks/ff9eef1940eaa3406223.js +1 -0
- package/assets/esri/libs/i3s/i3s.wasm +0 -0
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
- package/chunks/bundle.js +1 -1
- package/chunks/i3s.js +1 -1
- package/config.js +1 -1
- package/core/workers/registry.js +1 -1
- package/geometry/operators/json/generalizeOperator.js +5 -0
- package/geometry/operators/json/simplifyOperator.js +1 -1
- package/interfaces.d.ts +3 -3
- package/kernel.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +5 -0
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/TemporalSceneLayer.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/parquetUtils.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/networks/RulesTable.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess.js +1 -1
- package/rest/support/AlgorithmicColorRamp.js +1 -1
- package/rest/support/MultipartColorRamp.js +1 -1
- package/smartMapping/statistics/support/statsWorker.js +1 -1
- package/support/revision.js +1 -1
- package/support/zipUtils.js +1 -1
- package/symbols/cim/CIMEffects.js +1 -1
- package/symbols/cim/CIMResourceManager.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/animationUtils.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/effects/CIMEffectHelper.js +1 -1
- package/symbols/cim/effects/EffectAddControlPoints.js +1 -1
- package/symbols/cim/effects/EffectArrow.js +1 -1
- package/symbols/cim/effects/EffectBuffer.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/cim/effects/EffectCut.js +1 -1
- package/symbols/cim/effects/EffectDashes.js +1 -1
- package/symbols/cim/effects/EffectDonut.js +1 -1
- package/symbols/cim/effects/EffectEnclosingPolygon.js +1 -1
- package/symbols/cim/effects/EffectJog.js +1 -1
- package/symbols/cim/effects/EffectMove.js +1 -1
- package/symbols/cim/effects/EffectOffset.js +1 -1
- package/symbols/cim/effects/EffectRadial.js +1 -1
- package/symbols/cim/effects/EffectReverse.js +1 -1
- package/symbols/cim/effects/EffectRotate.js +1 -1
- package/symbols/cim/effects/EffectScale.js +1 -1
- package/symbols/cim/effects/EffectSuppress.js +1 -1
- package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
- package/symbols/cim/effects/EffectWave.js +1 -1
- package/symbols/cim/fitVectorMarker.js +1 -1
- package/symbols/cim/placements/CIMMarkerPlacementHelper.js +1 -1
- package/symbols/cim/placements/PlacementAlongLineSameSize.js +1 -1
- package/symbols/cim/placements/PlacementAtExtremities.js +1 -1
- package/symbols/cim/placements/PlacementAtRatioPositions.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/symbols/cim/placements/PlacementOnLine.js +1 -1
- package/symbols/cim/placements/PlacementOnVertices.js +1 -1
- package/symbols/cim/placements/PlacementPolygonCenter.js +1 -1
- package/symbols/cim/utils.js +1 -1
- package/symbols/support/gfxUtils.js +1 -1
- package/symbols/support/symbolLayerUtils.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/projection.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/input/handlers/MouseWheelZoom.js +1 -1
- package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/GaussianSplatWorkerHandle.js +1 -1
- package/views/3d/support/flow/StreamlineResources3D.js +5 -0
- package/views/3d/support/flow/StreamlineResources3DOverlay.js +5 -0
- package/views/3d/support/flow/StreamlineResources3DShape.js +5 -0
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +5 -5
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
- package/views/support/TextureCompressionWorker.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/CoordinateConversion/support/Format.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/Feature/FeatureRelationship.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
- package/assets/esri/core/workers/chunks/016d421114118307d4dd.js +0 -1
- package/assets/esri/core/workers/chunks/03df4668002eb4cb4f98.js +0 -1
- package/assets/esri/core/workers/chunks/087ae1e3e767f0e678e5.js +0 -1
- package/assets/esri/core/workers/chunks/0b45566fad2cbb03fea1.js +0 -1
- package/assets/esri/core/workers/chunks/0d73afce787ee1e76b21.js +0 -1
- package/assets/esri/core/workers/chunks/21dd626a5b5ea6a7e18e.js +0 -1
- package/assets/esri/core/workers/chunks/24e76fa530fc0c495fb5.js +0 -1
- package/assets/esri/core/workers/chunks/2a26c3fc324d672ebe88.js +0 -1
- package/assets/esri/core/workers/chunks/345ed9ac44e47355803e.js +0 -1
- package/assets/esri/core/workers/chunks/3984ca7e05f30724adaf.js +0 -1
- package/assets/esri/core/workers/chunks/439128f23fa091633d2d.js +0 -1
- package/assets/esri/core/workers/chunks/489391ed1d443140617d.js +0 -1
- package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +0 -1
- package/assets/esri/core/workers/chunks/774844eea928efa811f2.js +0 -1
- package/assets/esri/core/workers/chunks/7b82ed4cc475c782256b.js +0 -1
- package/assets/esri/core/workers/chunks/7ef29640de297a0cf744.js +0 -1
- package/assets/esri/core/workers/chunks/8867368ab9b005460f19.js +0 -353
- package/assets/esri/core/workers/chunks/8c3c752408fac3db05cf.js +0 -1
- package/assets/esri/core/workers/chunks/8ca95499e00ce8b0af9a.js +0 -1
- package/assets/esri/core/workers/chunks/98ac849cccc4d5316021.js +0 -1
- package/assets/esri/core/workers/chunks/9cd9b22354dbdf1b1df0.js +0 -1
- package/assets/esri/core/workers/chunks/a89c060ad302381aaf7d.js +0 -1
- package/assets/esri/core/workers/chunks/af98c7546be409303213.js +0 -1
- package/assets/esri/core/workers/chunks/b01a90ce699058307bc2.js +0 -1
- package/assets/esri/core/workers/chunks/c110941e87923ba47193.js +0 -1
- package/assets/esri/core/workers/chunks/c47227a626edc1e1ecf1.js +0 -1
- package/assets/esri/core/workers/chunks/c474800508e3ad5ce9d7.js +0 -1
- package/assets/esri/core/workers/chunks/d5d2d4df407cf078bb81.js +0 -1
- package/assets/esri/core/workers/chunks/d93b24e863379116b2aa.js +0 -1
- package/assets/esri/core/workers/chunks/da6f46211551a96dce19.js +0 -1
- package/assets/esri/core/workers/chunks/dd9be173cddc16a354ed.js +0 -1
- package/assets/esri/core/workers/chunks/e6d08230adb90b9a2a17.js +0 -1
- package/assets/esri/core/workers/chunks/eb7dd722e4cd7f83b3f5.js +0 -1
- package/assets/esri/core/workers/chunks/f1adf8ebc2c1b93857bf.js +0 -1
- package/assets/esri/core/workers/chunks/fb84fa28978a1820a725.js +0 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/loadGeometryEngine.js +0 -5
- package/views/3d/support/flow/StreamlinesResources3D.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as m}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as v,isFieldInput as b,differentValuesString as f}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as _,prepareISOFieldValueForDateComponents as y,prepareUnixFieldValueForDateComponents as F,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as x}from"./support/globalCss.js";import{setFocus as k}from"./support/widgetUtils.js";import{messageBundle as O}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import{isEmptyValue as D}from"./support/forms/formUtils.js";import{substitute as S}from"../intl/substitute.js";const U="data-element-id";let E=class extends l{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new h,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([i(()=>this.features,()=>{this._dateComponentMap.clear()}),i(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return C({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(m.base,x.widget,x.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:i,elementId:o}=e.dataset,n=t(this._dateComponentMap,`${o}`,()=>({}));switch(i){case"date":n.date=e;break;case"time":n.time=e;break;case"timeZone":n.timeZone=e}}_renderErrorNotice(e){return V("div",{class:this.classes(m.base,x.widget,x.panel)},V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=d(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?o+=` (${e.map(e=>e.label).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return o?V("calcite-notice",{class:m.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter(e=>e.visible).map(e=>this._renderInput(e))}_renderInput(e){return v(e)?this._renderGroupInput(e):b(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter(e=>e.visible),a=i.label??"";return V("calcite-block",{class:this.classes(m.group,"sequential"===this.groupDisplay?m.groupSequential:null,this.disabled?m.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?S(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:m.label,key:`field--${i}`},V("div",{class:m.labelTextContent,key:"labelTextContainer"},t,o?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?p(e,t,this.messages):null;return n?V("calcite-input-message",{icon:!0,status:"invalid"},n):i?V("calcite-input-message",{class:m.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===f||e.value===f)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:f,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:m.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return V("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...o},e===f?this.messages.differentValuesPlaceholder:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map(t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return V("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?f:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==f&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map(e=>e.map(({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))),a=[...o];n.length>0&&a.push(V("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&D(i.value);return e.showNoValueOptionEnabled&&a.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(V("calcite-combobox-item",{key:f,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:f})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map(({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i}));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=D(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:m.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?V("calcite-label",{class:m.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:m.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return V("calcite-label",{class:m.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:m.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(m.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(m.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(m.fieldInput,m.inputDisabled,m.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let o;switch(i.type){case"date":o=this._renderDateFieldComponents(e,t);break;case"date-only":o=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":o=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":o=this._renderTimestampOffsetFieldComponents(e,t);break;default:o=this._renderReadOnlyComponent(e,g(i,t.value,{timeZone:e.effectiveTimeZone,..._(e.template.field)}))}return e.value===f?[o,V("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:o}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[U],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[U],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=y(a),l=y(s),d=y(e.value===f?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-zone",{...u,class:i,clearable:e.value===f||null==e.value,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset||"",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=F(e.value===f?"":e.value,r),d=F(s,r),p=F(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...c,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?V("calcite-input-time-picker",{...c,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{template:t,valid:i,value:o,minLength:n,maxLength:a,required:s,fieldName:r,editable:l,userHasChangedValue:d,range:{max:p,min:u}}=e,c=!l||this.readOnly,h=!c&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===f&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(m.fieldInput,c?m.inputDisabled:null),status:!d&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:a&&a>-1?a:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:r,name:r,max:null!=p?p:void 0,min:null!=u?u:void 0,disabled:h,readOnly:c,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[U]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,k(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,()=>i.value);this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);a!==n&&this.viewModel.setValue(o,a)}async _afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===f?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?I({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?M({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===f?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],E.prototype,"activeFeatureIndex",null),e([n()],E.prototype,"disabled",null),e([n()],E.prototype,"_effectiveDisabled",null),e([n()],E.prototype,"features",null),e([n()],E.prototype,"map",null),e([n()],E.prototype,"spatialReference",null),e([n()],E.prototype,"timeZone",null),e([n()],E.prototype,"headingLevel",void 0),e([n()],E.prototype,"icon",null),e([n(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([n(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([n(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([n()],E.prototype,"readOnly",null),e([n()],E.prototype,"valid",null),e([n(),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([n()],E.prototype,"groupDisplay",void 0),E=e([a("esri.widgets.BatchAttributeForm")],E);const R=E;export{R as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as m}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as v,isFieldInput as b,differentValuesString as f}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as _,prepareISOFieldValueForDateComponents as y,prepareUnixFieldValueForDateComponents as F,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as x}from"./support/globalCss.js";import{setFocus as k}from"./support/widgetUtils.js";import{messageBundle as O}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import{isEmptyValue as D}from"./support/forms/formUtils.js";import{substitute as S}from"../intl/substitute.js";const U="data-element-id";let E=class extends l{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new h,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([i(()=>this.features,()=>{this._dateComponentMap.clear()}),i(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return C({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(m.base,x.widget,x.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:i,elementId:o}=e.dataset,n=t(this._dateComponentMap,`${o}`,()=>({}));switch(i){case"date":n.date=e;break;case"time":n.time=e;break;case"timeZone":n.timeZone=e}}_renderErrorNotice(e){return V("div",{class:this.classes(m.base,x.widget,x.panel)},V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=d(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?o+=` (${e.map(e=>e.label).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return o?V("calcite-notice",{class:m.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter(e=>e.visible).map(e=>this._renderInput(e))}_renderInput(e){return v(e)?this._renderGroupInput(e):b(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter(e=>e.visible),a=i.label??"";return V("calcite-block",{class:this.classes(m.group,"sequential"===this.groupDisplay?m.groupSequential:null,this.disabled?m.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?S(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:m.label,key:`field--${i}`},V("div",{class:m.labelTextContent,key:"labelTextContainer"},t,o?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?p(e,t,this.messages):null;return n?V("calcite-input-message",{icon:!0,status:"invalid"},n):i?V("calcite-input-message",{class:m.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===f||e.value===f)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:f,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:m.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return V("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...o},e===f?this.messages.differentValuesPlaceholder:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map(t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return V("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?f:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==f&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map(e=>e.map(({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))),a=[...o];n.length>0&&a.push(V("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&D(i.value);return e.showNoValueOptionEnabled&&a.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(V("calcite-combobox-item",{key:f,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:f})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map(({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i}));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=D(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:m.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?V("calcite-label",{class:m.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:m.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return V("calcite-label",{class:m.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:m.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(m.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(m.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(m.fieldInput,m.inputDisabled,m.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let o;switch(i.type){case"date":o=this._renderDateFieldComponents(e,t);break;case"date-only":o=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":o=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":o=this._renderTimestampOffsetFieldComponents(e,t);break;default:o=this._renderReadOnlyComponent(e,g(i,t.value,{timeZone:e.effectiveTimeZone,..._(e.template.field)}))}return e.value===f?[o,V("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:o}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[U],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[U],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=y(a),l=y(s),d=y(e.value===f?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-zone",{...u,class:i,clearable:e.value===f||null==e.value,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset||"",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=F(e.value===f?"":e.value,r),d=F(s,r),p=F(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...c,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?V("calcite-input-time-picker",{...c,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{template:t,valid:i,value:o,minLength:n,maxLength:a,required:s,fieldName:r,editable:l,userHasChangedValue:d,range:{max:p,min:u}}=e,c=!l||this.readOnly,h=!c&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===f&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(m.fieldInput,c?m.inputDisabled:null),status:!d&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:a&&a>-1?a:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:r,name:r,max:null!=p?p:void 0,min:null!=u?u:void 0,disabled:h,readOnly:c,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[U]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,k(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,()=>i.value);this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);a!==n&&this.viewModel.setValue(o,a)}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===f?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?I({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?M({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===f?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],E.prototype,"activeFeatureIndex",null),e([n()],E.prototype,"disabled",null),e([n()],E.prototype,"_effectiveDisabled",null),e([n()],E.prototype,"features",null),e([n()],E.prototype,"map",null),e([n()],E.prototype,"spatialReference",null),e([n()],E.prototype,"timeZone",null),e([n()],E.prototype,"headingLevel",void 0),e([n()],E.prototype,"icon",null),e([n(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([n(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([n(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([n()],E.prototype,"readOnly",null),e([n()],E.prototype,"valid",null),e([n(),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([n()],E.prototype,"groupDisplay",void 0),E=e([a("esri.widgets.BatchAttributeForm")],E);const R=E;export{R as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../core/Collection.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import i from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import p from"./Widget.js";import d from"./CatalogLayerList/CatalogLayerListViewModel.js";import c from"./CatalogLayerList/CatalogLayerListVisibleElements.js";import{css as m}from"./CatalogLayerList/css.js";import h from"./LayerList/LayerListItem.js";import y from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as g,removeDestroyedListItems as L,setFilterPredicate as f}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as v}from"./support/globalCss.js";import{calciteListFilterProps as I}from"./support/listUtils.js";import{setFocus as w}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as C}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";var M;const O=t.ofType(y),T="nested";let P=M=class extends(o(p)){constructor(e,o){super(e,o),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new i,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new i,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=u,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new O,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new d,this.visibilityAppearance="default",this.visibleElements=new c,this._onTablesOpen=e=>{this.onTablesOpen?this.onTablesOpen(e):(this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid)},this._onCatalogOpen=e=>{this.onCatalogOpen?this.onCatalogOpen(e):(this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid)},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find(e=>e.classList?.contains(m.item));this._activeItem=g(t)}}initialize(){this.addHandles([s(()=>this.openedLayers,"change",()=>this._handleOpenedLayersChange(),r),s(()=>this.viewModel.catalogItems,"change",()=>L(this.selectedItems),r),l(()=>[this.filterPredicate,this._rootListEl],()=>f(this._rootListEl,this.filterPredicate))])}loadDependencies(){return _({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get _visibleItems(){return this.catalogItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _openedPanelItems(){return this._visibleItems.flatten(e=>e.children).filter(({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map((t,o)=>this._renderLayerFlowItem(t,o===e.length-1))}get catalogItems(){return this.viewModel.catalogItems}set catalogItems(e){this.viewModel.catalogItems=e}get catalogLayer(){return this.viewModel.catalogLayer}set catalogLayer(e){this.viewModel.catalogLayer=e}get icon(){return"catalog-dataset"}set icon(e){this._overrideIfSome("icon",e)}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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[v.hidden]:"loading"===e,[v.disabled]:"disabled"===e};return F("div",{class:this.classes(m.base,v.widget,v.panel,t)},this._renderItemTooltips(),this._renderItems())}async _createFlowList(e,t){const{_layerListMap:o}=this,i=o.get(e);if(i)return i;const s="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||o.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:o}=this;this._openedLayersController?.abort();const i=new AbortController,{signal:s}=i;this._openedLayersController=i,e.forEach((o,i)=>{t.includes(i)||(o.destroy(),e.delete(i))});const l=await Promise.all(t.map(e=>this._createFlowList(e,s)));if(s.aborted)return;o.removeAll(),o.addMany(l);const r=o.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.forEach(e=>e.destroy()),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:o}=this;return e?.layer?F("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.layer.uid)},o.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter(e=>!e.hidden).toArray().map(e=>this._renderItemTooltipNodes(e))}_renderItemTooltips(){return this._visibleItems?.toArray().map(e=>this._renderItemTooltipNodes(e))}_renderNoItemsMessage(){return F("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return F("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},F("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map(({title:o,panel:i},s)=>{const l=()=>this._handlePanelFlowItemBack(i);return F("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:o,heading:i.title,headingLevel:this.headingLevel,key:`flow-panel-${i.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},i.render(),F("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))})}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,w(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,w(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:o,_filterEnabled:i,_rootGroupUid:s,visibleElements:{closeButton:l,collapseButton:r,heading:a,flow:n},selectionMode:p,filterText:d,filterPlaceholder:c,messages:h,openedLayers:y,_openedPanelItems:u}=this,g=[F("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:l,closed:!e,collapsed:t,collapsible:r,heading:a?h.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!u.length,onCalciteFlowItemClose:()=>this.visible=!1},o?.length?null:this._renderNoItems(),F("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},"data-layer-type":s,displayMode:T,filterEnabled:i,filterPlaceholder:c,filterProps:I,filterText:i?d:"",group:s,key:"root-list",label:h.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:p,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??""},o.toArray().map(e=>this._renderItem(e)),i?F("div",{class:m.filterNoResults,slot:"filter-no-results"},F("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?n?F("calcite-flow",{key:"root-flow"},g):g:null}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,w(e))}_renderLayerFlowItem(e,t){const{messages:o,openedLayers:i}=this,s=e.title||this.messages.untitledLayer;return F("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:o["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),i.pop();const t=i.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}async _createCatalogLayerList(e){const{headingLevel:t,catalogOptions:o,view:i,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:r,selectionMode:a,visibilityAppearance:n,onCatalogOpen:p,onTablesOpen:d}=this;return new M({headingLevel:t,view:i,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:r,selectionMode:a,visibilityAppearance:n,...o,catalogLayer:e,onCatalogOpen:p,onTablesOpen:d})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:o,selectionMode:i}=this;return new t({headingLevel:o,selectionMode:i,...this._getTableListParams(e)})}_renderItem(e,t,o){return F(h,{activeItem:this._activeItem,css:m,displayMode:T,dragEnabled:!1,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:o,rootGroupUid:this._rootGroupUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:o}=this;if("none"===t)return;const i=e.target.selectedItems.map(e=>g(e)).filter(Boolean);o.removeAll(),o.addMany(i)}};e([a()],P.prototype,"_rootListEl",void 0),e([a()],P.prototype,"_activeItem",void 0),e([a()],P.prototype,"_tooltipReferenceMap",void 0),e([a()],P.prototype,"_focusRootFlowItem",void 0),e([a()],P.prototype,"_focusPanelFlowItem",void 0),e([a()],P.prototype,"_focusLayerFlowItem",void 0),e([a()],P.prototype,"_layerListMap",void 0),e([a()],P.prototype,"_filterEnabled",null),e([a()],P.prototype,"_visibleItems",null),e([a()],P.prototype,"_openedPanelItems",null),e([a()],P.prototype,"_renderedOpenLayerFlowItems",null),e([a()],P.prototype,"catalogItems",null),e([a()],P.prototype,"catalogLayer",null),e([a({readOnly:!0})],P.prototype,"catalogLayerList",void 0),e([a()],P.prototype,"catalogOptions",void 0),e([a()],P.prototype,"collapsed",void 0),e([a()],P.prototype,"filterPlaceholder",void 0),e([a()],P.prototype,"filterPredicate",void 0),e([a()],P.prototype,"filterText",void 0),e([a()],P.prototype,"headingLevel",void 0),e([a()],P.prototype,"icon",null),e([a()],P.prototype,"knowledgeGraphOptions",void 0),e([a()],P.prototype,"label",null),e([a()],P.prototype,"layerTablesEnabled",void 0),e([a()],P.prototype,"listItemCreatedFunction",null),e([a()],P.prototype,"mapImageOptions",void 0),e([a(),b("esri/widgets/CatalogLayerList/t9n/CatalogLayerList")],P.prototype,"messages",void 0),e([a(),b("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([a()],P.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],P.prototype,"openedLayers",void 0),e([a({readOnly:!0})],P.prototype,"openedLayerLists",void 0),e([a()],P.prototype,"onCatalogOpen",void 0),e([a()],P.prototype,"onTablesOpen",void 0),e([a({type:O})],P.prototype,"selectedItems",void 0),e([a()],P.prototype,"selectionMode",void 0),e([a({readOnly:!0})],P.prototype,"tableList",void 0),e([a()],P.prototype,"tileOptions",void 0),e([a()],P.prototype,"view",null),e([C("trigger-action"),a({type:d})],P.prototype,"viewModel",void 0),e([a()],P.prototype,"visibilityAppearance",void 0),e([a({type:c,nonNullable:!0})],P.prototype,"visibleElements",void 0),P=M=e([n("esri.widgets.CatalogLayerList")],P);const A=P;export{A as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../core/Collection.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import i from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import p from"./Widget.js";import d from"./CatalogLayerList/CatalogLayerListViewModel.js";import c from"./CatalogLayerList/CatalogLayerListVisibleElements.js";import{css as m}from"./CatalogLayerList/css.js";import h from"./LayerList/LayerListItem.js";import y from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as g,removeDestroyedListItems as L,setFilterPredicate as f}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as v}from"./support/globalCss.js";import{calciteListFilterProps as I}from"./support/listUtils.js";import{setFocus as w}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as C}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";var M;const O=t.ofType(y),T="nested";let P=M=class extends(o(p)){constructor(e,o){super(e,o),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new i,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new i,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=u,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new O,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new d,this.visibilityAppearance="default",this.visibleElements=new c,this._onTablesOpen=e=>{this.onTablesOpen?this.onTablesOpen(e):(this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid)},this._onCatalogOpen=e=>{this.onCatalogOpen?this.onCatalogOpen(e):(this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid)},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find(e=>e.classList?.contains(m.item));this._activeItem=g(t)}}initialize(){this.addHandles([s(()=>this.openedLayers,"change",()=>this._handleOpenedLayersChange(),r),s(()=>this.viewModel.catalogItems,"change",()=>L(this.selectedItems),r),l(()=>[this.filterPredicate,this._rootListEl],()=>f(this._rootListEl,this.filterPredicate))])}loadDependencies(){return _({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get _visibleItems(){return this.catalogItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _openedPanelItems(){return this._visibleItems.flatten(e=>e.children).filter(({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map((t,o)=>this._renderLayerFlowItem(t,o===e.length-1))}get catalogItems(){return this.viewModel.catalogItems}set catalogItems(e){this.viewModel.catalogItems=e}get catalogLayer(){return this.viewModel.catalogLayer}set catalogLayer(e){this.viewModel.catalogLayer=e}get icon(){return"catalog-dataset"}set icon(e){this._overrideIfSome("icon",e)}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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[v.hidden]:"loading"===e,[v.disabled]:"disabled"===e};return F("div",{class:this.classes(m.base,v.widget,v.panel,t)},this._renderItemTooltips(),this._renderItems())}async _createFlowList(e,t){const{_layerListMap:o}=this,i=o.get(e);if(i)return i;const s="catalog"===e.type?this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||o.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:o}=this;this._openedLayersController?.abort();const i=new AbortController,{signal:s}=i;this._openedLayersController=i,e.forEach((o,i)=>{t.includes(i)||(o.destroy(),e.delete(i))});const l=await Promise.all(t.map(e=>this._createFlowList(e,s)));if(s.aborted)return;o.removeAll(),o.addMany(l);const r=o.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.forEach(e=>e.destroy()),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:o}=this;return e?.layer?F("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.layer.uid)},o.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter(e=>!e.hidden).toArray().map(e=>this._renderItemTooltipNodes(e))}_renderItemTooltips(){return this._visibleItems?.toArray().map(e=>this._renderItemTooltipNodes(e))}_renderNoItemsMessage(){return F("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return F("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},F("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map(({title:o,panel:i},s)=>{const l=()=>this._handlePanelFlowItemBack(i);return F("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:o,heading:i.title,headingLevel:this.headingLevel,key:`flow-panel-${i.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},i.render(),F("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))})}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,w(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,w(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:o,_filterEnabled:i,_rootGroupUid:s,visibleElements:{closeButton:l,collapseButton:r,heading:a,flow:n},selectionMode:p,filterText:d,filterPlaceholder:c,messages:h,openedLayers:y,_openedPanelItems:u}=this,g=[F("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:l,closed:!e,collapsed:t,collapsible:r,heading:a?h.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!u.length,onCalciteFlowItemClose:()=>this.visible=!1},o?.length?null:this._renderNoItems(),F("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},"data-layer-type":s,displayMode:T,filterEnabled:i,filterPlaceholder:c,filterProps:I,filterText:i?d:"",group:s,key:"root-list",label:h.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:p,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??""},o.toArray().map(e=>this._renderItem(e)),i?F("div",{class:m.filterNoResults,slot:"filter-no-results"},F("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?n?F("calcite-flow",{key:"root-flow"},g):g:null}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,w(e))}_renderLayerFlowItem(e,t){const{messages:o,openedLayers:i}=this,s=e.title||this.messages.untitledLayer;return F("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:o["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),i.pop();const t=i.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_createCatalogLayerList(e){const{headingLevel:t,catalogOptions:o,view:i,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:r,selectionMode:a,visibilityAppearance:n,onCatalogOpen:p,onTablesOpen:d}=this;return new M({headingLevel:t,view:i,filterPlaceholder:s,listItemCreatedFunction:l,minFilterItems:r,selectionMode:a,visibilityAppearance:n,...o,catalogLayer:e,onCatalogOpen:p,onTablesOpen:d})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:o,selectionMode:i}=this;return new t({headingLevel:o,selectionMode:i,...this._getTableListParams(e)})}_renderItem(e,t,o){return F(h,{activeItem:this._activeItem,css:m,displayMode:T,dragEnabled:!1,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:o,rootGroupUid:this._rootGroupUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:o}=this;if("none"===t)return;const i=e.target.selectedItems.map(e=>g(e)).filter(Boolean);o.removeAll(),o.addMany(i)}};e([a()],P.prototype,"_rootListEl",void 0),e([a()],P.prototype,"_activeItem",void 0),e([a()],P.prototype,"_tooltipReferenceMap",void 0),e([a()],P.prototype,"_focusRootFlowItem",void 0),e([a()],P.prototype,"_focusPanelFlowItem",void 0),e([a()],P.prototype,"_focusLayerFlowItem",void 0),e([a()],P.prototype,"_layerListMap",void 0),e([a()],P.prototype,"_filterEnabled",null),e([a()],P.prototype,"_visibleItems",null),e([a()],P.prototype,"_openedPanelItems",null),e([a()],P.prototype,"_renderedOpenLayerFlowItems",null),e([a()],P.prototype,"catalogItems",null),e([a()],P.prototype,"catalogLayer",null),e([a({readOnly:!0})],P.prototype,"catalogLayerList",void 0),e([a()],P.prototype,"catalogOptions",void 0),e([a()],P.prototype,"collapsed",void 0),e([a()],P.prototype,"filterPlaceholder",void 0),e([a()],P.prototype,"filterPredicate",void 0),e([a()],P.prototype,"filterText",void 0),e([a()],P.prototype,"headingLevel",void 0),e([a()],P.prototype,"icon",null),e([a()],P.prototype,"knowledgeGraphOptions",void 0),e([a()],P.prototype,"label",null),e([a()],P.prototype,"layerTablesEnabled",void 0),e([a()],P.prototype,"listItemCreatedFunction",null),e([a()],P.prototype,"mapImageOptions",void 0),e([a(),b("esri/widgets/CatalogLayerList/t9n/CatalogLayerList")],P.prototype,"messages",void 0),e([a(),b("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([a()],P.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],P.prototype,"openedLayers",void 0),e([a({readOnly:!0})],P.prototype,"openedLayerLists",void 0),e([a()],P.prototype,"onCatalogOpen",void 0),e([a()],P.prototype,"onTablesOpen",void 0),e([a({type:O})],P.prototype,"selectedItems",void 0),e([a()],P.prototype,"selectionMode",void 0),e([a({readOnly:!0})],P.prototype,"tableList",void 0),e([a()],P.prototype,"tileOptions",void 0),e([a()],P.prototype,"view",null),e([C("trigger-action"),a({type:d})],P.prototype,"viewModel",void 0),e([a()],P.prototype,"visibilityAppearance",void 0),e([a({type:c,nonNullable:!0})],P.prototype,"visibleElements",void 0),P=M=e([n("esri.widgets.CatalogLayerList")],P);const A=P;export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=this._project(e,this.spatialReference);return{location:n,coordinate:this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}_getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}_project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&d())return h(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as A}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import M from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as S}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import U from"./UpdateWorkflowData.js";import j from"./Workflow.js";import{isUpdateRecordWorkflow as P,createWorkflowSteps as R,fetchCandidates as L}from"./workflowUtils.js";import{findUtilityNetwork as O,isGraphicForRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";var T;let H=T=class extends j{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits&&!a?.disabled){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new M,l=new T({data:new U({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t,i=!1){try{const a=await this._createNestedUpdateWorkflow(e,i,t);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=P(e);t?(e.stageDelete(),e.data.edits.feature===this.data.rootFeature&&this._removeRootFeatureFromCandidates()):await e.cancel(),this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=A([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=O(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const h=u?.generateDeleteAssociations([i]);if(!h)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=u?.gdbVersion??void 0;await r(c,[h],{gdbVersion:w,globalIdUsed:!0})}_removeRootFeatureFromCandidates(){const{candidates:e,rootFeature:t}=this.data;if(0===e.length||!t)return;const a=e.indexOf(t);a>-1&&e.splice(a,1)}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t,a){const i=C(e.sourceLayer)?V:E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,d="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,c=await i.create({association:a,feature:e,parent:d,sketchOptions:s,snappingManager:n,viewModel:l,readOnly:t,applyEdits:o,applyEditsFeatureService:r,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e,readOnly:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,void 0,t)),selectAssociatedFeature:async({feature:e,association:a})=>await this._updatingHandles.addPromise(this.startUpdating(e,a,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u(()=>!c.updating),c}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(const i of t){const t=e(i).finally(()=>i.destroy());this._updatingHandles.addPromise(t),a.push(t)}await Promise.all(a),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!x(t))return;const o=a.relationships?.find(e=>e.id===i);if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===i);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return R(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let s=null;e.addHandles(i(()=>{s=r(s)}),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer(()=>new Promise((e,t)=>{l(s?.signal,()=>t(d())),e(L(r,a,i,s?.signal))}));if(c(s),o.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)):e.next()}finally{r.resolve()}},F.TOOL),u=f(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:S});e.addHandles([h(()=>o.rootFeature,(e,t)=>{a.remove(t),a.add(e)},w),i(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=s(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&o()},w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){o.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],H.prototype,"activeEditorItem",null),e([v()],H.prototype,"activeFeatureFormViewModel",null),e([v()],H.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],H.prototype,"activeSketchViewModel",null),e([v()],H.prototype,"canDeleteAssociation",null),e([v()],H.prototype,"activeWorkflow",null),e([v()],H.prototype,"updating",null),e([v()],H.prototype,"data",void 0),e([v()],H.prototype,"hasPreviousStep",null),e([v()],H.prototype,"hasUpdatableCandidates",null),e([v()],H.prototype,"nestedWorkflowCount",null),e([v()],H.prototype,"shouldShowAttachments",null),e([v()],H.prototype,"shouldAllowAttachmentEditing",null),e([v()],H.prototype,"hasPendingEdits",null),e([v()],H.prototype,"helpMessage",null),e([v()],H.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],H.prototype,"hasInvalidFormTemplate",null),H=T=e([k("esri.widgets.Editor.UpdateWorkflow")],H);const D=H;export{D as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as A}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import M from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as S}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import U from"./UpdateWorkflowData.js";import j from"./Workflow.js";import{isUpdateRecordWorkflow as P,createWorkflowSteps as R,fetchCandidates as L}from"./workflowUtils.js";import{findUtilityNetwork as O,isGraphicForRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";var T;let H=T=class extends j{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits&&!a?.disabled){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new M,l=new T({data:new U({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t,i=!1){try{const a=await this._createNestedUpdateWorkflow(e,i,t);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=P(e);t?(e.stageDelete(),e.data.edits.feature===this.data.rootFeature&&this._removeRootFeatureFromCandidates()):await e.cancel(),this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=A([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=O(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const h=u?.generateDeleteAssociations([i]);if(!h)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=u?.gdbVersion??void 0;await r(c,[h],{gdbVersion:w,globalIdUsed:!0})}_removeRootFeatureFromCandidates(){const{candidates:e,rootFeature:t}=this.data;if(0===e.length||!t)return;const a=e.indexOf(t);a>-1&&e.splice(a,1)}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t,a){const i=C(e.sourceLayer)?V:E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,d="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,c=await i.create({association:a,feature:e,parent:d,sketchOptions:s,snappingManager:n,viewModel:l,readOnly:t,applyEdits:o,applyEditsFeatureService:r,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e,readOnly:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,void 0,t)),selectAssociatedFeature:async({feature:e,association:a})=>await this._updatingHandles.addPromise(this.startUpdating(e,a,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u(()=>!c.updating),c}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(const i of t){const t=e(i).finally(()=>i.destroy());this._updatingHandles.addPromise(t),a.push(t)}await Promise.all(a),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!x(t))return;const o=a.relationships?.find(e=>e.id===i);if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===i);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return R(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let s=null;e.addHandles(i(()=>{s=r(s)}),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer(()=>new Promise((e,t)=>{l(s?.signal,()=>t(d())),e(L(r,a,i,s?.signal))}));if(c(s),o.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)):e.next()}finally{r.resolve()}},F.TOOL),u=f(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:S});e.addHandles([h(()=>o.rootFeature,(e,t)=>{a.remove(t),a.add(e)},w),i(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=s(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&o()},w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){o.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],H.prototype,"activeEditorItem",null),e([v()],H.prototype,"activeFeatureFormViewModel",null),e([v()],H.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],H.prototype,"activeSketchViewModel",null),e([v()],H.prototype,"canDeleteAssociation",null),e([v()],H.prototype,"activeWorkflow",null),e([v()],H.prototype,"updating",null),e([v()],H.prototype,"data",void 0),e([v()],H.prototype,"hasPreviousStep",null),e([v()],H.prototype,"hasUpdatableCandidates",null),e([v()],H.prototype,"nestedWorkflowCount",null),e([v()],H.prototype,"shouldShowAttachments",null),e([v()],H.prototype,"shouldAllowAttachmentEditing",null),e([v()],H.prototype,"hasPendingEdits",null),e([v()],H.prototype,"helpMessage",null),e([v()],H.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],H.prototype,"hasInvalidFormTemplate",null),H=T=e([k("esri.widgets.Editor.UpdateWorkflow")],H);const D=H;export{D as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as a}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import C from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{to3D as G}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as W}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as Q}from"../../views/support/drapedUtils.js";import{filterGraphicHits as $,hitTestSelectSimilarDistance as J}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as H}from"./support/dependencySort.js";import{isDrawGraphicTool as K}from"../Sketch/support/sketchUtils.js";const X=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function Y(e){return!!e&&"features"in e}function _(e){return null!=e&&"create-features"===e.type}function ee(e){return null!=e&&"update-features"===e.type}function te(e){return null!=e&&/update-/.test(e.type)&&"fullFeature"in e}function re(e){return null!=e&&"update"===e.type}function ne(e){const t=e&&"renderer"in e?e.renderer:null;if(!ue(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===E(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function ae(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ue(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ne(t);let a=null,o=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;a=oe(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;o=le(n,r)}return{rotation:a,size:o}}function oe(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",a={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ce((a.current+360)%360,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function se(e,t,r){if(null==t)return 0;const{symbol:n}=G(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const a=n.symbolLayers.at(0);if(!a)return 0;switch(a.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Ke.icon,(await e(a,Ke.icon))[0])||Ke.icon}case"text":return Ke.text;case"line":return Ke.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(a,e.scale/Ke.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Ke.viewScaleSizeFactor;default:return 0}}function le(e,t){const r=e.axis,n=t?.type??"double",a={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>ce(i(await se(t,e,r)),n),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ce(a.current,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:_e(e.valueUnit),axis:e.axis}}function ce(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ue(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function pe(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,n)&&(e.symbol=n)}function de(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:W,optionsPerTool:r};if(T(t)){const a=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(a){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const a=t.drawingTool;if("circle"===a||"ellipse"===a)return r.get("circle").preserveAspectRatio="circle"===a,{tool:"circle",createOptions:n};if("rectangle"===a)return{tool:"rectangle",createOptions:n};if("freehand"===a)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function fe(e,t,r){const{creationInfo:n,fullTemplate:a}=t;if(!n)throw new i("featureworkflow","No creation info provided.");const o=n.layer,s=Me(a,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(a)||F(a)||await Oe(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=de(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function ye(e){return s([await me(e),await he(e)])}async function me({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:a}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||S(i)||F(i))return null;const s=f(t=>Oe(r,o.layer,e,a,t));return g(()=>n.scale,e=>s(e))}async function he({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:a}=t;if(!a)return null;const o=r.activeComponent;if(!n||!K(o))return X().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=a,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>o,["cursor-update","vertex-add"],()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!ge(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=be(e,d);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function ge(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function be(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new D({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new C({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function we(e,t){const r=await N(t).load(),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function ve(e,t){const r=await we(e,t);if(!r)return new Map;const n=new Map;for(const a of r.layersAndTables)d(n,a.layerId,()=>[]).push(a);return n}function Ie(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Te(e){const{edits:t,serviceInfo:n,view:a,findOriginalFeature:o}=e,i=Se(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Fe(t,i,o),p=ke(l,je(s,c),c);if(a&&Ve(l,p,a),0===p.length)return t;const d=H(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=Ie(e):h.id!==e.layerId&&(m.push(h),h=Ie(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??Ie(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Se(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function je(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ae(n,e),""),t.has(e.relatedTableId)){const a=t.get(e.relatedTableId);if(a.length>0)for(const t of a[0].layer.relationships??[])if(t.id===e.id){r.set(Ae(n,e),t.keyField);break}}return r}function Fe(e,t,r){const n=new Map,a=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:n}}function ke(e,t,r){const n=[];for(const a of e){const e=a.layer.relationships??[],{uniqueId:o}=a;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Ae(a.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(a.operationType){case"add":for(const t of s)t!==a&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===a.after.attributes[e]&&n.push([o,t.uniqueId]));break;case"modify":if(a.before.attributes[e]!==a.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==a&&("delete"===t.operationType?t.before.attributes[c]===a.before.attributes[e]?n.push([r,o]):t.before.attributes[c]===a.after.attributes[e]&&n.push([o,r]):"add"===t.operationType?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):t.after.attributes[c]===a.before.attributes[e]&&n.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):n.push([r,o]):n.push([o,r])))}break;case"delete":for(const t of s)t!==a&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===a.before.attributes[e]&&n.push([t.uniqueId,o]))}}}}return n}function Ae(e,t){return`${e.layerId}:${t.id}`}function Ue(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ve(e,t,r){const n=[];for(const o of e)Ue(o.layer,r)&&n.push(o);if(0===n.length)return;let a=[];for(const o of n){const r=o.layer;switch(o.operationType){case"delete":a=[...Le(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Le(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([o.uniqueId,e.uniqueId]);break;case"add":a=[...Le(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Le(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([e.uniqueId,o.uniqueId])}}}function Le(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const a of n){const t=a.layer.globalIdField;("before"in a&&a.before?.attributes[t]===e||"after"in a&&a.after?.attributes[t]===e)&&r.push(a)}return r}function Me(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Oe(e,r,n,a,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ae(i);let c=await B(i,{useSourceLayer:!0,webStyleCache:a,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(i,{useSourceLayer:!0,webStyleCache:a,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}xe(e.tooltipOptions,l,s)}function xe(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function ze(e,t){return e?.find(e=>e.layer===t)}async function qe(e,t,r,n){switch(t.type){case"3d":return Pe(e,t,r,n);case"2d":return Ee(e,t,r,n)}}async function Pe(e,t,r,n){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer(async()=>{const{results:a}=await h(J(t,r),n),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};$(a).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&o.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}});return h(Promise.allSettled(o.map(async({layer:e})=>{const t=i.get(e),r=Ce(e);if(t.every(e=>L(e,r)))return t;const o=[];for(const n of t){o.push(n.getObjectId());const e=Object.keys(n.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ee(e,t,r,n){if(0===e.length)return[];const{mapPoint:a}=r;if(null==a)return[];let o=null;const i=await r.defer(async()=>{const{results:a}=await h(t.hitTest(r),n);if(0===a.length)return[];const i=new Set;o=$(a),o.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Ce(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=Q(a,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return o?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Ce(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Re(e,t,n,a){const o=t.createQuery();o.objectIds=e.map(e=>e.getObjectId()).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=n);const i=await t.queryFeatures(o,{signal:a});return m(a),i.features}function De(e){const t=new Map;for(const r of e){const e=r.sourceLayer,n=x(e)?e.parent:e;d(t,n,()=>[]).push(r)}return t}async function Ge(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a}=e;await Be(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=a.rotation,o.enableScaling=null!=a.size),r.update(t,o)}async function Be(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=a;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await pe(t,o,e)}xe(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ne(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ze(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function We(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const a=t.attributes;let o=!1;const i=n.rotation,s=Ne(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==a[r]&&t.setAttribute(r,l),o=!0}}const l=n.size,c=Ze(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==a[r]&&t.setAttribute(r,i),o=!0}}return o}async function Qe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:a,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await pe(t,i,"2d"===a.type?a.scale:null);let d=null;if("2d"===n?.view?.type){const e=f(e=>pe(t,i,e));d=g(()=>n?.view?.scale,t=>e(t))}const y=t.sourceLayer,m=rt(a,y);await Ge({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then(e=>h=e).catch(()=>{});const b=r.size,v=r.rotation,I=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const a=e[n];a!==t.getAttribute(n)&&(t.setAttribute(n,a),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(a),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(a),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await pe(t,i,"2d"===a.type?a.scale:null)}),T=n.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===a.activeTool)return Ge(s);const e=new AbortController,t=c(e);return p(t),u(w(()=>null===a.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),Ge(s)}))}We(a,t,e,r)&&await pe(t,i,"2d"===a.type?a.scale:null),o(at(t),e)}),S=n.on(["undo","redo"],async e=>{o(at(e.graphics[0]),e)});return s([S,T,l(()=>n.cancel()),I,d])}async function $e(e,t,r){const n=e.view;e.layer.add(r);const a=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o(async t=>{const r=await rt(n,a);m(t),r.setVisibility?.(c,e)})}return await He(n,r),p(!1),s([Je(n,r,e=>p(!e)),l(async()=>{p(!0);try{if(!n.destroyed){const e=await rt(n,a).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.layer.remove(r)}})])}function Je(e,t,r){if("3d"===e.type){const n=new Z({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function He(e,t){if("3d"===e.type){const r=new Z({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const Ke={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Xe(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function Ye(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,a=e.viewModel.getTemplatesForLayer(n);1===a.length&&"scene"!==n.type&&(r.template=a[0],t.shift())}return t}function _e(e){return"unknown"===e?null:e}function et(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const tt=e=>/-stop/.test(e)||/vertex-/.test(e),rt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function nt(e){return"createInteractiveEditSession"in e}function at(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ot(e){return e.acquireCursor("progress")}async function it(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),a=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===a.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return a[0].load()}return r}function st(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:a}=t;e.setAttribute(r,n.getAttribute(a))}}function lt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>st(e.relationships)),t.flatMap(e=>e.edits)):null}function ct(e){if(null==e)return[];if(ee(e))return e.data.layers;const t=re(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}function ut(){return new i("editing:multiple-layers-not-supported","UpdateFeaturesWorkflow does not support updating features from multiple layers.")}export{Ve as appendAllUtilityNetworkAssociationRelationships,Ye as avoidFeatureTemplateSelectionWithOnlyOneItem,nt as canCreateInteractiveEditSession,at as cloneGraphicExceptMesh,Se as createLayerIdMap,je as createRelationshipKeyMap,de as createToolFromGeometryType,Xe as createWorkflowSteps,qe as fetchCandidates,Re as fetchFullFeatures,ke as findAllDependencies,Le as findChangesByGlobalId,ze as findLayerInfo,Ae as generateHashForRelationship,Me as getCreationAttributes,it as getFullTemplateForCreationInfo,ct as getLayersFromWorkflow,oe as getRotationVariableAttribute,lt as getServiceEditsFromWorkflowData,we as getServiceInfoForLayer,ve as getServiceLayersById,le as getSizeVariableAttribute,ae as getVisualVariableAttributes,ne as getVisualVariablesForLayer,De as groupFeaturesByLayer,Y as isBatchAttributeFormViewModel,_ as isCreateFeaturesWorkflow,tt as isTerminalUpdateEventType,ee as isUpdateFeaturesWorkflow,te as isUpdateRecordWorkflow,re as isUpdateWorkflow,Ue as isUtilityNetworkAssociationsTable,ut as makeMultipleSourceLayersError,Te as orderEditsByRelationshipDependencies,et as prepareAttachmentsForCreateFeaturesWorkflow,st as setRelationshipFields,Qe as setUpGeometryUpdate,ye as setUpSketchCreateWatchers,Be as setVisualVariablesAndElevationInfoForUpdate,ot as showProgressCursor,Ke as sizeDefaults,_e as sizeVariableUnitToLengthUnit,fe as startCreatingNewFeature,Ge as startUpdatingFeatureGeometry,$e as swapForEditingSession,pe as updateGraphicSymbolWhenRequired,We as visualVariableInteractiveUpdate,rt as whenEditorLayerView,He as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import C from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{to3D as G}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as W}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as Q}from"../../views/support/drapedUtils.js";import{filterGraphicHits as $,hitTestSelectSimilarDistance as J}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as H}from"./support/dependencySort.js";import{isDrawGraphicTool as K}from"../Sketch/support/sketchUtils.js";const X=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function Y(e){return!!e&&"features"in e}function _(e){return null!=e&&"create-features"===e.type}function ee(e){return null!=e&&"update-features"===e.type}function te(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function re(e){return null!=e&&"update"===e.type}function ne(e){const t=e&&"renderer"in e?e.renderer:null;if(!ue(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===E(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function oe(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ue(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ne(t);let o=null,a=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=ae(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=le(n,r)}return{rotation:o,size:a}}function ae(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,ce((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function se(e,t,r){if(null==t)return 0;const{symbol:n}=G(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Ke.icon,(await e(o,Ke.icon))[0])||Ke.icon}case"text":return Ke.text;case"line":return Ke.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(o,e.scale/Ke.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Ke.viewScaleSizeFactor;default:return 0}}function le(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},a=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*a/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*a/2:e=>e*a,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>ce(i(await se(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,ce(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:_e(e.valueUnit),axis:e.axis}}function ce(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ue(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function pe(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,n)&&(e.symbol=n)}function de(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:W,optionsPerTool:r};if(T(t)){const o=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function fe(e,t,r){const{creationInfo:n,fullTemplate:o}=t;if(!n)throw new i("featureworkflow","No creation info provided.");const a=n.layer,s=Me(o,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(o)||F(o)||await Oe(e,a,s,r,c?l.scale:null);const{capabilities:u}=a;e.layer.elevationInfo=a.elevationInfo;const p=de(a.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}})}async function ye(e){return s([me(e),he(e)])}function me({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:a}=t,{fullTemplate:i}=t;if(!a||"2d"!==n?.type||S(i)||F(i))return null;const s=f(t=>Oe(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function he({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!K(a))return X().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>a,["cursor-update","vertex-add"],()=>{c.removeAll();const e=a.graphic?.geometry;if(!e||!ge(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=be(e,d);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function ge(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function be(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new D({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new C({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function we(e,t){const r=await N(t).load(),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function ve(e,t){const r=await we(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)d(n,o.layerId,()=>[]).push(o);return n}function Ie(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Te(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=Se(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Fe(t,i,a),p=ke(l,je(s,c),c);if(o&&Ve(l,p,o),0===p.length)return t;const d=H(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=Ie(e):h.id!==e.layerId&&(m.push(h),h=Ie(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??Ie(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Se(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function je(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ae(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Ae(n,e),t.keyField);break}}return r}function Fe(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function ke(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:a}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Ae(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([a,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,a]):t.before.attributes[c]===o.after.attributes[e]&&n.push([a,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,a]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):n.push([r,a]):n.push([a,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,a]))}}}}return n}function Ae(e,t){return`${e.layerId}:${t.id}`}function Ue(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ve(e,t,r){const n=[];for(const a of e)Ue(a.layer,r)&&n.push(a);if(0===n.length)return;let o=[];for(const a of n){const r=a.layer;switch(a.operationType){case"delete":o=[...Le(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Le(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Le(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Le(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Le(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function Me(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Oe(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=oe(i);let c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}xe(e.tooltipOptions,l,s)}function xe(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function ze(e,t){return e?.find(e=>e.layer===t)}async function qe(e,t,r,n){switch(t.type){case"3d":return Pe(e,t,r,n);case"2d":return Ee(e,t,r,n)}}async function Pe(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(J(t,r),n),a=new Map,i=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};$(o).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return h(Promise.allSettled(a.map(async({layer:e})=>{const t=i.get(e),r=Ce(e);if(t.every(e=>L(e,r)))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ee(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let a=null;const i=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const i=new Set;a=$(o),a.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Ce(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=Q(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return a?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Ce(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Re(e,t,n,o){const a=t.createQuery();a.objectIds=e.map(e=>e.getObjectId()).filter(r),a.outFields=["*"],a.returnM=t.capabilities.data.supportsM,a.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(a.outSpatialReference=n);const i=await t.queryFeatures(a,{signal:o});return m(o),i.features}function De(e){const t=new Map;for(const r of e){const e=r.sourceLayer,n=x(e)?e.parent:e;d(t,n,()=>[]).push(r)}return t}async function Ge(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await Be(e);const a={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(a.enableRotation=null!=o.rotation,a.enableScaling=null!=o.size),r.update(t,a)}async function Be(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o,webStyleCache:a}=e;let i=!1;const{rotation:s,size:l}=o;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await pe(t,a,e)}xe(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ne(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ze(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function We(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let a=!1;const i=n.rotation,s=Ne(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),a=!0}}const l=n.size,c=Ze(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==o[r]&&t.setAttribute(r,i),a=!0}}return a}async function Qe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:o,onUpdate:a,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await pe(t,i,"2d"===o.type?o.scale:null);let d=null;if("2d"===n?.view?.type){const e=f(e=>pe(t,i,e));d=g(()=>n?.view?.scale,t=>e(t))}const y=t.sourceLayer,m=rt(o,y);await Ge({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then(e=>h=e).catch(()=>{});const b=r.size,v=r.rotation,I=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await pe(t,i,"2d"===o.type?o.scale:null)}),T=n.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===o.activeTool)return Ge(s);const e=new AbortController,t=c(e);return p(t),u(w(()=>null===o.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),Ge(s)}))}We(o,t,e,r)&&await pe(t,i,"2d"===o.type?o.scale:null),a(ot(t),e)}),S=n.on(["undo","redo"],e=>{a(ot(e.graphics[0]),e)});return s([S,T,l(()=>n.cancel()),I,d])}async function $e(e,t,r){const n=e.view;e.layer.add(r);const o=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=a(async t=>{const r=await rt(n,o);m(t),r.setVisibility?.(c,e)})}return await He(n,r),p(!1),s([Je(n,r,e=>p(!e)),l(async()=>{p(!0);try{if(!n.destroyed){const e=await rt(n,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.layer.remove(r)}})])}function Je(e,t,r){if("3d"===e.type){const n=new Z({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function He(e,t){if("3d"===e.type){const r=new Z({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const Ke={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Xe(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function Ye(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function _e(e){return"unknown"===e?null:e}function et(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const tt=e=>e.includes("-stop")||e.includes("vertex-"),rt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function nt(e){return"createInteractiveEditSession"in e}function ot(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function at(e){return e.acquireCursor("progress")}async function it(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function st(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function lt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>st(e.relationships)),t.flatMap(e=>e.edits)):null}function ct(e){if(null==e)return[];if(ee(e))return e.data.layers;const t=re(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}function ut(){return new i("editing:multiple-layers-not-supported","UpdateFeaturesWorkflow does not support updating features from multiple layers.")}export{Ve as appendAllUtilityNetworkAssociationRelationships,Ye as avoidFeatureTemplateSelectionWithOnlyOneItem,nt as canCreateInteractiveEditSession,ot as cloneGraphicExceptMesh,Se as createLayerIdMap,je as createRelationshipKeyMap,de as createToolFromGeometryType,Xe as createWorkflowSteps,qe as fetchCandidates,Re as fetchFullFeatures,ke as findAllDependencies,Le as findChangesByGlobalId,ze as findLayerInfo,Ae as generateHashForRelationship,Me as getCreationAttributes,it as getFullTemplateForCreationInfo,ct as getLayersFromWorkflow,ae as getRotationVariableAttribute,lt as getServiceEditsFromWorkflowData,we as getServiceInfoForLayer,ve as getServiceLayersById,le as getSizeVariableAttribute,oe as getVisualVariableAttributes,ne as getVisualVariablesForLayer,De as groupFeaturesByLayer,Y as isBatchAttributeFormViewModel,_ as isCreateFeaturesWorkflow,tt as isTerminalUpdateEventType,ee as isUpdateFeaturesWorkflow,te as isUpdateRecordWorkflow,re as isUpdateWorkflow,Ue as isUtilityNetworkAssociationsTable,ut as makeMultipleSourceLayersError,Te as orderEditsByRelationshipDependencies,et as prepareAttachmentsForCreateFeaturesWorkflow,st as setRelationshipFields,Qe as setUpGeometryUpdate,ye as setUpSketchCreateWatchers,Be as setVisualVariablesAndElevationInfoForUpdate,at as showProgressCursor,Ke as sizeDefaults,_e as sizeVariableUnitToLengthUnit,fe as startCreatingNewFeature,Ge as startUpdatingFeatureGeometry,$e as swapForEditingSession,pe as updateGraphicSymbolWhenRequired,We as visualVariableInteractiveUpdate,rt as whenEditorLayerView,He as whenGraphicDisplayed};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import{handlesGroup as i}from"../../core/handleUtils.js";import{abortMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import{handlesGroup as i}from"../../core/handleUtils.js";import{abortMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{throwIfAborted as l,throwIfAbortError as a}from"../../core/promiseUtils.js";import{watch as n,syncAndInitial as p}from"../../core/reactiveUtils.js";import{throttle as m}from"../../core/throttle.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{hasGraphicFeatureExpressionInfo as u,getGraphicEffectiveElevationInfo as f}from"../../support/elevationInfoUtils.js";import{getConfig as c}from"./support/constants.js";import{isPolyline as _,isValidInputPath as P}from"./support/geometryUtils.js";import{generateProfiles as v}from"./support/profileUtils.js";const g=Symbol("line-change");let M=class extends t{constructor(e){super(e),this._updateTask=null,this._paramsPerProfile=new Map,this._getUpdateParametersMemoized=s((e,t,o)=>({stationary:e,visibleProfiles:t,generationParameters:o})),this._getGenerationParametersMemoized=s((e,t,o,i,r,s,l)=>_(t)&&P(t)&&null!=i?{view:e,geometry:t,elevationInfo:o,options:s,queue:i,cache:r,slicePlane:l}:null),this._getElevationInfoMemoized=s((e,t)=>({mode:e,offset:t})),this._getOptionsMemoized=s((e,t)=>{const{densificationMaxSamples:o,maxTotalSamples:i}=c();return{samplingDistance:e,densificationMaxSamples:Math.round(o/t),maxTotalSamples:i}}),this._updateThrottled=m(e=>this._update(e),c().updateThrottleMillis)}initialize(){const e=this.viewModel;this.addHandles([n(()=>({visible:e.visible,profiles:e.profiles.toArray()}),({visible:e,profiles:t})=>{this._abortUpdate(),this._paramsPerProfile.clear(),this.removeHandles(g),e&&0!==t.length&&this.addHandles([...t.map(e=>i([e.attach(this.viewModel),e.on("change",()=>{this._invalidateProfile(e)})])),n(()=>this._updateParameters,this._updateThrottled,p),this._updateThrottled],g)},p)])}destroy(){this._paramsPerProfile.clear()}get _updateParameters(){const{viewModel:e}=this,t=e.view;return this._getUpdateParametersMemoized(null==t||t.stationary,this.viewModel.visibleProfiles,this._generationParameters)}get _generationParameters(){const{view:e,input:t,queue:o,tileCache:i}=this.viewModel;return null!=e&&e.ready?this._getGenerationParametersMemoized(e,t?.geometry,this._elevationInfo,o,i,this._options,"3d"===e.type?e.slice.plane:null):null}get _elevationInfo(){const e=this.viewModel.input,t=e?u(e)?null:f(e):null;return null!=t?this._getElevationInfoMemoized(t.mode,t.offset):null}get _options(){const e=this.viewModel,t=e.visibleProfiles.length;let o=e.minDemResolution??c().defaultDemResolution;return o=parseFloat(o.toFixed(2)),this._getOptionsMemoized(o,t)}_update({stationary:e,visibleProfiles:t,generationParameters:i}){this._abortUpdate(),e&&(null!=i?this._updateTask=o(async e=>{this.viewModel.error=null;const o=t.filter(e=>!this._isProfileValid(e,i)),r=v({...i,providers:o},{signal:e});try{for await(const t of r){l(e),this._clearInvalidResults(i);for(let e=0;e<o.length;e++)o[e].result=t[e]}for(const e of o)this._paramsPerProfile.set(e,i)}catch(s){a(s),this._abortUpdate(),this.viewModel.error=s,o.forEach(e=>{e.result=null})}}):this._clearResults())}_abortUpdate(){this._updateTask=r(this._updateTask)}_isProfileValid(e,t){return this._paramsPerProfile.has(e)&&this._paramsPerProfile.get(e)===t}_invalidateProfile(e){this._paramsPerProfile.delete(e),this._updateThrottled(this._updateParameters)}_clearInvalidResults(e){for(const t of this.viewModel.profiles.items)this._isProfileValid(t,e)||(t.result=null,this._paramsPerProfile.delete(t))}_clearResults(){for(const e of this.viewModel.profiles.items)e.result=null,this._paramsPerProfile.delete(e)}};e([d({nonNullable:!0})],M.prototype,"viewModel",void 0),e([d()],M.prototype,"_updateParameters",null),e([d()],M.prototype,"_generationParameters",null),e([d()],M.prototype,"_elevationInfo",null),e([d()],M.prototype,"_options",null),M=e([h("esri.widgets.ElevationProfile.ElevationProfileController")],M);export{M as ElevationProfileController};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,on as r,initial as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as _}from"../support/jsxFactory.js";import{substitute as f}from"../../intl/substitute.js";import{formatNumber as g}from"../../intl/number.js";var b;const y="esri-feature",I=`${y}-relationship`,F={base:I,listContainer:`${I}__list`,listItem:`${I}__list-item`,listItemHidden:`${I}__list-item--hidden`,listContainerQuerying:`${I}__list--querying`,featureObserver:`${y}__feature-observer`,stickySpinnerContainer:`${y}__sticky-loading-container`,loadingSpinnerContainer:`${y}__loading-container`},C={title:!0,description:!0};let M=b=class extends c{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this.flowItems=null,this.flowType="feature-relationship",this.headingLevel=2,this.viewModel=new u,this.messages=null,this.messagesCommon=null,this.visibleElements={...C},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new h,this.addHandles([i(()=>[this.viewModel.description,this.viewModel.title,this.headingLevel],()=>this._setupFeatureElementInfo(),o),i(()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode],()=>this._handleRelatedFeatureObserverChange()),r(()=>this.viewModel.relatedFeatureViewModels,"change",()=>this._setupRelatedFeatureViewModels())])}loadDependencies(){return p({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i,allCategoriesCount:r}=this.viewModel;return!e&&"ready"===i&&(!!r&&(r>s||0===s)||!!t&&(t>s||0===s))}get displayListItems(){const{relatedFeatureViewModels:e,allCategoriesCount:t}=this.viewModel;return this.displayShowAllButton||!!e.length||!!t}get allItemsDescription(){const{messages:e}=this,{featureCount:t,allCategories:s,allCategoriesCount:i}=this.viewModel;return f(e?.numberRecords,{number:g(s?i:t)})}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){const{activeCategory:e,title:t}=this.viewModel;return e?.name??t}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...C,...e}}render(){const{state:e}=this.viewModel;return _("div",{class:this.classes(F.base,m.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderRelationshipNotFound():this._renderRelatedFeatures())}
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,on as r,initial as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as _}from"../support/jsxFactory.js";import{substitute as f}from"../../intl/substitute.js";import{formatNumber as g}from"../../intl/number.js";var b;const y="esri-feature",I=`${y}-relationship`,F={base:I,listContainer:`${I}__list`,listItem:`${I}__list-item`,listItemHidden:`${I}__list-item--hidden`,listContainerQuerying:`${I}__list--querying`,featureObserver:`${y}__feature-observer`,stickySpinnerContainer:`${y}__sticky-loading-container`,loadingSpinnerContainer:`${y}__loading-container`},C={title:!0,description:!0};let M=b=class extends c{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this.flowItems=null,this.flowType="feature-relationship",this.headingLevel=2,this.viewModel=new u,this.messages=null,this.messagesCommon=null,this.visibleElements={...C},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new h,this.addHandles([i(()=>[this.viewModel.description,this.viewModel.title,this.headingLevel],()=>this._setupFeatureElementInfo(),o),i(()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode],()=>this._handleRelatedFeatureObserverChange()),r(()=>this.viewModel.relatedFeatureViewModels,"change",()=>this._setupRelatedFeatureViewModels())])}loadDependencies(){return p({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i,allCategoriesCount:r}=this.viewModel;return!e&&"ready"===i&&(!!r&&(r>s||0===s)||!!t&&(t>s||0===s))}get displayListItems(){const{relatedFeatureViewModels:e,allCategoriesCount:t}=this.viewModel;return this.displayShowAllButton||!!e.length||!!t}get allItemsDescription(){const{messages:e}=this,{featureCount:t,allCategories:s,allCategoriesCount:i}=this.viewModel;return f(e?.numberRecords,{number:g(s?i:t)})}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){const{activeCategory:e,title:t}=this.viewModel;return e?.name??t}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...C,...e}}render(){const{state:e}=this.viewModel;return _("div",{class:this.classes(F.base,m.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderRelationshipNotFound():this._renderRelatedFeatures())}_selectCategory(e){const{flowItems:t,featureVisibleElements:s,viewModel:i}=this;t&&(i.activeCategory=e,i.showAllEnabled=!0,t.push(new b({flowItems:t,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:i})))}async _selectRecord(e){const{flowItems:t,featureVisibleElements:s}=this;if(!t)return;e.abilities={relationshipContent:!0};const{default:i}=await import("../Feature.js");t.push(new i({flowItems:t,flowType:this.flowType,viewModel:e,visibleElements:s}))}_showAllRecords(){const{flowItems:e}=this;if(!e)return;const{viewModel:t,featureVisibleElements:s}=this;t.showAllEnabled=!0;const i=new b({flowItems:e,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:t});e.push(i)}_renderStickyLoading(){return"querying"===this.viewModel.state?_("div",{class:F.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return _("calcite-loader",{inline:!0,label:""})}_renderLoading(){return _("div",{class:F.loadingSpinnerContainer,key:"loading-container"},this._renderLoadingIcon())}_renderShowAllIconNode(){return _("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})}_renderChevronIconNode(){const e=v(this.container)?"chevron-left":"chevron-right";return _("calcite-icon",{icon:e,scale:"s",slot:"content-end"})}_renderCategory(e){const{count:t,name:s,value:i}=e,r=g(t);return _("calcite-list-item",{class:F.listItem,disabled:!t,key:i,label:s,onCalciteListItemSelect:()=>this._selectCategory(e)},_("calcite-chip",{label:r,scale:"s",slot:"content-end"},r),this._renderChevronIconNode())}_renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return _("calcite-list-item",{class:this.classes(F.listItem,{[F.listItemHidden]:i}),description:n(e.description??""),key:e.uid,label:n(s),onCalciteListItemSelect:()=>this._selectRecord(e)},this._renderChevronIconNode())}_renderShowAllListItem(){return this.displayShowAllButton?_("calcite-list-item",{description:this.allItemsDescription,key:"show-all-item",label:this.messages?.showAll,onCalciteListItemSelect:()=>this._showAllRecords()},this._renderShowAllIconNode()):null}_renderNoRelatedFeaturesMessage(){return _("calcite-notice",{icon:"information",key:"no-related-features-message",kind:"brand",open:!0,scale:"s",width:"full"},_("div",{slot:"message"},this.messages?.noRelatedFeatures))}_renderFeatureObserver(){return _("div",{afterCreate:this._relatedFeatureIntersectionObserverCreated,bind:this,class:F.featureObserver,key:"feature-observer"})}_renderList(){const{relatedFeatureViewModels:e,categories:t}=this.viewModel;return _("calcite-list",{displayMode:"flat",label:this.messages?.relatedFeaturesList},t?.map(e=>this._renderCategory(e))??e.toArray().map(e=>this._renderRelatedFeature(e)),this._renderShowAllListItem())}_renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return _("div",{class:this.classes(F.listContainer,{[F.listContainerQuerying]:"querying"===t}),key:"list-container"},e?this._renderList():"ready"===t?this._renderNoRelatedFeaturesMessage():null,this._renderStickyLoading(),this._renderFeatureObserver())}_renderRelationshipNotFound(){return _("calcite-notice",{icon:"exclamation-mark-triangle",key:"relationship-not-found",kind:"danger",open:!0,scale:"s",width:"full"},_("div",{slot:"message"},this.messages?.relationshipNotFound))}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach(e=>{this.addHandles(i(()=>[e.title,e.state],()=>this.scheduleRender(),o),t)}),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([l()],M.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([l({readOnly:!0})],M.prototype,"displayShowAllButton",null),e([l({readOnly:!0})],M.prototype,"displayListItems",null),e([l({readOnly:!0})],M.prototype,"allItemsDescription",null),e([l()],M.prototype,"description",null),e([l()],M.prototype,"featureVisibleElements",void 0),e([l()],M.prototype,"flowItems",void 0),e([l()],M.prototype,"flowType",void 0),e([l()],M.prototype,"headingLevel",void 0),e([l()],M.prototype,"title",null),e([l({type:u})],M.prototype,"viewModel",void 0),e([l(),w("esri/widgets/Feature/t9n/Feature")],M.prototype,"messages",void 0),e([l(),w("esri/t9n/common")],M.prototype,"messagesCommon",void 0),e([l()],M.prototype,"visibleElements",void 0),e([a("visibleElements")],M.prototype,"castVisibleElements",null),M=b=e([d("esri.widgets.Feature.FeatureRelationship")],M);export{M as default};
|