@arcgis/core 5.0.0-next.57 → 5.0.0-next.58

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 (87) hide show
  1. package/applications/Components/arcadeFeatureUtils.d.ts +20 -1
  2. package/applications/Components/arcadeFeatureUtils.js +1 -1
  3. package/arcade.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/18ce7b1559a45d017c45.js +1 -0
  6. package/assets/esri/core/workers/chunks/3405a23973f9e701a4d6.js +1 -0
  7. package/assets/esri/core/workers/chunks/352c674730c7b7258ae3.js +1 -0
  8. package/assets/esri/core/workers/chunks/62752cd6821959cf6751.js +1 -0
  9. package/assets/esri/core/workers/chunks/72e3a48aa365542b0689.js +1 -0
  10. package/assets/esri/core/workers/chunks/a6b1e3ec30f6d641aea9.js +1 -0
  11. package/assets/esri/core/workers/chunks/{da2c41ac0f82f32013c1.js → a7aa87e2c4197ba595ef.js} +10 -10
  12. package/assets/esri/core/workers/chunks/{d76513a6260d9ec4ea25.js → bf82bb1cdd8b31e7f2aa.js} +1 -1
  13. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  14. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  15. package/assets/esri/themes/base/widgets/_FeatureTable.scss +24 -0
  16. package/assets/esri/themes/dark/main.css +1 -1
  17. package/assets/esri/themes/light/main.css +1 -1
  18. package/assets/esri/themes/light/view.css +1 -1
  19. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  20. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  21. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_fr.json +1 -1
  22. package/config.js +1 -1
  23. package/core/workers/workerFactory.js +1 -1
  24. package/editing/sharedTemplates/executor/builders/offsetLine.js +1 -1
  25. package/editing/sharedTemplates/executor/builders/offsetPrimaryLine.js +1 -1
  26. package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
  27. package/editing/sharedTemplates/executor/builders/polygonBoundaryTwoPoint.js +1 -1
  28. package/editing/sharedTemplates/executor/builders/polygonVertices.js +1 -1
  29. package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
  30. package/editing/sharedTemplates/executor/builders/support/shapeUtils.js +1 -1
  31. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
  32. package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +1 -1
  33. package/geometry/projection/projectBoundingSphere.js +1 -1
  34. package/geometry/support/curves/curveUtils.js +1 -1
  35. package/geometry/support/sphere.js +1 -1
  36. package/kernel.js +1 -1
  37. package/layers/KnowledgeGraphLayer.js +1 -1
  38. package/layers/LinkChartLayer.js +1 -1
  39. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  40. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  41. package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +1 -1
  42. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  43. package/layers/knowledgeGraph/layerUtils.js +1 -1
  44. package/package.json +2 -2
  45. package/support/revision.js +1 -1
  46. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  47. package/views/2d/engine/webgl/Painter.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/graph/GlslGraphWriter.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  52. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  53. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  54. package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
  55. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  56. package/views/3d/layers/I3SMeshView3D.js +1 -1
  57. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  58. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  59. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  60. package/views/3d/layers/i3s/I3SNode.js +1 -1
  61. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  62. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  63. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  64. package/views/3d/support/ElevationRange.js +1 -1
  65. package/views/3d/terrain/TerrainSurface.js +1 -1
  66. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js +1 -1
  67. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  68. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  69. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  70. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +44 -3
  71. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  72. package/widgets/FeatureTable/FieldColumn.js +1 -1
  73. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  74. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  75. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  76. package/widgets/FeatureTable/VisibleElements.d.ts +2 -2
  77. package/widgets/FeatureTable/VisibleElements.js +1 -1
  78. package/widgets/FeatureTable/support/FeatureStore.d.ts +1 -0
  79. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  80. package/widgets/FeatureTable.d.ts +46 -5
  81. package/widgets/FeatureTable.js +1 -1
  82. package/assets/esri/core/workers/chunks/30184e39129d9c66ea54.js +0 -1
  83. package/assets/esri/core/workers/chunks/5340887a4a48bde3407a.js +0 -1
  84. package/assets/esri/core/workers/chunks/537de53ef1e9101468f5.js +0 -1
  85. package/assets/esri/core/workers/chunks/94f02082a006003ef5a9.js +0 -1
  86. package/assets/esri/core/workers/chunks/d3db7244fac7398cc700.js +0 -1
  87. package/assets/esri/core/workers/chunks/d94a2ad5a91de7086fbe.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as l}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import{referenceSetter as r}from"../../core/collectionUtils.js";import{deprecatedFunction as n}from"../../core/deprecate.js";import a from"../../core/Error.js";import h from"../../core/Handles.js";import d from"../../core/Logger.js";import{abortMaybe as m}from"../../core/maybe.js";import{debounce as c,ignoreAbortErrors as p,after as u,throwIfAborted as g,createResolver as b}from"../../core/promiseUtils.js";import{watch as f,on as y,initial as T}from"../../core/reactiveUtils.js";import{throttle as w}from"../../core/throttle.js";import{property as _,subclass as C}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as I}from"../../editing/fieldUtils.js";import{geometryTypes as v}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as E}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as A,isSubtypeGroupLayer as F}from"../../layers/support/layerUtils.js";import{createFieldInfos as S}from"../../support/popupUtils.js";import j from"../../tables/AttributeTableTemplate.js";import R from"../../tables/support/FieldOrder.js";import x from"../../time/TimeExtent.js";import{defaultHighlightName as U,temporaryHighlightName as O}from"../../views/support/HighlightDefaults.js";import{highlightsSupported as V}from"../../views/support/layerViewUtils.js";import{isISelectableLayerWithObjectIds as z}from"../../views/support/selectionUtils.js";import W from"./ActionColumn.js";import P from"./AttachmentsColumn.js";import H from"./FieldColumn.js";import L from"./RelationshipColumn.js";import B from"./Grid/Column.js";import G from"./Grid/Grid.js";import k from"./Grid/GridViewModel.js";import N from"./Grid/GroupColumn.js";import D from"./support/AttachmentsColumnTemplate.js";import M from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as $,isFieldColumn as Z,isRelationshipColumn as q}from"./support/columnUtils.js";import{downloadAttachmentInfo as Q,exportToCSV as K}from"./support/exportUtils.js";import J from"./support/FeatureStore.js";import X from"./support/FieldColumnTemplate.js";import Y from"./support/RelationshipColumnTemplate.js";import ee from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as te,isIFeatureTableSupportedLayerWithRelationships as ie,findRelatedLayerInSources as se,findRelationship as le,uniqueColumnNames as oe,hasColumnForField as re,findField as ne,isIFeatureTableSupportedLayerWithAttachments as ae,getTableHighlightKey as he,getRelationshipIdsToShow as de}from"./support/tableUtils.js";import{createAttributeTableElements as me}from"./support/templateUtils.js";import{goTo as ce}from"../support/goToUtils.js";import{messageBundle as pe}from"../support/widget.js";const ue="80px";let ge=class extends k{constructor(e){super(e),this._currentTemporaryHighlight=null,this._highlights=new h,this._refreshDebounced=c(()=>this._refresh()),this._syncTemplateThrottled=w(()=>this._syncAttributeTableTemplate()),this._temporaryHighlightAbortController=null,this.attachmentsViewOptions=new M,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new o,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:l}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===l.length&&-1===l.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const o=this.paginationEnabled?this.pageIndex:e.page,r=await s.fetchItems({...e,page:o});t&&t(r)},this.grid=null,this.highlightEnabled=!0,this.layers=null,this.maxSize=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new o,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new J),this._set("grid",new G({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),f(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},T),y(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),f(()=>this.grid?.temporaryHighlightId,e=>{this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController,p(this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal))}),f(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),f(()=>this._viewSelection,()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}),f(()=>[this._tableHighlightsReady,this._viewSelectionReady],()=>this._syncSelection()),f(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch(()=>{})),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),f(()=>this.layer?.loaded,e=>e&&this._onLayerLoad()),f(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),f(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),f(()=>this.editingEnabled,()=>this.refreshCellContent()),f(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),f(()=>this.store.effectiveWhere,()=>"loaded"===this.store.state&&this.reset()),f(()=>this.layer?.timeExtent,(e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset()),y(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),y(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:l})=>{const o=t?.feature,r=o?.getObjectId(),n="cell-keydown"===l&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(l,{feature:o,index:e,native:i,type:l,fieldName:s??void 0,objectId:r}),(n||"cell-click"===l)&&this._onCellInteraction(r)}),f(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),f(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),y(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),f(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),f(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),f(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),f(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),f(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),y(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:l}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:l}}),y(()=>this.tableParent,"cell-click",e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)}),f(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),f(()=>this.layerFieldConfigurations,()=>this.refreshCellContent())])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this._currentTemporaryHighlight?.handle.remove(),this._temporaryHighlightAbortController=m(this._temporaryHighlightAbortController),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return E(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _highlightableLayerView(){const e=this.layerView;return V(e)?e:null}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return z(e)&&this._selectionManager?.sources?.includes(e)?e:null}get _subtypes(){return A(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,l=new o;return e&&l.push({type:"geometry",geometry:e}),i?l.push({type:"selection",objectIds:s.toArray()}):t.length&&l.push({type:"objectId",objectIds:t.toArray()}),l}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>$(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSize(){return super.effectiveSize}get fieldColumns(){return this.allColumns.filter(e=>Z(e))}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hiddenFields(){return this._get("hiddenFields")??new o}set hiddenFields(e){this._set("hiddenFields",r(e,this._get("hiddenFields"),o))}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this._highlights.removeAll(),this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return te(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find(({id:t})=>t===e)}get relationshipColumns(){return this.allColumns.filter(e=>q(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,l=this.store.relationshipInfos;if(l.length||!ie(e)||!i?.length)return l;const o=[],r=s?.layers||t||[];return i.forEach(t=>{const i=se(e,r,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),o}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:l}=t,{objectIdField:r}=i,n=le(i,l),a=i.displayField||n?.keyField||r;e.set({highlightIds:new o([s]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,l)});const h=e.hiddenFields;h.includes(oe.action)||h.add(oe.action),h.includes(oe.attachments)||h.add(oe.attachments),e.scrollLeft()}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.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await Q(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([oe.action,oe.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await K({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(n(d.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(oe.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),p(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const l=this._getDefaultLayerDisplayField(s),r=await this.store.getAttachmentsByObjectId(e,!0),n=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:r,mode:r.length?"list":"file",objectId:e}),this.set({highlightIds:new o([e]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(l)}),i.includes(oe.action)||i.add(oe.action),null!=n&&this.scrollToIndex(n)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}clearSelectionFilter(){n(d.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,o=s.objectId===e;await l.updateAttachment(e,t,i).catch(e=>{o&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),o&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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 l=await e.queryFeatures(s);try{await ce(t,l.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:l}=this;if(!i||!t||!l&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId)return;const{activeSortOrders:o,allColumns:r,columns:n}=this,a=[],h=me(n.toArray());o.forEach(({fieldName:e,direction:t})=>{e&&t&&a.push(new R({field:e,order:t}))}),r.forEach(({fieldName:e,direction:t})=>{t&&!a.some(t=>t.field===e)&&a.push(new R({field:e,order:t}))}),t.elements=h,t.orderByFields=a}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&F(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,l=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=l),this.grid?.set("pageSize",l),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t}=this,i=e?.columnTemplates,s=this._generateColumnsFromColumnTemplates(i)??this._generateColumnsFromAttributeTableTemplate(t)??this._generateDefaultFieldColumns();s.length&&(this.attachmentsEnabled&&!s.some(e=>$(e))&&s.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!s.some(e=>q(e))&&s.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&s.push(this._generateActionColumn()),s.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(s))}_generateColumnsFromAttributeTableTemplate(e){const{layer:t}=this;if(!e||!t)return null;const{elements:i,orderByFields:s}=e,o=S(t),r=[];r.push(...this._generateColumnsFromAttributeTableElements(i,s));const n=o.map(e=>{if(!e.fieldName||re(e.fieldName,r))return null;const{fieldName:i}=e,l=ne(t,i);return l?this._generateDefaultFieldColumn(l,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(l);return r.push(...n),this.attachmentsEnabled&&ae(t)&&!r.some(e=>$(e))&&r.push(this._generateDefaultAttachmentsColumn({hidden:!0})),this.relatedRecordsEnabled&&ie(t)&&t.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!r.some(t=>q(t)&&t.relationshipId===e)&&r.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),r.length?r:null}_generateColumnsFromAttributeTableElements(e,t){const{layer:i}=this;return i?e?.map((e,i)=>{switch(e.type){case"field":return this._createFieldColumnFromElement({element:e,orderByFields:t});case"group":return this._createGroupColumnFromElement({element:e,orderByFields:t});case"attachment":return this._createAttachmentColumnFromElement({element:e,index:i});case"relationship":return this._createRelationshipColumnFromElement({element:e,index:i})}}).filter(e=>!!e)??[]:[]}_createFieldColumnFromElement(e){const{layer:t}=this;if(!t)return null;const{element:i,orderByFields:s}=e,{fieldName:l}=i;if(null==l)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const o=ne(t,l);if(!o)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:r,label:n}=i,a=s?.findIndex(({field:e})=>e&&e===l)??-1,h=a>-1?s?.at(a)?.order:void 0,d=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b}=this;return new H({description:r,direction:h,field:o,fieldName:l,grid:m,initialSortPriority:d,label:n,layer:t,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{element:t,orderByFields:i}=e,{description:s,label:l}=t;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!t.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:o,messages:r,messagesCommon:n,messagesURIUtils:a,store:h}=this;return new N({columns:this._generateColumnsFromAttributeTableElements(t.elements,i),description:s,grid:o,label:l,messages:r,messagesCommon:n,messagesURIUtils:a,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{element:t,index:i}=e,{description:s,label:l}=t,{grid:o,layer:r,messages:n,messagesCommon:a,messagesURIUtils:h,store:d}=this;return new P({description:s,fieldName:`${oe.attachments}-${i}`,grid:o,label:l,layer:r,messages:n,messagesCommon:a,messagesURIUtils:h,store:d,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:l,relationshipId:o}=t,r=this.relationshipInfos.find(e=>e.relationshipId===o);if(!r)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:n,messages:a,messagesCommon:h,messagesURIUtils:d,store:m}=this;return new L({description:s,fieldName:`${oe.relationship}-${o}-${i}`,grid:n,label:l,messages:a,messagesCommon:h,messagesURIUtils:d,relationshipId:o,store:m,layer:r.relatedLayer,relatedLayer:r.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:r,view:n}=this;if(!e?.length||!i)return null;const a=[];return e.forEach((e,h)=>{const{autoWidth:d,description:m,direction:c,flexGrow:p,fieldName:u,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,menuConfig:v,resizable:E,sortable:A,textAlign:F,textWrap:S,timeZone:j,type:R,width:x}=e;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const U=!1===e.visible;if("group"===R){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const i=this._generateColumnsFromColumnTemplates(e.columnTemplates),r=U||this._isFieldHidden(e.label);a.push(new N({autoWidth:d,columns:i,description:m,flexGrow:p,frozen:b,frozenToEnd:f,grid:t,hidden:r,icon:y,iconText:T,invalid:_,label:C,labelTooltipText:I,menuConfig:v,messages:s,messagesCommon:l,messagesURIUtils:o,resizable:E,textAlign:F,textWrap:S,timeZone:j,width:x}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,h))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(e=>e.relationshipId===t);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,e,h))}else if(!u)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const O=U||this._isFieldHidden(u);if("column"===R)a.push(new B({autoWidth:d,description:m,direction:c,fieldName:u,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:t,hidden:O,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,menuConfig:v,messages:s,messagesCommon:l,messagesURIUtils:o,resizable:E,sortable:A,textAlign:F,textWrap:S,timeZone:j,width:x}));else if("field"===R){const h=ne(i,e.fieldName);if(!h)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:u,required:R}=e;a.push(new H({autoWidth:d,description:m,direction:c,editable:u,field:h,fieldName:h.name,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:t,hidden:O,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,menuConfig:v,required:R,resizable:E,sortable:A,store:r,template:e,textAlign:F,textWrap:S,timeZone:j,width:x,view:n,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(){return this.layer?.fields?.map(e=>this._generateDefaultFieldColumn(e)).filter(l)??[]}_generateDefaultFieldColumn(e,t){const{grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:r,store:n,view:a}=this,h=t?.orderByFields;if(!e.visible||"geometry"===e.type)return null;const d=e.name,m=h?.findIndex(({field:e})=>e&&e===d)??-1,c=m>-1?h?.at(m)?.order:void 0,p=m>-1?m:void 0;return new H({direction:c,field:e,fieldName:d,grid:i,hidden:t?.hidden||this._isFieldHidden(d),initialSortPriority:p,layer:s,messages:l,messagesCommon:o,messagesURIUtils:r,store:n,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:r,store:n}=this,{attachmentsViewEnabled:a,autoWidth:h,description:d,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,resizable:C,textAlign:I,textWrap:v,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:S,timeZone:j,width:R}=e;return new P({attachmentsViewEnabled:a,autoWidth:h,description:d,fieldName:`${oe.attachments}-${t}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:i,hidden:!1===e.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:s,menuConfig:_,messages:l,messagesCommon:o,messagesURIUtils:r,resizable:C,store:n,textAlign:I,textWrap:v,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:S,timeZone:j,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:r}=this,n=oe.attachments;return new P({fieldName:n,grid:t,hidden:e?.hidden||this._isFieldHidden(n),layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:r,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:l,messagesCommon:o,messagesURIUtils:r,store:n}=this,{autoWidth:a,collapsed:h,description:d,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,relationshipId:C,resizable:I,textAlign:v,textWrap:E,timeZone:A,width:F}=t;return new L({autoWidth:a,collapsed:h,description:d,fieldName:`${oe.relationship}-${C}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,messages:l,messagesCommon:o,messagesURIUtils:r,relationshipId:C,resizable:I,store:n,textAlign:v,textWrap:E,timeZone:A,width:F,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:l}=t,o=e.find(e=>e.relationshipId===l);o&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:o}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:l}=e,{grid:o,messages:r,messagesCommon:n,messagesURIUtils:a}=this,{relationshipId:h}=l;return new L({...t,fieldName:`${oe.relationship}-${h}-${s}`,grid:o,hidden:i,messages:r,messagesCommon:n,messagesURIUtils:a,layer:l.relatedLayer,relatedLayer:l.layer,relationshipId:h,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){return new W({hidden:this._isFieldHidden(oe.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_addTableHighlight(e){if(!this.highlightEnabled)return;const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),l=s?.feature??e;this._highlights.add(t.highlight(l,{name:U}),he(i,e))}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(he(t,e))}async _syncTemporaryHighlight(e,t){if(!this.highlightEnabled)return this._currentTemporaryHighlight?.handle.remove(),void(this._currentTemporaryHighlight=null);if(await u(25),g(t),!this._currentTemporaryHighlight&&!e)return;const{id:i}=this._currentTemporaryHighlight??{};if(i===e)return;this._currentTemporaryHighlight?.handle?.remove(),this._currentTemporaryHighlight=null;const{_highlightableLayerView:s,layer:l,highlightEnabled:o}=this;e&&s&&l&&o&&(this._currentTemporaryHighlight={id:e,handle:s.highlight(e,{name:O})})}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach(e=>this._addTableHighlight(e)):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.add(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach(e=>this._removeTableHighlight(e)),t.forEach(e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(oe.action)||s.add(oe.action),s.includes(oe.attachments)||s.add(oe.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:de(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([oe.action,oe.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new ee({columnTemplates:[new X({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,l])=>({selected:s===t,label:l||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new Y({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ue})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new X({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new D({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ue})),new ee({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:l}=e,{_subtypes:o,layer:r}=this;if(!r||!o.length)return void t.cancel();const n=o.find(e=>e.code===l);if(!n)return void t.cancel();const a=b(),h=this._createSubtypeEditPrompt(s,n,a),d=!!r.parent;try{this.showPrompt(h);const e=await a.promise,s=[{fieldName:t.fieldName,value:l}];switch(e){case"update-fields":for(const[e,t]of Object.entries(n.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),d&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),d&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:l,messages:o,messagesCommon:r}=this,n=l.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const h=[{label:o.subtypes.useDefaultValuesOption,value:"update-fields"},{label:o.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:o.subtypes.changeWarningTitle,message:i(o.subtypes.changeWarning,{originalType:n,newType:t.name}),radios:h,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:r.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new ee({columnTemplates:[new X({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new D({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ue})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&I(s,i)]}):i?.fields.map(e=>[e.name,I(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?d.getLogger(this).warnOnce(e):d.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([_()],ge.prototype,"_defaultHiddenFields",null),e([_()],ge.prototype,"_effectiveTableTemplate",null),e([_()],ge.prototype,"_effectiveAttributeTableTemplate",null),e([_()],ge.prototype,"_highlights",void 0),e([_()],ge.prototype,"_highlightableLayerView",null),e([_()],ge.prototype,"_selectionManager",null),e([_()],ge.prototype,"_selectableLayer",null),e([_()],ge.prototype,"_subtypes",null),e([_()],ge.prototype,"_tableHighlightsReady",null),e([_()],ge.prototype,"_viewSelection",null),e([_()],ge.prototype,"_viewSelectionReady",null),e([_()],ge.prototype,"activeFilters",null),e([_({readOnly:!0})],ge.prototype,"activeSortOrders",null),e([_()],ge.prototype,"allRelatedTablesVisible",null),e([_()],ge.prototype,"attachmentsColumns",null),e([_()],ge.prototype,"attachmentsEnabled",null),e([_()],ge.prototype,"attachmentsViewOptions",void 0),e([_({type:j})],ge.prototype,"attributeTableTemplate",void 0),e([_()],ge.prototype,"autoRefreshEnabled",void 0),e([_()],ge.prototype,"clearPrompt",null),e([_({readOnly:!0})],ge.prototype,"columns",void 0),e([_()],ge.prototype,"dataProvider",void 0),e([_()],ge.prototype,"definitionExpression",null),e([_()],ge.prototype,"fieldColumns",null),e([_({types:v})],ge.prototype,"filterGeometry",null),e([_()],ge.prototype,"filterBySelectionEnabled",null),e([_({readOnly:!0})],ge.prototype,"grid",void 0),e([_()],ge.prototype,"hiddenFields",null),e([_()],ge.prototype,"highlightEnabled",void 0),e([_()],ge.prototype,"initialSize",null),e([_()],ge.prototype,"isQueryingOrSyncing",null),e([_()],ge.prototype,"isSyncingAttachments",null),e([_()],ge.prototype,"layer",null),e([_()],ge.prototype,"layers",void 0),e([_()],ge.prototype,"layerFieldConfigurations",null),e([_()],ge.prototype,"layerView",null),e([_()],ge.prototype,"menuConfig",void 0),e([_()],ge.prototype,"messages",void 0),e([_(),pe("esri/t9n/common")],ge.prototype,"messagesCommon",void 0),e([_(),pe("esri/core/t9n/Units")],ge.prototype,"messagesUnits",void 0),e([_(),pe("esri/widgets/support/t9n/uriUtils")],ge.prototype,"messagesURIUtils",void 0),e([_()],ge.prototype,"outFields",null),e([_()],ge.prototype,"prompt",void 0),e([_()],ge.prototype,"relatedRecordsEnabled",null),e([_()],ge.prototype,"relatedTable",null),e([_()],ge.prototype,"relatedTables",void 0),e([_()],ge.prototype,"relationship",null),e([_()],ge.prototype,"relationshipColumnConfigs",void 0),e([_()],ge.prototype,"relationshipColumns",null),e([_()],ge.prototype,"relationshipConfig",null),e([_()],ge.prototype,"relationshipInfos",null),e([_()],ge.prototype,"relationships",null),e([_()],ge.prototype,"returnGeometryEnabled",null),e([_()],ge.prototype,"returnMEnabled",null),e([_()],ge.prototype,"returnZEnabled",null),e([_()],ge.prototype,"selectionSource",void 0),e([_()],ge.prototype,"showAllRelatedTables",null),e([_()],ge.prototype,"showPrompt",null),e([_()],ge.prototype,"showRelatedTableCallback",void 0),e([_({readOnly:!0,type:J})],ge.prototype,"store",void 0),e([_()],ge.prototype,"supportsAttachments",null),e([_()],ge.prototype,"supportsAddAttachments",null),e([_()],ge.prototype,"supportsDeleteAttachments",null),e([_()],ge.prototype,"supportsResizeAttachments",null),e([_()],ge.prototype,"supportsUpdateAttachments",null),e([_()],ge.prototype,"syncTemplateOnChangesEnabled",void 0),e([_()],ge.prototype,"tableController",void 0),e([_()],ge.prototype,"tableParent",void 0),e([_({type:ee})],ge.prototype,"tableTemplate",void 0),e([_()],ge.prototype,"tableTemplateOverride",void 0),e([_({type:x})],ge.prototype,"timeExtent",null),e([_()],ge.prototype,"timeZone",null),e([_()],ge.prototype,"view",null),ge=e([C("esri.widgets.FeatureTable.FeatureTableViewModel")],ge);const be=ge;export{be as default};
5
+ import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as l}from"../../core/arrayUtils.js";import n from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import a from"../../core/Error.js";import h from"../../core/Handles.js";import d from"../../core/Logger.js";import{abortMaybe as m}from"../../core/maybe.js";import{debounce as c,ignoreAbortErrors as p,after as u,throwIfAborted as g,createResolver as b}from"../../core/promiseUtils.js";import{watch as f,on as y,initial as T}from"../../core/reactiveUtils.js";import{throttle as w}from"../../core/throttle.js";import{property as _,subclass as C}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as I}from"../../editing/fieldUtils.js";import{geometryTypes as v}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as E}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as A,isSubtypeGroupLayer as S}from"../../layers/support/layerUtils.js";import{createFieldInfos as F}from"../../support/popupUtils.js";import j from"../../tables/AttributeTableTemplate.js";import R from"../../tables/support/FieldOrder.js";import x from"../../time/TimeExtent.js";import{defaultHighlightName as U,temporaryHighlightName as O}from"../../views/support/HighlightDefaults.js";import{highlightsSupported as V}from"../../views/support/layerViewUtils.js";import{isISelectableLayerWithObjectIds as P}from"../../views/support/selectionUtils.js";import z from"./ActionColumn.js";import W from"./AttachmentsColumn.js";import H from"./FieldColumn.js";import L from"./RelationshipColumn.js";import B from"./Grid/Column.js";import G from"./Grid/Grid.js";import k from"./Grid/GridViewModel.js";import N from"./Grid/GroupColumn.js";import D from"./support/AttachmentsColumnTemplate.js";import M from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as $,isFieldColumn as Z,isRelationshipColumn as q}from"./support/columnUtils.js";import{downloadAttachmentInfo as Q,exportToCSV as K}from"./support/exportUtils.js";import J from"./support/FeatureStore.js";import X from"./support/FieldColumnTemplate.js";import Y from"./support/RelationshipColumnTemplate.js";import ee from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as te,isIFeatureTableSupportedLayerWithRelationships as ie,findRelatedLayerInSources as se,findRelationship as le,uniqueColumnNames as ne,hasColumnForField as oe,findField as re,isIFeatureTableSupportedLayerWithAttachments as ae,getTableHighlightKey as he,getRelationshipIdsToShow as de}from"./support/tableUtils.js";import{createAttributeTableElements as me}from"./support/templateUtils.js";import{goTo as ce}from"../support/goToUtils.js";import{messageBundle as pe}from"../support/widget.js";const ue="80px";let ge=class extends k{constructor(e){super(e),this._currentTemporaryHighlight=null,this._highlights=new h,this._refreshDebounced=c(()=>this._refresh()),this._syncTemplateThrottled=w(()=>this._syncAttributeTableTemplate()),this._temporaryHighlightAbortController=null,this.attachmentsViewOptions=new M,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new n,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:l}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===l.length&&-1===l.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=this.paginationEnabled?this.pageIndex:e.page,o=await s.fetchItems({...e,page:n});t&&t(o)},this.grid=null,this.highlightEnabled=!0,this.layers=null,this.maxSize=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new n,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new J),this._set("grid",new G({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),f(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},T),y(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),f(()=>this.grid?.temporaryHighlightId,e=>{this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController,p(this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal))}),f(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),f(()=>this._viewSelection,()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}),f(()=>[this._tableHighlightsReady,this._viewSelectionReady],()=>this._syncSelection()),f(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch(()=>{})),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),f(()=>this.layer?.loaded,e=>e&&this._onLayerLoad()),f(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),f(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),f(()=>this.editingEnabled,()=>this.refreshCellContent()),f(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),f(()=>this.store.effectiveWhere,()=>"loaded"===this.store.state&&this.reset()),f(()=>this.layer?.timeExtent,(e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset()),y(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),y(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:l})=>{const n=t?.feature,o=n?.getObjectId(),r="cell-keydown"===l&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(l,{feature:n,index:e,native:i,type:l,fieldName:s??void 0,objectId:o}),(r||"cell-click"===l)&&this._onCellInteraction(o)}),f(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),f(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),y(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),f(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),f(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),f(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),f(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),f(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),y(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:l}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:l}}),y(()=>this.tableParent,"cell-click",e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)}),f(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),f(()=>this.layerFieldConfigurations,()=>this.refreshCellContent())])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this._currentTemporaryHighlight?.handle.remove(),this._temporaryHighlightAbortController=m(this._temporaryHighlightAbortController),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return E(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _highlightableLayerView(){const e=this.layerView;return V(e)?e:null}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return P(e)&&this._selectionManager?.sources?.includes(e)?e:null}get _subtypes(){return A(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,l=new n;return e&&l.push({type:"geometry",geometry:e}),i?l.push({type:"selection",objectIds:s.toArray()}):t.length&&l.push({type:"objectId",objectIds:t.toArray()}),l}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>$(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSize(){return super.effectiveSize}get fieldColumns(){return this.allColumns.filter(e=>Z(e))}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.store.hasPendingEdits}get hiddenFields(){return this._get("hiddenFields")??new n}set hiddenFields(e){this._set("hiddenFields",o(e,this._get("hiddenFields"),n))}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this._highlights.removeAll(),this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return te(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find(({id:t})=>t===e)}get relationshipColumns(){return this.allColumns.filter(e=>q(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,l=this.store.relationshipInfos;if(l.length||!ie(e)||!i?.length)return l;const n=[],o=s?.layers||t||[];return i.forEach(t=>{const i=se(e,o,t);i&&(i.load(),n.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),n}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}cancelPendingEdits(){this.store.cancelPendingEdits()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:l}=t,{objectIdField:o}=i,r=le(i,l),a=i.displayField||r?.keyField||o;e.set({highlightIds:new n([s]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,l)});const h=e.hiddenFields;h.includes(ne.action)||h.add(ne.action),h.includes(ne.attachments)||h.add(ne.attachments),e.scrollLeft()}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.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await Q(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([ne.action,ne.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await K({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(r(d.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(ne.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),p(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}async savePendingEdits(){await this.store.savePendingEdits(),await this.refresh()}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const l=this._getDefaultLayerDisplayField(s),o=await this.store.getAttachmentsByObjectId(e,!0),r=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?"list":"file",objectId:e}),this.set({highlightIds:new n([e]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(l)}),i.includes(ne.action)||i.add(ne.action),null!=r&&this.scrollToIndex(r)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}clearSelectionFilter(){r(d.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,n=s.objectId===e;await l.updateAttachment(e,t,i).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof a&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),n&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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 l=await e.queryFeatures(s);try{await ce(t,l.features)}catch(n){"AbortError"!==n.name&&console.error(n)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:l}=this;if(!i||!t||!l&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId)return;const{activeSortOrders:n,allColumns:o,columns:r}=this,a=[],h=me(r.toArray());n.forEach(({fieldName:e,direction:t})=>{e&&t&&a.push(new R({field:e,order:t}))}),o.forEach(({fieldName:e,direction:t})=>{t&&!a.some(t=>t.field===e)&&a.push(new R({field:e,order:t}))}),t.elements=h,t.orderByFields=a}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&S(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,l=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=l),this.grid?.set("pageSize",l),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t}=this,i=e?.columnTemplates,s=this._generateColumnsFromColumnTemplates(i)??this._generateColumnsFromAttributeTableTemplate(t)??this._generateDefaultFieldColumns();s.length&&(this.attachmentsEnabled&&!s.some(e=>$(e))&&s.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!s.some(e=>q(e))&&s.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&s.push(this._generateActionColumn()),s.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(s))}_generateColumnsFromAttributeTableTemplate(e){const{layer:t}=this;if(!e||!t)return null;const{elements:i,orderByFields:s}=e,n=F(t),o=[];o.push(...this._generateColumnsFromAttributeTableElements(i,s));const r=n.map(e=>{if(!e.fieldName||oe(e.fieldName,o))return null;const{fieldName:i}=e,l=re(t,i);return l?this._generateDefaultFieldColumn(l,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(l);return o.push(...r),this.attachmentsEnabled&&ae(t)&&!o.some(e=>$(e))&&o.push(this._generateDefaultAttachmentsColumn({hidden:!0})),this.relatedRecordsEnabled&&ie(t)&&t.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!o.some(t=>q(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t){const{layer:i}=this;return i?e?.map((e,i)=>{switch(e.type){case"field":return this._createFieldColumnFromElement({element:e,orderByFields:t});case"group":return this._createGroupColumnFromElement({element:e,orderByFields:t});case"attachment":return this._createAttachmentColumnFromElement({element:e,index:i});case"relationship":return this._createRelationshipColumnFromElement({element:e,index:i})}}).filter(e=>!!e)??[]:[]}_createFieldColumnFromElement(e){const{layer:t}=this;if(!t)return null;const{element:i,orderByFields:s}=e,{fieldName:l}=i;if(null==l)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const n=re(t,l);if(!n)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:o,label:r}=i,a=s?.findIndex(({field:e})=>e&&e===l)??-1,h=a>-1?s?.at(a)?.order:void 0,d=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b}=this;return new H({description:o,direction:h,field:n,fieldName:l,grid:m,initialSortPriority:d,label:r,layer:t,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{element:t,orderByFields:i}=e,{description:s,label:l}=t;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!t.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:n,messages:o,messagesCommon:r,messagesURIUtils:a,store:h}=this;return new N({columns:this._generateColumnsFromAttributeTableElements(t.elements,i),description:s,grid:n,label:l,messages:o,messagesCommon:r,messagesURIUtils:a,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{element:t,index:i}=e,{description:s,label:l}=t,{grid:n,layer:o,messages:r,messagesCommon:a,messagesURIUtils:h,store:d}=this;return new W({description:s,fieldName:`${ne.attachments}-${i}`,grid:n,label:l,layer:o,messages:r,messagesCommon:a,messagesURIUtils:h,store:d,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:l,relationshipId:n}=t,o=this.relationshipInfos.find(e=>e.relationshipId===n);if(!o)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:r,messages:a,messagesCommon:h,messagesURIUtils:d,store:m}=this;return new L({description:s,fieldName:`${ne.relationship}-${n}-${i}`,grid:r,label:l,messages:a,messagesCommon:h,messagesURIUtils:d,relationshipId:n,store:m,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:n,store:o,view:r}=this;if(!e?.length||!i)return null;const a=[];return e.forEach((e,h)=>{const{autoWidth:d,description:m,direction:c,flexGrow:p,fieldName:u,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,menuConfig:v,resizable:E,sortable:A,textAlign:S,textWrap:F,timeZone:j,type:R,width:x}=e;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const U=!1===e.visible;if("group"===R){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const i=this._generateColumnsFromColumnTemplates(e.columnTemplates),o=U||this._isFieldHidden(e.label);a.push(new N({autoWidth:d,columns:i,description:m,flexGrow:p,frozen:b,frozenToEnd:f,grid:t,hidden:o,icon:y,iconText:T,invalid:_,label:C,labelTooltipText:I,menuConfig:v,messages:s,messagesCommon:l,messagesURIUtils:n,resizable:E,textAlign:S,textWrap:F,timeZone:j,width:x}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,h))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(e=>e.relationshipId===t);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,e,h))}else if(!u)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const O=U||this._isFieldHidden(u);if("column"===R)a.push(new B({autoWidth:d,description:m,direction:c,fieldName:u,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:t,hidden:O,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,menuConfig:v,messages:s,messagesCommon:l,messagesURIUtils:n,resizable:E,sortable:A,textAlign:S,textWrap:F,timeZone:j,width:x}));else if("field"===R){const h=re(i,e.fieldName);if(!h)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:u,required:R}=e;a.push(new H({autoWidth:d,description:m,direction:c,editable:u,field:h,fieldName:h.name,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:t,hidden:O,icon:y,iconText:T,initialSortPriority:w,invalid:_,label:C,labelTooltipText:I,layer:i,messages:s,messagesCommon:l,messagesURIUtils:n,menuConfig:v,required:R,resizable:E,sortable:A,store:o,template:e,textAlign:S,textWrap:F,timeZone:j,width:x,view:r,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(){return this.layer?.fields?.map(e=>this._generateDefaultFieldColumn(e)).filter(l)??[]}_generateDefaultFieldColumn(e,t){const{grid:i,layer:s,messages:l,messagesCommon:n,messagesURIUtils:o,store:r,view:a}=this,h=t?.orderByFields;if(!e.visible||"geometry"===e.type)return null;const d=e.name,m=h?.findIndex(({field:e})=>e&&e===d)??-1,c=m>-1?h?.at(m)?.order:void 0,p=m>-1?m:void 0;return new H({direction:c,field:e,fieldName:d,grid:i,hidden:t?.hidden||this._isFieldHidden(d),initialSortPriority:p,layer:s,messages:l,messagesCommon:n,messagesURIUtils:o,store:r,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:l,messagesCommon:n,messagesURIUtils:o,store:r}=this,{attachmentsViewEnabled:a,autoWidth:h,description:d,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,resizable:C,textAlign:I,textWrap:v,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:S,thumbnailsEnabled:F,timeZone:j,width:R}=e;return new W({attachmentsViewEnabled:a,autoWidth:h,description:d,fieldName:`${ne.attachments}-${t}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:i,hidden:!1===e.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:s,menuConfig:_,messages:l,messagesCommon:n,messagesURIUtils:o,resizable:C,store:r,textAlign:I,textWrap:v,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:S,thumbnailsEnabled:F,timeZone:j,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:n,store:o}=this,r=ne.attachments;return new W({fieldName:r,grid:t,hidden:e?.hidden||this._isFieldHidden(r),layer:i,messages:s,messagesCommon:l,messagesURIUtils:n,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:l,messagesCommon:n,messagesURIUtils:o,store:r}=this,{autoWidth:a,collapsed:h,description:d,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,relationshipId:C,resizable:I,textAlign:v,textWrap:E,timeZone:A,width:S}=t;return new L({autoWidth:a,collapsed:h,description:d,fieldName:`${ne.relationship}-${C}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:_,messages:l,messagesCommon:n,messagesURIUtils:o,relationshipId:C,resizable:I,store:r,textAlign:v,textWrap:E,timeZone:A,width:S,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:l}=t,n=e.find(e=>e.relationshipId===l);n&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:n}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:l}=e,{grid:n,messages:o,messagesCommon:r,messagesURIUtils:a}=this,{relationshipId:h}=l;return new L({...t,fieldName:`${ne.relationship}-${h}-${s}`,grid:n,hidden:i,messages:o,messagesCommon:r,messagesURIUtils:a,layer:l.relatedLayer,relatedLayer:l.layer,relationshipId:h,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){return new z({hidden:this._isFieldHidden(ne.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_addTableHighlight(e){if(!this.highlightEnabled)return;const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),l=s?.feature??e;this._highlights.add(t.highlight(l,{name:U}),he(i,e))}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(he(t,e))}async _syncTemporaryHighlight(e,t){if(!this.highlightEnabled)return this._currentTemporaryHighlight?.handle.remove(),void(this._currentTemporaryHighlight=null);if(await u(25),g(t),!this._currentTemporaryHighlight&&!e)return;const{id:i}=this._currentTemporaryHighlight??{};if(i===e)return;this._currentTemporaryHighlight?.handle?.remove(),this._currentTemporaryHighlight=null;const{_highlightableLayerView:s,layer:l,highlightEnabled:n}=this;e&&s&&l&&n&&(this._currentTemporaryHighlight={id:e,handle:s.highlight(e,{name:O})})}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach(e=>this._addTableHighlight(e)):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.add(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach(e=>this._removeTableHighlight(e)),t.forEach(e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(ne.action)||s.add(ne.action),s.includes(ne.attachments)||s.add(ne.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:de(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([ne.action,ne.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new ee({columnTemplates:[new X({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,l])=>({selected:s===t,label:l||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new Y({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ue})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new X({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new D({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ue})),new ee({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:l}=e,{_subtypes:n,layer:o}=this;if(!o||!n.length)return void t.cancel();const r=n.find(e=>e.code===l);if(!r)return void t.cancel();const a=b(),h=this._createSubtypeEditPrompt(s,r,a),d=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(h);const e=await a.promise,s=[{fieldName:t.fieldName,value:l}];switch(e){case"update-fields":for(const[e,t]of Object.entries(r.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),d&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),d&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:l,messages:n,messagesCommon:o}=this,r=l.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const h=[{label:n.subtypes.useDefaultValuesOption,value:"update-fields"},{label:n.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:n.subtypes.changeWarningTitle,message:i(n.subtypes.changeWarning,{originalType:r,newType:t.name}),radios:h,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:o.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:o.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new ee({columnTemplates:[new X({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new D({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ue})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&I(s,i)]}):i?.fields.map(e=>[e.name,I(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?d.getLogger(this).warnOnce(e):d.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([_()],ge.prototype,"_defaultHiddenFields",null),e([_()],ge.prototype,"_effectiveTableTemplate",null),e([_()],ge.prototype,"_effectiveAttributeTableTemplate",null),e([_()],ge.prototype,"_highlights",void 0),e([_()],ge.prototype,"_highlightableLayerView",null),e([_()],ge.prototype,"_selectionManager",null),e([_()],ge.prototype,"_selectableLayer",null),e([_()],ge.prototype,"_subtypes",null),e([_()],ge.prototype,"_tableHighlightsReady",null),e([_()],ge.prototype,"_viewSelection",null),e([_()],ge.prototype,"_viewSelectionReady",null),e([_()],ge.prototype,"activeFilters",null),e([_({readOnly:!0})],ge.prototype,"activeSortOrders",null),e([_()],ge.prototype,"allRelatedTablesVisible",null),e([_()],ge.prototype,"attachmentsColumns",null),e([_()],ge.prototype,"attachmentsEnabled",null),e([_()],ge.prototype,"attachmentsViewOptions",void 0),e([_({type:j})],ge.prototype,"attributeTableTemplate",void 0),e([_()],ge.prototype,"autoRefreshEnabled",void 0),e([_()],ge.prototype,"autoSaveEnabled",null),e([_()],ge.prototype,"clearPrompt",null),e([_({readOnly:!0})],ge.prototype,"columns",void 0),e([_()],ge.prototype,"dataProvider",void 0),e([_()],ge.prototype,"definitionExpression",null),e([_()],ge.prototype,"fieldColumns",null),e([_({types:v})],ge.prototype,"filterGeometry",null),e([_()],ge.prototype,"filterBySelectionEnabled",null),e([_({readOnly:!0})],ge.prototype,"grid",void 0),e([_()],ge.prototype,"hasContingentValues",null),e([_()],ge.prototype,"hasInvalidPendingEdits",null),e([_()],ge.prototype,"hasPendingEdits",null),e([_()],ge.prototype,"hiddenFields",null),e([_()],ge.prototype,"highlightEnabled",void 0),e([_()],ge.prototype,"initialSize",null),e([_()],ge.prototype,"isQueryingOrSyncing",null),e([_()],ge.prototype,"isSyncingAttachments",null),e([_()],ge.prototype,"layer",null),e([_()],ge.prototype,"layers",void 0),e([_()],ge.prototype,"layerFieldConfigurations",null),e([_()],ge.prototype,"layerView",null),e([_()],ge.prototype,"menuConfig",void 0),e([_()],ge.prototype,"messages",void 0),e([_(),pe("esri/t9n/common")],ge.prototype,"messagesCommon",void 0),e([_(),pe("esri/core/t9n/Units")],ge.prototype,"messagesUnits",void 0),e([_(),pe("esri/widgets/support/t9n/uriUtils")],ge.prototype,"messagesURIUtils",void 0),e([_()],ge.prototype,"outFields",null),e([_()],ge.prototype,"prompt",void 0),e([_()],ge.prototype,"relatedRecordsEnabled",null),e([_()],ge.prototype,"relatedTable",null),e([_()],ge.prototype,"relatedTables",void 0),e([_()],ge.prototype,"relationship",null),e([_()],ge.prototype,"relationshipColumnConfigs",void 0),e([_()],ge.prototype,"relationshipColumns",null),e([_()],ge.prototype,"relationshipConfig",null),e([_()],ge.prototype,"relationshipInfos",null),e([_()],ge.prototype,"relationships",null),e([_()],ge.prototype,"returnGeometryEnabled",null),e([_()],ge.prototype,"returnMEnabled",null),e([_()],ge.prototype,"returnZEnabled",null),e([_()],ge.prototype,"selectionSource",void 0),e([_()],ge.prototype,"showAllRelatedTables",null),e([_()],ge.prototype,"showPrompt",null),e([_()],ge.prototype,"showRelatedTableCallback",void 0),e([_({readOnly:!0,type:J})],ge.prototype,"store",void 0),e([_()],ge.prototype,"supportsAttachments",null),e([_()],ge.prototype,"supportsAddAttachments",null),e([_()],ge.prototype,"supportsDeleteAttachments",null),e([_()],ge.prototype,"supportsResizeAttachments",null),e([_()],ge.prototype,"supportsUpdateAttachments",null),e([_()],ge.prototype,"syncTemplateOnChangesEnabled",void 0),e([_()],ge.prototype,"tableController",void 0),e([_()],ge.prototype,"tableParent",void 0),e([_({type:ee})],ge.prototype,"tableTemplate",void 0),e([_()],ge.prototype,"tableTemplateOverride",void 0),e([_({type:x})],ge.prototype,"timeExtent",null),e([_()],ge.prototype,"timeZone",null),e([_()],ge.prototype,"view",null),ge=e([C("esri.widgets.FeatureTable.FeatureTableViewModel")],ge);const be=ge;export{be as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{property as o,subclass as l}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as r}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as a,defaultFormatterOptionsNoTime as s,convertDateTimeFieldFormatToIntlOptions as u,defaultFormatterOptions as p}from"../../intl/date.js";import{formatNumber as d,convertNumberFormatToIntlOptions as m,convertNumberFieldFormatToIntlOptions as c}from"../../intl/number.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as h}from"../../layers/support/featureLayerUtils.js";import y from"../../layers/support/Field.js";import{defaultFieldFormat as g}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as v,isDateField as F,isTimeOnlyField as _,isIntegerField as C,isNumericField as b,isStringField as D,isDateOnlyField as I,isTimestampOffsetField as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as O}from"../../time/constants.js";import{getTimeZoneFormattingOptions as w}from"../../time/timeZoneUtils.js";import V from"../FeatureForm/FieldInput.js";import E from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{valueIsInRange as j,dateTimeIsInRange as R,getUnixFieldValueFromDateComponents as S,getISOFieldValueFromDateComponents as N,normalizeTimeOnlyString as A,getLabelForDateFieldValue as U,prepareISOFieldValueForDateComponents as q,prepareUnixFieldValueForDateComponents as B}from"../support/dateUtils.js";import{setFocus as k}from"../support/widgetUtils.js";const H={cancelEdit:"Escape"},z=Symbol(),P="esri-column",M={input:`${P}__cell-input`,inputContainer:`${P}__cell__input-container`};let W=class extends E{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:o,item:{attachments:l,feature:r,relatedRecords:a}}=t;return n({attachments:l,column:this,feature:r,field:this.field,index:o,relatedRecords:a,value:this.sanitizeContent(i),virtualIndex:this.getVirtualRowIndex(e)})}if(null===i)return"&nbsp;";const o=this._getDomainForFeature(t?.item?.feature),l=this._getComputedDomain(i,o)||i;return this._isAnyDateOrTimeField&&"coded-value"!==o?.type?this._formatDateValueForDisplay(this.field,l):this._isNumericField&&"coded-value"!==o?.type?d(parseFloat(l),this._numberFormatOptions):this.sanitizeContent(l)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(v(o,i)||!j({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!R({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&v(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(M.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await k(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return F(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=A(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return N({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return S({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||_(e)}get _isIntegerField(){return C(this.field)}get _isNumericField(){return b(this.field)}get _isStringField(){return D(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return Z(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?a(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?s:"date-time"===e?.type?u(e):this._isAnyDateOrTimeField?p:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?m(t.format):"number"===e?.type?c(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return r(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:this.sanitizeLabel(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=f(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return this.sanitizeLabel(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return w(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??O,this._dateTimeFormatOptions??p,t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??g(this.field)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],z);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=j({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],z),o>-1&&(a.maxLength=o),l>0&&(a.minLength=l);return a.classList.add(M.input),a.required=r,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===H.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],z),a}onInputBlur(e=!1){this.removeHandles(z),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?U(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(r,e),u=[];if(T(r)){const e=this.createDateComponent(),p=I(r)||x(r)?o:t,d=I(r)||x(r)?l:n,m=this._getDateFieldValuesForComponents(r,p??null),c=this._getDateFieldValuesForComponents(r,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return B(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return q(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new V({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=h(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([o()],W.prototype,"_effectiveDomain",null),e([o()],W.prototype,"_activeFieldInput",void 0),e([o()],W.prototype,"_effectiveRange",null),e([o()],W.prototype,"_isAnyDateOrTimeField",null),e([o()],W.prototype,"_isIntegerField",null),e([o()],W.prototype,"_isNumericField",null),e([o()],W.prototype,"_isStringField",null),e([o()],W.prototype,"_isSubtypeField",null),e([o()],W.prototype,"_layerWithFieldConfigurations",null),e([o()],W.prototype,"_dateTimeFormatOptions",null),e([o()],W.prototype,"_numberFormatOptions",null),e([o({readOnly:!0})],W.prototype,"alias",null),e([o()],W.prototype,"cellValueFormatFunction",void 0),e([o()],W.prototype,"cellValueValidatorFunction",void 0),e([o({readOnly:!0})],W.prototype,"defaultValue",null),e([o()],W.prototype,"effectiveDescription",null),e([o()],W.prototype,"effectiveEditable",null),e([o()],W.prototype,"effectiveLabel",null),e([o()],W.prototype,"effectiveRequired",null),e([o()],W.prototype,"effectiveSortable",null),e([o()],W.prototype,"effectiveTimeZoneOptions",null),e([o({type:y})],W.prototype,"field",void 0),e([o()],W.prototype,"formatFunction",void 0),e([o()],W.prototype,"includeTime",null),e([o()],W.prototype,"inputRenderFunction",void 0),e([o()],W.prototype,"layer",void 0),e([o()],W.prototype,"layerFieldConfigurationFormat",null),e([o({readOnly:!0})],W.prototype,"loadingMessage",null),e([o()],W.prototype,"maxLength",null),e([o()],W.prototype,"minLength",null),e([o({readOnly:!0})],W.prototype,"name",null),e([o({readOnly:!0})],W.prototype,"nullable",null),e([o()],W.prototype,"parseInputValueFunction",void 0),e([o()],W.prototype,"shouldShowPrompt",null),e([o()],W.prototype,"sortable",void 0),e([o()],W.prototype,"store",void 0),e([o()],W.prototype,"template",void 0),e([o()],W.prototype,"view",void 0),W=e([l("esri.widgets.FeatureTable.FieldColumn")],W);const G=W;export{G as default};
5
+ import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{property as o,subclass as l}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as r}from"../../editing/fieldUtils.js";import{convertDateFormatToIntlOptions as a,defaultFormatterOptionsNoTime as s,convertDateTimeFieldFormatToIntlOptions as u,defaultFormatterOptions as p}from"../../intl/date.js";import{formatNumber as d,convertNumberFormatToIntlOptions as m,convertNumberFieldFormatToIntlOptions as c}from"../../intl/number.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as h}from"../../layers/support/featureLayerUtils.js";import y from"../../layers/support/Field.js";import{defaultFieldFormat as g}from"../../layers/support/fieldFormatUtils.js";import{validateFieldValue as v,isDateField as F,isTimeOnlyField as _,isIntegerField as C,isNumericField as b,isStringField as D,isDateOnlyField as I,isTimestampOffsetField as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as T}from"../../smartMapping/support/utils.js";import{system as O}from"../../time/constants.js";import{getTimeZoneFormattingOptions as w}from"../../time/timeZoneUtils.js";import V from"../FeatureForm/FieldInput.js";import E from"./Grid/EditorColumn.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isEmptyStringOrWhitespace as L}from"./support/tableUtils.js";import{valueIsInRange as j,dateTimeIsInRange as R,getUnixFieldValueFromDateComponents as S,getISOFieldValueFromDateComponents as N,normalizeTimeOnlyString as A,getLabelForDateFieldValue as U,prepareISOFieldValueForDateComponents as q,prepareUnixFieldValueForDateComponents as B}from"../support/dateUtils.js";import{setFocus as k}from"../support/widgetUtils.js";const H={cancelEdit:"Escape"},z=Symbol(),P="esri-column",W={input:`${P}__cell-input`,inputContainer:`${P}__cell__input-container`};let M=class extends E{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:o,item:{attachments:l,feature:r,relatedRecords:a}}=t;return n({attachments:l,column:this,feature:r,field:this.field,index:o,relatedRecords:a,value:this.sanitizeContent(i),virtualIndex:this.getVirtualRowIndex(e)})}if(null===i)return"&nbsp;";const o=this._getDomainForFeature(t?.item?.feature),l=this._getComputedDomain(i,o)||i;return this._isAnyDateOrTimeField&&"coded-value"!==o?.type?this._formatDateValueForDisplay(this.field,l):this._isNumericField&&"coded-value"!==o?.type?d(parseFloat(l),this._numberFormatOptions):this.sanitizeContent(l)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(v(o,i)||!j({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!R({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&v(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(W.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach(t=>e.appendChild(t)),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await k(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return F(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=A(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return N({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return S({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return T(e)||_(e)}get _isIntegerField(){return C(this.field)}get _isNumericField(){return b(this.field)}get _isStringField(){return D(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get _layerWithFieldConfigurations(){const{layer:e}=this;return Z(e)?e:null}get _dateTimeFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?.dateFormat?a(t.format.dateFormat):t?.input&&"includeTime"in t.input&&!1===t.input.includeTime?s:"date-time"===e?.type?u(e):this._isAnyDateOrTimeField?p:void 0}get _numberFormatOptions(){const{layerFieldConfigurationFormat:e,template:t}=this;return t?.format?m(t.format):"number"===e?.type?c(e):this._isNumericField?{useGrouping:!0,maximumFractionDigits:20}:void 0}get alias(){return r(this.field,this._layerWithFieldConfigurations)}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=L(e)?L(i)?null:i:e;return null==n?null:this.sanitizeLabel(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=f(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return this.sanitizeLabel(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveSortable(){return!(!this.layer?.capabilities?.query?.supportsOrderBy||!this.sortable)}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return w(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??O,this._dateTimeFormatOptions??p,t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get layerFieldConfigurationFormat(){const{_layerWithFieldConfigurations:e}=this;if(e)return e.getFieldConfiguration(this.fieldName)?.fieldFormat??g(this.field)}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let a;if("coded-value"===t?.type)a=this.createCalciteSelect(e,t.codedValues.map(({code:e,name:t})=>({value:e,name:t}))),this.addHandles([i(()=>a,"calciteSelectChange",()=>this.onInputBlur(),n)],z);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;a=document.createElement("calcite-input"),a.type="number",this._isIntegerField&&(a.step=1),null!=t&&(a.max=t),null!=i&&(a.min=i),a.status=j({max:t,min:i,value:e})?"idle":"invalid"}else a=document.createElement("calcite-input"),this.addHandles([i(()=>a,"calciteInputChange",()=>this.onInputBlur(),n)],z),o>-1&&(a.maxLength=o),l>0&&(a.minLength=l);return a.classList.add(W.input),a.required=r,a.value=null!=e?e.toString():"",this.addHandles([i(()=>a,"keydown",e=>{e.key===H.cancelEdit&&this.onInputBlur(!0)},n),i(()=>a,"blur",()=>this.onInputBlur(),n)],z),a}onInputBlur(e=!1){this.removeHandles(z),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}get test(){}_clearActiveEditValues(){this.editInfo?.inputs?.forEach(e=>e.value="")}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?U(e,t,{...this._dateTimeFormatOptions,timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:a}=this,s=this._getDateFieldValuesForComponents(r,e),u=[];if(T(r)){const e=this.createDateComponent(),p=I(r)||x(r)?o:t,d=I(r)||x(r)?l:n,m=this._getDateFieldValuesForComponents(r,p??null),c=this._getDateFieldValuesForComponents(r,d??null);e.value=s.date??"",e.max=m.date??"",e.min=c.date??"",e.required=a,this.addHandles([i(()=>e,"calciteInputDatePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=s.time??"",e.required=a,this.addHandles([i(()=>e,"calciteInputTimePickerOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=s.timeZoneOffset??"0",this.addHandles([i(()=>e,"calciteInputTimeZoneOpen",()=>this._onDateComponentOpen(e))],z),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach(t=>{t!==e&&"open"in t&&(t.open=!1)})}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return B(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return q(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new V({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=h(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter(t=>t.hasOwnProperty("code")&&t.code===e);return i&&i.length?i[0].name:e}return null}};e([o()],M.prototype,"_effectiveDomain",null),e([o()],M.prototype,"_activeFieldInput",void 0),e([o()],M.prototype,"_effectiveRange",null),e([o()],M.prototype,"_isAnyDateOrTimeField",null),e([o()],M.prototype,"_isIntegerField",null),e([o()],M.prototype,"_isNumericField",null),e([o()],M.prototype,"_isStringField",null),e([o()],M.prototype,"_isSubtypeField",null),e([o()],M.prototype,"_layerWithFieldConfigurations",null),e([o()],M.prototype,"_dateTimeFormatOptions",null),e([o()],M.prototype,"_numberFormatOptions",null),e([o({readOnly:!0})],M.prototype,"alias",null),e([o()],M.prototype,"cellValueFormatFunction",void 0),e([o()],M.prototype,"cellValueValidatorFunction",void 0),e([o({readOnly:!0})],M.prototype,"defaultValue",null),e([o()],M.prototype,"effectiveDescription",null),e([o()],M.prototype,"effectiveEditable",null),e([o()],M.prototype,"effectiveLabel",null),e([o()],M.prototype,"effectiveRequired",null),e([o()],M.prototype,"effectiveSortable",null),e([o()],M.prototype,"effectiveTimeZoneOptions",null),e([o({type:y})],M.prototype,"field",void 0),e([o()],M.prototype,"formatFunction",void 0),e([o()],M.prototype,"includeTime",null),e([o()],M.prototype,"inputRenderFunction",void 0),e([o()],M.prototype,"layer",void 0),e([o()],M.prototype,"layerFieldConfigurationFormat",null),e([o()],M.prototype,"maxLength",null),e([o()],M.prototype,"minLength",null),e([o({readOnly:!0})],M.prototype,"name",null),e([o({readOnly:!0})],M.prototype,"nullable",null),e([o()],M.prototype,"parseInputValueFunction",void 0),e([o()],M.prototype,"shouldShowPrompt",null),e([o()],M.prototype,"sortable",void 0),e([o()],M.prototype,"store",void 0),e([o()],M.prototype,"template",void 0),e([o()],M.prototype,"view",void 0),M=e([l("esri.widgets.FeatureTable.FieldColumn")],M);const G=M;export{G as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{on as e,sync as n}from"../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../core/accessorSupport/decorators.js";import l from"./Column.js";import{autoLink as r}from"../../support/uriUtils.js";const a={showInput:"Enter",cancelEdit:"Escape"},s=Symbol();let c=class extends l{constructor(t){super(t),this.editInfo=null,this.cellValueValidatorFunction=({oldValue:t,value:e})=>t!==e,this.editable=!0,this.headerRenderFunction=t=>{const{root:e}=t,n=this.createHeaderContent();this.tableEditingEnabled&&!this.effectiveEditable&&n.prepend(this._lockIconNode),this.removeCellContent(e),e.appendChild(n)},this.inputRenderFunction=({root:t,column:e,rowData:n})=>{if(this.editInfo||!this.effectiveEditable||!n)return;const i=this.getCellValue(n),o=this.createInputElement({value:i});this._set("editInfo",{column:e,inputs:[o],root:t,rowData:n,oldValue:i});const l=document.createElement("div");l.appendChild(o),this.removeCellContent(t),t.appendChild(l),o.focus(),o instanceof HTMLInputElement&&o.select()},this.loadingMessage="",this.inputType="text",this.maxLength=null,this.onShowPromptCallback=()=>{},this.parseInputValueFunction=({inputs:t})=>t?.length||1!==t.length||Array.isArray(t[0].value)?null:t[0].value,this.renderFunction=t=>{const{root:e,rowData:n}=t,{editInfo:i}=this;if(i)return;const o=this.getCellValue(n),l=this.cellValueFormatFunction({root:e,rowData:n,value:o});let s=null;e.onclick=()=>e.focus(),e.ondblclick=()=>this.inputRenderFunction(t),e.ontouchend=()=>this.inputRenderFunction(t);const c=this.grid?.getSlotElementByName(e.slot),u=c?.parentElement;u&&!u.onkeydown&&(u.onkeydown=e=>{e.key!==a.showInput||this.editInfo||this.inputRenderFunction(t),e.key===a.cancelEdit&&this.editInfo&&this.cancel()}),null!=o&&null!=l?e.title=l.toString():e.title&&e.removeAttribute("title"),s=l instanceof HTMLElement?l:r(this.messagesURIUtils,l),this.removeCellContent(e),s instanceof HTMLElement?e.appendChild(s):null!=s&&(e.innerHTML=s.toString())},this.required=!1}get _lockIconNode(){return this.createCalciteIcon({icon:"lock",textLabel:this.messages?.editingPreventedColumn})}get effectiveEditable(){return this.tableEditingEnabled&&this.editable}get effectiveRequired(){return this.required}get editing(){return!!this.editInfo}get shouldShowPrompt(){return!1}get tableEditingEnabled(){return this.store.editingEnabled}cancel(){this.onEditComplete()}createCalciteOption(t,e,n=!1){const i=document.createElement("calcite-option");return i.label=t,i.value=`${e}`,i.selected=n,i}createCalciteSelect(t,e){const{effectiveRequired:n,messages:i}=this;let o=!1;const l=e.map(({name:e,value:n})=>{const i=n===t;return i&&(o=!0),this.createCalciteOption(e,n,i)});if(null!=t&&""!==t&&!o){const e=t.toString(),n=this.createCalciteOption(e,e);l.unshift(n)}n||l.unshift(this.createCalciteOption(`<${i?.noValue}>`,""));const r=document.createElement("calcite-select");return l.forEach(t=>r.appendChild(t)),r}createInputElement({value:t}){const{effectiveRequired:i,maxLength:o}=this,l=document.createElement("calcite-input");return null!=o&&(l.maxLength=o),l.required=i,l.value=null!=t?t.toString():"",this.addHandles([e(()=>l,"calciteInputChange",()=>this.onInputBlur(),n),e(()=>l,"keydown",t=>{t.key===a.cancelEdit&&this.onInputBlur(!0)},n),e(()=>l,"blur",()=>this.onInputBlur(),n)],s),l}createDateComponent(){const t=document.createElement("calcite-input-date-picker");return t.focusTrapDisabled=!0,t.overlayPositioning="fixed",t}createTimeComponent(){const t=document.createElement("calcite-input-time-picker");return t.overlayPositioning="fixed",t.placement="auto-start",t.step=1,t}createTimeZoneComponent(){const t=document.createElement("calcite-input-time-zone");return t.maxItems=4,t.overlayPositioning="fixed",t}onEditComplete(){this._set("editInfo",null),this.grid?.generateCellPartNames(),this.grid?.requestContentUpdate()}onInputBlur(t=!1){this.removeHandles(s),t?this.cancel():this.submit()}async submit(){const{editInfo:t}=this;if(!t)return void this.cancel();const{inputs:e,rowData:n,oldValue:i}=t,o=this.parseInputValueFunction({inputs:e});if(!this.cellValueValidatorFunction({value:o,oldValue:i}))return void this.cancel();const{root:l}=t,r=n.item.objectId,{fieldName:a}=this;l.textContent=this.loadingMessage,this.shouldShowPrompt?this.onShowPromptCallback({column:this,objectId:r,oldValue:i,value:o}):await this.updateItems({objectId:r,updates:[{fieldName:a,value:o}]})}async updateItems(t){try{await this.store.updateItem(t),this.onEditComplete()}catch{this.cancel()}}};t([i()],c.prototype,"_lockIconNode",null),t([i({readOnly:!0})],c.prototype,"editInfo",void 0),t([i()],c.prototype,"cellValueValidatorFunction",void 0),t([i()],c.prototype,"editable",void 0),t([i()],c.prototype,"effectiveEditable",null),t([i()],c.prototype,"effectiveRequired",null),t([i()],c.prototype,"editing",null),t([i()],c.prototype,"headerRenderFunction",void 0),t([i()],c.prototype,"inputRenderFunction",void 0),t([i({constructOnly:!0})],c.prototype,"loadingMessage",void 0),t([i()],c.prototype,"inputType",void 0),t([i()],c.prototype,"maxLength",void 0),t([i()],c.prototype,"onShowPromptCallback",void 0),t([i()],c.prototype,"parseInputValueFunction",void 0),t([i()],c.prototype,"renderFunction",void 0),t([i()],c.prototype,"required",void 0),t([i()],c.prototype,"shouldShowPrompt",null),t([i()],c.prototype,"tableEditingEnabled",null),c=t([o("esri.widgets.FeatureTable.Grid.EditorColumn")],c);const u=c;export{u as default};
5
+ import{__decorate as t}from"tslib";import{on as e,sync as n}from"../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../core/accessorSupport/decorators.js";import l from"./Column.js";import{autoLink as r}from"../../support/uriUtils.js";const a={showInput:"Enter",cancelEdit:"Escape"},s=Symbol();let c=class extends l{constructor(t){super(t),this.editInfo=null,this.cellValueValidatorFunction=({oldValue:t,value:e})=>t!==e,this.editable=!0,this.headerRenderFunction=t=>{const{root:e}=t,n=this.createHeaderContent();this.tableEditingEnabled&&!this.effectiveEditable&&n.prepend(this._lockIconNode),this.removeCellContent(e),e.appendChild(n)},this.inputRenderFunction=({root:t,column:e,rowData:n})=>{if(this.editInfo||!this.effectiveEditable||!n)return;const i=this.getCellValue(n),o=this.createInputElement({value:i});this._set("editInfo",{column:e,inputs:[o],root:t,rowData:n,oldValue:i});const l=document.createElement("div");l.appendChild(o),this.removeCellContent(t),t.appendChild(l),o.focus(),o instanceof HTMLInputElement&&o.select()},this.inputType="text",this.maxLength=null,this.onShowPromptCallback=()=>{},this.parseInputValueFunction=({inputs:t})=>t?.length||1!==t.length||Array.isArray(t[0].value)?null:t[0].value,this.renderFunction=t=>{const{root:e,rowData:n}=t,{editInfo:i}=this;if(i)return;const o=this.getCellValue(n),l=this.cellValueFormatFunction({root:e,rowData:n,value:o});let s=null;e.onclick=()=>e.focus(),e.ondblclick=()=>this.inputRenderFunction(t),e.ontouchend=()=>this.inputRenderFunction(t);const c=this.grid?.getSlotElementByName(e.slot),u=c?.parentElement;u&&!u.onkeydown&&(u.onkeydown=e=>{e.key!==a.showInput||this.editInfo||this.inputRenderFunction(t),e.key===a.cancelEdit&&this.editInfo&&this.cancel()}),null!=o&&null!=l?e.title=l.toString():e.title&&e.removeAttribute("title"),s=l instanceof HTMLElement?l:r(this.messagesURIUtils,l),this.removeCellContent(e),s instanceof HTMLElement?e.appendChild(s):null!=s&&(e.innerHTML=s.toString())},this.required=!1}get _lockIconNode(){return this.createCalciteIcon({icon:"lock",textLabel:this.messages?.editingPreventedColumn})}get effectiveEditable(){return this.tableEditingEnabled&&this.editable}get effectiveRequired(){return this.required}get editing(){return!!this.editInfo}get loadingMessage(){return this.messages?.loading||"..."}get shouldShowPrompt(){return!1}get tableEditingEnabled(){return this.store.editingEnabled}cancel(){this.onEditComplete()}createCalciteOption(t,e,n=!1){const i=document.createElement("calcite-option");return i.label=t,i.value=`${e}`,i.selected=n,i}createCalciteSelect(t,e){const{effectiveRequired:n,messages:i}=this;let o=!1;const l=e.map(({name:e,value:n})=>{const i=n===t;return i&&(o=!0),this.createCalciteOption(e,n,i)});if(null!=t&&""!==t&&!o){const e=t.toString(),n=this.createCalciteOption(e,e);l.unshift(n)}n||l.unshift(this.createCalciteOption(`<${i?.noValue}>`,""));const r=document.createElement("calcite-select");return l.forEach(t=>r.appendChild(t)),r}createInputElement({value:t}){const{effectiveRequired:i,maxLength:o}=this,l=document.createElement("calcite-input");return null!=o&&(l.maxLength=o),l.required=i,l.value=null!=t?t.toString():"",this.addHandles([e(()=>l,"calciteInputChange",()=>this.onInputBlur(),n),e(()=>l,"keydown",t=>{t.key===a.cancelEdit&&this.onInputBlur(!0)},n),e(()=>l,"blur",()=>this.onInputBlur(),n)],s),l}createDateComponent(){const t=document.createElement("calcite-input-date-picker");return t.focusTrapDisabled=!0,t.overlayPositioning="fixed",t}createTimeComponent(){const t=document.createElement("calcite-input-time-picker");return t.overlayPositioning="fixed",t.placement="auto-start",t.step=1,t}createTimeZoneComponent(){const t=document.createElement("calcite-input-time-zone");return t.maxItems=4,t.overlayPositioning="fixed",t}onEditComplete(){this._set("editInfo",null),this.grid?.generateCellPartNames(),this.grid?.requestContentUpdate()}onInputBlur(t=!1){this.removeHandles(s),t?this.cancel():this.submit()}async submit(){const{editInfo:t}=this;if(!t)return void this.cancel();const{inputs:e,rowData:n,oldValue:i}=t,o=this.parseInputValueFunction({inputs:e});if(!this.cellValueValidatorFunction({value:o,oldValue:i}))return void this.cancel();const{root:l}=t,r=n.item.objectId,{fieldName:a}=this;l.textContent=this.loadingMessage,this.shouldShowPrompt?this.onShowPromptCallback({column:this,objectId:r,oldValue:i,value:o}):await this.updateItems({objectId:r,updates:[{fieldName:a,value:o}]})}async updateItems(t){try{await this.store.updateItem(t),this.onEditComplete()}catch{this.cancel()}}};t([i()],c.prototype,"_lockIconNode",null),t([i({readOnly:!0})],c.prototype,"editInfo",void 0),t([i()],c.prototype,"cellValueValidatorFunction",void 0),t([i()],c.prototype,"editable",void 0),t([i()],c.prototype,"effectiveEditable",null),t([i()],c.prototype,"effectiveRequired",null),t([i()],c.prototype,"editing",null),t([i()],c.prototype,"headerRenderFunction",void 0),t([i()],c.prototype,"inputRenderFunction",void 0),t([i()],c.prototype,"loadingMessage",null),t([i()],c.prototype,"inputType",void 0),t([i()],c.prototype,"maxLength",void 0),t([i()],c.prototype,"onShowPromptCallback",void 0),t([i()],c.prototype,"parseInputValueFunction",void 0),t([i()],c.prototype,"renderFunction",void 0),t([i()],c.prototype,"required",void 0),t([i()],c.prototype,"shouldShowPrompt",null),t([i()],c.prototype,"tableEditingEnabled",null),c=t([o("esri.widgets.FeatureTable.Grid.EditorColumn")],c);const u=c;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"@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 i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as n,watch as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as l}from"../../../core/sanitizerUtils.js";import{property as s,subclass as d}from"../../../core/accessorSupport/decorators.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as u}from"../../support/globalCss.js";import{messageBundle as g,tsx as m}from"../../support/widget.js";const c="esri-grid",p="compact column-borders",_={base:c,content:`${c}__content`,grid:`${c}__grid`,noDataMessage:`${c}__no-data-message`},f={sort:["Enter"," "]};let v=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this._temporaryHighlightId=null,this.itemIdPath="objectId",this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new h,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",()=>this.renderNow()),this.columns.on("change",()=>this.onColumnChange()),n(()=>this.highlightIds,"before-add",({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()}),this.rowHighlightIds.on("change",()=>this.generateCellPartNames()),o(()=>this.effectiveSize,()=>this._updateGridSize()),o(()=>this.isEditing,()=>{this.generateCellPartNames(),this.requestContentUpdate()}),o(()=>this.store?.state,(e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()}),n(()=>this._table,"scroll",()=>this.viewModel.closeColumnMenus()),i(window,"resize",()=>this._updateColumnBorderStyles()),n(()=>this._table,"scrollend",()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex()),this._updateColumnBorderStyles()}),o(()=>this.multipleSelectionEnabled,e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()})])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map(e=>t?.getItemByObjectId(e)??{objectId:e})}get _gridIsDisabled(){return 0===this.viewModel.allVisibleColumns.length||this.hasInvalidColumnConfiguration}get _noDataMessage(){return l.sanitize(this.noDataMessage)}get _table(){return this._grid?.$?.table}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 editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get groupColumns(){return this.viewModel.groupColumns}get hasInvalidColumnConfiguration(){return this.viewModel.hasInvalidColumnConfiguration}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get temporaryHighlightId(){return this._temporaryHighlightId}get isEditing(){return this.viewModel.isEditing}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=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}get state(){return this.viewModel.state}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,fieldName:o,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:g,width:m}=e,c=`${i}_${o}_${t}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:f}=e,v=_?(e,t)=>_({root:e,column:t}):void 0,y=f?(e,t)=>f({root:e,column:t}):void 0,C=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let w="";return e.direction&&(w+=" direction"),e.invalid&&(w+=" invalid"),{footerRenderer:v,headerRenderer:y,renderer:C,autoWidth:r,direction:n,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:w,key:c,resizable:u,bind:this,"data-fieldName":o,header:h,hidden:this.hasInvalidColumnConfiguration||a,path:o,"text-align":g,width:"number"==typeof m?`${m}px`:m,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){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),this.store?.reset(),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache(),this._temporaryHighlightId=null}requestContentUpdate(){this._grid?.requestContentUpdate(),this._temporaryHighlightId=null}selectRows(e){const{itemIdPath:t}=this,i=e?.filter(e=>!this.highlightIds.includes(e[t])),r=i.map(e=>e[t]);r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map(e=>e[t])||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){0!==this.size&&(this._grid?.isConnected&&this._grid?.scrollToIndex(e),this._temporaryHighlightId=null)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach(e=>this._applyRenderersToColumnElement(e)),this.requestContentUpdate()}render(){return m("div",{bind:this,class:this.classes(_.base,u.widget)},m("div",{bind:this,class:_.content},this._renderGrid()))}_renderGrid(){return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:_.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,disabled:this._gridIsDisabled,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,multiSortPriority:this.multipleSortPriority,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns(),this._renderEmptyState())}_renderAllColumns(){return"disabled"!==this.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:this.hasInvalidColumnConfiguration||!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,(e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)})).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter(({hidden:e})=>!e);return r.length?m("vaadin-grid-column-group",{...i},r.map(e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)}))):null}_renderEmptyState(){const e=this.viewModel;if("loaded"===e.state&&!e.isQueryingOrSyncing)return m("div",{class:_.noDataMessage,slot:"empty-state"},this._noDataMessage??this.messages.noDataFound)}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",p),customElements.whenDefined("vaadin-grid").then(()=>{this._appendStyles(),this._addGridEventListeners()}),t.__updateSorter=(e,i,r)=>{const n=t._sorters,o=!n.includes(e),{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=n.filter(t=>t!==e),h=l&&(!s||!r)||s&&i;e._order=null,e.direction?h?null!=e._initialOrder?(o?n[e._initialOrder]=e:n.splice(e._initialOrder,0,e),e._initialOrder=null):"append"===d&&o?t._sorters=[...a,e]:"prepend"===d&&(t._sorters=[e,...a]):(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach(e=>{e._order=null,e.direction=null})):o||(t._sorters=[...a])},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter(e=>!e.direction));t._sorters=t._sorters.filter(e=>!i.has(e)),t.__applySorters()}}_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 #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\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.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],e=>this._onGridInteraction(e)),i(e,["pointerover","pointerout","cell-focus"],e=>this._onTransientGridInteraction(e)),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",()=>{this.notifyChange("sortOrders"),this._updateColumnBorderStyles()}),i(e,"column-resize",e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width}),this._updateColumnBorderStyles()}),i(e,"column-reorder",()=>this._onColumnOrderChange())])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:n,index:o,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&n?.path){const t=e.key;f.sort.includes(t)&&this.findColumn(n.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:o,item:l,native:e,path:n?.path??void 0})}_onTransientGridInteraction(e){if("pointerout"===e.type)return void(this._temporaryHighlightId=null);const t=this._grid;if(t)try{const{item:i}=t.getEventContext(e);this._temporaryHighlightId=i?.objectId}catch{this._temporaryHighlightId=null}}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],n=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map(e=>e.getAttribute("data-fieldName"));t?.forEach(e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort((e,t)=>n.indexOf(e.fieldName)>n.indexOf(t.fieldName)?1:-1)}}),this.columns.sort((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll(),this._temporaryHighlightId=null}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map(e=>e[i]),n=r.filter(e=>!t.includes(e));if(!this.multipleSelectionEnabled&&n.length&&t.length)t.removeAll(),t.add(n[0]);else{const e=t.filter(e=>!r.includes(e));t.removeMany(e),t.addMany(n)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:n}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),n&&(e.headerRenderer=(e,t)=>n({root:e,column:t}))}catch(r){}}_updateColumnBorderStyles(){try{this._grid?._updateFirstAndLastColumn()}catch(e){}}};e([s()],v.prototype,"_columnElements",void 0),e([s()],v.prototype,"_columnRendering",null),e([s()],v.prototype,"_selectedItems",null),e([s()],v.prototype,"_grid",void 0),e([s()],v.prototype,"_gridIsDisabled",null),e([s()],v.prototype,"_noDataMessage",null),e([s()],v.prototype,"_table",null),e([s()],v.prototype,"_temporaryHighlightId",void 0),e([s()],v.prototype,"cellPartNameGenerator",null),e([s()],v.prototype,"columns",null),e([s()],v.prototype,"columnPerformanceModeEnabled",null),e([s()],v.prototype,"columnReorderingEnabled",null),e([s()],v.prototype,"dataProvider",null),e([s()],v.prototype,"editingEnabled",null),e([s()],v.prototype,"effectiveSize",null),e([s()],v.prototype,"groupColumns",null),e([s()],v.prototype,"hasInvalidColumnConfiguration",null),e([s()],v.prototype,"highlightIds",null),e([s()],v.prototype,"temporaryHighlightId",null),e([s()],v.prototype,"isEditing",null),e([s()],v.prototype,"isReady",null),e([s()],v.prototype,"itemIdPath",void 0),e([s()],v.prototype,"label",null),e([s(),g("esri/widgets/FeatureTable/t9n/FeatureTable")],v.prototype,"messages",void 0),e([s()],v.prototype,"multipleSelectionEnabled",null),e([s()],v.prototype,"multiSortEnabled",null),e([s()],v.prototype,"noDataMessage",null),e([s()],v.prototype,"pageIndex",null),e([s()],v.prototype,"multipleSortPriority",null),e([s()],v.prototype,"pageSize",null),e([s()],v.prototype,"paginationEnabled",null),e([s()],v.prototype,"rowDetailsRenderer",null),e([s()],v.prototype,"rowHighlightIds",null),e([s()],v.prototype,"selectionColumnEnabled",void 0),e([s()],v.prototype,"size",null),e([s({readOnly:!0})],v.prototype,"sortOrders",null),e([s()],v.prototype,"store",null),e([s()],v.prototype,"state",null),e([s()],v.prototype,"viewModel",void 0),v=e([d("esri.widgets.FeatureTable.Grid.Grid")],v);const y=v;export{y as default};
5
+ import{__decorate as e}from"tslib";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 i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as n,watch as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as l}from"../../../core/sanitizerUtils.js";import{property as s,subclass as d}from"../../../core/accessorSupport/decorators.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as u}from"../../support/globalCss.js";import{messageBundle as g,tsx as m}from"../../support/widget.js";const c="esri-grid",p="compact column-borders",_={base:c,content:`${c}__content`,grid:`${c}__grid`,noDataMessage:`${c}__no-data-message`},f={sort:["Enter"," "]};let v=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this._temporaryHighlightId=null,this.itemIdPath="objectId",this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new h,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",()=>this.renderNow()),this.columns.on("change",()=>this.onColumnChange()),n(()=>this.highlightIds,"before-add",({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()}),this.rowHighlightIds.on("change",()=>this.generateCellPartNames()),o(()=>this.effectiveSize,()=>this._updateGridSize()),o(()=>[this.isEditing,this.store?.hasPendingEdits],()=>{this.generateCellPartNames(),this.requestContentUpdate()}),o(()=>this.store?.state,(e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()}),n(()=>this._table,"scroll",()=>this.viewModel.closeColumnMenus()),i(window,"resize",()=>this._updateColumnBorderStyles()),n(()=>this._table,"scrollend",()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex()),this._updateColumnBorderStyles()}),o(()=>this.multipleSelectionEnabled,e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()})])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map(e=>t?.getItemByObjectId(e)??{objectId:e})}get _gridIsDisabled(){return 0===this.viewModel.allVisibleColumns.length||this.hasInvalidColumnConfiguration}get _noDataMessage(){return l.sanitize(this.noDataMessage)}get _table(){return this._grid?.$?.table}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 editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get groupColumns(){return this.viewModel.groupColumns}get hasInvalidColumnConfiguration(){return this.viewModel.hasInvalidColumnConfiguration}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get temporaryHighlightId(){return this._temporaryHighlightId}get isEditing(){return this.viewModel.isEditing}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=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}get state(){return this.viewModel.state}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,fieldName:o,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:g,width:m}=e,c=`${i}_${o}_${t}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:f}=e,v=_?(e,t)=>_({root:e,column:t}):void 0,y=f?(e,t)=>f({root:e,column:t}):void 0,C=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let w="";return e.direction&&(w+=" direction"),e.invalid&&(w+=" invalid"),{footerRenderer:v,headerRenderer:y,renderer:C,autoWidth:r,direction:n,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:w,key:c,resizable:u,bind:this,"data-fieldName":o,header:h,hidden:this.hasInvalidColumnConfiguration||a,path:o,"text-align":g,width:"number"==typeof m?`${m}px`:m,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){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),this.store?.reset(),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache(),this._temporaryHighlightId=null}requestContentUpdate(){this._grid?.requestContentUpdate(),this._temporaryHighlightId=null}selectRows(e){const{itemIdPath:t}=this,i=e?.filter(e=>!this.highlightIds.includes(e[t])),r=i.map(e=>e[t]);r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map(e=>e[t])||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){0!==this.size&&(this._grid?.isConnected&&this._grid?.scrollToIndex(e),this._temporaryHighlightId=null)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach(e=>this._applyRenderersToColumnElement(e)),this.requestContentUpdate()}render(){return m("div",{bind:this,class:this.classes(_.base,u.widget)},m("div",{bind:this,class:_.content},this._renderGrid()))}_renderGrid(){return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:_.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,disabled:this._gridIsDisabled,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,multiSortPriority:this.multipleSortPriority,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns(),this._renderEmptyState())}_renderAllColumns(){return"disabled"!==this.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:this.hasInvalidColumnConfiguration||!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,(e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)})).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter(({hidden:e})=>!e);return r.length?m("vaadin-grid-column-group",{...i},r.map(e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)}))):null}_renderEmptyState(){const e=this.viewModel;if("loaded"===e.state&&!e.isQueryingOrSyncing)return m("div",{class:_.noDataMessage,slot:"empty-state"},this._noDataMessage??this.messages.noDataFound)}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",p),customElements.whenDefined("vaadin-grid").then(()=>{this._appendStyles(),this._addGridEventListeners()}),t.__updateSorter=(e,i,r)=>{const n=t._sorters,o=!n.includes(e),{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=n.filter(t=>t!==e),h=l&&(!s||!r)||s&&i;e._order=null,e.direction?h?null!=e._initialOrder?(o?n[e._initialOrder]=e:n.splice(e._initialOrder,0,e),e._initialOrder=null):"append"===d&&o?t._sorters=[...a,e]:"prepend"===d&&(t._sorters=[e,...a]):(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach(e=>{e._order=null,e.direction=null})):o||(t._sorters=[...a])},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter(e=>!e.direction));t._sorters=t._sorters.filter(e=>!i.has(e)),t.__applySorters()}}_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 #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\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.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],e=>this._onGridInteraction(e)),i(e,["pointerover","pointerout","cell-focus"],e=>this._onTransientGridInteraction(e)),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",()=>{this.notifyChange("sortOrders"),this._updateColumnBorderStyles()}),i(e,"column-resize",e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width}),this._updateColumnBorderStyles()}),i(e,"column-reorder",()=>this._onColumnOrderChange())])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:n,index:o,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&n?.path){const t=e.key;f.sort.includes(t)&&this.findColumn(n.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:o,item:l,native:e,path:n?.path??void 0})}_onTransientGridInteraction(e){if("pointerout"===e.type)return void(this._temporaryHighlightId=null);const t=this._grid;if(t)try{const{item:i}=t.getEventContext(e);this._temporaryHighlightId=i?.objectId}catch{this._temporaryHighlightId=null}}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],n=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map(e=>e.getAttribute("data-fieldName"));t?.forEach(e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort((e,t)=>n.indexOf(e.fieldName)>n.indexOf(t.fieldName)?1:-1)}}),this.columns.sort((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll(),this._temporaryHighlightId=null}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map(e=>e[i]),n=r.filter(e=>!t.includes(e));if(!this.multipleSelectionEnabled&&n.length&&t.length)t.removeAll(),t.add(n[0]);else{const e=t.filter(e=>!r.includes(e));t.removeMany(e),t.addMany(n)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:n}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),n&&(e.headerRenderer=(e,t)=>n({root:e,column:t}))}catch(r){}}_updateColumnBorderStyles(){try{this._grid?._updateFirstAndLastColumn()}catch(e){}}};e([s()],v.prototype,"_columnElements",void 0),e([s()],v.prototype,"_columnRendering",null),e([s()],v.prototype,"_selectedItems",null),e([s()],v.prototype,"_grid",void 0),e([s()],v.prototype,"_gridIsDisabled",null),e([s()],v.prototype,"_noDataMessage",null),e([s()],v.prototype,"_table",null),e([s()],v.prototype,"_temporaryHighlightId",void 0),e([s()],v.prototype,"cellPartNameGenerator",null),e([s()],v.prototype,"columns",null),e([s()],v.prototype,"columnPerformanceModeEnabled",null),e([s()],v.prototype,"columnReorderingEnabled",null),e([s()],v.prototype,"dataProvider",null),e([s()],v.prototype,"editingEnabled",null),e([s()],v.prototype,"effectiveSize",null),e([s()],v.prototype,"groupColumns",null),e([s()],v.prototype,"hasInvalidColumnConfiguration",null),e([s()],v.prototype,"highlightIds",null),e([s()],v.prototype,"temporaryHighlightId",null),e([s()],v.prototype,"isEditing",null),e([s()],v.prototype,"isReady",null),e([s()],v.prototype,"itemIdPath",void 0),e([s()],v.prototype,"label",null),e([s(),g("esri/widgets/FeatureTable/t9n/FeatureTable")],v.prototype,"messages",void 0),e([s()],v.prototype,"multipleSelectionEnabled",null),e([s()],v.prototype,"multiSortEnabled",null),e([s()],v.prototype,"noDataMessage",null),e([s()],v.prototype,"pageIndex",null),e([s()],v.prototype,"multipleSortPriority",null),e([s()],v.prototype,"pageSize",null),e([s()],v.prototype,"paginationEnabled",null),e([s()],v.prototype,"rowDetailsRenderer",null),e([s()],v.prototype,"rowHighlightIds",null),e([s()],v.prototype,"selectionColumnEnabled",void 0),e([s()],v.prototype,"size",null),e([s({readOnly:!0})],v.prototype,"sortOrders",null),e([s()],v.prototype,"store",null),e([s()],v.prototype,"state",null),e([s()],v.prototype,"viewModel",void 0),v=e([d("esri.widgets.FeatureTable.Grid.Grid")],v);const y=v;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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import{referenceSetter as i}from"../../../core/collectionUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isGroupColumn as r}from"../support/columnUtils.js";import{uniqueColumnNames as s,isPageIndexValid as u}from"../support/tableUtils.js";let d=class extends n{constructor(t){super(t),this.actionColumnConfig=null,this.cellPartNameGenerator=(t,e)=>{let i="";e?.item&&this.rowHighlightIds.includes(e.item.objectId)&&(i+=" highlight");const n=this.findColumn(t?.path);return n?(n.invalid&&(i+=" invalid"),n.textWrap&&(i+=" text-wrap"),"editInfo"in n&&n.editInfo&&n.editInfo.rowData?.index===e.index&&(i+=" editing"),i):i},this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new e,this.dataProvider=async(t,e)=>{const{store:i}=this;if(!e)return;e(await i.fetchItems(t))},this.maxSize=null,this.multipleSelectionEnabled=!0,this.multiSortEnabled=!1,this.multipleSortPriority="prepend",this.noDataMessage=null,this.paginationEnabled=!1,this.rowDetailsRenderer=null,this.store=null}get actionColumn(){return this.allColumns.find(t=>t.fieldName===s.action)}get allColumns(){return this.columns.toArray().flatMap(t=>[t,...r(t)&&t.columns?.length?t.columns:[]])}get allVisibleColumns(){return this.allColumns.filter(t=>!t.hidden)}get columnMenuIsOpen(){return this.allColumns.some(t=>t.menuIsOpen)}get editingEnabled(){return this.store.editingEnabled}set editingEnabled(t){this.store.editingEnabled=t}get editableColumns(){return this.allColumns.filter(t=>"editable"in t)}get effectiveSize(){const{filterBySelectionEnabled:t,highlightIds:e,objectIds:i,pageSize:n,size:o}=this;if(0===o)return 0;if(this.paginationEnabled){const l=this.pageCount===this.pageIndex+1&&o%n||n;return t?Math.min(e.length,l):i.length?Math.min(i.length,l):l}return t?e.length:i.length?i.length:o}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(t){this._set("filterBySelectionEnabled",t)}get groupColumns(){return this.columns.toArray().filter(t=>r(t))}get hasInvalidColumnConfiguration(){return this.visibleColumns.every(t=>t.frozen||t.frozenToEnd)}get highlightIds(){return this._get("highlightIds")||new e}set highlightIds(t){let n=Array.isArray(t)?new e(t):t;this.multipleSelectionEnabled||(n=n.slice(0,1)),this._set("highlightIds",i(n,this._get("highlightIds"),e))}get isEditing(){return this.editableColumns.some(t=>t.editInfo)}get isQuerying(){return this.store.isQuerying}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing}get isSyncing(){return this.store.isSyncing}get objectIds(){return this._get("objectIds")??new e}set objectIds(t){this._set("objectIds",i(t,this._get("objectIds"),e))}get pageCount(){const{pageSize:t,size:e}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(t){const{pageCount:e}=this;u(t,e)&&this._set("pageIndex",t)}get pageSize(){return this.store.pageSize}set pageSize(t){this.store.pageSize=t}get rowHighlightIds(){return this._get("rowHighlightIds")||new e}set rowHighlightIds(t){this._set("rowHighlightIds",i(t,this._get("rowHighlightIds"),e))}get size(){const t=this.store?.count??0,{maxSize:e}=this;return null!=t&&null!=e?Math.min(e,t):t}get state(){return this.store.state}get visibleColumns(){return this.columns.toArray().filter(t=>!t.hidden)}closeColumnMenus(){this.allColumns.forEach(t=>t.closeMenu())}sortColumn(t,e){if(!t)return;const i=this.findColumn(t);i&&(i.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.allColumns.forEach(t=>{t.hidden&&(t.hidden=!1)})}findColumn(t){return this.allColumns.find(e=>e.fieldName===t)}refresh(){this.store.reset(),this.store.load()}toggleColumnVisibility(t){const e=this.findColumn(t);e&&(e.hidden=!e.hidden)}};t([o()],d.prototype,"actionColumn",null),t([o()],d.prototype,"actionColumnConfig",void 0),t([o()],d.prototype,"allColumns",null),t([o()],d.prototype,"allVisibleColumns",null),t([o()],d.prototype,"cellPartNameGenerator",void 0),t([o()],d.prototype,"columnMenuIsOpen",null),t([o()],d.prototype,"columnPerformanceModeEnabled",void 0),t([o()],d.prototype,"columnReorderingEnabled",void 0),t([o()],d.prototype,"columns",void 0),t([o()],d.prototype,"dataProvider",void 0),t([o()],d.prototype,"editingEnabled",null),t([o()],d.prototype,"editableColumns",null),t([o()],d.prototype,"effectiveSize",null),t([o()],d.prototype,"filterBySelectionEnabled",null),t([o()],d.prototype,"groupColumns",null),t([o()],d.prototype,"hasInvalidColumnConfiguration",null),t([o()],d.prototype,"highlightIds",null),t([o()],d.prototype,"isEditing",null),t([o()],d.prototype,"isQuerying",null),t([o()],d.prototype,"isQueryingOrSyncing",null),t([o()],d.prototype,"isSyncing",null),t([o()],d.prototype,"maxSize",void 0),t([o()],d.prototype,"multipleSelectionEnabled",void 0),t([o()],d.prototype,"multiSortEnabled",void 0),t([o()],d.prototype,"multipleSortPriority",void 0),t([o()],d.prototype,"noDataMessage",void 0),t([o()],d.prototype,"objectIds",null),t([o()],d.prototype,"pageCount",null),t([o()],d.prototype,"pageIndex",null),t([o()],d.prototype,"pageSize",null),t([o()],d.prototype,"paginationEnabled",void 0),t([o()],d.prototype,"rowHighlightIds",null),t([o()],d.prototype,"rowDetailsRenderer",void 0),t([o({readOnly:!0})],d.prototype,"size",null),t([o()],d.prototype,"store",void 0),t([o({readOnly:!0})],d.prototype,"state",null),t([o()],d.prototype,"visibleColumns",null),d=t([l("esri.widgets.FeatureTable.Grid.GridViewModel")],d);const h=d;export{h as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import{referenceSetter as i}from"../../../core/collectionUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isGroupColumn as s}from"../support/columnUtils.js";import{uniqueColumnNames as r,isPageIndexValid as d}from"../support/tableUtils.js";let u=class extends n{constructor(t){super(t),this.actionColumnConfig=null,this.cellPartNameGenerator=(t,e)=>{const i=e.item.objectId;let n="";e?.item&&this.rowHighlightIds.includes(i)&&(n+=" highlight");const o=this.findColumn(t?.path);return o?(o.invalid&&(n+=" invalid"),o.textWrap&&(n+=" text-wrap"),"editInfo"in o&&o.editInfo&&o.editInfo.rowData?.index===e.index&&(n+=" editing"),o?.store?.hasPendingEdits&&o.store.itemHasPendingEdits(i,o.fieldName)&&(n+=" pending-edit"),n):n},this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new e,this.dataProvider=async(t,e)=>{const{store:i}=this;if(!e)return;e(await i.fetchItems(t))},this.maxSize=null,this.multipleSelectionEnabled=!0,this.multiSortEnabled=!1,this.multipleSortPriority="prepend",this.noDataMessage=null,this.paginationEnabled=!1,this.rowDetailsRenderer=null,this.store=null}get actionColumn(){return this.allColumns.find(t=>t.fieldName===r.action)}get allColumns(){return this.columns.toArray().flatMap(t=>[t,...s(t)&&t.columns?.length?t.columns:[]])}get allVisibleColumns(){return this.allColumns.filter(t=>!t.hidden)}get columnMenuIsOpen(){return this.allColumns.some(t=>t.menuIsOpen)}get editingEnabled(){return this.store.editingEnabled}set editingEnabled(t){this.store.editingEnabled=t}get editableColumns(){return this.allColumns.filter(t=>"editable"in t)}get effectiveSize(){const{filterBySelectionEnabled:t,highlightIds:e,objectIds:i,pageSize:n,size:o}=this;if(0===o)return 0;if(this.paginationEnabled){const l=this.pageCount===this.pageIndex+1&&o%n||n;return t?Math.min(e.length,l):i.length?Math.min(i.length,l):l}return t?e.length:i.length?i.length:o}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(t){this._set("filterBySelectionEnabled",t)}get groupColumns(){return this.columns.toArray().filter(t=>s(t))}get hasInvalidColumnConfiguration(){return this.visibleColumns.every(t=>t.frozen||t.frozenToEnd)}get highlightIds(){return this._get("highlightIds")||new e}set highlightIds(t){let n=Array.isArray(t)?new e(t):t;this.multipleSelectionEnabled||(n=n.slice(0,1)),this._set("highlightIds",i(n,this._get("highlightIds"),e))}get isEditing(){return this.editableColumns.some(t=>t.editInfo)}get isQuerying(){return this.store.isQuerying}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing}get isSyncing(){return this.store.isSyncing}get objectIds(){return this._get("objectIds")??new e}set objectIds(t){this._set("objectIds",i(t,this._get("objectIds"),e))}get pageCount(){const{pageSize:t,size:e}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(t){const{pageCount:e}=this;d(t,e)&&this._set("pageIndex",t)}get pageSize(){return this.store.pageSize}set pageSize(t){this.store.pageSize=t}get rowHighlightIds(){return this._get("rowHighlightIds")||new e}set rowHighlightIds(t){this._set("rowHighlightIds",i(t,this._get("rowHighlightIds"),e))}get size(){const t=this.store?.count??0,{maxSize:e}=this;return null!=t&&null!=e?Math.min(e,t):t}get state(){return this.store.state}get visibleColumns(){return this.columns.toArray().filter(t=>!t.hidden)}closeColumnMenus(){this.allColumns.forEach(t=>t.closeMenu())}sortColumn(t,e){if(!t)return;const i=this.findColumn(t);i&&(i.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.allColumns.forEach(t=>{t.hidden&&(t.hidden=!1)})}findColumn(t){return this.allColumns.find(e=>e.fieldName===t)}refresh(){this.store.reset(),this.store.load()}toggleColumnVisibility(t){const e=this.findColumn(t);e&&(e.hidden=!e.hidden)}};t([o()],u.prototype,"actionColumn",null),t([o()],u.prototype,"actionColumnConfig",void 0),t([o()],u.prototype,"allColumns",null),t([o()],u.prototype,"allVisibleColumns",null),t([o()],u.prototype,"cellPartNameGenerator",void 0),t([o()],u.prototype,"columnMenuIsOpen",null),t([o()],u.prototype,"columnPerformanceModeEnabled",void 0),t([o()],u.prototype,"columnReorderingEnabled",void 0),t([o()],u.prototype,"columns",void 0),t([o()],u.prototype,"dataProvider",void 0),t([o()],u.prototype,"editingEnabled",null),t([o()],u.prototype,"editableColumns",null),t([o()],u.prototype,"effectiveSize",null),t([o()],u.prototype,"filterBySelectionEnabled",null),t([o()],u.prototype,"groupColumns",null),t([o()],u.prototype,"hasInvalidColumnConfiguration",null),t([o()],u.prototype,"highlightIds",null),t([o()],u.prototype,"isEditing",null),t([o()],u.prototype,"isQuerying",null),t([o()],u.prototype,"isQueryingOrSyncing",null),t([o()],u.prototype,"isSyncing",null),t([o()],u.prototype,"maxSize",void 0),t([o()],u.prototype,"multipleSelectionEnabled",void 0),t([o()],u.prototype,"multiSortEnabled",void 0),t([o()],u.prototype,"multipleSortPriority",void 0),t([o()],u.prototype,"noDataMessage",void 0),t([o()],u.prototype,"objectIds",null),t([o()],u.prototype,"pageCount",null),t([o()],u.prototype,"pageIndex",null),t([o()],u.prototype,"pageSize",null),t([o()],u.prototype,"paginationEnabled",void 0),t([o()],u.prototype,"rowHighlightIds",null),t([o()],u.prototype,"rowDetailsRenderer",void 0),t([o({readOnly:!0})],u.prototype,"size",null),t([o()],u.prototype,"store",void 0),t([o({readOnly:!0})],u.prototype,"state",null),t([o()],u.prototype,"visibleColumns",null),u=t([l("esri.widgets.FeatureTable.Grid.GridViewModel")],u);const a=u;export{a as default};
@@ -4,7 +4,7 @@ import type TableMenuVisibleElements from "./TableMenuVisibleElements.js";
4
4
  import type { ColumnMenuVisibleElementsProperties } from "./ColumnMenuVisibleElements.js";
5
5
  import type { TableMenuVisibleElementsProperties } from "./TableMenuVisibleElements.js";
6
6
 
7
- export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "columnDescriptions" | "columnMenus" | "header" | "layerDropdown" | "layerDropdownIcons" | "menu" | "progress" | "selectionColumn" | "tooltips">> {
7
+ export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "columnDescriptions" | "columnMenus" | "header" | "layerDropdown" | "layerDropdownIcons" | "menu" | "pendingEditsFooter" | "selectionColumn" | "tooltips">> {
8
8
  /** _(Since 4.30)_ The menu items within the column menu. */
9
9
  columnMenuItems?: ColumnMenuVisibleElementsProperties;
10
10
  /** The menu items within the feature table menu. */
@@ -65,7 +65,7 @@ export default abstract class VisibleElements extends Accessor {
65
65
  *
66
66
  * @default true
67
67
  */
68
- accessor progress: boolean;
68
+ accessor pendingEditsFooter: boolean;
69
69
  /**
70
70
  * Indicates whether to display the selection column in the table. Each row has a checkbox that selects its corresponding feature. Default value is `true`. If working with a map, make certain to set the `FeatureTable.view` property as this enables highlighting the corresponding feature.
71
71
  *
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import e from"../../core/Accessor.js";import{property as t,subclass as l}from"../../core/accessorSupport/decorators.js";import n from"./ColumnMenuVisibleElements.js";import s from"./TableMenuVisibleElements.js";let p=class extends e{constructor(o){super(o),this.columnDescriptions=!0,this.columnMenus=!0,this.columnMenuItems=new n,this.close=!1,this.header=!0,this.layerDropdown=!1,this.layerDropdownIcons=!0,this.menu=!0,this.menuItems=new s,this.progress=!0,this.selectionColumn=!0,this.tooltips=!0}};o([t({type:Boolean,nonNullable:!0})],p.prototype,"columnDescriptions",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"columnMenus",void 0),o([t({type:n,nonNullable:!0})],p.prototype,"columnMenuItems",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"close",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"header",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"layerDropdown",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"layerDropdownIcons",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"menu",void 0),o([t({type:s,nonNullable:!0})],p.prototype,"menuItems",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"progress",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"selectionColumn",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"tooltips",void 0),p=o([l("esri.widgets.FeatureTable.VisibleElements")],p);const r=p;export{r as default};
5
+ import{__decorate as o}from"tslib";import e from"../../core/Accessor.js";import{property as t,subclass as l}from"../../core/accessorSupport/decorators.js";import n from"./ColumnMenuVisibleElements.js";import s from"./TableMenuVisibleElements.js";let p=class extends e{constructor(o){super(o),this.columnDescriptions=!0,this.columnMenus=!0,this.columnMenuItems=new n,this.close=!1,this.header=!0,this.layerDropdown=!1,this.layerDropdownIcons=!0,this.menu=!0,this.menuItems=new s,this.pendingEditsFooter=!0,this.progress=!0,this.selectionColumn=!0,this.tooltips=!0}};o([t({type:Boolean,nonNullable:!0})],p.prototype,"columnDescriptions",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"columnMenus",void 0),o([t({type:n,nonNullable:!0})],p.prototype,"columnMenuItems",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"close",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"header",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"layerDropdown",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"layerDropdownIcons",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"menu",void 0),o([t({type:s,nonNullable:!0})],p.prototype,"menuItems",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"pendingEditsFooter",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"progress",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"selectionColumn",void 0),o([t({type:Boolean,nonNullable:!0})],p.prototype,"tooltips",void 0),p=o([l("esri.widgets.FeatureTable.VisibleElements")],p);const r=p;export{r as default};