@arcgis/core 4.26.0-next.20230213 → 4.26.0-next.20230215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4b41a08d603e846306da.js → 1faf0e2aeabe003e2f64.js} +1 -1
- package/assets/esri/core/workers/chunks/{1770729d33e57bb2919a.js → 674d4a032e6db9a86f74.js} +1 -1
- package/assets/esri/core/workers/chunks/8111fc49f8e8f260981d.js +1 -0
- package/assets/esri/core/workers/chunks/979d5e22dbdcec90029f.js +1 -0
- package/assets/esri/core/workers/chunks/9f8aad19c5973e201604.js +1 -0
- package/assets/esri/core/workers/chunks/{21f1d91121d95ef21604.js → bb6e4affafef9855b8fd.js} +1 -1
- package/assets/esri/core/workers/chunks/{accb787c5c8ee7bfe35b.js → caa8768192cecad99776.js} +1 -1
- package/interfaces.d.ts +2 -2
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/localUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/rest/query/executeQuery.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMImageColorSubstitutionHelper.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/Settings.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/Slice.js +1 -1
- package/assets/esri/core/workers/chunks/52e40e348c27a0e66f9a.js +0 -1
- package/assets/esri/core/workers/chunks/8be68f08c270c62e38bb.js +0 -1
- package/assets/esri/core/workers/chunks/978220022a8c9a3e9261.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/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import n from"../../../Color.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import{subclass as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import n from"../../../Color.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";let o=class extends t{constructor(){super(...arguments),this.enabled=!0}};e([i({type:Boolean})],o.prototype,"enabled",void 0),o=e([r("esri.views.interactive.snapping.Settings.DefaultSnappingAlgorithm")],o);let l=class extends t{constructor(e){super(e),this.lineSnapper=new o,this.parallelLineSnapper=new o,this.rightAngleSnapper=new o,this.rightAngleTriangleSnapper=new o,this.shortLineThreshold=15,this.distance=5,this.pointThreshold=1e-6,this.intersectionParallelLineThreshold=1e-6,this.parallelLineThreshold=1e-6,this.verticalLineThreshold=.1,this.touchSensitivityMultiplier=1.5,this.pointOnLineThreshold=1e-6,this.orange=new n([255,127,0]),this.orangeTransparent=new n([255,127,0,.5]),this.lineHintWidthReference=3,this.lineHintWidthTarget=3,this.lineHintFadedExtensions=.3,this.parallelLineHintWidth=2,this.parallelLineHintLength=24,this.parallelLineHintOffset=1.5,this.rightAngleHintSize=24,this.rightAngleHintOutlineSize=1.5,this.satisfiesConstraintScreenThreshold=1}};e([i({type:o,constructOnly:!0,nonNullable:!0,json:{write:!0}})],l.prototype,"lineSnapper",void 0),e([i({type:o,constructOnly:!0,nonNullable:!0,json:{write:!0}})],l.prototype,"parallelLineSnapper",void 0),e([i({type:o,constructOnly:!0,nonNullable:!0,json:{write:!0}})],l.prototype,"rightAngleSnapper",void 0),e([i({type:o,constructOnly:!0,nonNullable:!0,json:{write:!0}})],l.prototype,"rightAngleTriangleSnapper",void 0),e([i({type:Number,nonNullable:!0,range:{min:-1,max:50,step:1},json:{write:!0}})],l.prototype,"shortLineThreshold",void 0),e([i({type:Number,nonNullable:!0,range:{min:-1,max:50,step:1},json:{write:!0}})],l.prototype,"distance",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1e-5},json:{write:!0}})],l.prototype,"pointThreshold",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1e-5},json:{write:!0}})],l.prototype,"intersectionParallelLineThreshold",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1e-5},json:{write:!0}})],l.prototype,"parallelLineThreshold",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1},json:{write:!0}})],l.prototype,"verticalLineThreshold",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:10},json:{write:!0}})],l.prototype,"touchSensitivityMultiplier",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1e-5},json:{write:!0}})],l.prototype,"pointOnLineThreshold",void 0),e([i({type:n,nonNullable:!0})],l.prototype,"orange",void 0),e([i({type:n,nonNullable:!0})],l.prototype,"orangeTransparent",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:10},json:{write:!0}})],l.prototype,"lineHintWidthReference",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:10},json:{write:!0}})],l.prototype,"lineHintWidthTarget",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:1},json:{write:!0}})],l.prototype,"lineHintFadedExtensions",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:10},json:{write:!0}})],l.prototype,"parallelLineHintWidth",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:50},json:{write:!0}})],l.prototype,"parallelLineHintLength",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:5},json:{write:!0}})],l.prototype,"parallelLineHintOffset",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:46},json:{write:!0}})],l.prototype,"rightAngleHintSize",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:6},json:{write:!0}})],l.prototype,"rightAngleHintOutlineSize",void 0),e([i({type:Number,nonNullable:!0,range:{min:0,max:5},json:{write:!0}})],l.prototype,"satisfiesConstraintScreenThreshold",void 0),l=e([r("esri.views.interactive.snapping.Settings.Defaults")],l);const p=new l;export{p as defaults};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../core/maybe.js";import{
|
|
5
|
+
import{isSome as e}from"../../../core/maybe.js";import{k as t}from"../../../chunks/vec2.js";import{absoluteHeightElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{defaults as r}from"./Settings.js";import{anyMapPointToSnappingPoint as i}from"./SnappingPoint.js";import{squaredScreenDistance as o}from"./snappingUtils.js";import{vectorToScreenPoint as h}from"../support/viewUtils.js";class n{constructor(e,t){this.view=e,this.options=t,this.squaredShortLineThreshold=r.shortLineThreshold*r.shortLineThreshold}snap(t,s){return e(s.vertexHandle)?"vertex"!==s.vertexHandle.type?[]:this.snapExistingVertex(t,s):this.snapNewVertex(t,s)}edgeExceedsShortLineThreshold(e,t){return this.exceedsShortLineThreshold(i(e.leftVertex.pos,this.view,t),i(e.rightVertex.pos,this.view,t),t)}exceedsShortLineThreshold(e,t,{spatialReference:r}){return 0===this.squaredShortLineThreshold||o(h(t,r,s,this.view),h(e,r,s,this.view))>this.squaredShortLineThreshold}isVertical(e,s){return t(e,s)<r.verticalLineThreshold}squaredProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:t}=this.options,s=e*t;return s*s}}export{n as SnappingAlgorithm};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l,isSome as d}from"../../core/maybe.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getEffectiveLayerCapabilities as k}from"../../layers/support/layerUtils.js";import g from"../Attachments/AttachmentsViewModel.js";import v from"./CreateFeaturesWorkflow.js";import b from"./CreateWorkflow.js";import{workflowDeprecation as _}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import{whenEditorLayerView as C}from"./workflowUtils.js";import F from"../FeatureForm/FeatureFormViewModel.js";import E from"../FeatureTemplates/FeatureTemplatesViewModel.js";import I from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const U="esri.widgets.Editor.EditorViewModel",A=n.getLogger(U),V=["create","create-features","update"];function M(t,e,a){A.error(new i(t,e,a))}function j(t,e){return t?t.find((t=>t.layer===e)):void 0}let T=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new g({abilities:{editing:!0}}),this.featureFormViewModel=new F,this.featureTemplatesViewModel=new E,this.sketchViewModel=new I({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;t.submit(),!t.submittable||t.validateContingencyConstraints(t.getValues(),{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.handles.add([p((()=>{const t=this.view?.map?.editableLayers.filter((t=>t.visible)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>{t.add(this._sketchGraphicsLayer)}),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...V]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((t=>t.supports.includes("update")||t.supports.includes("delete")||t.attachmentsOnUpdateEnabled))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(A,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.pendingFeatures.length?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.pendingFeatures.length){const{template:e}=t.data.creationInfo;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{state:t,activeWorkflow:e}=this;return"editing-existing-feature"===t&&"update"===e?.type&&!1===e?.data.editableItem.attributeUpdatesEnabled}get canGoBack(){return d(this.activeWorkflow)&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(_(A,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(_(A,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(_(A,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=k(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const a of o.reverse()){const{layer:t,suspended:e}=a;"subtype-group"===t.type?(await t.loadAll(),n.push(...t.sublayers.slice().reverse().map((t=>this._makeEditableItemForLayer(t,e))))):n.push(this._makeEditableItemForLayer(t,e))}for(const a of s.reverse())"subtype-group"===a.type?(await a.loadAll(),n.push(...a.sublayers.map((t=>this._makeEditableItemForLayer(t,!1))))):n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return v.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return b.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return W.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=[];return e?.forEach((e=>a.push(this._addAttachment(t,e.feature,e.attachment)))),Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;return await this._queueOperation((async()=>{if(k(t)?.operations.supportsQuery){const i=await C(this.view,t);return r=await t.applyEdits(e,a),await h((()=>!i.updating)),r}return r=await t.applyEdits(e,a),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{M("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=k(t),r=a?.operations,i=j(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],T.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],T.prototype,"_activityQueue",void 0),t([f({value:[...V]})],T.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],T.prototype,"canCreate",null),t([f({readOnly:!0})],T.prototype,"canUpdate",null),t([f()],T.prototype,"editableItems",void 0),t([f({readOnly:!0})],T.prototype,"failures",void 0),t([f()],T.prototype,"attachmentsViewModel",void 0),t([f()],T.prototype,"featureFormViewModel",void 0),t([f()],T.prototype,"featureTemplatesViewModel",void 0),t([f()],T.prototype,"labelOptions",null),t([f()],T.prototype,"layerInfos",null),t([f()],T.prototype,"sketchViewModel",void 0),t([f()],T.prototype,"snappingOptions",null),t([f()],T.prototype,"spinnerViewModel",void 0),t([f()],T.prototype,"state",null),t([f({readOnly:!0})],T.prototype,"syncing",null),t([f()],T.prototype,"updating",null),t([f()],T.prototype,"tooltipOptions",null),t([f()],T.prototype,"view",null),t([f()],T.prototype,"pageStack",void 0),t([f()],T.prototype,"showDiscardPrompt",void 0),t([f()],T.prototype,"_candidateCommitted",void 0),t([f()],T.prototype,"page",null),t([f()],T.prototype,"selectedTemplateItem",null),t([f()],T.prototype,"featureFormDisabled",null),t([f()],T.prototype,"canGoBack",null),t([f()],T.prototype,"shouldShowDeleteButton",null),t([f()],T.prototype,"hasPendingEdits",null),T=t([m(U)],T);const S=T;export{S as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l,isSome as d}from"../../core/maybe.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getEffectiveLayerCapabilities as k}from"../../layers/support/layerUtils.js";import g from"../Attachments/AttachmentsViewModel.js";import v from"./CreateFeaturesWorkflow.js";import b from"./CreateWorkflow.js";import{workflowDeprecation as _}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import{whenEditorLayerView as C}from"./workflowUtils.js";import F from"../FeatureForm/FeatureFormViewModel.js";import E from"../FeatureTemplates/FeatureTemplatesViewModel.js";import I from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const U="esri.widgets.Editor.EditorViewModel",A=n.getLogger(U),V=["create","create-features","update"];function M(t,e,a){A.error(new i(t,e,a))}function j(t,e){return t?t.find((t=>t.layer===e)):void 0}let T=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new g({abilities:{editing:!0}}),this.featureFormViewModel=new F,this.featureTemplatesViewModel=new E,this.sketchViewModel=new I({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;t.submit(),!t.submittable||t.validateContingencyConstraints(t.getValues(),{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.handles.add([p((()=>{const t=this.view?.map?.editableLayers.filter((t=>t.visible)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>{t.add(this._sketchGraphicsLayer)}),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...V]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((t=>t.supports.includes("update")||t.supports.includes("delete")||t.attachmentsOnUpdateEnabled))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(A,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.pendingFeatures.length?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.pendingFeatures.length){const{template:e}=t.data.creationInfo;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return d(this.activeWorkflow)&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(_(A,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(_(A,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(_(A,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=k(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const a of o.reverse()){const{layer:t,suspended:e}=a;"subtype-group"===t.type?(await t.loadAll(),n.push(...t.sublayers.slice().reverse().map((t=>this._makeEditableItemForLayer(t,e))))):n.push(this._makeEditableItemForLayer(t,e))}for(const a of s.reverse())"subtype-group"===a.type?(await a.loadAll(),n.push(...a.sublayers.map((t=>this._makeEditableItemForLayer(t,!1))))):n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return v.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return b.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return W.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=[];return e?.forEach((e=>a.push(this._addAttachment(t,e.feature,e.attachment)))),Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;return await this._queueOperation((async()=>{if(k(t)?.operations.supportsQuery){const i=await C(this.view,t);return r=await t.applyEdits(e,a),await h((()=>!i.updating)),r}return r=await t.applyEdits(e,a),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{M("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=k(t),r=a?.operations,i=j(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],T.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],T.prototype,"_activityQueue",void 0),t([f({value:[...V]})],T.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],T.prototype,"canCreate",null),t([f({readOnly:!0})],T.prototype,"canUpdate",null),t([f()],T.prototype,"editableItems",void 0),t([f({readOnly:!0})],T.prototype,"failures",void 0),t([f()],T.prototype,"attachmentsViewModel",void 0),t([f()],T.prototype,"featureFormViewModel",void 0),t([f()],T.prototype,"featureTemplatesViewModel",void 0),t([f()],T.prototype,"labelOptions",null),t([f()],T.prototype,"layerInfos",null),t([f()],T.prototype,"sketchViewModel",void 0),t([f()],T.prototype,"snappingOptions",null),t([f()],T.prototype,"spinnerViewModel",void 0),t([f()],T.prototype,"state",null),t([f({readOnly:!0})],T.prototype,"syncing",null),t([f()],T.prototype,"updating",null),t([f()],T.prototype,"tooltipOptions",null),t([f()],T.prototype,"view",null),t([f()],T.prototype,"pageStack",void 0),t([f()],T.prototype,"showDiscardPrompt",void 0),t([f()],T.prototype,"_candidateCommitted",void 0),t([f()],T.prototype,"page",null),t([f()],T.prototype,"selectedTemplateItem",null),t([f()],T.prototype,"featureFormDisabled",null),t([f()],T.prototype,"canGoBack",null),t([f()],T.prototype,"shouldShowDeleteButton",null),t([f()],T.prototype,"hasPendingEdits",null),T=t([m(U)],T);const S=T;export{S as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../core/HandleOwner.js";import{watch as n,initial as s}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import m from"../../../popup/content/TextContent.js";import h from"../../../popup/ElementExpressionInfo.js";import u from"../FeatureContent/FeatureContentViewModel.js";import d from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcadeUtils as y,createCompiledExpression as _}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends(r(o)){constructor(t){super(t),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.view=null,this._cancelQuery=()=>{const{_abortController:t}=this;t&&t.abort(),this._abortController=null},this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new d:"media"===t?new f:"text"===t?new u:null;this._set("contentElementViewModel",e)},this._compile=async()=>{this._cancelQuery();const t=new AbortController;this._abortController=t,await this._compileExpression(),this._abortController===t&&(this._abortController=null)},this._compileThrottled=i(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:t,graphic:e,interceptor:o,spatialReference:r,map:n,view:s,_abortController:i}=this;if(!(
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../core/HandleOwner.js";import{watch as n,initial as s}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import m from"../../../popup/content/TextContent.js";import h from"../../../popup/ElementExpressionInfo.js";import u from"../FeatureContent/FeatureContentViewModel.js";import d from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcadeUtils as y,createCompiledExpression as _}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends(r(o)){constructor(t){super(t),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.view=null,this._cancelQuery=()=>{const{_abortController:t}=this;t&&t.abort(),this._abortController=null},this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new d:"media"===t?new f:"text"===t?new u:null;this._set("contentElementViewModel",e)},this._compile=async()=>{this._cancelQuery();const t=new AbortController;this._abortController=t,await this._compileExpression(),this._abortController===t&&(this._abortController=null)},this._compileThrottled=i(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:t,graphic:e,interceptor:o,spatialReference:r,map:n,view:s,_abortController:i}=this;if(!(t&&e&&r&&n))return void this._set("contentElement",null);const l=await y();if(i!==this._abortController)return;const p=await _({arcadeUtils:l,expressionInfo:t,graphic:e,interceptor:o,map:n,spatialReference:r,view:s});if(!p||"esri.arcade.Dictionary"!==p.declaredClass)return void this._set("contentElement",null);const h=await p.castAsJsonAsync(i?.signal),u=h?.type,d="media"===u?c.fromJSON(h):"text"===u?m.fromJSON(h):"fields"===u?a.fromJSON(h):null;this._set("contentElement",d)},this.handles.add([n((()=>[this.expressionInfo,this.graphic,this.map,this.spatialReference,this.view]),(()=>this._compileThrottled()),s),n((()=>[this.contentElement]),(()=>this._createVM()),s)])}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{_abortController:t,contentElement:e,contentElementViewModel:o}=this;return t?"loading":e||o?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}};t([l()],j.prototype,"_abortController",void 0),t([l({type:h})],j.prototype,"expressionInfo",void 0),t([l({type:e})],j.prototype,"graphic",void 0),t([l({readOnly:!0})],j.prototype,"contentElement",void 0),t([l({readOnly:!0})],j.prototype,"contentElementViewModel",void 0),t([l()],j.prototype,"interceptor",void 0),t([l()],j.prototype,"spatialReference",null),t([l({readOnly:!0})],j.prototype,"state",null),t([l()],j.prototype,"map",null),t([l()],j.prototype,"view",void 0),j=t([p("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],j);const C=j;export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{destroyMaybe as o,isSome as r,isNone as a,unwrap as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as g}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{isGroupField as y,getNormalizedFeatureTypeInfo as _}from"./featureFormUtils.js";import{createFormExpressionArcadeExecutor as F}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as v}from"./FormExpressionsManager.js";import C from"./InputField.js";import E from"./InputFieldGroup.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as I}from"../../intl/messages.js";const V=new t({attributes:{}}),b=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],j=["visibilityExpression"],w="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",A="#JSAPI_CONTINGENT_VALUE_ANY_HASH",M="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let T=class extends(n(u(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=V.clone(),this._initialFeature=V.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.inputFields=[],this.messages=null,this.strict=!1}initialize(){const e=async()=>{const e=await I("esri/widgets/FeatureForm/t9n/FeatureForm");this.messages=e;for(const t of this.allInputFields)t.messages=e};e();const t=p((()=>[this.layer,this.layer?.loaded,this.formTemplate]),(([e,t])=>{r(e)&&(t?this._updateInputFields():e.load().catch((()=>i.getLogger(this.declaredClass).error("Failed to load layer",e.loadError))))}),{equals:([e,t,s],[n,i,o])=>e===n&&t===i&&s===o,initial:!0}),s=p((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([x(e),t,s])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache)}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:s,spatialReference:n,view:i}=this;return{layer:g(s)?s:null,originalFeature:e,editType:t,spatialReference:n,map:i?.map}}get updating(){return this.updatingHandles.updating}get allInputFields(){return L(this.inputFields)}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():V.clone(),this._initialFeature=this._featureClone.clone(),this._resetInputFieldValues(this._featureClone),this.contingencyConstraintViolations.clear(),r(this._expressionsManager)&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:s}=this,n=!!s?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:s,strict:n}=this,i=this.findField(e);t=""===t?null:t,i&&s.getAttribute(e)!==t&&(i.value=t,n&&!i.valid||(this._afterValueChange(i),r(this._expressionsManager)&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),s=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),s.push(i));this.emit("submit",{valid:[...t],invalid:s,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:s}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(s))return[];const{invalid:i,incomplete:o}=s.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:s}=this;s.geometry=t.geometry,r(e)&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:s}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:s,valid:t})}_updateInputFields(){const{_featureClone:e,_initialFeature:t,formTemplate:s,inputFields:n,messages:i,layer:o}=this,a={feature:e,initialFeature:t,layer:o,messages:i},l=n.slice(),u=r(s)&&s.elements.length>0?this._updateInputFieldsFromElements(l,s.elements,a):this._updateInputFieldsFromLayerFields(l,o?.fields,a);this.inputFields=u}_updateInputFieldsFromElements(e,t,s){const n=new Map;for(const r of e)if(y(r)){N(n,r.groupElement,r);for(const e of r.inputFields)N(n,e.fieldElement,e)}else N(n,r.fieldElement,r);const i=new Map,o=this._updateInputFieldsRecursive({existingInputFieldsByElement:n,updatedElements:t.filter(this._isSupportedElement),sharedInitializationProperties:s,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=L(o);return this._createExpressionsManager(e,t),l(this._expressionsManager).evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of n.entries())n.delete(r),a.destroy();return o}_updateInputFieldsRecursive(e){const{existingInputFieldsByElement:t,updatedElements:s,sharedInitializationProperties:n,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of s){const e=t.has(a),s=e?t.get(a):S(a)?this._makeInputFieldGroupFromGroupElement(a,n):this._makeInputFieldFromFieldElement(a,n,i);if(r.push(s),e)if(t.delete(a),y(s)){const{feature:e}=n;s.set({feature:e})}else s.set(n);else this._assignExpressionExecutors(s,a,o);if(S(a)){const e=a.elements.filter((e=>this._isSupportedElement(e)));s.inputFields=this._updateInputFieldsRecursive({existingInputFieldsByElement:t,updatedElements:e,sharedInitializationProperties:n,group:s,newExpressionExecutorPromises:o})}}return r}_updateInputFieldsFromLayerFields(e,t,s){if(!Array.isArray(t))return i.getLogger(this.declaredClass).warn(this.declaredClass,"No attribute fields found."),[];const n=new Map;for(const i of e)if(y(i)){for(const e of i.inputFields)e.destroy();i.inputFields.length=0,i.destroy()}else r(i.fieldElement)?i.destroy():n.set(i.field,i);const o=[],{feature:a,initialFeature:l,layer:u,messages:p}=s;for(const i of t){const e=n.get(i)??new C({field:i,feature:a,initialFeature:l,layer:u,messages:p,value:a.getAttribute(i.name)??null});o.push(e),n.delete(i)}for(const[i,r]of n.entries())n.delete(i),r.destroy();return o}_resetInputFieldValues(e){for(const t of this.allInputFields)t.value=e.getAttribute(t.name)}_makeInputFieldFromFieldElement(e,t,s=null){const{feature:n,initialFeature:i,layer:o,messages:r}=t;return new C({fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),value:n.getAttribute(e.fieldName)??null,feature:n,initialFeature:i,layer:o,group:s,messages:r})}_makeInputFieldGroupFromGroupElement(e,t){const{feature:s,initialFeature:n}=t;return new E({groupElement:e,inputFields:[],feature:s,initialFeature:n})}_assignExpressionExecutors(e,t,s){const n=S(t)?j:b,i=[];for(const o of n){const n=t[o],{_expressionExecutorLookup:i}=this;if(r(n)&&""!==n){const t=`${o}Executor`,r=this._expressionLookup.get(n)??this._addToExpressionLookup(n);if(i.has(r))e[t]=i.get(r);else if(s.has(r)){const n=s.get(r).then((s=>(e[t]=s,s)));s.set(r,n)}else{const n=F(r,this.layer).then((s=>(e[t]=s,i.set(r,s),s)));s.set(r,n)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:s,_featureClone:n}=this;this._expressionsManager=new v({executors:e,feature:n,arcadeContextInfo:s,inputFields:t})}_afterValueChange(e){const{name:t,value:s}=e,{_featureClone:n}=this,i=n.getAttribute(t);n.setAttribute(t,s);const{typeFieldName:o,types:r}=_(this.layer);if(t===o&&s!==i){if("subtype-sublayer"===this.layer.type){const e=this.layer.parent?.findSublayerForFeature(n);n.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of r)if(t.domains&&"object"==typeof t.domains)for(const s of Object.keys(t.domains))e.add(s);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allInputFields)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:s}=this,n=(r(s)&&r(s.expressionInfos)?Object.values(s.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(i.getLogger(this.declaredClass).warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(a(e))return[];const{typeFieldName:t}=_(this.layer),s=t?this.getValue(t):null,n=[];for(const a of e.fieldGroups){const{contingencies:e,fields:t,name:i}=a,o=[];for(const n of e)n.isRetired||r(n.subtype)&&n.subtype.code!==s||o.push({values:n.values});o.length>0&&n.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(n);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,s=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(n.has(r))continue;s.push([i,o]),n.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(s.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(s.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of s){const e=a.get(l),t=a.get(u);if(e===t)continue;const s=r.get(e),n=r.get(t);for(const i of n)s.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),s=t.shift();let n=t.shift(),i=this._generateJoinKey(s.fields,n.fields),o=new Set([...s.fields,...n.fields]),l=new Map;for(const r of s.contingencies){const[e]=this._hashContingency(r,i.codedValueFields,!0);l.has(e)?l.get(e).push(r):l.set(e,[r])}for(;t.length>0;){const e=new Map,s=t.shift(),r=this._generateJoinKey(o,s.fields);for(const t of n.contingencies){const[s,n]=this._hashContingency(t,i.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(l,s):l.get(s);if(l.has(A)&&o.push(...this._findMatchingContingenciesContainingAny(t,l.get(A),i.codedValueFields)),!a(o))for(const l of o){const s=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(l,t,i.rangeFields):this._joinContingencies(l,t);if(a(s))break;const[n]=this._hashContingency(s,r.codedValueFields,!0);e.has(n)?e.get(n).push(s):e.set(n,[s])}}l=e,n=s,i=r,o=new Set([...o,...n.fields])}const u=[];for(const p of n.contingencies){const[e,t]=this._hashContingency(p,i.codedValueFields),s=t?this._findMatchingContingenciesWithAnyHashMask(l,e):l.get(e);if(l.has(A)&&s.push(...this._findMatchingContingenciesContainingAny(p,l.get(A),i.codedValueFields)),!a(s))for(const n of s){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,p,i.rangeFields):this._joinContingencies(n,p);r(e)&&u.push(e)}}return u}_joinContingencies(e,t){const s={values:{...e.values,...t.values}};for(const[n,i]of Object.entries(s.values))"any"===i.objectType&&r(e.values[n])&&(s.values[n]=e.values[n]);return s}_joinContingenciesWithRangeDomains(e,t,s){const n=this._joinContingencies(e,t);for(const i of s){const s=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(s.objectType,o.objectType);if(l||d)continue;if(r&&p||a&&u){n.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&c)return null;u?(s.minValue=-1/0,s.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const g=Math.max(s.minValue,o.minValue),m=Math.min(s.maxValue,o.maxValue);if(g>m)return null;n.values[i]=new h({objectType:"range",minValue:g,maxValue:m})}return n}_findMatchingContingenciesContainingAny(e,t,s){return t.filter((t=>s.every((s=>{const n=t.values[s],i=e.values[s];return"any"===n.objectType||"any"===i.objectType||n.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const s=RegExp(`${t}$`),n=[];for(const[i,o]of e){if(i===A)break;s.test(i)&&n.push(...o)}return n}_generateJoinKey(e,t){const s=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,i=s.size<n.size?s:n,o=i===s?n:s,r=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,s=!1){if(t.length<1)return[w,!1];const n=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(s)return[A,!0];i=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${M}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([d()],T.prototype,"_featureClone",void 0),e([d()],T.prototype,"_arcadeContextInfo",null),e([d()],T.prototype,"updating",null),e([d({readOnly:!0})],T.prototype,"allInputFields",null),e([d()],T.prototype,"_layerFieldsByName",null),e([d()],T.prototype,"arcadeEditType",void 0),e([d()],T.prototype,"contingencyConstraintViolations",void 0),e([d()],T.prototype,"feature",null),e([d()],T.prototype,"fieldsWithContingentValues",null),e([d({type:f})],T.prototype,"formTemplate",null),e([d()],T.prototype,"inputFields",void 0),e([d()],T.prototype,"joinedContingentValues",null),e([d()],T.prototype,"layer",null),e([d()],T.prototype,"messages",void 0),e([d()],T.prototype,"spatialReference",null),e([d()],T.prototype,"state",null),e([d()],T.prototype,"strict",void 0),e([d()],T.prototype,"submittable",null),e([d()],T.prototype,"valid",null),e([d()],T.prototype,"view",void 0),e([d()],T.prototype,"getValues",null),e([d()],T.prototype,"submit",null),T=e([c("esri.widgets.FeatureForm.FeatureFormViewModel")],T);const S=e=>"group"===e.type,L=e=>e.reduce(((e,t)=>y(t)?[...e,...t.inputFields]:[...e,t]),[]),N=(e,t,s)=>{r(t)&&e.set(t,s)},k=T;export{k as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{destroyMaybe as o,isSome as a,isNone as r,unwrap as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as g}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{isGroupField as y,getNormalizedFeatureTypeInfo as _}from"./featureFormUtils.js";import{createFormExpressionArcadeExecutor as F}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as C}from"./FormExpressionsManager.js";import v from"./InputField.js";import E from"./InputFieldGroup.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as I}from"../../intl/messages.js";const V=new t({attributes:{}}),b=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],j=["visibilityExpression"],w="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",A="#JSAPI_CONTINGENT_VALUE_ANY_HASH",M="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let T=class extends(n(u(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=V.clone(),this._initialFeature=V.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.inputFields=[],this.messages=null,this.strict=!1}initialize(){const e=async()=>{const e=await I("esri/widgets/FeatureForm/t9n/FeatureForm");this.messages=e;for(const t of this.allInputFields)t.messages=e};e();const t=p((()=>[this.layer,this.layer?.loaded,this.formTemplate]),(([e,t])=>{a(e)&&(t?this._updateInputFields():e.load().catch((()=>i.getLogger(this.declaredClass).error("Failed to load layer",e.loadError))))}),{equals:([e,t,s],[n,i,o])=>e===n&&t===i&&s===o,initial:!0}),s=p((()=>this._arcadeContextInfo),(e=>{a(this._expressionsManager)&&(this._expressionsManager.arcadeContextInfo=e)})),n=p((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([x(e),t,s,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache)}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:s,spatialReference:n,view:i}=this;return{layer:g(s)?s:null,originalFeature:e,editType:t,spatialReference:n,map:i?.map}}get updating(){return this.updatingHandles.updating}get allInputFields(){return L(this.inputFields)}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():V.clone(),this._initialFeature=this._featureClone.clone(),this._resetInputFieldValues(this._featureClone),this.contingencyConstraintViolations.clear(),a(this._expressionsManager)&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(r(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:s}=this,n=!!s?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:s,strict:n}=this,i=this.findField(e);t=""===t?null:t,i&&s.getAttribute(e)!==t&&(i.value=t,n&&!i.valid||(this._afterValueChange(i),a(this._expressionsManager)&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),s=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),s.push(i));this.emit("submit",{valid:[...t],invalid:s,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:s}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(s))return[];const{invalid:i,incomplete:o}=s.validateContingencyConstraints(e),a=[...i,...t?.includeIncompleteViolations?o:[]];for(const r of a)for(const e of r.fieldGroup.fields)n.set(e,r);return a}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:s}=this;s.geometry=t.geometry,a(e)&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:s}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:s,valid:t})}_updateInputFields(){const{_featureClone:e,_initialFeature:t,arcadeEditType:s,formTemplate:n,inputFields:i,messages:o,layer:r}=this,l={arcadeEditType:s,feature:e,initialFeature:t,layer:r,messages:o},u=i.slice(),p=a(n)&&n.elements.length>0?this._updateInputFieldsFromElements(u,n.elements,l):this._updateInputFieldsFromLayerFields(u,r?.fields,l);this.inputFields=p}_updateInputFieldsFromElements(e,t,s){const n=new Map;for(const a of e)if(y(a)){N(n,a.groupElement,a);for(const e of a.inputFields)N(n,e.fieldElement,e)}else N(n,a.fieldElement,a);const i=new Map,o=this._updateInputFieldsRecursive({existingInputFieldsByElement:n,updatedElements:t.filter(this._isSupportedElement),sharedInitializationProperties:s,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=L(o);return this._createExpressionsManager(e,t),l(this._expressionsManager).evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[a,r]of n.entries())n.delete(a),r.destroy();return o}_updateInputFieldsRecursive(e){const{existingInputFieldsByElement:t,updatedElements:s,sharedInitializationProperties:n,group:i,newExpressionExecutorPromises:o}=e,a=[];for(const r of s){const e=t.has(r),s=e?t.get(r):S(r)?this._makeInputFieldGroupFromGroupElement(r,n):this._makeInputFieldFromFieldElement(r,n,i);if(a.push(s),e)if(t.delete(r),y(s)){const{feature:e}=n;s.set({feature:e})}else s.set(n);else this._assignExpressionExecutors(s,r,o);if(S(r)){const e=r.elements.filter((e=>this._isSupportedElement(e)));s.inputFields=this._updateInputFieldsRecursive({existingInputFieldsByElement:t,updatedElements:e,sharedInitializationProperties:n,group:s,newExpressionExecutorPromises:o})}}return a}_updateInputFieldsFromLayerFields(e,t,s){if(!Array.isArray(t))return i.getLogger(this.declaredClass).warn(this.declaredClass,"No attribute fields found."),[];const n=new Map;for(const i of e)if(y(i)){for(const e of i.inputFields)e.destroy();i.inputFields.length=0,i.destroy()}else a(i.fieldElement)?i.destroy():n.set(i.field,i);const o=[],{arcadeEditType:r,feature:l,initialFeature:u,layer:p,messages:d}=s;for(const i of t){const e=n.get(i)??new v({arcadeEditType:r,field:i,feature:l,initialFeature:u,layer:p,messages:d,value:l.getAttribute(i.name)??null});o.push(e),n.delete(i)}for(const[i,a]of n.entries())n.delete(i),a.destroy();return o}_resetInputFieldValues(e){for(const t of this.allInputFields)t.value=e.getAttribute(t.name)}_makeInputFieldFromFieldElement(e,t,s=null){const{arcadeEditType:n,feature:i,initialFeature:o,layer:a,messages:r}=t;return new v({arcadeEditType:n,fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),value:i.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:a,group:s,messages:r})}_makeInputFieldGroupFromGroupElement(e,t){const{feature:s,initialFeature:n}=t;return new E({groupElement:e,inputFields:[],feature:s,initialFeature:n})}_assignExpressionExecutors(e,t,s){const n=S(t)?j:b,i=[];for(const o of n){const n=t[o],{_expressionExecutorLookup:i}=this;if(a(n)&&""!==n){const t=`${o}Executor`,a=this._expressionLookup.get(n)??this._addToExpressionLookup(n);if(i.has(a))e[t]=i.get(a);else if(s.has(a)){const n=s.get(a).then((s=>(e[t]=s,s)));s.set(a,n)}else{const n=F(a,this.layer).then((s=>(e[t]=s,i.set(a,s),s)));s.set(a,n)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:s,_featureClone:n}=this;this._expressionsManager=new C({executors:e,feature:n,arcadeContextInfo:s,inputFields:t})}_afterValueChange(e){const{name:t,value:s}=e,{_featureClone:n}=this,i=n.getAttribute(t);n.setAttribute(t,s);const{typeFieldName:o,types:a}=_(this.layer);if(t===o&&s!==i){if("subtype-sublayer"===this.layer.type){const e=this.layer.parent?.findSublayerForFeature(n);n.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of a)if(t.domains&&"object"==typeof t.domains)for(const s of Object.keys(t.domains))e.add(s);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allInputFields)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:s}=this,n=(a(s)&&a(s.expressionInfos)?Object.values(s.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(i.getLogger(this.declaredClass).warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(r(e))return[];const{typeFieldName:t}=_(this.layer),s=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const n of e)n.isRetired||a(n.subtype)&&n.subtype.code!==s||o.push({values:n.values});o.length>0&&n.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(n);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,s=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,a=[i.name,o.name].sort().join("|");if(n.has(a))continue;s.push([i,o]),n.add(a),t.set(e,o)}else t.set(e,l);const i=new Set(s.flat()),o=new Set(e);for(const l of i)o.delete(l);const a=new Map,r=new Map;for(const l of new Set(s.flat())){const e=Symbol(l.name);a.set(e,new Set([l])),r.set(l,e)}for(const[l,u]of s){const e=r.get(l),t=r.get(u);if(e===t)continue;const s=a.get(e),n=a.get(t);for(const i of n)s.add(i),r.set(i,e);a.delete(t)}return[[...a.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),s=t.shift();let n=t.shift(),i=this._generateJoinKey(s.fields,n.fields),o=new Set([...s.fields,...n.fields]),l=new Map;for(const a of s.contingencies){const[e]=this._hashContingency(a,i.codedValueFields,!0);l.has(e)?l.get(e).push(a):l.set(e,[a])}for(;t.length>0;){const e=new Map,s=t.shift(),a=this._generateJoinKey(o,s.fields);for(const t of n.contingencies){const[s,n]=this._hashContingency(t,i.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(l,s):l.get(s);if(l.has(A)&&o.push(...this._findMatchingContingenciesContainingAny(t,l.get(A),i.codedValueFields)),!r(o))for(const l of o){const s=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(l,t,i.rangeFields):this._joinContingencies(l,t);if(r(s))break;const[n]=this._hashContingency(s,a.codedValueFields,!0);e.has(n)?e.get(n).push(s):e.set(n,[s])}}l=e,n=s,i=a,o=new Set([...o,...n.fields])}const u=[];for(const p of n.contingencies){const[e,t]=this._hashContingency(p,i.codedValueFields),s=t?this._findMatchingContingenciesWithAnyHashMask(l,e):l.get(e);if(l.has(A)&&s.push(...this._findMatchingContingenciesContainingAny(p,l.get(A),i.codedValueFields)),!r(s))for(const n of s){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,p,i.rangeFields):this._joinContingencies(n,p);a(e)&&u.push(e)}}return u}_joinContingencies(e,t){const s={values:{...e.values,...t.values}};for(const[n,i]of Object.entries(s.values))"any"===i.objectType&&a(e.values[n])&&(s.values[n]=e.values[n]);return s}_joinContingenciesWithRangeDomains(e,t,s){const n=this._joinContingencies(e,t);for(const i of s){const s=e.values[i],o=t.values[i],{leftIsNull:a,rightIsNull:r,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(s.objectType,o.objectType);if(l||d)continue;if(a&&p||r&&u){n.values[i]=new h({objectType:"null"});continue}if(a&&f||r&&c)return null;u?(s.minValue=-1/0,s.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const g=Math.max(s.minValue,o.minValue),m=Math.min(s.maxValue,o.maxValue);if(g>m)return null;n.values[i]=new h({objectType:"range",minValue:g,maxValue:m})}return n}_findMatchingContingenciesContainingAny(e,t,s){return t.filter((t=>s.every((s=>{const n=t.values[s],i=e.values[s];return"any"===n.objectType||"any"===i.objectType||n.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const s=RegExp(`${t}$`),n=[];for(const[i,o]of e){if(i===A)break;s.test(i)&&n.push(...o)}return n}_generateJoinKey(e,t){const s=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,i=s.size<n.size?s:n,o=i===s?n:s,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_hashContingency(e,t,s=!1){if(t.length<1)return[w,!1];const n=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(s)return[A,!0];i=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${M}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([d()],T.prototype,"_featureClone",void 0),e([d()],T.prototype,"_arcadeContextInfo",null),e([d()],T.prototype,"updating",null),e([d({readOnly:!0})],T.prototype,"allInputFields",null),e([d()],T.prototype,"_layerFieldsByName",null),e([d()],T.prototype,"arcadeEditType",void 0),e([d()],T.prototype,"contingencyConstraintViolations",void 0),e([d()],T.prototype,"feature",null),e([d()],T.prototype,"fieldsWithContingentValues",null),e([d({type:f})],T.prototype,"formTemplate",null),e([d()],T.prototype,"inputFields",void 0),e([d()],T.prototype,"joinedContingentValues",null),e([d()],T.prototype,"layer",null),e([d()],T.prototype,"messages",void 0),e([d()],T.prototype,"spatialReference",null),e([d()],T.prototype,"state",null),e([d()],T.prototype,"strict",void 0),e([d()],T.prototype,"submittable",null),e([d()],T.prototype,"valid",null),e([d()],T.prototype,"view",void 0),e([d()],T.prototype,"getValues",null),e([d()],T.prototype,"submit",null),T=e([c("esri.widgets.FeatureForm.FeatureFormViewModel")],T);const S=e=>"group"===e.type,L=e=>e.reduce(((e,t)=>y(t)?[...e,...t.inputFields]:[...e,t]),[]),N=(e,t,s)=>{a(t)&&e.set(t,s)},k=T;export{k as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isSome as r}from"../../core/maybe.js";import{isAbortError as o,createResolver as a}from"../../core/promiseUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const c="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let p=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:o,spatialReference:a}=this.arcadeContextInfo,i="feature"===t?.type?t:"scene"===t?.type&&r(t.associatedLayer)?t.associatedLayer:void 0;return[{$originalfeature:o,$editcontext:{editType:e},$layer:i,$featureset:i,$datastore:t?.url,$map:s},{spatialReference:a}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(c))return this._evaluate([...this._fieldReferencesLookup.get(c)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:o}=this,a=new Map(this.inputFields.map((e=>[e.name,e]))),i=new Map(o.map((e=>[e,new Array])));for(const n of o){for(const o of n.fieldsUsed){s(e,o,(()=>new Set)).add(n);const c=a.get(o),{valueExpressionExecutor:l,editableExpressionExecutor:p}=c;if(r(l)){i.get(l).push(n);s(t,l,(()=>new Set)).add(c)}if(r(p)){i.get(p).push(n);s(t,p,(()=>new Set)).add(c)}}if(n.geometryUsed){s(e,c,(()=>new Set)).add(n)}}return i}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:r,_latestFieldValues:a}=this;for(const o of e)u(o,t,s);for(const[n,{resolver:c,dependencyPromises:l}]of t){Promise.all(l).then((async()=>{const[e,t]=this._makeContext(a);return n.executeAsync(e,t)})).then((()=>{if(r.has(n))for(const e of r.get(n))this._latestFieldValues[e.name]=e.value;c.resolve()}),(e=>{!e||o(e)||f(e)||n.markStale(),c.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(o(e.reason)||f(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([i()],p.prototype,"_baseContext",null),e([i()],p.prototype,"feature",null),e([i()],p.prototype,"executors",void 0),e([i()],p.prototype,"inputFields",void 0),e([i()],p.prototype,"arcadeContextInfo",void 0),p=e([n(l)],p);const u=(e,t,s)=>{if(t.has(e))return;const r=a();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const o=s.get(e);for(const a of o)u(a,t,s),t.get(a).dependencyPromises.push(r.promise)},f=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{p as FormExpressionsManager};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isSome as r}from"../../core/maybe.js";import{isAbortError as o,createResolver as a}from"../../core/promiseUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const c="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let p=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:o,spatialReference:a}=this.arcadeContextInfo,i="feature"===t?.type?t:"scene"===t?.type&&r(t.associatedLayer)?t.associatedLayer:void 0;return[{$originalfeature:o,$editcontext:{editType:e},$layer:i,$featureset:i,$datastore:t?.url,$map:s},{spatialReference:a}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(c))return this._evaluate([...this._fieldReferencesLookup.get(c)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:o}=this,a=new Map(this.inputFields.map((e=>[e.name,e]))),i=new Map(o.map((e=>[e,new Array])));for(const n of o){for(const o of n.fieldsUsed){s(e,o,(()=>new Set)).add(n);const c=a.get(o),{valueExpressionExecutor:l,editableExpressionExecutor:p}=c;if(r(l)&&l!==n){i.get(l).push(n);s(t,l,(()=>new Set)).add(c)}if(r(p)&&p!==n){i.get(p).push(n);s(t,p,(()=>new Set)).add(c)}}if(n.geometryUsed){s(e,c,(()=>new Set)).add(n)}}return i}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:r,_latestFieldValues:a}=this;for(const o of e)u(o,t,s);for(const[n,{resolver:c,dependencyPromises:l}]of t){Promise.all(l).then((async()=>{const[e,t]=this._makeContext(a);return n.executeAsync(e,t)})).then((()=>{if(r.has(n))for(const e of r.get(n))this._latestFieldValues[e.name]=e.value;c.resolve()}),(e=>{!e||o(e)||f(e)||n.markStale(),c.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(o(e.reason)||f(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([i()],p.prototype,"_baseContext",null),e([i()],p.prototype,"feature",null),e([i()],p.prototype,"executors",void 0),e([i()],p.prototype,"inputFields",void 0),e([i()],p.prototype,"arcadeContextInfo",void 0),p=e([n(l)],p);const u=(e,t,s)=>{if(t.has(e))return;const r=a();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const o=s.get(e);for(const a of o)u(a,t,s),t.get(a).dependencyPromises.push(r.promise)},f=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{p as FormExpressionsManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as r,unwrap as s,isNone as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as r,unwrap as s,isNone as o,get as l}from"../../core/maybe.js";import{generateUID as n}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as p}from"../../layers/support/CodedValue.js";import"../../core/has.js";import d from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as m,DomainValidationError as y,getDomainRange as h}from"../../layers/support/domainUtils.js";import{isNumericField as c,isStringField as E,isDateField as f,TypeValidationError as g,validateFieldValue as v,getFeatureEditFields as x,getFeatureGeometryFields as b,NumericRangeValidationError as _,getFieldRange as V}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as T}from"../../layers/support/layerUtils.js";import{getNormalizedFeatureTypeInfo as O,isFieldElementWithInputType as j}from"./featureFormUtils.js";import{substitute as D}from"../../intl/substitute.js";var A,F;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(A||(A={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const N={type:"number"},U={type:"number",intlOptions:{notation:"scientific"}},L={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}},q="__internal-type-based-coded-value-domain__";function w(e){return e>=1e7||e<=-1e7}let I=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcadeEditType="NA",this.editableExpressionExecutor=null,this.id=n().toString(),this.requiredExpressionExecutor=null,this.valueExpressionExecutor=null,this.visibilityExpressionExecutor=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.error=null,this.group=null,this.messages=null}get _configAllowsEdits(){const{fieldElement:e,layer:t,name:i}=this;if(r(e))return e.editableExpression?this.evaluatedEditableExpression:!1!==e.editable;if(t.userHasUpdateItemPrivileges)return!0;return("popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null)?.isEditable??!0}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;if(!t||!e)return!1;const i=T(t),r=i?.operations.supportsEditing,s=e.editable,o=R(i,this.arcadeEditType);return!!(r&&s&&o)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableExpressionExecutor:e}=this;return r(e)?!!e.lastEvaluatedValue:null}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return r(e)?!!e.lastEvaluatedValue:null}get evaluatedVisibilityExpression(){const{visibilityExpressionExecutor:e}=this;return r(e)?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return r(e)?e.lastEvaluatedValue:null}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get description(){return s(this.fieldElement)?.description}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=O(e);if(t===this.name&&o(this.field.domain))return new d({name:q,codedValues:i.map((({code:e,name:t})=>new p({code:e,name:t})))});const{feature:s}=this,n=e.getFieldDomain(this.name,{feature:s}),a=l(this.fieldElement,"domain");return r(a)&&this._isDomainCompatible(a)?a:n}get editable(){return!!this._layerFieldAllowsEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get inputType(){return s(this.fieldElement)?.input?.type}get errorMessage(){return this._toErrorMessage()}get hint(){return s(this.fieldElement)?.hint}get includeTime(){const{fieldElement:e}=this,t=r(e)&&"datetime-picker"===e.input?.type?e.input.includeTime:void 0;return void 0===t||t}get label(){return r(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===A.Date)return e;const{field:t,fieldElement:i}=this,r=t?.length,s=S(i)?i.input.maxLength:NaN;return!isNaN(s)&&s>=e&&(r===e||s<=r)?s:r}get minLength(){const e=-1;if(this.type===A.Date)return e;const{field:t,fieldElement:i}=this,r=t?.length,s=S(i)?i.input.minLength:NaN;return!isNaN(s)&&s>=e&&(r===e||s<=r)?s:e}get name(){return this.field?.name}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:s}=this;return!!e&&(!1===i?.nullable||!(!s||!r(t))&&t)}set required(e){this._overrideIfSome("required",e)}get submittable(){const{field:e,required:t,valid:i,value:r}=this;return(!t||!o(r))&&(!!i||this.initialFeature.getAttribute(e.name)===r)}get type(){const{field:e}=this;return c(e)?A.Number:E(e)?A.Text:f(e)?A.Date:A.Unsupported}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t}=this;return r(t)&&t.updating||r(e)&&e.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._shouldUseValueExpression()){const e=this.evaluatedValueExpression;if(this.type===A.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return r(e)&&"object"==typeof e?e.toString():e}return this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(r(this.evaluatedVisibilityExpression)?this.evaluatedVisibilityExpression:!!r(this.fieldElement)||this._isVisibleByDefault())}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&E(t)||"number"===i&&c(t))return!0}return!!("range"===e?.type&&c(t)||f(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:r,required:s,type:o,valid:l,value:n}=this,a=s&&null===n,u=void 0!==l;return!a&&i.getAttribute(t.name)===n&&u?null:a?g.INVALID_TYPE:"text"===o&&r>-1&&"string"==typeof n&&n.length<r?F.TOO_SHORT:e?null!==n||s?m(e,n):null:v(t,n)}_isVisibleByDefault(){const e=this.field?.type;return this.field?.visible&&"oid"!==e&&"global-id"!==e&&!this._isGeometryField()}_isEditorField(){return x(this.layer).includes(this.name)}_isGeometryField(){return b(this.layer).includes(this.name)}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&r(this.valueExpressionExecutor)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:r,value:s,required:o,type:l}=this,n=this.error;if(o&&null===s)return i.validationErrors.cannotBeNull;if(n===y.VALUE_OUT_OF_RANGE||n===_.OUT_OF_RANGE){const r=h(e)||V(t);return D(i.validationErrors.outsideRange,r,{format:{max:"date"===l?L:w(r.max)?U:N,min:"date"===l?L:w(r.min)?U:N}})}return n===y.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:n===g.INVALID_TYPE?i.validationErrors.invalidType:n===F.TOO_SHORT?D(i.validationErrors.tooShort,{min:r}):null}};e([a()],I.prototype,"_storedValue",void 0),e([a()],I.prototype,"_configAllowsEdits",null),e([a()],I.prototype,"_layerFieldAllowsEdits",null),e([a()],I.prototype,"arcadeEditType",void 0),e([a()],I.prototype,"editableExpressionExecutor",void 0),e([a()],I.prototype,"requiredExpressionExecutor",void 0),e([a()],I.prototype,"valueExpressionExecutor",void 0),e([a()],I.prototype,"isUsingValueExpression",null),e([a()],I.prototype,"visibilityExpressionExecutor",void 0),e([a()],I.prototype,"evaluatedEditableExpression",null),e([a()],I.prototype,"evaluatedRequiredExpression",null),e([a()],I.prototype,"evaluatedVisibilityExpression",null),e([a()],I.prototype,"evaluatedValueExpression",null),e([a()],I.prototype,"feature",void 0),e([a()],I.prototype,"field",void 0),e([a({constructOnly:!0})],I.prototype,"fieldElement",void 0),e([a()],I.prototype,"initialFeature",null),e([a()],I.prototype,"layer",void 0),e([a({readOnly:!0})],I.prototype,"description",null),e([a()],I.prototype,"domain",null),e([a()],I.prototype,"editable",null),e([a({readOnly:!0})],I.prototype,"inputType",null),e([a({readOnly:!0})],I.prototype,"error",void 0),e([a({dependsOn:["error","messages","value"]})],I.prototype,"errorMessage",null),e([a()],I.prototype,"group",void 0),e([a({readOnly:!0})],I.prototype,"hint",null),e([a()],I.prototype,"includeTime",null),e([a()],I.prototype,"label",null),e([a()],I.prototype,"maxLength",null),e([a()],I.prototype,"minLength",null),e([a()],I.prototype,"messages",void 0),e([a({readOnly:!0})],I.prototype,"name",null),e([a()],I.prototype,"required",null),e([a()],I.prototype,"submittable",null),e([a()],I.prototype,"type",null),e([a()],I.prototype,"updating",null),e([a()],I.prototype,"valid",null),e([a({value:null})],I.prototype,"value",null),e([a()],I.prototype,"visible",null),I=e([u("esri.widgets.FeatureForm.InputField")],I);const R=(e,t)=>{if(!e)return!0;const{operations:i}=e;switch(t){case"INSERT":return i.supportsAdd;case"UPDATE":case"DELETE":return i.supportsUpdate;default:return!0}},S=e=>r(e)&&(j(e,"text-box")||j(e,"text-area")),C=I;export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Collection.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import r from"../../core/Handles.js";import{isSome as o}from"../../core/maybe.js";import{debounce as l,ignoreAbortErrors as n}from"../../core/promiseUtils.js";import{on as a,watch as h}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import c from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import p from"./Grid/Column.js";import y from"./Grid/Grid.js";import f from"./Grid/GridViewModel.js";import b from"./Grid/GroupColumn.js";import _ from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{fetchMessageBundle as E}from"../../intl/messages.js";let v=class extends(i(f)){constructor(e){super(e),this._debounceRefresh=l((()=>this._refresh())),this._defaultHiddenFields=["CreationDate","Creator","EditDate","Editor","GlobalID"],this._highlights=new r,this.activeFilters=new s,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||null,this.columns=new s,this.dataProvider=async(e,t)=>{const{store:s}=this,{page:i,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(s?(await s.set({orderByFields:l}),"loaded"!==s.state&&"loading"!==s.state&&await s.load(),t&&t(await s.fetchItems({page:i,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.fieldConfigs=null,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.store=null,this.tableTemplate=null,this.view=null;const{hiddenFields:t,itemIdPath:i}=this;t.addMany(this._defaultHiddenFields),this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new _),this._set("grid",new y({itemIdPath:i,viewModel:this}))}initialize(){const e=async()=>{this.messages=await E("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await E("esri/t9n/common"),this.messagesURIUtils=await E("esri/widgets/support/t9n/uriUtils")};e(),this.handles.add([I((()=>{e(),this._generateColumns()})),a((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._unhighlight(e)))}}),h((()=>this.layerView),(()=>{this._highlights.removeAll(),this.layerView&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.highlightEnabled),(()=>{this._highlights.removeAll(),this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),h((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),h((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),h((()=>[this.messages,this.tableTemplate,this.fieldConfigs]),(()=>this.layer?.loaded&&this._generateColumns())),h((()=>this.editingEnabled),(e=>this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})))),h((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),h((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this.handles.removeAll(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))):[]}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")||new s}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new s(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}set layer(e){this._set("layer",e),this.grid?.clearSort(),this._resetColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load()),this.notifyChange("state")}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearHighlights(){this._highlights.removeAll()}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),s=t.filter((e=>!e.error)).map((e=>e.objectId));s.length&&(this.deselectRows(s),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){return this.store.getItemByObjectId(e)?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new s}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new s(e)):this._set("highlightIds",e)}async refresh(){return n(this._debounceRefresh())}reset(){this.grid.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}zoomToSelection(){const{layer:e,view:t}=this,s=this.highlightIds.toArray();if(!e||!t||!s.length)return;const i=e.createQuery();i.objectIds=s,i.returnGeometry=!0,e.queryFeatures(i).then((e=>{t.goTo(e.features).catch((e=>{"AbortError"!==e.name&&console.error(e)}))}))}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,s)=>{t||this.deselectRows(e[s])}))}this.grid.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._resetColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this.fieldConfigs?.length?this._generateColumnsFromConfigs():this._generateDefaultFieldColumns();e.push(...t),this.attachmentsEnabled&&e.push(this._generateDefaultAttachmentColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:s,hiddenFields:i,layer:r,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,tableTemplate:h}=this,d=this.layer?.fields??[];return e.filter((e=>(d||[]).find((t=>"fieldName"in e&&e.fieldName===t.name))||"group"===e.type&&"columnTemplates"in e)).map((e=>{if("fieldName"in e){const m=(d||[]).find((t=>e.fieldName===t.name)),g=!1===e.visible||!0!==e.visible&&i.includes(m.name),{direction:c,formatFunction:p,initialSortPriority:y,menuConfig:f,textAlign:b}=e,_=h.expressionInfos||null;return new u({direction:c,editingEnabled:t,expressionInfos:_,field:m,formatFunction:p,grid:s,hidden:g,initialSortPriority:y,layer:r,messages:o,messagesCommon:l,messagesURIUtils:n,menuConfig:f,store:a,template:e,textAlign:b})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),s=!1===e.visible||!0!==e.visible&&i.includes(e.label),{label:r}=e;return new b({header:r,columns:t,hidden:s})}return new p({...e})}))}_generateColumnsFromConfigs(){const{editingEnabled:e,fieldConfigs:t,grid:s,hiddenFields:i,layer:r,messages:l,messagesCommon:n,messagesURIUtils:a,store:h}=this,d=this.layer?.fields??[];return t.filter((e=>(d||[]).find((t=>e.name===t.name)))).map((t=>{const m=t.direction||null,g=t.formatFunction||null,c=t.textAlign||null,p=o(t.initialSortPriority)?t.initialSortPriority:null,y=(d||[]).find((e=>t.name===e.name)),f=!1===t.visible||!0!==t.visible&&i.includes(y.name),b=t.menuConfig||null;return new u({config:t,direction:m,editingEnabled:e,field:y,formatFunction:g,grid:s,hidden:f,layer:r,store:h,messages:l,messagesCommon:n,messagesURIUtils:a,menuConfig:b,textAlign:c,initialSortPriority:p})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,hiddenFields:s,layer:i,messages:r,messagesCommon:o,messagesURIUtils:l,store:n}=this;return(this.layer?.fields??[]).map((a=>{const h=s.includes(a.name);return new u({editingEnabled:e,field:a,grid:t,hidden:h,layer:i,store:n,messages:r,messagesCommon:o,messagesURIUtils:l})}))}_generateDefaultAttachmentColumn(){return new c({header:this.messages?.attachments})}_sortOrdersToLayerOrderByFields(e){return e&&e.length?e.filter(((e,t,s)=>s.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e.toUpperCase())):[]}_highlight(e){this.layerView&&g(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_unhighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const s=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let i=e instanceof t?e:null;const r=i?i.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!i){const e=this.store.getItemByObjectId(r);e&&(i=e.feature)}s.push({objectId:r,feature:i})}})),s}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:s,removed:i}=e;t&&(s.forEach((e=>this._highlight(e))),i.forEach((e=>this._unhighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([d({readOnly:!0})],v.prototype,"activeFilters",void 0),e([d({readOnly:!0})],v.prototype,"activeSortOrders",null),e([d()],v.prototype,"attachmentsEnabled",null),e([d()],v.prototype,"autoRefreshEnabled",void 0),e([d()],v.prototype,"cellClassNameGenerator",void 0),e([d({readOnly:!0})],v.prototype,"columns",void 0),e([d()],v.prototype,"dataProvider",void 0),e([d()],v.prototype,"editingEnabled",void 0),e([d()],v.prototype,"fieldConfigs",void 0),e([d()],v.prototype,"filterGeometry",null),e([d({readOnly:!0})],v.prototype,"grid",void 0),e([d()],v.prototype,"hiddenFields",null),e([d()],v.prototype,"highlightEnabled",void 0),e([d()],v.prototype,"highlightOnRowSelectEnabled",null),e([d({readOnly:!0})],v.prototype,"itemIdPath",void 0),e([d()],v.prototype,"layer",null),e([d()],v.prototype,"layerView",null),e([d()],v.prototype,"messages",null),e([d(),w("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([d(),w("esri/widgets/support/t9n/uriUtils")],v.prototype,"messagesURIUtils",void 0),e([d()],v.prototype,"relatedRecordsEnabled",void 0),e([d({readOnly:!0})],v.prototype,"state",null),e([d({readOnly:!0,type:_})],v.prototype,"store",void 0),e([d()],v.prototype,"tableTemplate",void 0),e([d()],v.prototype,"timeExtent",null),e([d()],v.prototype,"view",void 0),e([d()],v.prototype,"highlightIds",null),v=e([m("esri.widgets.FeatureTable.FeatureTableViewModel")],v);const C=v;export{C as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Collection.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import r from"../../core/Handles.js";import{isSome as o}from"../../core/maybe.js";import{debounce as l,ignoreAbortErrors as n}from"../../core/promiseUtils.js";import{on as a,watch as h}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import c from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import p from"./Grid/Column.js";import y from"./Grid/Grid.js";import f from"./Grid/GridViewModel.js";import b from"./Grid/GroupColumn.js";import _ from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{fetchMessageBundle as C}from"../../intl/messages.js";let E=class extends(i(f)){constructor(e){super(e),this._debounceRefresh=l((()=>this._refresh())),this._defaultHiddenFields=["CreationDate","Creator","EditDate","Editor","GlobalID"],this._highlights=new r,this.activeFilters=new s,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||null,this.columns=new s,this.dataProvider=async(e,t)=>{const{store:s}=this,{page:i,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(s?(await s.set({orderByFields:l}),"loaded"!==s.state&&"loading"!==s.state&&await s.load(),t&&t(await s.fetchItems({page:i,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.fieldConfigs=null,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.store=null,this.tableTemplate=null,this.view=null;const{hiddenFields:t,itemIdPath:i}=this;t.addMany(this._defaultHiddenFields),this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new _),this._set("grid",new y({itemIdPath:i,viewModel:this}))}initialize(){const e=async()=>{this.messages=await C("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await C("esri/t9n/common"),this.messagesURIUtils=await C("esri/widgets/support/t9n/uriUtils")};e(),this.handles.add([I((()=>{e(),this._generateColumns()})),a((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._unhighlight(e)))}}),h((()=>this.layerView),(()=>{this._highlights.removeAll(),this.layerView&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.highlightEnabled),(()=>{this._highlights.removeAll(),this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),h((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),h((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),h((()=>[this.messages,this.tableTemplate,this.fieldConfigs]),(()=>this.layer?.loaded&&this._generateColumns())),h((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),h((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),h((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this.handles.removeAll(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))):[]}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")||new s}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new s(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}set layer(e){this._set("layer",e),this.grid?.clearSort(),this._resetColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load()),this.notifyChange("state")}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearHighlights(){this._highlights.removeAll()}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),s=t.filter((e=>!e.error)).map((e=>e.objectId));s.length&&(this.deselectRows(s),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){return this.store.getItemByObjectId(e)?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new s}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new s(e)):this._set("highlightIds",e)}async refresh(){return n(this._debounceRefresh())}reset(){this.grid.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}zoomToSelection(){const{layer:e,view:t}=this,s=this.highlightIds.toArray();if(!e||!t||!s.length)return;const i=e.createQuery();i.objectIds=s,i.returnGeometry=!0,e.queryFeatures(i).then((e=>{t.goTo(e.features).catch((e=>{"AbortError"!==e.name&&console.error(e)}))}))}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,s)=>{t||this.deselectRows(e[s])}))}this.grid.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._resetColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this.fieldConfigs?.length?this._generateColumnsFromConfigs():this._generateDefaultFieldColumns();e.push(...t),this.attachmentsEnabled&&e.push(this._generateDefaultAttachmentColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:s,hiddenFields:i,layer:r,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,tableTemplate:h}=this,d=this.layer?.fields??[];return e.filter((e=>(d||[]).find((t=>"fieldName"in e&&e.fieldName===t.name))||"group"===e.type&&"columnTemplates"in e)).map((e=>{if("fieldName"in e){const m=(d||[]).find((t=>e.fieldName===t.name)),g=!1===e.visible||!0!==e.visible&&i.includes(m.name),{direction:c,formatFunction:p,initialSortPriority:y,menuConfig:f,textAlign:b}=e,_=h.expressionInfos||null;return new u({direction:c,editingEnabled:t,expressionInfos:_,field:m,formatFunction:p,grid:s,hidden:g,initialSortPriority:y,layer:r,messages:o,messagesCommon:l,messagesURIUtils:n,menuConfig:f,store:a,template:e,textAlign:b})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),s=!1===e.visible||!0!==e.visible&&i.includes(e.label),{label:r}=e;return new b({header:r,columns:t,hidden:s})}return new p({...e})}))}_generateColumnsFromConfigs(){const{editingEnabled:e,fieldConfigs:t,grid:s,hiddenFields:i,layer:r,messages:l,messagesCommon:n,messagesURIUtils:a,store:h}=this,d=this.layer?.fields??[];return t.filter((e=>(d||[]).find((t=>e.name===t.name)))).map((t=>{const m=t.direction||null,g=t.formatFunction||null,c=t.textAlign||null,p=o(t.initialSortPriority)?t.initialSortPriority:null,y=(d||[]).find((e=>t.name===e.name)),f=!1===t.visible||!0!==t.visible&&i.includes(y.name),b=t.menuConfig||null;return new u({config:t,direction:m,editingEnabled:e,field:y,formatFunction:g,grid:s,hidden:f,layer:r,store:h,messages:l,messagesCommon:n,messagesURIUtils:a,menuConfig:b,textAlign:c,initialSortPriority:p})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,hiddenFields:s,layer:i,messages:r,messagesCommon:o,messagesURIUtils:l,store:n}=this;return(this.layer?.fields??[]).map((a=>{const h=s.includes(a.name);return new u({editingEnabled:e,field:a,grid:t,hidden:h,layer:i,store:n,messages:r,messagesCommon:o,messagesURIUtils:l})}))}_generateDefaultAttachmentColumn(){return new c({header:this.messages?.attachments})}_sortOrdersToLayerOrderByFields(e){return e&&e.length?e.filter(((e,t,s)=>s.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e.toUpperCase())):[]}_highlight(e){this.layerView&&g(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_unhighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const s=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let i=e instanceof t?e:null;const r=i?i.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!i){const e=this.store.getItemByObjectId(r);e&&(i=e.feature)}s.push({objectId:r,feature:i})}})),s}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:s,removed:i}=e;t&&(s.forEach((e=>this._highlight(e))),i.forEach((e=>this._unhighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([d({readOnly:!0})],E.prototype,"activeFilters",void 0),e([d({readOnly:!0})],E.prototype,"activeSortOrders",null),e([d()],E.prototype,"attachmentsEnabled",null),e([d()],E.prototype,"autoRefreshEnabled",void 0),e([d()],E.prototype,"cellClassNameGenerator",void 0),e([d({readOnly:!0})],E.prototype,"columns",void 0),e([d()],E.prototype,"dataProvider",void 0),e([d()],E.prototype,"editingEnabled",void 0),e([d()],E.prototype,"fieldConfigs",void 0),e([d()],E.prototype,"filterGeometry",null),e([d({readOnly:!0})],E.prototype,"grid",void 0),e([d()],E.prototype,"hiddenFields",null),e([d()],E.prototype,"highlightEnabled",void 0),e([d()],E.prototype,"highlightOnRowSelectEnabled",null),e([d({readOnly:!0})],E.prototype,"itemIdPath",void 0),e([d()],E.prototype,"layer",null),e([d()],E.prototype,"layerView",null),e([d()],E.prototype,"messages",null),e([d(),w("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([d(),w("esri/widgets/support/t9n/uriUtils")],E.prototype,"messagesURIUtils",void 0),e([d()],E.prototype,"relatedRecordsEnabled",void 0),e([d({readOnly:!0})],E.prototype,"state",null),e([d({readOnly:!0,type:_})],E.prototype,"store",void 0),e([d()],E.prototype,"tableTemplate",void 0),e([d()],E.prototype,"timeExtent",null),e([d()],E.prototype,"view",void 0),e([d()],E.prototype,"highlightIds",null),E=e([m("esri.widgets.FeatureTable.FeatureTableViewModel")],E);const v=E;export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/maybe.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as a,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as l,formatNumber as s}from"../../intl/number.js";import u from"../../layers/support/CodedValueDomain.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import c from"../FeatureForm/InputField.js";import m from"./Grid/EditorColumn.js";import h from"../support/DatePicker.js";import f from"../support/TimePicker.js";import{renderingSanitizer as g}from"../support/widgetUtils.js";const y={cancelEdit:"Escape"},v="esri-field-column",b={headerContent:`${v}__header-content`,headerLabel:`${v}__header-label`,input:`${v}__cell-input`,inputContainer:`${v}__cell__input-container`,dateInputContainer:`${v}__cell__date-input-container`,dateInputWrapper:`${v}__cell__date-input-wrapper`,button:`${v}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},_=r("short-date-short-time"),F=r("short-date"),C={useGrouping:!0,maximumFractionDigits:20};let E=class extends m{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:g.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,{item:{feature:o}}=e,r=this._getDomainForFeature(o);if(r)return this._getComputedDomain(t,r);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?a(t,{...e,...n}):null}if(d(i)){const e=n?.format?l(n.format):C;return s(parseFloat(t),e)}return g.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>!(this._inputField&&!this._inputField.valid)&&(!(this.required&&(!t(n)||""===n))&&e!==n),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:a}=this;if(this.removeCellContent(t),t.classList.add(b.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),a)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(b.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const a=this.createInputContainer();a.appendChild(o),this.removeCellContent(e),e.appendChild(a),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField,n=e.value,{required:i,type:o}=t;return i||""!==n?"number"===o||"date"===o?parseFloat(n):"text"===o?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e.item.feature.attributes[t.path]=n},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,template:i}=this;return t?!1!==i?.editable&&(!1!==e?.editable&&n?.editable):i?i.editable:!!e&&(!0===e.editable&&n?.editable)}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,a=n?.required;return this.editable&&(!i||!0===o||!0===a)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const{item:n}=e;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:a,required:r}=this,{domain:l}=this._inputField;let s=null;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),a>0&&(s.minLength=a)),s.classList.add(b.input),s.value=t,s.required=r;let u=!1;s.onkeydown=e=>{u=e.key===y.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(b.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(b.locked),e}getCellValue({path:e},{item:t}){return t?.feature?.attributes?.[e]??null}_renderDateEditors(e,t,i){const{config:o,messagesCommon:a,template:r}=this,l=e?new Date(e):new Date(Date.now()),s=new h({dateInputEnabled:!0,value:l}),u=new f({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};n((()=>[s.value,u.value]),(()=>p()));const g=document.createElement("div"),y=document.createElement("div");s.container=g,u.container=y;const v=document.createElement("button");v.classList.add(b.button,b.saveIcon),v.onclick=()=>c(),v.title=a?.save;const _=document.createElement("button");_.classList.add(b.button,b.trashIcon),_.onclick=()=>m(),_.title=a?.clear;const F=document.createElement("div");F.classList.add(b.dateInputWrapper),F.appendChild(g),(r&&r.input&&"datetime-picker"===r.input.type&&!1!==r.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(y);const C=document.createElement("div");C.classList.add(b.dateInputContainer),C.appendChild(F),C.appendChild(v),C.appendChild(_),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(t),t.appendChild(C),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const a=document.createElement("select");return o.forEach((e=>a.add(e))),a.value=e,a}_setUpInputField(e,t){const{config:n,field:i,layer:o}=this,a=new c({config:n,feature:e,initialFeature:e.clone(),field:i,layer:o,group:null,messages:null});return a.set("value",t),a}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:a}=n,r=a===i,l=this.field.domain;if(r&&!l)return new u({name:"__internal-type-based-coded-value-domain__",codedValues:n.types.map((({id:e,name:t})=>({code:e,name:t})))});const s=a&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:s}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?F:_}};e([i({readOnly:!0})],E.prototype,"alias",null),e([i()],E.prototype,"cellValueFormatFunction",void 0),e([i()],E.prototype,"cellValueValidatorFunction",void 0),e([i()],E.prototype,"config",void 0),e([i({readOnly:!0})],E.prototype,"defaultValue",null),e([i({readOnly:!0})],E.prototype,"description",null),e([i({readOnly:!0})],E.prototype,"editable",null),e([i()],E.prototype,"editingEnabled",void 0),e([i()],E.prototype,"expressionInfos",void 0),e([i()],E.prototype,"field",void 0),e([i()],E.prototype,"formatFunction",void 0),e([i({readOnly:!0})],E.prototype,"header",null),e([i()],E.prototype,"hidden",null),e([i()],E.prototype,"headerRenderFunction",void 0),e([i()],E.prototype,"inputRenderFunction",void 0),e([i()],E.prototype,"layer",void 0),e([i({readOnly:!0})],E.prototype,"loadingMessage",null),e([i()],E.prototype,"maxLength",null),e([i()],E.prototype,"minLength",null),e([i({readOnly:!0})],E.prototype,"name",null),e([i({readOnly:!0})],E.prototype,"nullable",null),e([i()],E.prototype,"parseInputValueFunction",void 0),e([i({readOnly:!0})],E.prototype,"path",null),e([i({readOnly:!0})],E.prototype,"required",null),e([i()],E.prototype,"sortable",null),e([i()],E.prototype,"store",void 0),e([i()],E.prototype,"template",void 0),e([i()],E.prototype,"updateRowItemFunction",void 0),e([i()],E.prototype,"updateStoreItemFunction",void 0),E=e([o("esri.widgets.FeatureTable.FieldColumn")],E);const I=E;export{I as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t,isNone as n}from"../../core/maybe.js";import{watch as i}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as a,convertDateFormatToIntlOptions as l}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as s,formatNumber as u}from"../../intl/number.js";import d from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as p}from"../../layers/support/editableLayers.js";import{isNumericField as c,isStringField as m}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as h}from"../../layers/support/layerUtils.js";import f from"../FeatureForm/InputField.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const _={cancelEdit:"Escape"},F="esri-field-column",C={headerContent:`${F}__header-content`,headerLabel:`${F}__header-label`,input:`${F}__cell-input`,inputContainer:`${F}__cell__input-container`,dateInputContainer:`${F}__cell__date-input-container`,dateInputWrapper:`${F}__cell__date-input-wrapper`,button:`${F}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=l("short-date-short-time"),I=l("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,{item:{feature:o}}=e,r=this._getDomainForFeature(o);if(r)return this._getComputedDomain(t,r);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?a(t,{...e,...n}):null}if(c(i)){const e=n?.format?s(n.format):L;return u(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>!(this._inputField&&!this._inputField.valid)&&(!(this.required&&(!t(n)||""===n))&&e!==n),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField,n=e.value,{required:i,type:o}=t;return i||""!==n?"number"===o||"date"===o?parseFloat(n):"text"===o?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e.item.feature.attributes[t.path]=n},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:i,layer:o,template:r}=this;if(n(i)||n(o))return!1;const a=p(o),l=h(o)?.operations.supportsUpdate;return!!(i.editable&&a&&l)&&(t?!(!1===r?.editable||!1===e?.editable):!(!r?.editable&&!e?.editable))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const{item:n}=e;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s=null;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,d()}):(s=document.createElement("input"),s.type=c(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===_.cancelEdit},s.onblur=()=>{s.onblur=null,d()};const d=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},{item:t}){return t?.feature?.attributes?.[e]??null}_renderDateEditors(e,t,n){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});n.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);n.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{n.value=null,this.submit()};i((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const _=document.createElement("div");_.classList.add(C.dateInputWrapper),_.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&_.appendChild(f);const F=document.createElement("div");F.classList.add(C.dateInputContainer),F.appendChild(_),F.appendChild(g),F.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(t),t.appendChild(F),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{config:n,field:i,layer:o}=this,r=new f({config:n,feature:e,initialFeature:e.clone(),field:i,layer:o,group:null,messages:null});return r.set("value",t),r}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&m(t)||"number"===n&&c(t))return!0}return!(!e||"range"!==e.type||!c(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new d({name:"__internal-type-based-coded-value-domain__",codedValues:n.types.map((({id:e,name:t})=>({code:e,name:t})))});const s=r&&n.getFieldDomain(i,{feature:e})||l,u=t?.domain;return this._isDomainCompatible(u)?u:s}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?l(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([o({readOnly:!0})],D.prototype,"alias",null),e([o()],D.prototype,"cellValueFormatFunction",void 0),e([o()],D.prototype,"cellValueValidatorFunction",void 0),e([o()],D.prototype,"config",void 0),e([o({readOnly:!0})],D.prototype,"defaultValue",null),e([o({readOnly:!0})],D.prototype,"description",null),e([o({readOnly:!0})],D.prototype,"editable",null),e([o()],D.prototype,"editingEnabled",void 0),e([o()],D.prototype,"expressionInfos",void 0),e([o()],D.prototype,"field",void 0),e([o()],D.prototype,"formatFunction",void 0),e([o({readOnly:!0})],D.prototype,"header",null),e([o()],D.prototype,"hidden",null),e([o()],D.prototype,"headerRenderFunction",void 0),e([o()],D.prototype,"inputRenderFunction",void 0),e([o()],D.prototype,"layer",void 0),e([o({readOnly:!0})],D.prototype,"loadingMessage",null),e([o()],D.prototype,"maxLength",null),e([o()],D.prototype,"minLength",null),e([o({readOnly:!0})],D.prototype,"name",null),e([o({readOnly:!0})],D.prototype,"nullable",null),e([o()],D.prototype,"parseInputValueFunction",void 0),e([o({readOnly:!0})],D.prototype,"path",null),e([o({readOnly:!0})],D.prototype,"required",null),e([o()],D.prototype,"sortable",null),e([o()],D.prototype,"store",void 0),e([o()],D.prototype,"template",void 0),e([o()],D.prototype,"updateRowItemFunction",void 0),e([o()],D.prototype,"updateStoreItemFunction",void 0),D=e([r("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
|
|
@@ -956,4 +956,4 @@ import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../co
|
|
|
956
956
|
<template class="header" id="headerTemplate">
|
|
957
957
|
<vaadin-grid-sorter path="[[path]]" direction="{{direction}}">[[_getHeader(header, path)]]</vaadin-grid-sorter>
|
|
958
958
|
</template>
|
|
959
|
-
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Jl.is,Jl);const Xl={selectionColumn:!0,columnMenus:!0},Zl="esri-grid",Kl="compact column-borders",Ql={base:Zl,content:`${Zl}__content`,grid:`${Zl}__grid`,noColumnMenu:`${Zl}--no-column-menu`,widget:"esri-widget"};let ed=class extends(i(h)){constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this._isDataLoaded=!1,this.itemIdPath=null,this.messages=null,this.viewModel=new c,this.visibleElements={...Xl}}initialize(){this.handles.add([this.columns.on("change",(()=>this._syncColumnRenderers())),n((()=>this.viewModel?.size),(()=>this._updateGridSize())),n((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),o((()=>this.highlightIds),"change",(e=>{const{added:t,removed:i}=e,s=t.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})),r=i.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e}));this._deselectRows(r),this._selectRows(s)})),o((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.handles.removeAll(),this.resetColumns(),this.columns?.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...Xl,...e}}render(){const{columnMenus:e}=this.visibleElements;return _("div",{bind:this,class:this.classes(Ql.base,Ql.widget,{[Ql.noColumnMenu]:!e})},_("div",{bind:this,class:Ql.content},this.renderGrid()))}renderGrid(){return _("vaadin-grid",{_safari:!1,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,class:Ql.grid,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,size:this.size},this.renderAllColumns())}renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?[this.renderSelectionColumn(),this.renderColumns()]:null}renderSelectionColumn(){return _("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!u(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>"columns"in e?this.renderGroupColumn(e,t):_("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(s)}renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const s=e.columns.filter((({hidden:e})=>!e));return s.length?_("vaadin-grid-column-group",{...i},s.map((e=>_("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:r,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${s(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns?.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e),this.scheduleRender()}notifyResize(){this._grid?.notifyResize()}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._isDataLoaded=!1,this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),i=t.map((e=>e.objectId));i.length&&(this.highlightIds.addMany(i),this._selectRows(t))}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&(this.highlightIds.removeMany(t),this._deselectRows(e))}showColumn(e){this.viewModel?.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}isEditingActive(){return!!this._getActiveEditInfo().length}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",Kl),customElements.whenDefined("vaadin-grid").then((()=>this._addGridEventListeners())),t.__updateSorter=e=>{const i=t._sorters,r=!i.includes(e);if(e.direction||!r)if(e._order=null,t.multiSort)t._removeArrayItem(i,e),e.direction&&(s(e._initialOrder)?(r?i[e._initialOrder]=e:i.splice(e._initialOrder,0,e),e._initialOrder=null):i.unshift(e)),t.__updateSortOrders();else if(e.direction){const s=i.filter((t=>t!==e));t._sorters=[e],s.forEach((e=>{e._order=null,e.direction=null}))}}}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)}))}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_getActiveEditInfo(){if(!this.columns||this.columns.length)return[];return this.columns.filter((e=>"activeEditInfo"in e)).map((e=>e.activeEditInfo)).items}_addGridEventListeners(){const e=this._grid;r(e),this.handles.add([t(e,"click",(e=>this._onRowClick(e))),t(e,"selected-items-changed",(e=>this._onSelectionChange(e))),t(e,"sorter-changed",(()=>this.notifyChange("sortOrders"))),t(e,"loading-changed",(e=>{this._isDataLoaded||!1===e.detail.value&&(this._isDataLoaded=!0,this._selectRowsOnLoad())}))])}_onRowClick(e){const t=this._grid;r(t);const i=t.getEventContext(e),{item:s,section:n}=i;s&&n&&"details"!==n&&"header"!==n&&this.emit("row-click",{context:i,native:e})}_clearSelection(){this._grid&&(this.highlightIds.removeAll(),this._grid.selectedItems=[],this._grid.render())}_selectRowsOnLoad(){const e=this._grid;if(!e)return;const t=e.selectedItems.slice(),i=this.highlightIds?.filter((e=>t.findIndex((t=>t.objectId===e))<0));i.forEach((t=>e.selectedItems.push(this.store?.getLocalItemByKey(t)||{objectId:t}))),e.render()}_selectRows(e){const t=this._grid;if(!t)return;const i=t.selectedItems.slice();e.filter((e=>i.findIndex((t=>t.objectId===e.objectId))<0)).forEach((e=>t.selectedItems.push(e))),t.render()}_deselectRows(e){const t=this._grid;if(!t)return;const i=t.selectedItems.slice();e.forEach((e=>{const t=i.findIndex((t=>t.objectId===e.objectId));t>-1&&i.splice(t,1)})),t.selectedItems=i,t.render()}_onSelectionChange(e){const t=e;if("selectedItems.splices"===t.detail.path){const{removed:e,object:i}=t.detail.value.indexSplices[0],s=i.filter((e=>!this.highlightIds.includes(e.objectId))).map((e=>e.objectId)),r=e.filter((e=>this.highlightIds.includes(e.objectId))).map((e=>e.objectId));this.highlightIds.removeMany(r),this.highlightIds.addMany(s)}}_applyRenderersToColumnElement(e){const t=e.path,i=this.viewModel.findColumn(t);if(i)try{const{renderFunction:t,footerRenderFunction:s,headerRenderFunction:r}=i;t&&"renderer"in e&&(e.renderer=(e,i,s)=>t({root:e,column:i,rowData:s})),s&&(e.footerRenderer=(e,t)=>s({root:e,column:t})),r&&(e.headerRenderer=(e,t)=>r({root:e,column:t}))}catch(s){}}};e([a()],ed.prototype,"_grid",void 0),e([a()],ed.prototype,"_isDataLoaded",void 0),e([a()],ed.prototype,"cellClassNameGenerator",null),e([a()],ed.prototype,"columns",null),e([a()],ed.prototype,"columnReorderingEnabled",null),e([a()],ed.prototype,"dataProvider",null),e([a()],ed.prototype,"highlightIds",null),e([a()],ed.prototype,"itemIdPath",void 0),e([a()],ed.prototype,"label",null),e([a(),p("esri/widgets/FeatureTable/t9n/FeatureTable")],ed.prototype,"messages",void 0),e([a()],ed.prototype,"multiSortEnabled",null),e([a()],ed.prototype,"pageSize",null),e([a()],ed.prototype,"rowDetailsRenderer",null),e([a()],ed.prototype,"size",null),e([a({readOnly:!0})],ed.prototype,"sortOrders",null),e([a()],ed.prototype,"store",null),e([a()],ed.prototype,"viewModel",void 0),e([a()],ed.prototype,"visibleElements",void 0),e([l("visibleElements")],ed.prototype,"castVisibleElements",null),ed=e([d("esri.widgets.FeatureTable.Grid.Grid")],ed);const td=ed;export{td as default};
|
|
959
|
+
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Jl.is,Jl);const Xl={selectionColumn:!0,columnMenus:!0},Zl="esri-grid",Kl="compact column-borders",Ql={base:Zl,content:`${Zl}__content`,grid:`${Zl}__grid`,noColumnMenu:`${Zl}--no-column-menu`,widget:"esri-widget"};let ed=class extends(i(h)){constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this._isDataLoaded=!1,this.itemIdPath=null,this.messages=null,this.viewModel=new c,this.visibleElements={...Xl}}initialize(){this.handles.add([this.columns.on("change",(()=>this.onColumnChange())),n((()=>this.viewModel?.size),(()=>this._updateGridSize())),n((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),o((()=>this.highlightIds),"change",(e=>{const{added:t,removed:i}=e,s=t.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})),r=i.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e}));this._deselectRows(r),this._selectRows(s)})),o((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.handles.removeAll(),this.resetColumns(),this.columns?.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...Xl,...e}}render(){const{columnMenus:e}=this.visibleElements;return _("div",{bind:this,class:this.classes(Ql.base,Ql.widget,{[Ql.noColumnMenu]:!e})},_("div",{bind:this,class:Ql.content},this.renderGrid()))}renderGrid(){return _("vaadin-grid",{_safari:!1,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,class:Ql.grid,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,size:this.size},this.renderAllColumns())}renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?[this.renderSelectionColumn(),this.renderColumns()]:null}renderSelectionColumn(){return _("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!u(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>"columns"in e?this.renderGroupColumn(e,t):_("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(s)}renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const s=e.columns.filter((({hidden:e})=>!e));return s.length?_("vaadin-grid-column-group",{...i},s.map((e=>_("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:r,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${s(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns?.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e),this.scheduleRender()}notifyResize(){this._grid?.notifyResize()}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._isDataLoaded=!1,this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),i=t.map((e=>e.objectId));i.length&&(this.highlightIds.addMany(i),this._selectRows(t))}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&(this.highlightIds.removeMany(t),this._deselectRows(e))}showColumn(e){this.viewModel?.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}isEditingActive(){return!!this._getActiveEditInfo().length}onColumnChange(){this._syncColumnRenderers()}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",Kl),customElements.whenDefined("vaadin-grid").then((()=>this._addGridEventListeners())),t.__updateSorter=e=>{const i=t._sorters,r=!i.includes(e);if(e.direction||!r)if(e._order=null,t.multiSort)t._removeArrayItem(i,e),e.direction&&(s(e._initialOrder)?(r?i[e._initialOrder]=e:i.splice(e._initialOrder,0,e),e._initialOrder=null):i.unshift(e)),t.__updateSortOrders();else if(e.direction){const s=i.filter((t=>t!==e));t._sorters=[e],s.forEach((e=>{e._order=null,e.direction=null}))}}}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)}))}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_getActiveEditInfo(){if(!this.columns||this.columns.length)return[];return this.columns.filter((e=>"activeEditInfo"in e)).map((e=>e.activeEditInfo)).items}_addGridEventListeners(){const e=this._grid;r(e),this.handles.add([t(e,"click",(e=>this._onRowClick(e))),t(e,"selected-items-changed",(e=>this._onSelectionChange(e))),t(e,"sorter-changed",(()=>this.notifyChange("sortOrders"))),t(e,"loading-changed",(e=>{this._isDataLoaded||!1===e.detail.value&&(this._isDataLoaded=!0,this._selectRowsOnLoad())}))])}_onRowClick(e){const t=this._grid;r(t);const i=t.getEventContext(e),{item:s,section:n}=i;s&&n&&"details"!==n&&"header"!==n&&this.emit("row-click",{context:i,native:e})}_clearSelection(){this._grid&&(this.highlightIds.removeAll(),this._grid.selectedItems=[],this._grid.render())}_selectRowsOnLoad(){const e=this._grid;if(!e)return;const t=e.selectedItems.slice(),i=this.highlightIds?.filter((e=>t.findIndex((t=>t.objectId===e))<0));i.forEach((t=>e.selectedItems.push(this.store?.getLocalItemByKey(t)||{objectId:t}))),e.render()}_selectRows(e){const t=this._grid;if(!t)return;const i=t.selectedItems.slice();e.filter((e=>i.findIndex((t=>t.objectId===e.objectId))<0)).forEach((e=>t.selectedItems.push(e))),t.render()}_deselectRows(e){const t=this._grid;if(!t)return;const i=t.selectedItems.slice();e.forEach((e=>{const t=i.findIndex((t=>t.objectId===e.objectId));t>-1&&i.splice(t,1)})),t.selectedItems=i,t.render()}_onSelectionChange(e){const t=e;if("selectedItems.splices"===t.detail.path){const{removed:e,object:i}=t.detail.value.indexSplices[0],s=i.filter((e=>!this.highlightIds.includes(e.objectId))).map((e=>e.objectId)),r=e.filter((e=>this.highlightIds.includes(e.objectId))).map((e=>e.objectId));this.highlightIds.removeMany(r),this.highlightIds.addMany(s)}}_applyRenderersToColumnElement(e){const t=e.path,i=this.viewModel.findColumn(t);if(i)try{const{renderFunction:t,footerRenderFunction:s,headerRenderFunction:r}=i;t&&"renderer"in e&&(e.renderer=(e,i,s)=>t({root:e,column:i,rowData:s})),s&&(e.footerRenderer=(e,t)=>s({root:e,column:t})),r&&(e.headerRenderer=(e,t)=>r({root:e,column:t}))}catch(s){}}};e([a()],ed.prototype,"_grid",void 0),e([a()],ed.prototype,"_isDataLoaded",void 0),e([a()],ed.prototype,"cellClassNameGenerator",null),e([a()],ed.prototype,"columns",null),e([a()],ed.prototype,"columnReorderingEnabled",null),e([a()],ed.prototype,"dataProvider",null),e([a()],ed.prototype,"highlightIds",null),e([a()],ed.prototype,"itemIdPath",void 0),e([a()],ed.prototype,"label",null),e([a(),p("esri/widgets/FeatureTable/t9n/FeatureTable")],ed.prototype,"messages",void 0),e([a()],ed.prototype,"multiSortEnabled",null),e([a()],ed.prototype,"pageSize",null),e([a()],ed.prototype,"rowDetailsRenderer",null),e([a()],ed.prototype,"size",null),e([a({readOnly:!0})],ed.prototype,"sortOrders",null),e([a()],ed.prototype,"store",null),e([a()],ed.prototype,"viewModel",void 0),e([a()],ed.prototype,"visibleElements",void 0),e([l("visibleElements")],ed.prototype,"castVisibleElements",null),ed=e([d("esri.widgets.FeatureTable.Grid.Grid")],ed);const td=ed;export{td as default};
|
package/widgets/Slice.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/maybe.js";import{ignoreAbortErrors as
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/maybe.js";import{ignoreAbortErrors as i}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import o from"./Slice/SliceViewModel.js";import{Heading as n}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{tsx as a}from"./support/jsxFactory.js";const d="esri-slice",u={buttonDisabled:"esri-button--disabled",layerIncludeButton:`${d}__cross`,widgetIcon:"esri-icon-slice",base:`${d} esri-widget esri-widget--panel`,layerList:`${d}__settings`,layerListHeading:`${d}__settings-title`,layerItem:`${d}__layer-item`,layerItemTitle:`${d}__layer-item__title`,container:`${d}__container`,actionSection:`${d}__actions`,hint:`${d}__hint`,hintText:`${d}__hint-text`,panelError:`${d}__panel--error`,newSliceButton:`${d}__clear-button esri-button esri-button--primary`,excludeButton:`${d}__exclude-button esri-button esri-button--secondary`,cancelButton:`${d}__cancel-button esri-button esri-button--secondary`};let p=class extends r{constructor(e,t){super(e,t),this.headingLevel=3,this.iconClass=u.widgetIcon,this.messages=null,this.viewModel=new o}loadDependencies(){return import("@esri/calcite-components/dist/components/calcite-button.js")}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get excludedLayers(){return this.viewModel.excludedLayers}set excludedLayers(e){this.viewModel.excludedLayers=e}get excludeGroundSurface(){return this.viewModel.excludeGroundSurface}set excludeGroundSurface(e){this.viewModel.excludeGroundSurface=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const e=this.viewModel.supported,i=this.viewModel.active,s="disabled"===this.viewModel.state,l="ready"===this.viewModel.state,r="slicing"===this.viewModel.state||"sliced"===this.viewModel.state,o="exclude"===this.viewModel.layersMode,{messages:c}=this,d=s&&u.buttonDisabled,p=!!t(this.viewModel.view)&&this.viewModel.view.allLayerViews.some((e=>"voxel-3d"===e.type)),y=i&&!r||o?null:a("button",{disabled:s,class:this.classes(u.newSliceButton,d),bind:this,onclick:this._onNewSliceClick,key:"esri-slice__clear",type:"button"},c.newSlice),h=r&&!o?a("button",{class:this.classes(u.excludeButton,d),bind:this,onclick:()=>{this.viewModel.enterExcludeLayerMode()},key:"esri-slice__exclude",type:"button"},c.excludeLayer):null,v=i&&o?a("button",{class:this.classes(u.cancelButton,d),bind:this,onclick:()=>{this.viewModel.exitExcludeLayerMode()},key:"esri-slice__cancel-exclude",type:"button"},c.cancel):null;let m=null;i&&(o?m=c.excludeHint:l&&(m=p?c.voxelHint:c.hint));const w=m?a("div",{class:u.hint,key:"esri-slice__hint"},a("p",{class:u.hintText},m),a("p",{class:u.hintText},c.verticalHint)):null,_=this.excludedLayers?this.excludedLayers.toArray().map((e=>this._renderLayerItem({uid:e.uid,title:e.title,onClick:()=>(this.excludedLayers.remove(e),!1)}))):[];this.excludeGroundSurface&&_.push(this._renderLayerItem({uid:"ground",title:c.ground,onClick:()=>(this.excludeGroundSurface=!1,!1)}));const b=!o&&r&&_.length>0?a("div",{class:u.layerList,key:"esri-slice__settings"},a(n,{class:u.layerListHeading,level:this.headingLevel},c.excludedLayers),a("ul",null,_)):null,x=a("div",{class:u.panelError,key:"esri-slice__unsupported"},a("p",null,c.unsupported)),g=a("div",{class:u.actionSection},h,v,y),M=this.visible?a("div",{class:u.container},e?[w,b,g]:x):null;return a("div",{class:u.base,role:"presentation"},M)}_renderLayerItem(e){return a("li",{class:u.layerItem,key:e.uid},a("calcite-button",{appearance:"transparent",class:u.layerIncludeButton,iconStart:"x",scale:"s",title:this.messages.includeLayer,bind:this,onclick:e.onClick}),a("div",{class:u.layerItemTitle},e.title))}_onNewSliceClick(){i(this.viewModel.start())}};e([s()],p.prototype,"active",null),e([s({constructOnly:!0,nonNullable:!0})],p.prototype,"analysis",null),e([s()],p.prototype,"excludedLayers",null),e([s()],p.prototype,"excludeGroundSurface",null),e([s()],p.prototype,"headingLevel",void 0),e([s()],p.prototype,"iconClass",void 0),e([s()],p.prototype,"label",null),e([s(),c("esri/widgets/Slice/t9n/Slice")],p.prototype,"messages",void 0),e([s()],p.prototype,"view",null),e([s({type:o})],p.prototype,"viewModel",void 0),e([s()],p.prototype,"visible",null),p=e([l("esri.widgets.Slice")],p);const y=p;export{y as default};
|