@arcgis/core 4.29.2 → 4.29.3
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/interfaces.d.ts +1 -1
- package/kernel.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as e}from"../../../../geometry/support/aaBoundingRect.js";import{SymbolFader as
|
|
5
|
+
import{create as e}from"../../../../geometry/support/aaBoundingRect.js";import t from"../../../../layers/support/TileInfo.js";import{SymbolFader as s}from"./decluttering/SymbolFader.js";import{Visibility as r,StyleLayerType as i}from"./style/StyleDefinition.js";import{WGLDrawPhase as l}from"../webgl/enums.js";import{RenderableTile as o}from"../webgl/RenderableTile.js";import n from"../webgl/TileContainer.js";import a from"../../tiling/TileCoverage.js";import d from"../../tiling/TileKey.js";import{StencilOperation as h,CompareFunction as c,BlendFactor as u}from"../../../webgl/enums.js";const y=1e-6;function p(e,t){if(e){const s=e.getLayoutProperty("visibility");if(!s||s.getValue()!==r.NONE&&(void 0===e.minzoom||e.minzoom<t+y)&&(void 0===e.maxzoom||e.maxzoom>=t-y))return!0}return!1}class m extends n{constructor(e){super(e),this._backgroundTiles=[],this._computeDisplayInfoView(e)}destroy(){this.removeAllChildren(),this._spriteMosaic?.dispose(),this._spriteMosaic=null,this._glyphMosaic?.dispose(),this._glyphMosaic=null,null!=this._symbolFader&&(this._symbolFader.clear(),this._symbolFader=null),this._styleRepository=null,this._backgroundTiles=[]}get fading(){return this._symbolFader?.fading??!1}get symbolFader(){return this._symbolFader}get symbolRepository(){return this._symbolFader?.symbolRepository}setStyleResources(e,t,r,i){this._spriteMosaic=e,this._glyphMosaic=t,this._styleRepository=r,this._tileInfoView=i,this._computeDisplayInfoView(i),null==this._symbolFader&&(this._symbolFader=new s(this._styleRepository,this.children)),this._symbolFader.styleRepository=r}setSpriteMosaic(e){this._spriteMosaic?.dispose(),this._spriteMosaic=e}deleteStyleLayers(e){null!=this._symbolFader&&this._symbolFader.deleteStyleLayers(e)}createRenderParams(e){return{...super.createRenderParams(e),renderPass:null,styleLayer:null,styleLayerUID:-1,glyphMosaic:this._glyphMosaic,spriteMosaic:this._spriteMosaic,hasClipping:!!this._clippingInfos}}doRender(e){!this.visible||e.drawPhase!==l.MAP&&e.drawPhase!==l.DEBUG||void 0===this._spriteMosaic||super.doRender(e)}addChild(e){return super.addChild(e),null!=this._symbolFader?this._symbolFader.addTile(e):e.decluttered=!0,this.requestRender(),e}removeChild(e){return null!=this._symbolFader&&this._symbolFader.removeTile(e),this.requestRender(),super.removeChild(e)}renderChildren(e){const{drawPhase:t}=e;t!==l.DEBUG?this._doRender(e):super.renderChildren(e)}removeAllChildren(){for(let e=0;e<this.children.length;e++){const t=this.children[e];null!=this._symbolFader&&this._symbolFader.removeTile(t),t.dispose()}super.removeAllChildren()}getStencilTarget(){return this.children.filter((e=>e.neededForCoverage&&e.hasData()))}restartDeclutter(){null!=this._symbolFader&&this._symbolFader.restartDeclutter()}_doRender(e){const{context:t,state:s}=e,r=this._styleRepository;if(!r)return;const i=r.layers,o=this._displayInfo.scaleToZoom(s.scale);r.backgroundBucketIds.length>0&&(e.renderPass="background",this._renderBackgroundLayers(e,r.backgroundBucketIds,o)),super.renderChildren(e),e.drawPhase===l.MAP&&this._fade(o,s);const n=this.children.filter((e=>e.visible&&e.hasData()));if(!n||0===n.length)return t.bindVAO(),t.setStencilTestEnabled(!0),void t.setBlendingEnabled(!0);for(const l of n)l.triangleCount=0;t.setStencilWriteMask(0),t.setColorMask(!0,!0,!0,!0),t.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!1),t.setDepthTestEnabled(!0),t.setDepthWriteEnabled(!0),t.setDepthFunction(c.LEQUAL),t.setClearDepth(1),t.clear(t.gl.DEPTH_BUFFER_BIT),e.renderPass="opaque";for(let l=i.length-1;l>=0;l--)this._renderStyleLayer(i[l],e,n);t.setDepthWriteEnabled(!1),t.setBlendingEnabled(!0),t.setBlendFunctionSeparate(u.ONE,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA),e.renderPass="translucent";for(let l=0;l<i.length;l++)this._renderStyleLayer(i[l],e,n);t.bindVAO(),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!0);for(const l of n)l.debugInfo.display.triangleCount=l.triangleCount}_fade(e,t){null!=this._symbolFader&&(this._symbolFader.update(e,t)||this.requestRender())}_renderStyleLayer(e,t,s){const{displayLevel:l,painter:o,renderPass:n}=t;if(void 0===e)return;const a=e.getLayoutProperty("visibility");if(a&&a.getValue()===r.NONE)return;let d;switch(e.type){case i.BACKGROUND:return;case i.FILL:if("opaque"!==n&&"translucent"!==t.renderPass)return;d="vtlFill";break;case i.LINE:if("translucent"!==n)return;d="vtlLine";break;case i.CIRCLE:if("translucent"!==n)return;d="vtlCircle";break;case i.SYMBOL:if("translucent"!==n)return;d="vtlSymbol"}if(s=e.type===i.SYMBOL?s.filter((e=>e.decluttered)):s.filter((e=>e.neededForCoverage)),"vtlSymbol"!==d&&(0===s.length||void 0!==e.minzoom&&e.minzoom>=l+y||void 0!==e.maxzoom&&e.maxzoom<l-y))return;const h=e.uid;t.styleLayerUID=h,t.styleLayer=e;for(const r of s)if(r.layerData.has(h)){o.renderObjects(t,s,d);break}}_renderBackgroundLayers(t,s,r){const{context:l,painter:n,state:u}=t,y=this._styleRepository;let m=!1;for(const e of s){if(y.getLayerById(e).type===i.BACKGROUND&&p(y.getLayerById(e),r)){m=!0;break}}if(!m)return;const f=this._tileInfoView,g=f.getTileCoverage(t.state,0,!0,"smallest"),{spans:_,lodInfo:b}=g,{level:E}=b,C=e(),F=[];if(this._renderPasses){const e=this._renderPasses[0];null!=this._clippingInfos&&(e.brushes[0].prepareState(t),e.brushes[0].drawMany(t,this._clippingInfos))}const L=this._backgroundTiles;let R,v=0;for(const{row:i,colFrom:a,colTo:h}of _)for(let t=a;t<=h;t++){if(v<L.length)R=L[v],R.key.set(E,i,b.normalizeCol(t),b.getWorldForColumn(t)),f.getTileBounds(C,R.key,!1),R.x=C[0],R.y=C[3],R.resolution=f.getTileResolution(E);else{const s=new d(E,i,b.normalizeCol(t),b.getWorldForColumn(t)),r=f.getTileBounds(e(),s),l=f.getTileResolution(E);R=new o(s,l,r[0],r[3],512,512,4096,4096),L.push(R)}R.setTransform(u),F.push(R),v++}l.setStencilWriteMask(0),l.setColorMask(!0,!0,!0,!0),l.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),l.setStencilFunction(c.EQUAL,0,255),l.setStencilTestEnabled(!0);for(const e of s){const s=y.getLayerById(e);s.type===i.BACKGROUND&&p(s,r)&&(t.styleLayerUID=s.uid,t.styleLayer=s,n.renderObjects(t,F,"vtlBackground"))}a.pool.release(g)}_computeDisplayInfoView(e){let s=e.tileInfo.lods[0].scale;const r=Math.max(25,e.tileInfo.lods.length),i=[];for(let t=0;t<=r;t++)i.push(s),s/=2;this._displayInfo=t.create({scales:i,size:512,spatialReference:e.spatialReference,numLODs:r})}}export{m as VectorTileContainer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{clone as t}from"../../../core/lang.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as n,hasDiff as o}from"../../../core/accessorSupport/diffUtils.js";import h from"../../../geometry/Point.js";import{create as u}from"../../../geometry/support/aaBoundingRect.js";import{equals as c}from"../../../geometry/support/spatialReferenceUtils.js";import{StyleUpdateType as y}from"../engine/vectorTiles/enums.js";import{TileHandler as p}from"../engine/vectorTiles/TileHandler.js";import{TileManager as d}from"../engine/vectorTiles/TileManager.js";import{VectorTile as _}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as f}from"../engine/vectorTiles/VectorTileContainer.js";import g from"../engine/vectorTiles/VectorTileFeatureIndex.js";import{StyleLayerType as m}from"../engine/vectorTiles/style/StyleDefinition.js";import T from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2DMixin as v}from"./LayerView2D.js";import C from"../tiling/TileInfoViewPOT.js";import R from"../tiling/TileQueue.js";import w from"../../layers/LayerView.js";const H=2,I=8,D=512;let S=class extends(v(w)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1}get fading(){return this._vectorTileContainer?.fading??!1}async hitTest(e,t){const i=this._tileHandlerPromise,s=this._vectorTileContainer?.symbolFader;if(!i||!this._isTileHandlerReady||!s)return;await i;let r=null;const a=this._vectorTileContainer?.symbolRepository;a&&(r=a.querySymbols(t,H,s.decluttererOffset,{}));const l=this.view.state,n=this._tileManager.getIntersectingTiles(t.x,t.y,H,l,r);if((!n||0===n.length)&&0===r?.length)return null;e=e.clone().normalize();const o=[],h=[];for(const u of n)o.push(this._queryTile(h,e,H,this.view.state.rotation,u,r?.filter((e=>e.tileKey.id===u.id))));return await Promise.all(o),h}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._start(),void(this._tileHandler.devicePixelRatio=e.pixelRatio)):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._parseQueue.resume(),this._fetchQueue.resume()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new T(e),this._tileInfoView=new C(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new f(this.view.featuresTilingScheme,this._tileInfoView),this._tileHandler=new p(this.layer,this._styleRepository,window.devicePixelRatio||1,this.layer.tileInfo.lods.length-1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this.layer.on("paint-change",(e=>{if(e.isDataDriven)this._styleChanges.push({type:y.PAINTER_CHANGED,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=i.type===m.SYMBOL;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender()}})),this.layer.on("layout-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=n(i.layout,e.layout);if(null!=s){if(o(s,"visibility")&&1===P(s))return t.setLayoutProperties(e.layer,e.layout),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),void this._vectorTileContainer?.requestRender();this._styleChanges.push({type:y.LAYOUT_CHANGED,data:e}),this.requestUpdate()}})),this.layer.on("style-layer-visibility-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(t.setStyleLayerVisibility(e.layer,e.visibility),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender())})),this.layer.on("style-layer-change",(e=>{this._styleChanges.push({type:y.LAYER_CHANGED,data:e}),this.requestUpdate()})),this.layer.on("delete-style-layer",(e=>{this._styleChanges.push({type:y.LAYER_REMOVED,data:e}),this.requestUpdate()})),this.layer.on("load-style",(()=>this._loadStyle())),this.layer.on("spriteSource-change",(e=>{this._styleChanges.push({type:y.SPRITES_CHANGED,data:e});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case m.SYMBOL:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:y.LAYOUT_CHANGED,data:{layer:i.id,layout:i.layout}});break;case m.LINE:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:y.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case m.FILL:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:y.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()}))])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=s(this._vectorTileContainer),this._tileHandler=s(this._tileHandler)}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return c(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t?.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.addPromise(this._fetchQueue.push(t.key).then((e=>this._parseQueue.push({key:t.key,data:e}))).then((e=>{t.once("attach",(()=>this.requestUpdate())),t.setData(e),this.requestUpdate()})).catch((e=>{r(e)||i.getLogger(this).error(e)}))),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new d({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then((()=>{this._fetchQueue=new R({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15}),this._parseQueue=new R({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8}),this.requestUpdate(),this._isTileHandlerReady=!0}));this._tileHandler.spriteMosaic.then((e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView,this.view.featuresTilingScheme),this.requestUpdate()})),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=s(this._fetchQueue),this._parseQueue=s(this._parseQueue),this._tileManager=s(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(l){i.getLogger(this).error("error applying vector-tiles style update",l.message),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0}const t=this._styleRepository,s=new Set;e.forEach((e=>{if(e.type!==y.LAYER_REMOVED)return;const i=e.data,r=t.getLayerById(i.layer);r&&s.add(r.uid)}));const r=new Set;e.forEach((e=>{let i;switch(e.type){case y.PAINTER_CHANGED:t.setPaintProperties(e.data.layer,e.data.paint),i=e.data.layer;break;case y.LAYOUT_CHANGED:t.setLayoutProperties(e.data.layer,e.data.layout),i=e.data.layer;break;case y.LAYER_REMOVED:return void t.deleteStyleLayer(e.data.layer);case y.LAYER_CHANGED:t.setStyleLayer(e.data.layer,e.data.index),i=e.data.layer.id;break;case y.SPRITES_CHANGED:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(e.data.spriteSource))}if(i){const e=t.getLayerById(i);e&&r.add(e.uid)}}));const a=this._vectorTileContainer.children;if(s.size>0){const e=Array.from(s);this._vectorTileContainer.deleteStyleLayers(e);for(const t of a)t.deleteLayerData(e)}if(this._fetchQueue.resume(),this._parseQueue.resume(),r.size>0){const e=Array.from(r),t=[];for(const i of a){const s=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then((t=>this._parseQueue.push({key:i.key,data:t,styleLayerUIDs:e}))).then((e=>i.setData(e))));t.push(s)}await Promise.all(t)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,i=t(e);this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._styleRepository=new T(i),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,i,this.layer.tileInfo.lods.length-1),await this._tileHandlerPromise}catch(n){if(!r(n))throw n}if(s.aborted)return this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,void this.requestUpdate();const a=await this._tileHandler.spriteMosaic,l=this._vectorTileContainer;this._tileInfoView=new C(this.layer.tileInfo,this.layer.fullExtent),l.setStyleResources(a,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView,this.view.featuresTilingScheme),this._tileManager=new d({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,this.requestUpdate()}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(u(),e),i=this._tileInfoView.getTileResolution(e.level);return new _(e,i,t[0],t[3],512,512,this._styleRepository)}async _queryTile(e,t,i,s,r,a){if(0===r.layerData.size)return;const l=this._ensureTileIndex(r),n=this._tileInfoView.getTileBounds(u(),r.key,!0),o=I*D*((t.x-n[0])/(n[2]-n[0])),h=I*D*(1-(t.y-n[1])/(n[3]-n[1])),c=await l.queryAttributes(o,h,i,s,a);for(const u of c)u.graphic.geometry=this._tileToMapPoint(u.tilePoint,r.transforms.tileUnitsToPixels),e.push({type:"graphic",layer:this.layer,graphic:u.graphic,mapPoint:t.clone()});e.sort(((e,t)=>t.graphic.origin.layerIndex-e.graphic.origin.layerIndex))}_tileToMapPoint(e,t){if(!e)return null;const i=e[0]*t[0]+e[1]*t[3]+t[6],s=e[0]*t[1]+e[1]*t[4]+t[7],r=this.view.state,a=[0,0];return r.toMap(a,[i,s]),new h({x:a[0],y:a[1],spatialReference:r.spatialReference})}_ensureTileIndex(e){let t=e.featureIndex;return t||(t=g.create(e.key,e.layerData,this._styleRepository,this._tileHandler,this.layer),e.featureIndex=t),t}};function P(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([a()],S.prototype,"_isTileHandlerReady",void 0),S=e([l("esri.views.2d.layers.VectorTileLayerView2D")],S);const A=S;export{A as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{clone as t}from"../../../core/lang.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as n,hasDiff as o}from"../../../core/accessorSupport/diffUtils.js";import h from"../../../geometry/Point.js";import{create as y}from"../../../geometry/support/aaBoundingRect.js";import{equals as u}from"../../../geometry/support/spatialReferenceUtils.js";import{StyleUpdateType as c}from"../engine/vectorTiles/enums.js";import{TileHandler as p}from"../engine/vectorTiles/TileHandler.js";import{TileManager as d}from"../engine/vectorTiles/TileManager.js";import{VectorTile as _}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as f}from"../engine/vectorTiles/VectorTileContainer.js";import g from"../engine/vectorTiles/VectorTileFeatureIndex.js";import{StyleLayerType as m}from"../engine/vectorTiles/style/StyleDefinition.js";import T from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import v from"../tiling/TileInfoViewPOT.js";import R from"../tiling/TileQueue.js";import H from"../../layers/LayerView.js";const w=2,I=8,D=512;let S=class extends(C(H)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1}get fading(){return this._vectorTileContainer?.fading??!1}async hitTest(e,t){const i=this._tileHandlerPromise,s=this._vectorTileContainer?.symbolFader;if(!i||!this._isTileHandlerReady||!s)return;await i;let r=null;const a=this._vectorTileContainer?.symbolRepository;a&&(r=a.querySymbols(t,w,s.decluttererOffset,{}));const l=this.view.state,n=this._tileManager.getIntersectingTiles(t.x,t.y,w,l,r);if((!n||0===n.length)&&0===r?.length)return null;e=e.clone().normalize();const o=[],h=[];for(const y of n)o.push(this._queryTile(h,e,w,this.view.state.rotation,y,r?.filter((e=>e.tileKey.id===y.id))));return await Promise.all(o),h}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._start(),void(this._tileHandler.devicePixelRatio=e.pixelRatio)):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._parseQueue.resume(),this._fetchQueue.resume()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new T(e),this._tileInfoView=new v(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new f(this._tileInfoView),this._tileHandler=new p(this.layer,this._styleRepository,window.devicePixelRatio||1,this.layer.tileInfo.lods.length-1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this.layer.on("paint-change",(e=>{if(e.isDataDriven)this._styleChanges.push({type:c.PAINTER_CHANGED,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=i.type===m.SYMBOL;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender()}})),this.layer.on("layout-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=n(i.layout,e.layout);if(null!=s){if(o(s,"visibility")&&1===P(s))return t.setLayoutProperties(e.layer,e.layout),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),void this._vectorTileContainer?.requestRender();this._styleChanges.push({type:c.LAYOUT_CHANGED,data:e}),this.requestUpdate()}})),this.layer.on("style-layer-visibility-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(t.setStyleLayerVisibility(e.layer,e.visibility),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender())})),this.layer.on("style-layer-change",(e=>{this._styleChanges.push({type:c.LAYER_CHANGED,data:e}),this.requestUpdate()})),this.layer.on("delete-style-layer",(e=>{this._styleChanges.push({type:c.LAYER_REMOVED,data:e}),this.requestUpdate()})),this.layer.on("load-style",(()=>this._loadStyle())),this.layer.on("spriteSource-change",(e=>{this._styleChanges.push({type:c.SPRITES_CHANGED,data:e});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case m.SYMBOL:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:c.LAYOUT_CHANGED,data:{layer:i.id,layout:i.layout}});break;case m.LINE:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:c.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case m.FILL:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:c.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()}))])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=s(this._vectorTileContainer),this._tileHandler=s(this._tileHandler)}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return u(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t?.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.addPromise(this._fetchQueue.push(t.key).then((e=>this._parseQueue.push({key:t.key,data:e}))).then((e=>{t.once("attach",(()=>this.requestUpdate())),t.setData(e),this.requestUpdate()})).catch((e=>{r(e)||i.getLogger(this).error(e)}))),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new d({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then((()=>{this._fetchQueue=new R({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15}),this._parseQueue=new R({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8}),this.requestUpdate(),this._isTileHandlerReady=!0}));this._tileHandler.spriteMosaic.then((e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this.requestUpdate()})),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=s(this._fetchQueue),this._parseQueue=s(this._parseQueue),this._tileManager=s(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(l){i.getLogger(this).error("error applying vector-tiles style update",l.message),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0}const t=this._styleRepository,s=new Set;e.forEach((e=>{if(e.type!==c.LAYER_REMOVED)return;const i=e.data,r=t.getLayerById(i.layer);r&&s.add(r.uid)}));const r=new Set;e.forEach((e=>{let i;switch(e.type){case c.PAINTER_CHANGED:t.setPaintProperties(e.data.layer,e.data.paint),i=e.data.layer;break;case c.LAYOUT_CHANGED:t.setLayoutProperties(e.data.layer,e.data.layout),i=e.data.layer;break;case c.LAYER_REMOVED:return void t.deleteStyleLayer(e.data.layer);case c.LAYER_CHANGED:t.setStyleLayer(e.data.layer,e.data.index),i=e.data.layer.id;break;case c.SPRITES_CHANGED:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(e.data.spriteSource))}if(i){const e=t.getLayerById(i);e&&r.add(e.uid)}}));const a=this._vectorTileContainer.children;if(s.size>0){const e=Array.from(s);this._vectorTileContainer.deleteStyleLayers(e);for(const t of a)t.deleteLayerData(e)}if(this._fetchQueue.resume(),this._parseQueue.resume(),r.size>0){const e=Array.from(r),t=[];for(const i of a){const s=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then((t=>this._parseQueue.push({key:i.key,data:t,styleLayerUIDs:e}))).then((e=>i.setData(e))));t.push(s)}await Promise.all(t)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,i=t(e);this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._styleRepository=new T(i),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,i,this.layer.tileInfo.lods.length-1),await this._tileHandlerPromise}catch(n){if(!r(n))throw n}if(s.aborted)return this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,void this.requestUpdate();const a=await this._tileHandler.spriteMosaic,l=this._vectorTileContainer;this._tileInfoView=new v(this.layer.tileInfo,this.layer.fullExtent),l.setStyleResources(a,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this._tileManager=new d({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,this.requestUpdate()}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(y(),e),i=this._tileInfoView.getTileResolution(e.level);return new _(e,i,t[0],t[3],512,512,this._styleRepository)}async _queryTile(e,t,i,s,r,a){if(0===r.layerData.size)return;const l=this._ensureTileIndex(r),n=this._tileInfoView.getTileBounds(y(),r.key,!0),o=I*D*((t.x-n[0])/(n[2]-n[0])),h=I*D*(1-(t.y-n[1])/(n[3]-n[1])),u=await l.queryAttributes(o,h,i,s,a);for(const y of u)y.graphic.geometry=this._tileToMapPoint(y.tilePoint,r.transforms.tileUnitsToPixels),e.push({type:"graphic",layer:this.layer,graphic:y.graphic,mapPoint:t.clone()});e.sort(((e,t)=>t.graphic.origin.layerIndex-e.graphic.origin.layerIndex))}_tileToMapPoint(e,t){if(!e)return null;const i=e[0]*t[0]+e[1]*t[3]+t[6],s=e[0]*t[1]+e[1]*t[4]+t[7],r=this.view.state,a=[0,0];return r.toMap(a,[i,s]),new h({x:a[0],y:a[1],spatialReference:r.spatialReference})}_ensureTileIndex(e){let t=e.featureIndex;return t||(t=g.create(e.key,e.layerData,this._styleRepository,this._tileHandler,this.layer),e.featureIndex=t),t}};function P(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([a()],S.prototype,"_isTileHandlerReady",void 0),S=e([l("esri.views.2d.layers.VectorTileLayerView2D")],S);const A=S;export{A 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as l,getActionStyles as r}from"../support/actions/actionUtils.js";import a from"./Widget.js";import c from"./BasemapLayerList/BasemapLayerListViewModel.js";import d from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as m}from"./BasemapLayerList/css.js";import p from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as h,getLayerType as g,getStatusIcon as b,getVisibilityIcon as f,sortableRoot as v,sortLayersToIds as _,sortChildLayersToIds as y,listItemHasChildren as I,canSortSublayers as E}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{incrementHeadingLevel as F}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";const A=t.ofType(p),k="basemap",S=".*\\S+.*";let x=class extends a{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.iconClass=m.widgetIcon,this.messages=null,this.messagesCommon=null,this.minFilterItems=u,this.selectedItems=new A,this.selectionMode="none",this.viewModel=new c,this.visibilityAppearance="default",this.visibleElements=new d,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const n="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,o=h(e);if(!o?.sortable)return!1;const l=h(t),r=g(t),a=h(i),c=g(i),d=!!r&&!!c&&r===c,m={selected:o,from:l,to:a};return t.group&&i.group&&"function"==typeof n?n.call(null,m):d&&"sublayer"!==o?.layer?.type&&"map-image"!==l?.layer?.type&&"map-image"!==a?.layer?.type},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=h(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:n,newIndex:o}=e;if(!s||!i||t?.newIndex===o&&t?.dragEl===n&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const l=s,r=i;if(l!==r)this._moveLayerFromChildList({toEl:r,fromEl:l,dragEl:n,newIndex:o});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new d({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return L({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.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"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _baseFilterEnabled(){return this.viewModel.totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this.viewModel.totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(s.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(s.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[w.hidden]:"loading"===e,[w.disabled]:"disabled"===e};return M("div",{class:this.classes(m.base,w.widget,w.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?M("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return M("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),M("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?M("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},M("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},M("div",{slot:"message"},this.messages.layerError))):e.incompatible?M("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},M("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},M("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t,i,s,n){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:r,selectedItems:a,messages:c}=this,d=e.title||c.untitledLayer,p=e.visibleAtCurrentScale?d:`${d} (${c.layerInvisibleAtScale})`,u=this._filterActions(e.actionsSections),h=this._countActions(u);return M("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable||i,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:d,metadata:{parentTitles:n,title:d},open:e.open,selected:"none"!==r&&a.includes(e),title:p,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},M("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},d),this._renderItemStatus(e,s),this._renderItemToggle(e,s),this._renderItemTemporaryIcon(e),this._renderChildList(e,t,n),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,u):1===h?this._renderAction({item:e,action:this._getSingleActionButton(u),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,l=o&&!t,r=!!s;return M("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:n,[m.updating]:l,[m.connectionStatus]:r,[m.connectionStatusConnected]:r&&"connected"===s}),icon:b({connectionStatus:s,publishing:n}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?M("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:n}=e,o=t?.visibilityMode;if("inherited"===o)return null;const l=f({visible:n,exclusive:"exclusive"===o,visibilityAppearance:s}),r="checkbox"===s;return M("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:M("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==o&&n}),icon:l,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:M("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return M("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:l(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return M("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},M("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return M("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,n={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!s};return t&&(n[t]=!0),s||t?M("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,n),key:"icon",styles:r(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e,{active:n,disabled:o,title:r,type:a,indicator:c}=i;return M("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:o,icon:l(i),indicator:c,key:`action-${i.uid}`,loading:n,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:r??"",textEnabled:s,title:r??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const n=h(i),o=h(e),l=h(t),r=j(t),a=j(e);r&&a&&this.viewModel.moveListItem({targetItem:n,fromParentItem:l,toParentItem:o,newIndex:s,from:r,to:a})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===v){const i=j(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;_(s,t)}else{const i=h(e);if(!i)return;y(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>h(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){h(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return M("div",{class:m.editing},M("calcite-label",null,e.basemapTitle,M("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:S,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return M("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return M("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?M("form",{bind:this,onsubmit:this._formSubmit},M("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:{editTitleButton:t},messagesCommon:{edit:i}}=this;return t&&!e?M("calcite-action",{bind:this,icon:"pencil",label:i,onclick:this._toggleEditingTitle,slot:"header-actions-end",text:i,title:i}):null}_renderNoLayersInfoMessage(e){return M("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return M("div",{class:m.itemMessage},M("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,scale:"m",width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:n,flow:o},messages:l,viewModel:r,referenceItems:a,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(a):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[M("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:n?r.basemapTitle??l.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d)];return t?[o?M("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{dragEnabled:s}=this,{children:n}=e,o=I(e),l=!o&&s&&"group"===e.layer?.type;return o||l?M("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":k,dragEnabled:!!s&&(e.childrenSortable&&E(e)),group:e.layer.uid},n?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:n,selectionMode:o,filterPlaceholder:l,baseFilterText:r,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d}=this,p="reference"===t?s.noReferenceLayers:s.noBaseLayers,u="reference"===t?d:c;return M("calcite-block",{class:m.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:F(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(p,t):null,M("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":k,dragEnabled:n,filterEnabled:u,filterPlaceholder:l,filterText:"reference"===t?a:r,group:v,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:o,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&u?M("div",{class:m.filterNoResults,slot:"filter-no-results"},M("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoLayersInfoMessage(p))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function j(e){return e?.getAttribute("data-basemap-layer-type")}e([n()],x.prototype,"_activeItem",void 0),e([n()],x.prototype,"_tooltipReferenceMap",void 0),e([n()],x.prototype,"_focusRootFlowItem",void 0),e([n()],x.prototype,"_focusPanelFlowItem",void 0),e([n()],x.prototype,"_focusEditingFlowItem",void 0),e([n()],x.prototype,"_baseFilterEnabled",null),e([n()],x.prototype,"_referenceFilterEnabled",null),e([n()],x.prototype,"basemapTitle",null),e([n()],x.prototype,"collapsed",void 0),e([n()],x.prototype,"dragEnabled",void 0),e([n()],x.prototype,"editingTitle",void 0),e([n()],x.prototype,"filterPlaceholder",void 0),e([n()],x.prototype,"baseFilterText",void 0),e([n()],x.prototype,"referenceFilterText",void 0),e([n()],x.prototype,"listItemCanGiveFunction",void 0),e([n()],x.prototype,"listItemCanReceiveFunction",void 0),e([n()],x.prototype,"baseListItemCreatedFunction",null),e([n()],x.prototype,"editingEnabled",null),e([n()],x.prototype,"headingLevel",void 0),e([n()],x.prototype,"iconClass",void 0),e([n()],x.prototype,"label",null),e([n(),C("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([n(),C("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([n()],x.prototype,"minFilterItems",void 0),e([n()],x.prototype,"multipleSelectionEnabled",null),e([n()],x.prototype,"referenceListItemCreatedFunction",null),e([n({readOnly:!0})],x.prototype,"baseItems",null),e([n({readOnly:!0})],x.prototype,"referenceItems",null),e([n()],x.prototype,"selectedItems",void 0),e([n()],x.prototype,"selectionMode",void 0),e([n()],x.prototype,"view",null),e([T("trigger-action"),n({type:c})],x.prototype,"viewModel",void 0),e([n()],x.prototype,"visibilityAppearance",void 0),e([n({type:d,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([o("esri.widgets.BasemapLayerList")],x);const B=x;export{B as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as l,getActionStyles as r}from"../support/actions/actionUtils.js";import a from"./Widget.js";import c from"./BasemapLayerList/BasemapLayerListViewModel.js";import d from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as m}from"./BasemapLayerList/css.js";import p from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as h,getLayerType as g,getStatusIcon as b,getVisibilityIcon as f,sortableRoot as v,sortLayersToIds as _,sortChildLayersToIds as y,listItemHasChildren as I,canSortSublayers as E}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{incrementHeadingLevel as F}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";const A=t.ofType(p),k="basemap",S=".*\\S+.*";let x=class extends a{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.iconClass=m.widgetIcon,this.messages=null,this.messagesCommon=null,this.minFilterItems=u,this.selectedItems=new A,this.selectionMode="none",this.viewModel=new c,this.visibilityAppearance="default",this.visibleElements=new d,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const n="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,o=h(e);if(!o?.sortable)return!1;const l=h(t),r=g(t),a=h(i),c=g(i),d=!!r&&!!c&&r===c,m={selected:o,from:l,to:a};return t.group&&i.group&&"function"==typeof n?n.call(null,m):d&&"sublayer"!==o?.layer?.type&&"map-image"!==l?.layer?.type&&"map-image"!==a?.layer?.type},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=h(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:n,newIndex:o}=e;if(!s||!i||t?.newIndex===o&&t?.dragEl===n&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const l=s,r=i;if(l!==r)this._moveLayerFromChildList({toEl:r,fromEl:l,dragEl:n,newIndex:o});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new d({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return L({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.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"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _baseFilterEnabled(){return this.viewModel.totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this.viewModel.totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(s.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(s.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(s.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[w.hidden]:"loading"===e,[w.disabled]:"disabled"===e};return M("div",{class:this.classes(m.base,w.widget,w.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?M("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return M("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),M("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?M("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},M("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},M("div",{slot:"message"},this.messages.layerError))):e.incompatible?M("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},M("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},M("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t,i,s,n){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:r,selectedItems:a,messages:c}=this,d=e.title||c.untitledLayer,p=e.visibleAtCurrentScale?d:`${d} (${c.layerInvisibleAtScale})`,u=this._filterActions(e.actionsSections),h=this._countActions(u);return M("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable||i,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:d,metadata:{parentTitles:n,title:d},open:e.open,selected:"none"!==r&&a.includes(e),title:p,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},M("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},d),this._renderItemStatus(e,s),this._renderItemToggle(e,s),this._renderItemTemporaryIcon(e),this._renderChildList(e,t,n),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,u):1===h?this._renderAction({item:e,action:this._getSingleActionButton(u),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,l=o&&!t,r=!!s;return M("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:n,[m.updating]:l,[m.connectionStatus]:r,[m.connectionStatusConnected]:r&&"connected"===s}),icon:b({connectionStatus:s,publishing:n}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?M("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:n}=e,o=t?.visibilityMode;if("inherited"===o)return null;const l=f({visible:n,exclusive:"exclusive"===o,visibilityAppearance:s}),r="checkbox"===s;return M("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:M("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==o&&n}),icon:l,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:M("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return M("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:l(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return M("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},M("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return M("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,n={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!s};return t&&(n[t]=!0),s||t?M("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,n),key:"icon",styles:r(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e,{active:n,disabled:o,title:r,type:a,indicator:c}=i;return M("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:o,icon:l(i),indicator:c,key:`action-${i.uid}`,loading:n,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:r??"",textEnabled:s,title:r??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const n=h(i),o=h(e),l=h(t),r=j(t),a=j(e);r&&a&&this.viewModel.moveListItem({targetItem:n,fromParentItem:l,toParentItem:o,newIndex:s,from:r,to:a})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===v){const i=j(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;_(s,t)}else{const i=h(e);if(!i)return;y(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>h(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){h(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return M("div",{class:m.editing},M("calcite-label",null,e.basemapTitle,M("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:S,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return M("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return M("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?M("form",{bind:this,onsubmit:this._formSubmit},M("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:{editTitleButton:t},messagesCommon:{edit:i}}=this;return t&&!e?M("calcite-action",{bind:this,icon:"pencil",label:i,onclick:this._toggleEditingTitle,slot:"header-actions-end",text:i,title:i}):null}_renderNoLayersInfoMessage(e){return M("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return M("div",{class:m.itemMessage},M("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,scale:"m",width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:n,flow:o},messages:l,viewModel:r,referenceItems:a,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(a):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[M("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:n?r.basemapTitle??l.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d)];return t?[o?M("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{dragEnabled:s}=this,{children:n}=e,o=I(e),l=!o&&s&&"group"===e.layer?.type;return o||l?M("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":k,dragEnabled:!!s&&(e.childrenSortable&&E(e)),group:e.layer.uid},n?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:n,selectionMode:o,filterPlaceholder:l,baseFilterText:r,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d}=this,p="reference"===t?s.noReferenceLayers:s.noBaseLayers,u="reference"===t?d:c;return M("calcite-block",{class:m.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:F(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(p,t):null,M("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":k,dragEnabled:n,filterEnabled:u,filterPlaceholder:l,filterText:u?"reference"===t?a:r:"",group:v,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:o,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&u?M("div",{class:m.filterNoResults,slot:"filter-no-results"},M("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoLayersInfoMessage(p))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function j(e){return e?.getAttribute("data-basemap-layer-type")}e([n()],x.prototype,"_activeItem",void 0),e([n()],x.prototype,"_tooltipReferenceMap",void 0),e([n()],x.prototype,"_focusRootFlowItem",void 0),e([n()],x.prototype,"_focusPanelFlowItem",void 0),e([n()],x.prototype,"_focusEditingFlowItem",void 0),e([n()],x.prototype,"_baseFilterEnabled",null),e([n()],x.prototype,"_referenceFilterEnabled",null),e([n()],x.prototype,"basemapTitle",null),e([n()],x.prototype,"collapsed",void 0),e([n()],x.prototype,"dragEnabled",void 0),e([n()],x.prototype,"editingTitle",void 0),e([n()],x.prototype,"filterPlaceholder",void 0),e([n()],x.prototype,"baseFilterText",void 0),e([n()],x.prototype,"referenceFilterText",void 0),e([n()],x.prototype,"listItemCanGiveFunction",void 0),e([n()],x.prototype,"listItemCanReceiveFunction",void 0),e([n()],x.prototype,"baseListItemCreatedFunction",null),e([n()],x.prototype,"editingEnabled",null),e([n()],x.prototype,"headingLevel",void 0),e([n()],x.prototype,"iconClass",void 0),e([n()],x.prototype,"label",null),e([n(),C("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([n(),C("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([n()],x.prototype,"minFilterItems",void 0),e([n()],x.prototype,"multipleSelectionEnabled",null),e([n()],x.prototype,"referenceListItemCreatedFunction",null),e([n({readOnly:!0})],x.prototype,"baseItems",null),e([n({readOnly:!0})],x.prototype,"referenceItems",null),e([n()],x.prototype,"selectedItems",void 0),e([n()],x.prototype,"selectionMode",void 0),e([n()],x.prototype,"view",null),e([T("trigger-action"),n({type:c})],x.prototype,"viewModel",void 0),e([n()],x.prototype,"visibilityAppearance",void 0),e([n({type:d,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([o("esri.widgets.BasemapLayerList")],x);const B=x;export{B 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Logger.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as o}from"./featureUtils.js";import{globalCss as i}from"../../support/globalCss.js";const n="esri.widgets.Feature.support.arcadeFeatureUtils",s=()=>e.getLogger(n);function
|
|
5
|
+
import e from"../../../core/Logger.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as o}from"./featureUtils.js";import{globalCss as i}from"../../support/globalCss.js";const n="esri.widgets.Feature.support.arcadeFeatureUtils",s=()=>e.getLogger(n);function p(e){return"string"==typeof e?a(o(e)):Array.isArray(e)?c(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function c(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?a(o(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?a(o(t)):t}</td></tr>`})).join("");return`<table class="${i.table}">${r}</table>`}function l(){return import("../../../arcade.js")}function d(e){return"createQuery"in e&&"queryFeatures"in e}async function f({graphic:e,view:r,options:t}){const{isAggregate:a,layer:o}=e;if(!a||!o||"2d"!==r?.type)return[];const i=await r.whenLayerView(o);if(!d(i))return[];const n=i.createQuery(),s=e.getObjectId();n.aggregateIds=null!=s?[s]:[];const{features:p}=await i.queryFeatures(n,t);return p}function y({layer:e,aggregatedFeatures:r,interceptor:a}){const{fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p}=e;return new t({fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p,interceptor:a,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}async function g({expressionInfo:e,arcade:r,interceptor:t,spatialReference:a,map:o,graphic:i,location:n,view:p,options:c}){if(!e?.expression)return null;const{isAggregate:u}=i,l=(i.sourceLayer||i.layer)??void 0,d=u?"feature-reduction-popup":"popup",g=r.createArcadeProfile(d),m=r.createArcadeExecutor(e.expression,g).catch((r=>s().error("arcade-executor-error",{error:r,expressionInfo:e}))),[w,h]=await Promise.all([f({graphic:i,view:p,options:c}),m]);if(!h)return null;const F="feature-reduction-popup"===d?y({layer:l,aggregatedFeatures:w,interceptor:t}):void 0,$={..."feature-reduction-popup"===d?{$aggregatedFeatures:F}:{$datastore:l?.url,$layer:"feature"===l?.type||"subtype-sublayer"===l?.type?l:"scene"===l?.type&&null!=l.associatedLayer?l.associatedLayer:void 0,$map:o,$userInput:n,$graph:"knowledge-graph-sublayer"===l?.type?l?.parentCompositeLayer?.knowledgeGraph:void 0},$feature:i},v={abortSignal:c?.signal??void 0,interceptor:t??void 0,rawOutput:!0,spatialReference:a??void 0,timeZone:p?.timeZone};return await h.executeAsync($,v).catch((r=>s().error("arcade-execution-error",{error:r,graphic:i,expressionInfo:e}))).finally((()=>F?.destroy()))}async function m({expressionInfos:e,spatialReference:t,graphic:a,interceptor:o,map:i,view:n,location:s,options:c}){if(!e?.length)return{};const u=await l(),d={};for(const r of e)d[`expression/${r.name}`]=g({expressionInfo:r,arcade:u,interceptor:o,spatialReference:t,map:i,graphic:a,location:s,view:n,options:c});const f=await r(d),y={};for(const r in f)y[r]=p(f[r].value);return y}export{g as createCompiledExpression,m as createCompiledExpressions,l as loadArcade};
|
package/widgets/LayerList.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as a}from"../support/actions/actionUtils.js";import c from"./Widget.js";import{css as d}from"./LayerList/css.js";import m from"./LayerList/LayerListViewModel.js";import p from"./LayerList/LayerListVisibleElements.js";import u from"./LayerList/ListItem.js";import{minDragEnabledItems as h,minFilterItems as g,getItem as v,getLayerType as y,sortableRoot as f,listItemHasChildren as _,canSortSublayers as b,getStatusIcon as I,getVisibilityIcon as w,sortLayersToIds as E,sortChildLayersToIds as L}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as A}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as F}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";const S=t.ofType(u),j="operational";let x=class extends c{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=d.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=h,this.minFilterItems=g,this.selectedItems=new S,this.selectionMode="none",this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new p,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=v(e);if(!l?.sortable)return!1;const n=v(t),r=y(t),a=v(i),c=y(i),d=!!r&&!!c&&r===c,m={selected:l,from:n,to:a};return t.group&&i.group&&"function"==typeof s?s.call(null,m):d&&"sublayer"!==l?.layer?.type&&"map-image"!==n?.layer?.type&&"map-image"!==a?.layer?.type},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(d.item)));this._activeItem=v(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.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"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[A.hidden]:"loading"===e,[A.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return k("div",{class:this.classes(d.base,A.widget,A.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?k("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return k("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return k("div",{class:d.itemMessage,key:"esri-layer-list__no-items"},k("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return k("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),k("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,visibleElements:{closeButton:s,collapseButton:l,heading:n,flow:r},_dragEnabled:a,selectionMode:c,filterText:m,filterPlaceholder:p,messages:u}=this,h=[k("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:s,closed:!t,collapsed:i,collapsible:l,heading:n?u.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},k("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":j,dragEnabled:a,filterEnabled:o,filterPlaceholder:p,filterText:m,group:f,key:"root-list",label:u.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?k("div",{class:d.filterNoResults,slot:"filter-no-results"},k("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?r?k("calcite-flow",{key:"root-flow"},h):h:null}_renderChildList(e,t=[]){const{_dragEnabled:i}=this,{children:o}=e,s=_(e),l=!s&&i&&"group"===e.layer?.type;return s||l?k("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":j,dragEnabled:!!i&&(e.childrenSortable&&b(e)),group:e.layer.uid},o?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title])))):null}_renderItemMessage(e){return e.error?k("div",{class:d.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},k("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},k("div",{slot:"message"},this.messages.layerError))):e.incompatible?k("div",{class:d.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},k("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},k("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:s,selectionMode:l,selectedItems:n,messages:r}=this,a=e.title||r.untitledLayer,c=e.visibleAtCurrentScale?a:`${a} (${r.layerInvisibleAtScale})`,m=this._filterActions(e.actionsSections),p=this._countActions(m);return k("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(d.item,{[d.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable,dragSelected:e.layer.uid===s,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:a,metadata:{parentTitles:i,title:a},open:e.open,selected:"none"!==l&&n.includes(e),title:c,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},k("div",{class:this.classes({[d.itemContent]:!0,[d.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},a),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),p>1?this._renderActionsSections(e,m):1===p?this._renderAction({item:e,action:this._getSingleActionButton(m),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:l}=e,n=l&&!t,r=!!o;return k("calcite-icon",{class:this.classes({[d.statusIndicator]:!0,[d.publishing]:s,[d.updating]:n,[d.connectionStatus]:r,[d.connectionStatusConnected]:r&&"connected"===o}),icon:I({connectionStatus:o,publishing:s}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?k("calcite-icon",{class:d.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:s}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=w({visible:s,exclusive:"exclusive"===l,visibilityAppearance:o}),r="checkbox"===o;return k("calcite-action",{appearance:"transparent",class:d.visibleToggle,icon:r?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:k("calcite-icon",{class:this.classes({[d.visibleIcon]:"exclusive"!==l&&s}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:k("div",{class:d.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return k("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return k("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},k("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return k("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[d.itemActionIcon]:!!t,[d.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?k("span",{"aria-hidden":"true",class:this.classes(d.itemActionIcon,s),key:"icon",styles:a(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:l,title:n,type:a,indicator:c}=i;return k("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:n??"",textEnabled:o,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=v(i),l=v(e),n=v(t);this.viewModel.moveListItem(s,n,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===f)E(this.view?.map?.layers,t);else{const i=v(e);if(!i)return;L(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>v(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){v(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([l()],x.prototype,"_activeItem",void 0),e([l()],x.prototype,"_tooltipReferenceMap",void 0),e([l()],x.prototype,"_focusRootFlowItem",void 0),e([l()],x.prototype,"_focusPanelFlowItem",void 0),e([l()],x.prototype,"_dragEnabled",null),e([l()],x.prototype,"_filterEnabled",null),e([l()],x.prototype,"collapsed",void 0),e([l()],x.prototype,"dragEnabled",void 0),e([l()],x.prototype,"filterPlaceholder",void 0),e([l()],x.prototype,"filterText",void 0),e([l()],x.prototype,"headingLevel",void 0),e([l()],x.prototype,"icon",void 0),e([l()],x.prototype,"iconClass",void 0),e([l()],x.prototype,"label",null),e([l()],x.prototype,"listItemCanGiveFunction",void 0),e([l()],x.prototype,"listItemCanReceiveFunction",void 0),e([l()],x.prototype,"listItemCreatedFunction",null),e([l(),M("esri/widgets/LayerList/t9n/LayerList")],x.prototype,"messages",void 0),e([l(),M("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([l()],x.prototype,"minDragEnabledItems",void 0),e([l()],x.prototype,"minFilterItems",void 0),e([l()],x.prototype,"multipleSelectionEnabled",null),e([l()],x.prototype,"operationalItems",null),e([l()],x.prototype,"selectionEnabled",null),e([l()],x.prototype,"selectedItems",void 0),e([l()],x.prototype,"selectionMode",void 0),e([l()],x.prototype,"view",null),e([F("trigger-action"),l({type:m})],x.prototype,"viewModel",void 0),e([l()],x.prototype,"visibilityAppearance",void 0),e([l({type:p,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([n("esri.widgets.LayerList")],x);const P=x;export{P as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as a}from"../support/actions/actionUtils.js";import c from"./Widget.js";import{css as d}from"./LayerList/css.js";import m from"./LayerList/LayerListViewModel.js";import p from"./LayerList/LayerListVisibleElements.js";import u from"./LayerList/ListItem.js";import{minDragEnabledItems as h,minFilterItems as g,getItem as v,getLayerType as y,sortableRoot as f,listItemHasChildren as _,canSortSublayers as b,getStatusIcon as I,getVisibilityIcon as w,sortLayersToIds as E,sortChildLayersToIds as L}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as A}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as F}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";const S=t.ofType(u),j="operational";let x=class extends c{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=d.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=h,this.minFilterItems=g,this.selectedItems=new S,this.selectionMode="none",this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new p,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=v(e);if(!l?.sortable)return!1;const n=v(t),r=y(t),a=v(i),c=y(i),d=!!r&&!!c&&r===c,m={selected:l,from:n,to:a};return t.group&&i.group&&"function"==typeof s?s.call(null,m):d&&"sublayer"!==l?.layer?.type&&"map-image"!==n?.layer?.type&&"map-image"!==a?.layer?.type},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(d.item)));this._activeItem=v(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.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"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.selectionEnabled?"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[A.hidden]:"loading"===e,[A.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return k("div",{class:this.classes(d.base,A.widget,A.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?k("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return k("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return k("div",{class:d.itemMessage,key:"esri-layer-list__no-items"},k("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return k("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),k("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,visibleElements:{closeButton:s,collapseButton:l,heading:n,flow:r},_dragEnabled:a,selectionMode:c,filterText:m,filterPlaceholder:p,messages:u}=this,h=[k("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:s,closed:!t,collapsed:i,collapsible:l,heading:n?u.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},k("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":j,dragEnabled:a,filterEnabled:o,filterPlaceholder:p,filterText:o?m:"",group:f,key:"root-list",label:u.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?k("div",{class:d.filterNoResults,slot:"filter-no-results"},k("calcite-notice",{kind:"info",open:!0,scale:"m",width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?r?k("calcite-flow",{key:"root-flow"},h):h:null}_renderChildList(e,t=[]){const{_dragEnabled:i}=this,{children:o}=e,s=_(e),l=!s&&i&&"group"===e.layer?.type;return s||l?k("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":j,dragEnabled:!!i&&(e.childrenSortable&&b(e)),group:e.layer.uid},o?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title])))):null}_renderItemMessage(e){return e.error?k("div",{class:d.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},k("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},k("div",{slot:"message"},this.messages.layerError))):e.incompatible?k("div",{class:d.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},k("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},k("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t,i){const{_activeItem:o,_selectedDragItemLayerUid:s,selectionMode:l,selectedItems:n,messages:r}=this,a=e.title||r.untitledLayer,c=e.visibleAtCurrentScale?a:`${a} (${r.layerInvisibleAtScale})`,m=this._filterActions(e.actionsSections),p=this._countActions(m);return k("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(d.item,{[d.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable,dragSelected:e.layer.uid===s,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:a,metadata:{parentTitles:i,title:a},open:e.open,selected:"none"!==l&&n.includes(e),title:c,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},k("div",{class:this.classes({[d.itemContent]:!0,[d.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},a),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),p>1?this._renderActionsSections(e,m):1===p?this._renderAction({item:e,action:this._getSingleActionButton(m),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:l}=e,n=l&&!t,r=!!o;return k("calcite-icon",{class:this.classes({[d.statusIndicator]:!0,[d.publishing]:s,[d.updating]:n,[d.connectionStatus]:r,[d.connectionStatusConnected]:r&&"connected"===o}),icon:I({connectionStatus:o,publishing:s}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?k("calcite-icon",{class:d.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:s}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=w({visible:s,exclusive:"exclusive"===l,visibilityAppearance:o}),r="checkbox"===o;return k("calcite-action",{appearance:"transparent",class:d.visibleToggle,icon:r?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:k("calcite-icon",{class:this.classes({[d.visibleIcon]:"exclusive"!==l&&s}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:k("div",{class:d.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return k("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return k("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},k("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return k("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[d.itemActionIcon]:!!t,[d.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?k("span",{"aria-hidden":"true",class:this.classes(d.itemActionIcon,s),key:"icon",styles:a(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:l,title:n,type:a,indicator:c}=i;return k("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:n??"",textEnabled:o,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=v(i),l=v(e),n=v(t);this.viewModel.moveListItem(s,n,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===f)E(this.view?.map?.layers,t);else{const i=v(e);if(!i)return;L(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>v(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){v(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([l()],x.prototype,"_activeItem",void 0),e([l()],x.prototype,"_tooltipReferenceMap",void 0),e([l()],x.prototype,"_focusRootFlowItem",void 0),e([l()],x.prototype,"_focusPanelFlowItem",void 0),e([l()],x.prototype,"_dragEnabled",null),e([l()],x.prototype,"_filterEnabled",null),e([l()],x.prototype,"collapsed",void 0),e([l()],x.prototype,"dragEnabled",void 0),e([l()],x.prototype,"filterPlaceholder",void 0),e([l()],x.prototype,"filterText",void 0),e([l()],x.prototype,"headingLevel",void 0),e([l()],x.prototype,"icon",void 0),e([l()],x.prototype,"iconClass",void 0),e([l()],x.prototype,"label",null),e([l()],x.prototype,"listItemCanGiveFunction",void 0),e([l()],x.prototype,"listItemCanReceiveFunction",void 0),e([l()],x.prototype,"listItemCreatedFunction",null),e([l(),M("esri/widgets/LayerList/t9n/LayerList")],x.prototype,"messages",void 0),e([l(),M("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([l()],x.prototype,"minDragEnabledItems",void 0),e([l()],x.prototype,"minFilterItems",void 0),e([l()],x.prototype,"multipleSelectionEnabled",null),e([l()],x.prototype,"operationalItems",null),e([l()],x.prototype,"selectionEnabled",null),e([l()],x.prototype,"selectedItems",void 0),e([l()],x.prototype,"selectionMode",void 0),e([l()],x.prototype,"view",null),e([F("trigger-action"),l({type:m})],x.prototype,"viewModel",void 0),e([l()],x.prototype,"visibilityAppearance",void 0),e([l({type:p,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([n("esri.widgets.LayerList")],x);const P=x;export{P as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/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/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=i.ofType(d),u=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.OrientedImageryLayer","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"]),f="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[f,p,"view.layerViews",v];let w=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new L,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),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.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.
|
|
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/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=i.ofType(d),u=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.OrientedImageryLayer","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"]),f="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[f,p,"view.layerViews",v];let w=class extends r{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new i,this.activeLayerInfos=new L,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),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.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._propertiesChangeHandle())),c.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),c.legendProperties)}_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===f||e===v),i=!this.groundLegendVisible&&e===p;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!!u.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 d({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.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&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)&&(!this.view||r.featureReduction.maxScale<=this.view.scale)?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:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import s from"../../config.js";import r from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{mappedFind as h}from"../../core/maybe.js";import{eachAlways as p,after as g}from"../../core/promiseUtils.js";import{watch as d,whenOnce as m,initial as y}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Point.js";import v from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w,getPointWithElevation as b}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import I from"../../portal/Portal.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import F from"./SearchSource.js";import{isArcGISWorldGeocoder as j,meteredArcGISLocatorUrl as P,isProxiedArcGISWorldGeocoder as C,isMeteredArcGISWorldGeocoder as G}from"./support/locatorUtils.js";import{supported as O,getCurrentPosition as A,positionToPoint as N}from"../support/geolocationUtils.js";import{GoToMixin as D}from"../support/GoTo.js";import M from"../../symbols/PictureMarkerSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import k from"../../symbols/SimpleFillSymbol.js";import J from"../../symbols/TextSymbol.js";function H(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U=()=>L("esri/widgets/Search/t9n/Search"),B="highlight",Q=a.ofType({key:e=>e.layer?"layer":"locator",base:F,typeMap:{layer:R,locator:E}}),Z=v.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(D(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new M({url:t(q),size:24,width:24,height:24}),polyline:new V({color:[130,130,130,1],width:2}),polygon:new k({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=I.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await U();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([d((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),y),x(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||O()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=O();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});c.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===K)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replace(z,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw c.getLogger(this).error(e),e}const t=(async()=>{try{const t=await A(),s=await N({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw c.getLogger(this).error(t),t}const{view:t}=this,s=H(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw c.getLogger(this).error(e),e}const i=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=H(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=H(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,h=(H(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:g}=e;if(!g){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:g});throw c.getLogger(this).error(e),e}const{attributes:d,geometry:m,layer:y,sourceLayer:f}=g,S=m?w(m):null,_={layerViewQuery:this._getLayerView(g),elevationQuery:t&&null!=S?b(S,t):Promise.resolve(S)},v=await p(_),x=v.layerViewQuery.value,L=v.elevationQuery.value;l instanceof J&&(l.text=e.name);const I=t&&u?e.target||e.extent:null,E=null!=I?this._goToSearchResult(I):Promise.resolve();await E;const F=x?g:new r({geometry:m,symbol:l,attributes:d,layer:y,sourceLayer:f,popupTemplate:h}),j=t?.popup,P=j&&F.getEffectivePopupTemplate(j.defaultPopupTemplateEnabled);return P&&await t.openPopup({features:[F],location:L}),x&&T(x)&&!P&&this._highlightFeature({graphic:F,layerView:x}),!x&&a&&t&&t.graphics.push(F),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",F),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await m((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=p([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}await m((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=s.apiKey&&j(e.url)?{url:P}:null,r=E.fromJSON({...e,...t}),o=r.url;if(j(o)||C(o)||G(o)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map((e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map((e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find((e=>e.id===t.subLayer));if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return c.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&e.close()}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return g(s,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?w(e.geometry):e instanceof _?e:Array.isArray(e)&&2===e.length?new _({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&H(e,"key")&&H(e,"text")&&H(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){return h(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),c.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===K){const r=s&&H(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach(((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&H(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:s});throw c.getLogger(this).error(e),e}return r===K?s.forEach(((s,r)=>{o.push(this._getResultsFromSource(e,r,t))})):o.push(this._getResultsFromSource(e,r,t)),p(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw c.getLogger(this).error(e),e}return r===K?s.forEach(((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))})):o.push(this._getSuggestionsFromSource(e,r,t)),p(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=H(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof R&&H(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=H(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=H(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=H(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof R&&H(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return H(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results?.some((({results:t})=>t?.includes(e)));return t?e.sourceIndex??null:null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:s}=e;return s?(await t.when(),t.whenLayerView(s)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o}=t,{objectIdField:i}=o,l=(i&&r?.[i])??null,a=s.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};W.ALL_INDEX=K,e([f()],W.prototype,"_searching",void 0),e([f()],W.prototype,"_updatingPromise",void 0),e([f({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([f()],W.prototype,"activeSourceIndex",null),e([f()],W.prototype,"allPlaceholder",null),e([f({readOnly:!0})],W.prototype,"allSources",null),e([f()],W.prototype,"autoNavigate",void 0),e([f()],W.prototype,"autoSelect",void 0),e([f()],W.prototype,"defaultPopupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultSources",void 0),e([f()],W.prototype,"defaultSymbols",void 0),e([f()],W.prototype,"includeDefaultSources",void 0),e([f()],W.prototype,"locationEnabled",null),e([f()],W.prototype,"maxInputLength",void 0),e([f()],W.prototype,"maxResults",void 0),e([f()],W.prototype,"maxSuggestions",void 0),e([f()],W.prototype,"messages",void 0),e([f()],W.prototype,"minSuggestCharacters",void 0),e([f({readOnly:!0})],W.prototype,"placeholder",null),e([f()],W.prototype,"popupEnabled",void 0),e([f({type:o})],W.prototype,"popupTemplate",void 0),e([f({type:I})],W.prototype,"portal",void 0),e([f()],W.prototype,"resultCount",void 0),e([f()],W.prototype,"resultGraphicEnabled",void 0),e([f({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([f({readOnly:!0})],W.prototype,"results",void 0),e([f({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([f()],W.prototype,"searchAllEnabled",void 0),e([f({readOnly:!0})],W.prototype,"selectedResult",void 0),e([f()],W.prototype,"searchTerm",null),e([f({type:Q})],W.prototype,"sources",void 0),e([f({readOnly:!0})],W.prototype,"state",null),e([f()],W.prototype,"suggestionDelay",void 0),e([f()],W.prototype,"suggestionCount",void 0),e([f({readOnly:!0})],W.prototype,"suggestions",void 0),e([f()],W.prototype,"suggestionsEnabled",void 0),e([f({readOnly:!0})],W.prototype,"updating",null),e([f()],W.prototype,"view",void 0),e([f()],W.prototype,"clear",null),W=e([S("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import r from"../../config.js";import s from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{mappedFind as h}from"../../core/maybe.js";import{eachAlways as p,after as g}from"../../core/promiseUtils.js";import{watch as d,whenOnce as m,initial as y}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Point.js";import v from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w,getPointWithElevation as b}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import I from"../../portal/Portal.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import F from"./SearchSource.js";import{isArcGISWorldGeocoder as j,meteredArcGISLocatorUrl as P,isProxiedArcGISWorldGeocoder as C,isMeteredArcGISWorldGeocoder as G}from"./support/locatorUtils.js";import{supported as O,getCurrentPosition as A,positionToPoint as N}from"../support/geolocationUtils.js";import{GoToMixin as D}from"../support/GoTo.js";import M from"../../symbols/PictureMarkerSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import k from"../../symbols/SimpleFillSymbol.js";import J from"../../symbols/TextSymbol.js";function H(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U=()=>L("esri/widgets/Search/t9n/Search"),B="highlight",Q=a.ofType({key:e=>e.layer?"layer":"locator",base:F,typeMap:{layer:R,locator:E}}),Z=v.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(D(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new M({url:t(q),size:24,width:24,height:24}),polyline:new V({color:[130,130,130,1],width:2}),polygon:new k({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=I.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await U();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([d((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),y),x(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||O()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=O();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});c.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===K)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(z,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw c.getLogger(this).error(e),e}const t=(async()=>{try{const t=await A(),r=await N({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw c.getLogger(this).error(t),t}const{view:t}=this,r=H(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw c.getLogger(this).error(e),e}const i=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=H(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=H(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,h=(H(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:g}=e;if(!g){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:g});throw c.getLogger(this).error(e),e}const{attributes:d,geometry:m,layer:y,sourceLayer:f}=g,S=m?w(m):null,_={layerViewQuery:this._getLayerView(g),elevationQuery:t&&null!=S?b(S,t):Promise.resolve(S)},v=await p(_),x=v.layerViewQuery.value,L=v.elevationQuery.value;l instanceof J&&(l.text=e.name);const I=t&&u?e.target||e.extent:null,E=null!=I?this._goToSearchResult(I):Promise.resolve();await E;const F=x?g:new s({geometry:m,symbol:l,attributes:d,layer:y,sourceLayer:f,popupTemplate:h}),j=t?.popup,P=j&&F.getEffectivePopupTemplate(j.defaultPopupTemplateEnabled);return P&&await t.openPopup({features:[F],location:L}),x&&T(x)&&!P&&this._highlightFeature({graphic:F,layerView:x}),!x&&a&&t&&t.graphics.push(F),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",F),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await m((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=p([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await m((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=r.apiKey&&j(e.url)?{url:P}:null,s=E.fromJSON({...e,...t}),o=s.url;if(j(o)||C(o)||G(o)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return c.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return g(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?w(e.geometry):e instanceof _?e:Array.isArray(e)&&2===e.length?new _({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&H(e,"key")&&H(e,"text")&&H(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return h(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),c.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===K){const s=r&&H(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&H(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),p(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),p(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=H(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof R&&H(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=H(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=H(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=H(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof R&&H(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return H(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return h(this.results??[],(({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null}))??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:r}=e;return r?(await t.when(),t.whenLayerView(r)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=(i&&s?.[i])??null,a=r.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};W.ALL_INDEX=K,e([f()],W.prototype,"_searching",void 0),e([f()],W.prototype,"_updatingPromise",void 0),e([f({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([f()],W.prototype,"activeSourceIndex",null),e([f()],W.prototype,"allPlaceholder",null),e([f({readOnly:!0})],W.prototype,"allSources",null),e([f()],W.prototype,"autoNavigate",void 0),e([f()],W.prototype,"autoSelect",void 0),e([f()],W.prototype,"defaultPopupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultSources",void 0),e([f()],W.prototype,"defaultSymbols",void 0),e([f()],W.prototype,"includeDefaultSources",void 0),e([f()],W.prototype,"locationEnabled",null),e([f()],W.prototype,"maxInputLength",void 0),e([f()],W.prototype,"maxResults",void 0),e([f()],W.prototype,"maxSuggestions",void 0),e([f()],W.prototype,"messages",void 0),e([f()],W.prototype,"minSuggestCharacters",void 0),e([f({readOnly:!0})],W.prototype,"placeholder",null),e([f()],W.prototype,"popupEnabled",void 0),e([f({type:o})],W.prototype,"popupTemplate",void 0),e([f({type:I})],W.prototype,"portal",void 0),e([f()],W.prototype,"resultCount",void 0),e([f()],W.prototype,"resultGraphicEnabled",void 0),e([f({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([f({readOnly:!0})],W.prototype,"results",void 0),e([f({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([f()],W.prototype,"searchAllEnabled",void 0),e([f({readOnly:!0})],W.prototype,"selectedResult",void 0),e([f()],W.prototype,"searchTerm",null),e([f({type:Q})],W.prototype,"sources",void 0),e([f({readOnly:!0})],W.prototype,"state",null),e([f()],W.prototype,"suggestionDelay",void 0),e([f()],W.prototype,"suggestionCount",void 0),e([f({readOnly:!0})],W.prototype,"suggestions",void 0),e([f()],W.prototype,"suggestionsEnabled",void 0),e([f({readOnly:!0})],W.prototype,"updating",null),e([f()],W.prototype,"view",void 0),e([f()],W.prototype,"clear",null),W=e([S("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X as default};
|