@arcgis/core 4.28.0 → 4.28.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/0a3da4b73beeaacd4667.js +1 -0
- package/assets/esri/core/workers/chunks/41306b698f78001dda55.js +1 -0
- package/assets/esri/core/workers/chunks/49faa024bab1ba6e2bf0.js +1 -0
- package/assets/esri/core/workers/chunks/{74951370a341f02d3714.js → 630b31a205d9db7147d0.js} +1 -1
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -16
- package/assets/esri/themes/base/widgets/_Features.scss +0 -5
- package/assets/esri/themes/base/widgets/_Popup.scss +1 -0
- 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/kernel.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/assets/esri/core/workers/chunks/07adca463da5554e514d.js +0 -1
- package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +0 -1
- package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +0 -1
package/kernel.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.1";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{difference as e,isSome as a}from"../../core/arrayUtils.js";import r from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import o from"../FeatureLayer.js";import{save as s,getLayerJSON as l,setCommonItemProperties as n,saveAs as i,getPortalItem as u,addItem as c,ensureLayerConfig as p,ensureItemConfig as m,createErrorMessage as f}from"./utils.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as d}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as h}from"../support/layerUtils.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as v,removeTypeKeyword as S,TypeKeyword as I,toggleTypeKeword as b,addTypeKeyword as T}from"../../portal/support/portalItemUtils.js";const P="Feature Service",$="feature-layer-utils",E=`${$}-save`,A=`${$}-save-as`,L=`${$}-saveall`,N=`${$}-saveall-as`;function x(e){return{isValid:h(e)&&("feature"!==e.type||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function j(e){const a=[],r=[];for(const{layer:t,layerJSON:o}of e)t.isTable?r.push(o):a.push(o);return{layers:a,tables:r}}function U(e){return j([e])}async function g(e,a){return/\/\d+\/?$/.test(e.url)?U(a[0]):O(a,e)}async function O(e,a){if(!a)return j(e);const{layer:{url:r,customParameters:t,apiKey:o}}=e[0];let s=await a.fetchData("json");null!=s?.layers&&null!=s
|
|
5
|
+
import{difference as e,isSome as a}from"../../core/arrayUtils.js";import r from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import o from"../FeatureLayer.js";import{save as s,getLayerJSON as l,setCommonItemProperties as n,saveAs as i,getPortalItem as u,addItem as c,ensureLayerConfig as p,ensureItemConfig as m,createErrorMessage as f}from"./utils.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as d}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as h}from"../support/layerUtils.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as v,removeTypeKeyword as S,TypeKeyword as I,toggleTypeKeword as b,addTypeKeyword as T}from"../../portal/support/portalItemUtils.js";const P="Feature Service",$="feature-layer-utils",E=`${$}-save`,A=`${$}-save-as`,L=`${$}-saveall`,N=`${$}-saveall-as`;function x(e){return{isValid:h(e)&&("feature"!==e.type||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function j(e){const a=[],r=[];for(const{layer:t,layerJSON:o}of e)t.isTable?r.push(o):a.push(o);return{layers:a,tables:r}}function U(e){return j([e])}async function g(e,a){return/\/\d+\/?$/.test(e.url)?U(a[0]):O(a,e)}async function O(e,a){if(!a)return e.reverse(),j(e);const{layer:{url:r,customParameters:t,apiKey:o}}=e[0];let s=await a.fetchData("json");null!=s?.layers&&null!=s?.tables||(s=await J(s,{url:r??"",customParameters:t,apiKey:o},e.map((e=>e.layer.layerId))));for(const l of e)D(l.layer,l.layerJSON,s);return s}async function J(e,a,r){e||={},e.layers||=[],e.tables||=[];const{url:t,customParameters:o,apiKey:s}=a,{serviceJSON:l,layersJSON:n}=await d(t,{customParameters:o,apiKey:s}),i=M(e.layers,l.layers,r),u=M(e.tables,l.tables,r);e.layers=i.itemResources,e.tables=u.itemResources;const c=[...i.added,...u.added],p=n?[...n.layers,...n.tables]:[];return await R(e,c,t,p),e}function M(a,r,t){const o=e(a,r,((e,a)=>e.id===a.id));a=a.filter((e=>!o.removed.some((a=>a.id===e.id))));const s=o.added.map((({id:e})=>({id:e})));return s.forEach((({id:e})=>{a.push({id:e})})),{itemResources:a,added:s.filter((({id:e})=>!t.includes(e)))}}async function R(e,a,r,t){const s=a.map((({id:e})=>new o({url:r,layerId:e,sourceJSON:t.find((({id:a})=>a===e))})));await Promise.allSettled(s.map((e=>e.load()))),s.forEach((a=>{const{layerId:r,loaded:t,defaultPopupTemplate:o}=a;if(!t||null==o)return;D(a,{id:r,popupInfo:o.toJSON()},e)}))}function D(e,a,r){e.isTable?F(r.tables,a):F(r.layers,a)}function F(e,a){const r=e.findIndex((({id:e})=>e===a.id));-1===r?e.push(a):e[r]=a}function K(e,a){if(!e.length)throw new r(`${a}:missing-parameters`,"'layers' array should contain at least one feature layer")}function Y(e,a){const t=e.map((e=>e.portalItem.id));if(new Set(t).size>1)throw new r(`${a}:invalid-parameters`,"All layers in the 'layers' array should be loaded from the same portal item")}function _(e,a){const t=e.map((e=>e.layerId));if(new Set(t).size!==t.length)throw new r(`${a}:invalid-parameters`,"'layers' array should contain only one instance each of layer or table in a feature service")}async function z(e){K(e,L),await Promise.all(e.map((e=>e.load())));for(const a of e)p(a,L,x),m({layer:a,itemType:P,errorNamePrefix:L});Y(e,L),_(e,L)}async function B(e,a){const{url:r,layerId:t,title:o,fullExtent:s,isTable:l}=e,n=y(r);a.url="FeatureServer"===n?.serverType?r:`${r}/${t}`,a.title||=o,a.extent=null,l||null==s||(a.extent=await v(s)),S(a,I.METADATA),S(a,I.MULTI_LAYER),T(a,I.SINGLE_LAYER),l&&T(a,I.TABLE)}function G(e,a){for(const l of e){const t=l.parsedUrl.path,o=y(t),s=o?.url.path;if(!s)throw new r(`${a}:invalid-parameters`,f(l,`has unsupported url pattern: ${t}`),{layer:l});const n=o?.serverType;if("FeatureServer"!==n&&"MapServer"!==n)throw new r(`${a}:invalid-parameters`,f(l,`has unsupported server type: ${n}`),{layer:l});if("MapServer"===n&&e.length>1)throw new r(`${a}:invalid-parameters`,"Only one layer or table in a map service can be saved")}const t=y(e[0].parsedUrl.path),o=t?.url.path,s=e.every((e=>{const a=y(e.parsedUrl.path);return a?.url.path===o}));if(!s)throw new r(`${a}:invalid-parameters`,"'layers' array should only contain layers or tables that belong to the same feature service")}async function C(e){K(e,N),await Promise.all(e.map((e=>e.load())));for(const a of e)p(a,N,x);G(e,N),_(e,N)}async function V(e,r){let t=0,o=0;for(const{isTable:a}of r)a?o++:t++;const s=r[0].parsedUrl.path,l=y(s);if(e.url="FeatureServer"===l?.serverType?l.url.path:s,e.title||=l.title,e.extent=null,t>0){const t=r.map((e=>e.fullExtent)).filter(a).reduce(((e,a)=>e.clone().union(a)));t&&(e.extent=await v(t))}S(e,I.METADATA),b(e,I.MULTI_LAYER,r.length>1),b(e,I.SINGLE_LAYER,1===r.length),b(e,I.TABLE,o>0&&0===t),n(e)}async function k(e,a){return s({layer:e,itemType:P,validateLayer:x,createItemData:(e,a)=>g(a,[e]),errorNamePrefix:E},a)}async function q(e,a){await z(e);const r=e[0].portalItem,o=w(r),s=await Promise.all(e.map((e=>l(e,o,a)))),i=await g(r,e.map(((e,a)=>({layer:e,layerJSON:s[a]}))));return n(r),await r.update({data:i}),await Promise.all(e.slice(1).map((e=>e.portalItem.reload()))),t(o),r.clone()}async function H(e,a,r){return i({layer:e,itemType:P,validateLayer:x,createItemData:(e,a)=>Promise.resolve(U(e)),errorNamePrefix:A,newItem:a,setItemProperties:B},r)}async function Q(e,a,r){await C(e);const o=u({itemType:P,errorNamePrefix:N,newItem:a}),s=w(o),n=await Promise.all(e.map((e=>l(e,s,r)))),i=await O(e.map(((e,a)=>({layer:e,layerJSON:n[a]}))));await V(o,e),await c(o,i,r);for(const t of e)t.portalItem=o.clone();return t(s),o}export{k as save,q as saveAll,Q as saveAllAs,H as saveAs};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{getPixelValueRange as t}from"./rasterFormats/pixelRangeUtils.js";import{schema as r}from"./rasterFunctions/rasterFunctionSchema.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=h(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=V(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return S(e,n);case"unique-value":return F(e,n);case"raster-colormap":return A(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster??e?.raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u,!0);if(n)l.functionArguments={colorRampName:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function S(e,t){const r=[],o=[],a=[],i=[],s=1e-
|
|
5
|
+
import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{getPixelValueRange as t}from"./rasterFormats/pixelRangeUtils.js";import{schema as r}from"./rasterFunctions/rasterFunctionSchema.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=h(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=V(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return S(e,n);case"unique-value":return F(e,n);case"raster-colormap":return A(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster??e?.raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u,!0);if(n)l.functionArguments={colorRampName:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function S(e,t){const r=[],o=[],a=[],i=[],s=1e-4,{pixelType:u,rasterAttributeTable:l}=t,c=null==l?null:l.features,m=C(l);if(m&&c&&Array.isArray(c)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&c.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&i.push([a.attributes[m],r.r,r.g,r.b]))}))}));const r=u?x(i,u):i,o=new n;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=r,o.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?r.push(e.minValue,e.maxValue+s):r.push(e.minValue+s,e.maxValue+s),o.push(n),i.push([n,t.r,t.g,t.b])):a.push(e.minValue,e.maxValue)}));const f=u?x(i,u):i,p=new n;p.functionName="Remap",p.functionArguments={InputRanges:r,OutputValues:o,NoDataRanges:a},p.variableName="Raster";const g=new n;return g.functionName="Colormap",g.functionArguments={Colormap:f,Raster:p},t.convertToRFT?new n({rasterFunctionDefinition:h(g)}):g}function x(e,n){const r=c.has(n)?t(n):null;return r&&e.push([Math.floor(r[0]-1),0,0,0],[Math.ceil(r[1]+1),0,0,0]),e}function C(e){if(null==e)return;const{fields:n}=e,t=n?.find((e=>e?.name&&"value"===e.name.toLowerCase()));return t?.name}function F(e,t){const r=[],{pixelType:o,rasterAttributeTable:a}=t,i=null==a?null:a.features,s=C(a),u=e.defaultSymbol?.color?.toRgb(),l=e.uniqueValueInfos;if(l)if(i){if(s){const n=new Map;l.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r?.a&&n.set(String(t),r.toRgb())}));const t=e.field;i.forEach((({attributes:e})=>{const o=String(e[t]),a=e[s],i=n.get(o);i?r.push([a,...i]):u&&r.push([a,...u])}))}}else for(let n=0;n<l.length;n++){const e=l[n],t=e.symbol?.color,o=+e.value;if(t?.a){if(isNaN(o))return null;r.push([o,t.r,t.g,t.b])}}const c=o?x(r,o):r,m=new n;return m.functionName="Colormap",m.functionArguments={},m.functionArguments.Colormap=c,m.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(m)}):m}function A(e,t){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=t,a=o?x(r,o):r,i=new n;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,t.convertToRFT?new n({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,p as isSupportedRendererType};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20231024",a="ebaa50250565ddb3ec5a45e4d510c4e0202a6c8d";export{e as buildDate,a 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Error.js";import t from"../../../../../core/Logger.js";import{assertIsSome as r}from"../../../../../core/maybe.js";import s from"../../../../../core/pbf.js";import{convertToGeometry as i,unquantizeOptimizedGeometry as n}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as a}from"../../../../../layers/graphics/OptimizedFeature.js";import h from"../../../../../layers/graphics/OptimizedGeometry.js";import{FeatureSetReader as o}from"./FeatureSetReader.js";import{parseHeader as d}from"./FeatureSetReaderPBFHeader.js";const u=!0,c=268435455,g=128,l=128e3,_={small:{delta:new Int32Array(g),decoded:new Int32Array(g)},large:{delta:new Int32Array(l),decoded:new Int32Array(l)}};function f(e){return e<=_.small.delta.length?_.small:(e<=_.large.delta.length||(_.large.delta=new Int32Array(Math.round(1.25*e)),_.large.decoded=new Int32Array(Math.round(1.25*e))),_.large)}function y(r){try{const e=2,t=new s(new Uint8Array(r),new DataView(r));for(;t.next();){if(t.tag()===e)return I(t.getMessage());t.skip()}}catch(i){const r=new e("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:i});t.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(r)}return null}function I(e){const t=1;for(;e.next();){if(e.tag()===t)return e.getMessage();e.skip()}return null}function p(e){const t=1,r=2,s=3,i=4,n=5,a=6,h=7,o=8,d=9,u=e.getLength(),c=e.pos()+u;for(;e.pos()<c&&e.next();)switch(e.tag()){case t:return e.getString();case r:return e.getFloat();case s:return e.getDouble();case i:return e.getSInt32();case n:return e.getUInt32();case a:return e.getInt64();case h:return e.getUInt64();case o:return e.getSInt64();case d:return e.getBool();default:return e.skip(),null}return null}function m(e,t,r,s,i,n){return.5*Math.abs(e*s+r*n+i*t-e*n-r*t-i*s)}function x(e,t,r,s){return 0===e*s-r*t&&e*r+t*s>0}class S extends o{static fromBuffer(e,t,r=!1){const s=t.geometryType,i=y(e),n=d(i,"esriGeometryPoint"===s,r),a=o.createInstance();return new S(a,i,n,t)}constructor(e,t,r,s){super(e,s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._geometryType=s.geometryType,this._reader=t,this._header=r,this._hasNext=r.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get _size(){return this._header.featureCount}get hasZ(){return!1}get hasM(){return!1}get stride(){return 2+(this.hasZ?1:0)+(this.hasM?1:0)}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getQuantizationTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(e){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=e}getAttributeHash(){let e="";for(const t of this._header.fields.fields)e+=this._readAttributeAtIndex(t.index)+".";return e}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(e){this._header.displayIds[this._featureIndex]=e}getGroupId(){return this._header.groupIds[this._featureIndex]}setGroupId(e){this._header.groupIds[this._featureIndex]=e}readLegacyFeature(){if(void 0===this._cache.legacyFeature){const e=this.readCentroid(),t={attributes:this.readAttributes(),geometry:this._isPoints?this.readLegacyPointGeometry():this.readLegacyGeometry(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null};return this._cache.legacyFeature=t,t}return this._cache.legacyFeature}readOptimizedFeature(){if(void 0===this._cache.optFeature){const e=new a(this.readGeometry(),this.readAttributes(),this.readCentroid());return e.objectId=this.getObjectId(),e.displayId=this.getDisplayId(),this._cache.optFeature=e,e}return this._cache.optFeature}getXHydrated(){const e=this._header.centroid[2*this._featureIndex],t=this.getQuantizationTransform();return null==t?e:e*t.scale[0]+t.translate[0]}getYHydrated(){const e=this._header.centroid[2*this._featureIndex+1],t=this.getQuantizationTransform();return null==t?e:t.translate[1]-e*t.scale[1]}getX(){return this._header.centroid[2*this._featureIndex]*this._sx+this._tx}getY(){return this._header.centroid[2*this._featureIndex+1]*this._sy+this._ty}readLegacyPointGeometry(){return{x:this.getX(),y:this.getY()}}readLegacyGeometry(e){const t=this.readUnquantizedGeometry(e);return i(t,this.geometryType,!1,!1)}readLegacyCentroid(){const e=this.readCentroid();if(!e)return null;const[t,r]=e.coords;return{x:t,y:r}}readGeometryArea(){return this._cache.area||this.readGeometry(!0),this._cache.area}readUnquantizedGeometry(e=!1){if(void 0===this._cache.unquantGeometry){const t=this.readGeometry(e);if(!t)return this._cache.unquantGeometry=void 0,null;const r=f(t.coords.length).decoded,s=t.clone(r),i=s.coords;let n=0;for(const e of s.lengths){for(let t=1;t<e;t++){const e=2*(n+t),r=2*(n+t-1);i[e]+=i[r],i[e+1]+=i[r+1]}n+=e}return this._cache.unquantGeometry=s,s}return this._cache.unquantGeometry}readHydratedGeometry(){if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===c)return null;const e=this.getXHydrated(),t=this.getYHydrated();return new h([],[e,t])}const e=this.readGeometry();if(!e)return null;const t=e.clone(),r=this.getQuantizationTransform();return null!=r&&n(t,t,this.hasZ,this.hasM,r),t}readGeometry(e=!1){if(void 0===this._cache.geometry){let r=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===c)return null;const e=this.getX(),t=this.getY();r=new h([],[e,t])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this.createQuantizedExtrudedGeometry(t,r)}i.move(s);try{if(r=e?this._parseGeometryForDisplay(i):this._parseGeometry(i),null===r){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this.createQuantizedExtrudedGeometry(t,r)}}catch(t){return console.error("Failed to parse geometry!",t),null}}return this._cache.geometry=r,r}return this._cache.geometry}readCentroid(){if(void 0===this._cache.centroid){let e;return e=this._computeCentroid(),e||(e=this._readServerCentroid()),this._cache.centroid=e??void 0,e??null}return this._cache.centroid}copy(){const e=this._reader.clone(),t=new S(this.instance,e,this._header,this.fullSchema());return this.copyInto(t),t}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_readAttribute(e,t){const r=this._header.fields.get(e);if(null==r)return;let s=this._readAttributeAtIndex(r.index);"esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s));const i=this._header.fields.isDateField(r.name);return t?null==s?s:i?new Date(s):s:s}_readAttributes(){const e={};for(const t of this._header.fields.fields)e[t.name]=this._readAttributeAtIndex(t.index);return e}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._featureOffset=this._featureOffset,e._hasNext=this._hasNext}_readAttributeAtIndex(e){const t=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+e],r=this._reader;return r.move(t),p(r)}_readServerCentroid(){const e=this._header.centroid[2*this._featureIndex]+this._tx,t=this._header.centroid[2*this._featureIndex+1]+this._ty;return e===c?null:new h([],[e,t])}_parseGeometry(e){const t=2,r=3,s=e.asUnsafe(),i=s.getLength(),n=s.pos()+i,a=[],o=[];for(;s.pos()<n&&s.next();)switch(s.tag()){case t:{const e=s.getUInt32(),t=s.pos()+e;for(;s.pos()<t;)o.push(s.getUInt32());break}case r:{const e=s.getUInt32(),t=s.pos()+e;for(a.push(s.getSInt32()+this._tx),a.push(s.getSInt32()+this._ty),this.hasZ&&s.getSInt32(),this.hasM&&s.getSInt32();s.pos()<t;)a.push(s.getSInt32()),a.push(s.getSInt32()),this.hasZ&&s.getSInt32(),this.hasM&&s.getSInt32();break}default:s.skip()}return new h(o,a)}_parseGeometryForDisplay(e){const t=2,s=3,i=e.asUnsafe(),n=i.getLength(),a=i.pos()+n,o=[],d=[];let c=0,g=0,l=null,_=0;const y="esriGeometryPolygon"===this.geometryType;for(;i.pos()<a&&i.next();)switch(i.tag()){case t:{const e=i.getUInt32(),t=i.pos()+e;for(;i.pos()<t;){const e=i.getUInt32();o.push(e),c+=e}l=f(2*c).delta;break}case s:{i.getUInt32();const e=2+(this.hasZ?1:0)+(this.hasM?1:0);r(l);for(const t of o)if(g+e*t>l.length)for(let e=0;e<t;e++)i.getSInt32(),i.getSInt32(),this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();else if(y&&u){const e=this.getAreaSimplificationThreshold(t,this._header.vertexCount);let r=2,s=1;const n=!1;let a=i.getSInt32(),h=i.getSInt32();l[g++]=a,l[g++]=h,this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();let o=i.getSInt32(),u=i.getSInt32();for(this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();r<t;){let t=i.getSInt32(),n=i.getSInt32();this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();const d=a+o,c=h+u;m(a,h,d,c,d+t,c+n)>=e?(_+=-.5*(d-a)*(c+h),s>1&&x(l[g-2],l[g-1],o,u)?(l[g-2]+=o,l[g-1]+=u):(l[g++]=o,l[g++]=u,s++),a=d,h=c):(t+=o,n+=u),o=t,u=n,r++}s<3||n?g-=2*s:(_+=-.5*(a+o-a)*(h+u+h),x(l[g-2],l[g-1],o,u)?(l[g-2]+=o,l[g-1]+=u,d.push(s)):(l[g++]=o,l[g++]=u,d.push(++s)))}else{let e=0,r=i.getSInt32(),s=i.getSInt32();this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32(),l[g++]=r,l[g++]=s,e+=1;for(let n=1;n<t;n++){const t=i.getSInt32(),a=i.getSInt32(),h=r+t,o=s+a;_+=-.5*(h-r)*(o+s),this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32(),n>2&&x(l[g-2],l[g-1],t,a)?(l[g-2]+=t,l[g-1]+=a):(l[g++]=t,l[g++]=a,e+=1),r=h,s=o}d.push(e)}break}default:i.skip()}if(this._cache.area=_,!d.length)return null;if(this._tx||this._ty){let e=0;r(l);for(const t of d)l[2*e]+=this._tx,l[2*e+1]+=this._ty,e+=t}return new h(d,l)}}export{S as FeatureSetReaderPBF};
|
|
5
|
+
import e from"../../../../../core/Error.js";import t from"../../../../../core/Logger.js";import{assertIsSome as r}from"../../../../../core/maybe.js";import s from"../../../../../core/pbf.js";import{convertToGeometry as i,unquantizeOptimizedGeometry as n}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as a}from"../../../../../layers/graphics/OptimizedFeature.js";import h from"../../../../../layers/graphics/OptimizedGeometry.js";import{FeatureSetReader as o}from"./FeatureSetReader.js";import{parseHeader as d}from"./FeatureSetReaderPBFHeader.js";const u=!0,c=268435455,g=128,l=128e3,_={small:{delta:new Int32Array(g),decoded:new Int32Array(g)},large:{delta:new Int32Array(l),decoded:new Int32Array(l)}};function f(e){return e<=_.small.delta.length?_.small:(e<=_.large.delta.length||(_.large.delta=new Int32Array(Math.round(1.25*e)),_.large.decoded=new Int32Array(Math.round(1.25*e))),_.large)}function y(r){try{const e=2,t=new s(new Uint8Array(r),new DataView(r));for(;t.next();){if(t.tag()===e)return I(t.getMessage());t.skip()}}catch(i){const r=new e("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:i});t.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(r)}return null}function I(e){const t=1;for(;e.next();){if(e.tag()===t)return e.getMessage();e.skip()}return null}function p(e){const t=1,r=2,s=3,i=4,n=5,a=6,h=7,o=8,d=9,u=e.getLength(),c=e.pos()+u;for(;e.pos()<c&&e.next();)switch(e.tag()){case t:return e.getString();case r:return e.getFloat();case s:return e.getDouble();case i:return e.getSInt32();case n:return e.getUInt32();case a:return e.getInt64();case h:return e.getUInt64();case o:return e.getSInt64();case d:return e.getBool();default:return e.skip(),null}return null}function m(e,t,r,s,i,n){return.5*Math.abs(e*s+r*n+i*t-e*n-r*t-i*s)}function x(e,t,r,s){return 0===e*s-r*t&&e*r+t*s>0}class S extends o{static fromBuffer(e,t,r=!1){const s=t.geometryType,i=y(e),n=d(i,"esriGeometryPoint"===s,r),a=o.createInstance();return new S(a,i,n,t)}constructor(e,t,r,s){super(e,s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._geometryType=s.geometryType,this._reader=t,this._header=r,this._hasNext=r.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get _size(){return this._header.featureCount}get hasZ(){return!1}get hasM(){return!1}get stride(){return 2+(this.hasZ?1:0)+(this.hasM?1:0)}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getQuantizationTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(e){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=e}getAttributeHash(){let e="";for(const t of this._header.fields.fields)e+=this._readAttributeAtIndex(t.index)+".";return e}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(e){this._header.displayIds[this._featureIndex]=e}getGroupId(){return this._header.groupIds[this._featureIndex]}setGroupId(e){this._header.groupIds[this._featureIndex]=e}readLegacyFeature(){if(void 0===this._cache.legacyFeature){const e=this.readCentroid(),t={attributes:this.readAttributes(),geometry:this._isPoints?this.readLegacyPointGeometry():this.readLegacyGeometry(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null};return this._cache.legacyFeature=t,t}return this._cache.legacyFeature}readOptimizedFeature(){if(void 0===this._cache.optFeature){const e=new a(this.readGeometry(),this.readAttributes(),this.readCentroid());return e.objectId=this.getObjectId(),e.displayId=this.getDisplayId(),this._cache.optFeature=e,e}return this._cache.optFeature}getXHydrated(){const e=this._header.centroid[2*this._featureIndex],t=this.getQuantizationTransform();return null==t?e:e*t.scale[0]+t.translate[0]}getYHydrated(){const e=this._header.centroid[2*this._featureIndex+1],t=this.getQuantizationTransform();return null==t?e:t.translate[1]-e*t.scale[1]}getX(){return this._header.centroid[2*this._featureIndex]*this._sx+this._tx}getY(){return this._header.centroid[2*this._featureIndex+1]*this._sy+this._ty}readLegacyPointGeometry(){return{x:this.getX(),y:this.getY()}}readLegacyGeometry(e){const t=this.readUnquantizedGeometry(e);return i(t,this.geometryType,!1,!1)}readLegacyCentroid(){const e=this.readCentroid();if(!e)return null;const[t,r]=e.coords;return{x:t,y:r}}readGeometryArea(){return this._cache.area||this.readGeometry(!0),this._cache.area}readUnquantizedGeometry(e=!1){if(void 0===this._cache.unquantGeometry){const t=this.readGeometry(e);if(!t)return this._cache.unquantGeometry=void 0,null;const r=f(t.coords.length).decoded,s=t.clone(r),i=s.coords;let n=0;for(const e of s.lengths){for(let t=1;t<e;t++){const e=2*(n+t),r=2*(n+t-1);i[e]+=i[r],i[e+1]+=i[r+1]}n+=e}return this._cache.unquantGeometry=s,s}return this._cache.unquantGeometry}readHydratedGeometry(){if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===c)return null;const e=this.getXHydrated(),t=this.getYHydrated();return new h([],[e,t])}const e=this.readGeometry();if(!e)return null;const t=e.clone(),r=this.getQuantizationTransform();return null!=r&&n(t,t,this.hasZ,this.hasM,r),t}readGeometry(e=!1){if(void 0===this._cache.geometry){let r=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===c)return null;const e=this.getX(),t=this.getY();r=new h([],[e,t])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this.createQuantizedExtrudedGeometry(t,r)}i.move(s);try{if(r=e?this._parseGeometryForDisplay(i):this._parseGeometry(i),!r){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this.createQuantizedExtrudedGeometry(t,r)}}catch(t){return console.error("Failed to parse geometry!",t),null}}return this._cache.geometry=r,r}return this._cache.geometry}readCentroid(){if(void 0===this._cache.centroid){let e;return e=this._computeCentroid(),e||(e=this._readServerCentroid()),this._cache.centroid=e??void 0,e??null}return this._cache.centroid}copy(){const e=this._reader.clone(),t=new S(this.instance,e,this._header,this.fullSchema());return this.copyInto(t),t}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_readAttribute(e,t){const r=this._header.fields.get(e);if(null==r)return;let s=this._readAttributeAtIndex(r.index);"esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s));const i=this._header.fields.isDateField(r.name);return t?null==s?s:i?new Date(s):s:s}_readAttributes(){const e={};for(const t of this._header.fields.fields)e[t.name]=this._readAttributeAtIndex(t.index);return e}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._featureOffset=this._featureOffset,e._hasNext=this._hasNext}_readAttributeAtIndex(e){const t=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+e],r=this._reader;return r.move(t),p(r)}_readServerCentroid(){const e=this._header.centroid[2*this._featureIndex]+this._tx,t=this._header.centroid[2*this._featureIndex+1]+this._ty;return e===c?null:new h([],[e,t])}_parseGeometry(e){const t=2,r=3,s=e.asUnsafe(),i=s.getLength(),n=s.pos()+i,a=[],o=[];for(;s.pos()<n&&s.next();)switch(s.tag()){case t:{const e=s.getUInt32(),t=s.pos()+e;for(;s.pos()<t;)o.push(s.getUInt32());break}case r:{const e=s.getUInt32(),t=s.pos()+e;for(a.push(s.getSInt32()+this._tx),a.push(s.getSInt32()+this._ty),this.hasZ&&s.getSInt32(),this.hasM&&s.getSInt32();s.pos()<t;)a.push(s.getSInt32()),a.push(s.getSInt32()),this.hasZ&&s.getSInt32(),this.hasM&&s.getSInt32();break}default:s.skip()}return a.length?new h(o,a):null}_parseGeometryForDisplay(e){const t=2,s=3,i=e.asUnsafe(),n=i.getLength(),a=i.pos()+n,o=[],d=[];let c=0,g=0,l=null,_=0;const y="esriGeometryPolygon"===this.geometryType;for(;i.pos()<a&&i.next();)switch(i.tag()){case t:{const e=i.getUInt32(),t=i.pos()+e;for(;i.pos()<t;){const e=i.getUInt32();o.push(e),c+=e}l=f(2*c).delta;break}case s:{i.getUInt32();const e=2+(this.hasZ?1:0)+(this.hasM?1:0);r(l);for(const t of o)if(g+e*t>l.length)for(let e=0;e<t;e++)i.getSInt32(),i.getSInt32(),this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();else if(y&&u){const e=this.getAreaSimplificationThreshold(t,this._header.vertexCount);let r=2,s=1;const n=!1;let a=i.getSInt32(),h=i.getSInt32();l[g++]=a,l[g++]=h,this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();let o=i.getSInt32(),u=i.getSInt32();for(this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();r<t;){let t=i.getSInt32(),n=i.getSInt32();this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32();const d=a+o,c=h+u;m(a,h,d,c,d+t,c+n)>=e?(_+=-.5*(d-a)*(c+h),s>1&&x(l[g-2],l[g-1],o,u)?(l[g-2]+=o,l[g-1]+=u):(l[g++]=o,l[g++]=u,s++),a=d,h=c):(t+=o,n+=u),o=t,u=n,r++}s<3||n?g-=2*s:(_+=-.5*(a+o-a)*(h+u+h),x(l[g-2],l[g-1],o,u)?(l[g-2]+=o,l[g-1]+=u,d.push(s)):(l[g++]=o,l[g++]=u,d.push(++s)))}else{let e=0,r=i.getSInt32(),s=i.getSInt32();this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32(),l[g++]=r,l[g++]=s,e+=1;for(let n=1;n<t;n++){const t=i.getSInt32(),a=i.getSInt32(),h=r+t,o=s+a;_+=-.5*(h-r)*(o+s),this.hasZ&&i.getSInt32(),this.hasM&&i.getSInt32(),n>2&&x(l[g-2],l[g-1],t,a)?(l[g-2]+=t,l[g-1]+=a):(l[g++]=t,l[g++]=a,e+=1),r=h,s=o}d.push(e)}break}default:i.skip()}if(this._cache.area=_,!d.length)return null;if(this._tx||this._ty){let e=0;r(l);for(const t of d)l[2*e]+=this._tx,l[2*e+1]+=this._ty,e+=t}return new h(d,l)}}export{S as FeatureSetReaderPBF};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as M}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{data:e}=this,{sketchViewModel:t}=e.viewModel,{activeComponent:a}=t,i=t.createGraphic?.geometry;if(("polyline"===i?.type||"polygon"===i?.type||"multipoint"===i?.type)&&("draw-2d"===a?.type||"draw-3d"===a?.type)&&a.drawOperation.committedVertices.length>0)return!0;const{upload:r}=e;return!(!r||"pending"!==r.state&&"success"!==r.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:p,sketchViewModel:u,view:h}=r;if(!h||!i)return;const f=i.layer,m=k(p,f),g=m?.formTemplate,y=h.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:h.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===h.type?h.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===h.type){const a=c((()=>h.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===h.type?h.scale:null)})),u.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:u,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await M({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const p=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const u=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&p.push(e._fadeExistingFeatures(i.creationInfo.layer)),p.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const p=e._visualVariableAttributes;await E(o,l,a,p,t);const u=l.attributes,{rotation:h,size:f}=p;if(null!=h){const{field:e}=h;n.setValue(e,u[e])}if(null!=f){const{field:e}=f;n.setValue(e,u[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(p),afterCommit:r((()=>{l.updateOnGraphicClick=u}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],p=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const u=D(o);d.push(u);const h=w(e?.layer);try{if(b(e)&&p.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),h){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),p.push(t.afterCommit),e?.initialFeature&&(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)),await this._startCreating(l)}}finally{u.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...p,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([h({constructOnly:!0})],N.prototype,"isNested",void 0),e([h()],N.prototype,"hasPendingEdits",null),e([h()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([h()],N.prototype,"helpMessage",null),e([h()],N.prototype,"parent",null),e([h()],N.prototype,"keyboardCancellationEnabled",null),e([h()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],N.prototype,"shouldShowAttachments",null),e([h()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as M}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{data:e}=this,{sketchViewModel:t}=e.viewModel,{activeComponent:a}=t,i=t.createGraphic?.geometry;if(("polyline"===i?.type||"polygon"===i?.type||"multipoint"===i?.type)&&("draw-2d"===a?.type||"draw-3d"===a?.type)&&a.drawOperation.committedVertices.length>0)return!0;const{upload:r}=e;return!(!r||"pending"!==r.state&&"success"!==r.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:p,sketchViewModel:u,view:h}=r;if(!h||!i)return;const f=i.layer,m=k(p,f),g=m?.formTemplate,y=h.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:h.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===h.type?h.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===h.type){const a=c((()=>h.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===h.type?h.scale:null)})),u.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:u,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await M({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const p=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const u=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&p.push(e._fadeExistingFeatures(i.creationInfo.layer)),p.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const p=e._visualVariableAttributes;await E(o,l,a,p,t);const u=l.attributes,{rotation:h,size:f}=p;if(null!=h){const{field:e}=h;n.setValue(e,u[e])}if(null!=f){const{field:e}=f;n.setValue(e,u[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(p),afterCommit:r((()=>{l.updateOnGraphicClick=u}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],p=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const u=D(o);d.push(u);const h=w(e?.layer);try{if(b(e)&&p.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),h){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),p.push(t.afterCommit),e?.initialFeature?(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)):await this._startCreating(l)}}finally{u.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...p,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([h({constructOnly:!0})],N.prototype,"isNested",void 0),e([h()],N.prototype,"hasPendingEdits",null),e([h()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([h()],N.prototype,"helpMessage",null),e([h()],N.prototype,"parent",null),e([h()],N.prototype,"keyboardCancellationEnabled",null),e([h()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],N.prototype,"shouldShowAttachments",null),e([h()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-feature-form",t=`${e}__group`,r=`${e}__input`,
|
|
5
|
+
const e="esri-feature-form",t=`${e}__group`,r=`${e}__input`,i=`${e}__related-records`,a={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,labelTextContent:`${e}__label-text-content`,fieldInput:`${r}`,inputRadio:`${r}--radio`,inputRadioGroup:`${r}--radio-group`,inputRadioLabel:`${r}--radio-label`,inputDisabled:`${r}--disabled`,inputSwitch:`${r}--switch`,inputInvalid:`${r}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordsHeader:`${i}_header`,relatedRecordsLabel:`${i}_label`,relatedRecordsList:`${i}_list`,dateInputContainer:`${`${e}__date`}-input-container`,group:t,groupSequential:`${t}--sequential`,groupActive:`${t}--active`};export{a as css};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as O,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as I}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as D,incrementHeadingLevel as x}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as T}from"../intl/substitute.js";const j="data-field-name",S="esri.widgets.FeatureForm",E=o.getLogger(S);let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,M.widget,M.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(D,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?x(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?T(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n,updating:a}=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)}if("datetime-picker"===o||"date"===t)return this._renderDateComponents(e,s);const r="number"===t?this._renderNumberComponent(e,s):this._renderStringComponent(e,s);return a?L("div",{class:p.fieldInputWrapper,key:`${s.key}-input-updating-wrapper`},r,L("div",{class:p.fieldInputLoader},L("calcite-progress",{type:"indeterminate"}))):r}_renderStringComponent(e,t){return L("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldCompnents(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,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[j],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[j],key:`${a}-time-input`,numberingSystem:F,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,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[j]:i,onfocus:this._onComponentFocus};return L("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},L("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[j]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,g=null!=l?w(l,u):void 0;return L("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:g?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[j],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:T(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=T(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[j]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(j))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;let a=this.viewModel.getValue(o),s=null;"date-only"===i?s=e.value:"time-only"===i?(a=O(a),s=O(e.value)):s="timestamp-offset"===i?null!=e.value?k({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?I({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:E.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),N(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r(S)],U);const $=U;export{$ as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as O,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as I}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as D,incrementHeadingLevel as x}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const j="data-field-name",S="esri.widgets.FeatureForm",E=o.getLogger(S);let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return T("div",{class:this.classes(p.base,M.widget,M.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return T("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&T(D,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&T("p",{class:p.description,key:"description"},e.formDescription);return T("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:T("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return T("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?x(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?L(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[T("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?T("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?T("label",{...s},r):T("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 T("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return T("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._renderDateFieldCompnents(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,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return T("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[j],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`: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 T("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[j],key:`${a}-time-input`,numberingSystem:F,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,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[j]:i,onfocus:this._onComponentFocus};return T("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},T("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),T("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?T("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[j]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,g=null!=l?w(l,u):void 0;return T("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},T("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:g?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?T("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return T("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>T("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(T("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[T("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),T("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(T("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return T("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return T("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[j],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return T("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return T("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},T("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?T("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return T("calcite-list-item",{description:L(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},T("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 T("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return T("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},T("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),T("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 T("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},T("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return T("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},T("span",null,e.label),t?T("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return T("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return T("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[j]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(j))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;let a=this.viewModel.getValue(o),s=null;"date-only"===i?s=e.value:"time-only"===i?(a=O(a),s=O(e.value)):s="timestamp-offset"===i?null!=e.value?k({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?I({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:E.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),N(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r(S)],U);const $=U;export{$ as default};
|