@arcgis/core 5.0.0-next.18 → 5.0.0-next.19
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/AttributeBinsGraphic.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineGround.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineQuery.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineScene.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerOGC.js +5 -0
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/057d59ee6144e5890780.js +1 -0
- package/assets/esri/core/workers/chunks/{31b5900119dd7cd9e7d3.js → 0a6ad58ca4ca0cba2fa0.js} +1 -1
- package/assets/esri/core/workers/chunks/0d8d3d0de49064971874.js +1 -0
- package/assets/esri/core/workers/chunks/{b87bc987983b31c13f64.js → 0f1b9d69961dad0b922f.js} +1 -1
- package/assets/esri/core/workers/chunks/110cc01dd6af7ee125d4.js +1 -0
- package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +1 -0
- package/assets/esri/core/workers/chunks/{5f6df4a3376b52ead53f.js → 14f994b1dd682bf2d61a.js} +1 -1
- package/assets/esri/core/workers/chunks/3538eb39ebb58acedd67.js +1 -0
- package/assets/esri/core/workers/chunks/{02a22dd6d208a925cc5a.js → 52cf643621662712dc85.js} +1 -1
- package/assets/esri/core/workers/chunks/5755b11272b777507612.js +1 -0
- package/assets/esri/core/workers/chunks/{d69265ceabfa92b40bb7.js → 58969dde8c3d0b2a9829.js} +1 -1
- package/assets/esri/core/workers/chunks/6e4829b52ade3e41ccc4.js +1 -0
- package/assets/esri/core/workers/chunks/{4a89e120be142ab58a27.js → 7224b321606116fd691c.js} +1 -1
- package/assets/esri/core/workers/chunks/{257f17b3836a623a9dbe.js → 795b09ff7a8f4e91f4dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ac7562ea90f91a9f30c.js → 82b2741e75c2e9b88252.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d2e5774768d8f290343.js → b656e8fd374113523404.js} +1 -1
- package/assets/esri/core/workers/chunks/bccb9ac572bc093fb177.js +1 -0
- package/assets/esri/core/workers/chunks/{79dbfa2b9b332ca0002f.js → c52161b94c0fb071747e.js} +1 -1
- package/assets/esri/core/workers/chunks/db76958fd9f54b6bd324.js +1 -0
- package/assets/esri/core/workers/chunks/e61d7762b56e36dc7e8a.js +1 -0
- package/assets/esri/core/workers/chunks/{b30897952494a3e5b9fe.js → e69c2b613bd0210e25ba.js} +1 -1
- package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/chunks/GlowComposition.glsl.js +46 -46
- package/chunks/ShadedColorMaterial.glsl.js +10 -10
- package/config.js +1 -1
- package/editing/templateUtils.js +1 -1
- package/interfaces.d.ts +120 -23
- package/kernel.js +1 -1
- package/layers/BingMapsLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/package.json +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/rest/support/QueryMixin.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/undoredo/support/ServiceVersionInfo.js +1 -1
- package/undoredo/support/Services.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterHighlightShader.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterXYBandHighlightShader.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/stretch.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/environment/SceneViewEnvironment.js +1 -1
- package/views/3d/environment/SunLighting.js +1 -1
- package/views/3d/environment/VirtualLighting.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/VisibleElements.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider.js +1 -1
- package/widgets/support/SelectionList/VisibleElements.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/assets/esri/core/workers/chunks/080268f78436a2f0d996.js +0 -1
- package/assets/esri/core/workers/chunks/18474c017ddacd1d3d2c.js +0 -1
- package/assets/esri/core/workers/chunks/27e6a6c5610007ac6a54.js +0 -1
- package/assets/esri/core/workers/chunks/5415fbcc7ed203fc5575.js +0 -1
- package/assets/esri/core/workers/chunks/631fb2e62e48f8be4051.js +0 -1
- package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +0 -1
- package/assets/esri/core/workers/chunks/9595aabbaf411eceea1e.js +0 -1
- package/assets/esri/core/workers/chunks/a470f662d73aa8d5d90f.js +0 -1
- package/assets/esri/core/workers/chunks/a57751f3d78524c876cd.js +0 -1
- package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +0 -1
- package/assets/esri/core/workers/chunks/dec336700cfb83abbbeb.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as w}from"./PanelContent.js";import k from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{Heading as v,incrementHeadingLevel as h}from"../../support/Heading.js";import{tsx as F,tsxFragment as y}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const j=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:b,renderBatchAttributeForm:A,renderSketchToolbar:j}=e,{activeFeatureCount:C,activeLeafWorkflow:S,activeWorkflow:T,formViewModel:
|
|
5
|
+
import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as w}from"./PanelContent.js";import k from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{Heading as v,incrementHeadingLevel as h}from"../../support/Heading.js";import{tsx as F,tsxFragment as y}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const j=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:b,renderBatchAttributeForm:A,renderSketchToolbar:j}=e,{activeFeatureCount:C,activeLeafWorkflow:S,activeWorkflow:T,formViewModel:B}=r;if(!S||!T||!B)return null;const V=a(B),z=o(S)&&!S.data.selectedPendingFeature||i(S)&&!S.activeFeature,I=n(S),x=S.shouldShowAttachments&&!V&&!B.activeRelationshipInput&&!B.activeAssociationInput,D=V?B.activeForm.inputs:B.inputs,W=o(S)&&D.every(e=>!e.visible)&&!x,H=null!=r.featureFormViewModel?.activeAssociationInput,P=!z&&!W&&!H,U=s(S)?A:b,E=W?F(f,null,F(k,{headingLevel:l,key:"pending-feature-list",workflow:S})):F(y,null,F(m,{activeFeatureCount:C,messages:p,workflow:T}),I?F(f,{class:t.mergeFeaturesListSection,key:"panel-section-merge"},F(u,{headingLevel:l,key:"merge-features-list",workflow:S})):void 0,F(f,{key:"panel-content-section-main"},F(g,null,z?F(k,{headingLevel:l,key:"pending-feature-list",workflow:S}):U(),x?F("div",{key:"attachments"},F(v,{level:h(l)},p.attachments),d()):null)));return F(y,null,P?M(S,e):void 0,W?j?.():void 0,F(w,{key:"attribute-panel-content"},E),F(c,{buttons:L(e)}))}function M(e,o){const i=[],n="3d"===o.editorViewModel.view?.type,{visibleElements:a}=o;if(a.zoomToButton&&o.editorViewModel.canZoomTo&&i.push(F("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>o.editorViewModel.zoomTo(),scale:"s",text:o.messages.zoomTo,title:o.messages.zoomTo})),a.splitButton&&r(e)&&e.editorItem.supportsSplitFeatureWorkflow&&!n&&o.onSplit){const{onSplit:e,messages:t}=o;i.push(F("calcite-action",{icon:"split-geometry",key:"split-button",onclick:e,scale:"s",text:t.split,title:t.split}))}if(a.mergeButton&&s(e)&&e.supportsMergeFeaturesWorkflow&&!n&&o.onMerge){const{onMerge:e,messages:t}=o;i.push(F("calcite-action",{icon:"merge",key:"merge-button",onclick:e,scale:"s",text:t.mergeFeatures,title:t.mergeFeatures}))}return i.length>0?F("calcite-action-bar",{class:A(t.sketchContainer,t.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal"},i):void 0}function L({editorViewModel:t,messages:o,messagesCommon:i,onDelete:n,onDeleteAssociation:s,onSave:a}){const{activeFeatureCount:r,activeLeafWorkflow:l,syncing:c}=t;if(!l)return[];const{page:u}=t;if("viewing-associated-features"===u||"viewing-associated-layers"===u)return[{appearance:"outline",onClick:()=>{const{featureFormViewModel:e}=t;null!=e?.associationId&&(e.associationId=null)},disabled:c,label:i.cancel,type:"button"}];const p=[],m=r>1?o.multiFeature:o.singleFeature,d=!l.allowSave||c,f=e(m[l.saveActionLabel],{count:r});p.push({appearance:"solid",onClick:a,disabled:d,label:f,type:"button"});const g={appearance:"outline",disabled:c,kind:"danger",label:e(m.delete,{count:r}),type:"button"};return t.shouldShowDeleteButton&&!t.featureFormHasAssociation&&n&&p.push({...g,onClick:n}),t.featureFormHasAssociation&&!t.shouldShowDeleteButton&&s&&p.push({...g,onClick:s,label:o.deleteAssociationTitle}),t.featureFormHasAssociation&&t.shouldShowDeleteButton&&s&&n&&p.push({...g,primaryLabel:i.delete,primaryText:i.delete,onClick:n,dropdownItems:[{onClick:s,label:o.deleteAssociationTitle}],type:"split-button"}),p}export{C as UpdateFeaturePanelContent,j as loadUpdateFeaturePanelContentComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import d from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as F,isSharedTemplate as j,isSharedPresetTemplate as k,isStandardFeatureTemplate as A,isSharedFeatureTemplate as L}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as M,fixFields as O,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as q}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as E}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as D}from"../../support/guards.js";import R from"../../symbols/SimpleFillSymbol.js";import G from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Z}from"../../symbols/support/symbolUtils.js";import{getServices as Q}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as $}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as H,hitTestSelectSimilarDistance as K}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as X}from"./support/dependencySort.js";import{isDrawGraphicTool as Y}from"../Sketch/support/sketchUtils.js";const _=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function ee(e){return ie(e)||oe(e)}function te(e){return!!e&&"features"in e}function re(e){return null!=e&&"create-features"===e.type}function ne(e){return!!e&&"feature"in e}function oe(e){return null!=e&&"update-features"===e.type}function ae(e){return null!=e&&"update-feature"===e.type}function ie(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function se(e){return null!=e&&"update"===e.type}function le(e){return null!=e&&"merge-features"===e.type}function ce(e){return null!=e&&"split-feature"===e.type}function ue(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function de(e){return"merge"===e?.type}function pe(e){return"split"===e?.type}function fe(e){return le(e)||ce(e)}function ye(e){return"update-multiple"===e?.type}function me(e){const t=e&&"renderer"in e?e.renderer:null;if(!Te(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===C(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function he(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&Te(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=me(t);let o=null,a=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=ge(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=Ie(n,r)}return{rotation:o,size:a}}function ge(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,ve((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function be(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 we(e,t,r){if(null==t)return 0;const{symbol:n}=N(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(ut.icon,(await e(o,ut.icon))[0])||ut.icon}case"text":return ut.text;case"line":return ut.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return be(await t(o,e.scale/ut.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/ut.viewScaleSizeFactor;default:return 0}}function Ie(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},a=E[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*a/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*a/2:e=>e*a,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>ve(i(await we(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,ve(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:ft(e.valueUnit),axis:e.axis}}function ve(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 Te(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Se(e,t,r){const n=await Z(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function Fe(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:$,optionsPerTool:r};if(S(t)){const o=t.defaultTool,a=F(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function je(e,t,r,n){const{creationInfo:o,fullTemplate:a}=r;if(!o)throw new i("featureworkflow","No creation info provided.");const s=o.layer,l=Ne(a,o.attributeOverrides),{view:c}=e,u="2d"===c?.type;F(a)||k(a)||await Ze(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=Fe(s.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:d.data.supportsZ,defaultZ:(u?d.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(p.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function ke(e){return s([Ae(e),Le(e)])}function Ae({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:a}=t,{fullTemplate:i}=t;if(!a||"2d"!==n?.type||F(i)||k(i))return null;const s=f(t=>Ze(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Le({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!Y(a))return _().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:d}=o,p=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>a,["cursor-update","vertex-add"],()=>{c.removeAll();const e=a.graphic?.geometry;if(!e||!Ue(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=d.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=Ve(e,p);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function Ue(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 Ve(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new B({angle:0,color:r,outline:new G({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 R({color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new G({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 Me(e,t){const r=await Q(t).load(),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function Oe(e,t){const r=await Me(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function xe(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function qe(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=ze(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Pe(t,i,a),d=Ce(l,Ee(s,c),c);if(o&&Ge(l,d,o),0===d.length)return t;const p=X(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of p)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of p){const{layer:e}=r;switch(null==h?h=xe(e):h.id!==e.layerId&&(m.push(h),h=xe(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??xe(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function ze(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Ee(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(De(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(De(n,e),t.keyField);break}}return r}function Pe(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function Ce(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:a}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=De(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([a,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,a]):t.before.attributes[c]===o.after.attributes[e]&&n.push([a,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,a]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):n.push([r,a]):n.push([a,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,a]))}}}}return n}function De(e,t){return`${e.layerId}:${t.id}`}function Re(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ge(e,t,r){const n=[];for(const a of e)Re(a.layer,r)&&n.push(a);if(0===n.length)return;let o=[];for(const a of n){const r=a.layer;switch(a.operationType){case"delete":o=[...Be(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Be(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Be(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Be(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Be(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function Ne(e,t={}){return F(e)||k(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ze(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=he(i);let c=await Z(i,{useSourceLayer:!0,webStyleCache:o,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await Z(i,{useSourceLayer:!0,webStyleCache:o,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Qe(e.tooltipOptions,l,s)}function Qe(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)}function $e(e,t){const r=We(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function Je(e,t){return e?.find(e=>e.layer===t)}async function He(e,t,r,n){switch(t.type){case"3d":return Ke(e,t,r,n);case"2d":return Xe(e,t,r,n)}}async function Ke(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(K(t,r),n),a=new Map,i=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};H(o).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return h(Promise.allSettled(a.map(async({layer:e})=>{const t=i.get(e),r=Ye(e);if(t.every(e=>M(e,r)))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=O(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Xe(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let a=null;const i=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const i=new Set;a=H(o),a.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Ye(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=J(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return a?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Ye(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function _e(e,t,n,o){return et(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function et(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,o.returnGeometry=!0,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=r);const a=await t.queryFeatures(o,{signal:n});return m(n),a.features}async function tt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await rt(e);const a={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(a.enableRotation=null!=o.rotation,a.enableScaling=null!=o.size),r.update(t,a)}async function rt(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:a,webStyleCache:i}=e;let s=!1;const{rotation:l,size:c}=a;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await Se(t,i,e)}Qe(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function nt(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function ot(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function at(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let a=!1;const i=n.rotation,s=nt(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),a=!0}}const l=n.size,c=ot(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==o[r]&&t.setAttribute(r,i),a=!0}}return a}async function it({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await Se(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>Se(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=ht(a,m);await tt({graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u});let b=null;h.then(e=>b=e).catch(()=>{});const I=r.size,v=r.rotation,T=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==I||I.isUpdatingInteractively||I.field!==n||I.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),(null==b||b.requiredFields.includes(n))&&(r=!0))}r&&await Se(t,u,"2d"===a.type?a.scale:null)}),S=o.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u};if("complete"===e.state){if(null===a.activeTool)return tt(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===a.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),tt(s)}))}at(a,t,e,r)&&await Se(t,u,"2d"===a.type?a.scale:null),i(bt(t),e)}),F=o.on(["undo","redo"],e=>{i(bt(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function st(e,t,r,n){e.add(n);const o=r.sourceLayer,i=r.getAttribute(o.objectIdField);let c=null;function u(e){c?.abort(),c=a(async r=>{const n=await ht(t,o);m(r),n.setVisibility?.(i,e)})}return await ct(t,n),u(!1),s([lt(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await ht(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function lt(e,t,r){if("3d"===e.type){const n=new W({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function ct(e,t){if("3d"===e.type){const r=new W({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const ut={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function dt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function pt(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function ft(e){return"unknown"===e?null:e}function yt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const mt=e=>e.includes("-stop")||e.includes("vertex-"),ht=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function gt(e){return"createInteractiveEditSession"in e}function bt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function wt(e){return e.acquireCursor("progress")}async function It(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(S(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function vt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function Tt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>vt(e.relationships)),t.flatMap(e=>e.edits)):null}function St(e){const t=se(e)?e.activeWorkflow:e;if(null==t)return[];if(oe(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function Ft({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function jt(e){if(!kt(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function kt(e){return 0===e.length||D(e[0])}export{Ge as appendAllUtilityNetworkAssociationRelationships,pt as avoidFeatureTemplateSelectionWithOnlyOneItem,gt as canCreateInteractiveEditSession,bt as cloneGraphicExceptMesh,ze as createLayerIdMap,Ee as createRelationshipKeyMap,Fe as createToolFromGeometryType,dt as createWorkflowSteps,He as fetchCandidates,_e as fetchFullFeatures,et as fetchFullFeaturesByObjectId,Ce as findAllDependencies,Be as findChangesByGlobalId,We as findEditorItemForLayer,$e as findEditorItemForLayerOrThrow,Je as findLayerInfo,De as generateHashForRelationship,Ne as getCreationAttributes,It as getFullTemplateForCreationInfo,St as getLayersFromWorkflow,ge as getRotationVariableAttribute,Tt as getServiceEditsFromWorkflowData,Me as getServiceInfoForLayer,Oe as getServiceLayersById,Ie as getSizeVariableAttribute,he as getVisualVariableAttributes,me as getVisualVariablesForLayer,ee as isAnyUpdateLeafWorkflow,te as isBatchAttributeFormViewModel,re as isCreateFeaturesWorkflow,ne as isFeatureFormViewModel,kt as isGraphicsArray,le as isMergeFeaturesWorkflow,de as isMergeWorkflowOptions,ue as isParentWorkflow,ce as isSplitFeatureWorkflow,pe as isSplitWorkflowOptions,mt as isTerminalUpdateEventType,ae as isUpdateFeatureWorkflow,oe as isUpdateFeaturesWorkflow,ye as isUpdateFeaturesWorkflowOptions,ie as isUpdateRecordWorkflow,se as isUpdateWorkflow,Re as isUtilityNetworkAssociationsTable,Ft as makeMinimalAttributes,qe as orderEditsByRelationshipDependencies,yt as prepareAttachmentsForCreateFeaturesWorkflow,vt as setRelationshipFields,it as setUpGeometryUpdate,ke as setUpSketchCreateWatchers,rt as setVisualVariablesAndElevationInfoForUpdate,wt as showProgressCursor,ut as sizeDefaults,ft as sizeVariableUnitToLengthUnit,je as startCreatingNewFeature,tt as startUpdatingFeatureGeometry,st as swapForEditingSession,jt as toFeatureInfos,Se as updateGraphicSymbolWhenRequired,at as visualVariableInteractiveUpdate,ht as whenEditorLayerView,ct as whenGraphicDisplayed,fe as workflowInfluencesOutcomeOfParent};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import d from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as F,isSharedTemplate as j,isSharedPresetTemplate as k,isStandardFeatureTemplate as A,isSharedFeatureTemplate as L}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as M,fixFields as O,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as q}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as E}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as D}from"../../support/guards.js";import R from"../../symbols/SimpleFillSymbol.js";import G from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Z}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as $}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as H,hitTestSelectSimilarDistance as K}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as X}from"./support/dependencySort.js";import{isDrawGraphicTool as Y}from"../Sketch/support/sketchUtils.js";const _="updateFeatureWorkflow-internal",ee=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function te(e){return se(e)||ae(e)}function re(e){return!!e&&"features"in e}function ne(e){return null!=e&&"create-features"===e.type}function oe(e){return!!e&&"feature"in e}function ae(e){return null!=e&&"update-features"===e.type}function ie(e){return null!=e&&"update-feature"===e.type}function se(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function le(e){return null!=e&&"update"===e.type}function ce(e){return null!=e&&"merge-features"===e.type}function ue(e){return null!=e&&"split-feature"===e.type}function de(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function pe(e){return"merge"===e?.type}function fe(e){return"split"===e?.type}function ye(e){return ce(e)||ue(e)}function me(e){return"update-multiple"===e?.type}function he(e){const t=e&&"renderer"in e?e.renderer:null;if(!Se(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===C(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function ge(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&Se(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=he(t);let o=null,a=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=be(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=ve(n,r)}return{rotation:o,size:a}}function be(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,Te((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function we(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 Ie(e,t,r){if(null==t)return 0;const{symbol:n}=N(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(dt.icon,(await e(o,dt.icon))[0])||dt.icon}case"text":return dt.text;case"line":return dt.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return we(await t(o,e.scale/dt.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/dt.viewScaleSizeFactor;default:return 0}}function ve(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},a=E[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*a/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*a/2:e=>e*a,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>Te(i(await Ie(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Te(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:yt(e.valueUnit),axis:e.axis}}function Te(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 Se(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Fe(e,t,r){const n=await Z(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function je(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:$,optionsPerTool:r};if(S(t)){const o=t.defaultTool,a=F(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function ke(e,t,r,n){const{creationInfo:o,fullTemplate:a}=r;if(!o)throw new i("featureworkflow","No creation info provided.");const s=o.layer,l=Ze(a,o.attributeOverrides),{view:c}=e,u="2d"===c?.type;F(a)||k(a)||await We(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=je(s.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:d.data.supportsZ,defaultZ:(u?d.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(p.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function Ae(e){return s([Le(e),Ue(e)])}function Le({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:a}=t,{fullTemplate:i}=t;if(!a||"2d"!==n?.type||F(i)||k(i))return null;const s=f(t=>We(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ue({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!Y(a))return ee().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:d}=o,p=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>a,["cursor-update","vertex-add"],()=>{c.removeAll();const e=a.graphic?.geometry;if(!e||!Ve(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=d.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=Me(e,p);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function Ve(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 Me(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new B({angle:0,color:r,outline:new G({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 R({color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new G({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}})}function Oe(e,t){const r=W(t),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function xe(e,t){const r=Oe(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function qe(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function ze(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=Ee(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ce(t,i,a),d=De(l,Pe(s,c),c);if(o&&Be(l,d,o),0===d.length)return t;const p=X(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of p)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of p){const{layer:e}=r;switch(null==h?h=qe(e):h.id!==e.layerId&&(m.push(h),h=qe(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??qe(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Ee(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Pe(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Re(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Re(n,e),t.keyField);break}}return r}function Ce(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function De(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:a}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Re(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([a,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,a]):t.before.attributes[c]===o.after.attributes[e]&&n.push([a,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,a]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):n.push([r,a]):n.push([a,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,a]))}}}}return n}function Re(e,t){return`${e.layerId}:${t.id}`}function Ge(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Be(e,t,r){const n=[];for(const a of e)Ge(a.layer,r)&&n.push(a);if(0===n.length)return;let o=[];for(const a of n){const r=a.layer;switch(a.operationType){case"delete":o=[...Ne(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Ne(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Ne(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function Ze(e,t={}){return F(e)||k(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function We(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ge(i);let c=await Z(i,{useSourceLayer:!0,webStyleCache:o,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await Z(i,{useSourceLayer:!0,webStyleCache:o,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Qe(e.tooltipOptions,l,s)}function Qe(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 $e(e,t){return e.find(e=>e.layer===t)}function Je(e,t){const r=$e(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function He(e,t){return e?.find(e=>e.layer===t)}async function Ke(e,t,r,n){switch(t.type){case"3d":return Xe(e,t,r,n);case"2d":return Ye(e,t,r,n)}}async function Xe(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(K(t,r),n),a=new Map,i=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};H(o).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return h(Promise.allSettled(a.map(async({layer:e})=>{const t=i.get(e),r=_e(e);if(t.every(e=>M(e,r)))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=O(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ye(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let a=null;const i=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const i=new Set;a=H(o),a.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=_e(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=J(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return a?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function _e(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function et(e,t,n,o){return tt(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function tt(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,o.returnGeometry=!0,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=r);const a=await t.queryFeatures(o,{signal:n});return m(n),a.features}async function rt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await nt(e);const a={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(a.enableRotation=null!=o.rotation,a.enableScaling=null!=o.size),r.update(t,a)}async function nt(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:a,webStyleCache:i}=e;let s=!1;const{rotation:l,size:c}=a;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await Fe(t,i,e)}Qe(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function ot(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function at(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function it(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let a=!1;const i=n.rotation,s=ot(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),a=!0}}const l=n.size,c=at(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==o[r]&&t.setAttribute(r,i),a=!0}}return a}async function st({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await Fe(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>Fe(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=gt(a,m);await rt({graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u});let b=null;h.then(e=>b=e).catch(()=>{});const I=r.size,v=r.rotation,T=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==I||I.isUpdatingInteractively||I.field!==n||I.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),(null==b||b.requiredFields.includes(n))&&(r=!0))}r&&await Fe(t,u,"2d"===a.type?a.scale:null)}),S=o.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u};if("complete"===e.state){if(null===a.activeTool)return rt(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===a.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),rt(s)}))}it(a,t,e,r)&&await Fe(t,u,"2d"===a.type?a.scale:null),i(wt(t),e)}),F=o.on(["undo","redo"],e=>{i(wt(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function lt(e,t,r,n){e.add(n);const o=r.sourceLayer,i=r.getAttribute(o.objectIdField);let c=null;function u(e){c?.abort(),c=a(async r=>{const n=await gt(t,o);m(r),n.setVisibility?.(i,e)})}return await ut(t,n),u(!1),s([ct(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await gt(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function ct(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function ut(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 dt={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function pt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function ft(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function yt(e){return"unknown"===e?null:e}function mt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const ht=e=>e.includes("-stop")||e.includes("vertex-"),gt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function bt(e){return"createInteractiveEditSession"in e}function wt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function It(e){return e.acquireCursor("progress")}async function vt(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(S(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function Tt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function St(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>Tt(e.relationships)),t.flatMap(e=>e.edits)):null}function Ft(e){const t=le(e)?e.activeWorkflow:e;if(null==t)return[];if(ae(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function jt({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function kt(e){if(!At(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function At(e){return 0===e.length||D(e[0])}export{Be as appendAllUtilityNetworkAssociationRelationships,ft as avoidFeatureTemplateSelectionWithOnlyOneItem,bt as canCreateInteractiveEditSession,wt as cloneGraphicExceptMesh,Ee as createLayerIdMap,Pe as createRelationshipKeyMap,je as createToolFromGeometryType,pt as createWorkflowSteps,Ke as fetchCandidates,et as fetchFullFeatures,tt as fetchFullFeaturesByObjectId,De as findAllDependencies,Ne as findChangesByGlobalId,$e as findEditorItemForLayer,Je as findEditorItemForLayerOrThrow,He as findLayerInfo,Re as generateHashForRelationship,Ze as getCreationAttributes,vt as getFullTemplateForCreationInfo,Ft as getLayersFromWorkflow,be as getRotationVariableAttribute,St as getServiceEditsFromWorkflowData,Oe as getServiceInfoForLayer,xe as getServiceLayersById,ve as getSizeVariableAttribute,ge as getVisualVariableAttributes,he as getVisualVariablesForLayer,te as isAnyUpdateLeafWorkflow,re as isBatchAttributeFormViewModel,ne as isCreateFeaturesWorkflow,oe as isFeatureFormViewModel,At as isGraphicsArray,ce as isMergeFeaturesWorkflow,pe as isMergeWorkflowOptions,de as isParentWorkflow,ue as isSplitFeatureWorkflow,fe as isSplitWorkflowOptions,ht as isTerminalUpdateEventType,ie as isUpdateFeatureWorkflow,ae as isUpdateFeaturesWorkflow,me as isUpdateFeaturesWorkflowOptions,se as isUpdateRecordWorkflow,le as isUpdateWorkflow,Ge as isUtilityNetworkAssociationsTable,jt as makeMinimalAttributes,ze as orderEditsByRelationshipDependencies,mt as prepareAttachmentsForCreateFeaturesWorkflow,Tt as setRelationshipFields,st as setUpGeometryUpdate,Ae as setUpSketchCreateWatchers,nt as setVisualVariablesAndElevationInfoForUpdate,It as showProgressCursor,dt as sizeDefaults,yt as sizeVariableUnitToLengthUnit,ke as startCreatingNewFeature,rt as startUpdatingFeatureGeometry,lt as swapForEditingSession,kt as toFeatureInfos,_ as updateFeatureWorkflowInternalGraphicsLayerTitle,Fe as updateGraphicSymbolWhenRequired,it as visualVariableInteractiveUpdate,gt as whenEditorLayerView,ut as whenGraphicDisplayed,ye as workflowInfluencesOutcomeOfParent};
|
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecatedFunction as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as o,abortMaybe as r,mappedFind as a}from"../core/maybe.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as l,on as c,when as d,initial as h}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import w from"./Attachments.js";import _ from"./BatchAttributeForm.js";import v from"./FeatureForm.js";import f from"./FeatureTemplates.js";import y from"./Spinner.js";import b from"./Widget.js";import{VisibleElements as k}from"./BatchAttributeForm/VisibleElements.js";import{css as F}from"./Editor/css.js";import M from"./Editor/EditorViewModel.js";import{isModelUpload as A}from"./Editor/modelUploadUtils.js";import T from"./Editor/VisibleElements.js";import{isFeatureFormViewModel as S,isUpdateWorkflow as C,isUpdateFeaturesWorkflow as L,isUpdateFeatureWorkflow as E,isBatchAttributeFormViewModel as W}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as P,CreateFeaturesPanelContent as I}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as j,FeatureList as U}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as V,FooterActions as D}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as x,Notice as B}from"./Editor/components/Notices.js";import{loadPanelContentComponents as O,PanelContent as N,PanelContentSection as H,PanelContentMessage as G}from"./Editor/components/PanelContent.js";import{PanelToolbar as R,loadPanelToolbarComponents as z}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as q,Prompt as K}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as Z,UpdateFeaturePanelContent as $}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as J,UploadDetails as Q}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as X}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as Y}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as ee}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as te}from"./support/componentsUtils.js";import{globalCss as ie}from"./support/globalCss.js";import{incrementHeadingLevel as se,Heading as oe}from"./support/Heading.js";import{renderItem as re}from"./support/ItemList.js";import{connectDelayedLoading as ae}from"./support/loaderUtils.js";import ne from"./support/SelectionList.js";import le from"./support/SelectionToolbar.js";import{messageBundle as ce,vmEvent as de,tsx as he}from"./support/widget.js";import me from"./support/SelectionList/VisibleElements.js";import pe from"./support/SelectionToolbar/VisibleElements.js";const ue=Symbol("sketch-setup-handles");let ge=class extends b{constructor(e,i){super(e,i),this._batchAttributeForm=new _({visibleElements:new k({loadingIndicator:!1})}),this._featureForm=new v,this._sketchToolbar=null,this._attachments=new w({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new f({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?he("calcite-icon",{class:F.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new y,this._loading=!1,this._selectionList=new ne({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new me({header:!1})}),this._selectionToolbar=new le({visibleElements:new pe({chip:!1})}),this._updatingHandles=new u,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new M,this.visibleElements=new T,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?he("div",{class:F.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>he("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return he("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?he(R,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&A(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&S(t.formViewModel)&&t.formViewModel.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onMerge=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;L(t)&&e.startMergingFeatures(t.viewGraphics)}},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;if(E(t)){const i=t.viewGraphic;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,i=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:i.deleteWarningTitle,message:i.deleteWarningMessage,context:"danger",actions:{primary:{label:t(i.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:i.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([l(()=>se(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},h),c(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),d(()=>this.viewModel.formViewModel,e=>{W(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),l(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},h),l(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},h),l(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},h),d(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),d(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),d(()=>this.viewModel?.failures,e=>{const{messages:i}=this,[{error:s,retry:o,cancel:r}]=e;this._showPrompt({title:i.errorWarningTitle,message:t(i.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:i.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:i.ignore,action:()=>{r(),this._clearPrompt()}}}})}),l(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),l(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),l(()=>this.visibleElements.sketch,()=>this._setupSketch(),h),ae({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=o(this._sketchToolbar),this._sketchImportAbortController=r(this._sketchImportAbortController)}loadDependencies(){return Promise.all([te({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),P(),j(),V(),x(),O(),z(),q(),Z(),J()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.mergeTheseFeatures,icon:"merge",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"merge")}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startMergeFeaturesWorkflow(e,t={}){return this.viewModel.startMergeFeaturesWorkflow(e,t)}startSplitFeatureWorkflow(e,t={}){return this.viewModel.startSplitFeatureWorkflow(e,t)}async startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return i(s.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(F.base,ie.widget,ie.panel);if(!t)return he("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return he("div",{class:i,key:"base"},e.flow?he("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?he(K,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":case"choosing-key-feature":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return he("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return he(t,{heading:i.selectTemplate,key:"templates-panel",...e},he(N,{key:"feature-templates"},he(H,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?he(t,{heading:s.createFeatures,key:"upload-details-panel",...e},he(Q,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return he(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?he($,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):he(I,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return he(t,{heading:a,key:"update-feature-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onMerge:this._onMerge,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return he(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},he(I,{helpMessage:this._helpMessage,noticeMessage:this._noticeMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return he(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return he(t,{heading:n,key:"viewing-associated-layers-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?he(i,{heading:a,key:"add-association-select-feature",...e},he(N,{key:"select-feature"},he(H,null,t.render())),he(D,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):he(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return he(i,{heading:a,key:"add-association",...e},he(N,{key:"add-association-content"},he(H,null,t.render())),he(D,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=a(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?he(B,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return he(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),he(D,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:i,_hasInvalidBatchSelection:s,_selectionCountExceedsMaximum:o,_selectionList:r,_visibleSelectionCount:a,messages:n,EditorPanel:l}=this,{batchUpdateActions:c}=this.visibleElements,{maxVisibleFeatureCountPerLayer:d}=r;return he(l,{heading:n.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,he(N,{key:"selection-list"},he(H,null,this._renderSelectionList())),he(D,{buttons:[c?{label:t(n.batchEditing.editCount,{count:a}),disabled:s,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:c&&i?{text:n.batchEditing.selectOneLayer,icon:"information"}:c&&o?{text:t(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:d}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?he(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?he(D,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return he(t,{heading:i.widgetLabel,key:"landing-panel",...e},he(N,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?he(H,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?he(H,{key:"create-actions"},this._renderCreateActions()):null]:he(G,{key:"no-content"},i.noEditableLayers)),r?he("div",{class:F.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){return this.getHelpMessageString(this.activeWorkflow?.helpMessage)}get _noticeMessage(){return this.getHelpMessageString(this.activeWorkflow?.noticeMessage)}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return he("div",{class:F.updateActions,key:"update-actions"},he(oe,{level:se(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):he("calcite-list",{class:F.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},re({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return he("div",{key:"create-actions"},he(oe,{level:se(this.headingLevel)},this.messages.createFeatures),he("div",{class:F.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:i,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const r=o.data.candidates,a=t(this.messages.multipleFeaturesTemplate,{total:r.length});return he(i,{heading:a,key:"feature-list",...e},he(U,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=n(),{view:r}=this,a=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),a&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e,t){await this.viewModel.onSelectionListMenuItemSelect(e,t)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=r(this._sketchImportAbortController),this._sketchToolbar=o(this._sketchToolbar),void this.removeHandles(ue);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new ee({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new X({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new Y({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([l(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},h),l(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},h),d(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},h)],ue)}finally{this._sketchImportAbortController=null}}getHelpMessageString(e){const{messages:t,view:i}=this;return e?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[e]:void 0}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([m()],ge.prototype,"_batchAttributeForm",void 0),e([m()],ge.prototype,"_featureForm",void 0),e([m()],ge.prototype,"_sketchToolbar",void 0),e([m()],ge.prototype,"_attachments",void 0),e([m()],ge.prototype,"_associationItemList",void 0),e([m()],ge.prototype,"_associationSettings",void 0),e([m()],ge.prototype,"_featureTemplates",void 0),e([m()],ge.prototype,"_filterText",void 0),e([m()],ge.prototype,"_hasInvalidBatchSelection",null),e([m()],ge.prototype,"_hasSelectionFromMultipleLayers",null),e([m()],ge.prototype,"_prompt",void 0),e([m()],ge.prototype,"_spinner",void 0),e([m()],ge.prototype,"_deleteButtonCommonInfo",null),e([m()],ge.prototype,"_loading",void 0),e([m()],ge.prototype,"_selectionCountExceedsMaximum",null),e([m()],ge.prototype,"_selectionList",void 0),e([m()],ge.prototype,"_selectionListItemActionConfigs",null),e([m()],ge.prototype,"_selectionToolbar",void 0),e([m()],ge.prototype,"_visibleSelectionCount",null),e([m({readOnly:!0})],ge.prototype,"activeWorkflow",null),e([m()],ge.prototype,"effectiveSelectionManager",null),e([m()],ge.prototype,"headingLevel",void 0),e([m()],ge.prototype,"hideTemplatesForInactiveLayers",null),e([m()],ge.prototype,"icon",null),e([m()],ge.prototype,"label",null),e([m()],ge.prototype,"labelOptions",null),e([m()],ge.prototype,"layerInfos",null),e([m(),ce("esri/widgets/Editor/t9n/Editor")],ge.prototype,"messages",void 0),e([m(),ce("esri/t9n/common")],ge.prototype,"messagesCommon",void 0),e([m(),ce("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ge.prototype,"messagesTemplates",void 0),e([m(),ce("esri/widgets/Feature/t9n/Feature")],ge.prototype,"messagesFeature",void 0),e([m()],ge.prototype,"snappingOptions",null),e([m()],ge.prototype,"tooltipOptions",null),e([m()],ge.prototype,"supportingWidgetDefaults",void 0),e([m({type:g,nonNullable:!0})],ge.prototype,"valueOptions",null),e([m()],ge.prototype,"view",null),e([m(),de(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ge.prototype,"viewModel",void 0),e([m({type:T,nonNullable:!0})],ge.prototype,"visibleElements",void 0),e([m()],ge.prototype,"_helpMessage",null),e([m()],ge.prototype,"_noticeMessage",null),ge=e([p("esri.widgets.Editor")],ge);const we=ge;export{we as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecatedFunction as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as o,abortMaybe as r,mappedFind as a}from"../core/maybe.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as l,on as c,when as d,initial as h}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import w from"./Attachments.js";import _ from"./BatchAttributeForm.js";import v from"./FeatureForm.js";import f from"./FeatureTemplates.js";import b from"./Spinner.js";import y from"./Widget.js";import{VisibleElements as k}from"./BatchAttributeForm/VisibleElements.js";import{css as F}from"./Editor/css.js";import M from"./Editor/EditorViewModel.js";import{isModelUpload as A}from"./Editor/modelUploadUtils.js";import T from"./Editor/VisibleElements.js";import{isFeatureFormViewModel as S,isUpdateWorkflow as C,isUpdateFeaturesWorkflow as L,isUpdateFeatureWorkflow as E,isBatchAttributeFormViewModel as W,findEditorItemForLayer as P}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as I,CreateFeaturesPanelContent as j}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as U,FeatureList as V}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as D,FooterActions as x}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as B,Notice as O}from"./Editor/components/Notices.js";import{loadPanelContentComponents as N,PanelContent as H,PanelContentSection as G,PanelContentMessage as R}from"./Editor/components/PanelContent.js";import{PanelToolbar as z,loadPanelToolbarComponents as q}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as K,Prompt as Z}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as $,UpdateFeaturePanelContent as J}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as Q,UploadDetails as X}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as Y}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as ee}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as te}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as ie}from"./support/componentsUtils.js";import{globalCss as se}from"./support/globalCss.js";import{incrementHeadingLevel as oe,Heading as re}from"./support/Heading.js";import{renderItem as ae}from"./support/ItemList.js";import{connectDelayedLoading as ne}from"./support/loaderUtils.js";import le from"./support/SelectionList.js";import ce from"./support/SelectionToolbar.js";import{messageBundle as de,vmEvent as he,tsx as me}from"./support/widget.js";import{isLayerItem as pe}from"./support/SelectionList/selectionListUtils.js";import ue from"./support/SelectionList/VisibleElements.js";import ge from"./support/SelectionToolbar/VisibleElements.js";const we=Symbol("sketch-setup-handles");let _e=class extends y{constructor(e,i){super(e,i),this._batchAttributeForm=new _({visibleElements:new k({loadingIndicator:!1})}),this._featureForm=new v,this._sketchToolbar=null,this._attachments=new w({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new f({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?me("calcite-icon",{class:F.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new b,this._loading=!1,this._selectionList=new le({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new ue({header:!1})}),this._selectionToolbar=new ce({visibleElements:new ge({chip:!1})}),this._updatingHandles=new u,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new M,this.visibleElements=new T,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?me("div",{class:F.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>me("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return me("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?me(z,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&A(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&S(t.formViewModel)&&t.formViewModel.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onMerge=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;L(t)&&e.startMergingFeatures(t.viewGraphics)}},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;if(E(t)){const i=t.viewGraphic;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,i=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:i.deleteWarningTitle,message:i.deleteWarningMessage,context:"danger",actions:{primary:{label:t(i.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:i.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([l(()=>oe(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},h),c(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),d(()=>this.viewModel.formViewModel,e=>{W(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),l(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},h),l(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},h),l(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},h),d(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),d(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),d(()=>this.viewModel?.failures,e=>{const{messages:i}=this,[{error:s,retry:o,cancel:r}]=e;this._showPrompt({title:i.errorWarningTitle,message:t(i.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:i.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:i.ignore,action:()=>{r(),this._clearPrompt()}}}})}),l(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),l(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),l(()=>this.visibleElements.sketch,()=>this._setupSketch(),h),l(()=>this.visibleElements.zoomToButton,e=>this._selectionList.visibleElements.zoomToButton=e,h),ne({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=o(this._sketchToolbar),this._sketchImportAbortController=r(this._sketchImportAbortController)}loadDependencies(){return Promise.all([ie({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),I(),U(),D(),B(),N(),q(),K(),$(),Q()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e,visibleElements:t}=this,i=t?.mergeButton??!0;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.mergeTheseFeatures,icon:"merge",type:"layer",hidden:!i||(({item:e})=>{if(!pe(e))return!0;const t=P(this.viewModel.editorItems,e.layer);return!t?.supportsMergeFeaturesWorkflow||e.visibleTotal<2}),callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"merge")}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startMergeFeaturesWorkflow(e,t={}){return this.viewModel.startMergeFeaturesWorkflow(e,t)}startSplitFeatureWorkflow(e,t={}){return this.viewModel.startSplitFeatureWorkflow(e,t)}async startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return i(s.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(F.base,se.widget,se.panel);if(!t)return me("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return me("div",{class:i,key:"base"},e.flow?me("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?me(Z,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":case"choosing-key-feature":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return me("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return me(t,{heading:i.selectTemplate,key:"templates-panel",...e},me(H,{key:"feature-templates"},me(G,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?me(t,{heading:s.createFeatures,key:"upload-details-panel",...e},me(X,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return me(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?me(J,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):me(j,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return me(t,{heading:a,key:"update-feature-panel",...e},me(J,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onMerge:this._onMerge,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return me(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},me(j,{helpMessage:this._helpMessage,noticeMessage:this._noticeMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return me(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},me(J,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return me(t,{heading:n,key:"viewing-associated-layers-panel",...e},me(J,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?me(i,{heading:a,key:"add-association-select-feature",...e},me(H,{key:"select-feature"},me(G,null,t.render())),me(x,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):me(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return me(i,{heading:a,key:"add-association",...e},me(H,{key:"add-association-content"},me(G,null,t.render())),me(x,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=a(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?me(O,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return me(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},me(H,{key:"attachments"},this._renderAttachments()),me(x,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:i,_hasInvalidBatchSelection:s,_selectionCountExceedsMaximum:o,_selectionList:r,_visibleSelectionCount:a,messages:n,EditorPanel:l}=this,{batchUpdateActions:c}=this.visibleElements,{maxVisibleFeatureCountPerLayer:d}=r;return me(l,{heading:n.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?me("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,me(H,{key:"selection-list"},me(G,null,this._renderSelectionList())),me(x,{buttons:[c?{label:t(n.batchEditing.editCount,{count:a}),disabled:s,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:c&&i?{text:n.batchEditing.selectOneLayer,icon:"information"}:c&&o?{text:t(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:d}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?me(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},me(H,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?me(x,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return me(t,{heading:i.widgetLabel,key:"landing-panel",...e},me(H,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?me(G,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?me(G,{key:"create-actions"},this._renderCreateActions()):null]:me(R,{key:"no-content"},i.noEditableLayers)),r?me("div",{class:F.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){return this.getHelpMessageString(this.activeWorkflow?.helpMessage)}get _noticeMessage(){return this.getHelpMessageString(this.activeWorkflow?.noticeMessage)}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return me("div",{class:F.updateActions,key:"update-actions"},me(re,{level:oe(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?me("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):me("calcite-list",{class:F.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},ae({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return me("div",{key:"create-actions"},me(re,{level:oe(this.headingLevel)},this.messages.createFeatures),me("div",{class:F.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:i,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const r=o.data.candidates,a=t(this.messages.multipleFeaturesTemplate,{total:r.length});return me(i,{heading:a,key:"feature-list",...e},me(V,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=n(),{view:r}=this,a=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),a&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e,t){await this.viewModel.onSelectionListMenuItemSelect(e,t)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=r(this._sketchImportAbortController),this._sketchToolbar=o(this._sketchToolbar),void this.removeHandles(we);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new te({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new Y({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new ee({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([l(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},h),l(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},h),d(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},h)],we)}finally{this._sketchImportAbortController=null}}getHelpMessageString(e){const{messages:t,view:i}=this;return e?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[e]:void 0}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([m()],_e.prototype,"_batchAttributeForm",void 0),e([m()],_e.prototype,"_featureForm",void 0),e([m()],_e.prototype,"_sketchToolbar",void 0),e([m()],_e.prototype,"_attachments",void 0),e([m()],_e.prototype,"_associationItemList",void 0),e([m()],_e.prototype,"_associationSettings",void 0),e([m()],_e.prototype,"_featureTemplates",void 0),e([m()],_e.prototype,"_filterText",void 0),e([m()],_e.prototype,"_hasInvalidBatchSelection",null),e([m()],_e.prototype,"_hasSelectionFromMultipleLayers",null),e([m()],_e.prototype,"_prompt",void 0),e([m()],_e.prototype,"_spinner",void 0),e([m()],_e.prototype,"_deleteButtonCommonInfo",null),e([m()],_e.prototype,"_loading",void 0),e([m()],_e.prototype,"_selectionCountExceedsMaximum",null),e([m()],_e.prototype,"_selectionList",void 0),e([m()],_e.prototype,"_selectionListItemActionConfigs",null),e([m()],_e.prototype,"_selectionToolbar",void 0),e([m()],_e.prototype,"_visibleSelectionCount",null),e([m({readOnly:!0})],_e.prototype,"activeWorkflow",null),e([m()],_e.prototype,"effectiveSelectionManager",null),e([m()],_e.prototype,"headingLevel",void 0),e([m()],_e.prototype,"hideTemplatesForInactiveLayers",null),e([m()],_e.prototype,"icon",null),e([m()],_e.prototype,"label",null),e([m()],_e.prototype,"labelOptions",null),e([m()],_e.prototype,"layerInfos",null),e([m(),de("esri/widgets/Editor/t9n/Editor")],_e.prototype,"messages",void 0),e([m(),de("esri/t9n/common")],_e.prototype,"messagesCommon",void 0),e([m(),de("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],_e.prototype,"messagesTemplates",void 0),e([m(),de("esri/widgets/Feature/t9n/Feature")],_e.prototype,"messagesFeature",void 0),e([m()],_e.prototype,"snappingOptions",null),e([m()],_e.prototype,"tooltipOptions",null),e([m()],_e.prototype,"supportingWidgetDefaults",void 0),e([m({type:g,nonNullable:!0})],_e.prototype,"valueOptions",null),e([m()],_e.prototype,"view",null),e([m(),he(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],_e.prototype,"viewModel",void 0),e([m({type:T,nonNullable:!0})],_e.prototype,"visibleElements",void 0),e([m()],_e.prototype,"_helpMessage",null),e([m()],_e.prototype,"_noticeMessage",null),_e=e([p("esri.widgets.Editor")],_e);const ve=_e;export{ve 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveFieldAlias as r}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as a,defaultFormatterOptionsNoTime as s,convertDateTimeFieldFormatToIntlOptions as u,defaultFormatterOptions as p}from"../../intl/date.js";import{formatNumber as d,convertNumberFormatToIntlOptions as m,convertNumberFieldFormatToIntlOptions as c}from"../../intl/number.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as h}from"../../layers/support/featureLayerUtils.js";import y from"../../layers/support/Field.js";import{defaultFieldFormat as g}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as v,isDateField as F,isTimeOnlyField as _,isIntegerField as C,isNumericField as b,isStringField as D,isDateOnlyField as I,isTimestampOffsetField as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as O}from"../../time/constants.js";import{getTimeZoneFormattingOptions as w}from"../../time/timeZoneUtils.js";import V from"../FeatureForm/FieldInput.js";import E from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{valueIsInRange as j,dateTimeIsInRange as R,getUnixFieldValueFromDateComponents as S,getISOFieldValueFromDateComponents as N,normalizeTimeOnlyString as A,getLabelForDateFieldValue as U,prepareISOFieldValueForDateComponents as q,prepareUnixFieldValueForDateComponents as k}from"../support/dateUtils.js";import{setFocus as B}from"../support/widgetUtils.js";const z={cancelEdit:"Escape"},H=Symbol(),P="esri-column",M={input:`${P}__cell-input`,inputContainer:`${P}__cell__input-container`};let W=class extends E{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:o,item:{attachments:l,feature:r,relatedRecords:a}}=t,s=n({attachments:l,column:this,feature:r,field:this.field,index:o,relatedRecords:a,value:this.sanitizeContent(i),virtualIndex:this.getVirtualRowIndex(e)});return this.sanitizeContent(s)}if(null===i)return" ";const o=this._getDomainForFeature(t?.item?.feature),l=this._getComputedDomain(i,o)||i;return this._isAnyDateOrTimeField&&"coded-value"!==o?.type?this._formatDateValueForDisplay(this.field,l):this._isNumericField&&"coded-value"!==o?.type?d(parseFloat(l),this._numberFormatOptions):this.sanitizeContent(l)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(v(o,i)||!j({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!R({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&v(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(M.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await B(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return F(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=A(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return N({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return S({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||_(e)}get _isIntegerField(){return C(this.field)}get _isNumericField(){return b(this.field)}get _isStringField(){return D(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return Z(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?a(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?s:"date-time"===e?.type?u(e):this._isAnyDateOrTimeField?p:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?m(t.format):"number"===e?.type?c(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return r(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:this.sanitizeLabel(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=f(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return this.sanitizeLabel(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return w(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??O,a("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??g(this.field)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],H);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=j({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],H),o>-1&&(a.maxLength=o),l>0&&(a.minLength=l);return a.classList.add(M.input),a.required=r,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===z.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],H),a}onInputBlur(e=!1){this.removeHandles(H),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?U(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(r,e),u=[];if(T(r)){const e=this.createDateComponent(),p=I(r)||x(r)?o:t,d=I(r)||x(r)?l:n,m=this._getDateFieldValuesForComponents(r,p??null),c=this._getDateFieldValuesForComponents(r,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],H),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return k(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return q(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new V({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=h(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([o()],W.prototype,"_effectiveDomain",null),e([o()],W.prototype,"_activeFieldInput",void 0),e([o()],W.prototype,"_effectiveRange",null),e([o()],W.prototype,"_isAnyDateOrTimeField",null),e([o()],W.prototype,"_isIntegerField",null),e([o()],W.prototype,"_isNumericField",null),e([o()],W.prototype,"_isStringField",null),e([o()],W.prototype,"_isSubtypeField",null),e([o()],W.prototype,"_layerWithFieldConfigurations",null),e([o()],W.prototype,"_dateTimeFormatOptions",null),e([o()],W.prototype,"_numberFormatOptions",null),e([o({readOnly:!0})],W.prototype,"alias",null),e([o()],W.prototype,"cellValueFormatFunction",void 0),e([o()],W.prototype,"cellValueValidatorFunction",void 0),e([o({readOnly:!0})],W.prototype,"defaultValue",null),e([o()],W.prototype,"effectiveDescription",null),e([o()],W.prototype,"effectiveEditable",null),e([o()],W.prototype,"effectiveLabel",null),e([o()],W.prototype,"effectiveRequired",null),e([o()],W.prototype,"effectiveSortable",null),e([o()],W.prototype,"effectiveTimeZoneOptions",null),e([o({type:y})],W.prototype,"field",void 0),e([o()],W.prototype,"formatFunction",void 0),e([o()],W.prototype,"includeTime",null),e([o()],W.prototype,"inputRenderFunction",void 0),e([o()],W.prototype,"layer",void 0),e([o()],W.prototype,"layerFieldConfigurationFormat",null),e([o({readOnly:!0})],W.prototype,"loadingMessage",null),e([o()],W.prototype,"maxLength",null),e([o()],W.prototype,"minLength",null),e([o({readOnly:!0})],W.prototype,"name",null),e([o({readOnly:!0})],W.prototype,"nullable",null),e([o()],W.prototype,"parseInputValueFunction",void 0),e([o()],W.prototype,"shouldShowPrompt",null),e([o()],W.prototype,"sortable",void 0),e([o()],W.prototype,"store",void 0),e([o()],W.prototype,"template",void 0),e([o()],W.prototype,"view",void 0),W=e([l("esri.widgets.FeatureTable.FieldColumn")],W);const G=W;export{G as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveFieldAlias as r}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as a,defaultFormatterOptionsNoTime as s,convertDateTimeFieldFormatToIntlOptions as u,defaultFormatterOptions as p}from"../../intl/date.js";import{formatNumber as d,convertNumberFormatToIntlOptions as m,convertNumberFieldFormatToIntlOptions as c}from"../../intl/number.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as h}from"../../layers/support/featureLayerUtils.js";import y from"../../layers/support/Field.js";import{defaultFieldFormat as g}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as v,isDateField as F,isTimeOnlyField as _,isIntegerField as C,isNumericField as b,isStringField as D,isDateOnlyField as I,isTimestampOffsetField as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as O}from"../../time/constants.js";import{getTimeZoneFormattingOptions as w}from"../../time/timeZoneUtils.js";import V from"../FeatureForm/FieldInput.js";import E from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{valueIsInRange as j,dateTimeIsInRange as R,getUnixFieldValueFromDateComponents as S,getISOFieldValueFromDateComponents as N,normalizeTimeOnlyString as A,getLabelForDateFieldValue as U,prepareISOFieldValueForDateComponents as q,prepareUnixFieldValueForDateComponents as k}from"../support/dateUtils.js";import{setFocus as B}from"../support/widgetUtils.js";const H={cancelEdit:"Escape"},z=Symbol(),P="esri-column",M={input:`${P}__cell-input`,inputContainer:`${P}__cell__input-container`};let W=class extends E{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:o,item:{attachments:l,feature:r,relatedRecords:a}}=t;return n({attachments:l,column:this,feature:r,field:this.field,index:o,relatedRecords:a,value:this.sanitizeContent(i),virtualIndex:this.getVirtualRowIndex(e)})}if(null===i)return" ";const o=this._getDomainForFeature(t?.item?.feature),l=this._getComputedDomain(i,o)||i;return this._isAnyDateOrTimeField&&"coded-value"!==o?.type?this._formatDateValueForDisplay(this.field,l):this._isNumericField&&"coded-value"!==o?.type?d(parseFloat(l),this._numberFormatOptions):this.sanitizeContent(l)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(v(o,i)||!j({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!R({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&v(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(M.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await B(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return F(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=A(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return N({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return S({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||_(e)}get _isIntegerField(){return C(this.field)}get _isNumericField(){return b(this.field)}get _isStringField(){return D(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return Z(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?a(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?s:"date-time"===e?.type?u(e):this._isAnyDateOrTimeField?p:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?m(t.format):"number"===e?.type?c(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return r(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:this.sanitizeLabel(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=f(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return this.sanitizeLabel(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return w(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??O,a("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??g(this.field)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],z);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=j({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],z),o>-1&&(a.maxLength=o),l>0&&(a.minLength=l);return a.classList.add(M.input),a.required=r,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===H.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],z),a}onInputBlur(e=!1){this.removeHandles(z),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?U(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(r,e),u=[];if(T(r)){const e=this.createDateComponent(),p=I(r)||x(r)?o:t,d=I(r)||x(r)?l:n,m=this._getDateFieldValuesForComponents(r,p??null),c=this._getDateFieldValuesForComponents(r,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return k(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return q(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new V({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=h(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([o()],W.prototype,"_effectiveDomain",null),e([o()],W.prototype,"_activeFieldInput",void 0),e([o()],W.prototype,"_effectiveRange",null),e([o()],W.prototype,"_isAnyDateOrTimeField",null),e([o()],W.prototype,"_isIntegerField",null),e([o()],W.prototype,"_isNumericField",null),e([o()],W.prototype,"_isStringField",null),e([o()],W.prototype,"_isSubtypeField",null),e([o()],W.prototype,"_layerWithFieldConfigurations",null),e([o()],W.prototype,"_dateTimeFormatOptions",null),e([o()],W.prototype,"_numberFormatOptions",null),e([o({readOnly:!0})],W.prototype,"alias",null),e([o()],W.prototype,"cellValueFormatFunction",void 0),e([o()],W.prototype,"cellValueValidatorFunction",void 0),e([o({readOnly:!0})],W.prototype,"defaultValue",null),e([o()],W.prototype,"effectiveDescription",null),e([o()],W.prototype,"effectiveEditable",null),e([o()],W.prototype,"effectiveLabel",null),e([o()],W.prototype,"effectiveRequired",null),e([o()],W.prototype,"effectiveSortable",null),e([o()],W.prototype,"effectiveTimeZoneOptions",null),e([o({type:y})],W.prototype,"field",void 0),e([o()],W.prototype,"formatFunction",void 0),e([o()],W.prototype,"includeTime",null),e([o()],W.prototype,"inputRenderFunction",void 0),e([o()],W.prototype,"layer",void 0),e([o()],W.prototype,"layerFieldConfigurationFormat",null),e([o({readOnly:!0})],W.prototype,"loadingMessage",null),e([o()],W.prototype,"maxLength",null),e([o()],W.prototype,"minLength",null),e([o({readOnly:!0})],W.prototype,"name",null),e([o({readOnly:!0})],W.prototype,"nullable",null),e([o()],W.prototype,"parseInputValueFunction",void 0),e([o()],W.prototype,"shouldShowPrompt",null),e([o()],W.prototype,"sortable",void 0),e([o()],W.prototype,"store",void 0),e([o()],W.prototype,"template",void 0),e([o()],W.prototype,"view",void 0),W=e([l("esri.widgets.FeatureTable.FieldColumn")],W);const G=W;export{G as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s,stripHTMLSanitizer as r}from"../../../core/sanitizerUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{css as c}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as d}from"../support/tableUtils.js";import{autoLink as p}from"../../support/uriUtils.js";import{setFocus as u}from"../../support/widgetUtils.js";const m=/<br\s*\/*>/gi;let h=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=this.sanitizeContent(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t,a=n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0});return this.sanitizeContent(a)}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:p(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return d(e)?null:this.sanitizeLabel(e)}get effectiveLabel(){return this.sanitizeLabel(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?this.sanitizeLabel(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(c.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(c.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!a,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(c.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:c.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:c.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,u(this.menuItems[0]))}sanitizeContent(e){return s.sanitize(e)}sanitizeLabel(e){return null==e||""===e?"":r.sanitize(e.toString()).replaceAll(m," ")}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([l()],h.prototype,"_headerRequiresTextContainer",null),e([l()],h.prototype,"_menuIsOpen",void 0),e([l()],h.prototype,"autoWidth",void 0),e([l()],h.prototype,"cellValueFormatFunction",void 0),e([l()],h.prototype,"customMenuItems",null),e([l()],h.prototype,"defaultMenuItems",null),e([l()],h.prototype,"description",void 0),e([l()],h.prototype,"direction",void 0),e([l()],h.prototype,"effectiveDescription",null),e([l()],h.prototype,"effectiveLabel",null),e([l()],h.prototype,"effectiveSortable",null),e([l({constructOnly:!0})],h.prototype,"fieldName",void 0),e([l()],h.prototype,"flexGrow",void 0),e([l()],h.prototype,"footerRenderFunction",void 0),e([l()],h.prototype,"formatFunction",void 0),e([l()],h.prototype,"frozen",void 0),e([l()],h.prototype,"frozenToEnd",void 0),e([l()],h.prototype,"grid",void 0),e([l()],h.prototype,"iconNode",null),e([l()],h.prototype,"invalid",null),e([l()],h.prototype,"headerRenderFunction",void 0),e([l()],h.prototype,"hidden",void 0),e([l()],h.prototype,"icon",void 0),e([l()],h.prototype,"iconText",void 0),e([l({constructOnly:!0})],h.prototype,"initialSortPriority",void 0),e([l()],h.prototype,"label",void 0),e([l()],h.prototype,"labelTooltipText",void 0),e([l()],h.prototype,"menu",null),e([l()],h.prototype,"menuItems",null),e([l()],h.prototype,"menuConfig",void 0),e([l()],h.prototype,"menuIsOpen",null),e([l()],h.prototype,"menuIsVisible",null),e([l()],h.prototype,"messages",void 0),e([l()],h.prototype,"messagesCommon",void 0),e([l()],h.prototype,"messagesURIUtils",void 0),e([l()],h.prototype,"renderFunction",void 0),e([l()],h.prototype,"resizable",void 0),e([l()],h.prototype,"sortable",void 0),e([l({readOnly:!0})],h.prototype,"sortElement",void 0),e([l()],h.prototype,"store",void 0),e([l()],h.prototype,"tableTimeZone",void 0),e([l()],h.prototype,"textAlign",void 0),e([l()],h.prototype,"textWrap",void 0),e([l()],h.prototype,"timeZone",void 0),e([l()],h.prototype,"visibleElements",void 0),e([l()],h.prototype,"width",void 0),h=e([a("esri.widgets.FeatureTable.Grid.Column")],h);const f=h;export{f as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s,stripHTMLSanitizer as r}from"../../../core/sanitizerUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{css as c}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as d}from"../support/tableUtils.js";import{autoLink as p}from"../../support/uriUtils.js";import{setFocus as u}from"../../support/widgetUtils.js";const m=/<br\s*\/*>/gi;let h=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=this.sanitizeContent(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t;return n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0})}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:p(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return d(e)?null:this.sanitizeLabel(e)}get effectiveLabel(){return this.sanitizeLabel(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?this.sanitizeLabel(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(c.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(c.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!a,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(c.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:c.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:c.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,u(this.menuItems[0]))}sanitizeContent(e){return s.sanitize(e)}sanitizeLabel(e){return null==e||""===e?"":r.sanitize(e.toString()).replaceAll(m," ")}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([l()],h.prototype,"_headerRequiresTextContainer",null),e([l()],h.prototype,"_menuIsOpen",void 0),e([l()],h.prototype,"autoWidth",void 0),e([l()],h.prototype,"cellValueFormatFunction",void 0),e([l()],h.prototype,"customMenuItems",null),e([l()],h.prototype,"defaultMenuItems",null),e([l()],h.prototype,"description",void 0),e([l()],h.prototype,"direction",void 0),e([l()],h.prototype,"effectiveDescription",null),e([l()],h.prototype,"effectiveLabel",null),e([l()],h.prototype,"effectiveSortable",null),e([l({constructOnly:!0})],h.prototype,"fieldName",void 0),e([l()],h.prototype,"flexGrow",void 0),e([l()],h.prototype,"footerRenderFunction",void 0),e([l()],h.prototype,"formatFunction",void 0),e([l()],h.prototype,"frozen",void 0),e([l()],h.prototype,"frozenToEnd",void 0),e([l()],h.prototype,"grid",void 0),e([l()],h.prototype,"iconNode",null),e([l()],h.prototype,"invalid",null),e([l()],h.prototype,"headerRenderFunction",void 0),e([l()],h.prototype,"hidden",void 0),e([l()],h.prototype,"icon",void 0),e([l()],h.prototype,"iconText",void 0),e([l({constructOnly:!0})],h.prototype,"initialSortPriority",void 0),e([l()],h.prototype,"label",void 0),e([l()],h.prototype,"labelTooltipText",void 0),e([l()],h.prototype,"menu",null),e([l()],h.prototype,"menuItems",null),e([l()],h.prototype,"menuConfig",void 0),e([l()],h.prototype,"menuIsOpen",null),e([l()],h.prototype,"menuIsVisible",null),e([l()],h.prototype,"messages",void 0),e([l()],h.prototype,"messagesCommon",void 0),e([l()],h.prototype,"messagesURIUtils",void 0),e([l()],h.prototype,"renderFunction",void 0),e([l()],h.prototype,"resizable",void 0),e([l()],h.prototype,"sortable",void 0),e([l({readOnly:!0})],h.prototype,"sortElement",void 0),e([l()],h.prototype,"store",void 0),e([l()],h.prototype,"tableTimeZone",void 0),e([l()],h.prototype,"textAlign",void 0),e([l()],h.prototype,"textWrap",void 0),e([l()],h.prototype,"timeZone",void 0),e([l()],h.prototype,"visibleElements",void 0),e([l()],h.prototype,"width",void 0),h=e([a("esri.widgets.FeatureTable.Grid.Column")],h);const f=h;export{f as default};
|