@arcgis/core 4.28.0-next.20231002 → 4.28.0-rc.0
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/02120d192eafd7612475.js +1 -0
- package/assets/esri/core/workers/chunks/{4d967e98d229f18d61f5.js → 09e8babe75407c2e64c4.js} +1 -1
- package/assets/esri/core/workers/chunks/0beebbb0c6dad0e742d7.js +1 -0
- package/assets/esri/core/workers/chunks/0d8ca51043c7784aed96.js +1 -0
- package/assets/esri/core/workers/chunks/112e89da628bdea5355c.js +1 -0
- package/assets/esri/core/workers/chunks/{5e9edd06e624f385fa4b.js → 121a9e148509f2fe2210.js} +1 -1
- package/assets/esri/core/workers/chunks/1856d16d738f44f58084.js +1 -0
- package/assets/esri/core/workers/chunks/{0526d623d0b4c12929bd.js → 18ab9cc85a1a7988fdfd.js} +1 -1
- package/assets/esri/core/workers/chunks/{7c960a2694c4c3123acf.js → 1a36703ebe934749646e.js} +1 -1
- package/assets/esri/core/workers/chunks/24a0cf405195421c0d06.js +1 -0
- package/assets/esri/core/workers/chunks/24ff267cf253feac22de.js +1 -0
- package/assets/esri/core/workers/chunks/{3c8613596659801fd6ab.js → 29cab345819ec02ed60a.js} +1 -1
- package/assets/esri/core/workers/chunks/{169a61c6e128b8a16021.js → 2c560a075d9ef2069ed1.js} +1 -1
- package/assets/esri/core/workers/chunks/2f8e71dac98135bbc3e6.js +1 -0
- package/assets/esri/core/workers/chunks/341fb51b2165522963b3.js +1 -0
- package/assets/esri/core/workers/chunks/{ad8e0f82cb1feafa9e2f.js → 36ab90fb34b9716a9983.js} +1 -1
- package/assets/esri/core/workers/chunks/{2688213bbff536da7917.js → 3ea0b872436fce84b927.js} +1 -1
- package/assets/esri/core/workers/chunks/40633064c290dc2af9ea.js +1 -0
- package/assets/esri/core/workers/chunks/42ec4c80b0c2944cd65c.js +1 -0
- package/assets/esri/core/workers/chunks/44b870cb53ba68b17c32.js +1 -0
- package/assets/esri/core/workers/chunks/{8a7fa4e8b0d14da7c9eb.js → 4cc680fe4c9c39d2f853.js} +1 -1
- package/assets/esri/core/workers/chunks/{6730c9f0890191a95fdb.js → 4d81aa50d90f5701a343.js} +1 -1
- package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +1 -0
- package/assets/esri/core/workers/chunks/4e6bf1efe3b0b474cbb4.js +1 -0
- package/assets/esri/core/workers/chunks/52cef7cd3aaaa4f45c94.js +1 -0
- package/assets/esri/core/workers/chunks/{4e04242e707c0eb3aa4a.js → 5a3ccc0a19ac8fa9e524.js} +1 -1
- package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +1 -0
- package/assets/esri/core/workers/chunks/66ba749ab0a631bbfdec.js +1 -0
- package/assets/esri/core/workers/chunks/6b14d89d689a21014aec.js +1 -0
- package/assets/esri/core/workers/chunks/6b1856303d1562f05100.js +1 -0
- package/assets/esri/core/workers/chunks/{576269fd1f9049876aa1.js → 6b7b5544ed1f9a84623f.js} +1 -1
- package/assets/esri/core/workers/chunks/710a6268de62003af825.js +1 -0
- package/assets/esri/core/workers/chunks/77923afde29ae1ff10ca.js +1 -0
- package/assets/esri/core/workers/chunks/784ffd52315a4d55d683.js +1 -0
- package/assets/esri/core/workers/chunks/7cf7f2b991a7cbdad2ce.js +1 -0
- package/assets/esri/core/workers/chunks/{70dffbf49b0633b1a5f1.js → 8f3680fee85a05839489.js} +1 -1
- package/assets/esri/core/workers/chunks/97aecf210938015cc7a3.js +1 -0
- package/assets/esri/core/workers/chunks/{c7ebd5d431fb996bfcee.js → 9f8207c82a17508a87a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{557305b91f77569ce664.js → a01ffe03b1465c21b9e6.js} +1 -1
- package/assets/esri/core/workers/chunks/a298c9031962951e55a9.js +1 -0
- package/assets/esri/core/workers/chunks/{329669a9beda89b028dd.js → a5a7bbdd8298016535bc.js} +1 -1
- package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +1 -0
- package/assets/esri/core/workers/chunks/ad38e456a7cee940a165.js +1 -0
- package/assets/esri/core/workers/chunks/adfbc168be8c49b51e1b.js +1 -0
- package/assets/esri/core/workers/chunks/b0526633a93ef69ec47b.js +1 -0
- package/assets/esri/core/workers/chunks/b99bc08a01e9250b0a31.js +1 -0
- package/assets/esri/core/workers/chunks/{36c4b4c3eca57417da2c.js → c260ad3434bb00ba64a7.js} +1 -1
- package/assets/esri/core/workers/chunks/{39922ce232338de076ae.js → c459c8d8630eb4b955b1.js} +1 -1
- package/assets/esri/core/workers/chunks/c92e75b79aff7b505b31.js +1 -0
- package/assets/esri/core/workers/chunks/ca85e88dad30b5f2956b.js +1 -0
- package/assets/esri/core/workers/chunks/{8e56d40691b6bf75d7cc.js → ce409944221a784ddb61.js} +1 -1
- package/assets/esri/core/workers/chunks/d13f75f233cf313e5a1d.js +1 -0
- package/assets/esri/core/workers/chunks/d60d5f006375f7fcc88c.js +1 -0
- package/assets/esri/core/workers/chunks/{77958089748dc31757cf.js → d6ded127949160103f69.js} +1 -1
- package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +1 -0
- package/assets/esri/core/workers/chunks/{304c81f6297ecba3a324.js → d95eed98316e59f8f35d.js} +1 -1
- package/assets/esri/core/workers/chunks/df7267892b6e0493e1d7.js +1 -0
- package/assets/esri/core/workers/chunks/{52dca349e1a45555954d.js → e52d5a48e83d8df36f92.js} +1 -1
- package/assets/esri/core/workers/chunks/e8688b6cc3b3c1010b43.js +1 -0
- package/assets/esri/core/workers/chunks/e8c7cc974420c0b92d0e.js +1 -0
- package/assets/esri/core/workers/chunks/{b7ef554b1213307499fc.js → e93442c6d92229f3a4b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{ef5772ca1848d6d01b88.js → eda86faa708cfe4c9f9a.js} +1 -1
- package/assets/esri/core/workers/chunks/f2718e260f594537f7fd.js +1 -0
- package/assets/esri/core/workers/chunks/f6b7036114b1d754fdd9.js +1 -0
- package/assets/esri/core/workers/chunks/{c4631241dc777ca77aaa.js → f6c0680c535c5a3c73ee.js} +1 -1
- package/assets/esri/core/workers/chunks/{a0ea1d3e22d52b8a59a8.js → fa6103e3d4e857b0035b.js} +9 -9
- package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +1 -0
- package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
- package/assets/esri/t9n/common.json +1 -1
- package/assets/esri/t9n/common_ar.json +1 -1
- package/assets/esri/t9n/common_bg.json +1 -1
- package/assets/esri/t9n/common_bs.json +1 -1
- package/assets/esri/t9n/common_ca.json +1 -1
- package/assets/esri/t9n/common_cs.json +1 -1
- package/assets/esri/t9n/common_da.json +1 -1
- package/assets/esri/t9n/common_de.json +1 -1
- package/assets/esri/t9n/common_el.json +1 -1
- package/assets/esri/t9n/common_en.json +1 -1
- package/assets/esri/t9n/common_es.json +1 -1
- package/assets/esri/t9n/common_et.json +1 -1
- package/assets/esri/t9n/common_fi.json +1 -1
- package/assets/esri/t9n/common_fr.json +1 -1
- package/assets/esri/t9n/common_he.json +1 -1
- package/assets/esri/t9n/common_hr.json +1 -1
- package/assets/esri/t9n/common_hu.json +1 -1
- package/assets/esri/t9n/common_id.json +1 -1
- package/assets/esri/t9n/common_it.json +1 -1
- package/assets/esri/t9n/common_ja.json +1 -1
- package/assets/esri/t9n/common_ko.json +1 -1
- package/assets/esri/t9n/common_lt.json +1 -1
- package/assets/esri/t9n/common_lv.json +1 -1
- package/assets/esri/t9n/common_nb.json +1 -1
- package/assets/esri/t9n/common_nl.json +1 -1
- package/assets/esri/t9n/common_pl.json +1 -1
- package/assets/esri/t9n/common_pt-BR.json +1 -1
- package/assets/esri/t9n/common_pt-PT.json +1 -1
- package/assets/esri/t9n/common_ro.json +1 -1
- package/assets/esri/t9n/common_ru.json +1 -1
- package/assets/esri/t9n/common_sk.json +1 -1
- package/assets/esri/t9n/common_sl.json +1 -1
- package/assets/esri/t9n/common_sr.json +1 -1
- package/assets/esri/t9n/common_sv.json +1 -1
- package/assets/esri/t9n/common_th.json +1 -1
- package/assets/esri/t9n/common_tr.json +1 -1
- package/assets/esri/t9n/common_uk.json +1 -1
- package/assets/esri/t9n/common_vi.json +1 -1
- package/assets/esri/t9n/common_zh-CN.json +1 -1
- package/assets/esri/t9n/common_zh-HK.json +1 -1
- package/assets/esri/t9n/common_zh-TW.json +1 -1
- package/assets/esri/themes/base/widgets/_DirectionalPad.scss +2 -1
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/pe-wasm.js +1 -1
- package/config.js +1 -1
- package/core/pbf.js +1 -1
- package/geometry/support/WKIDUnitConversion.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/interfaces.d.ts +37 -39
- package/kernel.js +1 -1
- package/layers/GroupLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/WFSSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/groupLayerUtils.js +5 -0
- package/layers/save/utils.js +1 -1
- package/layers/support/LayerLoadContext.js +5 -0
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/labelFormatUtils.js +1 -1
- package/layers/support/layersCreator.js +1 -1
- package/layers/support/versionUtils.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/support/jsonContext.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +5 -0
- package/portal/support/portalItemUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/rest/print.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/PolygonSymbol3D.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/colorizer/shadedrelief.js +1 -1
- package/views/2d/engine/imagery/colorizer/stretch.js +1 -1
- package/views/2d/input/handlers/KeyPan.js +1 -1
- package/views/2d/input/handlers/KeyRotate.js +1 -1
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js +1 -1
- package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/i3s/featureEditing.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/input/VisibilityChange.js +5 -0
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/FeatureSnappingSourceInfo.js +5 -0
- package/views/interactive/snapping/SnappingContext.js +1 -1
- package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/webdoc/support/saveUtils.js +1 -1
- package/webdoc/webdocSaveUtils.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
- package/widgets/DirectionalPad/constants.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/support/DatePicker.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation2D.js +1 -1
- package/widgets/support/Selector2D.js +1 -1
- package/widgets/support/TimePicker.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/027f8b57565c65fbccda.js +0 -1
- package/assets/esri/core/workers/chunks/048265fb5953350e3e33.js +0 -1
- package/assets/esri/core/workers/chunks/0b9cf14f8aafb76c578b.js +0 -1
- package/assets/esri/core/workers/chunks/0ebf58c927bfc4c9d4fe.js +0 -1
- package/assets/esri/core/workers/chunks/10fd951bd296b2beeeba.js +0 -1
- package/assets/esri/core/workers/chunks/1224475f3eefdfd59c76.js +0 -1
- package/assets/esri/core/workers/chunks/162b0220e24e9ba72655.js +0 -1
- package/assets/esri/core/workers/chunks/1e611cad53b745ee146f.js +0 -1
- package/assets/esri/core/workers/chunks/24b1bf1a5d80f43a6c9a.js +0 -1
- package/assets/esri/core/workers/chunks/29ed31fd4f9d5cf53686.js +0 -1
- package/assets/esri/core/workers/chunks/2b6d1c8e4ed759767827.js +0 -1
- package/assets/esri/core/workers/chunks/34b44b0fab88f838885c.js +0 -1
- package/assets/esri/core/workers/chunks/364f55294a1d7bf163d7.js +0 -1
- package/assets/esri/core/workers/chunks/3714ab435dd5ccf9e694.js +0 -1
- package/assets/esri/core/workers/chunks/3788009a5ece453011f3.js +0 -1
- package/assets/esri/core/workers/chunks/3aafe8160b3bfbaa6935.js +0 -1
- package/assets/esri/core/workers/chunks/41c002e4c42c581cda8d.js +0 -1
- package/assets/esri/core/workers/chunks/47be4c75dd6372b96fe4.js +0 -1
- package/assets/esri/core/workers/chunks/4e8d1e6051f6654a5e83.js +0 -1
- package/assets/esri/core/workers/chunks/53746e9976758630159b.js +0 -1
- package/assets/esri/core/workers/chunks/5449fdd69e12e5cbd12a.js +0 -1
- package/assets/esri/core/workers/chunks/57ce4ece0147afb0d43c.js +0 -1
- package/assets/esri/core/workers/chunks/5e83d21400a5dec05c81.js +0 -1
- package/assets/esri/core/workers/chunks/6047f4487dcd37cca98e.js +0 -1
- package/assets/esri/core/workers/chunks/6967d2b3721678b38774.js +0 -1
- package/assets/esri/core/workers/chunks/6ac5ca7de651e3d672a1.js +0 -1
- package/assets/esri/core/workers/chunks/6b7ee9164149428edb9e.js +0 -1
- package/assets/esri/core/workers/chunks/6c495077cc79e1898927.js +0 -1
- package/assets/esri/core/workers/chunks/6d43648d5326e01b4474.js +0 -1
- package/assets/esri/core/workers/chunks/74fb07de0f990d45af89.js +0 -1
- package/assets/esri/core/workers/chunks/8e9a52062ce059153a89.js +0 -1
- package/assets/esri/core/workers/chunks/919a57d372419785cd5e.js +0 -1
- package/assets/esri/core/workers/chunks/939f0a1a7d605e389e45.js +0 -1
- package/assets/esri/core/workers/chunks/9932f23ba6589df14a3d.js +0 -1
- package/assets/esri/core/workers/chunks/a25a38c9f338e0beffef.js +0 -1
- package/assets/esri/core/workers/chunks/a97581e584336b46ede7.js +0 -1
- package/assets/esri/core/workers/chunks/b1cb932cfadc4dc3f1e4.js +0 -1
- package/assets/esri/core/workers/chunks/be3fb6113b0b27b94537.js +0 -1
- package/assets/esri/core/workers/chunks/c37119f5692e19aa1ce2.js +0 -1
- package/assets/esri/core/workers/chunks/c685f16435d9861bbbd0.js +0 -1
- package/assets/esri/core/workers/chunks/d5dfc03673aec8aa57e2.js +0 -1
- package/assets/esri/core/workers/chunks/e6416a2684866d677b3e.js +0 -1
- package/assets/esri/core/workers/chunks/eb01f4cdb9b918cc61e7.js +0 -1
- package/assets/esri/core/workers/chunks/eb4aed4fdb44495a4fe6.js +0 -1
- package/assets/esri/core/workers/chunks/ec8258c9dc1491e97fc8.js +0 -1
- package/assets/esri/core/workers/chunks/eeac53da496de4cd4182.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{r as t,d as i}from"../../../chunks/Responsive.js";import"../../../intl.js";import{binaryFindClosest as e}from"../../../core/arrayUtils.js";import{handlesGroup as n,makeHandle as o}from"../../../core/handleUtils.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{signal as a}from"../../../core/signal.js";import{formatDecimal as l,unitName as r}from"../../../core/unitFormatUtils.js";import{convertUnit as d}from"../../../core/unitUtils.js";import{g as c}from"../../../chunks/common.js";import{getConfig as p,notAvailable as m}from"./constants.js";import{getTranslatedLineTitle as u}from"./intlUtils.js";import{niceScale as f}from"./niceScale.js";import{c as x,N as g}from"../../../chunks/chartUtilsAm5.js";import{isRTL as h}from"../../support/widgetUtils.js";import{isDarkTheme as A}from"../../../support/themeUtils.js";import{X as v,V as b,A as y,a as T,b as L,L as M}from"../../../chunks/LineSeries.js";import{aq as S,a6 as F,a4 as k,C as P}from"../../../chunks/Theme.js";import{T as X}from"../../../chunks/Tooltip.js";import{substitute as Y}from"../../../intl/substitute.js";import{formatNumber as z}from"../../../intl/number.js";const C="#f8f8f8",j="#a9a9a9",w="#323232",H="line",B="fill",U=15,D=12,R=.001,O=.1,W=.02,G={fontFamily:"Avenir Next",paddingBottom:D/2,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:j,axisTooltipFontSize:12,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,axisTooltipPaddingTop:Math.round(D/4),axisTooltipPaddingBottom:Math.round(D/4),axisTooltipPaddingHorizontal:Math.round(U/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(D/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(U/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:C,seriesTooltipLabelColor:w,seriesFillLighten:.9,seriesTooltipSpacing:D/2,seriesTooltipPaddingVertical:Math.round(U/4),seriesTooltipPaddingHorizontal:Math.round(U/4)},V={...G,axisGridStroke:w,axisLabelsColor:j,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:C,seriesFillLighten:-.75},E={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function I(e){const o=await x(e.container);s(e.abortOptions);const l=A(),r=l?V:G;o.setThemes(l?[t.new(o),i.new(o)]:[t.new(o)]);const d=h(e.container),c=o.container.children.push(v.new(o,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:d?r.paddingRight:r.paddingLeft,paddingRight:d?r.paddingLeft:r.paddingRight,maxTooltipDistance:0}));c.zoomOutButton.set("forceHidden",!0);const p=c.xAxes.push(b.new(o,{renderer:y.new(o,{})})),m=c.yAxes.push(b.new(o,{renderer:T.new(o,{})})),u=a(null),f=a("loading"),g={params:e,chart:c,xAxis:p,yAxis:m,seriesInfos:new Map,messages:null,theme:r,pointerIsOver:!1,get state(){return f.value},get data(){return u.value},set data(t){u.value=t}};Z(g),q(g),N(g);const L=n([lt(g,e.onRangeChange),dt(g,e.onCursorPositionChange),yt(o.events.once("frameended",(()=>{f.value="ready"}))),yt(o)]);return{destroy:()=>{L.remove(),f.value="destroyed"},update:t=>{t.data===g.data&&t.messages===g.messages||$(g)||J(g,t)},zoomOut:()=>K(g)}}function $(t){return"destroyed"===t.state}function N({chart:t,xAxis:i,yAxis:e}){const n=L.new(t.root,{behavior:"none",xAxis:i,yAxis:e});n.lineY.set("visible",!1),t.set("cursor",n)}function Z(t){const{chart:i,xAxis:e,theme:n}=t;e.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),e.axisHeader.set("forceHidden",!0);const o=e.get("renderer");o.setAll({inside:!1,minGridDistance:n.xAxisMinGridDistance}),o.labels.template.setAll({centerX:S,centerY:S,fill:F(n.axisLabelsColor),fontFamily:n.fontFamily,fontSize:n.axisLabelsFontSize,fontWeight:n.axisLabelsFontWeight,maxPosition:n.xAxisMaxLabelPosition,minPosition:n.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:n.xAxisLabelsSpacing});const s=e.set("tooltip",X.new(i.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));s.get("background")?.setAll({fill:F(n.axisTooltipBackgroundColor),stroke:void 0}),s.label.setAll({fill:F(n.axisTooltipLabelColor),fontFamily:n.fontFamily,fontSize:n.axisTooltipFontSize,paddingBottom:n.axisTooltipPaddingBottom,paddingLeft:n.axisTooltipPaddingHorizontal,paddingRight:n.axisTooltipPaddingHorizontal,paddingTop:n.axisTooltipPaddingTop}),o.grid.template.setAll({strokeOpacity:1,stroke:F(n.axisGridStroke)})}function q(t){const{yAxis:i,theme:e}=t;i.setAll({baseValue:p().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),i.axisHeader.set("visible",!1);const n=h(t.params.container),o=i.get("renderer");o.setAll({minGridDistance:e.yAxisMinGridDistance,opposite:n,inside:!0}),o.labels.template.setAll({centerX:S,centerY:k,fill:F(e.axisLabelsColor),fontFamily:e.fontFamily,fontSize:e.axisLabelsFontSize,fontWeight:e.axisLabelsFontWeight,maxPosition:e.yAxisMaxLabelPosition,minPosition:e.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:n?0:e.yAxisLabelSpacing,paddingRight:n?e.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),o.grid.template.setAll({strokeOpacity:1,stroke:F(e.axisGridStroke)})}function J(t,i){if($(t))return;const e=t.data??void 0,n=i.data??void 0;t.chart.get("cursor")?.set("forceHidden",!n?.refined);const o=e!==n,s=e?.effectiveUnits!==n?.effectiveUnits,a=e?.uniformScaling!==n?.uniformScaling;t.data=n,t.messages=i.messages,(o||s)&&(Q(t),et(t)),a&&K(t),pt(t)}function K(t){$(t)||(t.xAxis.zoom(0,1),t.yAxis.zoom(0,1))}function Q(t){const{chart:i,data:e,xAxis:n,yAxis:o}=t,{minX:s,maxX:a,minY:l,maxY:r}=_({data:e,pixelWidth:n.width(),pixelHeight:o.height()}),d=e?.uniformScaling;i.setAll({panX:!0,panY:d,pinchZoomX:d,pinchZoomY:d,wheelX:"panX",wheelY:d?"zoomXY":"zoomX"}),n.setAll({max:a,min:s,panX:!0,panY:!1,zoomX:!0,zoomY:d}),o.setAll({max:r,min:l,panX:!1,panY:d,zoomX:d,zoomY:d})}function _({data:t,pixelWidth:i,pixelHeight:e}){if(null==t)return E;const n=t.statistics,o=0,s=n?.maxDistance;let a=n?.minElevation,l=n?.maxElevation;if(null==s||null==a||null==l)return E;const r=Math.max(s-o,R);let c=Math.max(l-a,R);const m=t.effectiveUnits;if(t.dynamicElevationRange){const t=d(r,m.distance,m.elevation);c=Math.max(c,t/p().maxChartRatio)}return a-=W*c,l=a+c+O*c,[a,l]=f(a,l,10),c=l-a,t.uniformScaling?tt({data:t,bounds:{minX:o,maxX:s,minY:a,maxY:l},pixelWidth:i,pixelHeight:e,centered:!0}):{minX:o,maxX:o+r,minY:a,maxY:a+c}}function tt({data:t,bounds:i,pixelWidth:e,pixelHeight:n,centered:o}){if(null==t)return i;let{minX:s,maxX:a,minY:l,maxY:r}=i;if(null==s||null==a||null==l||null==r)return E;const c=a-s,p=r-l,m=t.effectiveUnits,u=d(p,m.elevation,m.distance)/n/(c/e);return u>=1?[s,a]=it([s,a],u,o):[l,r]=it([l,r],1/u,o),{minX:s,maxX:a,minY:l,maxY:r}}function it([t,i],e,n){const o=(i-t)*e;if(n){const e=(t+i)/2-o/2;return[e,e+o]}return[t,t+o]}function et(t){const{chart:i,data:e,seriesInfos:n,xAxis:o,yAxis:s}=t;if(null==e||0===e.lines.length)return void i.series.clear();const a=new Map,l=new Set(i.series.values),r=e.lines.length;for(let d=0;d<r;d++){const o=e.lines[d];let s=n.get(o.id);s?(s.fill&&l.delete(s.fill),l.delete(s.line)):(s=ot(t,o),s.fill&&i.series.push(s.fill),i.series.push(s.line)),a.set(s.id,s);const c=r-d-1;s.fill?.set("layer",c),s.line.set("layer",r+c),nt(t,s,o)}t.seriesInfos=a;for(const d of l)i.series.removeValue(d);o.set("layer",r+1),s.set("layer",r+2)}function nt({theme:t},i,e){const n=F(e.color.toCss()),o=e.samples??[],s=o.length>0,{line:a,fill:l}=i;a.set("visible",s),a.set("stroke",n),l?.set("visible",s),l?.set("fill",P.lighten(n,t.seriesFillLighten)),a.data.setAll(o),l?.data.setAll(o)}function ot(t,i){const{id:e}=i,n=st(t,`${H}-${e}`);n.setAll({dy:i.chartStrokeOffsetY,tooltip:at(t)}),n.strokes.template.setAll({strokeWidth:i.chartStrokeWidth});let o=null;return i.chartFillEnabled&&(o=st(t,`${B}-${e}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:e,line:n,fill:o}}function st(t,i){return M.new(t.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:i,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:t.xAxis,yAxis:t.yAxis})}function at({theme:t,chart:i}){const e=X.new(i.root,{forceHidden:!0,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return e.label.setAll({fill:F(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:n,paddingRight:n,paddingTop:o,textAlign:"start"}),e.get("background")?.setAll({stroke:void 0,fill:F(t.seriesTooltipBackgroundColor)}),e.adapters.add("dy",(i=>{const n=t.seriesTooltipSpacing,o=e.get("pointTo")?.y??0;return(i??0)+(e.y()>o?n:-n)})),e}function lt(t,i){const{xAxis:e,yAxis:n}=t,o=()=>{i(rt(e),rt(n))},s=t=>[t.on("start",o),t.on("end",o)];return bt([...s(e),...s(n)])}function rt(t){const i=Math.abs((t.get("end")??0)-(t.get("start")??0)),e=0!==i?1/i:1;return Math.abs(1-e)<c()?1:e}function dt(t,i){const{chart:e,xAxis:n,yAxis:o}=t,s=e.get("cursor"),a=e.plotContainer.events,l=i=>{t.pointerIsOver=i,pt(t)},r=()=>{l(!1),i(null,null)};return bt([s?.events.on("cursormoved",(()=>{if(!t.pointerIsOver)return;pt(t);let e=s?.getPrivate("positionX")??0,a=s?.getPrivate("positionY")??0;const l=t.data;if(null!=l?.statistics){const{maxDistance:t,minElevation:i,maxElevation:s}=l.statistics;if(null!=t){e=ct(e,At(n),vt(n),0,t)}if(null!=i&&null!=s){a=ct(a,At(o),vt(o),i,s)}}i(e,a)})),a.on("pointerover",(()=>l(!0))),a.on("pointerout",r),a.on("blur",r)])}function ct(t,i,e,n,o){return(i+t*(e-i)-n)/(o-n)}function pt(t){const i=mt(t);if(!i)return void t.seriesInfos.forEach((t=>{t.line.get("tooltip")?.set("forceHidden",!0)}));t.seriesInfos.forEach((t=>{const e=t.line.get("tooltip");e.set("forceHidden",!1),e.label.set("text",i)}));t.xAxis.getTooltip().setAll({tooltipText:xt(t)})}function mt(t){const{data:i}=t,e=i?.lines.map((i=>({line:i,y:ht(t,i)?.elevation}))).sort(ut);return e&&0!==e.length&&null!=e[0].y?e.map((({y:i,line:e})=>ft(t,e,i))).join("\n"):null}function ut({y:t},{y:i}){return null==t?1:null==i?-1:i-t}function ft(t,i,e){const{data:n,messages:o}=t;if(null==n||null==o)return"";const s=p().formatPrecision,a=Y(o.chartTooltip,{name:u(i,o),elevation:null!=e?l(o,e,n.effectiveUnits.elevation,s):m});return`[${i.color.toHex()}]●[/] ${a}`}function xt(t){const{data:i,messages:e}=t;if(null==i||null==e)return"";const n=i.lines[0],o=n?ht(t,n):null,s=p().formatPrecision;return null!=o?l(e,o.distance,i.effectiveUnits.distance,s):"-"}function gt(t,i){const e=g.new(t.chart.root,{});return e.format=(e,n,o)=>{const{data:s,messages:a}=t;if(null==a||null==s||"string"==typeof e)return"";return`${z(e,{maximumFractionDigits:o})} ${r(a,s.effectiveUnits[i],"abbr")}`},e}function ht({chart:t,xAxis:i},n){const o=n.samples??[];if(0===o.length)return null;const s=t.get("cursor"),a=s?.getPrivate("positionX")??0,l=i.toAxisPosition(a),r=i.positionToValue(l);return e(o,r,(t=>t.distance))}function At(t){return t.positionToValue(t.get("start")??0)}function vt(t){return t.positionToValue(t.get("end")??1)}function bt(t){return n(t.map(yt))}function yt(t){return o((()=>{t?.dispose()}))}export{I as createChart,_ as getAdjustedBounds};
|
|
5
|
+
import{r as t,d as i}from"../../../chunks/Responsive.js";import"../../../intl.js";import{binaryFindClosest as e}from"../../../core/arrayUtils.js";import{handlesGroup as n,makeHandle as o}from"../../../core/handleUtils.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{signal as a}from"../../../core/signal.js";import{formatDecimal as l,unitName as r}from"../../../core/unitFormatUtils.js";import{convertUnit as d}from"../../../core/unitUtils.js";import{g as c}from"../../../chunks/common.js";import{getConfig as p,notAvailable as m}from"./constants.js";import{getTranslatedLineTitle as u}from"./intlUtils.js";import{niceScale as f}from"./niceScale.js";import{c as x,N as g}from"../../../chunks/chartUtilsAm5.js";import{isRTL as h}from"../../support/widgetUtils.js";import{isDarkTheme as A}from"../../../support/themeUtils.js";import{X as v,V as b,A as y,a as T,b as L,L as M}from"../../../chunks/LineSeries.js";import{aq as S,a6 as F,a4 as k,C as P}from"../../../chunks/Theme.js";import{T as X}from"../../../chunks/Tooltip.js";import{substitute as Y}from"../../../intl/substitute.js";import{formatNumber as z}from"../../../intl/number.js";const C="#f8f8f8",j="#a9a9a9",w="#323232",H="line",B="fill",U=15,D=12,R=.001,O=.1,W=.02,G={fontFamily:"Avenir Next",paddingBottom:D/2,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:j,axisTooltipFontSize:12,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,axisTooltipPaddingTop:Math.round(D/4),axisTooltipPaddingBottom:Math.round(D/4),axisTooltipPaddingHorizontal:Math.round(U/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(D/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(U/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:C,seriesTooltipLabelColor:w,seriesFillLighten:.9,seriesTooltipSpacing:D/2,seriesTooltipPaddingVertical:Math.round(U/4),seriesTooltipPaddingHorizontal:Math.round(U/4)},V={...G,axisGridStroke:w,axisLabelsColor:j,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:C,seriesFillLighten:-.75},E={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function I(e){const o=await x(e.container);s(e.abortOptions);const l=A(),r=l?V:G;o.setThemes(l?[t.new(o),i.new(o)]:[t.new(o)]);const d=h(e.container),c=o.container.children.push(v.new(o,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:d?r.paddingRight:r.paddingLeft,paddingRight:d?r.paddingLeft:r.paddingRight,maxTooltipDistance:0}));c.zoomOutButton.set("forceHidden",!0);const p=c.xAxes.push(b.new(o,{renderer:y.new(o,{})})),m=c.yAxes.push(b.new(o,{renderer:T.new(o,{})})),u=a(null),f=a("loading"),g={params:e,chart:c,xAxis:p,yAxis:m,seriesInfos:new Map,messages:null,theme:r,pointerIsOver:!1,get state(){return f.value},get data(){return u.value},set data(t){u.value=t}};Z(g),q(g),N(g);const L=n([lt(g,e.onRangeChange),dt(g,e.onCursorPositionChange),yt(o.events.once("frameended",(()=>{f.value="ready"}))),yt(o)]);return{destroy:()=>{L.remove(),f.value="destroyed"},update:t=>{t.data===g.data&&t.messages===g.messages||$(g)||J(g,t)},zoomOut:()=>K(g)}}function $(t){return"destroyed"===t.state}function N({chart:t,xAxis:i,yAxis:e}){const n=L.new(t.root,{behavior:"none",xAxis:i,yAxis:e});n.lineY.set("visible",!1),t.set("cursor",n)}function Z(t){const{chart:i,xAxis:e,theme:n}=t;e.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),e.axisHeader.set("forceHidden",!0);const o=e.get("renderer");o.setAll({inside:!1,minGridDistance:n.xAxisMinGridDistance}),o.labels.template.setAll({centerX:S,centerY:S,fill:F(n.axisLabelsColor),fontFamily:n.fontFamily,fontSize:n.axisLabelsFontSize,fontWeight:n.axisLabelsFontWeight,maxPosition:n.xAxisMaxLabelPosition,minPosition:n.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:n.xAxisLabelsSpacing});const s=e.set("tooltip",X.new(i.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));s.get("background")?.setAll({fill:F(n.axisTooltipBackgroundColor),stroke:void 0}),s.label.setAll({fill:F(n.axisTooltipLabelColor),fontFamily:n.fontFamily,fontSize:n.axisTooltipFontSize,paddingBottom:n.axisTooltipPaddingBottom,paddingLeft:n.axisTooltipPaddingHorizontal,paddingRight:n.axisTooltipPaddingHorizontal,paddingTop:n.axisTooltipPaddingTop}),o.grid.template.setAll({strokeOpacity:1,stroke:F(n.axisGridStroke)})}function q(t){const{yAxis:i,theme:e}=t;i.setAll({baseValue:p().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),i.axisHeader.set("visible",!1);const n=h(t.params.container),o=i.get("renderer");o.setAll({minGridDistance:e.yAxisMinGridDistance,opposite:n,inside:!0}),o.labels.template.setAll({centerX:S,centerY:k,fill:F(e.axisLabelsColor),fontFamily:e.fontFamily,fontSize:e.axisLabelsFontSize,fontWeight:e.axisLabelsFontWeight,maxPosition:e.yAxisMaxLabelPosition,minPosition:e.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:n?0:e.yAxisLabelSpacing,paddingRight:n?e.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),o.grid.template.setAll({strokeOpacity:1,stroke:F(e.axisGridStroke)})}function J(t,i){if($(t))return;const e=t.data??void 0,n=i.data??void 0;t.chart.get("cursor")?.set("forceHidden",!n?.refined);const o=e!==n,s=e?.effectiveUnits!==n?.effectiveUnits,a=e?.uniformScaling!==n?.uniformScaling;t.data=n,t.messages=i.messages,(o||s)&&(Q(t),et(t)),a&&K(t),pt(t)}function K(t){$(t)||(t.xAxis.zoom(0,1),t.yAxis.zoom(0,1))}function Q(t){const{chart:i,data:e,xAxis:n,yAxis:o}=t,{minX:s,maxX:a,minY:l,maxY:r}=_({data:e,pixelWidth:n.width(),pixelHeight:o.height()}),d=e?.uniformScaling;i.setAll({panX:!0,panY:d,pinchZoomX:!0,pinchZoomY:d,wheelX:"panX",wheelY:d?"zoomXY":"zoomX"}),n.setAll({max:a,min:s,panX:!0,panY:!1,zoomX:!0,zoomY:d}),o.setAll({max:r,min:l,panX:!1,panY:d,zoomX:d,zoomY:d})}function _({data:t,pixelWidth:i,pixelHeight:e}){if(null==t)return E;const n=t.statistics,o=0,s=n?.maxDistance;let a=n?.minElevation,l=n?.maxElevation;if(null==s||null==a||null==l)return E;const r=Math.max(s-o,R);let c=Math.max(l-a,R);const m=t.effectiveUnits;if(t.dynamicElevationRange){const t=d(r,m.distance,m.elevation);c=Math.max(c,t/p().maxChartRatio)}return a-=W*c,l=a+c+O*c,[a,l]=f(a,l,10),c=l-a,t.uniformScaling?tt({data:t,bounds:{minX:o,maxX:s,minY:a,maxY:l},pixelWidth:i,pixelHeight:e,centered:!0}):{minX:o,maxX:o+r,minY:a,maxY:a+c}}function tt({data:t,bounds:i,pixelWidth:e,pixelHeight:n,centered:o}){if(null==t)return i;let{minX:s,maxX:a,minY:l,maxY:r}=i;if(null==s||null==a||null==l||null==r)return E;const c=a-s,p=r-l,m=t.effectiveUnits,u=d(p,m.elevation,m.distance)/n/(c/e);return u>=1?[s,a]=it([s,a],u,o):[l,r]=it([l,r],1/u,o),{minX:s,maxX:a,minY:l,maxY:r}}function it([t,i],e,n){const o=(i-t)*e;if(n){const e=(t+i)/2-o/2;return[e,e+o]}return[t,t+o]}function et(t){const{chart:i,data:e,seriesInfos:n,xAxis:o,yAxis:s}=t;if(null==e||0===e.lines.length)return void i.series.clear();const a=new Map,l=new Set(i.series.values),r=e.lines.length;for(let d=0;d<r;d++){const o=e.lines[d];let s=n.get(o.id);s?(s.fill&&l.delete(s.fill),l.delete(s.line)):(s=ot(t,o),s.fill&&i.series.push(s.fill),i.series.push(s.line)),a.set(s.id,s);const c=r-d-1;s.fill?.set("layer",c),s.line.set("layer",r+c),nt(t,s,o)}t.seriesInfos=a;for(const d of l)i.series.removeValue(d);o.set("layer",r+1),s.set("layer",r+2)}function nt({theme:t},i,e){const n=F(e.color.toCss()),o=e.samples??[],s=o.length>0,{line:a,fill:l}=i;a.set("visible",s),a.set("stroke",n),l?.set("visible",s),l?.set("fill",P.lighten(n,t.seriesFillLighten)),a.data.setAll(o),l?.data.setAll(o)}function ot(t,i){const{id:e}=i,n=st(t,`${H}-${e}`);n.setAll({dy:i.chartStrokeOffsetY,tooltip:at(t)}),n.strokes.template.setAll({strokeWidth:i.chartStrokeWidth});let o=null;return i.chartFillEnabled&&(o=st(t,`${B}-${e}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:e,line:n,fill:o}}function st(t,i){return M.new(t.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:i,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:t.xAxis,yAxis:t.yAxis})}function at({theme:t,chart:i}){const e=X.new(i.root,{forceHidden:!0,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return e.label.setAll({fill:F(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:n,paddingRight:n,paddingTop:o,textAlign:"start"}),e.get("background")?.setAll({stroke:void 0,fill:F(t.seriesTooltipBackgroundColor)}),e.adapters.add("dy",(i=>{const n=t.seriesTooltipSpacing,o=e.get("pointTo")?.y??0;return(i??0)+(e.y()>o?n:-n)})),e}function lt(t,i){const{xAxis:e,yAxis:n}=t,o=()=>{i(rt(e),rt(n))},s=t=>[t.on("start",o),t.on("end",o)];return bt([...s(e),...s(n)])}function rt(t){const i=Math.abs((t.get("end")??0)-(t.get("start")??0)),e=0!==i?1/i:1;return Math.abs(1-e)<c()?1:e}function dt(t,i){const{chart:e,xAxis:n,yAxis:o}=t,s=e.get("cursor"),a=e.plotContainer.events,l=i=>{t.pointerIsOver=i,pt(t)},r=()=>{l(!1),i(null,null)};return bt([s?.events.on("cursormoved",(()=>{if(!t.pointerIsOver)return;pt(t);let e=s?.getPrivate("positionX")??0,a=s?.getPrivate("positionY")??0;const l=t.data;if(null!=l?.statistics){const{maxDistance:t,minElevation:i,maxElevation:s}=l.statistics;if(null!=t){e=ct(e,At(n),vt(n),0,t)}if(null!=i&&null!=s){a=ct(a,At(o),vt(o),i,s)}}i(e,a)})),a.on("pointerover",(()=>l(!0))),a.on("pointerout",r),a.on("blur",r)])}function ct(t,i,e,n,o){return(i+t*(e-i)-n)/(o-n)}function pt(t){const i=mt(t);if(!i)return void t.seriesInfos.forEach((t=>{t.line.get("tooltip")?.set("forceHidden",!0)}));t.seriesInfos.forEach((t=>{const e=t.line.get("tooltip");e.set("forceHidden",!1),e.label.set("text",i)}));t.xAxis.getTooltip().setAll({tooltipText:xt(t)})}function mt(t){const{data:i}=t,e=i?.lines.map((i=>({line:i,y:ht(t,i)?.elevation}))).sort(ut);return e&&0!==e.length&&null!=e[0].y?e.map((({y:i,line:e})=>ft(t,e,i))).join("\n"):null}function ut({y:t},{y:i}){return null==t?1:null==i?-1:i-t}function ft(t,i,e){const{data:n,messages:o}=t;if(null==n||null==o)return"";const s=p().formatPrecision,a=Y(o.chartTooltip,{name:u(i,o),elevation:null!=e?l(o,e,n.effectiveUnits.elevation,s):m});return`[${i.color.toHex()}]●[/] ${a}`}function xt(t){const{data:i,messages:e}=t;if(null==i||null==e)return"";const n=i.lines[0],o=n?ht(t,n):null,s=p().formatPrecision;return null!=o?l(e,o.distance,i.effectiveUnits.distance,s):"-"}function gt(t,i){const e=g.new(t.chart.root,{});return e.format=(e,n,o)=>{const{data:s,messages:a}=t;if(null==a||null==s||"string"==typeof e)return"";return`${z(e,{maximumFractionDigits:o})} ${r(a,s.effectiveUnits[i],"abbr")}`},e}function ht({chart:t,xAxis:i},n){const o=n.samples??[];if(0===o.length)return null;const s=t.get("cursor"),a=s?.getPrivate("positionX")??0,l=i.toAxisPosition(a),r=i.positionToValue(l);return e(o,r,(t=>t.distance))}function At(t){return t.positionToValue(t.get("start")??0)}function vt(t){return t.positionToValue(t.get("end")??1)}function bt(t){return n(t.map(yt))}function yt(t){return o((()=>{t?.dispose()}))}export{I as createChart,_ as getAdjustedBounds};
|
|
@@ -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{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{EsriPromiseMixin as r}from"../../core/Promise.js";import{watch as a}from"../../core/reactiveUtils.js";import{templateHasKey as l}from"../../core/string.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import c from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{utc as g,unknown as y,system as _}from"../../time/timeZoneUtils.js";import{flattenFieldInputs as v,isGroupInput as I,flattenRelationshipInputs as F,parseFormTemplateString as C,isGroupElement as E,isFieldElement as x,isRelationshipElement as V,isRelationshipInput as b,isFieldInput as w,getNormalizedFeatureTypeInfo as j,valueIsValidContingentValue as T}from"./featureFormUtils.js";import A from"./FieldInput.js";import{createFormExpressionArcadeExecutor as M}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as R}from"./FormExpressionsManager.js";import S from"./GroupInput.js";import H from"./RelationshipInput.js";const N=new t({attributes:{}}),L=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],k=["visibilityExpression"],U=["editableExpression","visibilityExpression"],P="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",W="#JSAPI_CONTINGENT_VALUE_ANY_HASH",G="#JSAPI_CONTINGENT_VALUE_NULL_HASH",O="esri.widgets.FeatureForm.FeatureFormViewModel",Z=i.getLogger(O);let $=class extends(r(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=N.clone(),this._initialFeature=N.clone(),this._timeZone=null,this._updatingHandles=new d,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=a((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.arcadeEditType]),(async([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),{equals:([e,t,n,s,i],[o,r,a,l,u])=>e===o&&t===r&&n===a&&s===l&&i===u,initial:!0}),t=a((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=a((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return v(this.inputs)}get allGroupInputs(){return this.inputs.filter(I)}get allRelationshipInputs(){return F(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():N.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get fieldsWithInvalidCodedValue(){const e=this.allFieldInputs;return new Set(e.filter((e=>{const{name:t,domain:n,value:s}=e;if("coded-value"===n?.type){const e=this.getFieldValueOptionsForField(t);return null!=s&&""!==s&&!e.flat().some((e=>e.value===s))}return!1})))}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?C(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?C(e.title,this.getValues(),t.fieldsIndex):null}get formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(Z,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(Z,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return g;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===y?t||g:this._timeZone||_}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(Z,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(Z,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(i.length>0){const e=new Set(i.map((e=>e.value)));return[i,s.filter((t=>!e.has(t.value)))]}return[s,[]]}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _updateInputs(){this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o}=this;if(!o)return;const r={arcadeEditType:n,feature:e,initialFeature:t,layer:o},a=i.slice(),l=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(a,s.elements,r):this._updateInputsUsingLayerFields(a,o?.fields,r);this.inputs=l,await this._startExpressions()}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(I(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(z),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):E(a)?this._makeGroupInputFromElement(a,s):x(a)?this._makeFieldInputFromElement(a,s,i):V(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),I(n)){const{feature:e}=s;n.set({feature:e})}else if(b(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else n.set(s);if(E(a)){const e=a.elements.filter((e=>z(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return i.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const i of e)if(I(i)){for(const e of i.inputs)e.destroy();i.inputs.length=0,i.destroy()}else b(i)?i.destroy():w(i)&&(null!==i.element?i.destroy():s.set(i.field,i));const o=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const i of t){const e=s.get(i)??new A({arcadeEditType:r,field:i,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(i.name)??null,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});o.push(e),s.delete(i)}for(const[i,p]of s.entries())s.delete(i),p.destroy();return o}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new A({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new S({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new H({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=E(t)?k:V(t)?U:L,i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const i=t[o],{_expressionExecutorLookup:r}=this;if(null!=i&&""!==i){const t=this._expressionInfosLookup.get(i)?.expression??i;if(r.has(t))e[s]=this._useExecutor(r.get(t));else if(n.has(t)){const i=n.get(t).then((t=>(e[s]=t,t)));n.set(t,i)}else{const i=M(t,this.layer).then((n=>(e[s]=this._useExecutor(n),r.set(t,n),n)));n.set(t,i)}}}return i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new R({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:u}=j(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of u)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&l(n,t)&&this.notifyChange("formTitle"),e&&l(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=j(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(W)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(W),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(W)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(W),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||d)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&c)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===W)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||T(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[P,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[W,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${G}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function z(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(i.getLogger(O).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([u()],$.prototype,"_expressionInfosLookup",null),e([u()],$.prototype,"_featureClone",void 0),e([u()],$.prototype,"_timeZone",void 0),e([u()],$.prototype,"activeRelationshipInput",null),e([u()],$.prototype,"_arcadeContextInfo",null),e([u()],$.prototype,"allFieldInputs",null),e([u()],$.prototype,"allGroupInputs",null),e([u()],$.prototype,"allRelationshipInputs",null),e([u()],$.prototype,"_layerFieldsByName",null),e([u()],$.prototype,"arcadeEditType",void 0),e([u()],$.prototype,"contingencyConstraintViolations",void 0),e([u()],$.prototype,"disabled",void 0),e([u()],$.prototype,"feature",null),e([u()],$.prototype,"fieldsWithContingentValues",null),e([u()],$.prototype,"fieldsWithInvalidCodedValue",null),e([u({type:c})],$.prototype,"formTemplate",null),e([u()],$.prototype,"formDescription",null),e([u()],$.prototype,"formTitle",null),e([u()],$.prototype,"formHeaderVisible",null),e([u()],$.prototype,"highlightHelper",void 0),e([u()],$.prototype,"inputs",void 0),e([u()],$.prototype,"inputFields",null),e([u()],$.prototype,"joinedContingentValues",null),e([u()],$.prototype,"layer",null),e([u()],$.prototype,"map",void 0),e([u()],$.prototype,"relatedRecordCallbacks",void 0),e([u()],$.prototype,"relationshipId",null),e([u()],$.prototype,"spatialReference",null),e([u()],$.prototype,"state",null),e([u()],$.prototype,"strict",void 0),e([u()],$.prototype,"submittable",null),e([u()],$.prototype,"timeZone",null),e([u()],$.prototype,"updating",null),e([u()],$.prototype,"valid",null),e([u()],$.prototype,"view",null),e([u()],$.prototype,"getValues",null),e([u()],$.prototype,"submit",null),$=e([p(O)],$);const D=$;export{D as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{EsriPromiseMixin as r}from"../../core/Promise.js";import{watch as a}from"../../core/reactiveUtils.js";import{templateHasKey as l}from"../../core/string.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import c from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{utc as g,unknown as y,system as _}from"../../time/timeZoneUtils.js";import{flattenFieldInputs as v,isGroupInput as I,flattenRelationshipInputs as F,parseFormTemplateString as C,isGroupElement as E,isFieldElement as x,isRelationshipElement as V,isRelationshipInput as b,isFieldInput as w,getNormalizedFeatureTypeInfo as j,valueIsValidContingentValue as T}from"./featureFormUtils.js";import A from"./FieldInput.js";import{createFormExpressionArcadeExecutor as M}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as R}from"./FormExpressionsManager.js";import H from"./GroupInput.js";import S from"./RelationshipInput.js";const N=new t({attributes:{}}),L=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],k=["visibilityExpression"],U=["editableExpression","visibilityExpression"],P="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",W="#JSAPI_CONTINGENT_VALUE_ANY_HASH",G="#JSAPI_CONTINGENT_VALUE_NULL_HASH",O="esri.widgets.FeatureForm.FeatureFormViewModel",Z=i.getLogger(O);let $=class extends(r(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=N.clone(),this._initialFeature=N.clone(),this._timeZone=null,this._updatingHandles=new d,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=a((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.arcadeEditType]),(async([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),{equals:([e,t,n,s,i],[o,r,a,l,u])=>e===o&&t===r&&n===a&&s===l&&i===u,initial:!0}),t=a((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))))})),n=a((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get allFieldInputs(){return v(this.inputs)}get allGroupInputs(){return this.inputs.filter(I)}get allRelationshipInputs(){return F(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():N.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get fieldsWithInvalidCodedValue(){const e=this.allFieldInputs;return new Set(e.filter((e=>{const{name:t,domain:n,value:s}=e;if("coded-value"===n?.type){const e=this.getFieldValueOptionsForField(t);return null!=s&&""!==s&&!e.flat().some((e=>e.value===s))}return!1})))}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?C(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?C(e.title,this.getValues(),t.fieldsIndex):null}get formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(Z,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(Z,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return g;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===y?t||g:this._timeZone||_}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(Z,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(Z,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(i.length>0){const e=new Set(i.map((e=>e.value)));return[i,s.filter((t=>!e.has(t.value)))]}return[s,[]]}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _updateInputs(){this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o}=this;if(!o)return;const r={arcadeEditType:n,feature:e,initialFeature:t,layer:o},a=i.slice(),l=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(a,s.elements,r):this._updateInputsUsingLayerFields(a,o?.fields,r);this.inputs=l,await this._startExpressions()}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(I(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(z),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):E(a)?this._makeGroupInputFromElement(a,s):x(a)?this._makeFieldInputFromElement(a,s,i):V(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),I(n)){const{feature:e}=s;n.set({feature:e})}else if(b(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else n.set(s);if(E(a)){const e=a.elements.filter((e=>z(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return i.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const i of e)if(I(i)){for(const e of i.inputs)e.destroy();i.inputs.length=0,i.destroy()}else b(i)?i.destroy():w(i)&&(null!==i.element?i.destroy():s.set(i.field,i));const o=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const i of t){const e=s.get(i)??new A({arcadeEditType:r,field:i,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(i.name)??null,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});o.push(e),s.delete(i)}for(const[i,p]of s.entries())s.delete(i),p.destroy();return o}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new A({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new H({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new S({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=E(t)?k:V(t)?U:L,i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const i=t[o],{_expressionExecutorLookup:r}=this;if(null!=i&&""!==i){const t=this._expressionInfosLookup.get(i)?.expression??i;if(r.has(t))e[s]=this._useExecutor(r.get(t));else if(n.has(t)){const i=n.get(t).then((t=>(e[s]=t,t)));n.set(t,i)}else{const i=M(t,this.layer).then((n=>(e[s]=this._useExecutor(n),r.set(t,n),n)));n.set(t,i)}}}return i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new R({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:u}=j(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of u)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&l(n,t)&&this.notifyChange("formTitle"),e&&l(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=j(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(W)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(W),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(W)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(W),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||d)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&c)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===W)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||T(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[P,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[W,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${G}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function z(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(i.getLogger(O).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([u()],$.prototype,"_expressionInfosLookup",null),e([u()],$.prototype,"_featureClone",void 0),e([u()],$.prototype,"_timeZone",void 0),e([u()],$.prototype,"activeRelationshipInput",null),e([u()],$.prototype,"_arcadeContextInfo",null),e([u()],$.prototype,"allFieldInputs",null),e([u()],$.prototype,"allGroupInputs",null),e([u()],$.prototype,"allRelationshipInputs",null),e([u()],$.prototype,"_layerFieldsByName",null),e([u()],$.prototype,"arcadeEditType",void 0),e([u()],$.prototype,"contingencyConstraintViolations",void 0),e([u()],$.prototype,"disabled",void 0),e([u()],$.prototype,"feature",null),e([u()],$.prototype,"fieldsWithContingentValues",null),e([u()],$.prototype,"fieldsWithInvalidCodedValue",null),e([u({type:c})],$.prototype,"formTemplate",null),e([u()],$.prototype,"formDescription",null),e([u()],$.prototype,"formTitle",null),e([u()],$.prototype,"formHeaderVisible",null),e([u()],$.prototype,"highlightHelper",void 0),e([u()],$.prototype,"inputs",void 0),e([u()],$.prototype,"inputFields",null),e([u()],$.prototype,"joinedContingentValues",null),e([u()],$.prototype,"layer",null),e([u()],$.prototype,"map",void 0),e([u()],$.prototype,"relatedRecordCallbacks",void 0),e([u()],$.prototype,"relationshipId",null),e([u()],$.prototype,"spatialReference",null),e([u()],$.prototype,"state",null),e([u()],$.prototype,"strict",void 0),e([u()],$.prototype,"submittable",null),e([u()],$.prototype,"timeZone",null),e([u()],$.prototype,"updating",null),e([u()],$.prototype,"valid",null),e([u()],$.prototype,"view",null),e([u()],$.prototype,"getValues",null),e([u()],$.prototype,"submit",null),$=e([p(O)],$);const D=$;export{D 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
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as l}from"../../layers/support/CodedValue.js";import n from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as r}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as u,isNumericField as a,isStringField as p,isDateField as d,isTimeOnlyField as m,getFieldRange as h,TypeValidationError as y,validateFieldValue as c}from"../../layers/support/fieldUtils.js";import{isRelatableFeatureSupportedLayer as g}from"../Feature/support/featureUtils.js";import f from"./EditableInput.js";import{getNormalizedFeatureTypeInfo as v,isFieldElementWithInputType as E,valueIsInvalidSwitchValue as x,isFieldElementWithTextInput as b,isFieldElementWithShowNoValueOptionInput as _,LengthValidationError as V}from"./featureFormUtils.js";var T;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(T||(T={}));const D="__internal-type-based-coded-value-domain__";let I=class extends f{constructor(e){super(e),this._storedValue=null,this._valueOriginIsExpression=!1,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return u(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get dataType(){const{field:e}=this;return a(e)?T.Number:p(e)?T.Text:d(e)||m(e)?T.Date:T.Unsupported}get dateDataType(){if(this.dataType===T.Date)return"date"!==this.field.type?"string":"number"}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=v(e);if(t===this.name&&null==this.field.domain)return new n({name:D,codedValues:i.map((({code:e,name:t})=>new l({code:e,name:t})))});const{feature:s}=this,r=e?.getFieldDomain(this.name,{feature:s}),o=this.element?.domain;return null!=o&&this._isDomainCompatible(o)?o:r}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==T.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==T.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimestamp(){return"timestamp-offset"===this.field.type}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=E(e,"switch")?e.input:null;return!t||x(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return g(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){return this.element?.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.dataType===T.Date)return e;const{field:t,element:i}=this,l=t?.length,n=b(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===T.Date)return e;const{field:t,element:i}=this,l=t?.length,n=b(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&N(l)?l.getTime():null,o=null!=n&&N(n)?n.getTime():null,u=s(t)||h(i);if(!u)return{max:r,min:o};const a=u.max===Number.MAX_VALUE?null:u.max,p=u.min===Number.MIN_VALUE?null:u.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=o&&(null===p||null!=p&&o>p)?o:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l}=this;return!!e&&(!1===i?.nullable||!(!l||null==t)&&t)}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!_(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return _(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return this._valueOriginIsExpression=!0,null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){this._valueOriginIsExpression=!0;const e=this.evaluatedValueExpression;if(this.dataType===T.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return null!=e&&"object"==typeof e?e.toString():e}return this._valueOriginIsExpression=!1,this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get valueOriginIsExpression(){return this._valueOriginIsExpression}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&p(t)||"number"===i&&a(t))return!0}return!!("range"===e?.type&&a(t)||d(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,required:s,valid:o,value:u}=this,a=s&&null==u,p=void 0!==o;return!a&&l.getAttribute(i.name)===u&&p?null:a?y.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof u&&u.length<n?V.TOO_SHORT:t?null!==u||s?r(t,u):null:c(i,u)}};e([t()],I.prototype,"_storedValue",void 0),e([t()],I.prototype,"_configAllowsEdits",null),e([t()],I.prototype,"_layerAndFieldAllowEdits",null),e([t()],I.prototype,"_isVisibleByDefault",null),e([t()],I.prototype,"_isEditTrackingField",null),e([t()],I.prototype,"_shouldUseValueExpression",null),e([t()],I.prototype,"_valueOriginIsExpression",void 0),e([t()],I.prototype,"dataType",null),e([t()],I.prototype,"dateDataType",null),e([t()],I.prototype,"domain",null),e([t()],I.prototype,"editable",null),e([t({readOnly:!0})],I.prototype,"error",void 0),e([t({constructOnly:!0})],I.prototype,"preservesValueWhenHidden",void 0),e([t()],I.prototype,"evaluatedRequiredExpression",null),e([t()],I.prototype,"evaluatedValueExpression",null),e([t()],I.prototype,"field",void 0),e([t()],I.prototype,"group",void 0),e([t({readOnly:!0})],I.prototype,"hint",null),e([t()],I.prototype,"includeDate",null),e([t()],I.prototype,"includeTime",null),e([t()],I.prototype,"includeTimestamp",null),e([t()],I.prototype,"initialFeature",null),e([t({readOnly:!0})],I.prototype,"inputType",null),e([t()],I.prototype,"hasInvalidSwitchValue",null),e([t()],I.prototype,"isRelationshipKeyField",null),e([t()],I.prototype,"label",null),e([t()],I.prototype,"maxLength",null),e([t()],I.prototype,"minLength",null),e([t({readOnly:!0})],I.prototype,"name",null),e([t()],I.prototype,"range",null),e([t()],I.prototype,"required",null),e([t()],I.prototype,"requiredExpressionExecutor",void 0),e([t()],I.prototype,"showNoValueOptionEnabled",null),e([t()],I.prototype,"submittable",null),e([t({readOnly:!0})],I.prototype,"type",void 0),e([t()],I.prototype,"updating",null),e([t()],I.prototype,"valid",null),e([t({value:null})],I.prototype,"value",null),e([t()],I.prototype,"valueExpressionExecutor",void 0),e([t()],I.prototype,"valueOriginIsExpression",null),e([t()],I.prototype,"visible",null),I=e([i("esri.widgets.FeatureForm.FieldInput")],I);const N=e=>e&&!Number.isNaN(e.valueOf()),F=I;export{F as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as l}from"../../layers/support/CodedValue.js";import n from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as r}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as u,getLowerCaseEditTrackingFields as o,isNumericField as a,isStringField as p,isDateField as d,isTimeOnlyField as m,getFieldRange as h,TypeValidationError as y,NumericRangeValidationError as c,validateFieldValue as f}from"../../layers/support/fieldUtils.js";import{isRelatableFeatureSupportedLayer as g}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{getNormalizedFeatureTypeInfo as b,isFieldElementWithInputType as E,valueIsInvalidSwitchValue as x,isFieldElementWithTextInput as _,isFieldElementWithShowNoValueOptionInput as V,LengthValidationError as T}from"./featureFormUtils.js";import{timeResolutionToStepMap as F,valueIsInRange as D}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const I="__internal-type-based-coded-value-domain__";let N=class extends v{constructor(e){super(e),this._storedValue=null,this._valueOriginIsExpression=!1,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&u(e,t)}get _isEditTrackingField(){return o(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return a(e)?O.Number:p(e)?O.Text:d(e)||m(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=b(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new n({name:I,codedValues:e.subtypes.map((({code:e,name:t})=>new l({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new n({name:I,codedValues:i.map((({code:e,name:t})=>new l({code:e,name:t})))});const{feature:s}=this,r=e?.getFieldDomain(this.name,{feature:s}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:r}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=E(e,"switch")?e.input:null;return!t||x(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return g(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){return this.element?.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length,n=_(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length,n=_(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&w(l)?l.getTime():null,u=null!=n&&w(n)?n.getTime():null,o=s(t)||h(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!V(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return V(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?F.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return this._valueOriginIsExpression=!0,null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){this._valueOriginIsExpression=!0;const e=this.evaluatedValueExpression;if(this.dataType===O.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return null!=e&&"object"==typeof e?e.toString():e}return this._valueOriginIsExpression=!1,this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get valueOriginIsExpression(){return this._valueOriginIsExpression}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&p(t)||"number"===i&&a(t))return!0}return!!("range"===e?.type&&a(t)||d(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:s,required:u,valid:o,value:a}=this,p=u&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?y.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?T.TOO_SHORT:"date"===i.type&&null!=a&&s&&!D({value:a,max:s.max,min:s.min})?c.OUT_OF_RANGE:t?null!==a||u?r(t,a):null:f(i,a)}};e([t()],N.prototype,"_storedValue",void 0),e([t()],N.prototype,"_configAllowsEdits",null),e([t()],N.prototype,"_layerAndFieldAllowEdits",null),e([t()],N.prototype,"_isVisibleByDefault",null),e([t()],N.prototype,"_isEditTrackingField",null),e([t()],N.prototype,"_shouldUseValueExpression",null),e([t()],N.prototype,"_valueOriginIsExpression",void 0),e([t()],N.prototype,"_isSubtypeField",null),e([t()],N.prototype,"dataType",null),e([t()],N.prototype,"dateDataType",null),e([t()],N.prototype,"domain",null),e([t()],N.prototype,"editable",null),e([t({readOnly:!0})],N.prototype,"error",void 0),e([t({constructOnly:!0})],N.prototype,"preservesValueWhenHidden",void 0),e([t()],N.prototype,"evaluatedRequiredExpression",null),e([t()],N.prototype,"evaluatedValueExpression",null),e([t()],N.prototype,"field",void 0),e([t()],N.prototype,"group",void 0),e([t({readOnly:!0})],N.prototype,"hint",null),e([t()],N.prototype,"includeDate",null),e([t()],N.prototype,"includeTime",null),e([t()],N.prototype,"includeTimeOffset",null),e([t()],N.prototype,"initialFeature",null),e([t({readOnly:!0})],N.prototype,"inputType",null),e([t()],N.prototype,"hasInvalidSwitchValue",null),e([t()],N.prototype,"isRelationshipKeyField",null),e([t()],N.prototype,"label",null),e([t()],N.prototype,"maxLength",null),e([t()],N.prototype,"minLength",null),e([t({readOnly:!0})],N.prototype,"name",null),e([t()],N.prototype,"range",null),e([t()],N.prototype,"required",null),e([t()],N.prototype,"requiredExpressionExecutor",void 0),e([t()],N.prototype,"showNoValueOptionEnabled",null),e([t()],N.prototype,"submittable",null),e([t()],N.prototype,"timeResolution",null),e([t()],N.prototype,"timeStep",null),e([t({readOnly:!0})],N.prototype,"type",void 0),e([t()],N.prototype,"updating",null),e([t()],N.prototype,"valid",null),e([t({value:null})],N.prototype,"value",null),e([t()],N.prototype,"valueExpressionExecutor",void 0),e([t()],N.prototype,"valueOriginIsExpression",null),e([t()],N.prototype,"visible",null),N=e([i("esri.widgets.FeatureForm.FieldInput")],N);const w=e=>e&&!Number.isNaN(e.valueOf()),A=N;export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";const n="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this.preserveFieldValuesWhenHidden=!0,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}destroy(){this.resetExecutors()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o}=this.arcadeContextInfo,
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";const n="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this.preserveFieldValuesWhenHidden=!0,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}destroy(){this.resetExecutors()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o,timeZone:a}=this.arcadeContextInfo,i="feature"===t?.type?t:"scene"===t?.type&&null!=t.associatedLayer?t.associatedLayer:void 0;return[{$originalfeature:r,$editcontext:{editType:e},$layer:i,$featureset:i,$datastore:t?.url,$map:s},{spatialReference:o??void 0,timeZone:a}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(n))return this._evaluate([...this._fieldReferencesLookup.get(n)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:r,preserveFieldValuesWhenHidden:o}=this,a=new Map(this.fieldInputs.map((e=>[e.name,e]))),i=!1===o,l=new Map(r.map((e=>[e,new Array])));for(const c of r){for(const r of c.fieldsUsed){s(e,r,(()=>new Set)).add(c);const o=a.get(r);[o?.valueExpressionExecutor,o?.editableExpressionExecutor,i?o?.group?.visibilityExpressionExecutor:null,i?o?.visibilityExpressionExecutor:null].filter((e=>null!=e&&e!==c)).forEach((e=>{l.get(e).push(c);s(t,e,(()=>new Set)).add(o)}))}if(c.geometryUsed){s(e,n,(()=>new Set)).add(c)}}return l}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:a}=this;for(const r of e)u(r,t,s);for(const[n,{resolver:l,dependencyPromises:c}]of t){Promise.all(c).then((async()=>{const[e,t]=this._makeContext(a);return n.executeAsync(e,t)})).then((()=>{if(o.has(n))for(const e of o.get(n))this._latestFieldValues[e.name]=e.value;l.resolve()}),(e=>{!e||r(e)||p(e)||n.markStale(),l.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(r(e.reason)||p(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([a()],c.prototype,"_baseContext",null),e([a()],c.prototype,"feature",null),e([a({constructOnly:!0})],c.prototype,"preserveFieldValuesWhenHidden",void 0),e([a()],c.prototype,"executors",void 0),e([a()],c.prototype,"fieldInputs",void 0),e([a()],c.prototype,"arcadeContextInfo",void 0),c=e([i(l)],c);const u=(e,t,s)=>{if(t.has(e))return;const r=o();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const a=s.get(e);for(const o of a)u(o,t,s),t.get(o).dependencyPromises.push(r.promise)},p=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{c as FormExpressionsManager};
|
|
@@ -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"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as r,replace as n}from"../../core/string.js";import{DomainValidationError as o
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as r,replace as n}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isDateField as i,NumericRangeValidationError as a,TypeValidationError as l}from"../../layers/support/fieldUtils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as s}from"../../intl/substitute.js";const p=e=>"field"===e?.type,m=e=>"group"===e?.type,d=e=>"relationship"===e?.type,c=e=>!m(e)&&null!=e.group,f=e=>"field"===e.type,y=e=>"group"===e.type,T=e=>"relationship"===e.type,b=e=>e.reduce(((e,t)=>m(t)?[...e,...t.inputs]:[...e,t]),[]),E=e=>b(e).filter(p),O=e=>b(e).filter(d),g=e=>null!=e&&(j(e,"combo-box")||j(e,"radio-buttons")),j=(e,t)=>null!=e&&e.input?.type===t,v=e=>null!=e&&(j(e,"text-box")||j(e,"text-area")),x=({domain:e,inputType:t="text-box",dataType:r})=>"number"===r&&"text-box"===t&&(!e||"coded-value"!==e.type),V=e=>"items"in e,h={typeFieldName:null,types:[]};function U(t,n,o){const i=Object.keys(n).filter((e=>r(t,e))),a=i.map((e=>n[e])),l=i.map((e=>o.get(e))).filter(e);return _(t,N(a,l))}function N(e,t){const r=t.map(((t,r)=>{let n=e[r];if(t.domain&&"coded-value"===t.domain.type){const e=t.domain.codedValues.find((e=>e.code===n));e?.name&&(n=e.name)}return i(t)&&(n=u(t,n)),[t.name,n]}));return Object.fromEntries(r)}function _(e,t){return n(n(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const A=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:r})=>({code:e,name:t,domains:r})))}:h:h,L=(e,t)=>{if(!e)return!0;const{operations:r}=e;switch(t){case"INSERT":return r.supportsAdd;case"UPDATE":case"DELETE":return r.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const I={type:"number"},D={type:"number",intlOptions:{notation:"scientific"}},R={day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};function w(e){return e>=1e7||e<=-1e7}const C=(e,t,r)=>{const{dataType:n,error:i,minLength:u,value:p,required:m}=e;if(!t||!i)return null;if(m&&null===p)return t.validationErrors.cannotBeNull;if(i===o.VALUE_OUT_OF_RANGE||i===a.OUT_OF_RANGE){const o=e.range,i={type:"date",intlOptions:{...R,timeZone:r??void 0}};return s(t.validationErrors.outsideRange,o,{format:{max:"date"===n?i:w(o.max)?D:I,min:"date"===n?i:w(o.min)?D:I}})}return i===o.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===l.INVALID_TYPE?t.validationErrors.invalidType:i===F.TOO_SHORT?s(t.validationErrors.tooShort,{min:u}):null},S=e=>{if(!e)return;const t=e.layer,r=t&&"geometryType"in t?t.geometryType:void 0,n=e.geometry?.type;return"polyline"===n||"polyline"===r?"line":n||r||"table"},G=e=>{const t=[];if(e.formTemplate){const{description:n,title:o}=e.formTemplate;e.fields?.forEach((e=>{const i=o&&r(o,e.name),a=n&&r(n,e.name);(i||a)&&t.push(e.name)}))}return t};function H(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(f)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function P(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function k(e,r){switch(r.objectType){case"any":return!0;case"null":return null==e;case"code":return e===r.codedValue?.code;case"range":return null!=e&&null!=r.minValue&&null!=r.maxValue&&+e>=r.minValue&&+e<=r.maxValue;default:return t(r.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,E as flattenFieldInputs,b as flattenInputs,O as flattenRelationshipInputs,H as formTemplateHasInvalidFields,N as getComputedAttributes,C as getErrorMessageForFieldInput,G as getFieldsInTitleAndDesc,S as getIconForFeature,A as getNormalizedFeatureTypeInfo,f as isFieldElement,j as isFieldElementWithInputType,g as isFieldElementWithShowNoValueOptionInput,v as isFieldElementWithTextInput,p as isFieldInput,y as isGroupElement,m as isGroupInput,c as isInputInGroupInput,x as isNumberFieldInput,T as isRelationshipElement,d as isRelationshipInput,V as isTemplateItemGroup,U as parseFormTemplateString,_ as substituteFieldTemplatesInString,P as valueIsInvalidSwitchValue,k as valueIsValidContingentValue};
|
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 s}from"../core/reactiveUtils.js";import{property as a}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 b,isNumberFieldInput as g}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,getISOFieldValueFromDateComponents as O,getUnixFieldValueFromDateComponents as k}from"./support/dateUtils.js";import{globalCss as I}from"./support/globalCss.js";import{Heading as M,incrementHeadingLevel as D}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const T="data-field-name",j="esri.widgets.FeatureForm",E=o.getLogger(j);let S=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),(()=>{s((()=>!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 V("div",{class:this.classes(p.base,I.widget,I.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return V("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&&V(M,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&V("p",{class:p.description,key:"description"},e.formDescription);return V("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:V("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:s,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return V("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:s||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?D(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 s=n;s<o.length;s++){const e=o[s];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:s}=e,a={"aria-label":s?L(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[V("div",{class:p.labelTextContent,key:"labelTextContainer"},o,s?V("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?V("label",{...a},r):V("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n,updating:s}=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)}if("datetime-picker"===o||"date"===t)return this._renderDateComponents(e,a);const r="number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a);return s?V("div",{class:p.fieldInputWrapper,key:`${a.key}-input-updating-wrapper`},r,V("div",{class:p.fieldInputLoader},V("calcite-progress",{type:"indeterminate"}))):r}_renderStringComponent(e,t){return V("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return V("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,this.timeZone))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:s,min:a,key:r,readOnly:l}=t;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,bind:this,class:n,"data-date-part":"date","data-field-name":t[T],key:`${r}-date-input`,max:null!=s?`${s}`:void 0,min:null!=a?`${a}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},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:s,readOnly:a}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,bind:this,class:n,"data-date-part":"time","data-field-name":t[T],key:`${s}-time-input`,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:1,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,valid:o,value:n}=e,{class:s,key:a,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,[T]:i,onfocus:this._onComponentFocus};return V("div",{class:p.dateInputContainer,key:`${a}-date-time-container`},V("calcite-input-date-picker",{...m,bind:this,class:s,"data-date-part":"date",key:`${a}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),V("calcite-input-time-picker",{...m,bind:this,class:s,"data-date-part":"time",key:`${a}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},step:.001,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),V("calcite-input-time-zone",{...m,bind:this,class:s,"data-date-part":"timeZone",key:`${a}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}))}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:s}=e,{class:a,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,[T]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(s,u),_=null!=r?w(r,u):void 0,b=null!=l?w(l,u):void 0;return V("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},V("calcite-input-date-picker",{...m,bind:this,class:a,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:b?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?V("calcite-input-time-picker",{...m,bind:this,class:a,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("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:s,messagesTemplates:a,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(V("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[V("calcite-combobox-item-group",{key:"recommended",label:s.recommended},p),V("calcite-combobox-item-group",{key:"other",label:a.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||s.empty;u.unshift(V("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:s.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return V("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,s=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;s.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[T],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},s)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return V("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:s}){return V("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},V("calcite-radio-button",{...s,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:s.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?V("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 s=this.messages;return V("calcite-list-item",{description:L(s.totalCount,{count:t}),label:s.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},V("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:s}=this;if(t&&s?.addRelatedRecord&&o)return V("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:s,relatedRecordCallbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&s&&a.editRelatedRecord({parentFeature:s,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return V("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},V("calcite-icon",{icon:b(i),scale:"m",slot:"content-start"}),V("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),s=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return V("calcite-label",{class:this.classes(p.label,p.relationshipLabel),key:`relationship-${i}-container`},V("div",null,this._renderRelatedRecordsHeaderContainer(e),n,s),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return V("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},V("span",null,e.label),t?V("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return V("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),s=n?.label,a=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return V("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},V("div",{slot:"message"},a))}_renderNoRelatedRecordsNotice(){return V("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},V("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return V("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:s,minLength:a,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:s>-1?s:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[T]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(T))}_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);g(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,t=!1){const i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n}=i,s=this._dateComponentMap.get(n);if(!s)return;const a=this.viewModel.getValue(n);let r=null;r="date-only"===o||"time-only"===o?e.value:"timestamp-offset"===o?null!=e.value?O({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone}):null:null!=e.value?k({oldValue:a,dateComponent:s.date,timeComponent:s.time,timeZone:this.timeZone,max:i.range?.max}):null,a!==r&&(null!==r?this._updateFieldValue(n,r):t&&this._updateFieldValue(n,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;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&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([a()],S.prototype,"_listObserverNode",void 0),e([a()],S.prototype,"_relatedRecordsEnabled",null),e([a()],S.prototype,"disabled",null),e([a()],S.prototype,"feature",null),e([a()],S.prototype,"formTemplate",null),e([a()],S.prototype,"groupDisplay",void 0),e([a()],S.prototype,"headingLevel",void 0),e([a()],S.prototype,"label",null),e([a()],S.prototype,"layer",null),e([a()],S.prototype,"map",null),e([a(),x("esri/widgets/FeatureForm/t9n/FeatureForm")],S.prototype,"messages",void 0),e([a(),x("esri/t9n/common")],S.prototype,"messagesCommon",void 0),e([a(),x("esri/widgets/Feature/t9n/Feature")],S.prototype,"messagesFeature",void 0),e([a(),x("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],S.prototype,"messagesTemplates",void 0),e([a()],S.prototype,"relatedRecordCallbacks",null),e([a()],S.prototype,"relationshipId",null),e([a()],S.prototype,"spatialReference",null),e([a()],S.prototype,"strict",null),e([a()],S.prototype,"timeZone",null),e([a()],S.prototype,"view",null),e([a(),N(["value-change","submit"])],S.prototype,"viewModel",void 0),S=e([r(j)],S);const U=S;export{U 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,getISOFieldValueFromDateComponents as O,getUnixFieldValueFromDateComponents as k}from"./support/dateUtils.js";import{globalCss as I}from"./support/globalCss.js";import{Heading as M,incrementHeadingLevel as D}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as x}from"./support/decorators/vmEvent.js";import{tsx as N}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const T="data-field-name",j="esri.widgets.FeatureForm",S=o.getLogger(j);let E=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(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"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 N("div",{class:this.classes(p.base,I.widget,I.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return N("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&&N(M,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&N("p",{class:p.description,key:"description"},e.formDescription);return N("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:N("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 N("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?D(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=[N("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?N("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?N("label",{...s},r):N("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?N("div",{class:p.fieldInputWrapper,key:`${s.key}-input-updating-wrapper`},r,N("div",{class:p.fieldInputLoader},N("calcite-progress",{type:"indeterminate"}))):r}_renderStringComponent(e,t){return N("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return N("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 N("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[T],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 N("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[T],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,[T]:i,onfocus:this._onComponentFocus};return N("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},N("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)}),N("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?N("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,[T]: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 N("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},N("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?N("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 N("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})=>N("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(N("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[N("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),N("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(N("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return N("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 N("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[T],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 N("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 N("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},N("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?N("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 N("calcite-list-item",{description:L(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},N("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 N("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 N("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},N("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),N("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 N("calcite-label",{class:this.classes(p.label,p.relationshipLabel),key:`relationship-${i}-container`},N("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return N("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},N("span",null,e.label),t?N("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return N("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=n?.label,s=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return N("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},N("div",{slot:"message"},s))}_renderNoRelatedRecordsNotice(){return N("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},N("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return N("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,[T]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(T))}_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;const a=this.viewModel.getValue(o);let s=null;s="date-only"===i||"time-only"===i?e.value:"timestamp-offset"===i?null!=e.value?O({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?k({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:S.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()],E.prototype,"_listObserverNode",void 0),e([s()],E.prototype,"_relatedRecordsEnabled",null),e([s()],E.prototype,"disabled",null),e([s()],E.prototype,"feature",null),e([s()],E.prototype,"formTemplate",null),e([s()],E.prototype,"groupDisplay",void 0),e([s()],E.prototype,"headingLevel",void 0),e([s()],E.prototype,"label",null),e([s()],E.prototype,"layer",null),e([s()],E.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],E.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],E.prototype,"messagesTemplates",void 0),e([s()],E.prototype,"relatedRecordCallbacks",null),e([s()],E.prototype,"relationshipId",null),e([s()],E.prototype,"spatialReference",null),e([s()],E.prototype,"strict",null),e([s()],E.prototype,"timeZone",null),e([s()],E.prototype,"view",null),e([s(),x(["value-change","submit"])],E.prototype,"viewModel",void 0),E=e([r(j)],E);const U=E;export{U 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
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Collection.js";import i from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as h}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{highlightsSupported as m}from"../../views/support/layerViewUtils.js";import g from"./AttachmentsColumn.js";import c from"./FieldColumn.js";import p from"./Grid/Column.js";import u from"./Grid/Grid.js";import y from"./Grid/GridViewModel.js";import f from"./Grid/GroupColumn.js";import b from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as _}from"../support/decorators/messageBundle.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as E}from"../../intl/messages.js";let I=class extends y{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new i,this.activeFilters=new s,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||null,this.columns=new s,this.dataProvider=async(e,t)=>{const{store:s}=this,{page:i,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(s?(s.set({orderByFields:l}),"loaded"!==s.state&&"loading"!==s.state&&await s.load(),t&&t(await s.fetchItems({page:i,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new b),this._set("grid",new u({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await E("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await E("esri/t9n/common"),this.messagesURIUtils=await E("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([w((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._unhighlight(e)))}}),h((()=>this.layerView),(()=>{this._highlights.removeAll(),this.layerView&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.highlightEnabled),(()=>{this._highlights.removeAll(),this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),h((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),h((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),h((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),h((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),h((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),h((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),h((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),h((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))):[]}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new s}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new s(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}set layer(e){this._set("layer",e),this.grid?.clearSort(),this._resetColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load()),this.notifyChange("state")}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearHighlights(){this._highlights.removeAll()}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),s=t.filter((e=>!e.error)).map((e=>e.objectId));s.length&&(this.deselectRows(s),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const s=this.store.getItemByObjectId(e);return s?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new s}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new s(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,s=this.highlightIds.toArray();if(!e||!t||!s.length)return;const i=e.createQuery();i.objectIds=s,i.returnGeometry=!0;const r=await e.queryFeatures(i);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,s)=>{t||this.deselectRows(e[s])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._resetColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateDefaultAttachmentColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:s,layer:i,messages:r,messagesCommon:o,messagesURIUtils:l,store:h,tableTemplate:a}=this,n=this.layer?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return n.find((e=>t===e.name?.toLowerCase()))};return e.filter((e=>null!=d(e)||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((e=>{if("fieldName"in e){const n=d(e),m=!1===e.visible||!0!==e.visible&&this._isFieldHidden(n?.name),{direction:g,formatFunction:p,initialSortPriority:u,menuConfig:y,textAlign:f}=e;return new c({direction:g,editingEnabled:t,expressionInfos:a?.expressionInfos||null,field:n,formatFunction:p,grid:s,hidden:m,initialSortPriority:u,layer:i,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:y,store:h,template:e,textAlign:f})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),s=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:i}=e;return new f({header:i,columns:t,hidden:s})}return new p({...e})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:s,messages:i,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((h=>new c({editingEnabled:e,field:h,grid:t,hidden:this._isFieldHidden(h.name),layer:s,store:l,messages:i,messagesCommon:r,messagesURIUtils:o})))}_generateDefaultAttachmentColumn(){return new g({header:this.messages?.attachments})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,s)=>s.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&m(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_unhighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const s=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let i=e instanceof t?e:null;const r=i?i.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!i){const e=this.store.getItemByObjectId(r);e&&(i=e.feature)}s.push({objectId:r,feature:i})}})),s}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:s,removed:i}=e;t&&(s.forEach((e=>this._highlight(e))),i.forEach((e=>this._unhighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([a()],I.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],I.prototype,"activeFilters",void 0),e([a({readOnly:!0})],I.prototype,"activeSortOrders",null),e([a()],I.prototype,"attachmentsEnabled",null),e([a()],I.prototype,"autoRefreshEnabled",void 0),e([a()],I.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],I.prototype,"columns",void 0),e([a()],I.prototype,"dataProvider",void 0),e([a()],I.prototype,"editingEnabled",void 0),e([a()],I.prototype,"filterGeometry",null),e([a({readOnly:!0})],I.prototype,"grid",void 0),e([a()],I.prototype,"hiddenFields",null),e([a()],I.prototype,"highlightEnabled",void 0),e([a()],I.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],I.prototype,"itemIdPath",void 0),e([a()],I.prototype,"layer",null),e([a()],I.prototype,"layerView",null),e([a()],I.prototype,"messages",null),e([a(),_("esri/t9n/common")],I.prototype,"messagesCommon",void 0),e([a(),_("esri/widgets/support/t9n/uriUtils")],I.prototype,"messagesURIUtils",void 0),e([a()],I.prototype,"relatedRecordsEnabled",void 0),e([a()],I.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],I.prototype,"state",null),e([a({readOnly:!0,type:b})],I.prototype,"store",void 0),e([a()],I.prototype,"tableTemplate",void 0),e([a()],I.prototype,"timeExtent",null),e([a()],I.prototype,"view",void 0),e([a()],I.prototype,"highlightIds",null),I=e([n("esri.widgets.FeatureTable.FeatureTableViewModel")],I);const v=I;export{v as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as I}from"../support/decorators/messageBundle.js";import{onLocaleChange as v}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as E}from"../../intl/date.js";import{fetchMessageBundle as F}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||null,this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,{page:s,pageSize:r,sortOrders:o}=e,l=this._sortOrdersToLayerOrderByFields(o);t&&(i?(i.set({orderByFields:l}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems({page:s,pageSize:r}))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await F("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await F("esri/t9n/common"),this.messagesURIUtils=await F("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([v((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._unhighlight(e)))}}),n((()=>this.layerView),(()=>{this._highlights.removeAll(),this.layerView&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(()=>{this._highlights.removeAll(),this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._resetColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns?.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))):[]}set attachmentsEnabled(e){this.attachmentsEnabled!==e&&(this._set("attachmentsEnabled",e),this._generateColumns(),this.store.attachmentsEnabled=e)}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}set layer(e){this._set("layer",e),this.grid?.clearSort(),this._resetColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load()),this.notifyChange("state")}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearHighlights(){this._highlights.removeAll()}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._resetColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateDefaultAttachmentColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:h}=this,a=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return a.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:a})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(a?.name),{direction:m,formatFunction:g,initialSortPriority:c,menuConfig:p,textAlign:y}=e,f=h?.expressionInfos||null,{timeZone:b,timeZoneName:_}=this._getTimeZoneInfoForFieldColumn(a);return new u({direction:m,editingEnabled:t,expressionInfos:f,field:a,formatFunction:g,grid:i,hidden:d,initialSortPriority:c,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:p,store:n,template:e,textAlign:y,timeZone:b,timeZoneName:_})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:h,timeZoneName:a}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:h,timeZoneName:a})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m(this.layer,t??i?.timeZone??g,E("short-time"),e.type)}_generateDefaultAttachmentColumn(){return new p({header:this.messages?.attachments})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_unhighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return(e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._unhighlight(e))))}_resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}};e([h()],C.prototype,"_defaultHiddenFields",null),e([h({readOnly:!0})],C.prototype,"activeFilters",void 0),e([h({readOnly:!0})],C.prototype,"activeSortOrders",null),e([h()],C.prototype,"attachmentsEnabled",null),e([h()],C.prototype,"autoRefreshEnabled",void 0),e([h()],C.prototype,"cellClassNameGenerator",void 0),e([h({readOnly:!0})],C.prototype,"columns",void 0),e([h()],C.prototype,"dataProvider",void 0),e([h()],C.prototype,"editingEnabled",void 0),e([h()],C.prototype,"filterGeometry",null),e([h({readOnly:!0})],C.prototype,"grid",void 0),e([h()],C.prototype,"hiddenFields",null),e([h()],C.prototype,"highlightEnabled",void 0),e([h()],C.prototype,"highlightOnRowSelectEnabled",null),e([h({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([h()],C.prototype,"layer",null),e([h()],C.prototype,"layerView",null),e([h()],C.prototype,"messages",null),e([h(),I("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([h(),I("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([h()],C.prototype,"relatedRecordsEnabled",void 0),e([h()],C.prototype,"returnGeometryEnabled",void 0),e([h({readOnly:!0})],C.prototype,"state",null),e([h({readOnly:!0,type:w})],C.prototype,"store",void 0),e([h()],C.prototype,"tableTemplate",void 0),e([h()],C.prototype,"timeExtent",null),e([h()],C.prototype,"timeZone",void 0),e([h()],C.prototype,"view",void 0),e([h()],C.prototype,"highlightIds",null),C=e([a("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
|