@arcgis/core 4.31.0-next.20240521 → 4.31.0-next.20240523
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WebMap.js +1 -1
- package/assets/components/assets/icon/developerCredentials16.json +1 -0
- package/assets/components/assets/icon/developerCredentials24.json +1 -0
- package/assets/components/assets/icon/developerCredentials32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d7722531be4892293cb1.js → 00c49f6c84444e69f3a1.js} +1 -1
- package/assets/esri/core/workers/chunks/01927419855947110cc1.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{df26d7d07fed1f124fc2.js → 0903b492782dca69eb48.js} +1 -1
- package/assets/esri/core/workers/chunks/158c05b16372d8ed33ea.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/190913c221964292333b.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{2529a4b1e135223833f0.js → 2635ab64e75d4ec700a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{f965644347007e3d68e2.js → 27dc94db9ed42b237ecb.js} +1 -1
- package/assets/esri/core/workers/chunks/36d620a9c051e451e6b3.js +1 -0
- package/assets/esri/core/workers/chunks/{0ae3ea7a73f3b5083968.js → 3a01cf7e3355f3c78378.js} +1 -1
- package/assets/esri/core/workers/chunks/4268373bf374b2a6252a.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/43e1c935452b489e422e.js +1 -0
- package/assets/esri/core/workers/chunks/{15212a82e283d6df2873.js → 4ae885f257660545ceeb.js} +1 -1
- package/assets/esri/core/workers/chunks/{4ea2ced4b5ea1c8a1cee.js → 4ba866a10711b6a8158f.js} +1 -1
- package/assets/esri/core/workers/chunks/50ee28a1944bde74a7c1.js +1 -0
- package/assets/esri/core/workers/chunks/59b193d42e8abf9d4088.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{eafbe663f7a61d3222c5.js → 5efe1300a39ab9c7bbab.js} +1 -1
- package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js → 606f8b907166190a8b65.js} +2 -2
- package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js.LICENSE.txt → 606f8b907166190a8b65.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{5349b0de83ae4be8afe2.js → 6c1ded9acf5c8be493ea.js} +1 -1
- package/assets/esri/core/workers/chunks/{46225ebc10a4398170b5.js → 712ba8ad69b1aab6f508.js} +1 -1
- package/assets/esri/core/workers/chunks/{7d210c2a5a135da2c37d.js → 7c68dc664c0b4cf2a46b.js} +1 -1
- package/assets/esri/core/workers/chunks/88c7d84a1fde246ca71f.js +1 -0
- package/assets/esri/core/workers/chunks/948867b3c17f6c0e753a.js +1 -0
- package/assets/esri/core/workers/chunks/9b04a666726b5d2ff3c5.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/9c75837b7e75f0f38dc0.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{9a217c5c55ce6fb1d3cd.js → a111eb0ae78a9f5be981.js} +1 -1
- package/assets/esri/core/workers/chunks/a6b138f330625d98f856.js +1 -0
- package/assets/esri/core/workers/chunks/{e4a0fd9e0f8887009b92.js → a8a19e5a7ae4ec16480a.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcf0016d56df8a69f6c1.js → aa198e898b46c6e89d0b.js} +1 -1
- package/assets/esri/core/workers/chunks/{04faa3bf4ef5a6f0ccb4.js → b3de9bc3e75476b0a7e9.js} +1 -1
- package/assets/esri/core/workers/chunks/b61e458ef5021adba1cb.js +1 -0
- package/assets/esri/core/workers/chunks/{bd0545bb100b3393fd85.js → bbec62f8792520993909.js} +1 -1
- package/assets/esri/core/workers/chunks/bf6e75cc75d3bdfb70cb.js +1 -0
- package/assets/esri/core/workers/chunks/{5acac4616c53a95cc48f.js → c0c8e1a709648e1305c6.js} +1 -1
- package/assets/esri/core/workers/chunks/{4f3a87586e334c52d0bf.js → caffbaa8b0a67d117f34.js} +1 -1
- package/assets/esri/core/workers/chunks/{7b4ed96554722be59ae2.js → d8140b5316e80d734155.js} +1 -1
- package/assets/esri/core/workers/chunks/dde183c6bb1710ff16df.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/e3711bc5b100b64cac3a.js +1 -0
- package/assets/esri/core/workers/chunks/{2d5d66cee7c3ec992bcd.js → e93e59f6907fa4c1081c.js} +1 -1
- package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +15 -1
- package/assets/esri/themes/base/widgets/_Grid.scss +4 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/Tooltip.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/workers/InvokeHandler.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/interfaces.d.ts +568 -48
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/package.json +2 -2
- package/portal/PortalItem.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
- package/rest/print.js +1 -1
- package/rest/support/printTaskUtils.js +1 -1
- package/smartMapping/renderers/support/referenceSizeUtils.js +1 -1
- package/smartMapping/support/adapters/support/layerUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/views/2d/GoToManager.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
- package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
- package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
- package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/editingTools/undoRecords.js +5 -0
- package/views/SceneView.js +1 -1
- package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/webdoc/support/SlideThumbnail.js +1 -1
- package/widgets/Bookmarks/BookmarksUserState.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/CatalogLayerList/CatalogLayerListViewModel.d.ts +4 -0
- package/widgets/CatalogLayerList.d.ts +4 -0
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/FeatureForm/support/textManipulationUtils.js +1 -1
- package/widgets/FeatureTable/VisibleElements.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList/support/layerListUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/VideoPlayer/components/SettingsButton.js +1 -1
- package/assets/esri/core/workers/chunks/0753c636c2801f067235.js +0 -1
- package/assets/esri/core/workers/chunks/50936725c9bd23b780ef.js +0 -1
- package/assets/esri/core/workers/chunks/5c8c5290b9fcb5a4468f.js +0 -1
- package/assets/esri/core/workers/chunks/7745209175eb744aee5c.js +0 -1
- package/assets/esri/core/workers/chunks/80b1b1e8f3f7b9d2ad20.js +0 -1
- package/assets/esri/core/workers/chunks/aa020d495f464eff0134.js +0 -1
- package/assets/esri/core/workers/chunks/bf2af659da8e33d3c8bf.js +0 -1
- package/assets/esri/core/workers/chunks/cbb3a56e4072cdf25a9d.js +0 -1
- package/assets/esri/core/workers/chunks/fb48e8e42379fdf8a094.js +0 -1
- package/views/3d/interactive/editingTools/transform/undoRecords.js +0 -5
- package/views/3d/support/MapCoordsHelper.js +0 -5
- package/widgets/Bookmarks/bookmarkUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as
|
|
5
|
+
import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import s from"./ColumnMenuVisibleElements.js";import n from"./TableMenuVisibleElements.js";let r=class extends e{constructor(o){super(o),this.columnMenus=!0,this.columnMenuItems=new s,this.close=!1,this.header=!0,this.layerDropdown=!1,this.menu=!0,this.menuItems=new n,this.progress=!0,this.selectionColumn=!0,this.tooltips=!0}};o([t({type:Boolean,nonNullable:!0})],r.prototype,"columnMenus",void 0),o([t({type:s,nonNullable:!0})],r.prototype,"columnMenuItems",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"close",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"header",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"layerDropdown",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"menu",void 0),o([t({type:n,nonNullable:!0})],r.prototype,"menuItems",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"progress",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"selectionColumn",void 0),o([t({type:Boolean,nonNullable:!0})],r.prototype,"tooltips",void 0),r=o([l("esri.widgets.FeatureTable.VisibleElements")],r);const p=r;export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as m,isIFeatureTableSupportedLayerWithRelationships as f}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return m(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return f(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{effectiveTimeExtent:r,effectiveWhere:s,filterGeometry:i,objectIds:o,orderByFields:a,returnGeometry:n,supportsCacheHint:u,supportsOrderBy:l,supportsPagination:p}=this,{layer:d,start:h,pageSize:c}=e,y=d.createQuery();y.returnGeometry=n,p?(y.start=h,y.num=c,y.where=s,y.timeExtent=r,y.objectIds=o):y.objectIds=o||this._getObjectIdsForPage(h,c??0),l&&(y.orderByFields=a),i&&(y.geometry=i),u&&(y.cacheHint=!0);return(await d.queryFeatures(y)).features}async _queryRelatedFeatures(e,t){const{orderByFields:r,returnGeometry:s,supportsCacheHint:i}=this,{layer:o,start:a,pageSize:n}=e,{objectId:u,relatedLayer:l,relationshipId:p}=t,d=o.createQuery(),h=new y({cacheHint:i,num:n??0,objectIds:[u],orderByFields:r,outFields:["*"],relationshipId:p,returnGeometry:s,start:a,where:d.where??void 0}),c=await l.queryRelatedFeatures(h);return c[u]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as m,isIFeatureTableSupportedLayerWithRelationships as f}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return m(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return f(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n?.length?n:void 0,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i?.length?i:void 0,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{effectiveTimeExtent:r,effectiveWhere:s,filterGeometry:i,objectIds:o,orderByFields:a,returnGeometry:n,supportsCacheHint:u,supportsOrderBy:l,supportsPagination:p}=this,{layer:d,start:h,pageSize:c}=e,y=o?.length,_=d.createQuery();_.returnGeometry=n,p?(_.start=h,_.num=c,_.where=s,_.timeExtent=r,_.objectIds=y?o:void 0):_.objectIds=y?o:this._getObjectIdsForPage(h,c??0),l&&(_.orderByFields=a),i&&(_.geometry=i),u&&(_.cacheHint=!0);return(await d.queryFeatures(_)).features}async _queryRelatedFeatures(e,t){const{orderByFields:r,returnGeometry:s,supportsCacheHint:i}=this,{layer:o,start:a,pageSize:n}=e,{objectId:u,relatedLayer:l,relationshipId:p}=t,d=o.createQuery(),h=new y({cacheHint:i,num:n??0,objectIds:[u],orderByFields:r,outFields:["*"],relationshipId:p,returnGeometry:s,start:a,where:d.where??void 0}),c=await l.queryRelatedFeatures(h);return c[u]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e.length?e:void 0,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|
package/widgets/FeatureTable.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./FeatureTable/ColumnMenuVisibleElements.js";import c from"./FeatureTable/FeatureTableViewModel.js";import h from"./FeatureTable/VisibleElements.js";import p from"./FeatureTable/support/FieldColumnTemplate.js";import m from"./FeatureTable/support/TableTemplate.js";import{uniqueColumnNames as u,isIFeatureTableSupportedLayerWithAttachments as g}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import{renderingSanitizer as y}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as _}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import{substitute as C}from"../intl/substitute.js";var S;const E="esri-feature-table",T=`${E}__prompt`,A={base:E,content:`${E}__content`,menuPopover:`${E}__menu-popover`,tableContainer:`${E}__table-container`,tableNavigation:`${E}__table-navigation`,expanded:`${E}__expanded`,collapsed:`${E}__collapsed`,promptContainer:T,promptHeader:`${T}__header`,promptHeading:`${T}__header__heading`,promptMessage:`${T}__message`,promptDivider:`${T}__divider`,promptActions:`${T}__actions`},I={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let R=S=class extends a{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.disabled=!1,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new c,this.visibleElements=new h,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return y.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":return y.sanitize(e.title);case"loading":return t.loading;case"error":return t.errorData}return C(t.header,{title:y.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get 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 objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return M("div",{bind:this,class:this.classes(A.base,w.widget)},M("calcite-panel",{bind:this,class:A.content,closable:t.close,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?M("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),M("div",{class:A.tableContainer},this._renderTables())),e?M("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(A.base,e?A.expanded:A.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return M("calcite-panel",null,M("div",null,[n?M("div",{class:s},t?.render()):void 0,...r.map((e=>{const t=i.indexOf(e);return M("div",{class:s,key:`related-${t}`},e.render())})),,]))}return t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=M("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?M("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return M("div",{class:`${A.promptContainer}--${i}`},M("div",{class:A.promptHeader},M("calcite-icon",{icon:"exclamation-mark-triangle"}),M(v,{class:A.promptHeading,level:2},e)),M("div",{class:A.promptMessage},t),M("div",{class:A.promptDivider}),M("div",{class:A.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=C(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return M("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:I.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:I.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:I.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:I.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[M("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?M("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(M("calcite-popover",{autoClose:!0,class:A.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},M("calcite-list",{filterEnabled:!0,selectionMode:"multiple"},...s.map((({effectiveLabel:e,fieldName:t,hidden:i})=>M("calcite-list-item",{key:`toggle-columns__item-${t}`,label:e,selected:!i,value:t,onCalciteListItemSelect:({target:e})=>o.toggleColumnVisibility(e.value)})))))),a}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const e=this.messages.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return M("div",{class:A.tableNavigation,key:"table-nav"},M("calcite-action",{icon:"move-up",key:e,onclick:()=>this._drainRelatedTables(),text:e,title:e}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),M("div",null,M("calcite-label",{layout:"inline"},"Show all tables",M("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return M("calcite-action",{icon:"chevron-right",key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([u.action,u.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([u.action,u.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new p({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new h({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([u.action,u.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,c=o.getObjectId()??o.attributes[r],p=e===this,{visibleElements:g}=e;e.set({highlightIds:new t([c]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new m({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new h({header:p&&g.header,progress:p&&g.progress,columnMenus:g.columnMenus,close:g.close,tooltips:g.tooltips,selectionColumn:!1,columnMenuItems:new d({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([u.action,u.attachments])}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],p=i.length,m=p?i.getItemAt(p-1):this;await n.load();const u=this.attachmentsEnabled&&g(n),b=new S({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:m,view:l,visibleElements:new h({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});b.addHandles([s((()=>m.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(b.highlightIds.removeAll(),b.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>m),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&m.highlightIds.add(e)}}))]),this.relatedTables.add(b),this.scheduleRender()}};e([n()],R.prototype,"_columnVisibilityActions",void 0),e([n()],R.prototype,"_effectiveTitle",null),e([n()],R.prototype,"_effectiveVisibleElements",null),e([n()],R.prototype,"_hasCustomMenuItems",null),e([n()],R.prototype,"_hasDefaultMenuItems",null),e([n()],R.prototype,"_prompt",void 0),e([n()],R.prototype,"_shouldShowMenu",null),e([n()],R.prototype,"_showAllTablesEnabled",void 0),e([n()],R.prototype,"_showClearSelectionAction",null),e([n()],R.prototype,"_showColumnsVisibilityAction",null),e([n()],R.prototype,"_showDeleteSelectionAction",null),e([n()],R.prototype,"_showRefreshDataAction",null),e([n()],R.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],R.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],R.prototype,"_showZoomToSelectionAction",null),e([n()],R.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],R.prototype,"activeFilters",null),e([n({readOnly:!0})],R.prototype,"activeSortOrders",null),e([n()],R.prototype,"attachmentsEnabled",null),e([n()],R.prototype,"autoRefreshEnabled",null),e([n()],R.prototype,"columnPerformanceModeEnabled",null),e([n()],R.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],R.prototype,"columns",null),e([n()],R.prototype,"disabled",void 0),e([n()],R.prototype,"editingEnabled",null),e([n()],R.prototype,"filterGeometry",null),e([n()],R.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],R.prototype,"grid",null),e([n()],R.prototype,"hiddenFields",null),e([n()],R.prototype,"highlightEnabled",null),e([n()],R.prototype,"highlightIds",null),e([n()],R.prototype,"icon",null),e([n()],R.prototype,"isQueryingOrSyncing",null),e([n()],R.prototype,"label",null),e([n()],R.prototype,"layer",null),e([n()],R.prototype,"layerView",null),e([n(),f("esri/widgets/FeatureTable/t9n/FeatureTable")],R.prototype,"messages",null),e([n(),f("esri/t9n/common")],R.prototype,"messagesCommon",null),e([n(),f("esri/widgets/support/t9n/uriUtils")],R.prototype,"messagesURIUtils",null),e([n()],R.prototype,"menuConfig",void 0),e([n()],R.prototype,"multipleSelectionEnabled",null),e([n()],R.prototype,"multiSortEnabled",null),e([n()],R.prototype,"objectIds",null),e([n()],R.prototype,"pageSize",null),e([n()],R.prototype,"relatedRecordsEnabled",null),e([n()],R.prototype,"relatedTable",null),e([n()],R.prototype,"relatedTables",void 0),e([n()],R.prototype,"relationship",null),e([n()],R.prototype,"relationshipColumnConfigs",null),e([n()],R.prototype,"relationshipConfig",null),e([n()],R.prototype,"returnGeometryEnabled",null),e([n()],R.prototype,"rowHighlightIds",null),e([n()],R.prototype,"selectionSource",null),e([n()],R.prototype,"showRelatedTableCallback",null),e([n()],R.prototype,"size",null),e([n({readOnly:!0})],R.prototype,"state",null),e([n({constructOnly:!0})],R.prototype,"tableParent",void 0),e([n()],R.prototype,"tableTemplate",null),e([n()],R.prototype,"tableTemplateOverride",null),e([n()],R.prototype,"title",void 0),e([n()],R.prototype,"timeExtent",null),e([n()],R.prototype,"timeZone",null),e([n()],R.prototype,"view",null),e([n({type:c}),_(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],R.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],R.prototype,"visibleElements",void 0),e([n({type:h})],R.prototype,"visibleElementsOverride",void 0),R=S=e([r("esri.widgets.FeatureTable")],R);const j=R;export{j as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as a}from"../layers/catalog/catalogUtils.js";import d from"./Widget.js";import c from"./FeatureTable/ColumnMenuVisibleElements.js";import h from"./FeatureTable/FeatureTableViewModel.js";import p from"./FeatureTable/VisibleElements.js";import m from"./FeatureTable/support/FieldColumnTemplate.js";import u from"./FeatureTable/support/TableTemplate.js";import{isIFeatureTableSupportedLayer as g,uniqueColumnNames as b,isIFeatureTableSupportedLayerWithAttachments as w}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as v}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{Heading as f}from"./support/Heading.js";import{renderingSanitizer as _}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as C}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";var S;const A="esri-feature-table",I=`${A}__prompt`,R={base:A,content:`${A}__content`,menuPopover:`${A}__menu-popover`,layerDropdownMenu:`${A}__layer-switcher-menu`,tableContainer:`${A}__table-container`,tableNavigation:`${A}__table-navigation`,expanded:`${A}__expanded`,collapsed:`${A}__collapsed`,promptContainer:I,promptHeader:`${I}__header`,promptHeading:`${I}__header__heading`,promptMessage:`${I}__message`,promptDivider:`${I}__divider`,promptActions:`${I}__actions`},j={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let k=S=class extends d{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.disabled=!1,this.layers=null,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new h,this.visibleElements=new p,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return v({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?[...t]:[...this._viewLayers];return e&&!i.includes(e)&&i.push(e),i}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return _.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":return _.sanitize(e.title);case"loading":return t.loading;case"error":return t.errorData}return E(t.header,{title:_.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=[...e.allLayers,...e.allTables];return t.length?t.filter((e=>!a(e)&&g(e))):[]}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this._drainRelatedTables(),this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get 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 objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return T("div",{bind:this,class:this.classes(R.base,y.widget)},T("calcite-panel",{bind:this,class:R.content,closable:t.close,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?T("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),T("div",{class:R.tableContainer},this._renderTables())),e?T("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(R.base,e?R.expanded:R.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return T("calcite-panel",{overlayPositioning:"fixed"},T("div",null,[n?T("div",{class:s},t?.render()):void 0,...r.map((e=>{const t=i.indexOf(e);return T("div",{class:s,key:`related-${t}`},e.render())})),,]))}return t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=T("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?T("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return T("div",{class:`${R.promptContainer}--${i}`},T("div",{class:R.promptHeader},T("calcite-icon",{icon:"exclamation-mark-triangle"}),T(f,{class:R.promptHeading,level:2},e)),T("div",{class:R.promptMessage},t),T("div",{class:R.promptDivider}),T("div",{class:R.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=E(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return T("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:j.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:j.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:j.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:j.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:j.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:j.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[T("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?T("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(T("calcite-popover",{autoClose:!0,class:R.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},T("calcite-list",{filterEnabled:!0,selectionMode:"multiple"},...s.map((({effectiveLabel:e,fieldName:t,hidden:i})=>T("calcite-list-item",{key:`toggle-columns__item-${t}`,label:e,selected:!i,value:t,onCalciteListItemSelect:({target:e})=>o.toggleColumnVisibility(e.value)})))))),a}_renderLayerDropdownItem(e){return T("calcite-dropdown-item",{label:e.title??"",onclick:()=>{this.layer=e},selected:e===this.layer,value:e.id},e.title)}_renderLayerDropdown(){const e=this.messages.selectALayer;return T("div",{class:R.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},T("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-end"},T("calcite-action",{icon:"layers",slot:"trigger",text:e,title:e}),T("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map((e=>this._renderLayerDropdownItem(e)))??null)))}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const{messages:e}=this,t=e.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return T("div",{class:R.tableNavigation,key:"table-nav"},T("calcite-action",{icon:"move-up",key:t,onclick:()=>this._drainRelatedTables(),text:t,title:t}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),T("div",null,T("calcite-label",{layout:"inline"},e.showAllTables,T("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return T("calcite-action",{icon:"chevron-right",key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([b.action,b.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([b.action,b.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new u({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new m({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new u({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new p({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new c({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([b.action,b.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([b.action,b.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,d=o.getObjectId()??o.attributes[r],h=e===this,{close:m,columnMenus:g,header:w,layerDropdown:v,menu:y,menuItems:f,progress:_,tooltips:M}=e.visibleElements;e.set({highlightIds:new t([d]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new u({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new p({header:h&&w,progress:h&&_,columnMenus:g,close:m,layerDropdown:v,menu:y,menuItems:f,tooltips:M,selectionColumn:!1,columnMenuItems:new c({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([b.action,b.attachments])}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],h=i.length,m=h?i.getItemAt(h-1):this;await n.load();const u=this.attachmentsEnabled&&w(n),g=new S({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:m,view:l,visibleElements:new p({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});g.addHandles([s((()=>m.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(g.highlightIds.removeAll(),g.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>m),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&m.highlightIds.add(e)}}))]),this.relatedTables.add(g),this.scheduleRender()}};e([n()],k.prototype,"_columnVisibilityActions",void 0),e([n()],k.prototype,"_effectiveLayers",null),e([n()],k.prototype,"_effectiveTitle",null),e([n()],k.prototype,"_effectiveVisibleElements",null),e([n()],k.prototype,"_hasCustomMenuItems",null),e([n()],k.prototype,"_hasDefaultMenuItems",null),e([n()],k.prototype,"_prompt",void 0),e([n()],k.prototype,"_shouldShowMenu",null),e([n()],k.prototype,"_showAllTablesEnabled",void 0),e([n()],k.prototype,"_showClearSelectionAction",null),e([n()],k.prototype,"_showColumnsVisibilityAction",null),e([n()],k.prototype,"_showDeleteSelectionAction",null),e([n()],k.prototype,"_showLayerDropdown",null),e([n()],k.prototype,"_showRefreshDataAction",null),e([n()],k.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],k.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],k.prototype,"_showZoomToSelectionAction",null),e([n()],k.prototype,"_viewLayers",null),e([n()],k.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],k.prototype,"activeFilters",null),e([n({readOnly:!0})],k.prototype,"activeSortOrders",null),e([n()],k.prototype,"attachmentsEnabled",null),e([n()],k.prototype,"autoRefreshEnabled",null),e([n()],k.prototype,"columnPerformanceModeEnabled",null),e([n()],k.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],k.prototype,"columns",null),e([n()],k.prototype,"disabled",void 0),e([n()],k.prototype,"editingEnabled",null),e([n()],k.prototype,"filterGeometry",null),e([n()],k.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],k.prototype,"grid",null),e([n()],k.prototype,"hiddenFields",null),e([n()],k.prototype,"highlightEnabled",null),e([n()],k.prototype,"highlightIds",null),e([n()],k.prototype,"icon",null),e([n()],k.prototype,"isQueryingOrSyncing",null),e([n()],k.prototype,"label",null),e([n()],k.prototype,"layer",null),e([n()],k.prototype,"layers",void 0),e([n()],k.prototype,"layerView",null),e([n(),M("esri/widgets/FeatureTable/t9n/FeatureTable")],k.prototype,"messages",null),e([n(),M("esri/t9n/common")],k.prototype,"messagesCommon",null),e([n(),M("esri/widgets/support/t9n/uriUtils")],k.prototype,"messagesURIUtils",null),e([n()],k.prototype,"menuConfig",void 0),e([n()],k.prototype,"multipleSelectionEnabled",null),e([n()],k.prototype,"multiSortEnabled",null),e([n()],k.prototype,"objectIds",null),e([n()],k.prototype,"pageSize",null),e([n()],k.prototype,"relatedRecordsEnabled",null),e([n()],k.prototype,"relatedTable",null),e([n()],k.prototype,"relatedTables",void 0),e([n()],k.prototype,"relationship",null),e([n()],k.prototype,"relationshipColumnConfigs",null),e([n()],k.prototype,"relationshipConfig",null),e([n()],k.prototype,"returnGeometryEnabled",null),e([n()],k.prototype,"rowHighlightIds",null),e([n()],k.prototype,"selectionSource",null),e([n()],k.prototype,"showRelatedTableCallback",null),e([n()],k.prototype,"size",null),e([n({readOnly:!0})],k.prototype,"state",null),e([n({constructOnly:!0})],k.prototype,"tableParent",void 0),e([n()],k.prototype,"tableTemplate",null),e([n()],k.prototype,"tableTemplateOverride",null),e([n()],k.prototype,"title",void 0),e([n()],k.prototype,"timeExtent",null),e([n()],k.prototype,"timeZone",null),e([n()],k.prototype,"view",null),e([n({type:h}),C(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],k.prototype,"viewModel",void 0),e([n({type:p,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([n({type:p})],k.prototype,"visibleElementsOverride",void 0),k=S=e([r("esri.widgets.FeatureTable")],k);const F=k;export{F as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as m}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as f}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{system as v}from"../../time/timeZoneUtils.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import b from"../Feature/FeatureViewModel.js";import{ActionsCollection as C,zoomToFeature as P,zoomToClusteredFeatures as E,browseClusteredFeatures as j}from"../Popup/actions.js";import{triggerAction as M,isClusterFeature as A,removeClusteredFeaturesForBrowsing as L,displayClusterExtent as V,browseAggregateFeatures as I,getSelectedTarget as S}from"../Popup/actionUtils.js";import x from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../geometry/Point.js";const H=()=>[P.clone()],B=()=>[E.clone(),j.clone()];let U=null;function Z(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(x)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new C,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new T({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||F:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=o?g(o,t):null;if(!a)return;U||(U=await import("../../geometry/geometryEngineAsync.js")),await U.intersects(a,s)||(this.location=(await U.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=m(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>M({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.map,this.spatialReference,this.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new C;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new C;return e.removeAll(),e.addMany(A(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=f(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??v}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=S(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){L(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await V(this),await I(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await w(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await w(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=m(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(0),h=[];t.forEach(((t,i)=>{if(!t)return;let u=null;if(l.some(((e,i)=>(e&&e.graphic===t&&(u=e,l.splice(i,1)),!!u))),u)h[i]=u;else{const l=new b({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});h[i]=l}})),l.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",h)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await p(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:C})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:C,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:R})],G.prototype,"location",null),e([c()],G.prototype,"map",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"timeZone",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as m}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as f}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{system as v}from"../../time/timeZoneUtils.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import b from"../Feature/FeatureViewModel.js";import{ActionsCollection as C,zoomToFeature as P,zoomToClusteredFeatures as E,browseClusteredFeatures as j}from"../Popup/actions.js";import{triggerAction as M,isClusterFeature as A,removeClusteredFeaturesForBrowsing as L,displayClusterExtent as V,browseAggregateFeatures as I,getSelectedTarget as S}from"../Popup/actionUtils.js";import x from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../geometry/Point.js";const H=()=>[P.clone()],B=()=>[E.clone(),j.clone()];let U=null;function Z(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(x)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new C,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new T({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o((async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||F:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=o?g(o,t):null;if(!a)return;U||(U=await import("../../geometry/geometryEngineAsync.js")),await U.intersects(a,s)||(this.location=(await U.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=m(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>M({event:e,viewModel:this,view:this.view}))),u((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),h),l((()=>[this.features,this.map,this.spatialReference,this.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),u((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new C;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new C;return e.removeAll(),e.addMany(A(this.selectedFeature)?B():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=f(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??v}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=S(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){L(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await V(this),await I(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(P.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await w(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await w(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=m(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(0),u=[];t.forEach(((t,i)=>{if(!t)return;let h=null;if(l.some(((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h))),h)u[i]=h;else{const l=new b({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}})),l.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await p(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&_(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:C})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:C,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:R})],G.prototype,"location",null),e([c()],G.prototype,"map",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"timeZone",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{IdentifiableMixin as t}from"../../core/Identifiable.js";import{destroyMaybe as i}from"../../core/maybe.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{IdentifiableMixin as t}from"../../core/Identifiable.js";import{destroyMaybe as i}from"../../core/maybe.js";import{watch as n,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import l from"../Widget.js";import{isSublayer as d}from"./support/layerListUtils.js";import{isWidget as a}from"../support/widget.js";import{tsx as p}from"../support/jsxFactory.js";let g=class extends(t(l)){constructor(e,t){super(e,t),this._legend=null,this.className=null,this.content=null,this.flowEnabled=!1,this.image=null,this.listItem=null,this.open=!1,this.visible=!0}initialize(){this.addHandles([n((()=>this._canCreateLegend),(()=>this._createLegend()),r),n((()=>[this._legend,this._legendOptions]),(()=>this._updateLegend()),r)])}destroy(){this._legend=i(this._legend)}get _canCreateLegend(){const{content:e,listItem:t}=this;if(!t)return!1;const i="legend";return e===i||null!=e&&!!Array.isArray(e)&&e.includes(i)}get _legendOptions(){const{listItem:e,_legendLayerInfo:t}=this,i=e?.view;return t&&i?{view:i,layerInfos:[t]}:{}}get _legendLayerInfo(){const e=this.listItem?.layer;if(!e||"subtype-sublayer"===e.type)return null;const t=d(e)?e:null,i=e?.parent,n=null!=i&&"type"in i&&"map-image"===i.type?t?.source:null,r="";return n&&i?{layer:i,title:r,sublayerIds:[n.mapLayerId]}:{layer:e,title:r}}get disabled(){const{listItem:e,_legend:t,content:i}=this;return!e||!(Array.isArray(i)&&i.length>1)&&(!!t&&(!t.activeLayerInfos?.length||!e.visibleAtCurrentScale||!e.visible))}set disabled(e){this._overrideIfSome("disabled",e)}get icon(){const{image:e}=this,t=this._getFirstWidget();return this._get("icon")??(!e&&t?t.icon:null)}set icon(e){this._overrideIfSome("icon",e)}get title(){return this._get("title")||(this._getFirstWidget()?.label??"")}set title(e){this._override("title",e)}render(){return p("div",{class:"esri-list-item-panel"},this._renderContents())}_renderContent(e){const{_legend:t,disabled:i}=this;return!e||i?null:"legend"===e&&t?p("div",{key:"legend-widget"},t.render()):"string"==typeof e?p("div",{innerHTML:e,key:e}):a(e)?p("div",{key:"content-widget"},e.render()):e instanceof HTMLElement?p("div",{afterCreate:this._attachToNode,bind:e,key:"content-element"}):null}_renderContents(){const{content:e}=this;return Array.isArray(e)?e.map((e=>this._renderContent(e))):this._renderContent(e)}async _createLegend(){if(i(this._legend),this._legend=null,!this._canCreateLegend)return;const{default:e}=await import("../Legend.js"),t=new e(this._legendOptions);this._legend=t}_attachToNode(e){e.appendChild(this)}_updateLegend(){const e=this._legend;e&&e.set(this._legendOptions)}_getWidget(e){return"legend"===e?this._legend:a(e)?e:null}_getFirstWidget(){const{content:e}=this;return Array.isArray(e)?e.map((e=>this._getWidget(e))).find((e=>e)):this._getWidget(e)}};e([s()],g.prototype,"_legend",void 0),e([s()],g.prototype,"_canCreateLegend",null),e([s()],g.prototype,"_legendOptions",null),e([s()],g.prototype,"_legendLayerInfo",null),e([s()],g.prototype,"className",void 0),e([s()],g.prototype,"content",void 0),e([s()],g.prototype,"disabled",null),e([s()],g.prototype,"flowEnabled",void 0),e([s()],g.prototype,"icon",null),e([s()],g.prototype,"image",void 0),e([s()],g.prototype,"listItem",void 0),e([s()],g.prototype,"open",void 0),e([s()],g.prototype,"title",null),e([s()],g.prototype,"visible",void 0),g=e([o("esri.widgets.LayerList.ListItemPanel")],g);const c=g;export{c as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const i={hide:"hide",hideChildren:"hide-children"},
|
|
5
|
+
const i={hide:"hide",hideChildren:"hide-children"},n=10,e=2;function t({exclusive:i,visible:n,visibilityAppearance:e}){const t="checkbox"===e;return n?i?"circle-f":t?"check-square-f":"view-visible":i?"circle":t?"square":"view-hide"}function r({connectionStatus:i,publishing:n}){return i?"connected"===i?"beacon":"offline":n?"square":"bullet-point"}function l(n){return n?.listMode===i.hideChildren}function u(i){return i?.listMode??void 0}function s(i){if(!i)return"inherited";const n=b(p(i)?i.layer:i);return null!=n?n?"independent":"inherited":"visibilityMode"in i&&null!=i.visibilityMode?i.visibilityMode:"independent"}function o(i){if(i&&(!("type"in i)||"wmts"!==i.type))return"sublayers"in i?"sublayers":"layers"in i?"layers":void 0}function a(i){const n=(i?.layer&&p(i.layer)?i.layer.layer:void 0)??i?.layer;return!!n&&("catalog"!==n.type&&(h(n)??!0))}function c(n){return u(n)!==i.hide}function d(i,n){i?.sort(((i,e)=>{const t="uid"in i?n.indexOf(i.uid):-1,r="uid"in e?n.indexOf(e.uid):-1;return t>r?-1:t<r?1:0}))}function y(i,n){const e=i?.layer;if(!e)return;const t=o(e);if(!t)return;let r;"layers"===t&&"layers"in e?r=e.layers:"sublayers"===t&&"sublayers"in e&&(r=e.sublayers),d(r,n)}function f(i){const n=i?.layer;return n&&"layers"in n?n.layers:null}function p(i){return null!=i&&"layer"in i&&null!=i.layer}function b(i){const n=v(i);return null!=n&&"supportsSublayerVisibility"in n?n.supportsSublayerVisibility:void 0}function h(i){const n=v(i);return null!=n&&"supportsDynamicLayers"in n?n.supportsDynamicLayers:void 0}function v(i){return i&&"capabilities"in i&&null!=i.capabilities&&"exportMap"in i.capabilities?i.capabilities.exportMap:void 0}function x(i){return i?.["data-item"]}function M(i){return i?.getAttribute("data-layer-type")}function m({children:i,error:n,incompatible:e}){return!!i?.filter((i=>!i.hidden)).length&&!n&&!e}export{l as areChildrenHidden,c as canDisplayLayer,a as canSortSublayers,u as findLayerListMode,s as findLayerVisibilityMode,x as getItem,f as getItemLayers,M as getLayerType,o as getNormalizedChildLayerProperty,r as getStatusIcon,t as getVisibilityIcon,p as isSublayer,m as listItemHasChildren,e as minDragEnabledItems,n as minFilterItems,y as sortChildLayersToIds,d as sortLayersToIds};
|