@arcgis/core 4.30.0-next.20240213 → 4.30.0-next.20240215

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.
Files changed (193) hide show
  1. package/TimeExtent.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/08ba549f9c4afc42a21c.js +1 -0
  4. package/assets/esri/core/workers/chunks/114afcee6a66415cd123.js +1 -0
  5. package/assets/esri/core/workers/chunks/1320562881294ce93806.js +1 -0
  6. package/assets/esri/core/workers/chunks/13451fa3e4b02ca2beb0.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a384f29cb3256401962a.js → 1629a8c2085dce59cd1b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/18512caeeb03b9759ab1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{cc1c958aad790a44048b.js → 1ca28af7c516d8283bb0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1f8a0fb32b96e50f5909.js +1 -0
  11. package/assets/esri/core/workers/chunks/{abab3abb8ea7610d9fb8.js → 21e7a88478f5d15e0e71.js} +1 -1
  12. package/assets/esri/core/workers/chunks/24452a26b0c5322c7d2b.js +1 -0
  13. package/assets/esri/core/workers/chunks/25b88787ead0cc44cda4.js +1 -0
  14. package/assets/esri/core/workers/chunks/2649166d1a462c7f8338.js +1 -0
  15. package/assets/esri/core/workers/chunks/2c96771a365f8f70e996.js +1 -0
  16. package/assets/esri/core/workers/chunks/352e7f8d694f3f217a2d.js +1 -0
  17. package/assets/esri/core/workers/chunks/392214a3a1d712eda155.js +1 -0
  18. package/assets/esri/core/workers/chunks/397f15b5bce6838db084.js +1 -0
  19. package/assets/esri/core/workers/chunks/3bf281e979408b9363ed.js +1 -0
  20. package/assets/esri/core/workers/chunks/4edc667148d023b5b5af.js +1 -0
  21. package/assets/esri/core/workers/chunks/51e4f771bfe352967c97.js +1 -0
  22. package/assets/esri/core/workers/chunks/55cd747e06bb59d1a328.js +1 -0
  23. package/assets/esri/core/workers/chunks/5638d95e600ff271c5b1.js +1 -0
  24. package/assets/esri/core/workers/chunks/563d172caa15ea1b510d.js +1108 -0
  25. package/assets/esri/core/workers/chunks/58f088b08e12c5435dbc.js +1 -0
  26. package/assets/esri/core/workers/chunks/5aef1e898618f8dda2c9.js +1 -0
  27. package/assets/esri/core/workers/chunks/608be8ebf772aefc36a5.js +1 -0
  28. package/assets/esri/core/workers/chunks/64df2521b2814d2fb918.js +1 -0
  29. package/assets/esri/core/workers/chunks/65070fb591f6ef8313c3.js +1 -0
  30. package/assets/esri/core/workers/chunks/656ec8a14df0e4b68433.js +1 -0
  31. package/assets/esri/core/workers/chunks/6601fe99d587b9dff3c7.js +1 -0
  32. package/assets/esri/core/workers/chunks/{274e623323e24250ca46.js → 6ac424af4f2825fabceb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{eb2d6f1ee63b40ae0736.js → 774b655498289b1b36bb.js} +1 -1
  34. package/assets/esri/core/workers/chunks/781bb63af571568358e3.js +1 -0
  35. package/assets/esri/core/workers/chunks/9e54d2cbe42f5552aaca.js +1 -0
  36. package/assets/esri/core/workers/chunks/{f03d62ab7806b68d0b62.js → 9fbf61675e2a5374f754.js} +1 -1
  37. package/assets/esri/core/workers/chunks/a5253543eae1708d11b9.js +1 -0
  38. package/assets/esri/core/workers/chunks/aa9b46bcb75c96731de3.js +1 -0
  39. package/assets/esri/core/workers/chunks/cfb8b6b5e9c21d582cf4.js +1 -0
  40. package/assets/esri/core/workers/chunks/d1b2372084c1e8c60f79.js +1 -0
  41. package/assets/esri/core/workers/chunks/{1c6914ded7db720f7bf7.js → daf6eab5dd198ca9a67b.js} +1 -1
  42. package/assets/esri/core/workers/chunks/e03edeaf3af46495449e.js +1 -0
  43. package/assets/esri/core/workers/chunks/e685214698fbc84276dd.js +1 -0
  44. package/assets/esri/core/workers/chunks/ebb294c82207f3ff9f04.js +1 -0
  45. package/assets/esri/core/workers/chunks/ec20e23aec9370df8a55.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e4da908079417cc2f495.js → ee0c77889059815a31b2.js} +1 -1
  47. package/assets/esri/core/workers/chunks/f68b7bb88c444a7cbbd2.js +1 -0
  48. package/assets/esri/core/workers/chunks/f90bbebd2dc07a77ce09.js +1 -0
  49. package/assets/esri/core/workers/chunks/fa388680ff976a6b30f6.js +1 -0
  50. package/chunks/vec32.js +1 -1
  51. package/interfaces.d.ts +135 -68
  52. package/layers/WFSLayer.js +1 -1
  53. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  54. package/layers/graphics/applyEditsUtils.js +1 -1
  55. package/layers/graphics/editingSupport.js +1 -1
  56. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/save/featureLayerUtils.js +1 -1
  59. package/layers/support/arcgisLayers.js +1 -1
  60. package/layers/support/fetchService.js +1 -1
  61. package/layers/support/fromPortalItem.js +1 -1
  62. package/networks/Network.js +1 -1
  63. package/package.json +1 -1
  64. package/portal/Portal.js +1 -1
  65. package/portal/PortalGroup.js +1 -1
  66. package/portal/PortalUser.js +1 -1
  67. package/portal/support/geometryServiceUtils.js +1 -1
  68. package/portal/support/layersLoader.js +1 -1
  69. package/portal/support/loadUtils.js +1 -1
  70. package/portal/support/portalLayers.js +1 -1
  71. package/renderers/visualVariables/SizeVariable.js +1 -1
  72. package/rest/knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js +1 -1
  73. package/rest/networks/support/Association.js +1 -1
  74. package/rest/places.js +1 -1
  75. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  76. package/rest/support/ImageSampleParameters.js +1 -1
  77. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  78. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  79. package/support/elevationInfoUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/symbols/cim/cimAnalyzer.js +1 -1
  82. package/symbols/cim/defaultCIMValues.js +1 -1
  83. package/symbols/cim/utils.js +1 -1
  84. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  85. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  86. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  87. package/views/2d/engine/webgl/definitions.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  90. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  91. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  92. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  93. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  94. package/views/2d/layers/features/Processor.js +1 -1
  95. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  96. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  97. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  98. package/views/2d/layers/features/schema/processor/VisualVariablesSchema.js +1 -1
  99. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  100. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  101. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  102. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  103. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  104. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  105. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  106. package/views/3d/layers/SceneLayerView3D.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  109. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  110. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  111. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  112. package/views/3d/support/orientedBoundingBox.js +1 -1
  113. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  114. package/views/3d/terrain/OverlayRenderer.js +1 -1
  115. package/views/3d/webgl/RenderNode.js +1 -1
  116. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  117. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  118. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +9 -7
  119. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceConstants.js +5 -0
  120. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  121. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  122. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  123. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  124. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  125. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  126. package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
  127. package/views/draw/DrawGraphicTool.js +1 -1
  128. package/views/draw/DrawOperation.js +1 -1
  129. package/views/draw/drawSurfaces.js +1 -1
  130. package/views/interactive/snapping/SnappingManager.js +1 -1
  131. package/views/interactive/snapping/SnappingOptions.js +1 -1
  132. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  133. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  134. package/views/layers/ImageryTileLayerView.js +1 -1
  135. package/webdoc/support/webdocLoadUtils.js +1 -1
  136. package/webdoc/support/webdocSaveUtils.js +1 -1
  137. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  138. package/widgets/Editor/EditorViewModel.js +1 -1
  139. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  140. package/widgets/Editor/UpdateWorkflow.js +1 -1
  141. package/widgets/Editor/components/FooterActions.js +1 -1
  142. package/widgets/Editor/support/EditorItem.js +1 -1
  143. package/widgets/Editor.js +1 -1
  144. package/widgets/FeatureForm.js +1 -1
  145. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  146. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  147. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  148. package/widgets/FeatureTable.js +1 -1
  149. package/widgets/Features/FeaturesViewModel.js +1 -1
  150. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  151. package/widgets/Print/PrintViewModel.js +1 -1
  152. package/widgets/Print.js +1 -1
  153. package/widgets/Search/support/locatorUtils.js +1 -1
  154. package/widgets/Sketch/SketchViewModel.js +1 -1
  155. package/assets/esri/core/workers/chunks/00b9e92f8df245a83921.js +0 -1
  156. package/assets/esri/core/workers/chunks/02a6c43ec17e7223fac5.js +0 -1
  157. package/assets/esri/core/workers/chunks/02ee044597c89c86b934.js +0 -1
  158. package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +0 -1
  159. package/assets/esri/core/workers/chunks/143ccb14c9e915dd1412.js +0 -1
  160. package/assets/esri/core/workers/chunks/24649b410b757599a549.js +0 -1
  161. package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +0 -1
  162. package/assets/esri/core/workers/chunks/2519b207894132d5ea91.js +0 -1
  163. package/assets/esri/core/workers/chunks/30f9b2a3417cbcfeecca.js +0 -1
  164. package/assets/esri/core/workers/chunks/42ab9c282bb267c3db03.js +0 -1
  165. package/assets/esri/core/workers/chunks/478815fc19b452d8317d.js +0 -1
  166. package/assets/esri/core/workers/chunks/49afeac45250b15b5f36.js +0 -1
  167. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +0 -1
  168. package/assets/esri/core/workers/chunks/50cdc59426ba859027e2.js +0 -1
  169. package/assets/esri/core/workers/chunks/5401ec9c9fd62dcac6ec.js +0 -1
  170. package/assets/esri/core/workers/chunks/554d86df71821d671d2c.js +0 -1
  171. package/assets/esri/core/workers/chunks/58c5861d060c808813a1.js +0 -1
  172. package/assets/esri/core/workers/chunks/5dbb3ef6fdd25ac632ad.js +0 -1
  173. package/assets/esri/core/workers/chunks/61c4bb58ef9f2d99c75e.js +0 -1
  174. package/assets/esri/core/workers/chunks/6e50220f8e2d392e2855.js +0 -1
  175. package/assets/esri/core/workers/chunks/6fd8047741a0df006ddd.js +0 -1
  176. package/assets/esri/core/workers/chunks/7709248f59520aee6f51.js +0 -1
  177. package/assets/esri/core/workers/chunks/8852a64918caf80fc414.js +0 -1
  178. package/assets/esri/core/workers/chunks/8d119dc0a92ad3612daa.js +0 -1
  179. package/assets/esri/core/workers/chunks/94dfb80ab23dda92918b.js +0 -1
  180. package/assets/esri/core/workers/chunks/9ebbc75ba5c623a322aa.js +0 -1
  181. package/assets/esri/core/workers/chunks/a5babc10f47c24651d15.js +0 -1
  182. package/assets/esri/core/workers/chunks/a74c59cf5d1c4e63a4e1.js +0 -1
  183. package/assets/esri/core/workers/chunks/ada5d6fd70bd3e403442.js +0 -1
  184. package/assets/esri/core/workers/chunks/b95d69d84d60ac9828b9.js +0 -1
  185. package/assets/esri/core/workers/chunks/be562536212360943388.js +0 -1
  186. package/assets/esri/core/workers/chunks/ce823fc2d0e0095f398c.js +0 -1
  187. package/assets/esri/core/workers/chunks/d06d36815c2121484a13.js +0 -1
  188. package/assets/esri/core/workers/chunks/d5f06a7b0ea7951c8dd0.js +0 -1
  189. package/assets/esri/core/workers/chunks/ddc71fe66c7a49082920.js +0 -1
  190. package/assets/esri/core/workers/chunks/de6d54df7ae32694fd70.js +0 -1
  191. package/assets/esri/core/workers/chunks/f13c4b9692dad5802a32.js +0 -1106
  192. package/assets/esri/core/workers/chunks/f1e8f7d1a98b9e207b1b.js +0 -1
  193. package/assets/esri/core/workers/chunks/f9e9675f1c2287231653.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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{onAbort as s,createAbortError as n,throwIfAborted as l,debounce as d}from"../../core/promiseUtils.js";import c from"../../core/Queue.js";import{whenOnce as p,watch as u,sync as w}from"../../core/reactiveUtils.js";import{last as h}from"../../core/SetUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isSubtypeGroupLayer as g,isTable as v}from"../../layers/support/layerUtils.js";import y from"../../views/draw/support/HighlightHelper.js";import W from"../../views/interactive/sketch/SketchOptions.js";import b from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as _}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as C}from"./UpdateRecordWorkflow.js";import M from"./UpdateWorkflowData.js";import S from"./Workflow.js";import{createWorkflowSteps as F,fetchCandidates as A}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as j}from"../Feature/support/featureUtils.js";import{getAllTemplatesForLayer as U}from"../support/templateUtils.js";var E;const I="esri.widgets.Editor.UpdateWorkflow",x=()=>i.getLogger(I);let R=E=class extends S{constructor(e){super(e),this._workflowStack=new c(h),this._sketchStack=new c(h),this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=(()=>Promise.resolve(!0))){const{activeWorkflow:t}=this;if(null==t?.featureFormViewModel.relationshipId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else t.featureFormViewModel.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:o,addAttachmentsCallback:i,applyEditsCallback:r}=e,s=e.sketchOptions??new W,n=new E({data:new M({addAttachmentsCallback:i,applyEditsCallback:r,sketchOptions:s,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return n._set("steps",this._createWorkflowSteps(n,o)),n}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e){try{const t=await this._createNestedUpdateWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:t})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");O(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:o,applyEditsCallback:i,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return b.create({addAttachmentsCallback:o,applyEditsCallback:i,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:o}=e;if(!m(o)||g(o))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const i={layer:o,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=U(o);return s?.length>0?(i.attributeOverrides=r,1===s.length&&(i.template=s[0])):i.initialFeature=new t({sourceLayer:o,attributes:r}),i}async _createNestedUpdateWorkflow(e){const t=v(e.sourceLayer)?C:_,{applyEditsCallback:a,sketchOptions:o,snappingManager:i,viewModel:r}=this.data,s="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,n=await t.create({feature:e,parent:s,sketchOptions:o,snappingManager:i,viewModel:r,applyEdits:a,relatedRecordCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e)}});return await p((()=>!n.updating)),n}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const o=t.pop();this._sketchStack.pop();const i=e(o).then((()=>o.destroy()));this._updatingHandles.addPromise(i),a.push(i)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:o}=e;if(!j(t))return;const i=a.relationships?.find((e=>e.id===o));if(!i)return void P("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===i.role)return void P("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;i.relatedTableId!==r.layerId&&P("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===o));if(!s)return void P("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=t.getAttribute(s.keyField);return n||P("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field."),{[i.keyField]:n}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const o=this._sketchStack,i=await(e?.start()),r=o.peek();i?(r?.exit(),o.push(i)):o.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:i+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!v(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return F(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,a=i.viewModel.view;let d=null;e.addHandles(o((()=>{d=r(d)})),this.id),i.rootFeature=null,i.candidates=[];const c=a.on("immediate-click",(async o=>{o.stopPropagation(),t.location=o.mapPoint,t.visible=!0,d?.abort();const{editorItems:r}=i.viewModel;d=new AbortController;const c=await new Promise(((e,t)=>{s(d?.signal,(()=>t(n()))),e(A(r,a,o,d?.signal))}));l(d),i.candidates=c.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)),t.visible=1===i.candidates.length,0!==i.candidates.length&&(1===i.candidates.length?(i.rootFeature=i.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next())}));a.focus(),e.addHandles(c,this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeature=null;const{view:t}=i.viewModel;if(!t)return;const a=new y({view:t});e.addHandles([u((()=>i.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),w),o((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:o}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),o.spinnerViewModel.visible=!1;const i=d((async()=>{await p((()=>!e.updating)),e.previous()}));e.addHandles([u((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&i()}),w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}};e([f()],R.prototype,"activeEditorItem",null),e([f()],R.prototype,"activeFeatureFormViewModel",null),e([f()],R.prototype,"activeSketchViewModel",null),e([f()],R.prototype,"activeWorkflow",null),e([f()],R.prototype,"nestedWorkflowCount",null),e([f()],R.prototype,"shouldShowAttachments",null),e([f()],R.prototype,"shouldAllowAttachmentEditing",null),e([f()],R.prototype,"hasPendingEdits",null),e([f()],R.prototype,"helpMessage",null),e([f()],R.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],R.prototype,"hasInvalidFormTemplate",null),R=E=e([k(I)],R);const P=(e,t)=>x().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),O=e=>!!e&&/update-/.test(e.type),V=R;export{V as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{onAbort as s,createAbortError as n,throwIfAborted as l,debounce as d}from"../../core/promiseUtils.js";import c from"../../core/Queue.js";import{whenOnce as p,watch as u,sync as w}from"../../core/reactiveUtils.js";import{last as h}from"../../core/SetUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isSubtypeGroupLayer as g,isTable as v}from"../../layers/support/layerUtils.js";import y from"../../views/draw/support/HighlightHelper.js";import W from"../../views/interactive/sketch/SketchOptions.js";import b from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as C}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as _}from"./UpdateRecordWorkflow.js";import M from"./UpdateWorkflowData.js";import S from"./Workflow.js";import{createWorkflowSteps as F,fetchCandidates as A}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as j}from"../Feature/support/featureUtils.js";import{getAllTemplatesForLayer as U}from"../support/templateUtils.js";var E;const I="esri.widgets.Editor.UpdateWorkflow",x=()=>i.getLogger(I);let R=E=class extends S{constructor(e){super(e),this._workflowStack=new c(h),this._sketchStack=new c(h),this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get activeWorkflow(){return this._workflowStack.last()}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=(()=>Promise.resolve(!0))){const{activeWorkflow:t}=this;if(null==t?.featureFormViewModel.relationshipId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else t.featureFormViewModel.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:o,addAttachmentsCallback:i,applyEditsCallback:r}=e,s=e.sketchOptions??new W,n=new E({data:new M({addAttachmentsCallback:i,applyEditsCallback:r,sketchOptions:s,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return n._set("steps",this._createWorkflowSteps(n,o)),n}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e){try{const t=await this._createNestedUpdateWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:t})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");O(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:o,applyEditsCallback:i,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return b.create({addAttachmentsCallback:o,applyEditsCallback:i,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:o}=e;if(!m(o)||g(o))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const i={layer:o,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=U(o);return s?.length>0?(i.attributeOverrides=r,1===s.length&&(i.template=s[0])):i.initialFeature=new t({sourceLayer:o,attributes:r}),i}async _createNestedUpdateWorkflow(e){const t=v(e.sourceLayer)?_:C,{applyEditsCallback:a,sketchOptions:o,snappingManager:i,viewModel:r}=this.data,s="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,n=await t.create({feature:e,parent:s,sketchOptions:o,snappingManager:i,viewModel:r,applyEdits:a,relatedRecordCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e)}});return await p((()=>!n.updating)),n}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const o=t.pop();this._sketchStack.pop();const i=e(o).then((()=>o.destroy()));this._updatingHandles.addPromise(i),a.push(i)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:o}=e;if(!j(t))return;const i=a.relationships?.find((e=>e.id===o));if(!i)return void P("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===i.role)return void P("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;i.relatedTableId!==r.layerId&&P("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===o));if(!s)return void P("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=t.getAttribute(s.keyField);return n||P("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field."),{[i.keyField]:n}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const o=this._sketchStack,i=await(e?.start()),r=o.peek();i?(r?.exit(),o.push(i)):o.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:i+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!v(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return F(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,a=i.viewModel.view;let d=null;e.addHandles(o((()=>{d=r(d)})),this.id),i.rootFeature=null,i.candidates=[];const c=a.on("immediate-click",(async o=>{o.stopPropagation(),t.location=o.mapPoint,t.visible=!0,d?.abort();const{editorItems:r}=i.viewModel;d=new AbortController;const c=await new Promise(((e,t)=>{s(d?.signal,(()=>t(n()))),e(A(r,a,o,d?.signal))}));l(d),i.candidates=c.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)),t.visible=1===i.candidates.length,0!==i.candidates.length&&(1===i.candidates.length?(i.rootFeature=i.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next())}));a.focus(),e.addHandles(c,this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeature=null;const{view:t}=i.viewModel;if(!t)return;const a=new y({view:t});e.addHandles([u((()=>i.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),w),o((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:o}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),o.spinnerViewModel.visible=!1;const i=d((async()=>{await p((()=>!e.updating)),e.previous()}));e.addHandles([u((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&i()}),w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}};e([f()],R.prototype,"activeEditorItem",null),e([f()],R.prototype,"activeFeatureFormViewModel",null),e([f()],R.prototype,"activeSketchViewModel",null),e([f()],R.prototype,"activeWorkflow",null),e([f()],R.prototype,"hasUpdatableCandidates",null),e([f()],R.prototype,"nestedWorkflowCount",null),e([f()],R.prototype,"shouldShowAttachments",null),e([f()],R.prototype,"shouldAllowAttachmentEditing",null),e([f()],R.prototype,"hasPendingEdits",null),e([f()],R.prototype,"helpMessage",null),e([f()],R.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],R.prototype,"hasInvalidFormTemplate",null),R=E=e([k(I)],R);const P=(e,t)=>x().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),O=e=>!!e&&/update-/.test(e.type),V=R;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.30/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as s}from"../../support/jsxFactory.js";const i={base:"esri-editor__actions"},e=()=>o({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js")});function r({buttons:o,key:e}){return s("div",{class:i.base,key:e??"footer-actions",slot:"footer"},o.filter(t).map((({disabled:t,onClick:o,label:i,...e},r)=>s("calcite-button",{disabled:t??!1,key:`action-${r}`,onclick:o,slot:"footer-actions",width:"full",...e},i))))}export{r as FooterActions,i as css,e as loadFooterActionsComponents};
5
+ import{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as s}from"../../support/jsxFactory.js";const i={base:"esri-editor__actions"},e=()=>o({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js")});function r({buttons:o,key:e}){return s("div",{class:i.base,key:e??"footer-actions",slot:"footer"},o.filter(t).map((({disabled:t,onClick:o,label:i,...e},r)=>s("calcite-button",{disabled:t??!1,key:`action-${r}`,onclick:()=>{t||o()},slot:"footer-actions",width:"full",...e},i))))}export{r as FooterActions,i as css,e as loadFooterActionsComponents};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import s from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as i}from"../../FeatureForm/featureFormUtils.js";let a=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null}get capabilities(){return new s({layer:this.layer,layerInfo:this.layerInfo})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:o}}=this.capabilities,s=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||s||o||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return i(this.layer,this.formTemplate)}get supportsCreateFeaturesWorkflow(){return!this.disabled&&this.visible&&this.capabilities.create.enabled}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&this.visible&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return e.visible&&(!t||!("visible"in t)||!!t.visible)}};e([r()],a.prototype,"capabilities",null),e([r()],a.prototype,"disabled",void 0),e([r()],a.prototype,"editable",null),e([r()],a.prototype,"formTemplate",null),e([r()],a.prototype,"hasInvalidFormTemplate",null),e([r()],a.prototype,"layer",void 0),e([r()],a.prototype,"layerInfo",void 0),e([r()],a.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],a.prototype,"supportsUpdateWorkflow",null),e([r()],a.prototype,"visible",null),a=e([o("esri.widgets.editor.support.EditorItem")],a);const l=a;export{l as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import l from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as a}from"../../FeatureForm/featureFormUtils.js";let i=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new l({layer:this.layer,layerInfo:this.layerInfo})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return a(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){return!this.disabled&&this.capabilities.create.enabled}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],i.prototype,"_suspended",null),e([r()],i.prototype,"capabilities",null),e([r()],i.prototype,"disabled",void 0),e([r()],i.prototype,"editable",null),e([r()],i.prototype,"formTemplate",null),e([r()],i.prototype,"hasInvalidFormTemplate",null),e([r()],i.prototype,"isTable",null),e([r()],i.prototype,"layer",void 0),e([r()],i.prototype,"layerInfo",void 0),e([r()],i.prototype,"layerView",void 0),e([r()],i.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],i.prototype,"supportsUpdateWorkflow",null),e([r()],i.prototype,"visible",null),i=e([s("esri.widgets.editor.support.EditorItem")],i);const p=i;export{p as default};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{mappedFind as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../views/interactive/sketch/SketchValueOptions.js";import c from"./Attachments.js";import h from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as f}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{warningIcon as _}from"./Editor/icons.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as F,CreateFeaturesPanelContent as M}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as b,FeatureList as C}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as E,FooterActions as W}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as A,Notice as T}from"./Editor/components/Notices.js";import{loadPanelContentComponents as j,PanelContent as P,PanelContentSection as L,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as U,loadPanelToolbarComponents as S}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as x,UpdateFeaturePanelContent as B}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as V,UploadDetails as G}from"./Editor/components/UploadDetails.js";import{renderItem as R}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as q}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as N,Heading as z}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as J}from"./support/decorators/vmEvent.js";import{tsx as K}from"./support/jsxFactory.js";import{substitute as Q}from"../intl/substitute.js";let X=class extends w{constructor(e,t){super(e,t),this._featureForm=new h,this._attachments=new c({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?K("calcite-icon",{class:f.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this.headingLevel=4,this.iconClass=f.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new k,this._renderSelectIcon=()=>K("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t},...s)=>K("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,onCalciteFlowItemBack:this._onBack},K(U,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:this.visibleElements}),...s),this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPrompt("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):this._showPrompt({title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null}}initialize(){this.addHandles([r((()=>N(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),a),r((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),a),r((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),a),l((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.ownSketchViewModel.set(e.sketch)}),a),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:Q(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return Promise.all([q({"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js")}),F(),b(),E(),A(),j(),S(),O(),x(),V()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _loading(){const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){t(s.getLogger(this),"allowedWorkflows",{replacement:"visibleElements",version:"4.29",warnOnce:!0}),this.viewModel.allowedWorkflows=e}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this,t=this.classes(f.base,H.widget,H.panel);return e?K("div",{class:t,key:"base"},K("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e)))),this._prompt?K(D,{...this._prompt,headingLevel:this.headingLevel}):void 0):K("div",{class:t,key:"empty"})}_renderPage(e){switch(e){case"disabled":break;case"ready":return this._renderReady();case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo();case"creating-features-upload-details":return this._renderUploadDetails();case"creating-features":return this._renderCreatingFeatures();case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature();case"awaiting-update-feature-candidate":return this._renderFeatureList();case"adding-attachment":return this._renderAttachmentAdding();case"editing-attachment":return this._renderAttachmentEditing()}return K("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(){const{EditorPanel:e,messages:t}=this;return K(e,{heading:t.selectTemplate,key:"templates-panel"},K(P,{key:"feature-templates"},K(L,null,this._featureTemplates.render())))}_renderUploadDetails(){const{EditorPanel:e,activeWorkflow:t,messages:s}=this;if("create-features"!==t?.type)return null;const o=t.data.upload;return o?K(e,{heading:s.createFeatures,key:"upload-details-panel"},K(G,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(){const{EditorPanel:e,activeWorkflow:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;if(!t)return null;const a="create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&"create-features"===t?.activeWorkflow?.type&&t.activeWorkflow?.numPendingFeatures>0;return K(e,{heading:s.createFeatures,key:"create-features-panel"},a?K(B,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}):K(M,{helpMessage:this._helpMessage}))}_renderUpdateFeature(){const{EditorPanel:e,messages:t,messagesCommon:s,headingLevel:o,viewModel:i}=this;return K(e,{heading:t.editFeature,key:"update-feature-panel"},K(B,{editorViewModel:i,headingLevel:o,messages:t,messagesCommon:s,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,i=o(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?K(T,{icon:_,message:i}):null}_renderAttachmentAdding(){const{EditorPanel:e,_attachments:t,messages:s,messagesCommon:o}=this;return K(e,{heading:s.addAttachment,key:"attachment-adding-panel"},K(P,{key:"attachments"},t.render()),K(W,{buttons:[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentAdd}]}))}_renderAttachmentEditing(){const{EditorPanel:e,_attachments:t,activeWorkflow:s,messages:o,messagesCommon:i}=this;return s?K(e,{heading:o.editAttachment,key:"attachment-editing-panel"},K(P,{key:"attachments"},t.render()),s.shouldAllowAttachmentEditing?K(W,{buttons:[{label:i.update,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:t.submitting,label:i.delete}]}):void 0):null}_renderReady(){const{EditorPanel:e,messages:t,viewModel:s,visibleElements:o}=this,i=this._helpMessage;return K(e,{heading:t.widgetLabel,key:"landing-panel"},K(P,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?K(L,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection?K(L,{key:"create-actions"},this._renderCreateActions()):null]:K(I,{key:"no-content"},t.noEditableLayers)),i?K("div",{class:f.helpMessage,key:"footer-actions",slot:"footer"},i):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return K("div",{class:f.updateActions,key:"update-actions"},K(z,{level:N(this.headingLevel)},e.editFeatures),K("calcite-list",{class:f.updateActionsList,selectionAppearance:"border",selectionMode:"single"},R({disabled:!s.canUpdate,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return K("div",{key:"create-actions"},K(z,{level:N(this.headingLevel)},this.messages.createFeatures),K("div",{class:f.featureTemplatesContainer,key:"templates"},this._featureTemplates.render()))}_renderFeatureList(){const{EditorPanel:e,viewModel:t}=this,{activeWorkflow:s}=t;if("update"!==s?.type)return null;const o=s.data.candidates,i=Q(this.messages.multipleFeaturesTemplate,{total:o.length});return K(e,{heading:i,key:"feature-list"},K(C,{editorItems:t.editorItems,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,s)=>t.selectFeature(e,s)}))}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}},r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}};e([d()],X.prototype,"_featureForm",void 0),e([d()],X.prototype,"_attachments",void 0),e([d()],X.prototype,"_featureTemplates",void 0),e([d()],X.prototype,"_filterText",void 0),e([d()],X.prototype,"_prompt",void 0),e([d()],X.prototype,"_spinner",void 0),e([d()],X.prototype,"_deleteButtonCommonInfo",null),e([d()],X.prototype,"_loading",null),e([d({readOnly:!0})],X.prototype,"activeWorkflow",null),e([d()],X.prototype,"allowedWorkflows",null),e([d()],X.prototype,"headingLevel",void 0),e([d()],X.prototype,"hideTemplatesForInactiveLayers",null),e([d()],X.prototype,"iconClass",void 0),e([d()],X.prototype,"label",null),e([d()],X.prototype,"labelOptions",null),e([d()],X.prototype,"layerInfos",null),e([d(),$("esri/widgets/Editor/t9n/Editor")],X.prototype,"messages",void 0),e([d(),$("esri/t9n/common")],X.prototype,"messagesCommon",void 0),e([d(),$("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],X.prototype,"messagesTemplates",void 0),e([d()],X.prototype,"snappingOptions",null),e([d()],X.prototype,"tooltipOptions",null),e([d()],X.prototype,"supportingWidgetDefaults",void 0),e([d({type:p,nonNullable:!0})],X.prototype,"valueOptions",null),e([d()],X.prototype,"view",null),e([d(),J(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],X.prototype,"viewModel",void 0),e([d({type:k,nonNullable:!0})],X.prototype,"visibleElements",void 0),e([d()],X.prototype,"_helpMessage",null),X=e([m("esri.widgets.Editor")],X);const Y=X;export{Y as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{mappedFind as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../views/interactive/sketch/SketchValueOptions.js";import c from"./Attachments.js";import h from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as f}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{warningIcon as _}from"./Editor/icons.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as F,CreateFeaturesPanelContent as M}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as b,FeatureList as C}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as E,FooterActions as W}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as A,Notice as T}from"./Editor/components/Notices.js";import{loadPanelContentComponents as j,PanelContent as P,PanelContentSection as L,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as U,loadPanelToolbarComponents as S}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as x,UpdateFeaturePanelContent as B}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as V,UploadDetails as G}from"./Editor/components/UploadDetails.js";import{renderItem as R}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as q}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as N,Heading as z}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as J}from"./support/decorators/vmEvent.js";import{tsx as K}from"./support/jsxFactory.js";import{substitute as Q}from"../intl/substitute.js";let X=class extends w{constructor(e,t){super(e,t),this._featureForm=new h,this._attachments=new c({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?K("calcite-icon",{class:f.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this.headingLevel=4,this.iconClass=f.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new k,this._renderSelectIcon=()=>K("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t},...s)=>K("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,onCalciteFlowItemBack:this._onBack,onCalciteFlowItemScroll:this._featureForm?.onScroll},K(U,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:this.visibleElements}),...s),this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPrompt("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):this._showPrompt({title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null}}initialize(){this.addHandles([r((()=>N(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),a),r((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),a),r((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),a),l((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.ownSketchViewModel.set(e.sketch)}),a),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:Q(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return Promise.all([q({"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js")}),F(),b(),E(),A(),j(),S(),O(),x(),V()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _loading(){const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){t(s.getLogger(this),"allowedWorkflows",{replacement:"visibleElements",version:"4.29",warnOnce:!0}),this.viewModel.allowedWorkflows=e}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this,t=this.classes(f.base,H.widget,H.panel);return e?K("div",{class:t,key:"base"},K("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e)))),this._prompt?K(D,{...this._prompt,headingLevel:this.headingLevel}):void 0):K("div",{class:t,key:"empty"})}_renderPage(e){switch(e){case"disabled":break;case"ready":return this._renderReady();case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo();case"creating-features-upload-details":return this._renderUploadDetails();case"creating-features":return this._renderCreatingFeatures();case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature();case"awaiting-update-feature-candidate":return this._renderFeatureList();case"adding-attachment":return this._renderAttachmentAdding();case"editing-attachment":return this._renderAttachmentEditing()}return K("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(){const{EditorPanel:e,messages:t}=this;return K(e,{heading:t.selectTemplate,key:"templates-panel"},K(P,{key:"feature-templates"},K(L,null,this._featureTemplates.render())))}_renderUploadDetails(){const{EditorPanel:e,activeWorkflow:t,messages:s}=this;if("create-features"!==t?.type)return null;const o=t.data.upload;return o?K(e,{heading:s.createFeatures,key:"upload-details-panel"},K(G,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(){const{EditorPanel:e,activeWorkflow:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;if(!t)return null;const a="create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&"create-features"===t?.activeWorkflow?.type&&t.activeWorkflow?.numPendingFeatures>0;return K(e,{heading:s.createFeatures,key:"create-features-panel"},a?K(B,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}):K(M,{helpMessage:this._helpMessage}))}_renderUpdateFeature(){const{EditorPanel:e,messages:t,messagesCommon:s,headingLevel:o,viewModel:i}=this;return K(e,{heading:t.editFeature,key:"update-feature-panel"},K(B,{editorViewModel:i,headingLevel:o,messages:t,messagesCommon:s,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,i=o(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?K(T,{icon:_,message:i}):null}_renderAttachmentAdding(){const{EditorPanel:e,_attachments:t,messages:s,messagesCommon:o}=this;return K(e,{heading:s.addAttachment,key:"attachment-adding-panel"},K(P,{key:"attachments"},t.render()),K(W,{buttons:[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentAdd}]}))}_renderAttachmentEditing(){const{EditorPanel:e,_attachments:t,activeWorkflow:s,messages:o,messagesCommon:i}=this;return s?K(e,{heading:o.editAttachment,key:"attachment-editing-panel"},K(P,{key:"attachments"},t.render()),s.shouldAllowAttachmentEditing?K(W,{buttons:[{label:i.update,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:t.submitting,label:i.delete}]}):void 0):null}_renderReady(){const{EditorPanel:e,messages:t,viewModel:s,visibleElements:o}=this,i=this._helpMessage;return K(e,{heading:t.widgetLabel,key:"landing-panel"},K(P,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?K(L,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?K(L,{key:"create-actions"},this._renderCreateActions()):null]:K(I,{key:"no-content"},t.noEditableLayers)),i?K("div",{class:f.helpMessage,key:"footer-actions",slot:"footer"},i):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return K("div",{class:f.updateActions,key:"update-actions"},K(z,{level:N(this.headingLevel)},e.editFeatures),K("calcite-list",{class:f.updateActionsList,selectionAppearance:"border",selectionMode:"single"},R({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return K("div",{key:"create-actions"},K(z,{level:N(this.headingLevel)},this.messages.createFeatures),K("div",{class:f.featureTemplatesContainer,key:"templates"},this._featureTemplates.render()))}_renderFeatureList(){const{EditorPanel:e,viewModel:t}=this,{activeWorkflow:s}=t;if("update"!==s?.type)return null;const o=s.data.candidates,i=Q(this.messages.multipleFeaturesTemplate,{total:o.length});return K(e,{heading:i,key:"feature-list"},K(C,{editorItems:t.editorItems,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,s)=>t.selectFeature(e,s)}))}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}},r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}};e([d()],X.prototype,"_featureForm",void 0),e([d()],X.prototype,"_attachments",void 0),e([d()],X.prototype,"_featureTemplates",void 0),e([d()],X.prototype,"_filterText",void 0),e([d()],X.prototype,"_prompt",void 0),e([d()],X.prototype,"_spinner",void 0),e([d()],X.prototype,"_deleteButtonCommonInfo",null),e([d()],X.prototype,"_loading",null),e([d({readOnly:!0})],X.prototype,"activeWorkflow",null),e([d()],X.prototype,"allowedWorkflows",null),e([d()],X.prototype,"headingLevel",void 0),e([d()],X.prototype,"hideTemplatesForInactiveLayers",null),e([d()],X.prototype,"iconClass",void 0),e([d()],X.prototype,"label",null),e([d()],X.prototype,"labelOptions",null),e([d()],X.prototype,"layerInfos",null),e([d(),$("esri/widgets/Editor/t9n/Editor")],X.prototype,"messages",void 0),e([d(),$("esri/t9n/common")],X.prototype,"messagesCommon",void 0),e([d(),$("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],X.prototype,"messagesTemplates",void 0),e([d()],X.prototype,"snappingOptions",null),e([d()],X.prototype,"tooltipOptions",null),e([d()],X.prototype,"supportingWidgetDefaults",void 0),e([d({type:p,nonNullable:!0})],X.prototype,"valueOptions",null),e([d()],X.prototype,"view",null),e([d(),J(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],X.prototype,"viewModel",void 0),e([d({type:k,nonNullable:!0})],X.prototype,"visibleElements",void 0),e([d()],X.prototype,"_helpMessage",null),X=e([m("esri.widgets.Editor")],X);const Y=X;export{Y 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import C from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,getIntlOptionsForField as w,numberingSystem as R,prepareISOFieldValueForDateComponents as O,prepareUnixFieldValueForDateComponents as k,normalizeTimeOnlyString as I,getISOFieldValueFromDateComponents as M,getUnixFieldValueFromDateComponents as D}from"./support/dateUtils.js";import{globalCss as x}from"./support/globalCss.js";import{Heading as V,incrementHeadingLevel as N}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";const U="data-field-name";let S=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new C,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return j("div",{class:this.classes(p.base,x.widget,x.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return j("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&j(V,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&j("p",{class:p.description,key:"description"},e.formDescription);return j("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:j("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return j("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?N(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?E(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[j("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?j("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?j("label",{...s},r):j("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?j("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return j("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(i,t.value,{timeZone:this.timeZone,...w(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return j("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[U],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:R,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return j("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[U],key:`${a}-time-input`,numberingSystem:R,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:c,rawMin:u}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:R,overlayPositioning:"fixed",readOnly:d,[U]:i,onfocus:this._onComponentFocus},h=O(c,n),v=O(u,n),_=O(s,n);return j("div",{class:p.dateInputContainer,key:`${l}-date-time-container`},j("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),j("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:_.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?j("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:R,overlayPositioning:"fixed",readOnly:c,[U]:o,onfocus:this._onComponentFocus},h=k(a,u),v=k(l,u),_=k(d,u);return j("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?j("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return j("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>j("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(j("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[j("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),j("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);e.showNoValueOptionEnabled&&u.unshift(j("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:e.showNoValueLabel||a.empty,value:""}));const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return j("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return j("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[U],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return j("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return j("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},j("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?j("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return j("calcite-list-item",{description:E(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},j("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return j("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return j("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},j("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),j("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return j("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},j("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return j("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},j("span",null,e.label),t?j("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return j("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=E(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return j("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[U]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(U))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=e.value:"time-only"===o?(r=I(r),l=I(e.value)):l="timestamp-offset"===o?null!=e.value?M({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?D({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:o.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],S.prototype,"_listObserverNode",void 0),e([s()],S.prototype,"_relatedRecordsEnabled",null),e([s()],S.prototype,"disabled",null),e([s()],S.prototype,"feature",null),e([s()],S.prototype,"formTemplate",null),e([s()],S.prototype,"groupDisplay",void 0),e([s()],S.prototype,"headingLevel",void 0),e([s()],S.prototype,"label",null),e([s()],S.prototype,"layer",null),e([s()],S.prototype,"map",null),e([s(),L("esri/widgets/FeatureForm/t9n/FeatureForm")],S.prototype,"messages",void 0),e([s(),L("esri/t9n/common")],S.prototype,"messagesCommon",void 0),e([s(),L("esri/widgets/Feature/t9n/Feature")],S.prototype,"messagesFeature",void 0),e([s(),L("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],S.prototype,"messagesTemplates",void 0),e([s()],S.prototype,"relatedRecordCallbacks",null),e([s()],S.prototype,"relationshipId",null),e([s()],S.prototype,"spatialReference",null),e([s()],S.prototype,"strict",null),e([s()],S.prototype,"timeZone",null),e([s()],S.prototype,"view",null),e([s(),T(["value-change","submit"])],S.prototype,"viewModel",void 0),S=e([r("esri.widgets.FeatureForm")],S);const $=S;export{$ as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as c}from"./FeatureForm/css.js";import{isGroupInput as p,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as b,getIconForFeature as _,isNumberFieldInput as C}from"./FeatureForm/featureFormUtils.js";import g from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,getIntlOptionsForField as R,numberingSystem as w,prepareISOFieldValueForDateComponents as O,prepareUnixFieldValueForDateComponents as k,normalizeTimeOnlyString as x,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as V,incrementHeadingLevel as N}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";const S="data-field-name";let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new g,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._activeCombobox=null,this._activeComboboxClosedByWorkaround=!1,this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),this._onComboboxOpen=this._onComboboxOpen.bind(this),this._onComboboxClose=this._onComboboxClose.bind(this),this.onScroll=this.onScroll.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return j("div",{class:this.classes(c.base,D.widget,D.panel),onscroll:this.onScroll},"ready"===e?this._renderForm():null)}_renderForm(){return j("form",{class:c.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&j(V,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&j("p",{class:c.description,key:"description"},e.formDescription);return j("div",{class:c.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>p(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:j("div",{class:this.classes(c.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),h=p?.group===e,v=`${this.id}_group_${t}`,b="sequential"===this.groupDisplay;return j("calcite-block",{class:this.classes(c.group,b?c.groupSequential:null,h?c.groupActive:null,i?c.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?N(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(p(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?E(this.messages.requiredFieldLabel,{name:o}):o,class:c.label,key:`${n.id}-${i.uid}-${e.name}`},r=[j("div",{class:c.labelTextContent,key:"labelTextContainer"},o,a?j("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?j("label",{...s},r):j("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?j("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return j("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(i,t.value,{timeZone:this.timeZone,...R(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return j("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[S],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return j("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[S],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:u}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:w,overlayPositioning:"fixed",readOnly:d,[S]:i,onfocus:this._onComponentFocus},h=O(p,n),v=O(u,n),b=O(s,n);return j("div",{class:c.dateInputContainer,key:`${l}-date-time-container`},j("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),j("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:b.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?j("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:p}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:p,[S]:o,onfocus:this._onComponentFocus},h=k(a,u),v=k(l,u),b=k(d,u);return j("div",{class:c.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:b?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?j("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return j("calcite-input",{...i,class:this.classes(c.fieldInput,c.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>j("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[c,p]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&p.unshift(j("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=p.length>0?[j("calcite-combobox-item-group",{key:"recommended",label:a.recommended},c),j("calcite-combobox-item-group",{key:"other",label:s.other},p)]:c,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);e.showNoValueOptionEnabled&&u.unshift(j("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:e.showNoValueLabel||a.empty,value:""}));const b=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return j("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:b,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxBeforeOpen:this._onComboboxOpen,onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)},onCalciteComboboxClose:this._onComboboxClose},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return j("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:c.inputRadioGroup,"data-field-name":i[S],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return j("calcite-switch",{...t,checked:o,class:c.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return j("calcite-label",{class:c.inputRadioLabel,key:e,layout:"inline"},j("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:c.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?b(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?j("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return j("calcite-list-item",{description:E(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},j("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return j("calcite-button",{alignment:"center",appearance:"outline-fill",class:c.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return j("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:c,value:n},j("calcite-icon",{icon:_(i),scale:"m",slot:"content-start"}),j("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return j("calcite-label",{class:this.classes(c.label,c.relatedRecordsLabel),key:`relationship-${i}-container`},j("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return j("div",{class:c.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},j("span",null,e.label),t?j("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return j("calcite-list",{class:c.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=E(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return j("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:c.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:p,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(c.fieldInput,v?c.inputDisabled:null,h&&!u?c.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[S]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(S))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);C(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=e.value:"time-only"===o?(r=x(r),l=x(e.value)):l="timestamp-offset"===o?null!=e.value?I({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?M({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:o.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}_onComboboxClose(e){this._activeComboboxClosedByWorkaround||this._activeCombobox!==e.target||(this._activeCombobox=null)}_onComboboxOpen(e){this._activeComboboxClosedByWorkaround=!1,this._activeCombobox=e.target}onScroll(e){if(this._activeCombobox){const t=this._activeCombobox.getBoundingClientRect(),i=e.target.getBoundingClientRect();t.bottom>i.bottom?(this._activeComboboxClosedByWorkaround=!0,this._activeCombobox.open=!1):(this._activeComboboxClosedByWorkaround&&(this._activeCombobox.open=!0,this._activeComboboxClosedByWorkaround=!1),this._activeCombobox.reposition())}}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),L("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),L("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),L("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),L("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),T(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r("esri.widgets.FeatureForm")],U);const $=U;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/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 i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as E}from"../../intl/date.js";import{fetchMessageBundle as F}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await F("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await F("esri/t9n/common"),this.messagesURIUtils=await F("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}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 i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(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}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),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){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(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)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}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._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,initialSortPriority:c,invalid:p,menuConfig:y,sortable:f,textAlign:b}=e,_=a?.expressionInfos||null,{timeZone:w,timeZoneName:v}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==f,direction:m,editingEnabled:t,expressionInfos:_,field:h,formatFunction:g,grid:i,hidden:d,initialSortPriority:c,invalid:p,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:y,store:n,template:e,textAlign:b,timeZone:w,timeZoneName:v})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,E("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",null),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as E}from"../../intl/date.js";import{fetchMessageBundle as F}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await F("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await F("esri/t9n/common"),this.messagesURIUtils=await F("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&(await i.reset(),i.renderEmpty())),this._resetColumns(),e&&(this.store.layer=e,e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}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 i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}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}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),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){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(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)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}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._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,initialSortPriority:c,invalid:p,menuConfig:y,sortable:f,textAlign:b}=e,_=a?.expressionInfos||null,{timeZone:w,timeZoneName:v}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==f,direction:m,editingEnabled:t,expressionInfos:_,field:h,formatFunction:g,grid:i,hidden:d,initialSortPriority:c,invalid:p,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:y,store:n,template:e,textAlign:b,timeZone:w,timeZoneName:v})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,E("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as s}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as u}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),s((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){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 cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=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&&e.path)).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{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,b=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:b,autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,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()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}showColumn(e){this.viewModel?.showColumn(e)}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._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray();return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:"lazy",columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return this.columns.items.map(((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_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;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:s}=r;o&&s&&"details"!==s&&"header"!==s&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"cellPartNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),m("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n()],f.prototype,"multiSortEnabled",null),e([n()],f.prototype,"pageSize",null),e([n()],f.prototype,"rowDetailsRenderer",null),e([n()],f.prototype,"size",null),e([n({readOnly:!0})],f.prototype,"sortOrders",null),e([n()],f.prototype,"store",null),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;export{C as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as s}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as u}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this._forceEmptyRender=!1,this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),s((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){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 cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=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&&e.path)).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{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,y=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:y,autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,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()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}renderEmpty(){this._forceEmptyRender=!0,this.scheduleRender()}showColumn(e){this.viewModel?.showColumn(e)}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._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray(),t=this.columnPerformanceModeEnabled?"lazy":"eager";return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:t,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?this._forceEmptyRender?(this._forceEmptyRender=!1,null):[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_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;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:s}=r;o&&s&&"details"!==s&&"header"!==s&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"_forceEmptyRender",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"cellPartNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnPerformanceModeEnabled",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),m("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n()],f.prototype,"multiSortEnabled",null),e([n()],f.prototype,"pageSize",null),e([n()],f.prototype,"rowDetailsRenderer",null),e([n()],f.prototype,"size",null),e([n({readOnly:!0})],f.prototype,"sortOrders",null),e([n()],f.prototype,"store",null),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import o from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let i=class extends e{constructor(t){super(t),this.cellClassNameGenerator=null,this.cellPartNameGenerator=t=>this.findColumn(t?.path)?.invalid?"invalid":"",this.columnReorderingEnabled=!0,this.columns=new o,this.dataProvider=async(t,e)=>{const{store:o}=this;if(!e)return;if(!o)return void(e&&e([]));e(await o.fetchItems(t))},this.multiSortEnabled=!1,this.pageSize=50,this.rowDetailsRenderer=null,this.store=null}get highlightIds(){return this._get("highlightIds")||new o}set highlightIds(t){Array.isArray(t)?this._set("highlightIds",new o(t)):this._set("highlightIds",t)}get size(){return this.store?.count||0}get state(){const{store:t}=this;return t&&"disabled"!==t.state?"loading"===t.state?"loading":"loaded"===t.state?"loaded":"ready":"disabled"}closeColumnMenus(){this.columns?.forEach((t=>{t.menu&&t.menu.open&&t.menu.set("open",!1)}))}sortColumn(t,e){if(!t)return;const o=this.findColumn(t);o&&(o.direction=e)}hideColumn(t){const e=this.findColumn(t);!1===e?.hidden&&(e.hidden=!0)}showColumn(t){const e=this.findColumn(t);e?.hidden&&(e.hidden=!1)}showAllColumns(){this.columns?.forEach((t=>{t.hidden&&(t.hidden=!1)}))}findColumn(t){const e=[];return this.columns.forEach((t=>{e.push(t),"columns"in t&&t.columns?.forEach((t=>e.push(t)))})),e.find((e=>e.path===t))}getRowItemAt(t){return this.store?.getLocalItemAt(t)}refresh(){this.store&&(this.store.reset(),this.store.load())}};t([r()],i.prototype,"cellClassNameGenerator",void 0),t([r()],i.prototype,"cellPartNameGenerator",void 0),t([r()],i.prototype,"columnReorderingEnabled",void 0),t([r()],i.prototype,"columns",void 0),t([r()],i.prototype,"dataProvider",void 0),t([r()],i.prototype,"highlightIds",null),t([r()],i.prototype,"multiSortEnabled",void 0),t([r()],i.prototype,"pageSize",void 0),t([r()],i.prototype,"rowDetailsRenderer",void 0),t([r({readOnly:!0})],i.prototype,"size",null),t([r()],i.prototype,"store",void 0),t([r({readOnly:!0})],i.prototype,"state",null),i=t([s("esri.widgets.FeatureTable.Grid.GridViewModel")],i);const n=i;export{n as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import o from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let i=class extends t{constructor(e){super(e),this.cellClassNameGenerator=null,this.cellPartNameGenerator=e=>this.findColumn(e?.path)?.invalid?"invalid":"",this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new o,this.dataProvider=async(e,t)=>{const{store:o}=this;if(!t)return;if(!o)return void(t&&t([]));t(await o.fetchItems(e))},this.multiSortEnabled=!1,this.pageSize=50,this.rowDetailsRenderer=null,this.store=null}get highlightIds(){return this._get("highlightIds")||new o}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new o(e)):this._set("highlightIds",e)}get size(){return this.store?.count||0}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}closeColumnMenus(){this.columns?.forEach((e=>{e.menu&&e.menu.open&&e.menu.set("open",!1)}))}sortColumn(e,t){if(!e)return;const o=this.findColumn(e);o&&(o.direction=t)}hideColumn(e){const t=this.findColumn(e);!1===t?.hidden&&(t.hidden=!0)}showColumn(e){const t=this.findColumn(e);t?.hidden&&(t.hidden=!1)}showAllColumns(){this.columns?.forEach((e=>{e.hidden&&(e.hidden=!1)}))}findColumn(e){const t=[];return this.columns.forEach((e=>{t.push(e),"columns"in e&&e.columns?.forEach((e=>t.push(e)))})),t.find((t=>t.path===e))}getRowItemAt(e){return this.store?.getLocalItemAt(e)}refresh(){this.store&&(this.store.reset(),this.store.load())}};e([r()],i.prototype,"cellClassNameGenerator",void 0),e([r()],i.prototype,"cellPartNameGenerator",void 0),e([r()],i.prototype,"columnPerformanceModeEnabled",void 0),e([r()],i.prototype,"columnReorderingEnabled",void 0),e([r()],i.prototype,"columns",void 0),e([r()],i.prototype,"dataProvider",void 0),e([r()],i.prototype,"highlightIds",null),e([r()],i.prototype,"multiSortEnabled",void 0),e([r()],i.prototype,"pageSize",void 0),e([r()],i.prototype,"rowDetailsRenderer",void 0),e([r({readOnly:!0})],i.prototype,"size",null),e([r()],i.prototype,"store",void 0),e([r({readOnly:!0})],i.prototype,"state",null),i=e([s("esri.widgets.FeatureTable.Grid.GridViewModel")],i);const n=i;export{n 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedFunction as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{on as l,watch as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./FeatureTable/FeatureTableViewModel.js";import c from"./FeatureTable/Grid/support/ButtonMenu.js";import h from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{Heading as p}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{substitute as w}from"../intl/substitute.js";const M={header:!0,menu:!0,menuItems:{clearSelection:!0,refreshData:!0,toggleColumns:!0,selectedRecordsShowAllToggle:!0,selectedRecordsShowSelectedToggle:!0,zoomToSelection:!0,deleteSelection:!0},selectionColumn:!0,columnMenus:!0},y="esri-feature-table",_=`${y}__prompt`,E={base:y,header:`${y}__header`,title:`${y}__title`,content:`${y}__content`,loader:`${y}__loader`,loaderContainer:`${y}__loader-container`,menuContainer:`${y}__menu`,promptContainer:_,promptHeader:`${_}__header`,promptHeading:`${_}__header__heading`,promptMessage:`${_}__message`,promptDivider:`${_}__divider`,promptActions:`${_}__actions`};let f=class extends a{constructor(e,t){super(e,t),this._prompt=null,this.menu=null,this.menuConfig=null,this.viewModel=new d,this.visibleElements={...M},this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([l((()=>this.viewModel.columns),"change",(()=>this._syncMenuConfig())),l((()=>this.viewModel.activeFilters),"change",(()=>this._syncMenuConfig())),l((()=>this.highlightIds),"change",(e=>{this._syncMenuConfig(),this._onSelectionChange(e)})),s((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),s((()=>[this.menuConfig,this.editingEnabled]),(()=>this._syncMenuConfig())),s((()=>this.messages),(()=>{this.menu&&(this.menu.label=this.messages?.options),this._syncMenuConfig()}))]),this._set("menu",new c({label:this.messages?.options,iconClass:g.handleHorizontal,...this.menuConfig}));const{attachmentsEnabled:e,relatedRecordsEnabled:t}=this;this.viewModel?.store?.set({attachmentsEnabled:e,relatedRecordsEnabled:t})}loadDependencies(){return m({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._prompt=null,this.menu?.destroy()}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get highlightOnRowSelectEnabled(){return this.viewModel.highlightEnabled}set highlightOnRowSelectEnabled(e){this.viewModel.highlightEnabled=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=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 relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){const t={...M,...e};return this.grid?.set("visibleElements",{...this.grid.visibleElements,selectionColumn:t.selectionColumn,columnMenus:t.columnMenus}),t}clearSelection(){return t(i.getLogger(this),"`FeatureTable.clearSelection` is deprecated in favor of 'FeatureTable.highlightIds'",{replacement:"FeatureTable.highlightIds",version:"4.25",see:"https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#highlightIds"}),this.viewModel.clearSelection()}clearSelectionFilter(){return this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}deselectRows(e){return this.viewModel.deselectRows(e)}filterBySelection(){return this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e),this._syncMenuConfig()}refresh(){return this.viewModel.refresh()}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}showAllColumns(){return this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e),this._syncMenuConfig()}sortColumn(e,t){return this.viewModel.sortColumn(e,t)}selectRows(e){return this.viewModel.selectRows(e)}scrollToIndex(e){return this.viewModel.scrollToIndex(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e}=this,t=null!=e?v("calcite-scrim",null,this._renderPrompt(e)):null;return v("div",{bind:this,class:this.classes(E.base,u.widget)},this.visibleElements.header?this._renderHeader():null,v("div",{class:E.content},"disabled"!==this.state&&this.grid?.render()),t)}_renderPrompt({title:e,message:t,context:i,actions:l}){const s=v("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),o=l.secondary?v("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return v("div",{class:`${E.promptContainer}--${i}`},v("div",{class:E.promptHeader},v("calcite-icon",{icon:"exclamation-mark-triangle"}),v(p,{class:E.promptHeading,level:2},e)),v("div",{class:E.promptMessage},t),v("div",{class:E.promptDivider}),v("div",{class:E.promptActions},o,s))}_renderHeader(){return v("div",{class:E.header,key:"header"},this._renderLoader(),this._renderTitle(),this.visibleElements.menu?this._renderMenu():null)}_renderTitle(){return v("div",{class:E.title,key:"title"},this._getTitle())}_getTitle(){const{grid:e,highlightIds:t,layer:i,messages:l,viewModel:{size:s}}=this;return e&&i?w(l.header,{title:i.title,count:s,selected:t.length||0}):""}_renderLoader(){const{state:e,store:t}=this.viewModel,i="loading"===e||t.syncing||t.querying;return v("div",{class:E.loaderContainer},i?v("div",{class:E.loader,key:"loader"}):null)}_renderMenu(){return v("div",{class:E.menuContainer},this.menu?.render())}_onSelectionChange(e){const{added:t,removed:i}=e,l=t.map((e=>this.viewModel.store.getLocalItemByKey(e)||{objectId:e,feature:null,attachments:null,relatedRecords:null})),s=i.map((e=>this.viewModel.store.getLocalItemByKey(e)||{objectId:e,feature:null,attachments:null,relatedRecords:null}));this.emit("selection-change",{added:l,removed:s})}_syncMenuConfig(){this.menu?.set({...this.menuConfig,items:this._getMenuItems()})}_getMenuItems(){const e=this.menuConfig?.items,t=this._getDefaultMenuItems(),i=[];return t?.length&&i.push(...t),e?.length&&i.push(...e),i}_getDefaultMenuItems(){const{highlightIds:e,messages:t,viewModel:i,visibleElements:l}=this,{menuItems:s}=l,o=[];if(s?.refreshData&&o.push(new h({selectionEnabled:!1,label:t?.refreshData,clickFunction:()=>this.refresh()})),e.length){const i=this._getSelectionFilter();if(s?.clearSelection&&o.push(new h({selectionEnabled:!1,label:t?.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),s?.zoomToSelection&&this.view&&o.push(new h({selectionEnabled:!1,label:t?.zoomToSelection,clickFunction:()=>this.viewModel.zoomToSelection()})),s?.selectedRecordsShowSelectedToggle&&(!i||e.length!==i.objectIds.length)){const e=t.showSelected,i=new h({selectionEnabled:!1,label:e,clickFunction:()=>{this.filterBySelection(),i.set("label",e)}});o.push(i)}s?.deleteSelection&&this.editingEnabled&&this.layer?.capabilities?.operations?.supportsDelete&&o.push(new h({selectionEnabled:!1,label:t.deleteSelection,clickFunction:this._showDeletePrompt}))}if(s?.selectedRecordsShowAllToggle&&this._hasSelectionFilter()){const e=t.showAllRecords,i=new h({selectionEnabled:!1,label:e,clickFunction:()=>{this.clearSelectionFilter(),i.set("label",e)}});o.push(i)}return s?.toggleColumns&&o.push(new h({iconClass:g.right,label:t?.toggleColumns,clickFunction:this._toggleMenuItemSelectedIcon,items:i?.columns?.items.map((({header:e,hidden:t,path:i})=>new h({label:e||i,selected:!t,selectionEnabled:!0,iconClass:g.checkMark,clickFunction:()=>this._toggleColumnFromMenuItem(i)})))})),o.length?o:null}_toggleMenuItemSelectedIcon({item:e}){e?.set("iconClass",e?.selected?g.down:g.right)}_toggleColumnFromMenuItem(e){const{grid:t,viewModel:i}=this,l=i.findColumn(e);l?.hidden?t?.showColumn(e):t?.hideColumn(e)}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=this.highlightIds.length||0,l=w(e.deleteSelectionCount,{count:i});this.menu&&(this.menu.open=!1),this._prompt={title:l,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._prompt=null}}}}async _onDeleteSelectionClick(){await this.viewModel.deleteSelection(),this._prompt=null}_getSelectionFilter(){return this.viewModel.activeFilters?.find((e=>"selection"===e.type))}_hasSelectionFilter(){return!!this._getSelectionFilter()}};e([o({readOnly:!0})],f.prototype,"activeFilters",null),e([o({readOnly:!0})],f.prototype,"activeSortOrders",null),e([o()],f.prototype,"attachmentsEnabled",null),e([o()],f.prototype,"autoRefreshEnabled",null),e([o()],f.prototype,"columnReorderingEnabled",null),e([o({readOnly:!0})],f.prototype,"columns",null),e([o()],f.prototype,"editingEnabled",null),e([o()],f.prototype,"filterGeometry",null),e([o({readOnly:!0})],f.prototype,"grid",null),e([o()],f.prototype,"hiddenFields",null),e([o()],f.prototype,"highlightEnabled",null),e([o()],f.prototype,"highlightIds",null),e([o()],f.prototype,"highlightOnRowSelectEnabled",null),e([o()],f.prototype,"label",null),e([o()],f.prototype,"layer",null),e([o(),b("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",null),e([o(),b("esri/t9n/common")],f.prototype,"messagesCommon",null),e([o(),b("esri/widgets/support/t9n/uriUtils")],f.prototype,"messagesURIUtils",null),e([o({readOnly:!0})],f.prototype,"menu",void 0),e([o()],f.prototype,"menuConfig",void 0),e([o()],f.prototype,"multiSortEnabled",null),e([o()],f.prototype,"pageSize",null),e([o()],f.prototype,"relatedRecordsEnabled",null),e([o({readOnly:!0})],f.prototype,"state",null),e([o()],f.prototype,"tableTemplate",null),e([o()],f.prototype,"timeExtent",null),e([o()],f.prototype,"timeZone",null),e([o()],f.prototype,"view",null),e([o()],f.prototype,"viewModel",void 0),e([o()],f.prototype,"visibleElements",void 0),e([n("visibleElements")],f.prototype,"castVisibleElements",null),e([o()],f.prototype,"returnGeometryEnabled",null),f=e([r("esri.widgets.FeatureTable")],f);const S=f;export{S as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedFunction as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{on as l,watch as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./FeatureTable/FeatureTableViewModel.js";import c from"./FeatureTable/Grid/support/ButtonMenu.js";import h from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{Heading as p}from"./support/Heading.js";import{legacyIcon as g}from"./support/legacyIcon.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{substitute as w}from"../intl/substitute.js";const M={header:!0,menu:!0,menuItems:{clearSelection:!0,refreshData:!0,toggleColumns:!0,selectedRecordsShowAllToggle:!0,selectedRecordsShowSelectedToggle:!0,zoomToSelection:!0,deleteSelection:!0},selectionColumn:!0,columnMenus:!0},y="esri-feature-table",E=`${y}__prompt`,_={base:y,header:`${y}__header`,title:`${y}__title`,content:`${y}__content`,loader:`${y}__loader`,loaderContainer:`${y}__loader-container`,menuContainer:`${y}__menu`,promptContainer:E,promptHeader:`${E}__header`,promptHeading:`${E}__header__heading`,promptMessage:`${E}__message`,promptDivider:`${E}__divider`,promptActions:`${E}__actions`};let f=class extends a{constructor(e,t){super(e,t),this._prompt=null,this.menu=null,this.menuConfig=null,this.viewModel=new d,this.visibleElements={...M},this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([l((()=>this.viewModel.columns),"change",(()=>this._syncMenuConfig())),l((()=>this.viewModel.activeFilters),"change",(()=>this._syncMenuConfig())),l((()=>this.highlightIds),"change",(e=>{this._syncMenuConfig(),this._onSelectionChange(e)})),s((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),s((()=>[this.menuConfig,this.editingEnabled]),(()=>this._syncMenuConfig())),s((()=>this.messages),(()=>{this.menu&&(this.menu.label=this.messages?.options),this._syncMenuConfig()}))]),this._set("menu",new c({label:this.messages?.options,iconClass:g.handleHorizontal,...this.menuConfig}));const{attachmentsEnabled:e,relatedRecordsEnabled:t}=this;this.viewModel?.store?.set({attachmentsEnabled:e,relatedRecordsEnabled:t})}loadDependencies(){return m({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._prompt=null,this.menu?.destroy()}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get highlightOnRowSelectEnabled(){return this.viewModel.highlightEnabled}set highlightOnRowSelectEnabled(e){this.viewModel.highlightEnabled=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=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 relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){const t={...M,...e};return this.grid?.set("visibleElements",{...this.grid.visibleElements,selectionColumn:t.selectionColumn,columnMenus:t.columnMenus}),t}clearSelection(){return t(i.getLogger(this),"`FeatureTable.clearSelection` is deprecated in favor of 'FeatureTable.highlightIds'",{replacement:"FeatureTable.highlightIds",version:"4.25",see:"https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#highlightIds"}),this.viewModel.clearSelection()}clearSelectionFilter(){return this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}deselectRows(e){return this.viewModel.deselectRows(e)}filterBySelection(){return this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e),this._syncMenuConfig()}refresh(){return this.viewModel.refresh()}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}showAllColumns(){return this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e),this._syncMenuConfig()}sortColumn(e,t){return this.viewModel.sortColumn(e,t)}selectRows(e){return this.viewModel.selectRows(e)}scrollToIndex(e){return this.viewModel.scrollToIndex(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e}=this,t=null!=e?v("calcite-scrim",null,this._renderPrompt(e)):null;return v("div",{bind:this,class:this.classes(_.base,u.widget)},this.visibleElements.header?this._renderHeader():null,v("div",{class:_.content},"disabled"!==this.state&&this.grid?.render()),t)}_renderPrompt({title:e,message:t,context:i,actions:l}){const s=v("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),o=l.secondary?v("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return v("div",{class:`${_.promptContainer}--${i}`},v("div",{class:_.promptHeader},v("calcite-icon",{icon:"exclamation-mark-triangle"}),v(p,{class:_.promptHeading,level:2},e)),v("div",{class:_.promptMessage},t),v("div",{class:_.promptDivider}),v("div",{class:_.promptActions},o,s))}_renderHeader(){return v("div",{class:_.header,key:"header"},this._renderLoader(),this._renderTitle(),this.visibleElements.menu?this._renderMenu():null)}_renderTitle(){return v("div",{class:_.title,key:"title"},this._getTitle())}_getTitle(){const{grid:e,highlightIds:t,layer:i,messages:l,viewModel:{size:s}}=this;return e&&i?w(l.header,{title:i.title,count:s,selected:t.length||0}):""}_renderLoader(){const{state:e,store:t}=this.viewModel,i="loading"===e||t.syncing||t.querying;return v("div",{class:_.loaderContainer},i?v("div",{class:_.loader,key:"loader"}):null)}_renderMenu(){return v("div",{class:_.menuContainer},this.menu?.render())}_onSelectionChange(e){const{added:t,removed:i}=e,l=t.map((e=>this.viewModel.store.getLocalItemByKey(e)||{objectId:e,feature:null,attachments:null,relatedRecords:null})),s=i.map((e=>this.viewModel.store.getLocalItemByKey(e)||{objectId:e,feature:null,attachments:null,relatedRecords:null}));this.emit("selection-change",{added:l,removed:s})}_syncMenuConfig(){this.menu?.set({...this.menuConfig,items:this._getMenuItems()})}_getMenuItems(){const e=this.menuConfig?.items,t=this._getDefaultMenuItems(),i=[];return t?.length&&i.push(...t),e?.length&&i.push(...e),i}_getDefaultMenuItems(){const{highlightIds:e,messages:t,viewModel:i,visibleElements:l}=this,{menuItems:s}=l,o=[];if(s?.refreshData&&o.push(new h({selectionEnabled:!1,label:t?.refreshData,clickFunction:()=>this.refresh()})),e.length){const i=this._getSelectionFilter();if(s?.clearSelection&&o.push(new h({selectionEnabled:!1,label:t?.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),s?.zoomToSelection&&this.view&&o.push(new h({selectionEnabled:!1,label:t?.zoomToSelection,clickFunction:()=>this.viewModel.zoomToSelection()})),s?.selectedRecordsShowSelectedToggle&&(!i||e.length!==i.objectIds.length)){const e=t.showSelected,i=new h({selectionEnabled:!1,label:e,clickFunction:()=>{this.filterBySelection(),i.set("label",e)}});o.push(i)}s?.deleteSelection&&this.editingEnabled&&this.layer?.capabilities?.operations?.supportsDelete&&o.push(new h({selectionEnabled:!1,label:t.deleteSelection,clickFunction:this._showDeletePrompt}))}if(s?.selectedRecordsShowAllToggle&&this._hasSelectionFilter()){const e=t.showAllRecords,i=new h({selectionEnabled:!1,label:e,clickFunction:()=>{this.clearSelectionFilter(),i.set("label",e)}});o.push(i)}return s?.toggleColumns&&o.push(new h({iconClass:g.right,label:t?.toggleColumns,clickFunction:this._toggleMenuItemSelectedIcon,items:i?.columns?.items.map((({header:e,hidden:t,path:i})=>new h({label:e||i,selected:!t,selectionEnabled:!0,iconClass:g.checkMark,clickFunction:()=>this._toggleColumnFromMenuItem(i)})))})),o.length?o:null}_toggleMenuItemSelectedIcon({item:e}){e?.set("iconClass",e?.selected?g.down:g.right)}_toggleColumnFromMenuItem(e){const{grid:t,viewModel:i}=this,l=i.findColumn(e);l?.hidden?t?.showColumn(e):t?.hideColumn(e)}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=this.highlightIds.length||0,l=w(e.deleteSelectionCount,{count:i});this.menu&&(this.menu.open=!1),this._prompt={title:l,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._prompt=null}}}}async _onDeleteSelectionClick(){await this.viewModel.deleteSelection(),this._prompt=null}_getSelectionFilter(){return this.viewModel.activeFilters?.find((e=>"selection"===e.type))}_hasSelectionFilter(){return!!this._getSelectionFilter()}};e([o({readOnly:!0})],f.prototype,"activeFilters",null),e([o({readOnly:!0})],f.prototype,"activeSortOrders",null),e([o()],f.prototype,"attachmentsEnabled",null),e([o()],f.prototype,"autoRefreshEnabled",null),e([o()],f.prototype,"columnPerformanceModeEnabled",null),e([o()],f.prototype,"columnReorderingEnabled",null),e([o({readOnly:!0})],f.prototype,"columns",null),e([o()],f.prototype,"editingEnabled",null),e([o()],f.prototype,"filterGeometry",null),e([o({readOnly:!0})],f.prototype,"grid",null),e([o()],f.prototype,"hiddenFields",null),e([o()],f.prototype,"highlightEnabled",null),e([o()],f.prototype,"highlightIds",null),e([o()],f.prototype,"highlightOnRowSelectEnabled",null),e([o()],f.prototype,"label",null),e([o()],f.prototype,"layer",null),e([o(),b("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",null),e([o(),b("esri/t9n/common")],f.prototype,"messagesCommon",null),e([o(),b("esri/widgets/support/t9n/uriUtils")],f.prototype,"messagesURIUtils",null),e([o({readOnly:!0})],f.prototype,"menu",void 0),e([o()],f.prototype,"menuConfig",void 0),e([o()],f.prototype,"multiSortEnabled",null),e([o()],f.prototype,"pageSize",null),e([o()],f.prototype,"relatedRecordsEnabled",null),e([o({readOnly:!0})],f.prototype,"state",null),e([o()],f.prototype,"tableTemplate",null),e([o()],f.prototype,"timeExtent",null),e([o()],f.prototype,"timeZone",null),e([o()],f.prototype,"view",null),e([o()],f.prototype,"viewModel",void 0),e([o()],f.prototype,"visibleElements",void 0),e([n("visibleElements")],f.prototype,"castVisibleElements",null),e([o()],f.prototype,"returnGeometryEnabled",null),f=e([r("esri.widgets.FeatureTable")],f);const S=f;export{S as default};