@arcgis/core 4.27.0-rc.2 → 4.27.0-rc.4
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/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
- package/assets/esri/core/workers/chunks/09e677ca7532a281d262.js +1 -0
- package/assets/esri/core/workers/chunks/0f7ddb063ee0664f2fca.js +1 -0
- package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +1 -0
- package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
- package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
- package/assets/esri/core/workers/chunks/{2446e336b1f7256d4fde.js → 2c587ed66e2586cccb8d.js} +1 -1
- package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
- package/assets/esri/core/workers/chunks/{00c7b9fb375c9a934158.js → 38c6452dc9cf18e8bca8.js} +1 -1
- package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
- package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
- package/assets/esri/core/workers/chunks/{16db0bc87d87a7313dc4.js → 4806df402845c717c842.js} +1 -1
- package/assets/esri/core/workers/chunks/4884432d80e9af947449.js +1 -0
- package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
- package/assets/esri/core/workers/chunks/588cd91d08cec5207be1.js +1 -0
- package/assets/esri/core/workers/chunks/{83e3d104886b48f00397.js → 633c00c02a81397fc8df.js} +1 -1
- package/assets/esri/core/workers/chunks/{efb96aefe979a0f5c632.js → 640e8ac3498be30c6614.js} +1 -1
- package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
- package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{33901eb1574e46abd9af.js → 6c213768715c52625855.js} +1 -1
- package/assets/esri/core/workers/chunks/{5e6471dd2a08e66b47d0.js → 6e4940fe3bba014c921b.js} +57 -58
- package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
- package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 6f724f75f85dc3989d60.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
- package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
- package/assets/esri/core/workers/chunks/8b05fb365336cc42fecc.js +1 -0
- package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
- package/assets/esri/core/workers/chunks/8eec6da5e862cc33ea2b.js +1 -0
- package/assets/esri/core/workers/chunks/90d8f297d9cb359e071d.js +1 -0
- package/assets/esri/core/workers/chunks/91785144901dfe56c5e2.js +1 -0
- package/assets/esri/core/workers/chunks/{471f6eba213412b82840.js → 927417abea79c955b216.js} +1 -1
- package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
- package/assets/esri/core/workers/chunks/{adaa9d4239f4e905d011.js → 9d4bd73dd50400e9d328.js} +1 -1
- package/assets/esri/core/workers/chunks/a324cc07d486061d0d8e.js +1 -0
- package/assets/esri/core/workers/chunks/a40130579791293cefa2.js +1 -0
- package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → a49718c74053314ed741.js} +1 -1
- package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
- package/assets/esri/core/workers/chunks/ad2891985e0fe45aa8d2.js +1 -0
- package/assets/esri/core/workers/chunks/afcba35eea836aea98ca.js +1 -0
- package/assets/esri/core/workers/chunks/b3d2e397ea74ebef4423.js +1 -0
- package/assets/esri/core/workers/chunks/b5fb9da45cc9dee286f8.js +1 -0
- package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
- package/assets/esri/core/workers/chunks/b846d4215210aac9f6ef.js +1 -0
- package/assets/esri/core/workers/chunks/c7dc821db8c14fec24a7.js +1 -0
- package/assets/esri/core/workers/chunks/c9df9a0a4a45f9a53ce9.js +1 -0
- package/assets/esri/core/workers/chunks/{45a4041881e6235d73a2.js → d0a9711f48dfa5fee68a.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f69fb9687de9ebfcf90.js → d4ba894a2583f3930a4f.js} +1 -1
- package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
- package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
- package/assets/esri/core/workers/chunks/e23ec4f867c4735eec20.js +1 -0
- package/assets/esri/core/workers/chunks/ea16230a0edfc9f756bd.js +1 -0
- package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
- package/assets/esri/core/workers/chunks/ef900614353505afb210.js +1 -0
- package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
- package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
- package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
- package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
- package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
- package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
- package/assets/esri/themes/base/_View.scss +2 -5
- package/assets/esri/themes/base/widgets/_Feature.scss +12 -4
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/DefaultMaterial.glsl.js +42 -42
- package/chunks/Terrain.glsl.js +7 -7
- package/copyright.txt +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/geometry/support/meshUtils/bounds.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +87 -3
- package/kernel.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/graphics/sources/support/uploadAssets.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/core/bestImageUtils.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/capabilities.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +5 -0
- package/layers/video/VideoController.js +1 -1
- package/layers/video/videoUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/request.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/labels/bins.js +5 -0
- package/smartMapping/labels/clusters.js +1 -1
- package/smartMapping/labels/support/utils.js +5 -0
- package/smartMapping/support/binningUtils.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SClientMaterialUtil.js +5 -0
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +19 -20
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +9 -9
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/ui/DefaultUI.js +1 -1
- package/views/ui/UI.js +1 -1
- package/webmap/initialViewPropertiesUtils.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/RelationshipInput.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
- package/widgets/support/geolocationUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +0 -1
- package/assets/esri/core/workers/chunks/0618fb0058f39ecd363f.js +0 -1
- package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
- package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
- package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
- package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +0 -1
- package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
- package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
- package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +0 -1
- package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
- package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +0 -1
- package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +0 -1
- package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +0 -1
- package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
- package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
- package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
- package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
- package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
- package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +0 -1
- package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
- package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +0 -1
- package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
- package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
- package/assets/esri/core/workers/chunks/c96db6b7ce47bd343fdb.js +0 -1
- package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
- package/assets/esri/core/workers/chunks/d95ca50ca7af4c222036.js +0 -1
- package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +0 -1
- package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +0 -1
- package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
- package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
- package/assets/esri/core/workers/chunks/f720967ba8c5486a26a2.js +0 -1
- package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
- package/layers/orientedImagery/core/Affixes.js +0 -5
- package/layers/orientedImagery/core/CameraProperties.js +0 -5
- package/layers/orientedImagery/core/ImageProperties.js +0 -5
- package/layers/orientedImagery/core/ImageryTypes.js +0 -5
- package/layers/orientedImagery/core/imageryUtils.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({element:a,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const i="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o}=this.arcadeContextInfo,a="feature"===t?.type?t:"scene"===t?.type&&null!=t.associatedLayer?t.associatedLayer:void 0;return[{$originalfeature:r,$editcontext:{editType:e},$layer:a,$featureset:a,$datastore:t?.url,$map:s},{spatialReference:o??void 0}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(i))return this._evaluate([...this._fieldReferencesLookup.get(i)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:r}=this,o=new Map(this.fieldInputs.map((e=>[e.name,e]))),a=new Map(r.map((e=>[e,new Array])));for(const n of r){for(const r of n.fieldsUsed){s(e,r,(()=>new Set)).add(n);const i=o.get(r),
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const i="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o}=this.arcadeContextInfo,a="feature"===t?.type?t:"scene"===t?.type&&null!=t.associatedLayer?t.associatedLayer:void 0;return[{$originalfeature:r,$editcontext:{editType:e},$layer:a,$featureset:a,$datastore:t?.url,$map:s},{spatialReference:o??void 0}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(i))return this._evaluate([...this._fieldReferencesLookup.get(i)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:r}=this,o=new Map(this.fieldInputs.map((e=>[e.name,e]))),a=new Map(r.map((e=>[e,new Array])));for(const n of r){for(const r of n.fieldsUsed){s(e,r,(()=>new Set)).add(n);const i=o.get(r),l=i?.valueExpressionExecutor,c=i?.editableExpressionExecutor;if(null!=l&&l!==n){a.get(l).push(n);s(t,l,(()=>new Set)).add(i)}if(null!=c&&c!==n){a.get(c).push(n);s(t,c,(()=>new Set)).add(i)}}if(n.geometryUsed){s(e,i,(()=>new Set)).add(n)}}return a}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:a}=this;for(const r of e)u(r,t,s);for(const[i,{resolver:l,dependencyPromises:c}]of t){Promise.all(c).then((async()=>{const[e,t]=this._makeContext(a);return i.executeAsync(e,t)})).then((()=>{if(o.has(i))for(const e of o.get(i))this._latestFieldValues[e.name]=e.value;l.resolve()}),(e=>{!e||r(e)||p(e)||i.markStale(),l.reject(e)}))}const n=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(r(e.reason)||p(e.reason))));if(n.length>0)throw new AggregateError(n,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([a()],c.prototype,"_baseContext",null),e([a()],c.prototype,"feature",null),e([a()],c.prototype,"executors",void 0),e([a()],c.prototype,"fieldInputs",void 0),e([a()],c.prototype,"arcadeContextInfo",void 0),c=e([n(l)],c);const u=(e,t,s)=>{if(t.has(e))return;const r=o();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const a=s.get(e);for(const o of a)u(o,t,s),t.get(o).dependencyPromises.push(r.promise)},p=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{c as FormExpressionsManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../layers/support/layerUtils.js";import l from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as a}from"../Feature/support/featureUtils.js";import n from"./EditableInput.js";const p=3;let u=class extends n{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship||!this.loaded)return!1;const{cardinality:s,role:i}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===i&&t>0)&&e))}get displayCount(){return this.element.displayCount??p}get displayType(){return this.element.displayType}get editable(){if(!this.layerAllowsEdits)return!1;const{_relationshipVM:e,relatedLayer:t}=this;if(!e?.relationship)return!1;const{cardinality:r}=e.relationship;return"many-to-many"!==r&&(!(t&&!o(t))&&(this.evaluatedEditableExpression??!0))}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}get loaded(){return"ready"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:i,map:o,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;a(s)&&(this._relationshipVM=new l({graphic:t,displayCount:i,layer:s,map:o,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],u.prototype,"canAddRelatedFeature",null),e([s()],u.prototype,"displayCount",null),e([s()],u.prototype,"displayType",null),e([s()],u.prototype,"editable",null),e([s()],u.prototype,"group",void 0),e([s()],u.prototype,"map",null),e([s()],u.prototype,"orderByFields",null),e([s()],u.prototype,"relationshipId",null),e([s()],u.prototype,"relatedFeatureInfos",null),e([s()],u.prototype,"relatedLayer",null),e([s()],u.prototype,"showAllEnabled",null),e([s()],u.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],u.prototype,"type",void 0),e([s()],u.prototype,"updating",null),e([s()],u.prototype,"incrementPage",null),e([s()],u.prototype,"getRelatedFeatureByObjectId",null),u=e([i("esri.widgets.FeatureForm.RelationshipInput")],u);const h=u;export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-feature-form",i=`${e}__group`,
|
|
5
|
+
const e="esri-feature-form",i=`${e}__group`,r=`${e}__input`,t=`${e}__related-records`,a={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,relationshipLabel:`${e}__relationship-label`,fieldInputWrapper:`${r}-wrapper`,fieldInputLoader:`${r}-loader`,fieldInput:`${r}`,inputDate:`${r}--date`,inputTime:`${r}--time`,inputRadioGroup:`${r}--radio-group`,inputRadio:`${r}--radio`,inputRadioLabel:`${r}--radio-label`,inputDisabled:`${r}--disabled`,inputSwitch:`${r}--switch`,inputInvalid:`${r}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordsHeader:`${t}_header`,relatedRecordsList:`${t}_list`,dateInputContainer:`${`${e}__date`}-input-container`,group:i,groupLabel:`${i}-label`,groupHeader:`${i}-header`,groupTitle:`${i}-title`,groupToggleIcon:`${i}-toggle-icon`,groupCollapsed:`${i}--collapsed`,groupSequential:`${i}--sequential`,groupActive:`${i}--active`,collapseIcon:"esri-icon-up",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input"};export{a as CSS};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{neverReached as i}from"../core/compilerUtils.js";import{deprecatedProperty as l}from"../core/deprecate.js";import s from"../core/Logger.js";import{watch as a}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupInput as u,isFieldInput as c,isRelationshipInput as p,isInputInGroupInput as m,isFieldElementWithInputType as h,formatDateFieldValue as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as R}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{DateTime as V}from"luxon";import{substitute as M}from"../intl/substitute.js";import{getLocale as D}from"../intl/locale.js";const O="TT",k="data-field-name",T="latn",x=e=>"valueAsDate"in e,N="esri.widgets.FeatureForm",L=s.getLogger(N);let j=class extends o{constructor(e,t){super(e,t),this._dateFieldInputMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedFieldInputNames=new Set,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.addRelatedRecord&&i.addRelatedRecord({parentFeature:t,relationshipId:e})},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this),this._afterDateInputCreateOrUpdate=this._afterDateInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([a((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedFieldInputNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateFieldInputMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedFieldInputNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})),a((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return l(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){l(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return C("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return C("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},this._renderHeader(),this._renderInputs())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&C(F,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&C("p",{class:d.description,key:"description"},e.formDescription);return C("div",{class:d.formHeader},t,i)}_renderInputs(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>u(e)?this._renderGroup(e,t):c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:C("div",{class:this.classes(d.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:l}=this,{description:s,inputs:a,label:n,state:r}=e,o=a.filter((e=>e.visible)),u=this.viewModel.findField(this._activeInputName),m=!(!u||u.group!==e),h=`${this.id}_group_${t}`,v=`${this.id}_group-label_${t}`,_=`${this.id}_group-description_${t}`,b=this._renderDescriptionOrEmpty(s,_),g="sequential"===this.groupDisplay,f=g?m:"expanded"===r,I=f?d.collapseIcon:d.expandIcon;return C("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":v,"aria-describedby":s?_:"",class:this.classes(d.group,g?d.groupSequential:null,f?null:d.groupCollapsed,m?d.groupActive:null,l?d.inputDisabled:null),disabled:l,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},C("button",{role:g?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:g?-1:0},C("div",{class:d.groupTitle},C(F,{class:d.groupLabel,id:v,level:null!=i&&i.title?y(this.headingLevel):this.headingLevel},n),b),g?null:C("span",{class:this.classes(I,d.groupToggleIcon)})),o.map((e=>c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,l="forward"===e?i:i.slice().reverse();let s;if(!t||p(t))s=0;else if(u(t)){const e=t.inputs.find(c);s=e?l.indexOf(e):0}else{let i;if(m(t)&&"collapsed"===t.group.state){const l=t.group.inputs.filter(c);i="forward"===e?l[l.length-1]:l[0]}else i=t;s=l.indexOf(i)+1}for(let a=s;a<l.length;a++){const e=l[a];if(e.visible&&c(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:l,layer:s}=e;return C("label",{key:`${s.id}-${i.uid}-${e.name}`,class:d.label},[l,"unsupported"!==t?this._renderFieldInput(e):this._renderUnsupportedField(e),this._renderAuxiliaryText(e)])}_renderFieldInput(e){const{dataType:t,domain:i,name:l,updating:s,value:a}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){if(h(e.element,"switch")){const{element:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(l)||null==a||t.input.onValue!==a&&t.input.offValue!==a))return this._renderSwitchFieldInput(e,n);this._switchFieldsWithInitialIncompatibleValue.add(l)}return"radio-buttons"===e.inputType?this._renderRadioButtonsFieldInput(e,i.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),n):this._renderSelectFieldInput(e,this._getFieldValueOptions(l,i),n)}if("datetime-picker"===e.inputType||"date"===t)return this._renderDateFieldInput(e,n);const r="number"===t?C("input",{type:"number",...n,value:null!=this._activeNumberFieldEdit&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${n.value}`}):"text-area"===e.inputType?C("textarea",{...n}):C("input",{type:"text",...n});return s?C("div",{key:`${n.key}-input-updating-wrapper`,class:d.fieldInputWrapper},r,C("div",{class:d.fieldInputLoader},C("calcite-progress",{type:"indeterminate"}))):r}_renderDateFieldInput(e,t){const{dateDataType:i,includeTime:l,label:s,name:a,valid:n,value:r}=e,{readOnly:o,required:u}=t;if("string"===i)return this._renderUnsupportedField(e,v(e.field,t.value));const{date:c,time:p}=this._formatValueForDateInputs(r),m=null!=t.max?this._formatValueForDateInputs(t.max):void 0,h=null!=t.min?this._formatValueForDateInputs(t.min):void 0,_=m?.date??void 0,b=h?.date??void 0,g={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!n,label:s,numberingSystem:T,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[k]:a};return C("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},C("calcite-input-date-picker",{bind:this,...g,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:c??void 0,maxAsDate:_,minAsDate:b,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),l?C("calcite-input-time-picker",{bind:this,...g,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:p??void 0,step:1,onCalciteInputTimePickerChange:e=>this._commitDateChanges(e.target),onfocus:e=>{e.target.calciteTimePickerEl&&(e.target.calciteTimePickerEl.showSecond=!0)},onblur:e=>this._commitDateChanges(e.target,!0)}):null)}_renderUnsupportedField(e,t){const i=this.getCommonInputProps(e);return C("input",{afterCreate:i.afterCreate,afterUpdate:i.afterUpdate,class:this.classes(d.input,d.fieldInput,d.inputDisabled),onfocus:i.onfocus,readOnly:!0,tabIndex:i.tabIndex,type:"text",value:null!=t?`${t}`:i.value,[k]:i[k]})}_renderSelectFieldInput(e,t,i){const{element:l,required:s,value:a}=e,{messages:n,messagesTemplates:r}=this,o=t.map((e=>e.map((e=>C("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:a===e.value}))))),[d,u]=o;this._registerIncompatibleValue(a,t.flat(),e,(e=>{u.unshift(C("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const c=u.length>0?[C("calcite-combobox-item-group",{key:"recommended",label:n.recommended},d),C("calcite-combobox-item-group",{key:"other",label:r.other},u)]:d,p=null==l,m=h(l,"combo-box"),v=p||m&&l.input?.showNoValueOption;if(!s&&v){const e="",t=m&&l.input.noValueOptionLabel||n.empty;c.unshift(C("calcite-combobox-item",{value:e,textLabel:n.empty,key:"empty-option"},t))}return C("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},c)}_registerIncompatibleValue(e,t,i,l){const s=this._fieldToInitialIncompatibleDomainValue,a=s.has(i.name);(a||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(a||s.set(i.name,e),l?.(e))}_renderRadioButtonsFieldInput(e,t,i){const{element:l,name:s,required:a,value:n}=e,r=t.map((e=>this._renderRadioButton({key:e.name,label:e.name,name:s,value:e.value,selected:e.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const o=null==l,u=h(l,"radio-buttons"),c=o||u&&l.input?.showNoValueOption;if(!a&&c){const e="",t=u&&l.input.noValueOptionLabel||this.messages.empty,a=n===e||null===n;r.unshift(this._renderRadioButton({key:"empty-option",label:t,name:s,value:e,selected:a,props:i}))}return C("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},r)}_renderSwitchFieldInput(e,t){const{value:i}=e,l=!!h(e.element,"switch")&&i===e.element.input.onValue;return C("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:l,disabled:t.readOnly})}_renderRadioButton({key:e,name:t,value:i,selected:l,label:s,props:a}){return C("label",{key:e,class:d.inputRadioLabel},C("input",{...a,class:d.inputRadio,name:t,type:"radio",value:i,checked:l,disabled:a.readOnly,onchange:e=>this._commitInputValue(e.target)}),s)}_renderAuxiliaryText(e){const t=this._userUpdatedFieldInputNames.has(e.name)&&!e.valid?_(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(e.name)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=t?C("calcite-input-message",{status:"invalid",icon:!0},t):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:l}=e,{relatedRecordCallbacks:s}=this;if(!l||!s?.showAllRelatedRecords)return;const a=this.messages;return C("calcite-list-item",{description:M(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},C("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i}=e,{relatedRecordCallbacks:l}=this;if(t&&l?.addRelatedRecord)return C("calcite-button",{alignment:"center",appearance:"outline-fill",class:d.centeredButton,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:l,title:s}=e,{feature:a,relatedRecordCallbacks:n}=this,r=()=>{n?.editRelatedRecord&&a&&n.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})};return C("calcite-list-item",{bind:this,description:l,label:s,key:`${t}-${i.uid}`,value:s,onclick:r},C("calcite-icon",{slot:"content-start",scale:"m",icon:b(i)}),C("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,relatedFeatureInfos:i,showAllEnabled:l}=e,s=l?null:e.label,a=l?null:this._renderDescriptionOrEmpty(e.description),n=i.map((e=>this._renderRelatedRecordListItem(e,t)));return C("div",{class:d.label,key:`${s}-${t}`},C("calcite-label",null,s,a,C("calcite-list",{loading:e.updating,class:d.relatedRecordList},n,this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())),this._renderAddRelatedRecordButton(e))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return C("div",{key:"feature-observer",class:d.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{dataType:l,editable:s,group:a,hint:n,label:r,maxLength:o,minLength:u,name:c,required:p,valid:m,value:h}=e,v=this._userUpdatedFieldInputNames.has(c),_=!s||t,b="all"===i&&null!=a&&"collapsed"===a.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":m?"false":"true",class:this.classes(d.input,d.fieldInput,_?d.inputDisabled:null,v&&!m?d.inputInvalid:null),key:c,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...e.range,readOnly:_,value:null==h?"":`${h}`,[k]:c,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===l?this._handleNumberInputMouseDown:void 0,placeholder:"number"===l||"text"===l?n??void 0:"",required:p,tabIndex:b?-1:0}}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),l=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(l.length>0){const e=new Set(l.map((e=>e.value)));return[l,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const s of this.viewModel.allFieldInputs){const{name:i,value:l}=s;null!=l&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=l)}const i=this.viewModel.joinedContingentValues.slice(),l=new Map;for(const s of i){const i=s.values[e];if(null==i||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:a,name:n}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(l.has(a))continue;Object.entries(t).every((([e,t])=>!s.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,s.values[e])))&&l.set(a,{name:n,value:a})}return[...l.values()]}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(k))}async _afterDateInputCreate(e){!x(e)&&null!=e.value&&"setValue"in e&&e.setValue({value:e.value,origin:"external"}),this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateFieldInputMap.get(t),l=x(e);null!=i?l?i.date=e:i.time=e:this._dateFieldInputMap.set(t,{[l?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),l=t.findField(this._activeInputName),s=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&l===i&&("radio-buttons"!==i.inputType||s||e.checked)&&(this._fieldFocusNeeded=!1,m(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._activeInputName=i.name,g(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_handleInputBlur(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);"number"===i.dataType&&null!=this._activeNumberFieldEdit&&(this._activeNumberFieldEdit.input.value=`${i.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e);if(!this._dateFieldInputMap.has(i))return;const l=this._dateFieldInputMap.get(i);if(!l||!l.date)return;const s=this._getFieldValueFromDateInput(e),a=this._getFieldValueFromDateInputs(l.date,l.time);this.viewModel.getValue(i)!==a&&(null!==s&&null!==a?this._updateFieldValue(i,a):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getFieldInputFromHTMLElement(e);null!=this._activeNumberFieldEdit&&g(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:l,metaKey:s}=e,a=this._getFieldInputFromHTMLElement(e.target);if("Enter"===t)m(a)&&"collapsed"===a.group.state&&(a.group.state="expanded");else{const{type:n}=a.field,r="single"===n||"double"===n;if(("integer"===n||"small-integer"===n||r)&&(!i&&!l&&!s)&&1===t.length){const i=Number(t),l=["-","+"],s=["e","."],a=r?[...l,...s]:l;isNaN(i)&&!a.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedFieldInputNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;if(h(t.element,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.element.input.onValue:t.element.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{dataType:l}=t;return"number"===l?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,l="sequential"===this.groupDisplay,s=`.${d.groupHeader}`;if(!(i&&!e.target.closest(s))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",l){const l=e.target.closest(s);if(i&&!l)return;this.viewModel.inputs.forEach((e=>{u(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=l,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:D(),numberingSystem:T}}_getFieldValueFromDateInputs(e,t){const i=this._getDateTimeFromInput(e),l=this._getDateTimeFromInput(t);if(!i&&!l)return null;const s=this._getFieldInputFromHTMLElement(e).range,a=Date.now(),n=null!=s.max&&s.max<a?s.max:a,r=V.fromMillis(n,this._getDefaultLocaleOptions()),o=i||r,{year:d,month:u,day:c}=o,{hour:p,minute:m,second:h}=l||r,v=o.set({year:d,month:u,day:c,hour:p,minute:m,second:h});return v.isValid?v.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(x(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=V.fromJSDate(i)}else{if(!e.value)return null;t=V.fromFormat(e.value,O,this._getDefaultLocaleOptions())}return t??null}_getFieldValueFromDateInput(e){return this._dateTimeToFieldValue(this._getDateTimeFromInput(e))}_dateTimeToFieldValue(e){return e?.isValid?e.toMillis():null}_dateTimeFromFieldValue(e){return null===e?null:V.fromMillis(e,this._getDefaultLocaleOptions())}_formatValueForDateInputs(e){if(null==e||isNaN(e))return{date:null,time:null};const t=this._dateTimeFromFieldValue(e);return t?{date:t.toJSDate(),time:t.toFormat(O,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,t){switch(t.objectType){case"any":return!0;case"null":return null==e;case"code":return e===t.codedValue?.code;case"range":return null!=e&&null!=t.minValue&&null!=t.maxValue&&+e>=t.minValue&&+e<=t.maxValue;default:return i(t.objectType),!1}}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}async _onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([n()],j.prototype,"_listObserverNode",void 0),e([n()],j.prototype,"_relatedRecordsEnabled",null),e([n()],j.prototype,"disabled",null),e([n()],j.prototype,"feature",null),e([n()],j.prototype,"formTemplate",null),e([n()],j.prototype,"groupDisplay",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"layer",null),e([n()],j.prototype,"map",null),e([n(),w("esri/widgets/FeatureForm/t9n/FeatureForm")],j.prototype,"messages",void 0),e([n(),w("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],j.prototype,"messagesTemplates",void 0),e([n()],j.prototype,"relatedRecordCallbacks",null),e([n()],j.prototype,"relationshipId",null),e([n()],j.prototype,"spatialReference",null),e([n()],j.prototype,"strict",null),e([n()],j.prototype,"view",null),e([n(),R(["value-change","submit"])],j.prototype,"viewModel",void 0),j=e([r(N)],j);const E=j;export{E as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{neverReached as i}from"../core/compilerUtils.js";import{deprecatedProperty as s}from"../core/deprecate.js";import a from"../core/Logger.js";import{watch as l}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupInput as u,isFieldInput as c,isRelationshipInput as p,isInputInGroupInput as m,isFieldElementWithInputType as h,formatDateFieldValue as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as R}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{DateTime as M}from"luxon";import{substitute as V}from"../intl/substitute.js";import{getLocale as D}from"../intl/locale.js";const k="TT",O="data-field-name",T="latn",x=e=>"valueAsDate"in e,N="esri.widgets.FeatureForm",L=a.getLogger(N);let j=class extends o{constructor(e,t){super(e,t),this._dateFieldInputMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedFieldInputNames=new Set,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:s}=this;i&&s?.addRelatedRecord&&s.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this),this._afterDateInputCreateOrUpdate=this._afterDateInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([l((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedFieldInputNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateFieldInputMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedFieldInputNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})),l((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return s(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){s(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return C("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return C("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},this._renderHeader(),this._renderInputs())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&C(F,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&C("p",{class:d.description,key:"description"},e.formDescription);return C("div",{class:d.formHeader},t,i)}_renderInputs(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>u(e)?this._renderGroup(e,t):c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:C("div",{class:this.classes(d.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:s}=this,{description:a,inputs:l,label:n,state:r}=e,o=l.filter((e=>e.visible)),u=this.viewModel.findField(this._activeInputName),m=!(!u||u.group!==e),h=`${this.id}_group_${t}`,v=`${this.id}_group-label_${t}`,_=`${this.id}_group-description_${t}`,b=this._renderDescriptionOrEmpty(a,_),g="sequential"===this.groupDisplay,f=g?m:"expanded"===r,I=f?d.collapseIcon:d.expandIcon;return C("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":v,"aria-describedby":a?_:"",class:this.classes(d.group,g?d.groupSequential:null,f?null:d.groupCollapsed,m?d.groupActive:null,s?d.inputDisabled:null),disabled:s,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},C("button",{role:g?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:g?-1:0},C("div",{class:d.groupTitle},C(F,{class:d.groupLabel,id:v,level:null!=i&&i.title?y(this.headingLevel):this.headingLevel},n),b),g?null:C("span",{class:this.classes(I,d.groupToggleIcon)})),o.map((e=>c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,s="forward"===e?i:i.slice().reverse();let a;if(!t||p(t))a=0;else if(u(t)){const e=t.inputs.find(c);a=e?s.indexOf(e):0}else{let i;if(m(t)&&"collapsed"===t.group.state){const s=t.group.inputs.filter(c);i="forward"===e?s[s.length-1]:s[0]}else i=t;a=s.indexOf(i)+1}for(let l=a;l<s.length;l++){const e=s[l];if(e.visible&&c(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:s,layer:a}=e;return C("label",{key:`${a.id}-${i.uid}-${e.name}`,class:d.label},[s,"unsupported"!==t?this._renderFieldInput(e):this._renderUnsupportedField(e),this._renderAuxiliaryText(e)])}_renderFieldInput(e){const{dataType:t,domain:i,name:s,updating:a,value:l}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){if(h(e.element,"switch")){const{element:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(s)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this._renderSwitchFieldInput(e,n);this._switchFieldsWithInitialIncompatibleValue.add(s)}return"radio-buttons"===e.inputType?this._renderRadioButtonsFieldInput(e,i.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),n):this._renderSelectFieldInput(e,this._getFieldValueOptions(s,i),n)}if("datetime-picker"===e.inputType||"date"===t)return this._renderDateFieldInput(e,n);const r="number"===t?C("input",{type:"number",...n,value:null!=this._activeNumberFieldEdit&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${n.value}`}):"text-area"===e.inputType?C("textarea",{...n}):C("input",{type:"text",...n});return a?C("div",{key:`${n.key}-input-updating-wrapper`,class:d.fieldInputWrapper},r,C("div",{class:d.fieldInputLoader},C("calcite-progress",{type:"indeterminate"}))):r}_renderDateFieldInput(e,t){const{dateDataType:i,includeTime:s,label:a,name:l,valid:n,value:r}=e,{readOnly:o,required:u}=t;if("string"===i)return this._renderUnsupportedField(e,v(e.field,t.value));const{date:c,time:p}=this._formatValueForDateInputs(r),m=null!=t.max?this._formatValueForDateInputs(t.max):void 0,h=null!=t.min?this._formatValueForDateInputs(t.min):void 0,_=m?.date??void 0,b=h?.date??void 0,g={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!n,label:a,numberingSystem:T,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[O]:l};return C("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},C("calcite-input-date-picker",{bind:this,...g,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:c??void 0,maxAsDate:_,minAsDate:b,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),s?C("calcite-input-time-picker",{bind:this,...g,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:p??void 0,step:1,onCalciteInputTimePickerChange:e=>this._commitDateChanges(e.target),onfocus:e=>{e.target.calciteTimePickerEl&&(e.target.calciteTimePickerEl.showSecond=!0)},onblur:e=>this._commitDateChanges(e.target,!0)}):null)}_renderUnsupportedField(e,t){const i=this.getCommonInputProps(e);return C("input",{afterCreate:i.afterCreate,afterUpdate:i.afterUpdate,class:this.classes(d.input,d.fieldInput,d.inputDisabled),onfocus:i.onfocus,readOnly:!0,tabIndex:i.tabIndex,type:"text",value:null!=t?`${t}`:i.value,[O]:i[O]})}_renderSelectFieldInput(e,t,i){const{element:s,required:a,value:l}=e,{messages:n,messagesTemplates:r}=this,o=t.map((e=>e.map((e=>C("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:l===e.value}))))),[d,u]=o;this._registerIncompatibleValue(l,t.flat(),e,(e=>{u.unshift(C("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const c=u.length>0?[C("calcite-combobox-item-group",{key:"recommended",label:n.recommended},d),C("calcite-combobox-item-group",{key:"other",label:r.other},u)]:d,p=null==s,m=h(s,"combo-box"),v=p||m&&s.input?.showNoValueOption;if(!a&&v){const e="",t=m&&s.input.noValueOptionLabel||n.empty;c.unshift(C("calcite-combobox-item",{value:e,textLabel:n.empty,key:"empty-option"},t))}return C("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},c)}_registerIncompatibleValue(e,t,i,s){const a=this._fieldToInitialIncompatibleDomainValue,l=a.has(i.name);(l||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(l||a.set(i.name,e),s?.(e))}_renderRadioButtonsFieldInput(e,t,i){const{element:s,name:a,required:l,value:n}=e,r=t.map((e=>this._renderRadioButton({key:e.name,label:e.name,name:a,value:e.value,selected:e.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const o=null==s,u=h(s,"radio-buttons"),c=o||u&&s.input?.showNoValueOption;if(!l&&c){const e="",t=u&&s.input.noValueOptionLabel||this.messages.empty,l=n===e||null===n;r.unshift(this._renderRadioButton({key:"empty-option",label:t,name:a,value:e,selected:l,props:i}))}return C("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},r)}_renderSwitchFieldInput(e,t){const{value:i}=e,s=!!h(e.element,"switch")&&i===e.element.input.onValue;return C("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:s,disabled:t.readOnly})}_renderRadioButton({key:e,name:t,value:i,selected:s,label:a,props:l}){return C("label",{key:e,class:d.inputRadioLabel},C("input",{...l,class:d.inputRadio,name:t,type:"radio",value:i,checked:s,disabled:l.readOnly,onchange:e=>this._commitInputValue(e.target)}),a)}_renderAuxiliaryText(e){const t=this._userUpdatedFieldInputNames.has(e.name)&&!e.valid?_(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(e.name)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=t?C("calcite-input-message",{status:"invalid",icon:!0},t):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:s}=e,{relatedRecordCallbacks:a}=this;if(!s||!a?.showAllRelatedRecords)return;const l=this.messages;return C("calcite-list-item",{description:V(l.totalCount,{count:t}),label:l.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},C("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:s}=e,{relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&s)return C("calcite-button",{alignment:"center",appearance:"outline-fill",class:d.centeredButton,disabled:e.updating,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i,s)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:s,title:a}=e,{feature:l,relatedRecordCallbacks:n}=this,r=()=>{n?.editRelatedRecord&&l&&n.editRelatedRecord({parentFeature:l,relationshipId:t,relatedFeature:i})};return C("calcite-list-item",{bind:this,description:s,label:a,key:`${t}-${i.uid}`,value:a,onclick:r},C("calcite-icon",{slot:"content-start",scale:"m",icon:b(i)}),C("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,relatedFeatureInfos:i,showAllEnabled:s}=e,a=s?null:this._renderDescriptionOrEmpty(e.description),l=i.length?this._renderRelatedRecordsList(e):e.loaded?this._renderNoRelatedRecordsNotice():void 0;return C("label",{class:this.classes(d.label,d.relationshipLabel),key:`relationship-${t}-container`},C("div",null,this._renderRelatedRecordsHeaderContainer(e),a,l),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return C("div",{class:d.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},C("span",null,e.label),t?C("calcite-loader",{label:this.messagesCommon?.loading,inline:!0,key:"loader",scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return C("calcite-list",{class:d.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoRelatedRecordsNotice(){return C("calcite-notice",{open:!0,scale:"s",kind:"brand",icon:"information",width:"full"},C("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return C("div",{key:"feature-observer",class:d.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{dataType:s,editable:a,group:l,hint:n,label:r,maxLength:o,minLength:u,name:c,required:p,valid:m,value:h}=e,v=this._userUpdatedFieldInputNames.has(c),_=!a||t,b="all"===i&&null!=l&&"collapsed"===l.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":m?"false":"true",class:this.classes(d.input,d.fieldInput,_?d.inputDisabled:null,v&&!m?d.inputInvalid:null),key:c,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...e.range,readOnly:_,value:null==h?"":`${h}`,[O]:c,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===s?this._handleNumberInputMouseDown:void 0,placeholder:"number"===s||"text"===s?n??void 0:"",required:p,tabIndex:b?-1:0}}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),s=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(s.length>0){const e=new Set(s.map((e=>e.value)));return[s,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const a of this.viewModel.allFieldInputs){const{name:i,value:s}=a;null!=s&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=s)}const i=this.viewModel.joinedContingentValues.slice(),s=new Map;for(const a of i){const i=a.values[e];if(null==i||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:n}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(s.has(l))continue;Object.entries(t).every((([e,t])=>!a.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,a.values[e])))&&s.set(l,{name:n,value:l})}return[...s.values()]}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(O))}async _afterDateInputCreate(e){this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateFieldInputMap.get(t),s=x(e);null!=i?s?i.date=e:i.time=e:this._dateFieldInputMap.set(t,{[s?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),s=t.findField(this._activeInputName),a=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&s===i&&("radio-buttons"!==i.inputType||a||e.checked)&&(this._fieldFocusNeeded=!1,m(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._activeInputName=i.name,g(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_handleInputBlur(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);"number"===i.dataType&&null!=this._activeNumberFieldEdit&&(this._activeNumberFieldEdit.input.value=`${i.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e);if(!this._dateFieldInputMap.has(i))return;const s=this._dateFieldInputMap.get(i);if(!s||!s.date)return;const a=this._getFieldValueFromDateInput(e),l=this._getFieldValueFromDateInputs(s.date,s.time);this.viewModel.getValue(i)!==l&&(null!==a&&null!==l?this._updateFieldValue(i,l):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getFieldInputFromHTMLElement(e);null!=this._activeNumberFieldEdit&&g(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:s,metaKey:a}=e,l=this._getFieldInputFromHTMLElement(e.target);if("Enter"===t)m(l)&&"collapsed"===l.group.state&&(l.group.state="expanded");else{const{type:n}=l.field,r="single"===n||"double"===n;if(("integer"===n||"small-integer"===n||r)&&(!i&&!s&&!a)&&1===t.length){const i=Number(t),s=["-","+"],a=["e","."],l=r?[...s,...a]:s;isNaN(i)&&!l.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedFieldInputNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;if(h(t.element,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.element.input.onValue:t.element.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{dataType:s}=t;return"number"===s?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,s="sequential"===this.groupDisplay,a=`.${d.groupHeader}`;if(!(i&&!e.target.closest(a))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",s){const s=e.target.closest(a);if(i&&!s)return;this.viewModel.inputs.forEach((e=>{u(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=s,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:D(),numberingSystem:T}}_getFieldValueFromDateInputs(e,t){const i=this._getDateTimeFromInput(e),s=this._getDateTimeFromInput(t);if(!i&&!s)return null;const a=this._getFieldInputFromHTMLElement(e).range,l=Date.now(),n=null!=a.max&&a.max<l?a.max:l,r=M.fromMillis(n,this._getDefaultLocaleOptions()),o=i||r,{year:d,month:u,day:c}=o,{hour:p,minute:m,second:h}=s||r,v=o.set({year:d,month:u,day:c,hour:p,minute:m,second:h});return v.isValid?v.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(x(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=M.fromJSDate(i)}else{if(!e.value)return null;t=M.fromFormat(e.value,k,this._getDefaultLocaleOptions())}return t??null}_getFieldValueFromDateInput(e){return this._dateTimeToFieldValue(this._getDateTimeFromInput(e))}_dateTimeToFieldValue(e){return e?.isValid?e.toMillis():null}_dateTimeFromFieldValue(e){return null===e?null:M.fromMillis(e,this._getDefaultLocaleOptions())}_formatValueForDateInputs(e){if(null==e||isNaN(e))return{date:null,time:null};const t=this._dateTimeFromFieldValue(e);return t?{date:t.toJSDate(),time:t.toFormat(k,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,t){switch(t.objectType){case"any":return!0;case"null":return null==e;case"code":return e===t.codedValue?.code;case"range":return null!=e&&null!=t.minValue&&null!=t.maxValue&&+e>=t.minValue&&+e<=t.maxValue;default:return i(t.objectType),!1}}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}async _onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([n()],j.prototype,"_listObserverNode",void 0),e([n()],j.prototype,"_relatedRecordsEnabled",null),e([n()],j.prototype,"disabled",null),e([n()],j.prototype,"feature",null),e([n()],j.prototype,"formTemplate",null),e([n()],j.prototype,"groupDisplay",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"layer",null),e([n()],j.prototype,"map",null),e([n(),w("esri/widgets/FeatureForm/t9n/FeatureForm")],j.prototype,"messages",void 0),e([n(),w("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n(),w("esri/widgets/Feature/t9n/Feature")],j.prototype,"messagesFeature",void 0),e([n(),w("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],j.prototype,"messagesTemplates",void 0),e([n()],j.prototype,"relatedRecordCallbacks",null),e([n()],j.prototype,"relationshipId",null),e([n()],j.prototype,"spatialReference",null),e([n()],j.prototype,"strict",null),e([n()],j.prototype,"view",null),e([n(),R(["value-change","submit"])],j.prototype,"viewModel",void 0),j=e([r(N)],j);const E=j;export{E as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import s from"../../core/ObjectPool.js";import{when as o}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import s from"../../core/ObjectPool.js";import{when as o}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as i,getEffectiveLayerCapabilities as n}from"../../layers/support/layerUtils.js";import p from"./TemplateItem.js";import u from"./TemplateItemGroup.js";var m;const y=({layer:e})=>({key:e,label:e.title??""}),c=({layer:e})=>({key:e.geometryType,label:e.geometryType??""});let h=m=class extends(r(t.EventedAccessor)){constructor(e){super(e),this._itemPool=new s(p),this._groupPool=new s(u),this.filterFunction=null,this.selectedItem=null}initialize(){this._get("groupBy")||(this.groupBy="layer")}set groupBy(e){if(this._set("groupBy",e),"function"!=typeof e)switch(e){case"layer":this._groupByFunction=y;break;case"geometry":this._groupByFunction=c;break;default:this._groupByFunction=null}else this._groupByFunction=t=>this._ensureGroupByObject(e(t))}set layers(e){const t="layers";if(this.handles.remove(t),e){const r=()=>this.notifyChange("state");this.handles.add(e.map((e=>o((()=>e.loadStatus),r))),t)}this._set("layers",e)}get layers(){return this._get("layers")}get state(){const{layers:e}=this;return e&&0!==e.length?e.some((e=>"loading"===e.loadStatus||"not-loaded"===e.loadStatus))?"loading":"ready":"disabled"}get _featureTemplatesByLayer(){if(!this.layers)return new Map;const e=[];for(const t of this.layers)if("subtype-group"===t.type)for(const r of t.sublayers){const t=f(r);e.push([r,t])}else i(t)||e.push([t,f(t)]);return new Map(e)}get numberOfFeatureTemplates(){return Array.from(this._featureTemplatesByLayer.values()).reduce(((e,t)=>e+t.length),0)}get items(){if(0===this.numberOfFeatureTemplates)return this._releasePreviousItems(),[];const e=this._featureTemplatesByLayer,t=[],r=null!=this.filterFunction?this.filterFunction:m._nullFilterFunction;for(const[l,a]of e)if(l.loaded||"subtype-sublayer"===l.type&&l.parent?.loaded){const e=n(l)?.operations;if(e?.supportsEditing&&e?.supportsAdd)for(const s of a)t.push({layer:l,template:s,matchesFilter:r({label:s.name})})}if(null==this._groupByFunction){const e=t.filter((({matchesFilter:e})=>e)).map((({template:e,layer:t})=>this._createItem(e,t)));return this._releasePreviousItems(),e}const s=new Map;for(const l of t){const{template:e,layer:t}=l,r=this._groupByFunction({template:e,layer:t}),{key:o,label:a}=null!=r.key?r:m.nullGroupBy;s.has(o)||s.set(o,{label:a,templateItemInfos:[]}),s.get(o)?.templateItemInfos.push(l)}const o=[];for(const l of s.values()){const{label:e,templateItemInfos:t}=l,s=t.filter((({matchesFilter:e})=>e)),a=r({label:e})?t:t.length>0?s:[];if(a.length>0){const t=a.map((({template:e,layer:t})=>this._createItem(e,t)));o.push(this._createGroup(e,t))}}return 1===o.length&&o[0].label===m.nullGroupBy.label?(this._releasePreviousItems(),o[0].items):(this._releasePreviousItems(),o)}refresh(){this.notifyChange("items")}select(e,{emit:t=!0}={}){const r=this.selectedItem,s=e?.clone()||null;this._set("selectedItem",s),t&&this.emit("select",{item:s,oldItem:r,template:s?.template??null})}_createItem(e,t){const r=this._itemPool.acquire();return r.set({template:e,layer:t}),r}_createGroup(e,t){const r=this._groupPool.acquire();return r.set("label",e),r.items=t,r}_releasePreviousItems(){this._destroyItems(this._get("items"))}_destroyItems(e){if(!e)return;e[0]instanceof p?e.forEach((e=>this._destroyItem(e))):e.forEach((e=>this._destroyGroup(e)))}_destroyGroup(e){e.items.forEach((e=>this._destroyItem(e))),e.items.length=0,this._groupPool.release(e)}_destroyItem(e){e.layer=null,e.template=null,this._itemPool.release(e)}_ensureGroupByObject(e){return"string"==typeof e?{key:e,label:e}:e}};h.nullGroupBy={key:Symbol(),label:"Other"},h._nullFilterFunction=e=>!0,e([l()],h.prototype,"_groupByFunction",void 0),e([l()],h.prototype,"filterFunction",void 0),e([l()],h.prototype,"groupBy",null),e([l()],h.prototype,"layers",null),e([l()],h.prototype,"state",null),e([l({readOnly:!0})],h.prototype,"_featureTemplatesByLayer",null),e([l({readOnly:!0})],h.prototype,"numberOfFeatureTemplates",null),e([l({readOnly:!0})],h.prototype,"items",null),e([l({readOnly:!0})],h.prototype,"selectedItem",void 0),h=m=e([a("esri.widgets.FeatureTemplates.FeatureTemplatesViewModel")],h);const f=e=>[..."templates"in e&&Array.isArray(e.templates)?e.templates:[],..."types"in e&&Array.isArray(e.types)?e.types.flatMap((e=>e.templates)):[]],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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import i from"../../core/Collection.js";import r from"../../core/Evented.js";import o from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{once as a,on as n,watch as l,when as g,syncAndInitial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import{ensureType as m}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Extent.js";import y from"../../layers/GraphicsLayer.js";import _ from"../../layers/ImageryTileLayer.js";import{searchImages as v}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as f}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as C,computePolygonForInspection as P,resizePolygon as w,checkIfPolygonContainsSelectedPoint as I}from"../../layers/orientedImagery/core/coverageUtils.js";import{transformPoints as b}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as F}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import V from"../../views/MapView.js";import{getResolutionToScaleFactor as x}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as S}from"../../views/support/projectionUtils.js";import{activePolygonSymbol as O,polygonSymbol as G,activeSourcePointSymbol as j,sourcePointSymbol as M,crossSymbol as R,diamondSymbol as L}from"./symbols.js";import D from"../../geometry/SpatialReference.js";import A from"../../geometry/Point.js";import E from"../../geometry/Polygon.js";const U={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"};let J=class extends r.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=null,this.coveragePolygons=null,this.displayMessage=null,this.initialCurrentCoverageUpdate=!1,this.pointSources=null,this.selectedFeature=null,this.selectedPoint=null,this.features=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentCoveragePolygon=null,this._currentImage=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._isLoading=!1,this._overlays=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._crossSymbol=null,this._fetchFeaturesController=null,this._panConstraint=null,this._scaleConstraint=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadViewer=this.loadViewer.bind(this)}initialize(){a((()=>this.view?.ready)).then((()=>{this._overlays=new y({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles([n((()=>this.view),"click",(e=>{this.view.ready&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"===e.pointerType&&0!==e.button||(e.native.altKey?(this.plotReferencePoint(e),this.plotImagePointOnGround({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}})):(this.displayMessage=null,this.selectedPoint=e.mapPoint,this._fetchFeaturesWithController(e))))}))],U.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums=null,this.coveragePolygons=null,this.pointSources=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentImage=s(this._currentImage),this._imageViewer=s(this._imageViewer),this._initialCurrentCoveragePolygon=s(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=s(this._currentCoveragePolygon),this._crossSymbol=s(this._crossSymbol),this._referencePointOnGround=s(this._referencePointOnGround),this._referencePointOnImage=s(this._referencePointOnImage),this._overlays=s(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get hasImageLoaded(){return!!this._currentImage}get isAdditionalCoverageDisabled(){return!this._additionalCoveragePolygons?.length}get isAdditionalCoverageVisible(){return this._additionalCoveragePolygons?.getItemAt(0)?.visible??!1}get isAdditionalPointSourcesDisabled(){return!this._additionalFeatureGraphics?.length}get isAdditionalPointSourcesVisible(){return this._additionalFeatureGraphics?.getItemAt(0)?.visible??!1}get isCurrentCoverageDisabled(){return!this._currentCoveragePolygon}get isCurrentCoverageVisible(){return!!this._currentCoveragePolygon?.visible}get isLoading(){return!(this._imageViewer?.stationary??1)||(this.currentImageView?.updating??!1)||this._isLoading}get state(){const{active:e,hasImageLoaded:t,isLoading:i}=this;return i?"loading":t?"image-loaded":e?"ready":"disabled"}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}loadViewer(e){const t=new Map,i={wkid:0};this._imageViewer=new V({container:e,map:t,spatialReferance:i,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this._currentImage&&this._currentImage.fullExtent){const{xmin:t,xmax:i,ymin:r,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||i<s||o<a||r>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await F([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),l((()=>this._imageViewer?.viewpoint),(e=>{e&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())}))])}toggleAdditionalCameraLocations(){this._additionalFeatureGraphics?.forEach((e=>{e.visible=!e.visible}))}toggleAdditionalCoverage(){this._additionalCoveragePolygons?.forEach((e=>{e.visible=!e.visible}))}toggleCurrentCoverage(){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=!this._currentCoveragePolygon.visible,this._selectedFeatureGraphic.visible=!this._selectedFeatureGraphic)}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:i}=e,r=this.activeLayer;if(r){const e={include:r};return this.view.hitTest(i,e).then((e=>this._processHitTestResults(r,e,t)))}return null}_fetchFeaturesWithController(e){this._cancelFetchingFeatures(),this._isLoading=!0;const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;const r=this._fetchFeatures(e,{signal:i});this._processFeatureResponse(r,e,{signal:i})}_processFeatureResponse(e,r,o){this.initialCurrentCoverageUpdate=!1,e.then((async e=>{if(e){const s=o.signal,{features:n}=e;this._updateFeatures(n);const l=n.map((e=>({feature:e,...C(e)}))).map((e=>{const{feature:t}=e;return t.attributes.isInspection&&(e.polygon=P(t)),t.layer.coveragePercent&&(e.polygon=w(e.polygon,t.layer.coveragePercent)),e})).filter((({polygon:e})=>I(e,r.mapPoint))),g=l.map((e=>e.feature)),h=await f({features:g,selectedPoint:r.mapPoint,camera:"3d"===this.view.type?this.view.camera:null,currentImage:this.selectedFeature,polygons:l.map((e=>e.polygon))});h?.sort(((e,t)=>e.suitability-t.suitability));const c=h[0]?.feature;this.selectedFeature=c,this.coveragePolygons=new i,this.coverageFrustums=new i,this.pointSources=new i,l.forEach((({polygon:e,frustum:t,feature:i})=>{const r=e.toJSON(),o=t?.toJSON(),{attributes:s}=i,{averageHeightAboveGround:a,cameraHeading:n,location:l,objectId:g}=s,h="toJSON"in l?l.toJSON():l;Object.defineProperty(r,"imageID",{value:g}),Object.defineProperty(o,"imageID",{value:g}),Object.defineProperty(h,"imageID",{value:g}),h.z=a,this.pointSources?.push(h),n>0?(this.coveragePolygons?.push(r),this.coverageFrustums?.push(o)):(this.coveragePolygons?.push(void 0),this.coverageFrustums?.push(void 0))})),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null),this._additionalCoveragePolygons=new i;for(const e of this.coveragePolygons)e?.imageID===this.selectedFeature?.attributes.objectId?(this._currentCoveragePolygon=new t({attributes:{imageID:e?.imageID},geometry:{type:"polygon",...e},symbol:O,visible:!1}),this._initialCurrentCoveragePolygon=this._currentCoveragePolygon.clone()):this._additionalCoveragePolygons.push(new t({attributes:{imageID:e?.imageID},geometry:{type:"polygon",...e},symbol:G,visible:!1}));if(this.view){this._overlays?.removeAll(),this._additionalFeatureGraphics=new i;for(const e of this.pointSources)e.imageID===this.selectedFeature?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:j}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:M,visible:!1}));this._overlays?.graphics.addMany(this._additionalCoveragePolygons),this._overlays?.graphics.addMany(this._additionalFeatureGraphics),this._currentCoveragePolygon&&this._overlays?.add(this._currentCoveragePolygon),this._overlays?.add(this._selectedFeatureGraphic),this._overlays?.add(new t({geometry:{type:"point",...r.mapPoint.toJSON()},symbol:R}))}else a((()=>this.initialCurrentCoverageUpdate)).then((e=>{if(e){const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.selectedFeature?.geometry,currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}}));await this.loadImage(this.selectedFeature,r.mapPoint,{signal:s}),this._isLoading=!1}})).catch((e=>{throw e})).finally((()=>{this._isLoading=!1}))}_processHitTestResults(e,t,i){const{screenPoint:r,results:o}=t,s=this.view.toMap(r),a=o[0],n={layerInstanceOrURL:e,point:s,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0,outSpatialReference:s.spatialReference},queryFeatures:null};return v(n,i)}_updateFeatures(e){e.length&&(this.features=e)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&this.emit("update-current-coverage",{graphic:e.toJSON()})}async loadImage(e,i,r){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const s=e.layer?.affixes;let a=e.attributes.image;if(s){const{imagePathPrefix:e,imagePathSuffix:t}=s;e&&(a=e.trim()+"/"+a),t&&(a=a+"/"+t.trim())}this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const n={skipExtensions:["aux.xml","jgw"]};this._currentImage=new _({ioConfig:n,url:a,options:r}),this._imageViewer.map.layers.add(this._currentImage);try{const r=await this._currentImage.when();this._imageViewer.extent=r.fullExtent,r.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.constraints.rotationEnabled=!0,this._imageViewer.rotation=e.attributes.cameraRoll+(e.attributes.imageRotation??0),this._imageViewer.constraints.rotationEnabled=!1);const{pixelSize:o}=r.rasterInfo;b([i],{feature:e,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:{signal:this._fetchFeaturesController?.signal}}).then((async e=>{if(!e.length)return;const i=e[0];if(!i)return;const s=m(p,await S(r.fullExtent,m(D,this._imageViewer?.spatialReference)));i.x=i.x*o.x+s.xmin,i.y=s.ymax-i.y*o.y,i.spatialReference=s.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:{type:"point",...i},symbol:R}),this._imageViewer?.graphics.add(this._crossSymbol)})),this._panConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._panConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:i,xmax:r,ymin:o,ymax:s}=this._currentImage.fullExtent,{width:a,height:n}=this._imageViewer.extent,l=this._imageViewer?.rotation*Math.PI/180,g=Math.cos(l)*a+Math.sin(l)*n,h=Math.cos(l)*n+Math.sin(l)*a,{width:c,height:u}=this._currentImage.rasterInfo;return e.targetGeometry.x=Math.min(Math.max(i+(c>g?g:c)/2,e.targetGeometry.x),r-(c>g?g:c)/2),e.targetGeometry.y=Math.min(Math.max(o+(u>h?h:u)/2,e.targetGeometry.y),s-(u>h?h:u)/2),e}},this._scaleConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._scaleConstraint),this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:i}=this._currentImage.rasterInfo,{width:r,height:o}=this._imageViewer;e.scale=Math.min(e.scale,x(this._imageViewer.spatialReference)*Math.max(t/r,i/o))}return e}},this._imageViewer?.constraints.customConstraints.add(this._panConstraint),this._imageViewer?.constraints.customConstraints.add(this._scaleConstraint),r.addHandles([g((()=>this._imageViewer?.stationary),(e=>{e&&this._imageViewer?.viewpoint&&this._panConstraint?.constrain(this._imageViewer?.viewpoint)}),h)])}catch(l){o.getLogger(this.declaredClass).error("oriented-imagery-viewer:load-image",l)}}async plotImagePointOnGround(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:i,selectedLocation:r,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await b([r],{feature:i,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let g=l[0];const h=await S(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);a?(g.x=g.x*s.x+h.xmin,g.y=h.ymax-g.y*s.y,g.spatialReference=h.spatialReference):g=n.forwardTransform(new A(g)),this.plotReferencePointOnImage(g)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:L}),this._overlays?.add(this._referencePointOnGround)}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",..."toJSON"in e?e.toJSON():e},symbol:L}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,i){this.displayMessage={key:e,type:t,data:i}}async updateCoverage(){const e=new AbortController,{signal:i}=e;this._updateCoverageController=e;const{_imageViewer:r}=this;if(this._currentImage&&r){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,g=[[0,0],[Math.min(r.width,e),0],[Math.min(r.width,e),Math.min(r.height,o)],[0,Math.min(r.height,o)]].map((e=>r.toMap(c(e[0],e[1]))));g.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const h=await F(g,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:i}});if(h&&!i.aborted){const e=[h.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const i=new E({hasZ:!0,rings:e,spatialReference:h[0].spatialReference});this.updateCurrentCoveragePolygon(new t({geometry:i,symbol:O,visible:this.isCurrentCoverageVisible}))}}}};e([u()],J.prototype,"active",null),e([u()],J.prototype,"activeLayer",void 0),e([u()],J.prototype,"shouldShowSelectedImage",void 0),e([u()],J.prototype,"coverageFrustums",void 0),e([u()],J.prototype,"coveragePolygons",void 0),e([u()],J.prototype,"currentImageView",null),e([u()],J.prototype,"displayMessage",void 0),e([u()],J.prototype,"initialCurrentCoverageUpdate",void 0),e([u()],J.prototype,"pointSources",void 0),e([u()],J.prototype,"selectedFeature",void 0),e([u()],J.prototype,"selectedPoint",void 0),e([u({readOnly:!0})],J.prototype,"featureCount",null),e([u()],J.prototype,"features",void 0),e([u()],J.prototype,"hasImageLoaded",null),e([u()],J.prototype,"isAdditionalCoverageDisabled",null),e([u()],J.prototype,"isAdditionalCoverageVisible",null),e([u()],J.prototype,"isAdditionalPointSourcesDisabled",null),e([u()],J.prototype,"isAdditionalPointSourcesVisible",null),e([u()],J.prototype,"isCurrentCoverageDisabled",null),e([u()],J.prototype,"isCurrentCoverageVisible",null),e([u()],J.prototype,"isLoading",null),e([u()],J.prototype,"state",null),e([u()],J.prototype,"view",null),e([u()],J.prototype,"_additionalCoveragePolygons",void 0),e([u()],J.prototype,"_additionalFeatureGraphics",void 0),e([u()],J.prototype,"_currentCoveragePolygon",void 0),e([u()],J.prototype,"_currentImage",void 0),e([u()],J.prototype,"_imageViewer",void 0),e([u()],J.prototype,"_initialCurrentCoveragePolygon",void 0),e([u()],J.prototype,"_isLoading",void 0),e([u()],J.prototype,"_overlays",void 0),e([u()],J.prototype,"_referencePointOnGround",void 0),e([u()],J.prototype,"_referencePointOnImage",void 0),e([u()],J.prototype,"_selectedFeatureGraphic",void 0),J=e([d("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],J);const N=J;export{N as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import r from"../../core/Collection.js";import i from"../../core/Evented.js";import o from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{once as a,on as n,watch as l,when as g,syncAndInitial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import{ensureType as m}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Extent.js";import y from"../../layers/GraphicsLayer.js";import _ from"../../layers/ImageryTileLayer.js";import{searchImages as v}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as f}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as C,computePolygonForInspection as w,resizePolygon as P,checkIfPolygonContainsSelectedPoint as I}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as b,transformPoints as F}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import S from"../../views/MapView.js";import{getResolutionToScaleFactor as x}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as O}from"../../views/support/projectionUtils.js";import{activePolygonSymbol as G,polygonSymbol as M,activeSourcePointSymbol as j,sourcePointSymbol as R,crossSymbol as L,diamondSymbol as D}from"./symbols.js";import A from"../../geometry/Polygon.js";import E from"../../geometry/SpatialReference.js";import U from"../../geometry/Point.js";const J={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"};function N(e){return"3d"===e?.type}function T(e){return"esri.Graphic"===e?.declaredClass}let k=class extends i.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=null,this.coveragePolygons=null,this.displayMessage=null,this.pointSources=null,this.selectedFeature=null,this.selectedPoint=null,this.features=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this)}initialize(){a((()=>this.view?.ready)).then((()=>{this._overlays=new y({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles(n((()=>this.view),"click",(e=>{this.view.ready&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"===e.pointerType&&0!==e.button||(e.native.altKey?(this.plotReferencePoint(e),this.plotImagePointOnGround({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}})):(this.displayMessage=null,this.selectedPoint=e.mapPoint,this.features=null,this.selectedFeature=null,this._overlays?.removeAll(),this._overlays?.add(new t({geometry:e.mapPoint.clone(),symbol:L})),this._fetchFeaturesWithController(e))))})),J.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums=null,this.coveragePolygons=null,this.pointSources=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentImage=s(this._currentImage),this._imageViewer=s(this._imageViewer),this._initialCurrentCoveragePolygon=s(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=s(this._currentCoveragePolygon),this._crossSymbol=s(this._crossSymbol),this._referencePointOnGround=s(this._referencePointOnGround),this._referencePointOnImage=s(this._referencePointOnImage),this._overlays=s(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get hasImageLoaded(){return!!this._currentImage}get isAdditionalCoverageDisabled(){return!this._additionalCoveragePolygons?.length}get isAdditionalCoverageVisible(){return this._additionalCoveragePolygons?.getItemAt(0)?.visible??!1}get isAdditionalPointSourcesDisabled(){return!this._additionalFeatureGraphics?.length}get isAdditionalPointSourcesVisible(){return this._additionalFeatureGraphics?.getItemAt(0)?.visible??!1}get isCurrentCoverageDisabled(){return!this._currentCoveragePolygon}get isCurrentCoverageVisible(){return!!this._currentCoveragePolygon?.visible}get updating(){return!(this._imageViewer?.stationary??1)||(this.currentImageView?.updating??!1)||"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get state(){const{active:e,hasImageLoaded:t,updating:r}=this;return r?"loading":t?"image-loaded":e?"ready":"disabled"}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new S({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),a((()=>this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this._currentImage&&this._currentImage.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||r<s||o<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),l((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),(()=>{this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),l((()=>this.selectedFeature),(async()=>{const{_fetchFeaturesController:e,selectedFeature:t,selectedPoint:r}=this;!t&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=s(this._currentImage)),t&&r&&(await this.loadImage(t,{signal:e?.signal}),this.transformAndPlotSelectedLocation({signal:this._fetchFeaturesController?.signal}))}))])}async searchBestImage(e,t){try{const r=await v(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=o.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while finding best image",r)}}toggleAdditionalCameraLocations(){this._additionalFeatureGraphics?.forEach((e=>{e.visible=!e.visible}))}toggleAdditionalCoverage(){this._additionalCoveragePolygons?.forEach((e=>{e.visible=!e.visible}))}toggleCurrentCoverage(){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=!this._currentCoveragePolygon.visible,this._selectedFeatureGraphic.visible=!this._selectedFeatureGraphic)}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:r}=e,i=this.activeLayer;if(i){const e={include:i},o=await this.view.hitTest(r,e);this._processHitTestResults(i,o,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{this._fetchFeatures(e,{signal:r})}catch(i){const e=o.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while fetching features",i)}this._fetchFeaturesController=null}async _processFeatureResponse(e,i){const{selectedPoint:o}=this;if(!o)return;if(!e)return;const s=await e;if(this._fetchFeaturesController=null,!s)return;const{features:a}=s;if(!a.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const n=new Array;this.coveragePolygons=new r,this.coverageFrustums=new r,this.pointSources=new r,a.forEach((e=>{let t;const{polygon:r,frustum:i}=C(e);if(t=r,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=P(t,e.layer.coveragePercent)),I(t,o)){n.push(e);const r=t.toJSON(),o=i?.toJSON(),{attributes:s}=e,{cameraHeight:a,cameraHeading:l,location:g,objectId:h}=s,c="toJSON"in g?g.toJSON():g;r.imageID=c.imageID=h,o&&(o.imageID=h),c.z=a,this.pointSources?.push(c),this.coveragePolygons?.push(l>0?r:void 0),this.coverageFrustums?.push(l>0?o:void 0)}}));const l=this.coveragePolygons?.getItemAt(0);if(!n.length)return void this.setMessage("noImageError","error");if(n[0].attributes.elevationSource&&!o.z&&l){const e=await b([o],{feature:n[0],currentCoveragePolygon:new A(l),options:i});if(e[0]){const t=e[0];o.elevation=t.z}}const g=f({features:n,selectedPoint:o,camera:N(this.view)?this.view.camera:null,currentImage:this.selectedFeature});g?.sort(((e,t)=>e.suitability-t.suitability));const h=g?.map((e=>e.feature)),c=h[0];this._updateFeatures(h),this._additionalCoveragePolygons=new r,this._additionalFeatureGraphics=new r,this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of this.coveragePolygons)r?.imageID===c?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:G,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:M,visible:!1}));for(const r of this.pointSources)r.imageID===c?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:r.imageID},geometry:{type:"point",...r},symbol:j,visible:!1}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:r.imageID},geometry:{type:"point",...r},symbol:R,visible:!1}));this.selectedFeature=c,this._initialCurrentCoverageUpdate=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:o}=t,s=this.view.toMap(i),a=o[0],n={layerInstanceOrURL:e,point:s,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0,outSpatialReference:s.spatialReference},queryFeatures:null};await this.searchBestImage(n,r)}async _updateFeatures(e){e.length&&(this.features=new r(e),this.notifyChange("features"))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e),this.view)this._overlays?.graphics.addMany([...this._additionalCoveragePolygons??[],...this._additionalFeatureGraphics??[],this._currentCoveragePolygon,this._selectedFeatureGraphic].filter(T));else{const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.selectedFeature?.geometry,currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&this.emit("update-current-coverage",{graphic:e.toJSON()})}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const r=e.attributes.image;this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const i={skipExtensions:["aux.xml","jgw"]};this._currentImage=new _({ioConfig:i,url:r,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const t=await this._currentImage.when();this._imageViewer.extent=t.fullExtent,t.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.constraints.rotationEnabled=!0,this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0),this._imageViewer.constraints.rotationEnabled=!1),this._panConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._panConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:o,ymax:s}=this._currentImage.fullExtent,{width:a,height:n}=this._imageViewer.extent,l=this._imageViewer?.rotation*Math.PI/180,g=Math.abs(Math.cos(l)*a+Math.sin(l)*n),h=Math.abs(Math.cos(l)*n+Math.sin(l)*a),{width:c,height:u}=this._currentImage.rasterInfo;return e.targetGeometry.x=Math.min(Math.max(r+(c>g?g:c)/2,e.targetGeometry.x),i-(c>g?g:c)/2),e.targetGeometry.y=Math.min(Math.max(o+(u>h?h:u)/2,e.targetGeometry.y),s-(u>h?h:u)/2),e}},this._scaleConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._scaleConstraint),this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:o}=this._imageViewer;e.scale=Math.min(e.scale,x(this._imageViewer.spatialReference)*Math.max(t/i,r/o))}return e}},this._imageViewer?.constraints.customConstraints.add(this._panConstraint),this._imageViewer?.constraints.customConstraints.add(this._scaleConstraint),t.addHandles([g((()=>this._imageViewer?.stationary),(e=>{e&&this._imageViewer?.viewpoint&&this._panConstraint?.constrain(this._imageViewer?.viewpoint)}),h)])}catch(s){o.getLogger(this.declaredClass).error("oriented-imagery-viewer:load-image",s)}}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:o}=this;if(!o||!i||!r)return;const{pixelSize:s}=r.rasterInfo,a=await F([o],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=m(p,await O(r.fullExtent,m(E,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*s.x+l.xmin,n.y=l.ymax-n.y*s.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:U.fromJSON(n),symbol:L}),this._imageViewer?.graphics.add(this._crossSymbol)}async plotImagePointOnGround(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await F([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let g=l[0];const h=await O(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);a?(g.x=g.x*s.x+h.xmin,g.y=h.ymax-g.y*s.y,g.spatialReference=h.spatialReference):g=n.forwardTransform(new U(g)),this.plotReferencePointOnImage(g)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:D}),this._overlays?.add(this._referencePointOnGround)}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",..."toJSON"in e?e.toJSON():e},symbol:D}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,g=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,o)],[0,Math.min(i.height,o)]].map((e=>i.toMap(c(e[0],e[1]))));g.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const h=await V(g,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(h&&!r.aborted){const e=[h.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new A({hasZ:!0,rings:e,spatialReference:h[0].spatialReference});this.updateCurrentCoveragePolygon(new t({geometry:r,symbol:G,visible:this.isCurrentCoverageVisible}))}}}};e([u()],k.prototype,"active",null),e([u()],k.prototype,"activeLayer",void 0),e([u()],k.prototype,"shouldShowSelectedImage",void 0),e([u()],k.prototype,"coverageFrustums",void 0),e([u()],k.prototype,"coveragePolygons",void 0),e([u()],k.prototype,"currentImageView",null),e([u()],k.prototype,"displayMessage",void 0),e([u()],k.prototype,"pointSources",void 0),e([u()],k.prototype,"selectedFeature",void 0),e([u()],k.prototype,"selectedPoint",void 0),e([u({readOnly:!0})],k.prototype,"featureCount",null),e([u()],k.prototype,"features",void 0),e([u()],k.prototype,"hasImageLoaded",null),e([u()],k.prototype,"isAdditionalCoverageDisabled",null),e([u()],k.prototype,"isAdditionalCoverageVisible",null),e([u()],k.prototype,"isAdditionalPointSourcesDisabled",null),e([u()],k.prototype,"isAdditionalPointSourcesVisible",null),e([u()],k.prototype,"isCurrentCoverageDisabled",null),e([u()],k.prototype,"isCurrentCoverageVisible",null),e([u()],k.prototype,"updating",null),e([u()],k.prototype,"state",null),e([u()],k.prototype,"view",null),e([u()],k.prototype,"_additionalCoveragePolygons",void 0),e([u()],k.prototype,"_additionalFeatureGraphics",void 0),e([u()],k.prototype,"_currentCoveragePolygon",void 0),e([u()],k.prototype,"_currentImage",void 0),e([u()],k.prototype,"_fetchFeaturesController",void 0),e([u()],k.prototype,"_imageViewer",void 0),e([u()],k.prototype,"_initialCurrentCoveragePolygon",void 0),e([u()],k.prototype,"_initialCurrentCoverageUpdate",void 0),e([u()],k.prototype,"_overlays",void 0),e([u()],k.prototype,"_referencePointOnGround",void 0),e([u()],k.prototype,"_referencePointOnImage",void 0),e([u()],k.prototype,"_selectedFeatureGraphic",void 0),k=e([d("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],k);const H=k;export{H as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import{cast as t}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import s from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";import{isDarkTheme as l}from"../support/themeUtils.js";const c={
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import{cast as t}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import s from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";import{isDarkTheme as l}from"../support/themeUtils.js";const c={addCoverage:"esri-oriented-imagery-viewer__body-additional-coverage",addExpPoints:"esri-oriented-imagery-viewer__body-additional-camera-locations",base:"esri-oriented-imagery-viewer",body:"esri-oriented-imagery-viewer__body",calciteThemeDark:"calcite-mode-dark",calciteThemeLight:"calcite-mode-light",close:"esri-oriented-imagery-viewer__close",currentCoverage:"esri-oriented-imagery-viewer__body-current-coverage",footprint:"esri-oriented-imagery-viewer__body-footprint",header:"esri-oriented-imagery-viewer__header",messageBox:"esri-oriented-imagery-viewer__message-box",submenu:"esri-oriented-imagery-viewer__submenu",title:"esri-oriented-imagery-viewer__title",titleContainer:"esri-oriented-imagery-viewer__title-container",viewer:"esri-oriented-imagery-viewer__viewer",viewerContainer:"esri-oriented-imagery-viewer__viewer-container"},m={closeButton:!0,coverageMenu:!0,imageMenu:!0,viewerTools:!0,title:!0};let p=class extends o{constructor(e,i){super(e,i),this.isDocked=!1,this.viewModel=new s,this.messagesCommon=null,this.visibleElements={...m},this._actionItems=new Map,this.renderTitleContainer=this.renderTitleContainer.bind(this),this.renderTitle=this.renderTitle.bind(this),this.renderViewerContainer=this.renderViewerContainer.bind(this),this.renderViewer=this.renderViewer.bind(this)}loadDependencies(){return n({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js")})}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...m,...e}}_storeActionElement(e){this._actionItems.set(e.text,e)}_toggleAdditionalCameraLocations(){this.viewModel.toggleAdditionalCameraLocations()}_toggleAdditionalCoverage(){this.viewModel.toggleAdditionalCoverage()}_toggleCurrentCoverage(){this.viewModel.toggleCurrentCoverage()}renderActionTooltips(){return[...this._actionItems].map((([e,i])=>d("calcite-tooltip",{key:e,label:e,referenceElement:i},d("span",null,e))))}renderBody(){return d("div",{class:c.body},this.visibleElements.coverageMenu&&this.renderMenuBarContainer(),this.renderViewerContainer())}renderHeader(){return d("div",{class:c.header},this.renderTitleContainer())}renderMenuBarContainer(){const{isCurrentCoverageDisabled:e,isCurrentCoverageVisible:i,isAdditionalCoverageDisabled:t,isAdditionalCoverageVisible:r,isAdditionalPointSourcesDisabled:o,isAdditionalPointSourcesVisible:s}=this.viewModel;return d("calcite-action-bar",{layout:"horizontal",expandDisabled:!0},d("calcite-action-group",{layout:"horizontal"},d("calcite-action",{text:this.messages.currentFootprint,icon:"trapezoid-area",class:c.currentCoverage,bind:this,active:!e&&i,disabled:e,onclick:this._toggleCurrentCoverage,afterCreate:this._storeActionElement}),d("calcite-action",{text:this.messages.additionalFootprints,icon:"trapezoid-area",class:c.addCoverage,bind:this,active:!t&&r,disabled:t,onclick:this._toggleAdditionalCoverage,afterCreate:this._storeActionElement}),d("calcite-action",{text:this.messages.additionalCameraLocations,icon:"circle-area",class:c.addExpPoints,bind:this,disabled:o,active:!o&&s,onclick:this._toggleAdditionalCameraLocations,afterCreate:this._storeActionElement}),this.renderActionTooltips()))}renderMessageBox(){const{displayMessage:e}=this.viewModel;return e?d("span",{class:c.messageBox+"--"+e.type},this.messages[e.key],e?.data):null}renderTitleContainer(){return d("div",{class:c.titleContainer},this.renderTitle())}renderTitle(){return d("span",{class:c.title},this.messages.title)}renderViewerContainer(){return d("div",{class:c.viewerContainer},this.renderViewer(),this.renderMessageBox())}renderViewer(){const{displayMessage:e}=this.viewModel;return d("div",{bind:this,afterCreate:this.viewModel.loadViewer,class:`${c.viewer}${e?"--hide":""}`})}render(){const{updating:e}=this.viewModel;return d("calcite-panel",{class:this.classes(`${c.base}--${this.isDocked?"docked":"floating"}`,l()?c.calciteThemeDark:c.calciteThemeLight),bind:this},this.visibleElements.title&&this.renderHeader(),d("calcite-panel",{loading:e},this.renderBody()))}};e([i()],p.prototype,"isDocked",void 0),e([i({type:s})],p.prototype,"viewModel",void 0),e([i(),a("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],p.prototype,"messages",void 0),e([i(),a("esri/t9n/common")],p.prototype,"messagesCommon",void 0),e([i()],p.prototype,"view",null),e([i()],p.prototype,"visibleElements",void 0),e([t("visibleElements")],p.prototype,"castVisibleElements",null),p=e([r("esri.widgets.OrientedImageryViewer")],p);const g=p;export{g as default};
|