@arcgis/core 4.28.3 → 4.28.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{15852a47129b9e0d04c6.js → 023fc8504d032762ad82.js} +1 -1
- package/assets/esri/core/workers/chunks/{80d9bb9f247ecdfa266f.js → 0695fcdc01f195c5ae8d.js} +1 -1
- package/assets/esri/core/workers/chunks/{4363f2cc3909c9258064.js → 076ac767b5148357f1b5.js} +1 -1
- package/assets/esri/core/workers/chunks/07cb7d142205f2eccc83.js +1 -0
- package/assets/esri/core/workers/chunks/0f6b766f08c648fd7b99.js +1 -0
- package/assets/esri/core/workers/chunks/16b56e541afa438dfb7f.js +1 -0
- package/assets/esri/core/workers/chunks/1c855f091d1305b82594.js +1 -0
- package/assets/esri/core/workers/chunks/28c4a21cdddf2602ab97.js +1 -0
- package/assets/esri/core/workers/chunks/2cf2340ad817f3c27802.js +1 -0
- package/assets/esri/core/workers/chunks/319c222ce72254934060.js +1 -0
- package/assets/esri/core/workers/chunks/340ab726ba40fe3a99c8.js +1 -0
- package/assets/esri/core/workers/chunks/46b4a17ec898ab744861.js +1 -0
- package/assets/esri/core/workers/chunks/4a5d0b49a641d182b5ea.js +1 -0
- package/assets/esri/core/workers/chunks/{7f3bc7a2de59e485f22f.js → 4f0412b52844aa9c7bd4.js} +1 -1
- package/assets/esri/core/workers/chunks/54867a094fb740a6f4d9.js +1 -0
- package/assets/esri/core/workers/chunks/5b80ae1eb79f1db75dc6.js +1 -0
- package/assets/esri/core/workers/chunks/80fcb63476829b6a48d2.js +1 -0
- package/assets/esri/core/workers/chunks/84725021c43f1122056a.js +1 -0
- package/assets/esri/core/workers/chunks/{9f0e8dd5c9bacfc0f03c.js → 908a5326b61843d6d2b3.js} +1 -1
- package/assets/esri/core/workers/chunks/9607460895182d31aef9.js +1 -0
- package/assets/esri/core/workers/chunks/9ef3746c545296565ef6.js +1 -0
- package/assets/esri/core/workers/chunks/{77f557359a5033d7e429.js → a0a86383e69932a25e50.js} +1 -1
- package/assets/esri/core/workers/chunks/a3bf50d9e24ad1de9847.js +1 -0
- package/assets/esri/core/workers/chunks/a5db3be5eeb3005df3c1.js +1 -0
- package/assets/esri/core/workers/chunks/a87ab14d6a6ccc9004a0.js +1 -0
- package/assets/esri/core/workers/chunks/af13150c711ba7b7f3ac.js +1 -0
- package/assets/esri/core/workers/chunks/ba00df2e707550939a6f.js +1 -0
- package/assets/esri/core/workers/chunks/ca43955065012d4b22e9.js +1 -0
- package/assets/esri/core/workers/chunks/cfa6d1b63b794febe70a.js +1 -0
- package/assets/esri/core/workers/chunks/e0382138cf58191a9697.js +1 -0
- package/assets/esri/core/workers/chunks/e076c5523dfb6c53a825.js +1 -0
- package/assets/esri/core/workers/chunks/{e3950975030412ff6e20.js → f343db8dad71f3840610.js} +1 -1
- package/assets/esri/core/workers/chunks/{46ddc52fe9cdd573a614.js → fa5c69a0cdd78aa34ad7.js} +1 -1
- package/assets/esri/core/workers/chunks/fe0c6814ef56604540b3.js +1 -0
- package/core/date.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/kernel.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/support/fetchService.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/layers/features/sources/DataTileSubscription.js +1 -1
- package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/assets/esri/core/workers/chunks/32fbd4355a4a649623a7.js +0 -1
- package/assets/esri/core/workers/chunks/41306b698f78001dda55.js +0 -1
- package/assets/esri/core/workers/chunks/423672fe765083e1a0ec.js +0 -1
- package/assets/esri/core/workers/chunks/49d958631bcd93f6333a.js +0 -1
- package/assets/esri/core/workers/chunks/49faa024bab1ba6e2bf0.js +0 -1
- package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +0 -1
- package/assets/esri/core/workers/chunks/7beae29abdfae23b15cc.js +0 -1
- package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +0 -1
- package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +0 -1
- package/assets/esri/core/workers/chunks/8e91be2e38010391e351.js +0 -1
- package/assets/esri/core/workers/chunks/90f96a2ddfb25d851d4d.js +0 -1
- package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +0 -1
- package/assets/esri/core/workers/chunks/97fd7b82eec26449977e.js +0 -1
- package/assets/esri/core/workers/chunks/9d97a20f69047d0c47cc.js +0 -1
- package/assets/esri/core/workers/chunks/ac4636e82a103e2c27ca.js +0 -1
- package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +0 -1
- package/assets/esri/core/workers/chunks/b0653f63745e756f55fe.js +0 -1
- package/assets/esri/core/workers/chunks/c2199fb8f7a54a0ef18a.js +0 -1
- package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +0 -1
- package/assets/esri/core/workers/chunks/c8cb5fe1d23145c4842b.js +0 -1
- package/assets/esri/core/workers/chunks/ce409944221a784ddb61.js +0 -1
- package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +0 -1
- package/assets/esri/core/workers/chunks/eb5213ffb83d83a4dd05.js +0 -1
- package/assets/esri/core/workers/chunks/f037e4f9877ea08ced9d.js +0 -1
- package/assets/esri/core/workers/chunks/f520f093aa81d8ee1790.js +0 -1
- package/assets/esri/core/workers/chunks/f7ccc6c681fc9218555c.js +0 -1
- package/assets/esri/core/workers/chunks/fab4ee57b7c5376c9ccd.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,e.point.spatialReference??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I as default};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,p.fromJSON(e.point.spatialReference)??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t,pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
|
|
5
|
+
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t.toJSON(),pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,dateTimeFieldValuesToNumericRange as a,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as p,isNumericField as d,isStringField as m,isTimeOnlyField as y,getFieldRange as h,TypeValidationError as f,NumericRangeValidationError as c,validateFieldValue as g}from"../../layers/support/fieldUtils.js";import{isAnyDateField as b}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as _,isFieldElementWithInputType as V,valueIsInvalidSwitchValue as w,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{isNumber as N}from"../support/dataUtils.js";import{timeResolutionToStepMap as j,isArcadeDate as A,arcadeDateToFieldValue as I,dateTimeIsInRange as O}from"../support/dateUtils.js";var M;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(M||(M={}));const R="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?s(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=a(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&S(e)?e.getTime():null,min:null!=t&&S(t)?t.getTime():null}}const{max:u,min:o}=r;if(i){const{max:e,min:t}=i,l=N(e)&&(null==u||null!=u&&e<u),n=N(t)&&(null==o||null!=o&&t>o);return{max:l?e:u??null,min:n?t:o??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:o,max:u,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=s(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:a}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:N(l)&&(null===e||null!=e&&l<e)?l:e??null,min:N(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:s,rawMin:u}=i,o=N(l)&&r&&(null==e||l<e);return{max:o?l:e,min:N(n)&&a&&(null==t||n>t)?n:t,rawMax:o?r:s,rawMin:o?a:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return p(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return d(e)?M.Number:m(e)?M.Text:b(e)||y(e)?M.Date:M.Unsupported}get dateDataType(){if(this.dataType===M.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=_(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:R,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:R,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),a=this.element?.domain;return null!=a&&this._isDomainCompatible(a)?a:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==M.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==M.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=V(e,"switch")?e.input:null;return!t||w(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return x(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=s(i,e)||h(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:a,min:u}=s(i)||{};return{max:null!=a&&(null===n||null!=n&&a<n)?a:n,min:null!=u&&(null===r||null!=r&&u>r)?u:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?j.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===M.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(A(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&m(t)||"number"===i&&d(t))return!0}return!!("range"===e?.type&&d(t)||b(t)||y(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:o}=this,p=s&&null==o,d=void 0!==a;return!p&&l.getAttribute(i.name)===o&&d?null:p?f.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof o&&o.length<n?D.TOO_SHORT:"date"!==e||null==o||O({type:i.type,range:r,value:o})?t?null!==o||s?u(i,o):null:g(i,o):c.OUT_OF_RANGE}};e([i()],L.prototype,"_dateFormRange",null),e([i()],L.prototype,"_dateRange",null),e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),U=L;export{U as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{watch as i,sync as l}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import a from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as u,dateTimeFieldValuesToNumericRange as o,validateDomainValue as p}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as d,getLowerCaseEditTrackingFields as m,isNumericField as y,isStringField as h,isTimeOnlyField as f,getFieldRange as c,TypeValidationError as g,NumericRangeValidationError as b,validateFieldValue as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as v}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as E}from"../Feature/support/featureUtils.js";import _ from"./EditableInput.js";import{parseFormTemplateString as V,getNormalizedFeatureTypeInfo as w,isFieldElementWithInputType as T,valueIsInvalidSwitchValue as F,isFieldElementWithTextInput as D,isFieldElementWithShowNoValueOptionInput as N,LengthValidationError as j}from"./featureFormUtils.js";import{isNumber as I}from"../support/dataUtils.js";import{timeResolutionToStepMap as A,isArcadeDate as O,arcadeDateToFieldValue as M,dateTimeIsInRange as R}from"../support/dateUtils.js";var L;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(L||(L={}));const S="__internal-type-based-coded-value-domain__";let U=class extends _{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}initialize(){this.addHandles(i((()=>this.feature),(()=>this._fieldInputWasVisibleDuringLifetime=!1),l))}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?u(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=o(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&k(e)?e.getTime():null,min:null!=t&&k(t)?t.getTime():null}}const{max:s,min:a}=r;if(i){const{max:e,min:t}=i,l=I(e)&&(null==s||null!=s&&e<s),n=I(t)&&(null==a||null!=a&&t>a);return{max:l?e:s??null,min:n?t:a??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:a,max:s,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=u(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:s}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:I(l)&&(null===e||null!=e&&l<e)?l:e??null,min:I(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:a,rawMin:u}=i,o=I(l)&&r&&(null==e||l<e);return{max:o?l:e,min:I(n)&&s&&(null==t||n>t)?n:t,rawMax:o?r:a,rawMin:o?s:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&d(e,t)}get _isEditTrackingField(){return m(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return y(e)?L.Number:h(e)?L.Text:v(e)||f(e)?L.Date:L.Unsupported}get dateDataType(){if(this.dataType===L.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?V({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=w(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new a({name:S,codedValues:e.subtypes.map((({code:e,name:t})=>new s({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new a({name:S,codedValues:i.map((({code:e,name:t})=>new s({code:e,name:t})))});const{feature:l}=this,n=e?.getFieldDomain(this.name,{feature:l}),r=this.element?.domain;return null!=r&&this._isDomainCompatible(r)?r:n}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==L.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==L.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=T(e,"switch")?e.input:null;return!t||F(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return E(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?V({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===L.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===L.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=u(i,e)||c(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:s,min:a}=u(i)||{};return{max:null!=s&&(null===n||null!=n&&s<n)?s:n,min:null!=a&&(null===r||null!=r&&a>r)?a:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!N(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return N(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?A.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.visibilityExpressionExecutor?.lastEvaluatedValue||!1===this.group?.visibilityExpressionExecutor?.lastEvaluatedValue))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===L.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(O(e))return M(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&h(t)||"number"===i&&y(t))return!0}return!!("range"===e?.type&&y(t)||v(t)||f(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:u}=this,o=s&&null==u,d=void 0!==a;return!o&&l.getAttribute(i.name)===u&&d?null:o?g.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof u&&u.length<n?j.TOO_SHORT:"date"!==e||null==u||R({type:i.type,range:r,value:u})?t?null!==u||s?p(i,u):null:x(i,u):b.OUT_OF_RANGE}};e([n()],U.prototype,"_dateFormRange",null),e([n()],U.prototype,"_dateRange",null),e([n()],U.prototype,"_storedValue",void 0),e([n()],U.prototype,"_configAllowsEdits",null),e([n()],U.prototype,"_layerAndFieldAllowEdits",null),e([n()],U.prototype,"_isVisibleByDefault",null),e([n()],U.prototype,"_isEditTrackingField",null),e([n()],U.prototype,"_shouldUseValueExpression",null),e([n()],U.prototype,"_isSubtypeField",null),e([n()],U.prototype,"dataType",null),e([n()],U.prototype,"dateDataType",null),e([n()],U.prototype,"description",null),e([n()],U.prototype,"domain",null),e([n()],U.prototype,"editable",null),e([n({readOnly:!0})],U.prototype,"error",void 0),e([n({constructOnly:!0})],U.prototype,"preservesValueWhenHidden",void 0),e([n()],U.prototype,"evaluatedRequiredExpression",null),e([n()],U.prototype,"evaluatedValueExpression",null),e([n()],U.prototype,"field",void 0),e([n()],U.prototype,"group",void 0),e([n({readOnly:!0})],U.prototype,"hint",null),e([n()],U.prototype,"includeDate",null),e([n()],U.prototype,"includeTime",null),e([n()],U.prototype,"includeTimeOffset",null),e([n()],U.prototype,"initialFeature",null),e([n({readOnly:!0})],U.prototype,"inputType",null),e([n()],U.prototype,"hasInvalidSwitchValue",null),e([n()],U.prototype,"isRelationshipKeyField",null),e([n()],U.prototype,"label",null),e([n()],U.prototype,"maxLength",null),e([n()],U.prototype,"minLength",null),e([n({readOnly:!0})],U.prototype,"name",null),e([n()],U.prototype,"range",null),e([n()],U.prototype,"required",null),e([n()],U.prototype,"requiredExpressionExecutor",void 0),e([n()],U.prototype,"showNoValueOptionEnabled",null),e([n()],U.prototype,"submittable",null),e([n()],U.prototype,"timeResolution",null),e([n()],U.prototype,"timeStep",null),e([n({readOnly:!0})],U.prototype,"type",void 0),e([n()],U.prototype,"updating",null),e([n()],U.prototype,"valid",null),e([n({value:null})],U.prototype,"value",null),e([n()],U.prototype,"valueExpressionExecutor",void 0),e([n()],U.prototype,"visible",null),U=e([r("esri.widgets.FeatureForm.FieldInput")],U);const k=e=>e&&!Number.isNaN(e.valueOf()),q=U;export{q 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as i,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(j(e,"combo-box")||j(e,"radio-buttons")),j=(e,t)=>null!=e&&e.input?.type===t,x=e=>null!=e&&(j(e,"text-box")||j(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:o,label:i,timeZone:l}=t;if(!r||"object"!=typeof r)return i;const a=Object.keys(r).filter((e=>n(i,e))),s=a.map((e=>r[e])),u=a.map((e=>o.get(e))).filter(e);return A(i,_({values:s,fields:u,timeZone:l}))}function _(e){const{fields:t,values:n,timeZone:r}=e,o=t.map(((e,t)=>{let o=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(s(e)||i(e))&&(o=u(e,o,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,o]}));return Object.fromEntries(o)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric"},w={hour:"numeric",minute:"numeric",second:"numeric"},C={...Z,...w};function S(e){return e>=1e7||e<=-1e7}const G=(e,t,n)=>{const{dataType:r,error:i,minLength:s,value:u,required:m}=e;if(!t||!i)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(i===o.VALUE_OUT_OF_RANGE||i===l.OUT_OF_RANGE){const{field:o,range:i}=e,l={type:"date",intlOptions:{..."time-only"===o.type?w:"date-only"===o.type?Z:C,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,i,{format:{max:"date"===r?l:null!=i.max&&S(i.max)?R:D,min:"date"===r?l:null!=i.min&&S(i.min)?R:D}})}return i===o.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===a.INVALID_TYPE?t.validationErrors.invalidType:i===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},H=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},P=e=>{const t=[];if(e.formTemplate){const{description:r,title:o}=e.formTemplate;e.fields?.forEach((e=>{const i=o&&n(o,e.name),l=r&&n(r,e.name);(i||l)&&t.push(e.name)}))}return t};function k(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function q(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function B(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,k as formTemplateHasInvalidFields,_ as getComputedAttributes,G as getErrorMessageForFieldInput,P as getFieldsInTitleAndDesc,H as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,j as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,x as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,q as valueIsInvalidSwitchValue,B as valueIsValidContingentValue};
|
package/widgets/FeatureForm.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,numberingSystem as w,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as O,normalizeTimeOnlyString as k,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as x,incrementHeadingLevel as V}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const E="data-field-name",U="esri.widgets.FeatureForm",S=o.getLogger(U);let $=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,D.widget,D.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(x,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?V(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?j(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return L("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[E],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[E],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:l,[E]:i,onfocus:this._onComponentFocus},m=R(d),h=R(c),v=R(a);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:c,[E]:o,onfocus:this._onComponentFocus},h=O(a,u),v=O(l,u),_=O(d,u);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[E],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:j(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:b(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=j(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[E]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(E))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);g(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=k(s),r=k(e.value)):r="timestamp-offset"===i?null!=e.value?I({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?M({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],$.prototype,"_listObserverNode",void 0),e([s()],$.prototype,"_relatedRecordsEnabled",null),e([s()],$.prototype,"disabled",null),e([s()],$.prototype,"feature",null),e([s()],$.prototype,"formTemplate",null),e([s()],$.prototype,"groupDisplay",void 0),e([s()],$.prototype,"headingLevel",void 0),e([s()],$.prototype,"label",null),e([s()],$.prototype,"layer",null),e([s()],$.prototype,"map",null),e([s(),N("esri/widgets/FeatureForm/t9n/FeatureForm")],$.prototype,"messages",void 0),e([s(),N("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([s(),N("esri/widgets/Feature/t9n/Feature")],$.prototype,"messagesFeature",void 0),e([s(),N("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],$.prototype,"messagesTemplates",void 0),e([s()],$.prototype,"relatedRecordCallbacks",null),e([s()],$.prototype,"relationshipId",null),e([s()],$.prototype,"spatialReference",null),e([s()],$.prototype,"strict",null),e([s()],$.prototype,"timeZone",null),e([s()],$.prototype,"view",null),e([s(),T(["value-change","submit"])],$.prototype,"viewModel",void 0),$=e([r(U)],$);const A=$;export{A as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,numberingSystem as w,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as O,normalizeTimeOnlyString as k,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as x,incrementHeadingLevel as V}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const E="data-field-name",U="esri.widgets.FeatureForm",S=o.getLogger(U);let $=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,D.widget,D.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(x,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?V(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?j(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?L("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):L("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):L("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[E],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[E],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:l,[E]:i,onfocus:this._onComponentFocus},m=R(d),h=R(c),v=R(a);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:c,[E]:o,onfocus:this._onComponentFocus},h=O(a,u),v=O(l,u),_=O(d,u);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[E],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:j(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=j(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[E]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(E))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=k(s),r=k(e.value)):r="timestamp-offset"===i?null!=e.value?I({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?M({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],$.prototype,"_listObserverNode",void 0),e([s()],$.prototype,"_relatedRecordsEnabled",null),e([s()],$.prototype,"disabled",null),e([s()],$.prototype,"feature",null),e([s()],$.prototype,"formTemplate",null),e([s()],$.prototype,"groupDisplay",void 0),e([s()],$.prototype,"headingLevel",void 0),e([s()],$.prototype,"label",null),e([s()],$.prototype,"layer",null),e([s()],$.prototype,"map",null),e([s(),N("esri/widgets/FeatureForm/t9n/FeatureForm")],$.prototype,"messages",void 0),e([s(),N("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([s(),N("esri/widgets/Feature/t9n/Feature")],$.prototype,"messagesFeature",void 0),e([s(),N("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],$.prototype,"messagesTemplates",void 0),e([s()],$.prototype,"relatedRecordCallbacks",null),e([s()],$.prototype,"relationshipId",null),e([s()],$.prototype,"spatialReference",null),e([s()],$.prototype,"strict",null),e([s()],$.prototype,"timeZone",null),e([s()],$.prototype,"view",null),e([s(),T(["value-change","submit"])],$.prototype,"viewModel",void 0),$=e([r(U)],$);const A=$;export{A as default};
|
package/widgets/Features.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.28/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{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import w from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const R="selected-index",j=0,N="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new w,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),j),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),s=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>s?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(R);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{class:this.classes(m.base,M.widget,M.panel)},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:x(o+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onkeydown:this._onMainKeydown,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,M.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:o.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){return C("calcite-flow",{key:"content-container"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?A(o,i):o??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=this._getActionImage(e),s={[m.icon]:!!t,[m.actionImage]:!!o};return t&&(s[t]=!0),o||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,s),key:"icon",styles:o?this._getIconStyles(o):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=f(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?A(n,{messages:t}):"remove-selected-feature"===s?A(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,R)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:N,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,N),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusFeatureMenuFlowItem",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_focusRootFlowItem",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:_})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),I(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:w,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const E=k;export{E as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import s from"../core/Logger.js";import{watch as o,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import _ from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as w}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as M}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const j="selected-index",R=0,O="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusOn=null,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new w,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new _,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:s,active:o,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===s&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:o,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusOn="root-flow-item",this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1)},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),R),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,o((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),o((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),o((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),o((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),o((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),o((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return M({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:s}=this.viewModel,o={title:!1};return s?(e?(e.viewModel=s,e.visibleElements=o):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:s,visibleElements:o}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():s.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?(this._setFocusOn(),this.scheduleRender()):s.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(j);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{bind:this,class:this.classes(m.base,F.widget,F.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:s,pendingPromisesCount:o}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:o>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:x(s+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,s=e===t,o=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":o,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:s,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const s=i.sourceLayer??i.layer,o=t.get(s)??[];t.set(s,[...o,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:s,featureNavigationTop:o}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:o?"down":"up",collapsible:s,headingLevel:e,key:"root-flow-item",onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,F.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:s}=this,{active:o,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!o,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:s.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},s.back)):null}_renderContentContainer(){return C("calcite-flow",{key:"content-container"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:s}=e;return s&&i?A(s,i):s??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s=this._getActionImage(e),o={[m.icon]:!!t,[m.actionImage]:!!s};return t&&(o[t]=!0),s||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,o),key:"icon",styles:s?this._getIconStyles(s):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_setFocusOn(){this._focusOn=this.featureMenuOpen?"menu-flow-item":"root-flow-item"}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const s=f(i);this.open({features:[t],location:null!=s?s:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,"root-flow-item"===this._focusOn&&(this._focusOn=null,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,"menu-flow-item"===this._focusOn&&(this._focusOn=null,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:s}=this,{id:o}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===o?A(n,{messages:t}):"remove-selected-feature"===o?A(n,{messages:s}):"zoom-to-clustered-features"===o||"browse-clustered-features"===o?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=o((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,j)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,s=this.headerActions.find((({uid:e})=>e===i));s&&!s.disabled&&("toggle"===s?.type&&(s.value=!s.value),this.emit("trigger-header-action",{action:s}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:s}=this.viewModel,o=s.findIndex((e=>e.uid===i)),r=s.at(o);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(o)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:O,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,O),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusOn",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:w})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),I(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:_,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const N=k;export{N as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import r from"../../core/Accessor.js";import i from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import y from"./support/ActiveLayerInfo.js";import{onLocaleChange as d}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},c=i.ofType(y),L=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",p="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",p];let v=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new c,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),h.view),this.addHandles(d((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(h.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const r=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],r?.parent&&r.parent.children.remove(r)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:r}=e;r.length&&this._refresh(),this.addHandles(r.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh()}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const r=this.view;if(e.length<2||!r)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const t={};r.allLayerViews.forEach(((e,r)=>t[e.layer.uid]=r)),e.sort(((e,r)=>{const i=t[e.layer.uid]||0;return(t[r.layer.uid]||0)-i}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const r=!this.basemapLegendVisible&&(e===u||e===p),i=!this.groundLegendVisible&&e===f;return!r&&!i}_collectLayerViews(e,r){const i=t=>(t&&t.forEach((t=>{r.push(t),i(t[e])})),r);return i}_filterLayerViewsByLayerInfos(e){const r=this.layerInfos;return!r||!r.length||r.some((r=>this._hasLayerInfo(r,e)))}_hasLayerInfo(e,r){const i=this._isLayerUIDMatching(e.layer,r.layer.uid);return i&&(this._layerInfosByLayerViewId[r.uid]=e),i}_isLayerUIDMatching(e,r){return e&&(e.uid===r||this._hasLayerUID(e.layers,r))}_hasLayerUID(e,r){return e&&e.some((e=>this._isLayerUIDMatching(e,r)))}_isLayerViewSupported(e){return!!L.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import r from"../../core/Accessor.js";import i from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import y from"./support/ActiveLayerInfo.js";import{onLocaleChange as d}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},c=i.ofType(y),L=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",p="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",p];let v=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new c,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),h.view),this.addHandles(d((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(h.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const r=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],r?.parent&&r.parent.children.remove(r)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:r}=e;r.length&&this._refresh(),this.addHandles(r.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh()}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const r=this.view;if(e.length<2||!r)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const t={};r.allLayerViews.forEach(((e,r)=>t[e.layer.uid]=r)),e.sort(((e,r)=>{const i=t[e.layer.uid]||0;return(t[r.layer.uid]||0)-i}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const r=!this.basemapLegendVisible&&(e===u||e===p),i=!this.groundLegendVisible&&e===f;return!r&&!i}_collectLayerViews(e,r){const i=t=>(t&&t.forEach((t=>{r.push(t),i(t[e])})),r);return i}_filterLayerViewsByLayerInfos(e){const r=this.layerInfos;return!r||!r.length||r.some((r=>this._hasLayerInfo(r,e)))}_hasLayerInfo(e,r){const i=this._isLayerUIDMatching(e.layer,r.layer.uid);return i&&(this._layerInfosByLayerViewId[r.uid]=e),i}_isLayerUIDMatching(e,r){return e&&(e.uid===r||this._hasLayerUID(e.layers,r))}_hasLayerUID(e,r){return e&&e.some((e=>this._isLayerUIDMatching(e,r)))}_isLayerViewSupported(e){return!!L.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const r=e.layer,i=e.uid,n=this._layerInfosByLayerViewId[i];let o=this._activeLayerInfosByLayerViewId[i];if(!o){const t=void 0!==n?.title&&n.layer.uid===r.uid;o=new y({layer:r,layerView:e,title:t?n.title:r.title,view:this.view,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[i]=o}const l=r.parent&&"uid"in r.parent?this._layerViewByLayerId[r.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(i)){const n=[t((()=>r.title),(e=>this._titleHandle(e,o))),t((()=>[r.opacity,"renderer"in r&&r.renderer,"pointSymbol"in r&&r.pointSymbol,"lineSymbol"in r&&r.lineSymbol,"polygonSymbol"in r&&r.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e._effectiveRenderer),(()=>this._constructLegendElements(o))),t((()=>"effect"in r&&r.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const i=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>r.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(i,s)}this.addHandles(n,i)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,r){r.title=e,this._constructLegendElements(r)}_legendEnabledHandle(e,r){e?this._addActiveLayerInfo(r):this._removeActiveLayerInfo(r)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:r,layer:i}=e;if(this._isLayerActive(r)&&!this.activeLayerInfos.includes(e)){const r=e.parent;if(r)r.children.includes(e)||r.children.push(e),this._sortActiveLayerInfos(r.children);else{const r=this.layerInfos?.some((e=>e.layer.uid===i.uid));i.parent&&"uid"in i.parent&&!r?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((r=>{const i=r.layer.parent,t=i&&"uid"in i?this._layerViewByLayerId[i?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(r),r.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const r=e.parent;r?r.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const r=e.layer;"featureCollections"in r&&r.featureCollections?e.buildLegendElementsForFeatureCollections(r.featureCollections):"featureReduction"in r&&r.featureReduction&&"renderer"in r.featureReduction&&("binning"===r.featureReduction.type||"cluster"===r.featureReduction.type)?e.buildLegendElementsForFeatureReduction(r.featureReduction):"renderer"in r&&r.renderer&&!("sublayers"in r)?e.buildLegendElementsForRenderer(r.renderer):"url"in r&&r.url?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:c})],v.prototype,"activeLayerInfos",void 0),e([n()],v.prototype,"basemapLegendVisible",void 0),e([n()],v.prototype,"groundLegendVisible",void 0),e([n()],v.prototype,"hideLayersNotInCurrentView",void 0),e([n()],v.prototype,"keepCacheOnDestroy",void 0),e([n()],v.prototype,"respectLayerVisibility",void 0),e([n()],v.prototype,"layerInfos",void 0),e([n({readOnly:!0})],v.prototype,"state",null),e([n()],v.prototype,"view",void 0),v=e([o("esri.widgets.Legend.LegendViewModel")],v);const I=v;export{I as default};
|
package/widgets/Popup.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import{deprecatedProperty as e}from"../core/deprecate.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as n,on as s,whenOnce as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import d from"../support/actions/ActionButton.js";import c from"./Features.js";import p from"./Widget.js";import{css as h}from"./Popup/css.js";import u from"./Popup/PopupViewModel.js";import g from"./Popup/PopupVisibleElements.js";import{globalCss as v}from"./support/globalCss.js";import{isRTL as w}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";const _={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let k=class extends p{constructor(t,e){super(t,e),this._dockAction=new d({id:"popup-dock-action"}),this._featuresWidget=new c({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this.alignment="auto",this.collapsed=!1,this.collapseEnabled=!0,this.dockEnabled=!1,this.headingLevel=2,this.maxInlineActions=3,this.messages=null,this.spinnerEnabled=!0,this.viewModel=new u,this.visibleElements=new g}initialize(){this.addHandles([n((()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled]),(()=>this._handleDockIcon()),{initial:!0}),n((()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock]),(()=>this._handleDockEnabled()),{initial:!0}),n((()=>this.dockOptions),(t=>{const{_dockAction:e}=this,i=this._featuresWidget.headerActions;i.remove(e),t.buttonEnabled&&i.add(e)}),{initial:!0}),n((()=>this.viewModel?.screenLocation),(()=>this._positionContainer())),n((()=>[this.viewModel?.active,this.dockEnabled]),(()=>this._toggleScreenLocationEnabled())),n((()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment]),(()=>this.reposition())),n((()=>this.viewModel?.view?.size),((t,e)=>this._updateDockEnabledForViewSize(t,e))),n((()=>this.viewModel?.view),((t,e)=>this._viewChange(t,e))),n((()=>this.viewModel?.view?.ready),((t,e)=>this._viewReadyChange(t??!1,e??!1))),n((()=>this.viewModel),(()=>this._featuresWidget.viewModel=this.viewModel),{initial:!0}),n((()=>this._featureNavigationTop),(t=>this._featuresWidget.featureNavigationTop=t),{initial:!0}),n((()=>this.headingLevel),(t=>this._featuresWidget.headingLevel=t),{initial:!0}),n((()=>this.collapseEnabled),(t=>this._featuresWidget.visibleElements.collapseButton=t),{initial:!0}),n((()=>this.collapsed),(t=>this._featuresWidget.collapsed=t),{initial:!0}),n((()=>this.visibleElements.closeButton),(t=>this._featuresWidget.visibleElements.closeButton=!!t),{initial:!0}),n((()=>this.spinnerEnabled),(t=>this._featuresWidget.visibleElements.spinner=t),{initial:!0}),n((()=>this.visibleElements.featureNavigation),(t=>this._featuresWidget.visibleElements.featureNavigation=!!t),{initial:!0}),s((()=>this._featuresWidget),"trigger-header-action",(t=>{t.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)}))])}destroy(){this._dockAction.destroy(),this._featuresWidget?.destroy()}get _featureNavigationTop(){const{currentAlignment:t,currentDockPosition:e}=this;return"bottom-left"===t||"bottom-center"===t||"bottom-right"===t||"top-left"===e||"top-center"===e||"top-right"===e}get actions(){return this.viewModel.actions}set actions(t){this.viewModel.actions=t}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(t){this.viewModel.autoCloseEnabled=t}get autoOpenEnabled(){return e(o.getLogger(this),"autoOpenEnabled",{replacement:"MapView/SceneView.popupEnabled",version:"4.27"}),this.viewModel.autoOpenEnabled}set autoOpenEnabled(t){e(o.getLogger(this),"autoOpenEnabled",{replacement:"MapView/SceneView.popupEnabled",version:"4.27"}),this.viewModel.autoOpenEnabled=t}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(t){this.viewModel.defaultPopupTemplateEnabled=t}get content(){return this.viewModel.content}set content(t){this.viewModel.content=t}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||_}set dockOptions(t){const e={..._},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...e,...t},s={...e.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(t){this.viewModel.featureMenuOpen=t}get features(){return this.viewModel.features}set features(t){this.viewModel.features=t}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(t){this.viewModel.goToOverride=t}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(t){this.viewModel.highlightEnabled=t}get location(){return this.viewModel.location}set location(t){this.viewModel.location=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get promises(){return this.viewModel.promises}set promises(t){this.viewModel.promises=t}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(t){this.viewModel.selectedFeatureIndex=t}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(t){this.viewModel.title=t}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(t){this.viewModel.updateLocationEnabled=t}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}blur(){const{active:t}=this.viewModel;t||o.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(t,e){return this.viewModel.fetchFeatures(t,e)}focus(){const{active:t}=this.viewModel;t||o.getLogger(this).warn("Popup can only be focused when currently active."),this._featuresWidget.focus()}next(){return this.viewModel.next()}open(t){const e=!!t&&!!t.featureMenuOpen,i={collapsed:!!t&&!!t.collapsed,featureMenuOpen:e};this.set(i),this.viewModel.open(t),this._shouldFocus(t)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(t){return this.viewModel.triggerAction(t)}render(){const{dockEnabled:t,currentAlignment:e,currentDockPosition:i}=this,{active:o}=this.viewModel,n=o&&t,s=o&&!t,r=this.selectedFeature?.layer?.title,l=this.selectedFeature?.layer?.id,a={[h.alignTopCenter]:"top-center"===e,[h.alignBottomCenter]:"bottom-center"===e,[h.alignTopLeft]:"top-left"===e,[h.alignBottomLeft]:"bottom-left"===e,[h.alignTopRight]:"top-right"===e,[h.alignBottomRight]:"bottom-right"===e,[h.isDocked]:n,[h.shadow]:s,[h.isDockedTopLeft]:"top-left"===i,[h.isDockedTopCenter]:"top-center"===i,[h.isDockedTopRight]:"top-right"===i,[h.isDockedBottomLeft]:"bottom-left"===i,[h.isDockedBottomCenter]:"bottom-center"===i,[h.isDockedBottomRight]:"bottom-right"===i};return f("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,bind:this,class:this.classes(h.base,a),"data-layer-id":l,"data-layer-title":r,role:"presentation"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:f("div",{class:h.pointer,key:"popup-pointer",role:"presentation"},f("div",{class:this.classes(h.pointerDirection,h.shadow)}))}_renderMainContainer(){const{dockEnabled:t}=this,e={[h.shadow]:t};return f("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(h.main,v.widget,e),onkeyup:this._handleMainKeyup},this._featuresWidget.render())}_handleMainKeyup(t){const e=i(t);"ArrowLeft"===e&&(t.stopPropagation(),this.previous()),"ArrowRight"===e&&(t.stopPropagation(),this.next())}async _shouldFocus(t){t?.shouldFocus&&(await r((()=>!0===this.viewModel?.active)),this.focus())}_isOutsideView(t){const{popupHeight:e,popupWidth:i,screenLocation:o,side:n,view:s}=t;if(isNaN(i)||isNaN(e)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-e<r.top||"bottom"===n&&o.y+e>s.height-r.bottom))}_calculateAutoAlignment(t){if("auto"!==t)return t;const{_pointerOffsetInPx:e,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(t){return parseInt(t.replaceAll(/[^-\d\.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:p,width:h}=i.getBoundingClientRect(),u=h+e,g=Math.max(p,d,c)+e,v=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"right",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"left",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"top",view:r}),b=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"bottom",view:r});return w?m?"bottom-right":"top-right":v?m?"bottom-left":"top-left":m?b?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(t){return"function"==typeof t?t.call(this):t}_getCurrentAlignment(){const{alignment:t,dockEnabled:e}=this;return e||!this.viewModel.active?null:this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(t)))}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(t){const e=["left","right"];return w(this.container)&&e.reverse(),t?.replace(/leading/gi,e[0]).replaceAll(/trailing/gi,e[1])}_callDockPosition(t){return"function"==typeof t?t.call(this):t}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(t){if("auto"!==t)return t;const e=this.viewModel?.view,i=w(this.container)?"top-left":"top-right";if(!e)return i;const o=e.padding||{left:0,right:0,top:0,bottom:0},n=e.width-o.left-o.right,{breakpoints:s}=e;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const t=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(t){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(t){this._mainContainerNode=t}_positionContainer(t=this._containerNode){if(t&&(this._containerNode=t),!this._containerNode)return;const{screenLocation:e}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(e,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(t){const{currentAlignment:e,_pointerOffsetInPx:i}=this;return"top-left"===e||"bottom-left"===e||"top-right"===e||"bottom-right"===e?t+i:t}_calculateAlignmentPosition(t,e,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-e,d=i.width-t;return"bottom-center"===n?{top:e+s-r.top,left:t-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:e+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:t+s-r.left}:"bottom-right"===n?{top:e+s-r.top,left:t+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:t-l-r.left}:void 0}_calculatePositionStyle(t,e){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==t||!e)return;const n=this._calculateFullWidth(e),s=this._calculateAlignmentPosition(t.x,t.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(t,e){t&&e&&(this.close(),this.clear())}_viewReadyChange(t,e){t?this._wireUpView():e&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(t,e,i){const[o,n]=t,[s,r]=e,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(t,e){if(!t||!e)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=t[0]-o,s[1]=t[1]-n,r[0]=e[0]-o,r[1]=e[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:t,viewModel:e}=this;if(!e)return;const i=e.active&&!t;e.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(t){const e=t.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!e)return!1;const s=e.hasOwnProperty("width")&&o<=(e.width??0),r=e.hasOwnProperty("height")&&n<=(e.height??0);return s||r}_setDockEnabledForViewSize(t){t.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(t))}};t([l({readOnly:!0})],k.prototype,"_featureNavigationTop",null),t([l()],k.prototype,"actions",null),t([l()],k.prototype,"alignment",void 0),t([l()],k.prototype,"autoCloseEnabled",null),t([l()],k.prototype,"autoOpenEnabled",null),t([l()],k.prototype,"defaultPopupTemplateEnabled",null),t([l()],k.prototype,"content",null),t([l()],k.prototype,"collapsed",void 0),t([l()],k.prototype,"collapseEnabled",void 0),t([l({readOnly:!0})],k.prototype,"currentAlignment",null),t([l({readOnly:!0})],k.prototype,"currentDockPosition",null),t([l()],k.prototype,"dockOptions",null),t([l()],k.prototype,"dockEnabled",void 0),t([l({readOnly:!0})],k.prototype,"featureCount",null),t([l()],k.prototype,"featureMenuOpen",null),t([l()],k.prototype,"features",null),t([l()],k.prototype,"goToOverride",null),t([l()],k.prototype,"headingLevel",void 0),t([l()],k.prototype,"highlightEnabled",null),t([l()],k.prototype,"location",null),t([l()],k.prototype,"label",null),t([l()],k.prototype,"maxInlineActions",void 0),t([l(),m("esri/widgets/Popup/t9n/Popup")],k.prototype,"messages",void 0),t([l()],k.prototype,"promises",null),t([l({readOnly:!0})],k.prototype,"selectedFeature",null),t([l()],k.prototype,"selectedFeatureIndex",null),t([l({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),t([l()],k.prototype,"spinnerEnabled",void 0),t([l()],k.prototype,"title",null),t([l()],k.prototype,"updateLocationEnabled",null),t([l()],k.prototype,"view",null),t([l({type:u}),b(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),t([l()],k.prototype,"visible",null),t([l({type:g,nonNullable:!0})],k.prototype,"visibleElements",void 0),k=t([a("esri.widgets.Popup")],k);const M=k;export{M as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{deprecatedProperty as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as o,on as n,whenOnce as s}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import a from"../support/actions/ActionButton.js";import d from"./Features.js";import c from"./Widget.js";import{css as p}from"./Popup/css.js";import h from"./Popup/PopupViewModel.js";import u from"./Popup/PopupVisibleElements.js";import{globalCss as g}from"./support/globalCss.js";import{isRTL as v}from"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as m}from"./support/decorators/vmEvent.js";import{tsx as b}from"./support/jsxFactory.js";const f={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let _=class extends c{constructor(e,t){super(e,t),this._dockAction=new a({id:"popup-dock-action"}),this._featuresWidget=new d({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this.alignment="auto",this.collapsed=!1,this.collapseEnabled=!0,this.dockEnabled=!1,this.headingLevel=2,this.maxInlineActions=3,this.messages=null,this.spinnerEnabled=!0,this.viewModel=new h,this.visibleElements=new u}initialize(){this.addHandles([o((()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled]),(()=>this._handleDockIcon()),{initial:!0}),o((()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock]),(()=>this._handleDockEnabled()),{initial:!0}),o((()=>this.dockOptions),(e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)}),{initial:!0}),o((()=>this.viewModel?.screenLocation),(()=>this._positionContainer())),o((()=>[this.viewModel?.active,this.dockEnabled]),(()=>this._toggleScreenLocationEnabled())),o((()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment]),(()=>this.reposition())),o((()=>this.viewModel?.view?.size),((e,t)=>this._updateDockEnabledForViewSize(e,t))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>this.viewModel),(()=>this._featuresWidget.viewModel=this.viewModel),{initial:!0}),o((()=>this._featureNavigationTop),(e=>this._featuresWidget.featureNavigationTop=e),{initial:!0}),o((()=>this.headingLevel),(e=>this._featuresWidget.headingLevel=e),{initial:!0}),o((()=>this.collapseEnabled),(e=>this._featuresWidget.visibleElements.collapseButton=e),{initial:!0}),o((()=>this.collapsed),(e=>this._featuresWidget.collapsed=e),{initial:!0}),o((()=>this.visibleElements.closeButton),(e=>this._featuresWidget.visibleElements.closeButton=!!e),{initial:!0}),o((()=>this.spinnerEnabled),(e=>this._featuresWidget.visibleElements.spinner=e),{initial:!0}),o((()=>this.visibleElements.featureNavigation),(e=>this._featuresWidget.visibleElements.featureNavigation=!!e),{initial:!0}),n((()=>this._featuresWidget),"trigger-header-action",(e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)}))])}destroy(){this._dockAction.destroy(),this._featuresWidget?.destroy()}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get autoOpenEnabled(){return t(i.getLogger(this),"autoOpenEnabled",{replacement:"MapView/SceneView.popupEnabled",version:"4.27"}),this.viewModel.autoOpenEnabled}set autoOpenEnabled(e){t(i.getLogger(this),"autoOpenEnabled",{replacement:"MapView/SceneView.popupEnabled",version:"4.27"}),this.viewModel.autoOpenEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||f}set dockOptions(e){const t={...f},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||i.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||i.getLogger(this).warn("Popup can only be focused when currently active."),this._featuresWidget.focus(),this.scheduleRender()}next(){return this.viewModel.next()}open(e){const t=!!e&&!!e.featureMenuOpen,i={collapsed:!!e&&!!e.collapsed,featureMenuOpen:t};this.set(i),this.viewModel.open(e),this._shouldFocus(e)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o}=this.viewModel,n=o&&e,s=o&&!e,r=this.selectedFeature?.layer?.title,l=this.selectedFeature?.layer?.id,a={[p.alignTopCenter]:"top-center"===t,[p.alignBottomCenter]:"bottom-center"===t,[p.alignTopLeft]:"top-left"===t,[p.alignBottomLeft]:"bottom-left"===t,[p.alignTopRight]:"top-right"===t,[p.alignBottomRight]:"bottom-right"===t,[p.isDocked]:n,[p.shadow]:s,[p.isDockedTopLeft]:"top-left"===i,[p.isDockedTopCenter]:"top-center"===i,[p.isDockedTopRight]:"top-right"===i,[p.isDockedBottomLeft]:"bottom-left"===i,[p.isDockedBottomCenter]:"bottom-center"===i,[p.isDockedBottomRight]:"bottom-right"===i};return b("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,bind:this,class:this.classes(p.base,a),"data-layer-id":l,"data-layer-title":r,role:"presentation"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:b("div",{class:p.pointer,key:"popup-pointer",role:"presentation"},b("div",{class:this.classes(p.pointerDirection,p.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[p.shadow]:e};return b("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(p.main,g.widget,t)},this._featuresWidget.render())}async _shouldFocus(e){e?.shouldFocus&&(await s((()=>!0===this.viewModel?.active)),this.focus())}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d\.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:p,width:h}=i.getBoundingClientRect(),u=h+t,g=Math.max(p,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"right",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"left",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"top",view:r}),b=this._isOutsideView({popupHeight:g,popupWidth:u,screenLocation:s,side:"bottom",view:r});return w?m?"bottom-right":"top-right":v?m?"bottom-left":"top-left":m?b?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t}=this;return t||!this.viewModel.active?null:this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e)))}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return v(this.container)&&t.reverse(),e?.replace(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=v(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0,top:0,bottom:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const n=this._calculateFullWidth(t),s=this._calculateAlignmentPosition(e.x,e.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([r({readOnly:!0})],_.prototype,"_featureNavigationTop",null),e([r()],_.prototype,"actions",null),e([r()],_.prototype,"alignment",void 0),e([r()],_.prototype,"autoCloseEnabled",null),e([r()],_.prototype,"autoOpenEnabled",null),e([r()],_.prototype,"defaultPopupTemplateEnabled",null),e([r()],_.prototype,"content",null),e([r()],_.prototype,"collapsed",void 0),e([r()],_.prototype,"collapseEnabled",void 0),e([r({readOnly:!0})],_.prototype,"currentAlignment",null),e([r({readOnly:!0})],_.prototype,"currentDockPosition",null),e([r()],_.prototype,"dockOptions",null),e([r()],_.prototype,"dockEnabled",void 0),e([r({readOnly:!0})],_.prototype,"featureCount",null),e([r()],_.prototype,"featureMenuOpen",null),e([r()],_.prototype,"features",null),e([r()],_.prototype,"goToOverride",null),e([r()],_.prototype,"headingLevel",void 0),e([r()],_.prototype,"highlightEnabled",null),e([r()],_.prototype,"location",null),e([r()],_.prototype,"label",null),e([r()],_.prototype,"maxInlineActions",void 0),e([r(),w("esri/widgets/Popup/t9n/Popup")],_.prototype,"messages",void 0),e([r()],_.prototype,"promises",null),e([r({readOnly:!0})],_.prototype,"selectedFeature",null),e([r()],_.prototype,"selectedFeatureIndex",null),e([r({readOnly:!0})],_.prototype,"selectedFeatureWidget",null),e([r()],_.prototype,"spinnerEnabled",void 0),e([r()],_.prototype,"title",null),e([r()],_.prototype,"updateLocationEnabled",null),e([r()],_.prototype,"view",null),e([r({type:h}),m(["triggerAction","trigger-action"])],_.prototype,"viewModel",void 0),e([r()],_.prototype,"visible",null),e([r({type:u,nonNullable:!0})],_.prototype,"visibleElements",void 0),_=e([l("esri.widgets.Popup")],_);const k=_;export{k as default};
|