@arcgis/core 4.33.0-next.20250303 → 4.33.0-next.20250304
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/04341d50082f864025aa.js +1 -0
- package/assets/esri/core/workers/chunks/{b49af2e3a1a38a063ab9.js → 1bd4fe77ba6fb25322e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ebdd0701e77bb28c75d.js → 2079f9d28e4199714f22.js} +1 -1
- package/assets/esri/core/workers/chunks/{0fd6a78b38b0e2dae8a5.js → 237a965bd41ba8903e03.js} +1 -1
- package/assets/esri/core/workers/chunks/{4dbd4523281691401272.js → 4539a802cba77a7a7cc7.js} +1 -1
- package/assets/esri/core/workers/chunks/{99f90d085aa9eb13e4fb.js → 46fb6ba8900286d18b6f.js} +1 -1
- package/assets/esri/core/workers/chunks/{2a44a6e75b2799246257.js → 4fb4884d2de42792abe3.js} +1 -1
- package/assets/esri/core/workers/chunks/5295e685ae839087c568.js +1 -0
- package/assets/esri/core/workers/chunks/{d60da671aba70485050e.js → 6e6422eda398774acbc7.js} +1 -1
- package/assets/esri/core/workers/chunks/{c9cb8a6ff01275bec713.js → 77845cd5d824c1004bfa.js} +1 -1
- package/assets/esri/core/workers/chunks/{a73a262ddc959a59819f.js → 7d3b2bdc75525d47389c.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc1aedb2b3aa3854b0de.js → 901c957c049f53318e87.js} +1 -1
- package/assets/esri/core/workers/chunks/{654fe135d41af81daa13.js → 909be86782af3deb448e.js} +1 -1
- package/assets/esri/core/workers/chunks/{7d93ff4f18fd21c7b9f2.js → 94f41ef15f6c61562e5e.js} +1 -1
- package/assets/esri/core/workers/chunks/{8540fb31bd0b29ff1906.js → 968956284f44187f0622.js} +1 -1
- package/assets/esri/core/workers/chunks/{92b48e3365d1cc933113.js → 96d2a0777f5c418055fb.js} +1 -1
- package/assets/esri/core/workers/chunks/988efc508c33ca341e49.js +1 -0
- package/assets/esri/core/workers/chunks/{56db71ea7eb8a5652d98.js → abfc5f9ac16c3e885c5f.js} +1 -1
- package/assets/esri/core/workers/chunks/{856b03020b2dd047291d.js → ad9b3b83aa96db7b79ea.js} +1 -1
- package/assets/esri/core/workers/chunks/{c3b2b05996e2008adbe3.js → afddb94ff4e1a70022c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{c409bb2acd846d3b1395.js → b2f9f0767dadf185120c.js} +1 -1
- package/assets/esri/core/workers/chunks/{563594357f3648652a5c.js → ba917175ca2a6681501e.js} +1 -1
- package/assets/esri/core/workers/chunks/c03e6e35082beaec02a6.js +1 -0
- package/assets/esri/core/workers/chunks/{759781cad91d31ab7bc4.js → db4c110ab4c26c4b768c.js} +1 -1
- package/assets/esri/core/workers/chunks/dcb043986fb065de0366.js +1 -0
- package/assets/esri/core/workers/chunks/{05c80002c37002ac99e8.js → de16b771d2c8d816c738.js} +1 -1
- package/assets/esri/core/workers/chunks/{3010a22d00f45fce5939.js → e0ac90b4ad8c36fb7d70.js} +1 -1
- package/assets/esri/core/workers/chunks/{5719471414810b6a9aec.js → e56647e61296643c5f84.js} +1 -1
- package/assets/esri/core/workers/chunks/{1bc22af4cc4effcbcf2b.js → e6a5911ea21bef32834b.js} +1 -1
- package/assets/esri/core/workers/chunks/{2f818b9a6b1f2b61410d.js → e99d7ecb80a9df9ead6d.js} +24 -24
- package/assets/esri/core/workers/chunks/{12d798775a96a45aada2.js → f46c4a69ef2f763e905b.js} +1 -1
- package/assets/esri/core/workers/chunks/{5e80e10b7c7e66dd861e.js → febae745a29a17ca130a.js} +1 -1
- package/chunks/Bufferer-CicaNej1.js +1 -1
- package/chunks/DefaultMaterial.glsl.js +22 -22
- package/chunks/Distance2DCalculator-C1KHhZwD.js +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/GeodeticDistanceCalculator-CcF1gMZX.js +1 -1
- package/chunks/OperatorClip.js +1 -1
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/ProjectionTransformation.js +1 -1
- package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
- package/chunks/disjointOperator.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
- package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
- package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +5 -0
- package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +5 -0
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/json/disjointOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/support/apiConverter.js +1 -1
- package/geometry/operators/support/initNoPeFactory.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/interfaces.d.ts +12 -14
- package/layers/WMTSLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/dehydratedFeatures.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/wmtsUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
- package/views/3d/layers/support/projectExtentUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/View.js +1 -1
- package/views/support/LayerLayerViewInfo.js +5 -0
- package/views/support/LayerViewManager.js +5 -0
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/Feature/FeatureRelationship.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/Features/FeaturesDrillIn.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeaturesDrillIn.js +1 -1
- package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +1 -1
- package/assets/esri/core/workers/chunks/0e6d338b0937724763c7.js +0 -1
- package/assets/esri/core/workers/chunks/7d120f8b01fe719eb257.js +0 -1
- package/assets/esri/core/workers/chunks/95047f145ebda65c3d8e.js +0 -1
- package/assets/esri/core/workers/chunks/960b12a6fd5b6933212f.js +0 -1
- package/assets/esri/core/workers/chunks/af005704f23088db3ded.js +0 -1
- package/editing/sharedTemplates/executor/support/createServiceEdit.js +0 -5
- package/views/LayerViewManager.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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as n}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import"../../core/has.js";import o from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as j,isSharedPresetTemplate as I,isStandardFeatureTemplate as T,isSharedFeatureTemplate as V,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as x,getDisplayFieldName as M}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as P}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as R,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as q}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as J}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as H,filterGraphicHits as K}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function $(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!oe(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===i.length&&(r=ee(i[0],t));const o=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&R(e)===E.RealWorldSize));return 1===o.length&&(n=ne(o[0],t)),{rotation:r,size:n}}function ee(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=e.field,i=t.fields&&t.fields.filter((e=>e.name===n)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0};return{field:n,fieldType:o,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ie((a.current+360)%360,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function re(e,t,r){if(null==t)return 0;const{symbol:n}=q(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const i=n.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Me.icon,(await e(i,Me.icon))[0])||Me.icon}case"text":return Me.text;case"line":return Me.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(i,e.scale/Me.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Me.viewScaleSizeFactor;default:return 0}}function ne(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:o,getDefaultValue:async(e,t)=>ie(l(await re(t,e,n)),o),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ie(a.current,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ce(e.valueUnit),axis:e.axis}}function ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function oe(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ae(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,n)&&(e.symbol=n)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:J,optionsPerTool:r};if(S(t)){const i=t.defaultTool,o=j(t)?t.definition?.inputGeometryType??e:e;switch(i){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const i=t.drawingTool;if("circle"===i||"ellipse"===i)return r.get("circle").preserveAspectRatio="circle"===i,{tool:"circle",createOptions:n};if("rectangle"===i)return{tool:"rectangle",createOptions:n};if("freehand"===i)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function le(e,t,r){const{creationInfo:n,fullTemplate:i}=t;if(!n)throw new o("No creation info provided.");const a=n.layer,s=me(i,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;j(i)||I(i)||await ge(e,a,s,r,c?l.scale:null);const{capabilities:u}=a;e.layer.elevationInfo=a.elevationInfo;const p=se(a.geometryType,i);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}}),ce({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function ce(e){return a([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:i}){const{creationInfo:o}=t,{fullTemplate:a}=t;if(!o||"2d"!==n?.type||j(a)||I(a))return null;const s=f((t=>ge(r,o.layer,e,i,t)));return g((()=>n.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:i}=t;if(!i)return null;const l=r.activeComponent;if(!n||!X(l))return Y().error(new o("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=i,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=ye(e,d);t&&c.add(t)}}})),s((()=>{n.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function ye(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function fe(e,t){const r=await N(t).load(),n=P(e)?e.parent:e,i=r.tablesAndLayersLookup.get(n);if(!i)return new Map;const o=new Map;for(const a of i.layersAndTables)p(o,a.layerId,(()=>[])).push(a);return o}function me(e,t={}){return j(e)||I(e)?{}:T(e)?{...e.prototype.attributes,...t}:V(e)?{...e.definition?.defaultValues,...t}:{...t}}async function ge(e,r,n,i,o){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=_(a);let c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}he(e.tooltipOptions,l,s)}function he(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function we(e,t){return e?.find((e=>e.layer===t))}async function be(e,t,r,n){switch(t.type){case"3d":return ve(e,t,r,n);case"2d":return Se(e,t,r,n)}}async function ve(e,t,n,i){if(0===e.length)return[];const{updatable:o,graphicsByLayer:a}=await n.async((async()=>{const{results:r}=await d(H(t,n),i),o=new Map,a=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};K(r).forEach((({graphic:e})=>a(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&n.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return d(Promise.allSettled(o.map((async({layer:e})=>{const t=a.get(e),n=je(e);if(t.every((e=>A(n,e))))return t;const o=[];for(const i of t){o.push(i.getObjectId());const e=Object.keys(i.attributes);r(n,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=x(e.fieldsIndex,n),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function Se(e,t,r,n){if(0===e.length)return[];const{mapPoint:i}=r;if(null==i)return[];let o=null;const a=await r.async((async()=>{const{results:i}=await d(t.hitTest(r),n);if(0===i.length)return[];const a=new Set;o=K(i),o.forEach((({graphic:e})=>e&&a.add(e.layer)));const s=e.filter((e=>a.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(a.map((async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=je(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=W(i,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function je(e){return x(e.fieldsIndex,[e.objectIdField,M({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ie(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,"scene"===n.type&&null!=n.infoFor3D||(i.outSpatialReference=t);const o=await n.queryFeatures(i,{signal:r});y(r);return o.features[0]}async function Te(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i}=e;await Ve(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=i.rotation,o.enableScaling=null!=i.size),r.update(t,o)}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i,webStyleCache:o}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===r.view?.type?r.view.scale:null;await ae(t,o,e)}he(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ue(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Le(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function ke(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const o=n.rotation,a=Ue(r.toolEventInfo);if(null!=o&&null!=a){const{field:r,getValue:n}=o;"rotate-stop"===a.type?(o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(r))):(o.isUpdatingInteractively=!0,t.setAttribute(r,n(a.angle,e)))}const s=n.size,l=Le(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:n}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,n(l.xScale,e)))}await ae(t,i,"2d"===e.type?e.scale:null)}async function Fe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:i,onUpdate:o,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await ae(t,c,"2d"===i.type?i.scale:null);let d=null;if("2d"===n?.view?.type){const e=f((e=>ae(t,c,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ge(i,y);await Te({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const i=e[n];i!==t.getAttribute(n)&&(t.setAttribute(n,i),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(i),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(i),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ae(t,c,"2d"===i.type?i.scale:null)})),j=n.on("update",(async e=>{const t=e.graphics[0],a={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===i.activeTool)return Te(a);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===i.activeTool),e.signal).then((()=>(e.abort(),Te(a)))))}await ke(i,t,e,r,c),o(Ze(t),e)})),I=n.on(["undo","redo"],(async e=>{o(Ze(e.graphics[0]),e)}));return a([I,j,s((()=>n.cancel())),S,d])}async function Oe(e,t,r){const n=e.view;e.layer.add(r);const o=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=i((async t=>{const r=await Ge(n,o);y(t),r.setVisibility?.(c,e)}))}return await xe(n,r),p(!1),a([Ae(n,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ge(n,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return a([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function xe(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const Me={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Pe(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function ze(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,n=U(e);1===n.length&&"scene"!==e.type&&(r.template=n[0],t.shift())}return t}function Ce(e){return"unknown"===e?null:e}function Re(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ee=e=>/-stop/.test(e)||/vertex-/.test(e),Ge=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function De(e){return"createInteractiveEditSession"in e}function Ze(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function qe(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Be(e,t){const{template:r}=e;if(null==r)return null;if(L(r))return r.load();if(S(r)){const e=F(t,{makeSharedTemplateFromJSON:Qe}),n=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new o("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function Ne(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:i}=t;e.setAttribute(r,n.getAttribute(i))}}const Qe=e=>k.fromJSON(e);export{ze as avoidFeatureTemplateSelectionWithOnlyOneItem,De as canCreateInteractiveEditSession,Ze as cloneGraphicExceptMesh,se as createToolFromGeometryType,Pe as createWorkflowSteps,be as fetchCandidates,Ie as fetchFullFeature,we as findLayerInfo,me as getCreationAttributes,Be as getFullTemplateForCreationInfo,fe as getServiceLayersById,_ as getVisualVariableAttributes,Ee as isTerminalUpdateEventType,$ as isUpdateWorkflow,Re as prepareAttachmentsForCreateFeaturesWorkflow,Ne as setRelationshipFields,Fe as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ve as setVisualVariablesAndElevationInfoForUpdate,qe as showProgressCursor,Me as sizeDefaults,Ce as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,Te as startUpdatingFeatureGeometry,Oe as swapForEditingSession,ae as updateGraphicSymbolWhenRequired,ke as visualVariableInteractiveUpdate,Ge as whenEditorLayerView,xe as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as n}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import"../../core/has.js";import o from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as f,debounce as y,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as j,isSharedPresetTemplate as I,isStandardFeatureTemplate as T,isSharedFeatureTemplate as V,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as x,getDisplayFieldName as M}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as P}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as R,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as q}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as J}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as H,filterGraphicHits as K}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function $(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!oe(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===i.length&&(r=ee(i[0],t));const o=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&R(e)===E.RealWorldSize));return 1===o.length&&(n=ne(o[0],t)),{rotation:r,size:n}}function ee(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=e.field,i=t.fields&&t.fields.filter((e=>e.name===n)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0};return{field:n,fieldType:o,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ie((a.current+360)%360,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function re(e,t,r){if(null==t)return 0;const{symbol:n}=q(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const i=n.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Me.icon,(await e(i,Me.icon))[0])||Me.icon}case"text":return Me.text;case"line":return Me.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(i,e.scale/Me.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Me.viewScaleSizeFactor;default:return 0}}function ne(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:o,getDefaultValue:async(e,t)=>ie(l(await re(t,e,n)),o),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ie(a.current,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ce(e.valueUnit),axis:e.axis}}function ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function oe(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ae(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,n)&&(e.symbol=n)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:J,optionsPerTool:r};if(S(t)){const i=t.defaultTool,o=j(t)?t.definition?.inputGeometryType??e:e;switch(i){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const i=t.drawingTool;if("circle"===i||"ellipse"===i)return r.get("circle").preserveAspectRatio="circle"===i,{tool:"circle",createOptions:n};if("rectangle"===i)return{tool:"rectangle",createOptions:n};if("freehand"===i)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function le(e,t,r){const{creationInfo:n,fullTemplate:i}=t;if(!n)throw new o("No creation info provided.");const a=n.layer,s=me(i,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;j(i)||I(i)||await ge(e,a,s,r,c?l.scale:null);const{capabilities:u}=a;e.layer.elevationInfo=a.elevationInfo;const p=se(a.geometryType,i);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}})}async function ce(e){return a([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:i}){const{creationInfo:o}=t,{fullTemplate:a}=t;if(!o||"2d"!==n?.type||j(a)||I(a))return null;const s=y((t=>ge(r,o.layer,e,i,t)));return g((()=>n.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:i}=t;if(!i)return null;const l=r.activeComponent;if(!n||!X(l))return Y().error(new o("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=i,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=fe(e,d);t&&c.add(t)}}})),s((()=>{n.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function fe(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function ye(e,t){const r=await N(t).load(),n=P(e)?e.parent:e,i=r.tablesAndLayersLookup.get(n);if(!i)return new Map;const o=new Map;for(const a of i.layersAndTables)p(o,a.layerId,(()=>[])).push(a);return o}function me(e,t={}){return j(e)||I(e)?{}:T(e)?{...e.prototype.attributes,...t}:V(e)?{...e.definition?.defaultValues,...t}:{...t}}async function ge(e,r,n,i,o){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=_(a);let c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}he(e.tooltipOptions,l,s)}function he(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function we(e,t){return e?.find((e=>e.layer===t))}async function be(e,t,r,n){switch(t.type){case"3d":return ve(e,t,r,n);case"2d":return Se(e,t,r,n)}}async function ve(e,t,n,i){if(0===e.length)return[];const{updatable:o,graphicsByLayer:a}=await n.async((async()=>{const{results:r}=await d(H(t,n),i),o=new Map,a=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};K(r).forEach((({graphic:e})=>a(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&n.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return d(Promise.allSettled(o.map((async({layer:e})=>{const t=a.get(e),n=je(e);if(t.every((e=>A(n,e))))return t;const o=[];for(const i of t){o.push(i.getObjectId());const e=Object.keys(i.attributes);r(n,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=x(e.fieldsIndex,n),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function Se(e,t,r,n){if(0===e.length)return[];const{mapPoint:i}=r;if(null==i)return[];let o=null;const a=await r.async((async()=>{const{results:i}=await d(t.hitTest(r),n);if(0===i.length)return[];const a=new Set;o=K(i),o.forEach((({graphic:e})=>e&&a.add(e.layer)));const s=e.filter((e=>a.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(a.map((async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=je(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=W(i,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function je(e){return x(e.fieldsIndex,[e.objectIdField,M({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ie(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,"scene"===n.type&&null!=n.infoFor3D||(i.outSpatialReference=t);const o=await n.queryFeatures(i,{signal:r});f(r);return o.features[0]}async function Te(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i}=e;await Ve(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=i.rotation,o.enableScaling=null!=i.size),r.update(t,o)}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i,webStyleCache:o}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===r.view?.type?r.view.scale:null;await ae(t,o,e)}he(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ue(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Le(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function ke(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const o=n.rotation,a=Ue(r.toolEventInfo);if(null!=o&&null!=a){const{field:r,getValue:n}=o;"rotate-stop"===a.type?(o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(r))):(o.isUpdatingInteractively=!0,t.setAttribute(r,n(a.angle,e)))}const s=n.size,l=Le(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:n}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,n(l.xScale,e)))}await ae(t,i,"2d"===e.type?e.scale:null)}async function Fe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:i,onUpdate:o,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await ae(t,c,"2d"===i.type?i.scale:null);let d=null;if("2d"===n?.view?.type){const e=y((e=>ae(t,c,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,m=Ge(i,f);await Te({graphic:t,sketchViewModel:n,sourceLayer:f,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const i=e[n];i!==t.getAttribute(n)&&(t.setAttribute(n,i),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(i),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(i),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ae(t,c,"2d"===i.type?i.scale:null)})),j=n.on("update",(async e=>{const t=e.graphics[0],a={graphic:t,sketchViewModel:n,sourceLayer:f,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===i.activeTool)return Te(a);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===i.activeTool),e.signal).then((()=>(e.abort(),Te(a)))))}await ke(i,t,e,r,c),o(Ze(t),e)})),I=n.on(["undo","redo"],(async e=>{o(Ze(e.graphics[0]),e)}));return a([I,j,s((()=>n.cancel())),S,d])}async function Oe(e,t,r){const n=e.view;e.layer.add(r);const o=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=i((async t=>{const r=await Ge(n,o);f(t),r.setVisibility?.(c,e)}))}return await xe(n,r),p(!1),a([Ae(n,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ge(n,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return a([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function xe(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const Me={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Pe(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function ze(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,n=U(e);1===n.length&&"scene"!==e.type&&(r.template=n[0],t.shift())}return t}function Ce(e){return"unknown"===e?null:e}function Re(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ee=e=>/-stop/.test(e)||/vertex-/.test(e),Ge=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function De(e){return"createInteractiveEditSession"in e}function Ze(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function qe(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Be(e,t){const{template:r}=e;if(null==r)return null;if(L(r))return r.load();if(S(r)){const e=F(t,{makeSharedTemplateFromJSON:Qe}),n=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new o("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function Ne(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:i}=t;e.setAttribute(r,n.getAttribute(i))}}const Qe=e=>k.fromJSON(e);export{ze as avoidFeatureTemplateSelectionWithOnlyOneItem,De as canCreateInteractiveEditSession,Ze as cloneGraphicExceptMesh,se as createToolFromGeometryType,Pe as createWorkflowSteps,be as fetchCandidates,Ie as fetchFullFeature,we as findLayerInfo,me as getCreationAttributes,Be as getFullTemplateForCreationInfo,ye as getServiceLayersById,_ as getVisualVariableAttributes,Ee as isTerminalUpdateEventType,$ as isUpdateWorkflow,Re as prepareAttachmentsForCreateFeaturesWorkflow,Ne as setRelationshipFields,Fe as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ve as setVisualVariablesAndElevationInfoForUpdate,qe as showProgressCursor,Me as sizeDefaults,Ce as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,Te as startUpdatingFeatureGeometry,Oe as swapForEditingSession,ae as updateGraphicSymbolWhenRequired,ke as visualVariableInteractiveUpdate,Ge as whenEditorLayerView,xe as whenGraphicDisplayed};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import l from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import s from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as b}from"../../FeatureForm/featureFormUtils.js";const g=100;let _=class extends(l.ClonableMixin(s.IdentifiableMixin(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,g),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,g),this._queryPageDebounced=n(this._queryPageController,g),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.destroyAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.destroyAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&null!=this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10,o=3;this._set("displayCount",Math.min(Math.max(e??o,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?C(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return null!=e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}refresh(){this._queryFeatureCountDebounced()}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.destroyAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t||null==o)return void this._set("featureCount",0);const i=t.createQuery(),{historicMoment:n,gdbVersion:u}=e,d=new p({cacheHint:s,gdbVersion:u,historicMoment:n,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),h=await e.queryRelatedFeaturesCount(d,{signal:l?.signal});this._set("featureCount",h[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:h}=this,{canQuery:y,objectId:c}=this;if(!y||!s||!d||null==c)return[];const C=r?((n-1)*l+u)%u:0,g=r?l:a,_=d.objectIdField,F=[...t.map((e=>e.field)),...b(d),_].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),{historicMoment:q,gdbVersion:A}=s,P=new p({orderByFields:m,start:C,num:g,outFields:F,cacheHint:h,historicMoment:q,gdbVersion:A,relationshipId:i,returnGeometry:!1,objectIds:[c],where:f.where??void 0}),w=await s.queryRelatedFeatures(P,{signal:e?.signal}),j=w[c]?.features||[];return j.forEach((e=>{e.sourceLayer=d,e.layer=d})),j}};e([h()],_.prototype,"_loaded",void 0),e([h()],_.prototype,"_queryAbortController",void 0),e([h()],_.prototype,"_queryPageAbortController",void 0),e([h()],_.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],_.prototype,"featurePage",null),e([h()],_.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],_.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],_.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],_.prototype,"canLoad",null),e([h({readOnly:!0})],_.prototype,"canQuery",null),e([h()],_.prototype,"description",void 0),e([h({readOnly:!0})],_.prototype,"itemDescriptionFieldName",null),e([h({value:3})],_.prototype,"displayCount",null),e([h({type:t})],_.prototype,"graphic",void 0),e([h()],_.prototype,"layer",void 0),e([h()],_.prototype,"map",void 0),e([h({readOnly:!0})],_.prototype,"objectId",null),e([h({readOnly:!0})],_.prototype,"objectIdField",null),e([h()],_.prototype,"orderByFields",void 0),e([h({readOnly:!0})],_.prototype,"relatedFeatures",null),e([h({readOnly:!0})],_.prototype,"relatedLayer",null),e([h({readOnly:!0})],_.prototype,"relationship",null),e([h()],_.prototype,"featureCount",void 0),e([h({readOnly:!0})],_.prototype,"relatedFeatureViewModels",null),e([h()],_.prototype,"relationshipId",void 0),e([h()],_.prototype,"showAllEnabled",void 0),e([h()],_.prototype,"state",null),e([h()],_.prototype,"title",void 0),_=e([y("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],_);const F=_;export{F as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import l from"../../../core/Clonable.js";import i from"../../../core/Collection.js";import a from"../../../core/Identifiable.js";import{ignoreAbortErrors as s,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,isRelatableFeatureSupportedLayer as g,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as b}from"../../FeatureForm/featureFormUtils.js";const F=100;let _=class extends(l.ClonableMixin(a.IdentifiableMixin(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.activeCategory=null,this.categories=null,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await s(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await s(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await s(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,F),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,F),this._queryPageDebounced=n(this._queryPageController,F),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&("subtype-group"!==this.relatedLayer?.type||this.activeCategory)&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.destroyAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount,this.activeCategory]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery,this.activeCategory]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.destroyAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&null!=this.objectId&&e?.supportsCount&&e?.supportsPagination)}set displayCount(e){const t=0,r=10,o=3;this._set("displayCount",Math.min(Math.max(e??o,t),r))}get displayCount(){return this._get("displayCount")}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new i}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;if(!e?.loaded||!t||!r)return null;const o="subtype-sublayer"===e.type&&e.parent&&g(e.parent)?e.parent:e;return C(t,o,r)??null}get relatedLayerKeyField(){const{relatedLayer:e,relationshipId:t}=this;return e?.loaded&&null!=t?e.relationships?.find((e=>e.id===t))?.keyField:null}get relatedLayerKeyFields(){const{relatedLayer:e}=this;return e?.loaded?e.relationships?.map((e=>e.keyField)).filter(o)??[]:[]}get relationship(){const{relationshipId:e,layer:t}=this;return null!=e&&t?.loaded?t.relationships?.find((({id:t})=>t===e))??null:null}get relationshipKey(){const{relationshipKeyField:e}=this;return(e&&this.graphic?.attributes?.[e])??null}get relationshipKeyField(){return this.relationship?.keyField||null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new i}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:i}=this;return t||i&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}refresh(){this._queryFeatureCountDebounced()}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.destroyAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t}=this;await(e?.load()),await(t?.load());const{_queryFeatureCountAbortController:r,activeCategory:l,canQuery:i,displayCount:a,objectId:s,relatedLayerKeyField:n,relationshipId:u,relationshipKey:d,showAllEnabled:y,supportsCacheHint:h}=this;if(!i||!e||!t||null==s)return this._set("featureCount",0),void this._set("categories",null);if("subtype-group"===t?.type&&!l){if(this._set("featureCount",0),this._destroyRelatedFeatureViewModels(),this.featurePage=1,this.relatedFeatures.destroyAll(),n&&null!=d){const{default:e}=await import("../../../smartMapping/statistics/uniqueValues.js"),{uniqueValueInfos:l}=await e({layer:t,sqlWhere:`${n} = '${d}'`,field:t.subtypeField,signal:r?.signal}),i=l.map((({count:e,value:r})=>{const o=t.subtypes?.find((e=>e.code===r))?.name;return null!=r&&o?{count:e,value:r,name:o}:void 0})).filter(o);this._set("categories",y?i:i.slice(0,a))}return}const{historicMoment:c,gdbVersion:g}=e,C=new p({cacheHint:h,gdbVersion:g,historicMoment:c,relationshipId:u,returnGeometry:!1,objectIds:[s],where:this._getRelationshipWhereClause(t)}),b=await e.queryRelatedFeaturesCount(C,{signal:r?.signal});this._set("categories",null),this._set("featureCount",b[s]||0)}_getRelationshipWhereClause(e){const{activeCategory:t}=this,r=e.createQuery(),o="subtypeField"in e?e.subtypeField:void 0,l=t&&o?`${o} = ${t.value}`:void 0,i=r.where;return i&&l?`(${i}) AND (${l})`:i??l}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||"subtype-group"===this.relatedLayer?.type&&!this.activeCategory||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{displayCount:t,featureCount:r,featurePage:l,featuresPerPage:i,layer:a,orderByFieldsFixedCasing:s,relatedLayer:n,relatedLayerKeyFields:u,relationshipId:d,showAllEnabled:y,supportsCacheHint:h}=this,{canQuery:c,objectId:g}=this;if(!c||!a||!n||null==g)return[];const C=y?((l-1)*i+r)%r:0,F=y?i:t,_=n.objectIdField,f="subtypeField"in n?n.subtypeField:void 0,m=[...s.map((e=>e.field)),...b(n),...u,_,f].filter(o),q=s.map((e=>`${e.field} ${e.order}`)),{historicMoment:A,gdbVersion:w}=a,P=new p({orderByFields:q,start:C,num:F,outFields:m,cacheHint:h,historicMoment:A,gdbVersion:w,relationshipId:d,returnGeometry:!1,objectIds:[g],where:this._getRelationshipWhereClause(n)}),v=await a.queryRelatedFeatures(P,{signal:e?.signal}),j=v[g]?.features||[];return"subtype-group"===n.type&&f?j.forEach((e=>{const t=e.attributes[f],r=n.findSublayerForSubtypeCode?.(t);e.sourceLayer=r,e.layer=r})):j.forEach((e=>{e.sourceLayer=n,e.layer=n})),j}};e([y()],_.prototype,"_loaded",void 0),e([y()],_.prototype,"_queryAbortController",void 0),e([y()],_.prototype,"_queryPageAbortController",void 0),e([y()],_.prototype,"_queryFeatureCountAbortController",void 0),e([y({value:1})],_.prototype,"featurePage",null),e([y()],_.prototype,"featuresPerPage",void 0),e([y({readOnly:!0})],_.prototype,"orderByFieldsFixedCasing",null),e([y({readOnly:!0})],_.prototype,"supportsCacheHint",null),e([y({readOnly:!0})],_.prototype,"canLoad",null),e([y({readOnly:!0})],_.prototype,"canQuery",null),e([y()],_.prototype,"activeCategory",void 0),e([y({readOnly:!0})],_.prototype,"categories",void 0),e([y()],_.prototype,"description",void 0),e([y({value:3})],_.prototype,"displayCount",null),e([y({type:t})],_.prototype,"graphic",void 0),e([y({readOnly:!0})],_.prototype,"itemDescriptionFieldName",null),e([y()],_.prototype,"layer",void 0),e([y()],_.prototype,"map",void 0),e([y({readOnly:!0})],_.prototype,"objectId",null),e([y({readOnly:!0})],_.prototype,"objectIdField",null),e([y()],_.prototype,"orderByFields",void 0),e([y({readOnly:!0})],_.prototype,"relatedFeatures",null),e([y({readOnly:!0})],_.prototype,"relatedLayer",null),e([y({readOnly:!0})],_.prototype,"relatedLayerKeyField",null),e([y({readOnly:!0})],_.prototype,"relatedLayerKeyFields",null),e([y({readOnly:!0})],_.prototype,"relationship",null),e([y({readOnly:!0})],_.prototype,"relationshipKey",null),e([y({readOnly:!0})],_.prototype,"relationshipKeyField",null),e([y({readOnly:!0})],_.prototype,"featureCount",void 0),e([y({readOnly:!0})],_.prototype,"relatedFeatureViewModels",null),e([y()],_.prototype,"relationshipId",void 0),e([y()],_.prototype,"showAllEnabled",void 0),e([y()],_.prototype,"state",null),e([y()],_.prototype,"title",void 0),_=e([h("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],_);const f=_;export{f 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as g}from"../support/jsxFactory.js";import{substitute as _}from"../../intl/substitute.js";import{formatNumber as f}from"../../intl/number.js";var b;const y="esri-feature",I=`${y}-relationship`,F={base:I,listContainer:`${I}__list`,listItem:`${I}__list-item`,listItemHidden:`${I}__list-item--hidden`,listContainerQuerying:`${I}__list--querying`,featureObserver:`${y}__feature-observer`,stickySpinnerContainer:`${y}__sticky-loading-container`,loadingSpinnerContainer:`${y}__loading-container`},M={title:!0,description:!0};let C=b=class extends c{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.flowItems=null,this.flowType="feature-relationship",this.headingLevel=2,this.viewModel=new u,this.messages=null,this.messagesCommon=null,this.visibleElements={...M},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new h,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return p({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i,categories:r}=this.viewModel;return!e&&"ready"===i&&((r?.length??0)>s||0===s||!!t&&(t>s||0===s))}get displayListItems(){const{relatedFeatureViewModels:e,categories:t}=this.viewModel;return this.displayShowAllButton||!!e.length||!!t?.length}get allItemsDescription(){const{messages:e}=this,{featureCount:t,categories:s}=this.viewModel;return _(e?.numberRecords,{number:f(s?.length??t)})}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){const{activeCategory:e,title:t}=this.viewModel;return e?.name??t}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...M,...e}}render(){const{state:e}=this.viewModel;return g("div",{class:this.classes(F.base,m.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderRelationshipNotFound():this._renderRelatedFeatures())}async _selectCategory(e){const{flowItems:t,featureVisibleElements:s,viewModel:i}=this;t&&(i.activeCategory=e,i.showAllEnabled=!0,t.push(new b({flowItems:t,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:i})))}async _selectRecord(e){const{flowItems:t,featureVisibleElements:s}=this;if(!t)return;e.abilities={relationshipContent:!0};const{default:i}=await import("../Feature.js");t.push(new i({flowItems:t,flowType:this.flowType,viewModel:e,visibleElements:s}))}_showAllRecords(){const{flowItems:e}=this;if(!e)return;const{viewModel:t,featureVisibleElements:s}=this;t.showAllEnabled=!0;const i=new b({flowItems:e,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:t});e.push(i)}_renderStickyLoading(){return"querying"===this.viewModel.state?g("div",{class:F.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return g("calcite-loader",{inline:!0,label:""})}_renderLoading(){return g("div",{class:F.loadingSpinnerContainer,key:"loading-container"},this._renderLoadingIcon())}_renderShowAllIconNode(){return g("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})}_renderChevronIconNode(){const e=v(this.container)?"chevron-left":"chevron-right";return g("calcite-icon",{icon:e,scale:"s",slot:"content-end"})}_renderCategory(e){const{count:t,name:s,value:i}=e,r=f(t);return g("calcite-list-item",{class:F.listItem,disabled:!t,key:i,label:s,onCalciteListItemSelect:()=>this._selectCategory(e)},g("calcite-chip",{label:r,scale:"s",slot:"content-end"},r),this._renderChevronIconNode())}_renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return g("calcite-list-item",{class:this.classes(F.listItem,{[F.listItemHidden]:i}),description:n(e.description??""),key:e.uid,label:n(s),onCalciteListItemSelect:()=>this._selectRecord(e)},this._renderChevronIconNode())}_renderShowAllListItem(){return this.displayShowAllButton?g("calcite-list-item",{description:this.allItemsDescription,key:"show-all-item",label:this.messages?.showAll,onCalciteListItemSelect:()=>this._showAllRecords()},this._renderShowAllIconNode()):null}_renderNoRelatedFeaturesMessage(){return g("calcite-notice",{icon:"information",key:"no-related-features-message",kind:"brand",open:!0,scale:"s",width:"full"},g("div",{slot:"message"},this.messages?.noRelatedFeatures))}_renderFeatureObserver(){return g("div",{afterCreate:this._relatedFeatureIntersectionObserverCreated,bind:this,class:F.featureObserver,key:"feature-observer"})}_renderList(){const{relatedFeatureViewModels:e,categories:t}=this.viewModel;return g("calcite-list",{displayMode:"flat",label:this.messages?.relatedFeaturesList},t?.map((e=>this._renderCategory(e)))??e.toArray().map((e=>this._renderRelatedFeature(e))),this._renderShowAllListItem())}_renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return g("div",{class:this.classes(F.listContainer,{[F.listContainerQuerying]:"querying"===t}),key:"list-container"},e?this._renderList():"ready"===t?this._renderNoRelatedFeaturesMessage():null,this._renderStickyLoading(),this._renderFeatureObserver())}_renderRelationshipNotFound(){return g("calcite-notice",{icon:"exclamation-mark-triangle",key:"relationship-not-found",kind:"danger",open:!0,scale:"s",width:"full"},g("div",{slot:"message"},this.messages?.relationshipNotFound))}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([l()],C.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([l({readOnly:!0})],C.prototype,"displayShowAllButton",null),e([l({readOnly:!0})],C.prototype,"displayListItems",null),e([l({readOnly:!0})],C.prototype,"allItemsDescription",null),e([l()],C.prototype,"description",null),e([l()],C.prototype,"featureVisibleElements",void 0),e([l()],C.prototype,"flowItems",void 0),e([l()],C.prototype,"flowType",void 0),e([l()],C.prototype,"headingLevel",void 0),e([l()],C.prototype,"title",null),e([l({type:u})],C.prototype,"viewModel",void 0),e([l(),w("esri/widgets/Feature/t9n/Feature")],C.prototype,"messages",void 0),e([l(),w("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([l()],C.prototype,"visibleElements",void 0),e([a("visibleElements")],C.prototype,"castVisibleElements",null),C=b=e([d("esri.widgets.Feature.FeatureRelationship")],C);const E=C;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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"content-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,I=/'/g,h=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,j=/^(?:mailto:|tel:)/,N="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!j.test(e.trim().toLowerCase())}function E(e){return!!e&&h.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const n=t.replace(h,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=v(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function U(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function A(e){return e.replaceAll(b,"")}function M(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?O({formattedAttributes:t,template:P(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function O({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(A(t(t(n,(e=>U(e,r))),e)))}function z(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>z(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function Q(e,t){return e.replaceAll(g,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function P(e,t,n){const r=Q(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ne({fieldName:e,value:t,graphic:n,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function ie(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=M(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function oe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=ne({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return W(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function fe(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function de({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(N)}function ye(e){return`${N}${e.layerId}/${e.fieldName}`}function me({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ie=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},he=({query:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?Ne({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):Ne({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function je(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function Ne({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=Ne({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||Ne({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?je(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?je(e,o):o}return null}function Ze(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,re as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,C as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,Ze as getHighlightKeyForFeature,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,he as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,O as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|
|
5
|
+
import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,I=/'/g,h=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,j=/^(?:mailto:|tel:)/,N="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!j.test(e.trim().toLowerCase())}function E(e){return!!e&&h.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const n=t.replace(h,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=v(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function U(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function A(e){return e.replaceAll(b,"")}function M(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?O({formattedAttributes:t,template:P(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function O({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(A(t(t(n,(e=>U(e,r))),e)))}function z(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>z(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function Q(e,t){return e.replaceAll(g,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function P(e,t,n){const r=Q(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ne({fieldName:e,value:t,graphic:n,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function ie(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=M(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function oe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=ne({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return W(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function fe(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function de({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(N)}function ye(e){return`${N}${e.layerId}/${e.fieldName}`}function me({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ie=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},he=({query:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?Ne({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):Ne({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function je(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function Ne({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=Ne({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||Ne({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?je(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?je(e,o):o}return null}function Ze(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,re as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,C as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,Ze as getHighlightKeyForFeature,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,he as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,O as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as d}from"../../core/string.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import g from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as y,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as N,isRelationshipInput as k,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as H}from"./featureFormUtils.js";import U from"./FieldInput.js";import{FormExpressionsManager as Z}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import G from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as $}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const D=new t({attributes:{}}),z={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},J="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",B="#JSAPI_CONTINGENT_VALUE_ANY_HASH",K="#JSAPI_CONTINGENT_VALUE_NULL_HASH",Y="esri.widgets.FeatureForm.FeatureFormViewModel",q=()=>i.getLogger(Y);let Q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=D.clone(),this._initialFeature=D.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():D.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),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 e?.description&&t?N({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?N({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}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.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}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}}overrideInitialFeature(e){this._initialFeature=e}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.notifyChange("submittable"),this.notifyChange("valid"),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;t&&(n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated()))))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(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=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(X),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _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):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(k(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else y(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>X(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return q().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else k(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new U({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?ee(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):y(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?te(e,t):y(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new U({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._expressionsManager?.evaluateAsyncExpressions()))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new G({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=z[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=$(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new Z({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_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}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);this.feature&&(this.feature.sourceLayer=e),s.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")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&d(n,t)&&this.notifyChange("formTitle"),e&&d(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)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(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(B)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(B),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(B)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(B),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:h}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}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===B)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,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||H(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[J,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[B,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${K}`):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}}get test(){return{featureClone:this._featureClone}}};function X(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(q().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function ee(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function te(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([h()],Q.prototype,"_expressionInfosLookup",null),e([h()],Q.prototype,"_featureClone",void 0),e([h()],Q.prototype,"_timeZone",void 0),e([h()],Q.prototype,"activeAssociation",void 0),e([h()],Q.prototype,"activeAssociationInput",null),e([h()],Q.prototype,"activeRelationshipInput",null),e([h()],Q.prototype,"_arcadeContextInfo",null),e([h()],Q.prototype,"associationId",null),e([h()],Q.prototype,"associatedLayer",null),e([h()],Q.prototype,"allAssociationInputs",null),e([h()],Q.prototype,"allFieldInputs",null),e([h()],Q.prototype,"allGroupInputs",null),e([h()],Q.prototype,"allRelationshipInputs",null),e([h()],Q.prototype,"_layerFieldsByName",null),e([h()],Q.prototype,"arcadeEditType",void 0),e([h()],Q.prototype,"contingencyConstraintViolations",void 0),e([h()],Q.prototype,"disabled",void 0),e([h()],Q.prototype,"feature",null),e([h()],Q.prototype,"fieldsWithContingentValues",null),e([h({type:g})],Q.prototype,"formTemplate",null),e([h()],Q.prototype,"formDescription",null),e([h()],Q.prototype,"formTitle",null),e([h()],Q.prototype,"formHeaderVisible",null),e([h()],Q.prototype,"highlightHelper",void 0),e([h()],Q.prototype,"inputs",void 0),e([h()],Q.prototype,"joinedContingentValues",null),e([h()],Q.prototype,"layer",null),e([h()],Q.prototype,"map",void 0),e([h()],Q.prototype,"callbacks",void 0),e([h()],Q.prototype,"relationshipId",null),e([h()],Q.prototype,"spatialReference",null),e([h()],Q.prototype,"state",null),e([h()],Q.prototype,"strict",void 0),e([h()],Q.prototype,"submittable",null),e([h()],Q.prototype,"timeZone",null),e([h()],Q.prototype,"updating",null),e([h()],Q.prototype,"valid",null),e([h()],Q.prototype,"pendingSubtypeChoice",void 0),e([h()],Q.prototype,"getValues",null),e([h()],Q.prototype,"submit",null),e([h()],Q.prototype,"test",null),Q=e([f(Y)],Q);const ne=Q;export{ne as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as d}from"../../core/string.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import g from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as y,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as N,isRelationshipInput as k,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as H}from"./featureFormUtils.js";import U from"./FieldInput.js";import{FormExpressionsManager as Z}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import G from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as $}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const D=new t({attributes:{}}),z={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},J="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",B="#JSAPI_CONTINGENT_VALUE_ANY_HASH",K="#JSAPI_CONTINGENT_VALUE_NULL_HASH",Y="esri.widgets.FeatureForm.FeatureFormViewModel",q=()=>i.getLogger(Y);let Q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=D.clone(),this._initialFeature=D.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():D.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),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 e?.description&&t?N({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?N({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}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.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}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}}overrideInitialFeature(e){this._initialFeature=e}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.notifyChange("submittable"),this.notifyChange("valid"),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;t&&(n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated()))))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(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=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(X),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _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):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(k(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else y(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>X(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return q().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else k(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new U({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?ee(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):y(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?te(e,t):y(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new U({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._expressionsManager?.evaluateAsyncExpressions()))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new G({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=z[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=$(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new Z({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_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}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.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")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&d(n,t)&&this.notifyChange("formTitle"),e&&d(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)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(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(B)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(B),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(B)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(B),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:h}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}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===B)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,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||H(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[J,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[B,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${K}`):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}}get test(){return{featureClone:this._featureClone}}};function X(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(q().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function ee(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function te(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([h()],Q.prototype,"_expressionInfosLookup",null),e([h()],Q.prototype,"_featureClone",void 0),e([h()],Q.prototype,"_timeZone",void 0),e([h()],Q.prototype,"activeAssociation",void 0),e([h()],Q.prototype,"activeAssociationInput",null),e([h()],Q.prototype,"activeRelationshipInput",null),e([h()],Q.prototype,"_arcadeContextInfo",null),e([h()],Q.prototype,"associationId",null),e([h()],Q.prototype,"associatedLayer",null),e([h()],Q.prototype,"allAssociationInputs",null),e([h()],Q.prototype,"allFieldInputs",null),e([h()],Q.prototype,"allGroupInputs",null),e([h()],Q.prototype,"allRelationshipInputs",null),e([h()],Q.prototype,"_layerFieldsByName",null),e([h()],Q.prototype,"arcadeEditType",void 0),e([h()],Q.prototype,"contingencyConstraintViolations",void 0),e([h()],Q.prototype,"disabled",void 0),e([h()],Q.prototype,"feature",null),e([h()],Q.prototype,"fieldsWithContingentValues",null),e([h({type:g})],Q.prototype,"formTemplate",null),e([h()],Q.prototype,"formDescription",null),e([h()],Q.prototype,"formTitle",null),e([h()],Q.prototype,"formHeaderVisible",null),e([h()],Q.prototype,"highlightHelper",void 0),e([h()],Q.prototype,"inputs",void 0),e([h()],Q.prototype,"joinedContingentValues",null),e([h()],Q.prototype,"layer",null),e([h()],Q.prototype,"map",void 0),e([h()],Q.prototype,"callbacks",void 0),e([h()],Q.prototype,"relationshipId",null),e([h()],Q.prototype,"spatialReference",null),e([h()],Q.prototype,"state",null),e([h()],Q.prototype,"strict",void 0),e([h()],Q.prototype,"submittable",null),e([h()],Q.prototype,"timeZone",null),e([h()],Q.prototype,"updating",null),e([h()],Q.prototype,"valid",null),e([h()],Q.prototype,"pendingSubtypeChoice",void 0),e([h()],Q.prototype,"getValues",null),e([h()],Q.prototype,"submit",null),e([h()],Q.prototype,"test",null),Q=e([f(Y)],Q);const ne=Q;export{ne 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as a}from"./css.js";import{zoomToFeature as r}from"../Popup/actions.js";import{loadCalciteComponents as c}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as l,tsxFragment as p}from"../support/jsxFactory.js";import{substitute as d}from"../../intl/substitute.js";const
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as a}from"./css.js";import{zoomToFeature as r}from"../Popup/actions.js";import{loadCalciteComponents as c}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as l,tsxFragment as p}from"../support/jsxFactory.js";import{substitute as d}from"../../intl/substitute.js";const m=r.clone();let u=class extends s{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenFeature=e=>{this.emit("open-feature",{feature:e})},this._handleZoomToFeature=e=>{this.emit("zoom-to-feature",{featureWidget:e})}}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item")})}render(){const{flowItems:e}=this,t=e?.toArray();return l(p,null,t?.map(((t,i)=>this._renderFlowItem(t,i===e.length-1))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleDrillInBackClick(){const{flowItems:e}=this,t=e?.pop();t&&("activeCategory"in t.viewModel?(t.viewModel.activeCategory=null,e.length||(t.viewModel.showAllEnabled=!1)):"showAllEnabled"in t.viewModel&&(t.viewModel.showAllEnabled=!1),t&&(t.viewModel=null,t.destroy()))}_getExitMessage(e){switch(e.flowType){case"feature":case"feature-association":return"";case"feature-relationship":return this.messages.exitRelatedRecords;case"feature-utility-network-associations":case"feature-utility-network-association-type":return this.messages.exitAssociations}}_renderFlowItem(e,i){const{messages:o,closable:s,closed:r}=this,c="graphic"in e&&!e.isTable,n="feature-association"===e.flowType,p=this._getExitMessage(e),d=o.selectFeature;return l("calcite-flow-item",{bind:this,closable:s,closed:r,description:t(this._getDrillInFlowItemDescription(e)??""),heading:t(e.title??""),key:`flow-item-${e.viewModel.uid}`,selected:i,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleDrillInBackClick()},onCalciteFlowItemClose:this._handleCloseClick},l("calcite-action",{appearance:"transparent",bind:this,class:a.actionExit,icon:"move-up",key:"exit-action",onclick:this._handleExitClick,slot:"header-actions-start",text:p,title:p}),c?l("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-feature-action",onclick:()=>this._handleOpenFeature(e),slot:"header-actions-end",text:d,title:d}):null,n?l("calcite-action-bar",{expandDisabled:!0,expanded:!0,key:"header-action-bar",scale:"s",slot:"action-bar"},l("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderDefaultActions(e))):null,l("div",{class:a.container},e.render()))}_renderDefaultActions(e){const t=this._getActionTitle(m);return l("calcite-action",{active:m.active,appearance:"solid",bind:this,"data-action-uid":m.uid,disabled:m.disabled,icon:m.icon??"question",indicator:m.indicator,key:`action-${m.uid}`,loading:m.active,onclick:()=>this._handleZoomToFeature(e),scale:"s",text:t,textEnabled:!0,title:t})}_getActionTitle(e){const{messages:t}=this,{id:i}=e,o=e.title??"";return"zoom-to-feature"===i?d(o,{messages:t}):o}_getDrillInFlowItemDescription(e){switch(e.flowType){case"feature":case"feature-association":case"feature-utility-network-associations":return e.viewModel.description??"";case"feature-relationship":return e.allItemsDescription;case"feature-utility-network-association-type":return e.description??""}}};e([i()],u.prototype,"flowItems",void 0),e([i(),n("esri/widgets/Features/t9n/Features")],u.prototype,"messages",void 0),e([i()],u.prototype,"closed",void 0),e([i()],u.prototype,"closable",void 0),u=e([o("esri.widgets.Features.FeaturesDrillIn")],u);const h=u;export{h as default};
|