@arcgis/core 4.34.0-next.78 → 4.34.0-next.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0668eee42b3169e1bf66.js → 03e5d1a00d85e4d16bff.js} +1 -1
- package/assets/esri/core/workers/chunks/{e81386199a6db9a50fd3.js → 0914a52fb33af5d77fab.js} +1 -1
- package/assets/esri/core/workers/chunks/{29a86d51407310bb7745.js → 09f1a27442bdd52cdeb7.js} +1 -1
- package/assets/esri/core/workers/chunks/0bae29ffcbb812d3ba0d.js +1 -0
- package/assets/esri/core/workers/chunks/0dfc2ca36014910457ef.js +1 -0
- package/assets/esri/core/workers/chunks/{a0edff37fd4a3f2cb2eb.js → 1c7fffb496af6f2540dd.js} +1 -1
- package/assets/esri/core/workers/chunks/{7680d4d739f7aa3f7ae1.js → 20ae2316d927415f3df9.js} +1 -1
- package/assets/esri/core/workers/chunks/{54b1a960bb8c3fe05976.js → 2266a8f2c2ec37c19bb4.js} +1 -1
- package/assets/esri/core/workers/chunks/22bd4255b6b511a43b66.js +1 -0
- package/assets/esri/core/workers/chunks/{9ce599dc1d385e6893c1.js → 22f196d173711ebd64c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 23a13fbab9984953a7c6.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f7d7dc05e63fc50325e.js → 3c0990c4be06a2fd51e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{d69bd6b5d781a6c527d1.js → 486ea51306c619238e41.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc7423413747566f56e2.js → 49cb78c85de0102e5f02.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9e725d2b5a7d0132663.js → 5610dfde4e636e2333a9.js} +1 -1
- package/assets/esri/core/workers/chunks/{5ed381a268855bcad072.js → 56edb55b53779e7fd31e.js} +1 -1
- package/assets/esri/core/workers/chunks/{bccecd678faff927ac76.js → 5b35b30495145bf8dd5d.js} +1 -1
- package/assets/esri/core/workers/chunks/5c1cdc2ec06c4c6bd0b3.js +1 -0
- package/assets/esri/core/workers/chunks/{3452ba299f6ce0582f09.js → 5dee8c0c60ced791e57f.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f523bc8551e712c9bd4.js → 637a5293e36f4f7f2853.js} +1 -1
- package/assets/esri/core/workers/chunks/{3505988ce3839cdbbc98.js → 651b9144abb1895cc510.js} +1 -1
- package/assets/esri/core/workers/chunks/{9e3164bf8872d7b1b191.js → 66e0bc4acb18f00a433d.js} +1 -1
- package/assets/esri/core/workers/chunks/{afa3ca2bd2648774f133.js → 6e2a3abc3dbc342212c4.js} +1 -1
- package/assets/esri/core/workers/chunks/6e4ec9fa931c69e4e4ba.js +1 -0
- package/assets/esri/core/workers/chunks/6e5175b43220d6692263.js +1 -0
- package/assets/esri/core/workers/chunks/{cac5732f9dfece4bf2c5.js → 7402c2853f6aed8d1bc7.js} +1 -1
- package/assets/esri/core/workers/chunks/{49e6202da7a20f06c661.js → 76db75337044de8218c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{b97f224972f1b1abaee8.js → 79a9f47dfa9ebabb5dbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{d1657a29321adb259166.js → 86378d4f4d7f9a370c22.js} +1 -1
- package/assets/esri/core/workers/chunks/86832d94190150c70c11.js +1 -0
- package/assets/esri/core/workers/chunks/{d89832617bac4890893e.js → 885a398de8a33d36c59e.js} +1 -1
- package/assets/esri/core/workers/chunks/88d8ff0140f5ea97c6b7.js +1 -0
- package/assets/esri/core/workers/chunks/{5248581d23ada240c78d.js → 8cae725e631d922853c8.js} +1 -1
- package/assets/esri/core/workers/chunks/{0b69d251961d8b46fe30.js → 9346437b152b20bdcf8a.js} +1 -1
- package/assets/esri/core/workers/chunks/{a05a7df07b74e1957538.js → 9673e25114fc1897460d.js} +1 -1
- package/assets/esri/core/workers/chunks/96e483db7dd1f5dbb07a.js +1 -0
- package/assets/esri/core/workers/chunks/9789f178ece126c4006d.js +1 -0
- package/assets/esri/core/workers/chunks/9a0b9d931c1a29e81475.js +1 -0
- package/assets/esri/core/workers/chunks/{feed74ed275f21a68a1b.js → 9c5dcef2a75d4bb9b3d6.js} +1 -1
- package/assets/esri/core/workers/chunks/a7fcb60d5a9d2d9560e4.js +1 -0
- package/assets/esri/core/workers/chunks/aa84775399420e35c6a5.js +1 -0
- package/assets/esri/core/workers/chunks/{8b7f6f2d1692b6b6dbd5.js → ae6066ea6cb373dc6db3.js} +1 -1
- package/assets/esri/core/workers/chunks/ae8dce1a43ca7019f81d.js +1 -0
- package/assets/esri/core/workers/chunks/afb2770c4abbff9bab3d.js +1 -0
- package/assets/esri/core/workers/chunks/{a8a79a5c804ef715aa94.js → b4b26cc2ba3ff30e1d03.js} +1 -1
- package/assets/esri/core/workers/chunks/{8a5e40f48a8265fd1b42.js → b78ea9cc4d5f2fd3d871.js} +1 -1
- package/assets/esri/core/workers/chunks/{ce49ff6bf20cff349726.js → be8dd8e68c8805300ad1.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8d02f1b73c374767a5f.js → c78de6dd6c10280cee69.js} +1 -1
- package/assets/esri/core/workers/chunks/{92d0e0155563c6355079.js → c90571063bd2bb57a5a7.js} +1 -1
- package/assets/esri/core/workers/chunks/{930322c9790572bd0c49.js → d2fe403d6ab237bc89c2.js} +1 -1
- package/assets/esri/core/workers/chunks/d7adef4093ce19ad356d.js +1 -0
- package/assets/esri/core/workers/chunks/{b4ba7f8ea81522ad1e2e.js → da42cc4f6142846cb745.js} +1 -1
- package/assets/esri/core/workers/chunks/e080628ac6e1cf25dc72.js +1 -0
- package/assets/esri/core/workers/chunks/{8c94448a44fb27054a22.js → e760b8ca64d67c04d98a.js} +1 -1
- package/assets/esri/core/workers/chunks/edaf059c7ea18088c3dd.js +1 -0
- package/assets/esri/core/workers/chunks/{e7af5caab9aa9b6a12e3.js → ede479faa4e6920fe673.js} +3 -3
- package/assets/esri/core/workers/chunks/f9decc88561c03aca3c9.js +1 -0
- package/chunks/FocusAreaColor.glsl.js +5 -5
- package/config.js +1 -1
- package/core/NestedMap.js +1 -1
- package/interfaces.d.ts +57 -58
- package/intl/date.js +1 -1
- package/intl/number.js +1 -1
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/support/DateTimeFieldFormat.js +5 -0
- package/layers/support/FieldConfiguration.js +5 -0
- package/layers/support/FieldFormat.js +5 -0
- package/layers/support/NumberFieldFormat.js +5 -0
- package/layers/support/fieldConfigUtils.js +5 -0
- package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
- package/package.json +5 -5
- package/rest/print.js +1 -1
- package/rest/support/AttributeBinsQuery.js +1 -1
- package/rest/support/Query.js +1 -1
- package/rest/support/QueryMixin.d.ts +2 -2
- package/rest/support/QueryMixin.js +5 -0
- package/rest/support/TopFeaturesQuery.js +1 -1
- package/support/arcadeExpressionUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BaseRasterProcessorTechnique.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/support/GaussianSplatWorkerHandle.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColor.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryBaseInstance.js +5 -0
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBaseInstanceData.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/25118304c9a914194e90.js +0 -1
- package/assets/esri/core/workers/chunks/3d6f07e04f77cc0a7506.js +0 -1
- package/assets/esri/core/workers/chunks/4f22e5a7f81883e8e5b6.js +0 -1
- package/assets/esri/core/workers/chunks/5102c20645d9708c34b4.js +0 -1
- package/assets/esri/core/workers/chunks/79e965e8f7cf822b4f45.js +0 -1
- package/assets/esri/core/workers/chunks/7b1fc59822ac2d421a5a.js +0 -1
- package/assets/esri/core/workers/chunks/83589cfcc443b925c1aa.js +0 -1
- package/assets/esri/core/workers/chunks/8f02349602b072186a1f.js +0 -1
- package/assets/esri/core/workers/chunks/9835c579edfc08125d31.js +0 -1
- package/assets/esri/core/workers/chunks/a7e649b3b02e664ada80.js +0 -1
- package/assets/esri/core/workers/chunks/adc61d88c3c6936ad75a.js +0 -1
- package/assets/esri/core/workers/chunks/ae7b86bd08a44e26b339.js +0 -1
- package/assets/esri/core/workers/chunks/bbb3b32affde9ea78534.js +0 -1
- package/assets/esri/core/workers/chunks/c35dad3d5ceaac6ad5a4.js +0 -1
- package/assets/esri/core/workers/chunks/c4b2678dd46fa1e22f7e.js +0 -1
- package/assets/esri/core/workers/chunks/cafc19bf2caaf7a8c2e8.js +0 -1
- package/assets/esri/core/workers/chunks/d2b69f91eb85b561fe01.js +0 -1
- package/assets/esri/core/workers/chunks/f6107f844f4feed42828.js +0 -1
- package/assets/esri/core/workers/chunks/fac020b6886ff2d75015.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as s,filterInPlace as n}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as i}from"../../../../../core/uid.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{assert as d}from"../../lib/Util.js";import{BufferRange as u,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as h}from"./Instance.js";import{PerBaseInstanceData as m}from"./PerBaseInstanceData.js";import{PerBufferData as p,getTargetBuffer as g,hasVao as y}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";import{VaoWriter as _}from"./VaoWriter.js";let B=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new _(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const n of this.dataByBaseInstance.values())for(const r of n.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const n=r.buffers[t];n.holes.length<=1?++t:(n.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(n),s(r.buffers,n,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=n;r.buffers.forEach(t=>this._applyAdds(e,t,o));const s=g(null!=e);for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(s),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const s of t.dataByOrigin.values())for(const t of s.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const n=this._vaoWriter;if(null!=n)for(const r of e.updates){if(t.done)return;const{renderGeometry:o,updateType:a}=r;s(e.pending.updates,r),t.madeProgress();const l=this.dataByBaseInstance.get(o.geometry.baseGeometry?.id??i),c=l?.dataByOrigin.get(o.localOrigin.id)?.findBuffer(o.id);if(null==c)return;const d=c.instances.get(o.id);6&a&&n.updateInstance(d,c),25&a&&(c.drawCommandsDirty=!0)}else e.clearUpdates()}_computeDeltas(e,t){const s=new Map;for(const n of e){const e=n.localOrigin;if(null==e)continue;const t=n.geometry.baseGeometry,o=r(s,t??null,O);let a=o.get(e,null);null==a&&(a=new b(e.vec3,t),o.set(e,null,a)),a.changes.push(n)}for(const n of t){const e=n.localOrigin;if(null==e)continue;const t=n.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??i),a=o?.dataByOrigin.get(e.id)?.findBuffer(n.id);if(null==a)continue;const l=r(s,t??null,O);let c=l.get(e,a);null==c&&(c=new b(e.vec3,t),l.set(e,a,c)),c.changes.push(n)}return s}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:n}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,l]of o){const e=r(n,a?.id??i,()=>new m(t.createBaseInstanceData(a))),o=null!=a;for(const[n,a]of l.outerMap()){const i=a.get(null),c=i?.changes??[];l.delete(n,null);const u=r(e.dataByOrigin,n.id,()=>new v(n.vec3,o));for(const[r,o]of a){if(l.delete(n,r),null==r&&d(!1,"No VAO for removed geometries"),r.instances.size===o.changes.length){t.deleteBuffer(r),s(u.buffers,r),0===u.buffers.length&&0===c.length&&e.dataByOrigin.delete(n.id);continue}const a=r.numElements;switch(t.evaluateBufferAllocation(a,c,o.changes,r)){case 0:o.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>c.push(e)),t.deleteBuffer(r),s(u.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,c,o);break;case 2:this._applyRemoves(r,o)}}if(c.length>0){const{baseInstanceData:t}=e,s=g(o);for(const e of u.buffers)this._applyAdds(t,e,c);for(;c.length>0;)u.buffers.push(this._applyAndRebuild(t,new p(s),c,null))}}0===e.dataByOrigin.size&&(e.dispose(),n.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,s,n){if(n)for(const c of n.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements(t.targetBuffer);let a=t.numElements;for(;s.length>0;){const e=s.pop(),n=r.elementCount(e.geometry);if(a+n>o&&a>0){s.push(e);break}a+=n;const i=new h(e,0,0,this.highlightOrderMap);d(null==t.instances.get(e.id)),t.addInstance(e.id,i)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,a),t.vaoEndElement=r.endElement(t);const i=r.rebuildInstances(a,t.writeableInstances.values(),t);t.updateInstances(),t.holes.clear();const l=t.holes.pushNew();return l.from=i,l.to=t.vaoEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:s}=this;if(0===t.changes.length||null==s)return;let n=1/0,r=-1/0;for(const o of t.changes){const t=o.id,s=e.instances.get(t);if(!s)continue;e.deleteInstance(t),this._useMetalWorkaround&&(n=Math.min(n,s.from),r=Math.max(r,s.to));const a=I.back();if(a){if(a.to===s.from){a.to=s.to;continue}if(a.from===s.to){a.from=s.from;continue}}const i=I.pushNew();i.from=s.from,i.to=s.to}f(I),this._useMetalWorkaround?s.clearHolesMetal(e.instances.values(),n,r,e):s.clearHoles(I,e),e.holes.pushArray(I.data,I.length),I.forAll((e,t)=>I.data[t]=null),I.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,s){if(0===s.length||null==this._vaoWriter)return;if(!y(t))return void this._applyAndRebuild(e,t,s,null);const r=this._vaoWriter,o=t.numElements,a=s.reduce((e,{geometry:t})=>e+r.elementCount(t),0),i=Math.min(o+a,r.maxElements(t.targetBuffer));if(r.canGrow(t,i))return void this._applyAndRebuild(e,t,s,null);f(t.holes);const l=new Array;let c=1/0,d=-1/0;for(const{geometry:n}of s){const e=r.elementCount(n),s=w(t.holes,e);l.push(s),this._useMetalWorkaround&&null!=s&&(c=Math.min(s,c),d=Math.max(s+e,d))}const u=this._addInstances(s,t,l);if(this._useMetalWorkaround){for(const e of u);r.writeInstanceRangeMetal(d,c,t.instances.values(),t)}else r.writeRandomInstances(i,u,t);n(s,(e,t)=>null==l[t])}*_addInstances(e,t,s){const n=e.length,r=this._vaoWriter;for(let o=0;o<n;++o){const n=s[o];if(null==n)continue;const a=e[o],i=r.elementCount(a.geometry),l=new h(a,n,n+i,this.highlightOrderMap);d(null==t.instances.get(a.id)),t.addInstance(a.id,l),t.drawCommandsDirty=!0,yield l}}static prune(){_.prune()}};e([l({constructOnly:!0})],B.prototype,"dataByBaseInstance",void 0),e([l({constructOnly:!0})],B.prototype,"material",void 0),e([l()],B.prototype,"highlightOrderMap",void 0),B=e([c("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],B);class b{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function w(e,t){const s=e.find(e=>e.numElements>=t);if(null==s)return null;const n=s.from;return s.from+=t,s.from>=s.to&&e.removeUnordered(s),n}const I=new a({allocator:e=>e||new u,deallocator:null});function O(){return new o}export{B as MergedBuffer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SyncRenderPlugin as
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SyncRenderPlugin as s}from"../../effects/RenderPlugin.js";import{MergedBuffer as i}from"./MergedBuffer.js";import{VaoRenderer as a}from"./VaoRenderer.js";let n=class extends s{constructor(e){super(e),this._dataByBaseInstance=new Map,this._buffer=null,this._renderer=null,this.drapedPriority=0}initialize(){this._buffer=new i({material:this.material,dataByBaseInstance:this._dataByBaseInstance,highlightOrderMap:this.highlightOrderMap}),this._renderer=new a({material:this.material,dataByBaseInstance:this._dataByBaseInstance})}destroy(){for(const e of this._dataByBaseInstance.values())e.dispose();this._dataByBaseInstance.clear(),this._buffer.destroy(),this._renderer.destroy()}hasHighlight(e){return this._renderer.hasHighlight(e)}initializeRenderContext(e){this._buffer.initializeRenderContext(e),this._renderer.initializeRenderContext(e)}uninitializeRenderContext(){this._buffer.uninitializeRenderContext(),this._renderer.uninitializeRenderContext()}get produces(){return this._renderer.produces}get hasOccludees(){return this._buffer.hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmitters(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;for(const r of this._dataByBaseInstance.values())for(const t of r.dataByOrigin.values())e+=t.buffers.reduce((e,r)=>e+r.instances.size,0);return e}get usedMemory(){let e=0;for(const r of this._dataByBaseInstance.values())for(const t of r.dataByOrigin.values())e+=t.buffers.reduce((e,r)=>e+r.vao.usedMemory,0);return e}forEachGeometry(e){for(const r of this._dataByBaseInstance.values())for(const t of r.dataByOrigin.values())for(const r of t.buffers)for(const{geometry:t}of r.instances.values())e(t)}modify(e,r){this._buffer.modify(e,r),this._renderer.updateHighlights()}get canCompact(){return this._buffer.canCompact}compact(e){return this._buffer.compact(e)}updateHighlights(e){this.highlightOrderMap=e,this._buffer.updateHighlights(e),this._renderer.updateHighlights()}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){return this._renderer.acquireTechniques(e)}render(e,r){return this._renderer.render(e,r)}static prune(){i.prune()}get test(){}};e([r({constructOnly:!0})],n.prototype,"material",void 0),e([r()],n.prototype,"highlightOrderMap",void 0),n=e([t("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],n);export{n as MergedRenderer};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{nullUid as s}from"../../../../../core/uid.js";class a{constructor(s){this.baseInstanceData=s,this.dataByOrigin=new Map}get id(){return this.baseInstanceData?.baseInstance.id??s}dispose(){for(const s of this.dataByOrigin.values())s.dispose();this.dataByOrigin.clear(),this.baseInstanceData?.dispose()}}class t{constructor(s,a,t){this.baseInstance=s,this.baseInstanceBuffer=a,this.baseCommand=t}dispose(){this.baseInstanceBuffer.dispose()}}export{t as BaseInstanceData,a as PerBaseInstanceData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import s from"../../../../../core/PooledArray.js";import{BufferRange as e}from"./BufferRange.js";import{DrawCommand as i}from"./DrawCommand.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";class a{constructor(){this.vaoEndElement=0,this._numElements=0,this._instances=new Map,this.holes=new s({allocator:t=>t||new e,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=
|
|
5
|
+
import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import s from"../../../../../core/PooledArray.js";import{BufferRange as e}from"./BufferRange.js";import{DrawCommand as i}from"./DrawCommand.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";class a{constructor(t){this.targetBuffer=t,this.vaoEndElement=0,this._numElements=0,this._instances=new Map,this.holes=new s({allocator:t=>t||new e,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=m(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=m(),this.drawCommandsShadowHighlightRest=m()}get numElements(){return this._numElements}get instances(){return this._instances}get writeableInstances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t)}}addInstance(t,s){this.deleteInstance(t),this._instances.set(t,s),this._numElements+=s.numElements}deleteInstance(t){const s=this._instances.get(t);s&&(this._numElements-=s.numElements,this._instances.delete(t))}updateInstances(){let t=0;for(const s of this._instances.values())t+=s.numElements,this.updateDrawState(s);this._numElements=t}updateDrawState(t){if(t.isVisible){const{highlightName:s}=t;s&&this.highlightNames.add(s),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:s}=this;if(this._updateHighlightDrawCommands(t,s),!this.needsMultipleCommands){const t=this.drawCommandsDefault.pushNew(),s=this.holes.front();return this.vao&&1===this.holes.length&&s.to===this.vaoEndElement?(t.first=0,void(t.count=s.from)):(t.first=1/0,t.count=0,this._instances.forEach(s=>{t.first=Math.min(t.first,s.from),t.count=Math.max(t.count,s.to)}),void(t.count-=t.first))}for(const e of s)e.isVisible&&l(e.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,e)}get sortedInstances(){return Array.from(this._instances.values()).sort((t,s)=>t.from===s.from?t.to-s.to:t.from-s.from)}updateHighlights(t){this.highlightNames.clear();const s=this.sortedInstances;for(const e of s)e.updateHighlightOptions(t),e.isVisible&&e.highlightName&&this.highlightNames.add(e.highlightName);this._updateHighlightDrawCommands(t)}_updateHighlightDrawCommands(s,e=this.sortedInstances){const{drawCommandsHighlights:i,drawCommandsShadowHighlightRest:a}=this;i.clear(),a.clear();for(const h of e){if(h.updateHighlightOptions(s),!h.isVisible)continue;const{highlightName:e}=h;if(e){this.highlightNames.add(e);l(t(i,e,m),h)}e&&e===n||l(a,h)}}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}class h extends a{}function o(t){return null!=t.vao}function r(t){return t?"instances":"geometry"}function m(){return new s({allocator:t=>t||new i,deallocator:t=>t})}function l(t,s){const e=t.back();if(null==e){const e=t.pushNew();return e.first=s.from,void(e.count=s.numElements)}if(c(e,s)){const t=s.from-e.first+s.numElements;e.count=t}else{const e=t.pushNew();e.first=s.from,e.count=s.numElements}}function c(t,s){return t.first+t.count>=s.from}export{a as PerBufferData,h as PerVaoData,r as getTargetBuffer,o as hasVao};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class s{constructor(s){this.origin=s,this.buffers=new Array}dispose(){this.buffers.
|
|
5
|
+
class s{constructor(s,e){this.origin=s,this.isInstanced=e,this.buffers=new Array}dispose(){if(this.isInstanced)for(const s of this.buffers)s.vao.buffer("instances")?.dispose(),s.vao.disposeVAOOnly();else for(const s of this.buffers)s.vao.dispose();this.buffers.length=0}findBuffer(s){return this.buffers.find(e=>e.instances.has(s))}}export{s as PerOriginData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import
|
|
5
|
+
import{__decorate as t}from"tslib";import s from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{GLMaterials as a}from"../../lib/GLMaterials.js";import{DrawParameters as o}from"../DrawParameters.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";import{bindVertexBufferLayout as l}from"../../../../webgl/Util.js";let h=class extends s{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,s)=>{this._produces.set(s,s=>!(0===this.dataByBaseInstance.size||!(9!==s&&5!==s||this._hasHighlights))&&t(s))})}initializeRenderContext(t){this._glMaterials=new a(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=e(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:s,bind:e}=t,i=this.material.produces.get(e.slot);if(!i?.(s))return null;const{highlight:r,slot:a}=e,o=5===s,l=9===s,h=l||o,d=r?.name;if(h&&(0===this._highlightNames.size||l&&d&&!this._highlightNames.has(d)))return null;const c=t=>l&&!!d&&!t.has(d),g=6===s,m=!(h||g);for(const u of this.dataByBaseInstance.values())for(const i of u.dataByOrigin.values())for(const r of i.buffers){if(c(r.highlightNames))continue;const i=o?r.drawCommandsHighlights.get(n):h?d?r.drawCommandsHighlights.get(d):r.drawCommandsHighlights.size>0:((g&&r.needsMultipleCommands?r.drawCommandsShadowHighlightRest:r.drawCommandsDefault)||null)?.length??!1,l=m&&r.drawCommandsOccludees||null;if(i||l?.length){const i=this._glMaterials.load(t.rctx,a,s),r=i?.beginSlot(e);if(r)return r}}return null}render(t,s){const{output:e,bind:i}=t,{slot:r,highlight:a}=i,o=9===e,l=a?.name??"";if(o&&!a)return;const h=5===e,g=o||h,m=6===e,u=!(g||m),f=10===r||11===r?r:null,{rctx:p}=t;p.runAppleAmdDriverHelper();const w=p.bindTechnique(s,i,this.material.parameters);for(const _ of this.dataByBaseInstance.values()){const{baseInstanceData:t}=_,e=null==t?d:c;for(const r of _.dataByOrigin.values())for(const a of r.buffers){if(o&&(!a.hasHighlights||!a.drawCommandsHighlights.has(l)))continue;if(h&&(!a.hasHighlights||!a.drawCommandsHighlights.has(n)))continue;const d=g&&!h?a.drawCommandsHighlights.get(l)??null:null,c=h?a.drawCommandsHighlights.get(n):g?d:m&&a.needsMultipleCommands?a.drawCommandsShadowHighlightRest:a.drawCommandsDefault,_=u&&a.drawCommandsOccludees||null;if(c?.length||_?.length){const{vao:o}=a;this._drawParameters.origin=r.origin,w.bindDraw(i,this.material.parameters,this._drawParameters),s.ensureAttributeLocations(o),p.bindVAO(o),e(p,s,t,o,c,f,!1),e(p,s,t,o,_,f,!0)}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const s of this.dataByBaseInstance.values())for(const e of s.dataByOrigin.values())for(const s of e.buffers)for(const e of s.highlightNames)t.add(e);this._updateProduces()}get test(){}};t([i({constructOnly:!0})],h.prototype,"material",void 0),t([i({constructOnly:!0})],h.prototype,"dataByBaseInstance",void 0),h=t([r("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],h);const d=(t,s,e,i,r,a,o)=>{if(r?.length){t.setPipelineState(s.getPipeline(o,a));for(const e of r)t.drawArrays(s.primitiveType,e.first,e.count)}},c=(t,s,e,i,r,a,o)=>{if(!r?.length)return;const n=e.baseCommand;t.setPipelineState(s.getPipeline(o,a));for(const h of r)l(t,i.locations,i.buffer("instances"),h.first),t.drawArraysInstanced(s.primitiveType,n.first,n.count,h.count)};export{h as VaoRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{copy as e,invert as r,transpose as
|
|
5
|
+
import{nextHighestPowerOfTwo as t}from"../../../../../core/mathUtils.js";import{copy as e,invert as r,transpose as a}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as s}from"../../../support/buffer/glUtil.js";import{assert as n}from"../../lib/Util.js";import{VertexArrayObject as i}from"../../lib/VertexArrayObject.js";import{DrawCommand as f}from"./DrawCommand.js";import{BaseInstanceData as u}from"./PerBaseInstanceData.js";import{VertexBuffer as c}from"../../../../webgl/VertexBuffer.js";class l{constructor(t,e){this._rctx=e,this._bufferWriter=t.createBufferWriter(),this._vaoCache=e.getVaoCache(s(this._bufferWriter.layout))}maxElements(t){return Math.floor(d/this._targetStrideFloats(t))}_targetStrideFloats(t){return this._targetStrideBytes(t)/4}_targetStrideBytes(t){return this._targetLayout(t)?.stride??0}_targetLayout(t){return"geometry"===t?this._bufferWriter.layout:this._bufferWriter.instanceLayout}endElement(t){return Math.floor((t.vao?.getByteLength(t.targetBuffer)??0)/this._targetStrideBytes(t.targetBuffer))}evaluateBufferAllocation(t,e,r,a){const o=this._targetStrideFloats(a.targetBuffer),s=e.reduce((t,{geometry:e})=>t+this.elementCount(e),0),n=r.reduce((t,{geometry:e})=>t+this.elementCount(e),0),i=Math.min((t+s-n)*o,d),f=a.vao?.buffer(a.targetBuffer),u=(f?.sizeBytes??0)/4;return i>h&&i<u/2?0:i>u?1:2}deleteBuffer(t){if("instances"===t.targetBuffer)return t.vao?.buffer("instances")?.dispose(),t.vao?.disposeVAOOnly(),void(t.vao=null);this._vaoCache.deleteVao(t.vao)}createBaseInstanceData(t){const{_bufferWriter:e}=this;if(null==t||null==e.writeBaseInstance)return null;const r=e.layout,a=e.elementCount(t.attributes),o=a*this._targetStrideFloats("geometry"),n=new c(this._rctx,s(r));n.setSize(S(o));const i=w(o),l=r.createView(i.buffer);e.writeBaseInstance(t.attributes,l),n.setSubData(i,0,0,o);const m=new f;return m.first=0,m.count=a,new u(t,n,m)}_allocateInstanceBuffer(t){const e=this._bufferWriter.instanceLayout;n(null!=e,"Trying to allocate an instance buffer, but the BufferWriter does not support instancing");const r=t*this._targetStrideFloats("instances"),a=new c(this._rctx,s(e,1));return a.setSize(S(r)),a}_createInstancedVao(t,e){return new i(this._rctx,new Map([["geometry",t],["instances",e]]))}reallocateBuffer(t,e,r){if(this.deleteBuffer(e),null!=t){const e=t.baseInstanceBuffer,a=this._allocateInstanceBuffer(r);return this._createInstancedVao(e,a)}const a=r*this._targetStrideFloats("geometry");return this._vaoCache.newVao(S(a))}elementCount(t){return this._bufferWriter.elementCount(t.attributes)}canGrow(t,e){const{targetBuffer:r,vao:a}=t;if(null==a)return!0;const o=4*(e*this._targetStrideFloats(r));return a.getByteLength(r)<S(d-h)&&o>a.getByteLength(r)}clearHoles(t,{vao:e,targetBuffer:r}){const a=this._targetStrideFloats(r),o=t.reduce((t,e)=>Math.max(t,e.numElements),0)*a,s=w(o);s.fill(0,0,o);const n=e.buffer(r);for(const i of t)n?.setSubData(s,i.from*a,0,i.numElements*a)}clearHolesMetal(t,e,r,{vao:a,targetBuffer:o}){const s=this._targetStrideFloats(o),n=(r-e)*s,i=w(n),f=this._targetLayout(o).createView(i.buffer);i.fill(0,0,n);for(const u of t){if(!(u.from>=e&&u.to<=r))continue;const t=u.from-e;this._writeGeometry(u.geometry,f,t)}a.buffer(o)?.setSubData(i,e*s,0,n)}writeRandomInstances(t,e,{vao:r,targetBuffer:a}){const o=this._targetStrideFloats(a),s=w(t*o),n=this._targetLayout(a).createView(s.buffer);let i=0,f=0,u=0;const c=r.buffer(a);for(const m of e){if(!(u===m.from)){const t=u-f;t>0&&c?.setSubData(s,f*o,0,t*o),f=m.from,i=0}this._writeGeometry(m.geometry,n,i),i+=m.numElements,u=m.to}const l=u-f;l>0&&c?.setSubData(s,f*o,0,l*o)}writeInstanceRangeMetal(t,e,r,{vao:a,targetBuffer:o}){const s=this._targetStrideFloats(o),n=t-e,i=n*s,f=w(i),u=this._targetLayout(o).createView(f.buffer);f.fill(0,0,i);for(const c of r){if(!(c.from>=e&&c.to<=t))continue;const r=c.from-e;this._writeGeometry(c.geometry,u,r)}n>0&&a.buffer(o)?.setSubData(f,e*s,0,i)}rebuildInstances(t,e,{vao:r,targetBuffer:a}){const o=this._targetStrideFloats(a),s=w(t*o),n=this._targetLayout(a).createView(s.buffer);let i=0;for(const f of e){this._writeGeometry(f.geometry,n,i);const t=i;i+=this.elementCount(f.geometry.geometry),f.from=t,f.to=i}return r?.buffer(a)?.setSubData(s,0,0,i*o),i}updateInstance(t,{vao:e,targetBuffer:r}){const{_bufferWriter:a}=this,o=this._targetStrideFloats(r),s=w(a.elementCount(t.geometry.geometry.attributes)*o),n=this._targetLayout(r).createView(s.buffer);this._writeGeometry(t.geometry,n,0),e.buffer(r)?.setSubData(s,t.from*o,0,t.numElements*o)}_writeGeometry(t,o,s){const{_bufferWriter:n}=this;null!=n&&(e(m,t.transformation),m[12]-=t.localOrigin.vec3[0],m[13]-=t.localOrigin.vec3[1],m[14]-=t.localOrigin.vec3[2],r(g,m),a(g,g),n.write(m,g,t.geometry.attributes,t.geometry.olidColor,o,s))}static prune(){B=new Float32Array(h)}}const m=o(),g=o(),h=65536,_=4*h,y=1024,b=16777216,d=b/4;let B=new Float32Array(h);function w(t){return B.length<t&&(B=new Float32Array(t)),B}function S(e){const r=4*e;return r<=y?y:r<_?t(r):Math.max(Math.min(Math.ceil(1.5*r/_)*_,b),r)}export{l as VaoWriter};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s}from"../../../core/sanitizerUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{css as a}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as c}from"../support/tableUtils.js";import{autoLink as d}from"../../support/uriUtils.js";import{setFocus as p}from"../../support/widgetUtils.js";let u=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=s.sanitize(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t;return n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0})}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:d(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return c(e)?null:s.sanitize(e)}get effectiveLabel(){return s.sanitize(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?s.sanitize(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.overlayPositioning="fixed",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(a.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:c}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(a.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!c,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(a.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:a.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:a.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,p(this.menuItems[0]))}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([r()],u.prototype,"_headerRequiresTextContainer",null),e([r()],u.prototype,"_menuIsOpen",void 0),e([r()],u.prototype,"autoWidth",void 0),e([r()],u.prototype,"cellValueFormatFunction",void 0),e([r()],u.prototype,"customMenuItems",null),e([r()],u.prototype,"defaultMenuItems",null),e([r()],u.prototype,"description",void 0),e([r()],u.prototype,"direction",void 0),e([r()],u.prototype,"effectiveDescription",null),e([r()],u.prototype,"effectiveLabel",null),e([r()],u.prototype,"effectiveSortable",null),e([r({constructOnly:!0})],u.prototype,"fieldName",void 0),e([r()],u.prototype,"flexGrow",void 0),e([r()],u.prototype,"footerRenderFunction",void 0),e([r()],u.prototype,"formatFunction",void 0),e([r()],u.prototype,"frozen",void 0),e([r()],u.prototype,"frozenToEnd",void 0),e([r()],u.prototype,"grid",void 0),e([r()],u.prototype,"iconNode",null),e([r()],u.prototype,"invalid",null),e([r()],u.prototype,"headerRenderFunction",void 0),e([r()],u.prototype,"hidden",void 0),e([r()],u.prototype,"icon",void 0),e([r()],u.prototype,"iconText",void 0),e([r({constructOnly:!0})],u.prototype,"initialSortPriority",void 0),e([r()],u.prototype,"label",void 0),e([r()],u.prototype,"labelTooltipText",void 0),e([r()],u.prototype,"menu",null),e([r()],u.prototype,"menuItems",null),e([r()],u.prototype,"menuConfig",void 0),e([r()],u.prototype,"menuIsOpen",null),e([r()],u.prototype,"menuIsVisible",null),e([r()],u.prototype,"messages",void 0),e([r()],u.prototype,"messagesCommon",void 0),e([r()],u.prototype,"messagesURIUtils",void 0),e([r()],u.prototype,"renderFunction",void 0),e([r()],u.prototype,"resizable",void 0),e([r()],u.prototype,"sortable",void 0),e([r({readOnly:!0})],u.prototype,"sortElement",void 0),e([r()],u.prototype,"store",void 0),e([r()],u.prototype,"tableTimeZone",void 0),e([r()],u.prototype,"textAlign",void 0),e([r()],u.prototype,"textWrap",void 0),e([r()],u.prototype,"timeZone",void 0),e([r()],u.prototype,"visibleElements",void 0),e([r()],u.prototype,"width",void 0),u=e([l("esri.widgets.FeatureTable.Grid.Column")],u);const m=u;export{m as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{watch as i,when as n,initial as o}from"../../../core/reactiveUtils.js";import{renderingSanitizer as s}from"../../../core/sanitizerUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{css as a}from"./ColumnCSS.js";import{isEmptyStringOrWhitespace as c}from"../support/tableUtils.js";import{autoLink as d}from"../../support/uriUtils.js";import{setFocus as p}from"../../support/widgetUtils.js";let u=class extends t{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this,o=s.sanitize(i);if(n&&t){const{index:i,item:{attachments:s,feature:r,relatedRecords:l}}=t;return n({attachments:s,column:this,feature:r,index:i,relatedRecords:l,value:o,virtualIndex:this.getVirtualRowIndex(e),field:void 0})}return o},this.description=null,this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,i=this.createHeaderContent();this.removeCellContent(t),t.appendChild(i)},this.hidden=!1,this.icon=null,this.iconText=null,this.initialSortPriority=null,this.label=null,this.labelTooltipText=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,rowData:t})=>{const i=this.getCellValue(t),n=this.cellValueFormatFunction({root:e,rowData:t,value:i});let o=null;if(o=n instanceof HTMLElement?n:d(this.messagesURIUtils,n),this.removeCellContent(e),o instanceof HTMLElement)e.removeAttribute("title"),e.appendChild(o);else if(null!=o){const t=o.toString();e.innerHTML=t,e.title=t}},this.resizable=!0,this.sortable=!1,this.store=null,this.tableTimeZone=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([i(()=>this.direction,e=>{const{sortElement:t}=this;this.effectiveSortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))}),n(()=>this.grid?.isReady&&this.sortElement,()=>{const{direction:e,grid:t,hidden:i,sortElement:n}=this;i&&e&&n&&t&&!t.hasSorter(n)&&t.addSorter(n)},o),i(()=>[this.timeZone,this.icon,this.iconText,this.labelTooltipText],()=>this.grid?.requestContentUpdate()),i(()=>this.hidden,()=>this.closeMenu()),i(()=>this.fieldName,e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)}),i(()=>[this.effectiveLabel,this.labelTooltipText],([e,t])=>{const{sortElement:i}=this;i&&(i.setAttribute("title",t||e),i.textContent=e)})])}get _headerRequiresTextContainer(){return!(!this.effectiveSortable&&""===this.effectiveLabel&&null==this.effectiveDescription)}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:i,iconClass:n,label:o,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:i,selected:s,textContent:o,onclick:e=>r(e)}))??[]}get defaultMenuItems(){if(!this.effectiveSortable)return[];const e=this.messages,t=[],i=this.visibleElements?.columnMenuItems;if(!1!==i?.sortAscending){const i=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(i)}if(!1!==i?.sortDescending){const i=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(i)}return t}get effectiveDescription(){const{description:e}=this;return c(e)?null:s.sanitize(e)}get effectiveLabel(){return s.sanitize(this.label||this.fieldName)}get effectiveSortable(){return this.sortable}get iconNode(){const{icon:e,iconText:t}=this,i=t?s.sanitize(t):void 0;return e?this.createCalciteIcon({icon:e,textLabel:i}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get invalid(){return this._get("invalid")??!1}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:i}=this,n=!!i?.open,o=this.createCalciteAction({icon:i?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=i?.maxItems??4,s.placement="top-end",s.scale=i?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(o),s.addEventListener("calciteDropdownOpen",()=>this._menuIsOpen=!0),s.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",e=>{e.stopPropagation()}),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=i?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:i,initialSortPriority:n}=this,o=document.createElement("vaadin-grid-sorter");return o.classList.add(a.sorter),o.setAttribute("path",i),o.setAttribute("title",this.labelTooltipText||e),o.textContent=e,t&&o.setAttribute("direction",t),null!=n&&(o._initialOrder=n),o.addEventListener("direction-changed",()=>{this.direction!==o.direction&&this._set("direction",o.direction)}),o}createCalciteAction(e){const t=document.createElement("calcite-action"),{alignment:i,appearance:n,className:o,disabled:s,icon:r,label:l,scale:a,slot:c,text:d,textEnabled:p,onclick:u}=e;return t.alignment=i??"center",t.appearance=n??"transparent",t.className=o??"",t.disabled=!!s,t.icon=r??"",t.label=l??"",t.scale=a??"s",t.slot=c??"",t.text=t.title=d??"",t.textEnabled=!!p,t.onclick=u??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{alignment:i,appearance:n,className:o,disabled:s,iconEnd:r,iconFlipRtl:l,kind:a,loading:c,onclick:d,scale:p,textContent:u,title:m,width:h}=e;return t.alignment=i??"center",t.className=o??"",t.scale=p??"s",t.appearance=n??"transparent",t.disabled=!!s,t.iconEnd=r??"",l&&(t.iconFlipRtl=l),t.kind=a??"brand",t.loading=!!c,t.textContent=u??"",m&&(t.title=m),t.width=h??"auto",t.onclick=d??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:i,hidden:n,iconClass:o,iconStart:s,textContent:r,onclick:l,selected:c}=e,d=r??"";if(o&&!s){const e=document.createElement("span"),i=document.createElement("span");i.classList.add(a.headerMenuIcon,o),e.textContent=e.title=d,e.insertBefore(i,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!i,t.hidden="function"==typeof n?n():!!n,t.selected=!!c,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:i,scale:n,textLabel:o}=e,s=document.createElement("calcite-icon"),r=o??t;return s.icon=i,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveDescription:e,effectiveLabel:t,iconNode:i}=this,n=document.createElement("div");if(n.classList.add(a.headerContent),i&&n.appendChild(i),!this._headerRequiresTextContainer)return n;const o=n.appendChild(document.createElement("div"));return this.effectiveSortable?o.appendChild(this.sortElement):""!==t&&o.appendChild(this._createHeaderTextElement({label:t,cssClass:a.headerLabel,title:this.labelTooltipText})),null!=e&&!1!==this.visibleElements?.columnDescriptions&&o.appendChild(this._createHeaderTextElement({label:e,cssClass:a.headerDescription})),this.menuIsVisible&&n.appendChild(this.menu),n}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}getVirtualRowIndex(e){const t=this.grid?.getRowContainingNode(e);return t?.parentElement?[...t.parentElement.children].indexOf(t):-1}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,p(this.menuItems[0]))}sort(){this.effectiveSortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}_createHeaderTextElement({cssClass:e,label:t,title:i}){const n=document.createElement("span");n.classList.add(e);const o=n.appendChild(document.createElement("span"));return o.textContent=t,o.setAttribute("title",i||t),n}};e([r()],u.prototype,"_headerRequiresTextContainer",null),e([r()],u.prototype,"_menuIsOpen",void 0),e([r()],u.prototype,"autoWidth",void 0),e([r()],u.prototype,"cellValueFormatFunction",void 0),e([r()],u.prototype,"customMenuItems",null),e([r()],u.prototype,"defaultMenuItems",null),e([r()],u.prototype,"description",void 0),e([r()],u.prototype,"direction",void 0),e([r()],u.prototype,"effectiveDescription",null),e([r()],u.prototype,"effectiveLabel",null),e([r()],u.prototype,"effectiveSortable",null),e([r({constructOnly:!0})],u.prototype,"fieldName",void 0),e([r()],u.prototype,"flexGrow",void 0),e([r()],u.prototype,"footerRenderFunction",void 0),e([r()],u.prototype,"formatFunction",void 0),e([r()],u.prototype,"frozen",void 0),e([r()],u.prototype,"frozenToEnd",void 0),e([r()],u.prototype,"grid",void 0),e([r()],u.prototype,"iconNode",null),e([r()],u.prototype,"invalid",null),e([r()],u.prototype,"headerRenderFunction",void 0),e([r()],u.prototype,"hidden",void 0),e([r()],u.prototype,"icon",void 0),e([r()],u.prototype,"iconText",void 0),e([r({constructOnly:!0})],u.prototype,"initialSortPriority",void 0),e([r()],u.prototype,"label",void 0),e([r()],u.prototype,"labelTooltipText",void 0),e([r()],u.prototype,"menu",null),e([r()],u.prototype,"menuItems",null),e([r()],u.prototype,"menuConfig",void 0),e([r()],u.prototype,"menuIsOpen",null),e([r()],u.prototype,"menuIsVisible",null),e([r()],u.prototype,"messages",void 0),e([r()],u.prototype,"messagesCommon",void 0),e([r()],u.prototype,"messagesURIUtils",void 0),e([r()],u.prototype,"renderFunction",void 0),e([r()],u.prototype,"resizable",void 0),e([r()],u.prototype,"sortable",void 0),e([r({readOnly:!0})],u.prototype,"sortElement",void 0),e([r()],u.prototype,"store",void 0),e([r()],u.prototype,"tableTimeZone",void 0),e([r()],u.prototype,"textAlign",void 0),e([r()],u.prototype,"textWrap",void 0),e([r()],u.prototype,"timeZone",void 0),e([r()],u.prototype,"visibleElements",void 0),e([r()],u.prototype,"width",void 0),u=e([l("esri.widgets.FeatureTable.Grid.Column")],u);const m=u;export{m as default};
|
package/widgets/Legend.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{on as
|
|
5
|
+
import{__decorate as e}from"tslib";import{deprecateWidget as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{on as i,watch as r,initial as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import p from"./Legend/LegendViewModel.js";import c from"./Legend/styles/card/CardView.js";import y from"./Legend/styles/classic/ClassicView.js";import{globalCss as h}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";const u={base:"esri-legend"};let L=class extends d{constructor(e,i){super(e,i),this.headingLevel=3,this.messages=null,this.viewModel=new p,this.style=new y,t(s.getLogger(this),"Legend","arcgis-legend",{version:"4.34"})}initialize(){this.addHandles([i(()=>this.view,"resize",()=>this.scheduleRender()),i(()=>this.activeLayerInfos,"change",()=>this._refreshActiveLayerInfos(this.activeLayerInfos)),r(()=>this.headingLevel,e=>{const{style:t}=this;t&&(t.headingLevel=e)}),r(()=>this.style,(e,t)=>{t&&e!==t&&t.destroy(),e&&(e.activeLayerInfos=this.activeLayerInfos,"card"===e.type&&(e.view=this.view),e.headingLevel=this.headingLevel)},o)])}destroy(){this.style?.destroy()}get activeLayerInfos(){return this.viewModel.activeLayerInfos}set activeLayerInfos(e){this.viewModel.activeLayerInfos=e}get basemapLegendVisible(){return this.viewModel.basemapLegendVisible}set basemapLegendVisible(e){this.viewModel.basemapLegendVisible=e}get groundLegendVisible(){return this.viewModel.groundLegendVisible}set groundLegendVisible(e){this.viewModel.groundLegendVisible=e}get hideLayersNotInCurrentView(){return this.viewModel.hideLayersNotInCurrentView}set hideLayersNotInCurrentView(e){this.viewModel.hideLayersNotInCurrentView=e}get keepCacheOnDestroy(){return this.viewModel.keepCacheOnDestroy}set keepCacheOnDestroy(e){this.viewModel.keepCacheOnDestroy=e}get respectLayerDefinitionExpression(){return this.viewModel.respectLayerDefinitionExpression}set respectLayerDefinitionExpression(e){this.viewModel.respectLayerDefinitionExpression=e}get respectLayerVisibility(){return this.viewModel.respectLayerVisibility}set respectLayerVisibility(e){this.viewModel.respectLayerVisibility=e}get icon(){return"legend"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}set style(e){const t=this._get("style");e!==t&&t?.destroy(),this._set("style",e)}castStyle(e){if(e instanceof c||e instanceof y)return e;if("string"==typeof e)return"card"===e?new c:new y;if(e&&"string"==typeof e.type){const t={...e};return delete t.type,"card"===e.type?new c(t):new y(t)}return new y}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return v("div",{class:this.classes(u.base,h.widget,this.style instanceof y?h.panel:null)},this.style.render())}_refreshActiveLayerInfos(e){e.forEach(e=>{this.removeHandles(`version_${e.layer.uid}`),this._renderOnActiveLayerInfoChange(e)}),this.scheduleRender()}_renderOnActiveLayerInfoChange(e){const t=r(()=>e.version,()=>this.scheduleRender());this.addHandles(t,`version_${e.layer.uid}`);const s=i(()=>e.children,"change",()=>e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e)),o);this.addHandles(s,`version_${e.layer.uid}`),e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e))}};e([n()],L.prototype,"activeLayerInfos",null),e([n()],L.prototype,"basemapLegendVisible",null),e([n()],L.prototype,"groundLegendVisible",null),e([n()],L.prototype,"headingLevel",void 0),e([n()],L.prototype,"hideLayersNotInCurrentView",null),e([n()],L.prototype,"keepCacheOnDestroy",null),e([n()],L.prototype,"respectLayerDefinitionExpression",null),e([n()],L.prototype,"respectLayerVisibility",null),e([n()],L.prototype,"icon",null),e([n()],L.prototype,"label",null),e([n()],L.prototype,"layerInfos",null),e([n(),g("esri/widgets/Legend/t9n/Legend")],L.prototype,"messages",void 0),e([n()],L.prototype,"style",null),e([l("style")],L.prototype,"castStyle",null),e([n()],L.prototype,"view",null),e([n()],L.prototype,"viewModel",void 0),L=e([a("esri.widgets.Legend")],L);const f=L;export{f as default};
|
package/widgets/Popup.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{ignoreAbortErrors as i,after as o}from"../core/promiseUtils.js";import{watch as n,on as s,initial as r,whenOnce as l}from"../core/reactiveUtils.js";import{waitAnimationFrame as a}from"../core/scheduling.js";import{stripHTML as d}from"../core/string.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import u from"../support/actions/ActionButton.js";import p from"./Features.js";import g from"./Widget.js";import v from"./Features/FeaturesViewModel.js";import{css as m}from"./Popup/css.js";import f from"./Popup/PopupViewModel.js";import w from"./Popup/PopupVisibleElements.js";import{globalCss as b}from"./support/globalCss.js";import{isRTL as _}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as k}from"./support/decorators/vmEvent.js";import{tsx as y}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";const E=200,C={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let D=class extends g{constructor(e,t){super(e,t),this._dockAction=new u({id:"popup-dock-action"}),this._featuresWidget=new p({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this._focusAbortController=null,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.viewModel=new f,this.visibleElements=new w}initialize(){this.addHandles([n(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),r),n(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),r),n(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},r),n(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),n(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),n(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),n(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),n(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),n(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),n(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,r),n(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,r),n(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,r),n(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,r),n(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,r),n(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,r),n(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,r),n(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,r),n(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,r),n(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,r),n(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,r),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new v,this._featuresWidget.destroy()),this._focusAbortController?.abort()}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||C}set dockOptions(e){const t={...C},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._handleFocus()}next(){return this.viewModel.next()}open(e){const t=!!e&&!!e.featureMenuOpen,i={collapsed:!!e&&!!e.collapsed,featureMenuOpen:t};this.set(i),this.viewModel.open(e),e?.shouldFocus&&this._handleFocus(!0)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:n}=this.viewModel,s=o&&e,r=o&&!e,l=this.selectedFeature?.layer?.title,a=this.selectedFeature?.layer?.id,c={[m.alignTopCenter]:"top-center"===t,[m.alignBottomCenter]:"bottom-center"===t,[m.alignTopLeft]:"top-left"===t,[m.alignBottomLeft]:"bottom-left"===t,[m.alignTopRight]:"top-right"===t,[m.alignBottomRight]:"bottom-right"===t,[m.isDocked]:s,[m.shadow]:r,[m.isDockedTopLeft]:"top-left"===i,[m.isDockedTopCenter]:"top-center"===i,[m.isDockedTopRight]:"top-right"===i,[m.isDockedBottomLeft]:"bottom-left"===i,[m.isDockedBottomCenter]:"bottom-center"===i,[m.isDockedBottomRight]:"bottom-right"===i};return y("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":d(this.title??""),"aria-modal":"false",bind:this,class:this.classes(m.base,c,{[m.baseHidden]:!n&&!e}),"data-layer-id":a,"data-layer-title":l,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:y("div",{class:m.pointer,key:"popup-pointer",role:"presentation"},y("div",{class:this.classes(m.pointerDirection,m.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[m.shadow]:e};return y("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(m.main,b.widget,t)},this._featuresWidget.render())}_getAnimationDurationMS(){const{_containerNode:e}=this;return e?1e3*parseFloat(window.getComputedStyle(e).animationDuration):E}async _handleFocus(e=!1){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;e&&await l(()=>!0===this.viewModel?.active,{signal:t}),await i(a(t)),await i(o(this._getAnimationDurationMS(),t)),this._featuresWidget.focus()}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:h,width:u}=i.getBoundingClientRect(),p=u+t,g=Math.max(h,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return _(this.container)&&t.reverse(),e?.replace(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=_(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const n=this._calculateFullWidth(t),s=this._calculateAlignmentPosition(e.x,e.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([c()],D.prototype,"_containerNode",void 0),e([c({readOnly:!0})],D.prototype,"_featureNavigationTop",null),e([c()],D.prototype,"actions",null),e([c({readOnly:!0})],D.prototype,"active",null),e([c()],D.prototype,"alignment",void 0),e([c()],D.prototype,"autoCloseEnabled",null),e([c()],D.prototype,"defaultPopupTemplateEnabled",null),e([c()],D.prototype,"content",null),e([c()],D.prototype,"collapsed",null),e([c({readOnly:!0})],D.prototype,"currentAlignment",null),e([c({readOnly:!0})],D.prototype,"currentDockPosition",null),e([c()],D.prototype,"dockOptions",null),e([c()],D.prototype,"dockEnabled",void 0),e([c({readOnly:!0})],D.prototype,"featureCount",null),e([c()],D.prototype,"featureMenuOpen",null),e([c()],D.prototype,"features",null),e([c()],D.prototype,"goToOverride",null),e([c()],D.prototype,"headingLevel",void 0),e([c()],D.prototype,"highlightEnabled",null),e([c()],D.prototype,"icon",null),e([c()],D.prototype,"initialDisplayMode",null),e([c()],D.prototype,"location",null),e([c()],D.prototype,"label",null),e([c(),M("esri/widgets/Popup/t9n/Popup")],D.prototype,"messages",void 0),e([c()],D.prototype,"promises",null),e([c({readOnly:!0})],D.prototype,"selectedFeature",null),e([c({readOnly:!0})],D.prototype,"selectedDrillInFeature",null),e([c()],D.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],D.prototype,"selectedFeatureWidget",null),e([c()],D.prototype,"title",null),e([c()],D.prototype,"updateLocationEnabled",null),e([c()],D.prototype,"view",null),e([c({type:f}),k(["triggerAction","trigger-action"])],D.prototype,"viewModel",void 0),e([c()],D.prototype,"visible",null),e([c({type:w,nonNullable:!0})],D.prototype,"visibleElements",void 0),D=e([h("esri.widgets.Popup")],D);const P=D;export{P as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{ignoreAbortErrors as i,after as o}from"../core/promiseUtils.js";import{watch as n,on as s,initial as r,whenOnce as l}from"../core/reactiveUtils.js";import{waitAnimationFrame as a}from"../core/scheduling.js";import{stripHTML as d}from"../core/string.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import u from"../support/actions/ActionButton.js";import p from"./Features.js";import g from"./Widget.js";import v from"./Features/FeaturesViewModel.js";import{css as m}from"./Popup/css.js";import f from"./Popup/PopupViewModel.js";import w from"./Popup/PopupVisibleElements.js";import{globalCss as b}from"./support/globalCss.js";import{isRTL as _}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as k}from"./support/decorators/vmEvent.js";import{tsx as y}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";const E=200,C={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let D=class extends g{constructor(e,t){super(e,t),this._dockAction=new u({id:"popup-dock-action"}),this._featuresWidget=new p({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this._focusAbortController=null,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.viewModel=new f,this.visibleElements=new w}initialize(){this.addHandles([n(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),r),n(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),r),n(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},r),n(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),n(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),n(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),n(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),n(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),n(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),n(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,r),n(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,r),n(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,r),n(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,r),n(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,r),n(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,r),n(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,r),n(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,r),n(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,r),n(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,r),n(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,r),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new v,this._featuresWidget.destroy()),this._focusAbortController?.abort()}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||C}set dockOptions(e){const t={...C},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._handleFocus()}next(){return this.viewModel.next()}open(e){const t=!!e&&!!e.featureMenuOpen,i={collapsed:!!e&&!!e.collapsed,featureMenuOpen:t};this.set(i),this.viewModel.open(e),e?.shouldFocus&&this._handleFocus(!0)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:n}=this.viewModel,s=o&&e,r=o&&!e,l=this.selectedFeature?.layer?.title,a=this.selectedFeature?.layer?.id,c={[m.alignTopCenter]:"top-center"===t,[m.alignBottomCenter]:"bottom-center"===t,[m.alignTopLeft]:"top-left"===t,[m.alignBottomLeft]:"bottom-left"===t,[m.alignTopRight]:"top-right"===t,[m.alignBottomRight]:"bottom-right"===t,[m.isDocked]:s,[m.shadow]:r,[m.isDockedTopLeft]:"top-left"===i,[m.isDockedTopCenter]:"top-center"===i,[m.isDockedTopRight]:"top-right"===i,[m.isDockedBottomLeft]:"bottom-left"===i,[m.isDockedBottomCenter]:"bottom-center"===i,[m.isDockedBottomRight]:"bottom-right"===i};return y("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":d(this.title??""),"aria-modal":"false",bind:this,class:this.classes(m.base,c,{[m.baseHidden]:!n&&!e}),"data-layer-id":a,"data-layer-title":l,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:y("div",{class:m.pointer,key:"popup-pointer",role:"presentation"},y("div",{class:this.classes(m.pointerDirection,m.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[m.shadow]:e};return y("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(m.main,b.widget,t)},this._featuresWidget.render())}_getAnimationDurationMS(){const{_containerNode:e}=this;return e?1e3*parseFloat(window.getComputedStyle(e).animationDuration):E}async _handleFocus(e=!1){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;e&&await l(()=>!0===this.viewModel?.active,{signal:t}),await i(a(t)),await i(o(this._getAnimationDurationMS(),t)),this._featuresWidget.focus()}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:h,width:u}=i.getBoundingClientRect(),p=u+t,g=Math.max(h,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return _(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=_(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const n=this._calculateFullWidth(t),s=this._calculateAlignmentPosition(e.x,e.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([c()],D.prototype,"_containerNode",void 0),e([c({readOnly:!0})],D.prototype,"_featureNavigationTop",null),e([c()],D.prototype,"actions",null),e([c({readOnly:!0})],D.prototype,"active",null),e([c()],D.prototype,"alignment",void 0),e([c()],D.prototype,"autoCloseEnabled",null),e([c()],D.prototype,"defaultPopupTemplateEnabled",null),e([c()],D.prototype,"content",null),e([c()],D.prototype,"collapsed",null),e([c({readOnly:!0})],D.prototype,"currentAlignment",null),e([c({readOnly:!0})],D.prototype,"currentDockPosition",null),e([c()],D.prototype,"dockOptions",null),e([c()],D.prototype,"dockEnabled",void 0),e([c({readOnly:!0})],D.prototype,"featureCount",null),e([c()],D.prototype,"featureMenuOpen",null),e([c()],D.prototype,"features",null),e([c()],D.prototype,"goToOverride",null),e([c()],D.prototype,"headingLevel",void 0),e([c()],D.prototype,"highlightEnabled",null),e([c()],D.prototype,"icon",null),e([c()],D.prototype,"initialDisplayMode",null),e([c()],D.prototype,"location",null),e([c()],D.prototype,"label",null),e([c(),M("esri/widgets/Popup/t9n/Popup")],D.prototype,"messages",void 0),e([c()],D.prototype,"promises",null),e([c({readOnly:!0})],D.prototype,"selectedFeature",null),e([c({readOnly:!0})],D.prototype,"selectedDrillInFeature",null),e([c()],D.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],D.prototype,"selectedFeatureWidget",null),e([c()],D.prototype,"title",null),e([c()],D.prototype,"updateLocationEnabled",null),e([c()],D.prototype,"view",null),e([c({type:f}),k(["triggerAction","trigger-action"])],D.prototype,"viewModel",void 0),e([c()],D.prototype,"visible",null),e([c({type:w,nonNullable:!0})],D.prototype,"visibleElements",void 0),D=e([h("esri.widgets.Popup")],D);const P=D;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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){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 B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({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=x.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 B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}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 B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)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(q,"");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 l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({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 l("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),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 d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>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=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){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(o)}_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=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).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=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).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 l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.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 h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(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 u(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),n.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===z){const s=r&&U(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&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(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??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(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 U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(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(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_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)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){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 B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({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=x.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 B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}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 B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)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?.replaceAll(q,"");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 l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({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 l("select:missing-parameter","Cannot select without a searchResult.",{value:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),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 d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>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=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){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(o)}_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=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).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=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).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 l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.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 h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(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 u(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),n.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===z){const s=r&&U(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&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(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??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(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 U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(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(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_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)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};
|