@arcgis/core 4.30.0 → 4.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{c39237c00c1d588dc107.js → 25c41ceb1951d80f4798.js} +1 -1
- package/assets/esri/core/workers/chunks/61500e48a3d672445e14.js +1 -0
- package/assets/esri/core/workers/chunks/{f13fb6b712e364bbf48c.js → 61e1f1564a8440f186e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{70ebc0e38eb1cfb79320.js → 85701ca4ebc2de529053.js} +1 -1
- package/assets/esri/core/workers/chunks/88e8547079b299572bfe.js +1 -0
- package/assets/esri/core/workers/chunks/{403f73017bf763f7471c.js → 91f8f99c6f64e85458f3.js} +1 -1
- package/assets/esri/core/workers/chunks/{37dfb3ff86c4ef1b26c1.js → a9efe7abda35995d0dd8.js} +1 -1
- package/assets/esri/core/workers/chunks/{4cf5414d67aa888f2322.js → d502a5fe47e77d63ae5e.js} +1 -1
- package/assets/esri/core/workers/chunks/d6c954272cc96d6b7987.js +1 -0
- package/assets/esri/core/workers/chunks/{aa198e898b46c6e89d0b.js → e2c927ef4d88a0a8104b.js} +1 -1
- package/assets/esri/core/workers/chunks/{880e8329e264b6156fbc.js → e3a049ebcb0b89f16228.js} +1 -1
- package/assets/esri/core/workers/chunks/{f927c28f2fa78ec68235.js → ed9c88afccc5041d899a.js} +1 -1
- package/assets/esri/core/workers/chunks/{31f7a3c8e1a5b4ca4a73.js → fb97d6cc841c67c09d5c.js} +1 -1
- package/assets/esri/themes/base/widgets/_Grid.scss +3 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/persistableUrlUtils.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/interfaces.d.ts +94 -50
- package/kernel.js +1 -1
- package/layers/CatalogLayer.js +1 -1
- package/layers/mixins/EditBusLayer.js +1 -1
- package/layers/support/MediaElementBase.js +1 -1
- package/package.json +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/portal/support/urlUtils.js +1 -1
- package/rest/imageService/fetchRasterInfo.js +1 -1
- package/support/persistableUrlUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/assets/esri/core/workers/chunks/20d447aa01a66a464363.js +0 -1
- package/assets/esri/core/workers/chunks/2b39f50b92fe27c30497.js +0 -1
- package/assets/esri/core/workers/chunks/8865ca9cb8d867d48d2d.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{parse as t}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as a}from"../../layers/support/LayerLoadContext.js";import{populateGroupLayer as o}from"../../layers/support/layersCreator.js";import{layerLookupMap as n}from"../../layers/support/lazyLayerLoader.js";import s from"../Portal.js";import{createForItemRead as
|
|
5
|
+
import e from"../../core/Error.js";import{parse as t}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as a}from"../../layers/support/LayerLoadContext.js";import{populateGroupLayer as o}from"../../layers/support/layersCreator.js";import{layerLookupMap as n}from"../../layers/support/lazyLayerLoader.js";import s from"../Portal.js";import{createForItemRead as l}from"./jsonContext.js";import{getFirstLayerOrTable as i,preprocessFSItemData as c,populateSceneServiceItemData as u,getNumLayersAndTables as p,createSublayerData as y,instanceTypeToLayerType as f,getSublayersByLayerType as m,layerTypeToLayerModuleType as d}from"./loadUtils.js";import{hasTypeKeyword as w}from"./portalItemUtils.js";import{loadStyleRenderer as h}from"../../renderers/support/styleUtils.js";import{fetchArcGISServiceJSON as I}from"../../support/requestPresets.js";async function b(e,t){const r=e.instance.portalItem;if(r?.id)return await r.load(t),g(e),e.validateItem&&e.validateItem(r),L(e,t)}function g(t){const r=t.instance.portalItem;if(!r?.type||!t.supportedTypes.includes(r.type))throw new e("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}'",{type:r?.type,expectedType:t.supportedTypes.join(", ")})}async function L(e,t){const r=e.instance,o=r.portalItem;if(!o)return;const{url:n,title:s}=o,i=l(o,"portal-item");if("group"===r.type)return S(r,i,e);n&&"media"!==r.type&&r.read({url:n},i);const c=new a,u=await M(e,c,t);return u&&r.read(u,i),r.resourceReferences={portalItem:o,paths:i.readResourcePaths??[]},"subtype-group"!==r.type&&r.read({title:s},i),h(r,i)}async function S(t,r,a){const o=t.portalItem;if(!t.sourceIsPortalItem)return;const{title:n,type:s}=o;if("Group Layer"===s){if(!w(o,"Map"))throw new e("portal:invalid-layer-item-typekeyword","'Group Layer' item without 'Map' type keyword is not supported");return v(t)}return t.read({title:n},r),T(t,a)}async function v(e){const t=e.portalItem,r=await t.fetchData("json");if(!r)return;const a=l(t,"web-map");e.read(r,a),await o(e,r,{context:a}),e.resourceReferences={portalItem:t,paths:a.readResourcePaths??[]}}async function T(t,r){let o;const{portalItem:n}=t;if(!n)return;const s=n.type,l=r.layerModuleTypeMap;switch(s){case"Feature Service":case"Feature Collection":o=l.FeatureLayer;break;case"Stream Service":o=l.StreamLayer;break;case"Scene Service":o=l.SceneLayer;break;default:throw new e("portal:unsupported-item-type-as-group",`The item type '${s}' is not supported as a 'IGroupLayer'`)}const y=new a;let[f,m]=await Promise.all([o(),M(r,y)]),d=()=>f;if("Feature Service"===s){const e=i(m)?.customParameters;m=n.url?await c(m,n.url,y):{},d=await E(m,l)||d;const r=await k(n.url,{customParameters:e,loadContext:y});return await P(t,d,m,r)}return"Scene Service"===s&&n.url&&(m=await u(n,m,y)),p(m)>0?await P(t,d,m):await j(t,d)}async function j(e,t){const{portalItem:r}=e;if(!r?.url)return;const a=await I(r.url);a&&P(e,t,{layers:a.layers?.map(y),tables:a.tables?.map(y)})}async function P(e,t,r,a){let o=r.layers||[];const s=r.tables||[];if("Feature Collection"===e.portalItem?.type?(o.forEach(((e,t)=>{e.id=t,"Table"===e?.layerDefinition?.type&&s.push(e)})),o=o.filter((e=>"Table"!==e?.layerDefinition?.type))):(o.reverse(),s.reverse()),o.forEach((o=>{const n=a?.(o);if(n||!a){const a=F(e,t(o),r,o,n);e.add(a)}})),s.length){const t=await n.FeatureLayer();s.forEach((o=>{const n=a?.(o);if(n||!a){const a=F(e,t,r,o,n);e.tables.add(a)}}))}}function F(e,t,r,a,o){const n=e.portalItem,l={portalItem:n.clone(),layerId:a.id};null!=a.url&&(l.url=a.url);const i=new t(l);if("sourceJSON"in i&&(i.sourceJSON=o),"subtype-group"!==i.type&&"catalog"!==i.type&&(i.sublayerTitleMode="service-name"),"Feature Collection"===n.type){const e={origin:"portal-item",portal:n.portal||s.getDefault()};i.read(a,e);const t=r.showLegend;null!=t&&i.read({showLegend:t},e)}return i}async function M(e,t,r){if(!1===e.supportsData)return;const a=e.instance,o=a.portalItem;if(!o)return;let n=null;try{n=await o.fetchData("json",r)}catch(s){}if(D(a)){let e=null;const r=await x(o,n,t);if((n?.layers||n?.tables)&&r>0){if(null==a.layerId){const e=f(a.type),t=e?m(n,e)[0]:i(n);t&&(a.layerId=t.id)}e=C(n,a),e&&null!=n.showLegend&&(e.showLegend=n.showLegend)}return r>1&&"sublayerTitleMode"in a&&"service-name"!==a.sublayerTitleMode&&(a.sublayerTitleMode="item-title-and-service-name"),e}return n}async function x(e,r,a){if(r?.layers&&r?.tables)return p(r);const o=t(e.url);if(!o)return 1;const n=await a.fetchServiceMetadata(o.url.path,{customParameters:i(r)?.customParameters}).catch((()=>null));return(r?.layers?.length??n?.layers?.length??0)+(r?.tables?.length??n?.tables?.length??0)}function C(e,t){const{layerId:r}=t,a=e.layers?.find((e=>e.id===r))||e.tables?.find((e=>e.id===r));return a&&G(a,t)?a:null}function D(e){return"stream"!==e.type&&"layerId"in e}function G(e,t){const r="layerType"in e&&e.layerType,{type:a}=t;return!("feature"===a&&r&&"ArcGISFeatureLayer"!==e.layerType||"catalog"===a&&!r||"oriented-imagery"===a&&!r||"subtype-group"===a&&!r)}async function k(e,t){const{layersJSON:a}=await r(e,t);if(!a)return null;const o=[...a.layers,...a.tables];return e=>o.find((t=>t.id===e.id))}async function E(e,t){const{layers:r}=e;if(!r?.length)return;const a=new Set,o=[];for(const{layerType:l}of r){const e=l??"ArcGISFeatureLayer";if(a.has(e))continue;a.add(e);const r=t[d(e)];o.push(r())}const n=await Promise.all(o),s=new Map;return Array.from(a).forEach(((e,t)=>{s.set(e,n[t])})),({layerType:e})=>{const t=e??"ArcGISFeatureLayer";return s.get(t)}}export{b as load};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{findAssociatedFeatureService as e}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";function t(e){const t={id:e.id,name:e.name},a=r(e.type);return"FeatureLayer"!==a&&(t.layerType=a),t}async function a(e,r,a){if(null==e?.layers||null==e?.tables){const l=await a.fetchServiceMetadata(r,{customParameters:s(e)?.customParameters});(e=e||{}).layers=e.layers||l?.layers?.map(t),e.tables=e.tables||l?.tables?.map(t)}return e}function s(e){if(!e)return null;const{layers:r,tables:t}=e;return r?.length?r[0]:t?.length?t[0]:null}function l(e,r){if(null==r)return null;return[...e.layers||[],...e.tables||[]].find((e=>e.id===r))}function n(e,r){return[...e.layers||[],...e.tables||[]].filter((({layerType:e})=>
|
|
5
|
+
import{findAssociatedFeatureService as e}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";function t(e){const t={id:e.id,name:e.name},a=r(e.type);return"FeatureLayer"!==a&&(t.layerType=a),t}async function a(e,r,a){if(null==e?.layers||null==e?.tables){const l=await a.fetchServiceMetadata(r,{customParameters:s(e)?.customParameters});(e=e||{}).layers=e.layers||l?.layers?.map(t),e.tables=e.tables||l?.tables?.map(t)}return e}function s(e){if(!e)return null;const{layers:r,tables:t}=e;return r?.length?r[0]:t?.length?t[0]:null}function l(e,r){if(null==r)return null;return[...e.layers||[],...e.tables||[]].find((e=>e.id===r))}function n(e,r){return[...e.layers||[],...e.tables||[]].filter((({layerType:e})=>e?e===r:"ArcGISFeatureLayer"===r))}function u(e){return(e?.layers?.length??0)+(e?.tables?.length??0)}function c(e){switch(e){case"catalog":return"CatalogLayer";case"feature":return"ArcGISFeatureLayer";case"oriented-imagery":return"OrientedImageryLayer";case"subtype-group":return"SubtypeGroupLayer"}return null}function i(e){switch(e){case"CatalogLayer":return"CatalogLayer";case"OrientedImageryLayer":return"OrientedImageryLayer";case"SubtypeGroupLayer":return"SubtypeGroupLayer"}return"FeatureLayer"}async function o(r,a,l){if(!r?.url)return a??{};if(a??={},!a.layers){const e=await l.fetchServiceMetadata(r.url);a.layers=e.layers?.map(t)}const{serverUrl:n,portalItem:u}=await e(r.url,{sceneLayerItem:r,customParameters:s(a)?.customParameters}).catch((()=>({serverUrl:null,portalItem:null})));if(null==n)return a.tables=[],a;if(!a.tables&&u){const e=await u.fetchData();if(e?.tables)a.tables=e.tables.map(t);else{const r=await l.fetchServiceMetadata(n,{customParameters:s(e)?.customParameters});a.tables=r?.tables?.map(t)}}if(a.tables)for(const e of a.tables)e.url=`${n}/${e.id}`;return a}export{t as createSublayerData,s as getFirstLayerOrTable,l as getLayerOrTable,u as getNumLayersAndTables,n as getSublayersByLayerType,c as instanceTypeToLayerType,i as layerTypeToLayerModuleType,o as populateSceneServiceItemData,a as preprocessFSItemData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const t=/^https:\/\/([a-z\d-]+)(\.maps([^.]*))?\.arcgis\.com/i,e={devext:{customBaseUrl:"mapsdevext.arcgis.com",portalHostname:"devext.arcgis.com"},qaext:{customBaseUrl:"mapsqa.arcgis.com",portalHostname:"qaext.arcgis.com"},www:{customBaseUrl:"maps.arcgis.com",portalHostname:"www.arcgis.com"}};function s(s){const a=s?.match(t);if(!a)return null;const[,r,c,o]=a;if(!r)return null;let l=null,m=null,n=null;const{devext:u,qaext:i,www:p}=e;if(c)if(l=r,o)switch(o.toLowerCase()){case"devext":({customBaseUrl:m,portalHostname:n}=u);break;case"qa":({customBaseUrl:m,portalHostname:n}=i);break;default:return null}else({customBaseUrl:m,portalHostname:n}=p);else switch(r.toLowerCase()){case"devext":({customBaseUrl:m,portalHostname:n}=u);break;case"qaext":({customBaseUrl:m,portalHostname:n}=i);break;case"www":({customBaseUrl:m,portalHostname:n}=p);break;default:return null}return{customBaseUrl:m,isPortal:!1,portalHostname:n,urlKey:l}}function a(t){return/\/(sharing|usrsvcs)\/(appservices|servers)\//i.test(t)}function r(t){const e=/^https?:\/\/(?:cdn|[a-z\d-]+\.maps)\.arcgis\.com/i,s=/^https?:\/\/(?:cdndev|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,a=/^https?:\/\/(?:cdnqa|[a-z\d-]+\.mapsqa)\.arcgis\.com/i;return e.test(t)?t=t.replace(e,"https://www.arcgis.com"):s.test(t)?t=t.replace(s,"https://devext.arcgis.com"):a.test(t)&&(t=t.replace(a,"https://qaext.arcgis.com")),t}export{a as isSecureProxyService,r as normalizeArcGISOnlineOrgDomain,s as parseKnownArcGISOnlineDomain,t as reArcGISOnlineDomain};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../request.js";import t from"../../geometry/Extent.js";import a from"../../geometry/Point.js";import l from"../../geometry/SpatialReference.js";import i from"../../layers/support/RasterInfo.js";import{parseUrl as s,encode as
|
|
5
|
+
import e from"../../request.js";import t from"../../geometry/Extent.js";import a from"../../geometry/Point.js";import l from"../../geometry/SpatialReference.js";import i from"../../layers/support/RasterInfo.js";import n from"../../layers/support/RasterStorageInfo.js";import{parseUrl as s,encode as r,asValidOptions as o}from"../utils.js";import u from"../support/FeatureSet.js";async function m(m,f,p){const c=s(m),{rasterFunction:d,sourceJSON:h}=f||{},g=d?JSON.stringify(d.rasterFunctionDefinition||d):null,y=r({...c.query,renderingRule:g,f:"json"}),x=o(y,p);m=c.path;const b=h||await e(m,x).then((e=>e.data)),v=b.hasRasterAttributeTable?e(`${m}/rasterAttributeTable`,x):null,S=b.hasColormap?e(`${m}/colormap`,x):null,V=b.hasHistograms?e(`${m}/histograms`,x):null,D=b.currentVersion>=10.3?e(`${m}/keyProperties`,x):null,I=b.hasMultidimensions?e(`${m}/multidimensionalInfo`,x):null,T=await Promise.allSettled([v,S,V,D,I]);let R=null;if(b.minValues&&b.minValues.length===b.bandCount){R=[];for(let e=0;e<b.minValues.length;e++)R.push({min:b.minValues[e],max:b.maxValues[e],avg:b.meanValues[e],stddev:b.stdvValues[e]})}const j=t.fromJSON(b.extent),w=Math.ceil(j.width/b.pixelSizeX-.1),M=Math.ceil(j.height/b.pixelSizeY-.1),N=l.fromJSON(b.spatialReference||b.extent.spatialReference),J="fulfilled"===T[0].status?T[0].value?.data:null,O=J?.features?.length?u.fromJSON(J):null,k="fulfilled"===T[1].status?T[1].value?.data.colormap:null,C=k?.length?k:null,P="fulfilled"===T[2].status?T[2].value?.data.histograms:null,z=P?.[0]?.counts?.length?P:null,F="fulfilled"===T[3].status?T[3].value?.data??{}:{},$="fulfilled"===T[4].status?T[4].value?.data.multidimensionalInfo:null,H=$?.variables?.length?$:null;H&&H.variables.forEach((e=>{e.statistics?.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))}));const{defaultVariable:L,serviceDataType:A}=b;L&&L!==F.DefaultVariable&&(F.DefaultVariable=L),A?.includes("esriImageServiceDataTypeVector")&&!A.includes(F.DataType)&&(F.DataType=A.replace("esriImageServiceDataType",""));let E=b.noDataValue;b.noDataValues?.length&&b.noDataValues.some((e=>e!==E))&&(E=b.noDataValues);const q=b.transposeInfo?new n({blockWidth:256,blockHeight:256,pyramidBlockWidth:256,pyramidBlockHeight:256,pyramidScalingFactor:2,compression:"lerc",origin:new a({x:b.extent.xmin,y:b.extent.ymax,spatialReference:N}),firstPyramidLevel:1,maximumPyramidLevel:Math.max(0,Math.round(Math.log(Math.max(w,M))/Math.LN2-8)),transposeInfo:b.transposeInfo}):void 0;return new i({width:w,height:M,bandCount:b.bandCount,extent:t.fromJSON(b.extent),spatialReference:N,pixelSize:new a({x:b.pixelSizeX,y:b.pixelSizeY,spatialReference:N}),pixelType:b.pixelType.toLowerCase(),statistics:R,attributeTable:O,colormap:C,histograms:z,keyProperties:F,noDataValue:E,multidimensionalInfo:H,storageInfo:q})}function f(e,t,a){return m(e,{sourceJSON:t},a)}function p(e,t,a){return m(e,{rasterFunction:t},a)}function c(e,t){e.attributeTable||(t.hasRasterAttributeTable=!1),e.histograms||(t.hasHistograms=!1),e.colormap||(t.hasColormap=!1),e.multidimensionalInfo||(t.hasMultidimensions=!1)}export{f as fetchServiceRasterInfo,p as generateRasterInfo,c as patchServiceInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../kernel.js";import"../core/urlUtils.js";export{M as MarkKeep,e as ensureMainOnlineDomain,c as fromCDNUrl,f as fromJSON,i as itemIdFromResourceUrl,p as prefixAndFilenameFromResourceUrl,r as read,a as toCDNUrl,t as toJSON,w as write}from"../chunks/persistableUrlUtils.js";
|
|
5
|
+
import"../kernel.js";import"../core/urlUtils.js";import"../portal/support/urlUtils.js";export{M as MarkKeep,e as ensureMainOnlineDomain,c as fromCDNUrl,f as fromJSON,i as itemIdFromResourceUrl,p as prefixAndFilenameFromResourceUrl,r as read,a as toCDNUrl,t as toJSON,w as write}from"../chunks/persistableUrlUtils.js";
|
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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const b="20240627",c="fe105cb6984889590b420bfd80d8f495c7bec1d9";export{b as buildDate,c 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as t}from"../../../support/FeatureSetReaderJSON.js";class r extends e{constructor(e,t){super(),this.metadata=e,this.removed=new Set,this.overriddenIds=new Set,this._features=[],this.chunkId=t,this.normalizedChunkId=t}get reader(){return t.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate();const{reader:t,removed:r}=e,s=[],d=new Set,o=t.getCursor(),i=new Set(r);for(this.overriddenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),t=e.objectId;s.push(e),d.add(t),this.overriddenIds.add(t),this.removed.delete(t)}for(const n of this._features){const e=n.objectId;i.has(e)||d.has(e)||(s.push(n),this.overriddenIds.add(e))}this._features=s;for(const n of d.values())this.removed.delete(n);for(const n of r)this.removed.add(n),this.overriddenIds.add(n)}removeOverrides(e){const t=e.reader.getCursor(),r=new Set;for(;t.next();){const e=t.getObjectId();this.overriddenIds.has(e)&&(r.add(e),this.overriddenIds.delete(e))}this._features=this._features.filter((e=>!r.has(e.objectId)))}getTileReader(e){if(!this._features.length)return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}export{r as OverrideChunk};
|
|
5
|
+
import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as t}from"../../../support/FeatureSetReaderJSON.js";class r extends e{constructor(e,t){super(),this.metadata=e,this.removed=new Set,this.overriddenIds=new Set,this._features=[],this.chunkId=t,this.normalizedChunkId=t}get reader(){return t.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate();const{reader:t,removed:r}=e,s=[],d=new Set,o=t.getCursor(),i=new Set(r);for(this.overriddenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),t=e.objectId;s.push(e),d.add(t),this.overriddenIds.add(t),this.removed.delete(t)}for(const n of this._features){const e=n.objectId;i.has(e)||d.has(e)||(s.push(n),this.overriddenIds.add(e))}this._features=s;for(const n of d.values())this.removed.delete(n);for(const n of r)this.removed.add(n),this.overriddenIds.add(n)}removeOverrides(e){this.invalidate();const t=e.reader.getCursor(),r=new Set;for(;t.next();){const e=t.getObjectId();this.overriddenIds.has(e)&&(r.add(e),this.overriddenIds.delete(e))}this._features=this._features.filter((e=>!r.has(e.objectId)))}getTileReader(e){if(!this._features.length)return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}export{r as OverrideChunk};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as t}from"./OverrideChunk.js";class n{constructor(s){this._onChange=s,this._chunks=new Map,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),null!=this._localEditChunk&&this._chunksToRemove.push(this._localEditChunk),this._localEditChunk=null}*chunks(){this._localEditChunk&&(yield this._localEditChunk),this._localOverridesChunk&&(yield this._localOverridesChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._localOverridesChunk?.overriddenIds.size&&e.reader.removeIds(this._localOverridesChunk.overriddenIds),this._localEditChunk?.overriddenIds.size&&this._localEditChunk.removeOverrides(e),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyLocalOverrides(e,s){null==this._localOverridesChunk&&(this._localOverridesChunk=new t(s,"localOverride")),this._localOverridesChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._localOverridesChunk.overriddenIds),o.invalidate()}applyLocalEdit(e,s){null==this._localEditChunk&&(this._localEditChunk=new t(s,"localEdit")),this._localEditChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._localEditChunk.overriddenIds),o.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const t=o.reader.getCursor();for(;t.next();){const o=t.getObjectId();s.has(o)||(e(t.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const t=o.reader.getCursor();for(;t.next();){const o=t.getObjectId();s.has(o)||(e(t),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const t of this.chunks()){const n=t.queryFeaturesInBounds(e);for(;n.next();){const e=n.getObjectId();o.has(e)||(s(n.copy()),o.add(e))}}}forEachBounds(e,o){const t=s();for(const s of e){s.getBounds(t)&&o(t)}}}export{n as FeatureSourceChunkStore};
|
|
5
|
+
import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as t}from"./OverrideChunk.js";class n{constructor(s){this._onChange=s,this._chunks=new Map,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),null!=this._localEditChunk&&this._chunksToRemove.push(this._localEditChunk),this._localEditChunk=null}*chunks(){this._localEditChunk&&(yield this._localEditChunk),this._localOverridesChunk&&(yield this._localOverridesChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._localOverridesChunk?.overriddenIds.size&&(e.reader.removeIds(this._localOverridesChunk.overriddenIds),e.invalidate()),this._localEditChunk?.overriddenIds.size&&this._localEditChunk.removeOverrides(e),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyLocalOverrides(e,s){null==this._localOverridesChunk&&(this._localOverridesChunk=new t(s,"localOverride")),this._localOverridesChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._localOverridesChunk.overriddenIds),o.invalidate()}applyLocalEdit(e,s){null==this._localEditChunk&&(this._localEditChunk=new t(s,"localEdit")),this._localEditChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._localEditChunk.overriddenIds),o.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const t=o.reader.getCursor();for(;t.next();){const o=t.getObjectId();s.has(o)||(e(t.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const t=o.reader.getCursor();for(;t.next();){const o=t.getObjectId();s.has(o)||(e(t),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const t of this.chunks()){const n=t.queryFeaturesInBounds(e);for(;n.next();){const e=n.getObjectId();o.has(e)||(s(n.copy()),o.add(e))}}}forEachBounds(e,o){const t=s();for(const s of e){s.getBounds(t)&&o(t)}}}export{n as FeatureSourceChunkStore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as s,isAbortError as r}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as l}from"../../../../core/support/UpdatingHandles.js";import n from"../../../../geometry/Point.js";import h from"../../../../layers/support/PixelBlock.js";import c from"../../../../layers/support/TileInfo.js";import{update as u,unregister as d,getRasterId as p,register as y}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as g,computeProjectedScales as m}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import _ from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import f from"../../tiling/TileQueue.js";import b from"../../tiling/TileStrategy.js";import{tileSize as w}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as I}from"../../../webgl/capabilities.js";import P from"../../../../geometry/Extent.js";const R=[0,0];let C=class extends t{constructor(){super(...arguments),this._updatingHandles=new l,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=s((async(e={})=>{const t=this._rasterFunctionState;if(e.reprocess&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const i=this._rasterFunctionState,{type:s}=this;return e.refetch||"raster"!==s&&!!e.reprocess||"cpu"===i||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new b({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:P.fromJSON(t);u(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=I();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new _(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new f({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t)});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new b({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new h({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=null!=t?t.signal:null,s=this.canUseWebGLForProcessing(),{layerView:r}=this,{tileInfo:a}=r,o=!a.isWrappable&&null!=g(r.view.spatialReference),l=s&&this.layer.raster.hasUniqueSourceStorageInfo,n={allowPartialFill:!0,datumTransformation:r.datumTransformation,interpolation:s?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:l,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:i,srcResolution:this._srcResolutions[e.level],timeExtent:r.timeExtent,tileInfo:a,disableWrapAround:o};return this.fetchTile(e,n)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=c.create({spatialReference:t,size:w,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const{scales:i,srcResolutions:s,isCustomTilingScheme:r}=m(this.layer.serviceRasterInfo,t,{tileSize:w,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),a=c.create({spatialReference:t,size:w,scales:i}),o=0===a.origin.x,{xmin:l,ymax:h}=e.fullExtent;(o||r&&a.origin.x>l)&&(a.origin=new n({x:l,y:h,spatialReference:t})),this._isCustomTilingScheme=r,e.set("tileInfo",a),this._srcResolutions=s??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),a=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){r(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(R,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:a,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){r(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await Promise.allSettled(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=p(s.rasterId,a);if(o!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(o,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];u(o,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=o}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([a()],C.prototype,"_globalUpdateRequested",void 0),e([a()],C.prototype,"attached",void 0),e([a()],C.prototype,"container",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",void 0),e([a()],C.prototype,"type",void 0),e([a()],C.prototype,"useWebGLForProcessing",null),e([a()],C.prototype,"useProgressiveUpdate",null),e([a()],C.prototype,"timeExtent",void 0),e([a()],C.prototype,"updating",null),C=e([o("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],C);export{C as BaseImageryTileSubView2D};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as s,isAbortError as r}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as l}from"../../../../core/support/UpdatingHandles.js";import n from"../../../../geometry/Point.js";import h from"../../../../layers/support/PixelBlock.js";import c from"../../../../layers/support/TileInfo.js";import{update as u,unregister as d,getRasterId as p,register as y}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as g,computeProjectedScales as m}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import _ from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import f from"../../tiling/TileQueue.js";import b from"../../tiling/TileStrategy.js";import{tileSize as w}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as I}from"../../../webgl/capabilities.js";import P from"../../../../geometry/Extent.js";const R=[0,0];let C=class extends t{constructor(){super(...arguments),this._updatingHandles=new l,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=s((async(e={})=>{const t=this._rasterFunctionState;if(e.reprocess&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const i=this._rasterFunctionState,{type:s}=this;return e.refetch||"raster"!==s&&!!e.reprocess||"cpu"===i||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new b({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:P.fromJSON(t);u(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=I();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new _(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new f({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t)});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new b({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new h({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=this._getFetchOptions(e.level,t.signal);return this.fetchTile(e,i)}_getFetchOptions(e,t){const i=this.canUseWebGLForProcessing(),{layerView:s}=this,{tileInfo:r}=s,a=!r.isWrappable&&null!=g(s.view.spatialReference),o=i&&this.layer.raster.hasUniqueSourceStorageInfo;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:i?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:t,srcResolution:this._srcResolutions[e],timeExtent:s.timeExtent,tileInfo:r,disableWrapAround:a}}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=c.create({spatialReference:t,size:w,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const{scales:i,srcResolutions:s,isCustomTilingScheme:r}=m(this.layer.serviceRasterInfo,t,{tileSize:w,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),a=c.create({spatialReference:t,size:w,scales:i}),o=0===a.origin.x,{xmin:l,ymax:h}=e.fullExtent;(o||r&&a.origin.x>l)&&(a.origin=new n({x:l,y:h,spatialReference:t})),this._isCustomTilingScheme=r,e.set("tileInfo",a),this._srcResolutions=s??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),a=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){r(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(R,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:a,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){r(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await Promise.allSettled(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t=this._getFetchOptions(this.previousLOD.level,e),i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...t,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=p(s.rasterId,a);if(o!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(o,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];u(o,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=o}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([a()],C.prototype,"_globalUpdateRequested",void 0),e([a()],C.prototype,"attached",void 0),e([a()],C.prototype,"container",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",void 0),e([a()],C.prototype,"type",void 0),e([a()],C.prototype,"useWebGLForProcessing",null),e([a()],C.prototype,"useProgressiveUpdate",null),e([a()],C.prototype,"timeExtent",void 0),e([a()],C.prototype,"updating",null),C=e([o("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],C);export{C as BaseImageryTileSubView2D};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as n,whenOnce as s}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{Prompt as p}from"./Editor/components/Prompt.js";import{css as u}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as m,isRelationshipInput as h,isTextElementInput as v,flattenInputs as g,isInputInGroupInput as _,isFieldElementWithInputType as b,getErrorMessageForFieldInput as C,getIconForFeature as f,isNumberFieldInput as y,subtypeChangeShouldPrompt as F}from"./FeatureForm/featureFormUtils.js";import w from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{isString as O}from"./support/dataUtils.js";import{getLabelForDateFieldValue as k,getIntlOptionsForField as I,numberingSystem as x,prepareISOFieldValueForDateComponents as M,prepareUnixFieldValueForDateComponents as D,normalizeTimeOnlyString as N,getISOFieldValueFromDateComponents as V,getUnixFieldValueFromDateComponents as T}from"./support/dateUtils.js";import{globalCss as L}from"./support/globalCss.js";import{Heading as S,incrementHeadingLevel as j}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as U}from"./support/decorators/vmEvent.js";import{tsx as P}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";const $="data-field-name";let H=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new w,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),s((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return R({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return P("div",{class:this.classes(u.base,L.widget,L.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return P("div",null,P("form",{class:u.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?P(p,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&P(S,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&P("p",{class:u.description,key:"description"},e.formDescription);return P("div",{class:u.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return c(e)?this._renderGroup(e):m(e)?this._renderLabeledField(e):h(e)?this._renderRelationshipInput(e):v(e)?this._renderTextElementInput(e):void 0}_renderDescriptionOrEmpty(e,t){return null==e?null:P("div",{class:this.classes(u.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:n,id:s,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),c=p?.group===e,m="sequential"===this.groupDisplay;return P("calcite-block",{class:this.classes(u.group,m?u.groupSequential:null,c?u.groupActive:null,t?u.inputDisabled:null),collapsible:!0,"data-group":e,description:n||void 0,disabled:t,heading:`${r}`,headingLevel:i?.title?j(o):o,id:s,key:s,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=g(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(c(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let n;if(_(t)&&!t.group.open){const i=t.group.inputs.filter(m);n="forward"===e?i[i.length-1]:i[0]}else n=t;o=i.indexOf(n)+1}else o=0;for(let n=o;n<i.length;n++){const e=i[n];if(e.visible&&m(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:s}=e,a={"aria-label":s?A(this.messages.requiredFieldLabel,{name:o}):o,class:u.label,key:`${n.id}-${i.uid}-${e.name}`},r=[P("div",{class:u.labelTextContent,key:"labelTextContainer"},o,s?P("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?P("label",{...a},r):P("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,s=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),s):this._renderComboBoxComponent(e,t,s):this._renderSwitchComponent(e,s)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,s):"number"===t?this._renderNumberComponent(e,s):this._renderStringComponent(e,s)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?P("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return P("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,k(i,t.value,{timeZone:this.timeZone,...I(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:s,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return P("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:s,"data-date-part":"date","data-field-name":t[$],key:`${a}-date-input`,max:O(l)?l:void 0,min:O(d)?d:void 0,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:s,readOnly:a}=t;return P("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[$],key:`${s}-time-input`,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:s,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:c}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:x,overlayPositioning:"fixed",readOnly:d,[$]:i,onfocus:this._onComponentFocus},h=M(p,n),v=M(c,n),g=M(a,n);return P("div",{class:u.dateInputContainer,key:`${l}-date-time-container`},P("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),P("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:g.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?P("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:s}=e,{class:a,key:r,max:l,min:d,readOnly:p}=t,{timeZone:c}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:x,overlayPositioning:"fixed",readOnly:p,[$]:o,onfocus:this._onComponentFocus},h=D(s,c),v=D(l,c),g=D(d,c);return P("div",{class:u.dateInputContainer,key:`${r}-date-time-container`},P("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:g?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?P("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return P("calcite-input",{...i,class:this.classes(u.fieldInput,u.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{viewModel:s,_inputsWithChanges:a}=this,r="INSERT"===s.arcadeEditType,l=a.has(n),d=null==o&&(!r||l),p=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return P("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:p,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:n,messagesTemplates:s,viewModel:a,_inputsWithChanges:r}=this,[l,d,p]=t.map((e=>e.map((({name:e,value:t})=>P("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(P("calcite-combobox-item-group",{key:"other",label:s.other},d)),p.length>0&&u.push(P("calcite-combobox-item-group",{key:"unsupported",label:n.subtypes.unsupportedDomainGroupTitle},p)),u.length>0?u.unshift(P("calcite-combobox-item-group",{key:"recommended",label:n.recommended},l)):u.push(...l);const c="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!c||m);return e.showNoValueOptionEnabled&&u.unshift(P("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||n.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,s=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;s.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return P("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:u.inputRadioGroup,"data-field-name":i[$],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},s)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!b(e.element,"switch")&&i===e.element.input.onValue;return P("calcite-switch",{...t,checked:o,class:u.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:s}){return P("calcite-label",{class:u.inputRadioLabel,key:e,layout:"inline"},P("calcite-radio-button",{...s,afterCreate:void 0,afterUpdate:void 0,checked:o,class:u.inputRadio,disabled:s.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?C(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?P("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?P("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const s=this.messages;return P("calcite-list-item",{description:A(s.totalCount,{count:t}),label:s.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},P("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:s}=this;if(t&&s?.addRelatedRecord&&o)return P("calcite-button",{alignment:"center",appearance:"outline-fill",class:u.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:s,relatedRecordCallbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&s&&a.editRelatedRecord({parentFeature:s,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return P("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},P("calcite-icon",{icon:f(i),slot:"content-start"}),P("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),s=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return P("calcite-label",{class:this.classes(u.label,u.relatedRecordsLabel),key:`relationship-${i}-container`},P("div",null,this._renderRelatedRecordsHeaderContainer(e),n,s),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return P("div",{class:u.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},P("span",null,e.label),t?P("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return P("calcite-list",{class:u.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),s=e.layer?.fieldsIndex.get(o),a=n?.label||s?.alias||o,r=A(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return P("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:u.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return P("div",{class:u.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:s,minLength:a,name:r,range:{max:l,min:d},required:p,valid:c,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(u.fieldInput,v?u.inputDisabled:null),status:h&&!c?"invalid":"idle",key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:s>-1?s:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[$]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute($))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);y(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,_(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:s}=i,a=this._dateComponentMap.get(n);if(!a)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=N(r),l=N(e.value)):l="timestamp-offset"===o?null!=e.value?V({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?T({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:s.max,min:s.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&F(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:n}=e,{layer:s,messages:a,viewModel:r,messagesCommon:l}=this;if(this._updateFieldValue(n,t),!s||!("subtypes"in s)||!s.subtypes?.length)return;const d=s.subtypes.find((e=>e.code===t)),p=s.subtypes.find((e=>e.code===i))?.name??`${i}`;if(!d)return;r.hasPendingSubtypeChoice=!0;const u=o();let c="update-fields";const m=[{label:a.subtypes.useDefaultValuesOption,value:"update-fields"},{label:a.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:a.subtypes.changeWarningTitle,message:A(a.subtypes.changeWarning,{originalType:p,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>c=e,actions:{primary:{label:l.apply,action:()=>u.resolve(c),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":r.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{r.hasPendingSubtypeChoice=!1,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&_(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return b(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges}}};e([a()],H.prototype,"_listObserverNode",void 0),e([a()],H.prototype,"_relatedRecordsEnabled",null),e([a()],H.prototype,"_prompt",void 0),e([a()],H.prototype,"disabled",null),e([a()],H.prototype,"feature",null),e([a()],H.prototype,"formTemplate",null),e([a()],H.prototype,"groupDisplay",void 0),e([a()],H.prototype,"headingLevel",void 0),e([a()],H.prototype,"icon",null),e([a()],H.prototype,"label",null),e([a()],H.prototype,"layer",null),e([a()],H.prototype,"map",null),e([a(),E("esri/widgets/FeatureForm/t9n/FeatureForm")],H.prototype,"messages",void 0),e([a(),E("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([a(),E("esri/widgets/Feature/t9n/Feature")],H.prototype,"messagesFeature",void 0),e([a(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],H.prototype,"messagesTemplates",void 0),e([a()],H.prototype,"relatedRecordCallbacks",null),e([a()],H.prototype,"relationshipId",null),e([a()],H.prototype,"spatialReference",null),e([a()],H.prototype,"strict",null),e([a()],H.prototype,"timeZone",null),e([a()],H.prototype,"showPrompt",null),e([a()],H.prototype,"clearPrompt",null),e([a(),U(["value-change","submit"])],H.prototype,"viewModel",void 0),e([a()],H.prototype,"test",null),H=e([r("esri.widgets.FeatureForm")],H);const Z=H;export{Z as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{Prompt as p}from"./Editor/components/Prompt.js";import{css as u}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as m,isRelationshipInput as h,isTextElementInput as v,flattenInputs as g,isInputInGroupInput as _,isFieldElementWithInputType as b,getErrorMessageForFieldInput as C,getIconForFeature as f,isNumberFieldInput as y,subtypeChangeShouldPrompt as F}from"./FeatureForm/featureFormUtils.js";import w from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{isString as O}from"./support/dataUtils.js";import{getLabelForDateFieldValue as k,getIntlOptionsForField as I,numberingSystem as x,prepareISOFieldValueForDateComponents as M,prepareUnixFieldValueForDateComponents as D,normalizeTimeOnlyString as N,getISOFieldValueFromDateComponents as V,getUnixFieldValueFromDateComponents as T}from"./support/dateUtils.js";import{globalCss as L}from"./support/globalCss.js";import{Heading as S,incrementHeadingLevel as j}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as U}from"./support/decorators/vmEvent.js";import{tsx as P}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";const $="data-field-name";let H=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new w,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return R({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return P("div",{class:this.classes(u.base,L.widget,L.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return P("div",null,P("form",{class:u.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?P(p,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&P(S,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&P("p",{class:u.description,key:"description"},e.formDescription);return P("div",{class:u.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return c(e)?this._renderGroup(e):m(e)?this._renderLabeledField(e):h(e)?this._renderRelationshipInput(e):v(e)?this._renderTextElementInput(e):void 0}_renderDescriptionOrEmpty(e,t){return null==e?null:P("div",{class:this.classes(u.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:n,id:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),c=p?.group===e,m="sequential"===this.groupDisplay;return P("calcite-block",{class:this.classes(u.group,m?u.groupSequential:null,c?u.groupActive:null,t?u.inputDisabled:null),collapsible:!0,"data-group":e,description:n||void 0,disabled:t,heading:`${r}`,headingLevel:i?.title?j(o):o,id:a,key:a,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=g(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(c(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let n;if(_(t)&&!t.group.open){const i=t.group.inputs.filter(m);n="forward"===e?i[i.length-1]:i[0]}else n=t;o=i.indexOf(n)+1}else o=0;for(let n=o;n<i.length;n++){const e=i[n];if(e.visible&&m(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?A(this.messages.requiredFieldLabel,{name:o}):o,class:u.label,key:`${n.id}-${i.uid}-${e.name}`},r=[P("div",{class:u.labelTextContent,key:"labelTextContainer"},o,a?P("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?P("label",{...s},r):P("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?P("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return P("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,k(i,t.value,{timeZone:this.timeZone,...I(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return P("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[$],key:`${s}-date-input`,max:O(l)?l:void 0,min:O(d)?d:void 0,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return P("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[$],key:`${a}-time-input`,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:c}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:x,overlayPositioning:"fixed",readOnly:d,[$]:i,onfocus:this._onComponentFocus},h=M(p,n),v=M(c,n),g=M(s,n);return P("div",{class:u.dateInputContainer,key:`${l}-date-time-container`},P("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),P("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:g.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?P("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:p}=t,{timeZone:c}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:x,overlayPositioning:"fixed",readOnly:p,[$]:o,onfocus:this._onComponentFocus},h=D(a,c),v=D(l,c),g=D(d,c);return P("div",{class:u.dateInputContainer,key:`${r}-date-time-container`},P("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:g?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?P("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return P("calcite-input",{...i,class:this.classes(u.fieldInput,u.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{viewModel:a,_inputsWithChanges:s}=this,r="INSERT"===a.arcadeEditType,l=s.has(n),d=null==o&&(!r||l),p=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return P("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:p,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:n,messagesTemplates:a,viewModel:s,_inputsWithChanges:r}=this,[l,d,p]=t.map((e=>e.map((({name:e,value:t})=>P("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(P("calcite-combobox-item-group",{key:"other",label:a.other},d)),p.length>0&&u.push(P("calcite-combobox-item-group",{key:"unsupported",label:n.subtypes.unsupportedDomainGroupTitle},p)),u.length>0?u.unshift(P("calcite-combobox-item-group",{key:"recommended",label:n.recommended},l)):u.push(...l);const c="INSERT"===s.arcadeEditType,m=r.has(o),h=null==i&&(!c||m);return e.showNoValueOptionEnabled&&u.unshift(P("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||n.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return P("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:u.inputRadioGroup,"data-field-name":i[$],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!b(e.element,"switch")&&i===e.element.input.onValue;return P("calcite-switch",{...t,checked:o,class:u.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return P("calcite-label",{class:u.inputRadioLabel,key:e,layout:"inline"},P("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:u.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?C(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?P("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?P("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return P("calcite-list-item",{description:A(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},P("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return P("calcite-button",{alignment:"center",appearance:"outline-fill",class:u.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return P("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},P("calcite-icon",{icon:f(i),slot:"content-start"}),P("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return P("calcite-label",{class:this.classes(u.label,u.relatedRecordsLabel),key:`relationship-${i}-container`},P("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return P("div",{class:u.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},P("span",null,e.label),t?P("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return P("calcite-list",{class:u.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=A(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return P("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:u.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return P("div",{class:u.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:p,valid:c,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(u.fieldInput,v?u.inputDisabled:null),status:h&&!c?"invalid":"idle",key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[$]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute($))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const i=new ResizeObserver((()=>{e.value=void 0,e.value=D(t.value).date??"",i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);y(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,_(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=N(r),l=N(e.value)):l="timestamp-offset"===o?null!=e.value?V({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?T({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&F(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:n}=e,{layer:a,messages:s,viewModel:r,messagesCommon:l}=this;if(this._updateFieldValue(n,t),!a||!("subtypes"in a)||!a.subtypes?.length)return;const d=a.subtypes.find((e=>e.code===t)),p=a.subtypes.find((e=>e.code===i))?.name??`${i}`;if(!d)return;r.hasPendingSubtypeChoice=!0;const u=o();let c="update-fields";const m=[{label:s.subtypes.useDefaultValuesOption,value:"update-fields"},{label:s.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:s.subtypes.changeWarningTitle,message:A(s.subtypes.changeWarning,{originalType:p,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>c=e,actions:{primary:{label:l.apply,action:()=>u.resolve(c),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":r.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{r.hasPendingSubtypeChoice=!1,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&_(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return b(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges}}};e([s()],H.prototype,"_listObserverNode",void 0),e([s()],H.prototype,"_relatedRecordsEnabled",null),e([s()],H.prototype,"_prompt",void 0),e([s()],H.prototype,"disabled",null),e([s()],H.prototype,"feature",null),e([s()],H.prototype,"formTemplate",null),e([s()],H.prototype,"groupDisplay",void 0),e([s()],H.prototype,"headingLevel",void 0),e([s()],H.prototype,"icon",null),e([s()],H.prototype,"label",null),e([s()],H.prototype,"layer",null),e([s()],H.prototype,"map",null),e([s(),E("esri/widgets/FeatureForm/t9n/FeatureForm")],H.prototype,"messages",void 0),e([s(),E("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([s(),E("esri/widgets/Feature/t9n/Feature")],H.prototype,"messagesFeature",void 0),e([s(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],H.prototype,"messagesTemplates",void 0),e([s()],H.prototype,"relatedRecordCallbacks",null),e([s()],H.prototype,"relationshipId",null),e([s()],H.prototype,"spatialReference",null),e([s()],H.prototype,"strict",null),e([s()],H.prototype,"timeZone",null),e([s()],H.prototype,"showPrompt",null),e([s()],H.prototype,"clearPrompt",null),e([s(),U(["value-change","submit"])],H.prototype,"viewModel",void 0),e([s()],H.prototype,"test",null),H=e([r("esri.widgets.FeatureForm")],H);const Z=H;export{Z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:o}=e,{formatFunction:n}=this,i=r.sanitize(o);if(n&&t){const{index:e,item:{feature:o}}=t;return n({column:this,feature:o,index:e,value:i})}return i},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,o=this.createHeaderContent();this.removeCellContent(t),t.appendChild(o)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:o})=>{const n=this.getCellValue(t,o),i=this.cellValueFormatFunction({column:t,rowData:o,value:n});let r=null;r=i instanceof HTMLElement?i:s(this.messagesURIUtils,i),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([o((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.closeMenu())),o((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)})),o((()=>this.effectiveLabel),(e=>{const{sortElement:t}=this;t&&t.textContent!==e&&(t.setAttribute("title",e),t.textContent=e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:o,iconClass:n,label:i,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:o,selected:s,textContent:i,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],o=this.visibleElements?.columnMenuItems;if(!1!==o?.sortAscending){const o=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(o)}if(!1!==o?.sortDescending){const o=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(o)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:o}=this,n=!!o?.open,i=this.createCalciteAction({icon:o?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=o?.maxItems??4,s.placement="top-end",s.overlayPositioning="fixed",s.scale=o?.scale??"m",s.widthScale="s",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(i),s.addEventListener("calciteDropdownOpen",(()=>this._menuIsOpen=!0)),s.addEventListener("calciteDropdownClose",(()=>this._menuIsOpen=!1)),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=o?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e,t){return e.path&&t?.item?t.item[e.path]:""}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:o,initialSortPriority:n}=this,i=document.createElement("vaadin-grid-sorter");return i.classList.add(c.sorter),i.setAttribute("path",o),i.setAttribute("title",e),i.textContent=e,t&&i.setAttribute("direction",t),null!=n&&(i._initialOrder=n),i.addEventListener("direction-changed",(()=>{this.direction!==i.direction&&this._set("direction",i.direction)})),i}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:o,disabled:n,icon:i,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=o??"",t.disabled=!!n,t.icon=i??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:o,className:n,disabled:i,iconEnd:s,iconFlipRtl:r,loading:l,onclick:c,scale:a,textContent:d}=e;return t.className=n??"",t.scale=a??"s",t.appearance=o??"transparent",t.disabled=!!i,t.iconEnd=s??"",r&&(t.iconFlipRtl=r),t.loading=!!l,t.textContent=t.title=d??"",t.onclick=c??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:o,hidden:n,iconClass:i,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(i&&!s){const e=document.createElement("span"),o=document.createElement("span");o.classList.add(c.headerMenuIcon,i),e.textContent=e.title=d,e.insertBefore(o,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!o,t.hidden="function"==typeof n?n():!!n,t.selected=!!a,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:o,scale:n,textLabel:i}=e,s=document.createElement("calcite-icon"),r=i??t;return s.icon=o,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,o=document.createElement("div");if(o.classList.add(c.headerContent),t&&o.appendChild(t),this.sortable)o.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const n=t.appendChild(document.createElement("span"));n.textContent=e,n.setAttribute("title",e),o.appendChild(t)}return this.menuIsVisible&&o.appendChild(this.menu),o}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}};e([n()],a.prototype,"_menuIsOpen",void 0),e([n()],a.prototype,"autoWidth",void 0),e([n()],a.prototype,"cellValueFormatFunction",void 0),e([n()],a.prototype,"customMenuItems",null),e([n()],a.prototype,"defaultMenuItems",null),e([n()],a.prototype,"direction",void 0),e([n()],a.prototype,"effectiveLabel",null),e([n({constructOnly:!0})],a.prototype,"fieldName",void 0),e([n()],a.prototype,"flexGrow",void 0),e([n()],a.prototype,"footerRenderFunction",void 0),e([n()],a.prototype,"formatFunction",void 0),e([n()],a.prototype,"frozen",void 0),e([n()],a.prototype,"frozenToEnd",void 0),e([n()],a.prototype,"grid",void 0),e([n()],a.prototype,"iconNode",null),e([n()],a.prototype,"invalid",null),e([n()],a.prototype,"headerRenderFunction",void 0),e([n()],a.prototype,"hidden",void 0),e([n()],a.prototype,"icon",void 0),e([n({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([n()],a.prototype,"label",void 0),e([n()],a.prototype,"menu",null),e([n()],a.prototype,"menuItems",null),e([n()],a.prototype,"menuConfig",void 0),e([n()],a.prototype,"menuIsOpen",null),e([n()],a.prototype,"menuIsVisible",null),e([n()],a.prototype,"messages",void 0),e([n()],a.prototype,"messagesCommon",void 0),e([n()],a.prototype,"messagesURIUtils",void 0),e([n()],a.prototype,"renderFunction",void 0),e([n()],a.prototype,"resizable",void 0),e([n()],a.prototype,"sortable",void 0),e([n({readOnly:!0})],a.prototype,"sortElement",void 0),e([n()],a.prototype,"store",void 0),e([n()],a.prototype,"textAlign",void 0),e([n()],a.prototype,"textWrap",void 0),e([n()],a.prototype,"timeZone",void 0),e([n()],a.prototype,"timeZoneName",void 0),e([n()],a.prototype,"visibleElements",void 0),e([n()],a.prototype,"width",void 0),a=e([i("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d as default};
|