@arcgis/core 4.24.3 → 4.24.6
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/arcade/arcadeCompiler.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{1872276fb7f434c41c09.js → 1d6f79eae87228ba21c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{b780228a520e1a0b100b.js → 8706454ab4002d4b60f6.js} +1 -1
- package/assets/esri/core/workers/chunks/{ef41d8689350b5a260d6.js → aa52809ed4a234dd024a.js} +1 -1
- package/config.js +1 -1
- package/interfaces.d.ts +6039 -8310
- package/layers/support/FeatureReductionBinning.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/MapNotesLayerView2D.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureForm/InputFieldGroup.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as o}from"../../renderers/support/types.js";import{clone as t}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import n from"./AggregateField.js";import{labelsVisible as l,popupEnabled as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as o}from"../../renderers/support/types.js";import{clone as t}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import n from"./AggregateField.js";import{labelsVisible as l,popupEnabled as d}from"./commonProperties.js";import{FeatureReduction as a}from"./FeatureReduction.js";import m from"./LabelClass.js";var u;let c=u=class extends a{constructor(e){super(e),this.type="binning",this.fixedBinLevel=3,this.labelingInfo=null,this.labelsVisible=!0,this.popupEnabled=!0,this.popupTemplate=null,this.fields=[],this.renderer=null}clone(){return new u({fields:t(this.fields),fixedBinLevel:this.fixedBinLevel,labelingInfo:t(this.labelingInfo),labelsVisible:this.labelsVisible,popupEnabled:this.popupEnabled,popupTemplate:t(this.popupTemplate),renderer:t(this.renderer)})}};e([i({binning:"binning"})],c.prototype,"type",void 0),e([s({type:Number,json:{write:!0}})],c.prototype,"fixedBinLevel",void 0),e([s({type:[m],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],c.prototype,"labelingInfo",void 0),e([s(l)],c.prototype,"labelsVisible",void 0),e([s(d)],c.prototype,"popupEnabled",void 0),e([s({type:r,json:{name:"popupInfo",write:!0}})],c.prototype,"popupTemplate",void 0),e([s({type:[n],json:{write:!0,origins:{"web-document":{write:!1},"portal-item":{write:!1}}}})],c.prototype,"fields",void 0),e([s({types:o,json:{write:!0}})],c.prototype,"renderer",void 0),c=u=e([p("esri.layers.support.FeatureReductionBinning")],c);const f=c;export{f as default};
|
package/package.json
CHANGED
package/support/revision.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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const d="20220707",f="7fd01dbc0e83d753fcf101c8ff2a8d215430252d";export{d as buildDate,f as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../Graphic.js";import s from"../../../core/Collection.js";import{isSome as t,isNone as r}from"../../../core/maybe.js";import{watch as h,on as a,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/set.js";import{subclass as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../Graphic.js";import s from"../../../core/Collection.js";import{isSome as t,isNone as r}from"../../../core/maybe.js";import{watch as h,on as a,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/set.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{Container as p}from"../engine/Container.js";import{GroupContainer as c}from"../engine/webgl/GroupContainer.js";import{LayerView2DMixin as l}from"./LayerView2D.js";import g from"./graphics/GraphicContainer.js";import d from"./graphics/GraphicsView2D.js";import u from"../../layers/LayerView.js";const f="sublayers",m="layerView",w=Object.freeze({remove(){},pause(){},resume(){}});let y=class extends(l(u)){constructor(){super(...arguments),this._highlightIds=new Map,this.container=new c}async fetchPopupFeatures(e){return Array.from(this.graphicsViews(),(i=>i.hitTest(e).filter((e=>!!e.popupTemplate)))).flat()}*graphicsViews(){t(this._graphicsViewsFeatureCollectionMap)?yield*this._graphicsViewsFeatureCollectionMap.keys():t(this._graphicsViews)?yield*this._graphicsViews:yield*[]}async hitTest(e,i){return Array.from(this.graphicsViews(),(i=>{const s=i.hitTest(e);if(t(this._graphicsViewsFeatureCollectionMap)){const e=this._graphicsViewsFeatureCollectionMap.get(i);for(const i of s)!i.popupTemplate&&e.popupTemplate&&(i.popupTemplate=e.popupTemplate)}return s})).flat().map((i=>({type:"graphic",graphic:i,layer:this.layer,mapPoint:e})))}highlight(e){let t;return"number"==typeof e?t=[e]:e instanceof i?t=[e.uid]:Array.isArray(e)&&e.length>0?t="number"==typeof e[0]?e:e.map((e=>e&&e.uid)):s.isCollection(e)&&(t=e.map((e=>e&&e.uid)).toArray()),t=t.filter((e=>null!=e)),t.length?(this._addHighlight(t),{remove:()=>{this._removeHighlight(t)}}):w}update(e){for(const i of this.graphicsViews())i.processUpdate(e)}attach(){const e=this.view,i=()=>this.requestUpdate(),s=this.layer.featureCollections;if(t(s)&&s.length){this._graphicsViewsFeatureCollectionMap=new Map;for(const t of s){const s=new g(this.view.featuresTilingScheme);s.fadeTransitionEnabled=!0;const r=new d({view:e,graphics:t.source,renderer:t.renderer,requestUpdateCallback:i,container:s});this._graphicsViewsFeatureCollectionMap.set(r,t),this.container.addChild(r.container),this.handles.add([h((()=>t.visible),(e=>r.container.visible=e),o),h((()=>r.updating),(()=>this.notifyChange("updating")),o)],m)}this._updateHighlight()}else t(this.layer.sublayers)&&this.handles.add(a((()=>this.layer.sublayers),"change",(()=>this._createGraphicsViews()),{onListenerAdd:()=>this._createGraphicsViews(),onListenerRemove:()=>this._destroyGraphicsViews()}),f)}detach(){this._destroyGraphicsViews(),this.handles.remove(f)}moveStart(){}moveEnd(){}viewChange(){for(const e of this.graphicsViews())e.viewChange()}isUpdating(){for(const e of this.graphicsViews())if(e.updating)return!0;return!1}_destroyGraphicsViews(){this.container.removeAllChildren(),this.handles.remove(m);for(const e of this.graphicsViews())e.destroy();this._graphicsViews=null,this._graphicsViewsFeatureCollectionMap=null}_createGraphicsViews(){if(this._destroyGraphicsViews(),r(this.layer.sublayers))return;const e=[],i=this.view,s=()=>this.requestUpdate();for(const t of this.layer.sublayers){const r=new p,a=new g(this.view.featuresTilingScheme);a.fadeTransitionEnabled=!0;const n=new d({view:i,graphics:t.graphics,requestUpdateCallback:s,container:a});this.handles.add([t.on("graphic-update",n.graphicUpdateHandler),h((()=>t.visible),(e=>n.container.visible=e),o),h((()=>n.updating),(()=>this.notifyChange("updating")),o)],m),r.addChild(n.container),this.container.addChild(r),e.push(n)}this._graphicsViews=e,this._updateHighlight()}_addHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i);this._highlightIds.set(i,e+1)}else this._highlightIds.set(i,1);this._updateHighlight()}_removeHighlight(e){for(const i of e)if(this._highlightIds.has(i)){const e=this._highlightIds.get(i)-1;0===e?this._highlightIds.delete(i):this._highlightIds.set(i,e)}this._updateHighlight()}_updateHighlight(){const e=Array.from(this._highlightIds.keys());for(const i of this.graphicsViews())i.setHighlight(e)}};y=e([n("esri.views.2d.layers.MapNotesLayerView2D")],y);const _=y;export{_ 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{applySome as r,isNone as i,isSome as a,unwrapOrThrow as o,unwrap as n}from"../../../../../core/maybe.js";import{throwIfAborted as l,isAbortError as c}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/set.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as h,hasDiff as f}from"../../../../../core/accessorSupport/diffUtils.js";import m from"../../../../../geometry/SpatialReference.js";import{isAggregateId as u}from"../../../engine/webgl/DisplayId.js";import{MeshData as p}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as g}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as y}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as _}from"../../../engine/webgl/util/Matcher.js";import{codepoints as b}from"../textUtils.js";import S from"./BaseProcessor.js";import w from"../support/ResourceManagerProxy.js";function I(e,t){return(!e.minScale||e.minScale>=t)&&(!e.maxScale||e.maxScale<=t)}function v(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const i in t.data){const e=t.data[i];if(s.message.data[i]=null,a(e)){const t=e.stride,a=e.indices.slice(0),o=e.vertices.slice(0),n=e.records.slice(0),l={stride:t,indices:a,vertices:o,records:n,metrics:r(e.metrics,(e=>e.slice(0)))};s.transferList.push(a,o,n),s.message.data[i]=l}}return s}s.getLogger("esri.views.2d.layers.features.processors.SymbolProcessor");let M=class extends S{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new w(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=h(this._schema,s);f(r,"mesh")&&(e.mesh=!0,e.why.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,r){return l(r),this._onTileData(e,t,s,r)}onTileClear(e){const t={clear:!0};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,v(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e).push(v(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:i}=this.service,a=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),o={geometryType:t,fields:i,spatialReference:m.fromJSON(this.spatialReference)},n=new y(a,this.tileStore.tileScheme.tileInfo),{matcher:l,aggregateMatcher:c}=e.mesh;return this._store=n,this._matchers.feature=_(l,n,o,this._resourceManagerProxy),this._matchers.aggregate=r(c,(e=>_(e,n,o,this._resourceManagerProxy))),new g(t,s,n)}async _onTileData(e,t,s,r){l(r);const{type:o,addOrUpdate:n,remove:c
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{applySome as r,isNone as i,isSome as a,unwrapOrThrow as o,unwrap as n}from"../../../../../core/maybe.js";import{throwIfAborted as l,isAbortError as c}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/set.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as h,hasDiff as f}from"../../../../../core/accessorSupport/diffUtils.js";import m from"../../../../../geometry/SpatialReference.js";import{isAggregateId as u}from"../../../engine/webgl/DisplayId.js";import{MeshData as p}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as g}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as y}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as _}from"../../../engine/webgl/util/Matcher.js";import{codepoints as b}from"../textUtils.js";import S from"./BaseProcessor.js";import w from"../support/ResourceManagerProxy.js";function I(e,t){return(!e.minScale||e.minScale>=t)&&(!e.maxScale||e.maxScale<=t)}function v(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const i in t.data){const e=t.data[i];if(s.message.data[i]=null,a(e)){const t=e.stride,a=e.indices.slice(0),o=e.vertices.slice(0),n=e.records.slice(0),l={stride:t,indices:a,vertices:o,records:n,metrics:r(e.metrics,(e=>e.slice(0)))};s.transferList.push(a,o,n),s.message.data[i]=l}}return s}s.getLogger("esri.views.2d.layers.features.processors.SymbolProcessor");let M=class extends S{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new w(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=h(this._schema,s);f(r,"mesh")&&(e.mesh=!0,e.why.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,r){return l(r),this._onTileData(e,t,s,r)}onTileClear(e){const t={clear:!0};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,v(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e).push(v(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:i}=this.service,a=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),o={geometryType:t,fields:i,spatialReference:m.fromJSON(this.spatialReference)},n=new y(a,this.tileStore.tileScheme.tileInfo),{matcher:l,aggregateMatcher:c}=e.mesh;return this._store=n,this._matchers.feature=_(l,n,o,this._resourceManagerProxy),this._matchers.aggregate=r(c,(e=>_(e,n,o,this._resourceManagerProxy))),new g(t,s,n)}async _onTileData(e,t,s,r){l(r);const{type:o,addOrUpdate:n,remove:c,clear:d,end:h}=t,f=!!this._schema.mesh.sortKey;if(!n){const t={type:o,addOrUpdate:null,remove:c,clear:d,end:h,sort:f};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const m=this._processFeatures(e,n,s,r,t.status.version);try{const s=await m;if(i(s)){const t={type:o,addOrUpdate:null,remove:c,clear:d,end:h,sort:f};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const n=[];for(const t of s){let s=!1;const r=t.message.bufferIds,i=e.key.id,o=t.message.tileKey;if(i!==o&&a(r)){if(!this.tileStore.get(o)){this._addBufferData(i,t),n.push(t);continue}let e=this._bufferIds.get(o);e||(e=new Set,this._bufferIds.set(o,e));const a=Array.from(r);for(const t of a){if(e.has(t)){s=!0;break}e.add(t)}}s||(this._addBufferData(i,t),n.push(t))}await Promise.all(n.map((s=>{const i=e.key.id===s.message.tileKey,a=i?t.remove:[],n=i&&t.end;return this._updateTileMesh(o,e,s,a,n,t.clear,r.signal)})))}catch(u){this._handleError(e,u,r)}}async _updateTileMesh(e,t,s,i,a,o,c){const d=e,h=s.message.tileKey,f=!!this._schema.mesh.sortKey;h!==t.key.id&&(a=!1);const m=r(s,(e=>e.message)),u=r(s,(e=>e.transferList))||[],p={type:d,addOrUpdate:m,remove:i,clear:o,end:a,sort:f},g={transferList:n(u)||[],signal:c};return l(g),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:h,data:p},g)}async _processFeatures(e,t,s,r,a){if(i(t)||!t.hasFeatures)return null;const o={transform:e.transform,hasZ:!1,hasM:!1},n=this._factory,c={viewingMode:"",scale:e.scale},d=await this._matchers.feature,h=await this._matchers.aggregate;l(r);const f=this._getLabelInfos(e,t);return await n.analyze(t.getCursor(),this._resourceManagerProxy,d,h,o,c),l(r),this._writeFeatureSet(e,t,o,f,n,s,a)}_writeFeatureSet(e,t,s,r,i,o,n){const l=t.getSize(),c=new p(e.key.id,{features:l,records:l,metrics:0},this._schema.mesh.matcher.symbologyType,o,!0,n),d={viewingMode:"",scale:e.scale},h=t.getCursor();for(;h.next();)try{const t=h.getDisplayId(),o=a(r)?r.get(t):null;i.writeCursor(c,h,s,d,e.level,o,this._resourceManagerProxy)}catch(m){}const f=e.tileInfoView.tileInfo.isWrappable;return c.serialize(f)}_handleError(e,t,s){if(!c(t)){const r={tileKey:e.id,error:t.message};return this.remoteClient.invoke("tileRenderer.onTileError",r,{signal:s.signal})}}_getLabelingSchemaForScale(e){const t=this._schema.mesh.labels;if(i(t))return null;if("subtype"===t.type){const s={type:"subtype",classes:{}};let r=!1;for(const i in t.classes){const a=t.classes[i].filter((t=>I(t,e.scale)));r=r||!!a.length,s.classes[i]=a}return r?s:null}const s=t.classes.filter((t=>I(t,e.scale)));return s.length?{type:"simple",classes:s}:null}_getLabels(e,t){if("subtype"===t.type){const s=this.service.subtypeField,r=o(s,"Expected to find subtype Field"),i=e.readAttribute(r);return null==i?[]:t.classes[i]??[]}return t.classes}_getLabelInfos(e,s){const r=this._getLabelingSchemaForScale(e);if(i(r))return null;const a=new Map,o=s.getCursor();for(;o.next();){const e=o.getDisplayId(),s=[],i=u(e),n=i&&1!==o.readAttribute("cluster_count")?"aggregate":"feature",l=this._getLabels(o,r);for(const r of l){if(r.target!==n)continue;const a=o.getStorage(),l=i&&"feature"===n?a.getComputedStringAtIndex(o.readAttribute("referenceId"),r.fieldIndex):a.getComputedStringAtIndex(e,r.fieldIndex);if(!l)continue;const c=t(l.toString()),d=c[0],h=c[1];this._store.getMosaicItem(r.symbol,b(d)).then((e=>{s[r.index]={glyphs:e.glyphMosaicItems,rtl:h,index:r.index}}))}a.set(e,s)}return a}};M=e([d("esri.views.2d.layers.features.processors.SymbolProcessor")],M);const x=M;export{x 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import i from"../../../core/Collection.js";import s from"../../../core/Error.js";import r from"../../../core/Evented.js";import o from"../../../core/Handles.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,isNone as h,isSome as c,abortMaybe as p,get as l}from"../../../core/maybe.js";import{createTask as d}from"../../../core/promiseUtils.js";import{when as m,pausable as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as g,geometryToCoordinates as u,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import f from"../../../layers/GraphicsLayer.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as b}from"../../ViewingMode.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import w from"./GraphicMover.js";import S from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as E}from"./settings.js";import{ViewEventPriorities as I}from"../../input/InputManager.js";import{SKETCH_KEYS as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import j from"../../../geometry/Polyline.js";import H from"../../../geometry/Point.js";class A{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class U{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class T{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class D{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class F{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class z{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class L{constructor(e){this.added=e,this.type="vertex-select"}}class P{constructor(e){this.removed=e,this.type="vertex-deselect"}}class K{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class N{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const q=E.reshapeGraphics,B={vertices:{default:new G({style:"circle",size:q.vertex.size,color:q.vertex.color,outline:{color:q.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:q.vertex.hoverSize,color:q.vertex.hoverColor,outline:{color:q.vertex.hoverOutlineColor,width:1}}),selected:new G({style:"circle",size:q.selected.size,color:q.selected.color,outline:{color:q.selected.outlineColor,width:1}})},midpoints:{default:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}}),hover:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}})}},J="esri.views.draw.support.Reshape",Q=n.getLogger(J);let W=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new o,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingTask=null,this._stagedVertex=null,this._viewHandles=new o,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new i,this.midpointSymbol=new G({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.type="reshape",this.vertexGraphics=new i,this.view=null}initialize(){this._highlightHelper=new S({view:this.view}),this._setup(),this._handles.add([m((()=>this.view?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),I.TOOL))}),{once:!0,initial:!0}),v((()=>this.graphic),(()=>this.refresh())),v((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),v((()=>this.enableMidpoints),(()=>this.refresh()))])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._handles=a(this._handles),this._viewHandles=a(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=B.midpoints,vertices:i=B.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||h(e.geometry))return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&g(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(h(e)||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new j({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,b.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new f({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){c(this.snappingManager)&&this.snappingManager.doneSnapping(),c(this._snappingGraphicsLayer)&&(this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=u(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(c(e)&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,c]=e;o.push(new t({geometry:new H({x:h,y:c,spatialReference:r}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[c,p]=a,d=e[h+1]?h+1:0;if("polygon"===l(this.graphic.geometry,"type")||0!==d){const[a,l]=e[d],[m,v]=x([c,p],[a,l]);o.push(new t({geometry:new H({x:m,y:v,spatialReference:r}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),o}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const r=t[i],o=t[e];r.x===o.x&&r.y===o.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:r}=this,o=s.concat(i).items;e&&o.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:o,view:r,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:r?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const t=e.graphic,{dx:i,dy:s}=e;if(t===this.graphic)return this._clearSelection(),this._resetGraphics(),this._setUpOperation(e),this._emitMoveStartEvent(i,s),void("point"===this._editGeometryOperations.data.type&&this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))));if(!this.selectedVertices.includes(t)){if(this._clearSelection(),this._isMidpoint(t)){const e=this.graphic.clone(),i=this._createVertexFromMidpoint(t);this._emitVertexAddEvent([t],e,i)}this._addToSelection(t)}this._setUpOperation(e),this._emitReshapeStartEvent(t),this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s;const{operationType:r}=this._activeOperationInfo;"move"===r?"point"===this._editGeometryOperations.data.type?this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))):this._emitMoveEvent(i,s):this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveStopCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s,this._onHandleMove(t,i,s,e,(()=>t===this.graphic?this._emitMoveStopEvent():this._emitReshapeStopEvent(t))),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._isMidpoint(t)&&this.refresh()}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:r}=t.attributes,[o,n]=e[i][s],[a,h]=e[i][r],[c,p]=x([o,n],[a,h]);t.geometry=new H({x:c,y:p,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,i,s,r){if(p(this._snappingTask),!this._snappingContext)return;const o=e.geometry,n="graphic-move-stop"===s.type;if(c(this.snappingManager)&&this.selectedVertices.length<2&&!n){const s=this.snappingManager;this._stagedVertex=s.update(o,this._snappingContext),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r(),this._snappingTask=d((async a=>{const h=await s.snap(o,this._snappingContext,a);h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r())}))}else{const s=c(this._stagedVertex)?new H(this._stagedVertex):o;this._syncGeometryAfterVertexMove(e,s,t,i,n),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,r=!1){const o=this._editGeometryOperations.data.geometry;if("point"===o.type)e.geometry=t;else{const{x:n,y:a}=t,[h,c]=this._getIndicesForVertexGraphic(e);let p=u(o);const l=p[h].length-1;p[h][c]=[n,a],"polygon"===o.type&&(0===c?p[h][l]=[n,a]:c===l&&(p[h][0]=[n,a])),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,n,a),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===o.type),this._updateMidpointGraphicLocations(p)),this.graphic.geometry=o.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),r&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:r}=t.attributes;for(const o of r){const r=this.vertexGraphics.getItemAt(o),{pathIndex:n,pointIndex:a}=r.attributes;e[n][a]=[i,s],r.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,r){for(const o of this.selectedVertices)if(o!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=o.attributes,h=M(o.geometry,i,s,this.view),c=e[t].length-1;e[t][n]=[h.x,h.y],o.geometry=h,r&&(0===n?e[t][c]=[h.x,h.y]:n===c&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:r}=t.attributes;e[s][r]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default"}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(h(s)||"polygon"!==s.type&&"polyline"!==s.type)return[];const r=s.clone(),o=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:c}=e.attributes,{x:p,y:l}=e.geometry,d=0===c?a+1:c,m=u(r);return m[n].splice(d,0,[p,l]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},o.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=r,o}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,r=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",r);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(h(i)||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),r=i.clone();let o=u(r);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<o.length;t++){const s=o[t];for(let r=0;r<s.length;r++){const[a,h]=s[r];e===a&&i===h&&(n.push({coordinates:o[t][r],componentIndex:t,vertexIndex:r}),o[t].splice(Number(r),1))}}}if("polygon"===r.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,r]=e[e.length-1];return(2!==e.length||t!==s||i!==r)&&(t===s&&i===r||e.push(e[0]),!0)})),r.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);r.paths=o}this.graphic.geometry=r,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_emitMoveStartEvent(e,t){const i=new D(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new F(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const{totalDx:e,totalDy:t}=this._activeOperationInfo,i=new z(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(i)}_emitReshapeStartEvent(e){const t=new A(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new U(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new T(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new L(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new P(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new K(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new N(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){Q.error(new s("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([y()],W.prototype,"callbacks",void 0),e([y()],W.prototype,"enableMidpoints",void 0),e([y()],W.prototype,"enableMovement",void 0),e([y()],W.prototype,"enableVertices",void 0),e([y()],W.prototype,"graphic",void 0),e([y({value:!0})],W.prototype,"highlightsEnabled",null),e([y()],W.prototype,"layer",void 0),e([y({readOnly:!0})],W.prototype,"midpointGraphics",void 0),e([y()],W.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],W.prototype,"selectedVertices",void 0),e([y()],W.prototype,"snappingManager",void 0),e([y({readOnly:!0})],W.prototype,"state",null),e([y({value:B})],W.prototype,"symbols",null),e([y({readOnly:!0})],W.prototype,"type",void 0),e([y({readOnly:!0})],W.prototype,"vertexGraphics",void 0),e([y()],W.prototype,"view",void 0),W=e([_(J)],W);const X=W;export{X as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import i from"../../../core/Collection.js";import s from"../../../core/Error.js";import r from"../../../core/Evented.js";import o from"../../../core/Handles.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,isNone as h,isSome as c,abortMaybe as p,get as l}from"../../../core/maybe.js";import{createTask as d}from"../../../core/promiseUtils.js";import{when as m,pausable as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as g,geometryToCoordinates as u,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import f from"../../../layers/GraphicsLayer.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as b}from"../../ViewingMode.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import w from"./GraphicMover.js";import S from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as E}from"./settings.js";import{ViewEventPriorities as I}from"../../input/InputManager.js";import{SKETCH_KEYS as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import j from"../../../geometry/Polyline.js";import H from"../../../geometry/Point.js";class A{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class U{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class T{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class D{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class F{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class z{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class L{constructor(e){this.added=e,this.type="vertex-select"}}class P{constructor(e){this.removed=e,this.type="vertex-deselect"}}class K{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class N{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const q=E.reshapeGraphics,B={vertices:{default:new G({style:"circle",size:q.vertex.size,color:q.vertex.color,outline:{color:q.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:q.vertex.hoverSize,color:q.vertex.hoverColor,outline:{color:q.vertex.hoverOutlineColor,width:1}}),selected:new G({style:"circle",size:q.selected.size,color:q.selected.color,outline:{color:q.selected.outlineColor,width:1}})},midpoints:{default:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}}),hover:new G({style:"circle",size:q.midpoint.size,color:q.midpoint.color,outline:{color:q.midpoint.outlineColor,width:1}})}},J="esri.views.draw.support.Reshape",Q=n.getLogger(J);let W=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new o,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingTask=null,this._stagedVertex=null,this._viewHandles=new o,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new i,this.midpointSymbol=new G({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.type="reshape",this.vertexGraphics=new i,this.view=null}initialize(){this._highlightHelper=new S({view:this.view}),this._setup(),this._handles.add([m((()=>this.view?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),I.TOOL))}),{once:!0,initial:!0}),v((()=>this.graphic),(()=>this.refresh())),v((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),v((()=>this.enableMidpoints),(()=>this.refresh()))])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._handles=a(this._handles),this._viewHandles=a(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=B.midpoints,vertices:i=B.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||h(e.geometry))return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&g(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(h(e)||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new j({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,b.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new f({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){c(this.snappingManager)&&this.snappingManager.doneSnapping(),c(this._snappingGraphicsLayer)&&(this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=u(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(c(e)&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,c]=e;o.push(new t({geometry:new H({x:h,y:c,spatialReference:r}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:r}}=this,o=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[c,p]=a,d=e[h+1]?h+1:0;if("polygon"===l(this.graphic.geometry,"type")||0!==d){const[a,l]=e[d],[m,v]=x([c,p],[a,l]);o.push(new t({geometry:new H({x:m,y:v,spatialReference:r}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),o}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const r=t[i],o=t[e];r.x===o.x&&r.y===o.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:r}=this,o=s.concat(i).items;e&&o.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:o,view:r,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:r?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const t=e.graphic,{dx:i,dy:s}=e;if(t===this.graphic)return this._clearSelection(),this._resetGraphics(),this._setUpOperation(e),this._emitMoveStartEvent(i,s),void("point"===this._editGeometryOperations.data.type&&this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))));if(!this.selectedVertices.includes(t)){if(this._clearSelection(),this._isMidpoint(t)){const e=this.graphic.clone(),i=this._createVertexFromMidpoint(t);this._emitVertexAddEvent([t],e,i)}this._addToSelection(t)}this._setUpOperation(e),this._emitReshapeStartEvent(t),this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveCallback(e){const{graphic:t,dx:i,dy:s}=e;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s;const{operationType:r}=this._activeOperationInfo;"move"===r?"point"===this._editGeometryOperations.data.type?this._onHandleMove(t,i,s,e,(()=>this._emitMoveEvent(i,s))):this._emitMoveEvent(i,s):this._onHandleMove(t,i,s,e,(()=>this._emitReshapeEvent(t)))}_onGraphicMoveStopCallback(e){const{graphic:t,dx:i,dy:s}=e,r=t===this.graphic,o="point"!==this._editGeometryOperations.data.type;this._activeOperationInfo.totalDx+=i,this._activeOperationInfo.totalDy+=s,this._onHandleMove(t,i,s,e,(()=>r?this._emitMoveStopEvent():this._emitReshapeStopEvent(t))),r&&o||this._isMidpoint(t)?this.refresh():(this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:r}=t.attributes,[o,n]=e[i][s],[a,h]=e[i][r],[c,p]=x([o,n],[a,h]);t.geometry=new H({x:c,y:p,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,i,s,r){if(p(this._snappingTask),!this._snappingContext)return;const o=e.geometry,n="graphic-move-stop"===s.type;if(c(this.snappingManager)&&this.selectedVertices.length<2&&!n){const s=this.snappingManager;this._stagedVertex=s.update(o,this._snappingContext),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r(),this._snappingTask=d((async a=>{const h=await s.snap(o,this._snappingContext,a);h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new H(this._stagedVertex),t,i,n),r())}))}else{const s=c(this._stagedVertex)?new H(this._stagedVertex):o;this._syncGeometryAfterVertexMove(e,s,t,i,n),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,r=!1){const o=this._editGeometryOperations.data.geometry;if("point"===o.type)e.geometry=t;else{const{x:n,y:a}=t,[h,c]=this._getIndicesForVertexGraphic(e);let p=u(o);const l=p[h].length-1;p[h][c]=[n,a],"polygon"===o.type&&(0===c?p[h][l]=[n,a]:c===l&&(p[h][0]=[n,a])),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,n,a),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===o.type),this._updateMidpointGraphicLocations(p)),this.graphic.geometry=o.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),r&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:r}=t.attributes;for(const o of r){const r=this.vertexGraphics.getItemAt(o),{pathIndex:n,pointIndex:a}=r.attributes;e[n][a]=[i,s],r.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,r){for(const o of this.selectedVertices)if(o!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=o.attributes,h=M(o.geometry,i,s,this.view),c=e[t].length-1;e[t][n]=[h.x,h.y],o.geometry=h,r&&(0===n?e[t][c]=[h.x,h.y]:n===c&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:r}=t.attributes;e[s][r]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default"}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(h(s)||"polygon"!==s.type&&"polyline"!==s.type)return[];const r=s.clone(),o=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:c}=e.attributes,{x:p,y:l}=e.geometry,d=0===c?a+1:c,m=u(r);return m[n].splice(d,0,[p,l]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},o.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=r,o}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,r=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",r);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(h(i)||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),r=i.clone();let o=u(r);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<o.length;t++){const s=o[t];for(let r=0;r<s.length;r++){const[a,h]=s[r];e===a&&i===h&&(n.push({coordinates:o[t][r],componentIndex:t,vertexIndex:r}),o[t].splice(Number(r),1))}}}if("polygon"===r.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,r]=e[e.length-1];return(2!==e.length||t!==s||i!==r)&&(t===s&&i===r||e.push(e[0]),!0)})),r.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);r.paths=o}this.graphic.geometry=r,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_emitMoveStartEvent(e,t){const i=new D(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new F(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const{totalDx:e,totalDy:t}=this._activeOperationInfo,i=new z(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(i)}_emitReshapeStartEvent(e){const t=new A(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new U(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new T(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new L(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new P(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new K(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new N(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){Q.error(new s("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([y()],W.prototype,"callbacks",void 0),e([y()],W.prototype,"enableMidpoints",void 0),e([y()],W.prototype,"enableMovement",void 0),e([y()],W.prototype,"enableVertices",void 0),e([y()],W.prototype,"graphic",void 0),e([y({value:!0})],W.prototype,"highlightsEnabled",null),e([y()],W.prototype,"layer",void 0),e([y({readOnly:!0})],W.prototype,"midpointGraphics",void 0),e([y()],W.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],W.prototype,"selectedVertices",void 0),e([y()],W.prototype,"snappingManager",void 0),e([y({readOnly:!0})],W.prototype,"state",null),e([y({value:B})],W.prototype,"symbols",null),e([y({readOnly:!0})],W.prototype,"type",void 0),e([y({readOnly:!0})],W.prototype,"vertexGraphics",void 0),e([y()],W.prototype,"view",void 0),W=e([_(J)],W);const X=W;export{X 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{makeHandle as s}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{destroyMaybe as r,isNone as a,isSome as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as C}from"../../intl/messages.js";const v=new t({attributes:{}}),b="esri.widgets.FeatureForm.FeatureFormViewModel",E=o.getLogger(b),V=["editable","required","value","visibility"],x="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",w="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let I=class extends(n(u(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressionLookup=new Map,this._expressionLookup=new Map,this._expressionInvalidationCallbacks=new Set,this._contingentValuesCache=null,this._featureClone=v.clone(),this._initialFeature=v.clone(),this._arcadeGeometryOperationsEnabled=!1,this._inputFieldCache=[],this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await C("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=c((()=>this.layer),(e=>{"feature"===e?.type&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=c((()=>this.feature?.geometry),(e=>{this._featureClone.geometry=e;for(const t of this._expressionInvalidationCallbacks)t()}));this.handles.add([F(e),t,i])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get allInputFields(){return this.inputFields.reduce(((e,t)=>T(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():v.clone(),this._initialFeature=this._featureClone.clone(),this.contingencyConstraintViolations.clear(),this._clearInputFieldCache(),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){null!=e?this._override("formTemplate",e):this._clearOverride("formTemplate")}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,formTemplate:s,messages:o,layer:r,state:a,spatialReference:u}=this;if("ready"!==a)return[];const c={arcade:e,feature:t,initialFeature:i,layer:r,messages:o,expressionTrackingProvider:{registerExpression:this._registerExpression.bind(this)},spatialReference:u},p=l(s)&&s.elements.length>0?this._updateInputFieldsFromElements(n,s.elements,c):this._updateInputFieldsFromLayerFields(n,r?.fields,c);return this._inputFieldCache=p,p}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:i}=this,n=!!i?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),r=[...s,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_updateInputFieldsFromElements(e,t,i){const n=new Map;for(const o of e)if(T(o)){A(n,o.groupElement,o);for(const e of o.inputFields)A(n,e.fieldElement,e)}else A(n,o.fieldElement,o);const s=this._updateInputFieldsRecursive(n,t.filter(this._isSupportedElement),i);for(const[o,r]of n.entries())n.delete(o),r.destroy();return s}_updateInputFieldsRecursive(e,t,i,n=null){const s=[];for(const o of t){const t=e.has(o),r=t?e.get(o):k(o)?this._makeInputFieldGroupFromGroupElement(o,i):this._makeInputFieldFromFieldElement(o,i,n);if(s.push(r),t)if(e.delete(o),T(r)){const{arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s}=i;r.set({arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s})}else r.set(i);if(k(o)){const t=o.elements.filter((e=>this._isSupportedElement(e)));r.inputFields=this._updateInputFieldsRecursive(e,t,i,r)}}return s}_updateInputFieldsFromLayerFields(e,t,i){if(!Array.isArray(t))return E.warn(b,"No attribute fields found."),[];const n=new Map;for(const c of e)if(T(c)){for(const e of c.inputFields)e.destroy();c.inputFields.length=0,c.destroy()}else n.set(c.field,c);const s=[],{feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u}=i;for(const c of t){const e=n.get(c)??new y({field:c,feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u,value:o.getAttribute(c.name)});e.set({fieldElement:null,requiredFunction:null,visibilityFunction:null,valueFunction:null,editableFunction:null}),s.push(e),n.delete(c)}for(const[c,p]of n.entries())n.delete(c),p.destroy();return s}_makeInputFieldFromFieldElement(e,t,i=null){const{arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d}=t,h=new y({fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),requiredFunction:this._getCompiledExpression(e.requiredExpression),visibilityFunction:this._getCompiledExpression(e.visibilityExpression),valueFunction:this._getCompiledExpression(e.valueExpression),editableFunction:this._getCompiledExpression(e.editableExpression),group:i,arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d,value:r.getAttribute(e.fieldName)}),f=`watch-expression-field-${h.id}`,m=c((()=>h.fieldElement),(e=>{this.handles.remove(f),l(e)&&this.handles.add(V.map((t=>c((()=>e[`${t}Expression`]),(async e=>{e&&""!==e&&(h[`${t}Function`]=await this._getOrMakeCompiledExpression(e),h.arcade=this._arcade)}),{initial:!0,sync:!0}))),f)}),{initial:!0,sync:!0}),g=s((()=>this.handles.remove(f))),_=c((()=>h.value),(()=>this._afterValueChange(h)));return h.own([m,g,_]),h}_makeInputFieldGroupFromGroupElement(e,t){const{arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o}=t,r=new _({groupElement:e,visibilityFunction:this._getCompiledExpression(e.visibilityExpression),inputFields:[],arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o});return r.own(c((()=>r.groupElement),(e=>l(e)&&e.own(c((()=>e.visibilityExpression),(async e=>{e&&""!==e&&(r.visibilityFunction=await this._getOrMakeCompiledExpression(e),r.arcade=this._arcade)}),{initial:!0}))),{initial:!0})),r}_clearInputFieldCache(){for(const e of this._inputFieldCache)e.destroy();this._inputFieldCache=[]}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===t&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i);for(const n of this._expressionInvalidationCallbacks)n();this._emitChangeEvent(e)}_registerExpression(e){const{_expressionInvalidationCallbacks:t}=this;return t.add(e),s((()=>t.delete(e)))}_getCompiledExpression(e){return this._compiledExpressionLookup.get(this._expressionLookup.get(e))}async _getOrMakeCompiledExpression(e){{if(a(e)||""===e)return null;const t=this._expressionLookup.get(e)??this._addToExpressionLookup(e);if(this._compiledExpressionLookup.has(t))return this._compiledExpressionLookup.get(t);this._arcade||(this._arcade=await g());const i=this._arcade.arcadeUtils;return!this._arcadeGeometryOperationsEnabled&&i.hasGeometryOperations(t)&&(await i.enableGeometryOperations(),this._arcadeGeometryOperationsEnabled=!0),this._addToCompiledExpressionLookup(t)}}_addToCompiledExpressionLookup(e){const{_arcade:{arcadeUtils:t},_compiledExpressionLookup:i}=this,n=t.createFunction(e);return i.set(e,n),n}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:i}=this,n=(l(i)&&l(i.expressionInfos)?Object.values(i.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(E.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(a(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const s=t.get(e),o=l,r=[s.name,o.name].sort().join("|");if(n.has(r))continue;i.push([s,o]),n.add(r),t.set(e,o)}else t.set(e,l);const s=new Set(i.flat()),o=new Set(e);for(const l of s)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(i.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of i){const e=a.get(l),t=a.get(u);if(e===t)continue;const i=r.get(e),n=r.get(t);for(const s of n)i.add(s),a.set(s,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),r=new Map;for(const a of i.contingencies){const[e]=this._hashContingency(a,s.codedValueFields,!0);r.has(e)?r.get(e).push(a):r.set(e,[a])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(r,i):r.get(i);if(r.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,r.get(j),s.codedValueFields)),!a(o))for(const r of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,s.rangeFields):this._joinContingencies(r,t);if(a(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}r=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,r.get(j),s.codedValueFields)),!a(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:c,bothAreAny:p,leftIsRange:d,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(l||p)continue;if(r&&c||a&&u){n.values[s]=new f({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{const n=t.values[i],s=e.values[i];return"any"===n.objectType||"any"===s.objectType||n.codedValue?.code===s.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,r=new Set,l=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,i=!1){if(t.length<1)return[x,!1];const n=[];let s=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${w}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([p({readOnly:!0})],I.prototype,"allInputFields",null),e([p()],I.prototype,"_layerFieldsByName",null),e([p()],I.prototype,"_inputFieldCache",void 0),e([p()],I.prototype,"contingencyConstraintViolations",void 0),e([p()],I.prototype,"feature",null),e([p()],I.prototype,"fieldsWithContingentValues",null),e([p({type:h})],I.prototype,"formTemplate",null),e([p({readOnly:!0})],I.prototype,"inputFields",null),e([p()],I.prototype,"joinedContingentValues",null),e([p()],I.prototype,"layer",null),e([p()],I.prototype,"messages",void 0),e([p()],I.prototype,"spatialReference",null),e([p()],I.prototype,"state",null),e([p()],I.prototype,"strict",void 0),e([p()],I.prototype,"submittable",null),e([p()],I.prototype,"valid",null),e([p()],I.prototype,"getValues",null),e([p()],I.prototype,"submit",null),I=e([d(b)],I);const T=e=>!!e.inputFields,k=e=>"group"===e.type,A=(e,t,i)=>{l(t)&&e.set(t,i)},M=I;export{M as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{makeHandle as s}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{destroyMaybe as r,isNone as a,isSome as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as C}from"../../intl/messages.js";const v=new t({attributes:{}}),b="esri.widgets.FeatureForm.FeatureFormViewModel",E=o.getLogger(b),V=["editable","required","value","visibility"],x="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",w="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let I=class extends(n(u(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressionLookup=new Map,this._expressionLookup=new Map,this._expressionInvalidationCallbacks=new Set,this._contingentValuesCache=null,this._featureClone=v.clone(),this._initialFeature=v.clone(),this._arcadeGeometryOperationsEnabled=!1,this._inputFieldCache=[],this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await C("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=c((()=>this.layer),(e=>{"feature"===e?.type&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=c((()=>this.feature?.geometry),(e=>{this._featureClone.geometry=e;for(const t of this._expressionInvalidationCallbacks)t()}));this.handles.add([F(e),t,i])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get allInputFields(){return this.inputFields.reduce(((e,t)=>T(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():v.clone(),this._initialFeature=this._featureClone.clone(),this.contingencyConstraintViolations.clear(),this._clearInputFieldCache(),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){null!=e?this._override("formTemplate",e):this._clearOverride("formTemplate")}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,formTemplate:s,messages:o,layer:r,state:a,spatialReference:u}=this;if("ready"!==a)return[];const c={arcade:e,feature:t,initialFeature:i,layer:r,messages:o,expressionTrackingProvider:{registerExpression:this._registerExpression.bind(this)},spatialReference:u},p=l(s)&&s.elements.length>0?this._updateInputFieldsFromElements(n,s.elements,c):this._updateInputFieldsFromLayerFields(n,r?.fields,c);return this._inputFieldCache=p,p}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:i}=this,n=!!i?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),r=[...s,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_updateInputFieldsFromElements(e,t,i){const n=new Map;for(const o of e)if(T(o)){A(n,o.groupElement,o);for(const e of o.inputFields)A(n,e.fieldElement,e)}else A(n,o.fieldElement,o);const s=this._updateInputFieldsRecursive(n,t.filter(this._isSupportedElement),i);for(const[o,r]of n.entries())n.delete(o),r.destroy();return s}_updateInputFieldsRecursive(e,t,i,n=null){const s=[];for(const o of t){const t=e.has(o),r=t?e.get(o):k(o)?this._makeInputFieldGroupFromGroupElement(o,i):this._makeInputFieldFromFieldElement(o,i,n);if(s.push(r),t)if(e.delete(o),T(r)){const{arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s}=i;r.set({arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s})}else r.set(i);if(k(o)){const t=o.elements.filter((e=>this._isSupportedElement(e)));r.inputFields=this._updateInputFieldsRecursive(e,t,i,r)}}return s}_updateInputFieldsFromLayerFields(e,t,i){if(!Array.isArray(t))return E.warn(b,"No attribute fields found."),[];const n=new Map;for(const c of e)if(T(c)){for(const e of c.inputFields)e.destroy();c.inputFields.length=0,c.destroy()}else n.set(c.field,c);const s=[],{feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u}=i;for(const c of t){const e=n.get(c)??new y({field:c,feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u,value:o.getAttribute(c.name)});e.set({fieldElement:null,requiredFunction:null,visibilityFunction:null,valueFunction:null,editableFunction:null}),s.push(e),n.delete(c)}for(const[c,p]of n.entries())n.delete(c),p.destroy();return s}_makeInputFieldFromFieldElement(e,t,i=null){const{arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d}=t,h=new y({fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),requiredFunction:this._getCompiledExpression(e.requiredExpression),visibilityFunction:this._getCompiledExpression(e.visibilityExpression),valueFunction:this._getCompiledExpression(e.valueExpression),editableFunction:this._getCompiledExpression(e.editableExpression),group:i,arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d,value:r.getAttribute(e.fieldName)}),f=`watch-expression-field-${h.id}`,m=c((()=>h.fieldElement),(e=>{this.handles.remove(f),l(e)&&this.handles.add(V.map((t=>c((()=>e[`${t}Expression`]),(async e=>{e&&""!==e&&(h[`${t}Function`]=await this._getOrMakeCompiledExpression(e),h.arcade=this._arcade)}),{initial:!0,sync:!0}))),f)}),{initial:!0,sync:!0}),g=s((()=>this.handles.remove(f))),_=c((()=>h.value),(()=>this._afterValueChange(h)));return h.own([m,g,_]),h}_makeInputFieldGroupFromGroupElement(e,t){const{arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o}=t,r=new _({groupElement:e,visibilityFunction:this._getCompiledExpression(e.visibilityExpression),inputFields:[],arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o});return r.own(c((()=>r.groupElement),(e=>l(e)&&e.own(c((()=>e.visibilityExpression),(async e=>{e&&""!==e&&(r.visibilityFunction=await this._getOrMakeCompiledExpression(e),r.arcade=this._arcade)}),{initial:!0}))),{initial:!0})),r}_clearInputFieldCache(){for(const e of this._inputFieldCache){if(T(e))for(const t of e.inputFields)t.destroy();e.destroy()}this._inputFieldCache=[]}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===t&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i);for(const n of this._expressionInvalidationCallbacks)n();this._emitChangeEvent(e)}_registerExpression(e){const{_expressionInvalidationCallbacks:t}=this;return t.add(e),s((()=>t.delete(e)))}_getCompiledExpression(e){return this._compiledExpressionLookup.get(this._expressionLookup.get(e))}async _getOrMakeCompiledExpression(e){{if(a(e)||""===e)return null;const t=this._expressionLookup.get(e)??this._addToExpressionLookup(e);if(this._compiledExpressionLookup.has(t))return this._compiledExpressionLookup.get(t);this._arcade||(this._arcade=await g());const i=this._arcade.arcadeUtils;return!this._arcadeGeometryOperationsEnabled&&i.hasGeometryOperations(t)&&(await i.enableGeometryOperations(),this._arcadeGeometryOperationsEnabled=!0),this._addToCompiledExpressionLookup(t)}}_addToCompiledExpressionLookup(e){const{_arcade:{arcadeUtils:t},_compiledExpressionLookup:i}=this,n=t.createFunction(e);return i.set(e,n),n}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:i}=this,n=(l(i)&&l(i.expressionInfos)?Object.values(i.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(E.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(a(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const s=t.get(e),o=l,r=[s.name,o.name].sort().join("|");if(n.has(r))continue;i.push([s,o]),n.add(r),t.set(e,o)}else t.set(e,l);const s=new Set(i.flat()),o=new Set(e);for(const l of s)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(i.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of i){const e=a.get(l),t=a.get(u);if(e===t)continue;const i=r.get(e),n=r.get(t);for(const s of n)i.add(s),a.set(s,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),r=new Map;for(const a of i.contingencies){const[e]=this._hashContingency(a,s.codedValueFields,!0);r.has(e)?r.get(e).push(a):r.set(e,[a])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(r,i):r.get(i);if(r.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,r.get(j),s.codedValueFields)),!a(o))for(const r of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,s.rangeFields):this._joinContingencies(r,t);if(a(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}r=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,r.get(j),s.codedValueFields)),!a(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:c,bothAreAny:p,leftIsRange:d,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(l||p)continue;if(r&&c||a&&u){n.values[s]=new f({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{const n=t.values[i],s=e.values[i];return"any"===n.objectType||"any"===s.objectType||n.codedValue?.code===s.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,r=new Set,l=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,i=!1){if(t.length<1)return[x,!1];const n=[];let s=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${w}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([p({readOnly:!0})],I.prototype,"allInputFields",null),e([p()],I.prototype,"_layerFieldsByName",null),e([p()],I.prototype,"_inputFieldCache",void 0),e([p()],I.prototype,"contingencyConstraintViolations",void 0),e([p()],I.prototype,"feature",null),e([p()],I.prototype,"fieldsWithContingentValues",null),e([p({type:h})],I.prototype,"formTemplate",null),e([p({readOnly:!0})],I.prototype,"inputFields",null),e([p()],I.prototype,"joinedContingentValues",null),e([p()],I.prototype,"layer",null),e([p()],I.prototype,"messages",void 0),e([p()],I.prototype,"spatialReference",null),e([p()],I.prototype,"state",null),e([p()],I.prototype,"strict",void 0),e([p()],I.prototype,"submittable",null),e([p()],I.prototype,"valid",null),e([p()],I.prototype,"getValues",null),e([p()],I.prototype,"submit",null),I=e([d(b)],I);const T=e=>!!e.inputFields,k=e=>"group"===e.type,A=(e,t,i)=>{l(t)&&e.set(t,i)},M=I;export{M 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{makeHandle as r}from"../../core/handleUtils.js";import{isSome as s,isNone as n,get as o}from"../../core/maybe.js";import{watch as l,syncAndInitial as a}from"../../core/reactiveUtils.js";import{generateUID as u}from"../../core/uid.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as h,DomainValidationError as m,getDomainRange as f}from"../../layers/support/domainUtils.js";import{isNumericField as y,isStringField as g,isDateField as v,TypeValidationError as E,validateFieldValue as b,getFeatureEditFields as x,getFeatureGeometryFields as _,NumericRangeValidationError as F,getFieldRange as T}from"../../layers/support/fieldUtils.js";import{substitute as V}from"../../intl/substitute.js";var U,O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(U||(U={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(O||(O={}));const R={type:"number"},j={type:"number",intlOptions:{notation:"scientific"}},D={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};function A(e){return e>=1e7||e<=-1e7}const w=["editable","required","value","visibility"];let N=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this._expressionTrackingHandles=new Map,this.arcade=null,this.editableFunction=null,this.id=u().toString(),this.requiredFunction=null,this.expressionTrackingProvider={registerExpression:()=>r()},this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){const e=e=>"value"!==e,t=w.filter(e);this.own(t.map((e=>l((()=>this.get(`${e}Function`)),(t=>{s(t)?this._registerExpressionWithTrackingProvider(e):this._unregisterExpressionWithTrackingProvider(e)}),a))))}get _configAllowsEdits(){const{fieldElement:e,layer:t,name:i}=this;if(s(e))return e.editableExpression?this.evaluatedEditableExpression:!1!==e.editable;return("subtype-group"!==t?.type?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null)?.isEditable??!0}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return t?.capabilities.operations.supportsEditing&&e?.editable}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e,spatialReference:t}=this;if(n(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedRequiredExpression(){const{requiredFunction:e,spatialReference:t}=this;if(n(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedVisibilityExpression(){const{visibilityFunction:e,spatialReference:t}=this;if(n(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedValueExpression(){const{valueFunction:e,spatialReference:t}=this;if(n(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){const{typeIdField:e}=this.layer,t=e===this.name,i=this.field?.domain;if(t&&!i){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new c({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:r}=this,n=e&&this.layer.getFieldDomain(this.name,{feature:r})||i,l=o(this.fieldElement,"domain");return s(l)&&this._isDomainCompatible(l)?l:n}get editable(){return!!this._layerFieldAllowsEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){const{fieldElement:e}=this,t=s(e)&&"datetime-picker"===e.input?.type?e.input.includeTime:void 0;return void 0===t||t}get label(){return s(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===U.Date)return e;const{field:t,fieldElement:i}=this,r=t?.length,n=s(i)&&k(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===U.Date)return e;const{field:t,fieldElement:i}=this,r=t?.length,n=s(i)&&k(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:r}=this;return!!e&&(!1===i?.nullable||!(!r||!s(t))&&t)}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get submittable(){const{field:e,required:t,valid:i,value:r}=this;return(!t||!n(r))&&(!!i||this.initialFeature.getAttribute(e.name)===r)}get type(){const{field:e}=this;return y(e)?U.Number:g(e)?U.Text:v(e)?U.Date:U.Unsupported}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._shouldUseValueExpression()){const e=this.evaluatedValueExpression;return this.type===U.Date&&e instanceof Date?e.getTime():s(e)&&"object"==typeof e?e.toString():e}return this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(s(this.fieldElement)?this.evaluatedVisibilityExpression??!0:this._isVisibleByDefault())}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&g(t)||"number"===i&&y(t))return!0}return!!("range"===e?.type&&y(t)||v(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:r,required:s,type:n,valid:o,value:l}=this,a=s&&null===l,u=void 0!==o;return!a&&i.getAttribute(t.name)===l&&u?null:a?E.INVALID_TYPE:"text"===n&&r>-1&&"string"==typeof l&&l.length<r?O.TOO_SHORT:e?null!==l||s?h(e,l):null:b(t,l)}_isVisibleByDefault(){const e=this.field?.type;return"oid"!==e&&"global-id"!==e&&!this._isGeometryField()}_isEditorField(){return x(this.layer).includes(this.name)}_isGeometryField(){return _(this.layer).includes(this.name)}_shouldUseValueExpression(){const e=this._layerFieldAllowsEdits&&!this._configAllowsEdits&&s(this.valueFunction);return e?this._registerExpressionWithTrackingProvider("value"):this._unregisterExpressionWithTrackingProvider("value"),e}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:r,value:s,required:n,type:o}=this,l=this.error;if(n&&null===s)return i.validationErrors.cannotBeNull;if(l===m.VALUE_OUT_OF_RANGE||l===F.OUT_OF_RANGE){const r=f(e)||T(t);return V(i.validationErrors.outsideRange,r,{format:{max:"date"===o?D:A(r.max)?j:R,min:"date"===o?D:A(r.min)?j:R}})}return l===m.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:l===E.INVALID_TYPE?i.validationErrors.invalidType:l===O.TOO_SHORT?V(i.validationErrors.tooShort,{min:r}):null}_registerExpressionWithTrackingProvider(e){const{_expressionTrackingHandles:t}=this;if(t.has(e))return;const i=`evaluated${C(e)}Expression`,r=this.expressionTrackingProvider.registerExpression((()=>this.notifyChange(i)));t.set(e,r)}_unregisterExpressionWithTrackingProvider(e){const{_expressionTrackingHandles:t}=this,i=t.get(e);i&&(i.remove(),t.delete(e))}};function k(e){return!!e&&"maxLength"in e}e([p()],N.prototype,"_storedValue",void 0),e([p()],N.prototype,"_configAllowsEdits",null),e([p()],N.prototype,"_layerFieldAllowsEdits",null),e([p()],N.prototype,"arcade",void 0),e([p()],N.prototype,"editableFunction",void 0),e([p()],N.prototype,"requiredFunction",void 0),e([p()],N.prototype,"expressionTrackingProvider",void 0),e([p()],N.prototype,"valueFunction",void 0),e([p()],N.prototype,"isUsingValueExpression",null),e([p()],N.prototype,"visibilityFunction",void 0),e([p()],N.prototype,"evaluatedEditableExpression",null),e([p()],N.prototype,"evaluatedRequiredExpression",null),e([p()],N.prototype,"evaluatedVisibilityExpression",null),e([p()],N.prototype,"evaluatedValueExpression",null),e([p()],N.prototype,"feature",void 0),e([p()],N.prototype,"field",void 0),e([p()],N.prototype,"fieldElement",void 0),e([p()],N.prototype,"initialFeature",null),e([p()],N.prototype,"layer",void 0),e([p({aliasOf:"fieldElement.description"})],N.prototype,"description",void 0),e([p()],N.prototype,"domain",null),e([p()],N.prototype,"editable",null),e([p({aliasOf:"fieldElement.input.type"})],N.prototype,"inputType",void 0),e([p({readOnly:!0})],N.prototype,"error",void 0),e([p({dependsOn:["error","messages","value"]})],N.prototype,"errorMessage",null),e([p()],N.prototype,"group",void 0),e([p({aliasOf:"fieldElement.hint"})],N.prototype,"hint",void 0),e([p()],N.prototype,"includeTime",null),e([p()],N.prototype,"label",null),e([p()],N.prototype,"maxLength",null),e([p()],N.prototype,"minLength",null),e([p()],N.prototype,"messages",void 0),e([p({aliasOf:"field.name"})],N.prototype,"name",void 0),e([p()],N.prototype,"required",null),e([p()],N.prototype,"spatialReference",null),e([p()],N.prototype,"submittable",null),e([p()],N.prototype,"type",null),e([p()],N.prototype,"valid",null),e([p({value:null})],N.prototype,"value",null),e([p()],N.prototype,"visible",null),N=e([d("esri.widgets.FeatureForm.InputField")],N);const C=e=>e.charAt(0).toUpperCase()+e.slice(1),I=N;export{I as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as r,isNone as s,get as n}from"../../core/maybe.js";import{watch as o,syncAndInitial as l}from"../../core/reactiveUtils.js";import{generateUID as a}from"../../core/uid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as c,DomainValidationError as h,getDomainRange as m}from"../../layers/support/domainUtils.js";import{isNumericField as f,isStringField as y,isDateField as g,TypeValidationError as v,validateFieldValue as E,getFeatureEditFields as _,getFeatureGeometryFields as b,NumericRangeValidationError as x,getFieldRange as F}from"../../layers/support/fieldUtils.js";import{substitute as T}from"../../intl/substitute.js";var V,U;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(V||(V={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(U||(U={}));const O={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},j={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};function D(e){return e>=1e7||e<=-1e7}const A=["editable","required","value","visibility"];let w=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this._expressionTrackingHandles=new Map,this.arcade=null,this.editableFunction=null,this.id=a().toString(),this.requiredFunction=null,this.expressionTrackingProvider=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){const e=e=>"value"!==e,t=A.filter(e);this.own(t.map((e=>o((()=>this.get(`${e}Function`)),(t=>{r(t)?this._registerExpressionWithTrackingProvider(e):this._unregisterExpressionWithTrackingProvider(e)}),l))))}destroy(){for(const e of this._expressionTrackingHandles.values())e.remove()}get _configAllowsEdits(){const{fieldElement:e,layer:t,name:i}=this;if(r(e))return e.editableExpression?this.evaluatedEditableExpression:!1!==e.editable;return("subtype-group"!==t?.type?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null)?.isEditable??!0}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return t?.capabilities.operations.supportsEditing&&e?.editable}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e,spatialReference:t}=this;if(s(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedRequiredExpression(){const{requiredFunction:e,spatialReference:t}=this;if(s(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedVisibilityExpression(){const{visibilityFunction:e,spatialReference:t}=this;if(s(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}get evaluatedValueExpression(){const{valueFunction:e,spatialReference:t}=this;if(s(e))return null;const{arcade:i}=this,r=i.arcadeUtils.getViewInfo({spatialReference:t});return i.arcadeUtils.executeFunction(e,i.arcadeUtils.createExecContext(this.feature,r))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){const{typeIdField:e}=this.layer,t=e===this.name,i=this.field?.domain;if(t&&!i){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new p({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:s}=this,o=e&&this.layer.getFieldDomain(this.name,{feature:s})||i,l=n(this.fieldElement,"domain");return r(l)&&this._isDomainCompatible(l)?l:o}get editable(){return!!this._layerFieldAllowsEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){const{fieldElement:e}=this,t=r(e)&&"datetime-picker"===e.input?.type?e.input.includeTime:void 0;return void 0===t||t}get label(){return r(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,s=t?.length,n=r(i)&&N(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(s===e||n<=s)?n:s}get minLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,s=t?.length,n=r(i)&&N(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(s===e||n<=s)?n:e}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:s}=this;return!!e&&(!1===i?.nullable||!(!s||!r(t))&&t)}set required(e){s(e)?this._clearOverride("required"):this._override("required",e)}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get submittable(){const{field:e,required:t,valid:i,value:r}=this;return(!t||!s(r))&&(!!i||this.initialFeature.getAttribute(e.name)===r)}get type(){const{field:e}=this;return f(e)?V.Number:y(e)?V.Text:g(e)?V.Date:V.Unsupported}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._shouldUseValueExpression()){const e=this.evaluatedValueExpression;return this.type===V.Date&&e instanceof Date?e.getTime():r(e)&&"object"==typeof e?e.toString():e}return this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(r(this.fieldElement)?this.evaluatedVisibilityExpression??!0:this._isVisibleByDefault())}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&f(t))return!0}return!!("range"===e?.type&&f(t)||g(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:r,required:s,type:n,valid:o,value:l}=this,a=s&&null===l,u=void 0!==o;return!a&&i.getAttribute(t.name)===l&&u?null:a?v.INVALID_TYPE:"text"===n&&r>-1&&"string"==typeof l&&l.length<r?U.TOO_SHORT:e?null!==l||s?c(e,l):null:E(t,l)}_isVisibleByDefault(){const e=this.field?.type;return"oid"!==e&&"global-id"!==e&&!this._isGeometryField()}_isEditorField(){return _(this.layer).includes(this.name)}_isGeometryField(){return b(this.layer).includes(this.name)}_shouldUseValueExpression(){const e=this._layerFieldAllowsEdits&&!this._configAllowsEdits&&r(this.valueFunction);return e?this._registerExpressionWithTrackingProvider("value"):this._unregisterExpressionWithTrackingProvider("value"),e}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:r,value:s,required:n,type:o}=this,l=this.error;if(n&&null===s)return i.validationErrors.cannotBeNull;if(l===h.VALUE_OUT_OF_RANGE||l===x.OUT_OF_RANGE){const r=m(e)||F(t);return T(i.validationErrors.outsideRange,r,{format:{max:"date"===o?j:D(r.max)?R:O,min:"date"===o?j:D(r.min)?R:O}})}return l===h.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:l===v.INVALID_TYPE?i.validationErrors.invalidType:l===U.TOO_SHORT?T(i.validationErrors.tooShort,{min:r}):null}_registerExpressionWithTrackingProvider(e){const{_expressionTrackingHandles:t,expressionTrackingProvider:i}=this;if(s(i)||t.has(e))return;const r=`evaluated${k(e)}Expression`,n=i.registerExpression((()=>this.notifyChange(r)));t.set(e,n)}_unregisterExpressionWithTrackingProvider(e){const{_expressionTrackingHandles:t}=this,i=t.get(e);i&&(i.remove(),t.delete(e))}};function N(e){return!!e&&"maxLength"in e}e([u()],w.prototype,"_storedValue",void 0),e([u()],w.prototype,"_configAllowsEdits",null),e([u()],w.prototype,"_layerFieldAllowsEdits",null),e([u()],w.prototype,"arcade",void 0),e([u()],w.prototype,"editableFunction",void 0),e([u()],w.prototype,"requiredFunction",void 0),e([u()],w.prototype,"expressionTrackingProvider",void 0),e([u()],w.prototype,"valueFunction",void 0),e([u()],w.prototype,"isUsingValueExpression",null),e([u()],w.prototype,"visibilityFunction",void 0),e([u()],w.prototype,"evaluatedEditableExpression",null),e([u()],w.prototype,"evaluatedRequiredExpression",null),e([u()],w.prototype,"evaluatedVisibilityExpression",null),e([u()],w.prototype,"evaluatedValueExpression",null),e([u()],w.prototype,"feature",void 0),e([u()],w.prototype,"field",void 0),e([u()],w.prototype,"fieldElement",void 0),e([u()],w.prototype,"initialFeature",null),e([u()],w.prototype,"layer",void 0),e([u({aliasOf:"fieldElement.description"})],w.prototype,"description",void 0),e([u()],w.prototype,"domain",null),e([u()],w.prototype,"editable",null),e([u({aliasOf:"fieldElement.input.type"})],w.prototype,"inputType",void 0),e([u({readOnly:!0})],w.prototype,"error",void 0),e([u({dependsOn:["error","messages","value"]})],w.prototype,"errorMessage",null),e([u()],w.prototype,"group",void 0),e([u({aliasOf:"fieldElement.hint"})],w.prototype,"hint",void 0),e([u()],w.prototype,"includeTime",null),e([u()],w.prototype,"label",null),e([u()],w.prototype,"maxLength",null),e([u()],w.prototype,"minLength",null),e([u()],w.prototype,"messages",void 0),e([u({aliasOf:"field.name"})],w.prototype,"name",void 0),e([u()],w.prototype,"required",null),e([u()],w.prototype,"spatialReference",null),e([u()],w.prototype,"submittable",null),e([u()],w.prototype,"type",null),e([u()],w.prototype,"valid",null),e([u({value:null})],w.prototype,"value",null),e([u()],w.prototype,"visible",null),w=e([d("esri.widgets.FeatureForm.InputField")],w);const k=e=>e.charAt(0).toUpperCase()+e.slice(1),q=w;export{q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{HandleOwnerMixin as t}from"../../core/HandleOwner.js";import{
|
|
5
|
+
import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{HandleOwnerMixin as t}from"../../core/HandleOwner.js";import{isSome as s,isNone as r,unwrap as o}from"../../core/maybe.js";import{watch as n,syncAndInitial as l}from"../../core/reactiveUtils.js";import{aliasOf as p}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";const u=["visibility"];let d=class extends(t(e)){constructor(i){super(i),this._expressionTrackingHandles=new Map,this.arcade=null,this.visibilityExpression=null,this.description=null,this.expressionTrackingProvider=null,this.feature=null,this.groupElement=null,this.label=null,this.spatialReference=null}initialize(){this.own([...u.map((i=>n((()=>this.get(`${i}Function`)),(e=>{s(e)?this._registerExpressionWithTrackingProvider(i):this._unregisterExpressionWithTrackingProvider(i)}),l))),n((()=>[this.visible,this.inputFields]),(([i])=>{const{inputFields:e}=this,t=!!i&&void 0;for(const s of e)s.required=t}),{initial:!0,equals:(i,e)=>e[0]===i[0]&&e[1]===i[1]})])}destroy(){for(const i of this._expressionTrackingHandles.values())i.remove()}set visibilityFunction(i){this._set("visibilityFunction",i),s(i)?this._registerExpressionWithTrackingProvider("visibility"):this._unregisterExpressionWithTrackingProvider("visibility")}get evaluatedVisibilityExpression(){const{visibilityFunction:i,spatialReference:e}=this;if(r(i))return;const{arcade:t}=this,s=t.arcadeUtils.getViewInfo({spatialReference:o(e)});return t.arcadeUtils.executeFunction(i,t.arcadeUtils.createExecContext(this.feature,s))}get inputFields(){return this._get("inputFields")}set inputFields(i){this.handles.removeAll(),i&&this.handles.add(i.map((i=>n((()=>i.visible),(()=>this._dirtyEvaluatedVisibilityExpression()))))),this._set("inputFields",i)}get state(){return s(this.groupElement)&&this.groupElement.initialState||"expanded"}set state(i){r(i)?this._clearOverride("state"):this._override("state",i)}get visible(){return!1!==this.evaluatedVisibilityExpression&&this.inputFields&&this.inputFields.some((i=>i.visible))}_registerExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e,expressionTrackingProvider:t}=this;if(r(t)||e.has(i))return;const s=`evaluated${h(i)}Expression`,o=t.registerExpression((()=>this.notifyChange(s)));e.set(i,o)}_unregisterExpressionWithTrackingProvider(i){const{_expressionTrackingHandles:e}=this,t=e.get(i);t&&(t.remove(),e.delete(i))}_dirtyEvaluatedVisibilityExpression(){const{groupElement:i}=this;s(i)&&i.visibilityExpression&&this.notifyChange("evaluatedVisibilityExpression")}};i([a()],d.prototype,"arcade",void 0),i([p("groupElement.visibilityExpression")],d.prototype,"visibilityExpression",void 0),i([a()],d.prototype,"visibilityFunction",null),i([a()],d.prototype,"evaluatedVisibilityExpression",null),i([p("groupElement.description")],d.prototype,"description",void 0),i([a()],d.prototype,"expressionTrackingProvider",void 0),i([a()],d.prototype,"feature",void 0),i([a()],d.prototype,"groupElement",void 0),i([a()],d.prototype,"inputFields",null),i([p("groupElement.label")],d.prototype,"label",void 0),i([a()],d.prototype,"spatialReference",void 0),i([a()],d.prototype,"state",null),i([a()],d.prototype,"visible",null),d=i([c("esri.widgets.FeatureForm.InputFieldGroup")],d);const h=i=>i.charAt(0).toUpperCase()+i.slice(1),v=d;export{v 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import t from"../../core/Handles.js";import{watch as s,initial as a,when as n}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import y from"./support/ActiveLayerInfo.js";import{onLocaleChange as d}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},c=r.ofType(y),L=["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer"],_="view.basemapView.baseLayerViews",f="view.groundView.layerViews",u="view.basemapView.referenceLayerViews",p=[_,f,"view.layerViews",u];let v=class extends i{constructor(e){super(e),this._handles=new t,this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new c,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this._handles.add(s((()=>this.view),(()=>this._viewHandles()),a),h.view),this._handles.add(d((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this._handles.destroy(),this._handles=null,this.view=null}get state(){return this.get("view.ready")?"ready":"disabled"}_viewHandles(){this._handles.remove(h.state),this.view&&this._handles.add(s((()=>this.state),(()=>this._stateHandles()),a),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this._handles.remove([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this._handles.remove(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i&&i.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{allLayerViews:e}=this.view;e.length&&this._refresh(),this._handles.add(e.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this._handles.add(s((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh()}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){if(e.length<2)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const r={};this.view.allLayerViews.forEach(((e,i)=>r[e.layer.uid]=i)),e.sort(((e,i)=>{const t=r[e.layer.uid]||0;return(r[i.layer.uid]||0)-t}))}_generateLayerViews(){const e=[];return p.filter(this._filterLayerViews,this).map(this.get,this).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===_||e===u),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!L.includes(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this._handles.remove(e.uid),this._handles.add(s((()=>[e.legendEnabled,e.layer
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import t from"../../core/Handles.js";import{watch as s,initial as a,when as n}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import y from"./support/ActiveLayerInfo.js";import{onLocaleChange as d}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},c=r.ofType(y),L=["esri.layers.BuildingSceneLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer"],_="view.basemapView.baseLayerViews",f="view.groundView.layerViews",u="view.basemapView.referenceLayerViews",p=[_,f,"view.layerViews",u];let v=class extends i{constructor(e){super(e),this._handles=new t,this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new c,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this._handles.add(s((()=>this.view),(()=>this._viewHandles()),a),h.view),this._handles.add(d((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this._handles.destroy(),this._handles=null,this.view=null}get state(){return this.get("view.ready")?"ready":"disabled"}_viewHandles(){this._handles.remove(h.state),this.view&&this._handles.add(s((()=>this.state),(()=>this._stateHandles()),a),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this._handles.remove([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this._handles.remove(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i&&i.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{allLayerViews:e}=this.view;e.length&&this._refresh(),this._handles.add(e.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this._handles.add(s((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh()}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){if(e.length<2)return;const i=[];e.forEach((r=>{if(!r.parent){const t=r.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(i.push(r),r.parent=a,a.children.add(r),this._sortActiveLayerInfos(a.children))}})),e.removeMany(i);const r={};this.view.allLayerViews.forEach(((e,i)=>r[e.layer.uid]=i)),e.sort(((e,i)=>{const t=r[e.layer.uid]||0;return(r[i.layer.uid]||0)-t}))}_generateLayerViews(){const e=[];return p.filter(this._filterLayerViews,this).map(this.get,this).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===_||e===u),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!L.includes(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this._handles.remove(e.uid),this._handles.add(s((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this._handles.remove(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.get("layer.legendEnabled")}_buildActiveLayerInfo(e){const i=e.layer,r=e.uid,t=this._layerInfosByLayerViewId[r];let o=this._activeLayerInfosByLayerViewId[r];if(!o){const s=t&&void 0!==t.title&&t.layer.uid===i.uid;o=new y({layer:i,layerView:e,title:s?t.title:i.title,view:this.view,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:t&&t.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[r]=o}const l=i.parent&&"uid"in i.parent&&this._layerViewByLayerId[i.parent?.uid];if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this._handles.has(r)){const t=[s((()=>i.title),(e=>this._titleHandle(e,o))),s((()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol]),(()=>this._constructLegendElements(o))),n((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),a),s((()=>e._effectiveRenderer),(()=>this._constructLegendElements(o))),s((()=>"effect"in i&&i.effect),(()=>this._constructLegendElements(o)))];if(this.respectLayerVisibility){const r=s((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),a=s((()=>i.legendEnabled),(e=>this._legendEnabledHandle(e,o)));t.push(r,a)}this._handles.add(t,r)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some((e=>e.layer.uid===r.uid));r.parent&&"uid"in r.parent&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((i=>{const r=i.layer.parent,t=r&&"uid"in r&&this._layerViewByLayerId[r?.uid],s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const i=e.layer;"featureCollections"in i&&i.featureCollections?e.buildLegendElementsForFeatureCollections(i.featureCollections):"featureReduction"in i&&"binning"===i.featureReduction?.type&&"renderer"in i.featureReduction?e.buildLegendElementsForRenderer(i.featureReduction.renderer):"renderer"in i&&i.renderer?e.buildLegendElementsForRenderer(i.renderer):"url"in i&&i.url?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([o({type:c})],v.prototype,"activeLayerInfos",void 0),e([o()],v.prototype,"basemapLegendVisible",void 0),e([o()],v.prototype,"groundLegendVisible",void 0),e([o()],v.prototype,"hideLayersNotInCurrentView",void 0),e([o()],v.prototype,"keepCacheOnDestroy",void 0),e([o()],v.prototype,"respectLayerVisibility",void 0),e([o()],v.prototype,"layerInfos",void 0),e([o({readOnly:!0})],v.prototype,"state",null),e([o()],v.prototype,"view",void 0),v=e([l("esri.widgets.Legend.LegendViewModel")],v);const I=v;export{I as default};
|