@arcgis/core 5.2.0-next.113 → 5.2.0-next.114
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/Ground.d.ts +5 -4
- package/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/e164acd876bbd42ed658.js +1 -0
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ar.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.bg.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.bs.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ca.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.cs.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.da.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.de.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.el.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.es.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.et.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.fi.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.fr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.he.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.hr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.hu.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.id.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.it.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ja.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ko.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.lt.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.lv.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.nl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.no.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ro.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ru.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sk.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sv.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.th.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.tr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.uk.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.vi.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-TW.json +1 -1
- package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/messages.ja.json +1 -1
- package/assets/esri/views/3d/environment/resources/milkyway-band.ktx2 +0 -0
- package/assets/esri/widgets/DistanceMeasurement2D/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/DistanceMeasurement2D/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/Expand/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/Features/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/Features/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.hu.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.nl.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.th.json +1 -1
- package/assets/esri/widgets/Home/t9n/messages.tr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/Print/t9n/messages.sr.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/Search/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.ar.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.ca.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.cs.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.el.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.pl.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.ru.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/smartMapping/HeatmapSlider/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/support/GridControls/t9n/messages.pt-BR.json +1 -1
- package/chunks/DeepSky.glsl.js +1 -1
- package/config.js +1 -1
- package/core/Evented.d.ts +1 -1
- package/form/elements/AttachmentElement.d.ts +5 -5
- package/form/elements/inputs/attachments/AttachmentInput.d.ts +1 -1
- package/kernel.js +1 -1
- package/layers/FeatureLayer.d.ts +2 -2
- package/layers/support/FeatureReductionBinning.d.ts +2 -2
- package/layers/support/FeatureReductionCluster.d.ts +2 -2
- package/layers/support/SubtypeSublayer.d.ts +1 -1
- package/package.json +3 -3
- package/popup/FeatureContent.d.ts +7 -7
- package/portal/schemas/definitions.js +1 -1
- package/portal/types.d.ts +1 -1
- package/renderers/DotDensityRenderer.d.ts +2 -2
- package/rest/knowledgeGraph/ReplicaDefinition.d.ts +1 -1
- package/rest/knowledgeGraphService.d.ts +2 -2
- package/rest/support/Query.d.ts +1 -3
- package/rest/support/RelationshipQuery.d.ts +1 -1
- package/support/revision.js +1 -1
- package/symbols/LineSymbol3D.js +1 -1
- package/symbols/cim/types.d.ts +32 -0
- package/views/3d/analysis/ShadowCastAnalysisView3D.d.ts +1 -1
- package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/webgl-engine/effects/glow/BlurEmission.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
- package/views/BreakpointsOwner.d.ts +2 -2
- package/views/SceneView.js +1 -1
- package/views/SelectionManager.d.ts +24 -24
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/interactive/support/types.d.ts +0 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/widgets/Attachments/support/attachmentUtils.d.ts +8 -0
- package/widgets/BasemapLayerList/BasemapLayerListViewModel.d.ts +1 -0
- package/widgets/BasemapLayerList/BasemapLayerListViewModel.js +1 -1
- package/widgets/BasemapLayerList/BasemapLayerListVisibleElements.d.ts +5 -1
- package/widgets/BasemapLayerList/types.d.ts +15 -2
- package/widgets/BasemapLayerList.d.ts +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +14 -0
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +29 -2
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/MultipleChoiceController.d.ts +1 -5
- package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/types.d.ts +8 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +2 -2
- package/widgets/Editor.d.ts +2 -2
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +6 -6
- package/widgets/FeatureTable/support/FeatureStore.d.ts +2 -2
- package/widgets/FeatureTable.d.ts +5 -5
- package/widgets/LayerList/LayerListVisibleElements.d.ts +4 -1
- package/widgets/support/SelectionList/SelectionListViewModel.d.ts +1 -1
- package/assets/esri/core/workers/chunks/f9b29d2ce1cd31c0fce1.js +0 -1
- package/graphic/graphicOrigins.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../request.js";import a from"../../../core/Collection.js";import i from"../../../core/Error.js";import n from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import o from"../../../core/ReactiveSet.js";import{generateBracedUUID as l}from"../../../core/uuid.js";import{property as d,subclass as h}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import m from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentCategoryForFile as p}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentKey as u,getAttachmentUrl as g,preserveAttachmentFilenameExtension as y,attachmentValidationUtils as f}from"../attachmentUtils.js";import _ from"./EditableInput.js";import A from"./SingleFeatureInputAdapter.js";import{visibilityCodeToBoolean as U}from"./support/inputUtils.js";let v=-1;const b=["maximum-audio-length","maximum-file-size","maximum-image-size","minimum-number-of-files","maximum-number-of-files","maximum-video-length"];let C=class extends _{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new A({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new a,this._stagedDeletes=new o,this._stagedUpdates=new r,this._failedStagedUpdateHydrations=new o,this._pendingStagedUpdateHydrations=new r,this._temporaryAttachmentUrls=new r,this._validationCriterionStates=new r,this._hasUnsupportedFileTypeValidationError=!1}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return!this.editable||null!=t&&e>=t}get effectiveAttachmentCount(){return this._initialAttachments.length-this._stagedDeletes.size+this._stagedAdds.length}get effectiveVisible(){return U(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:t}=this;if("visible"!==t)return t;const{group:e}=this;if(null==e)return t;const a=e.visibilityCode;return"hidden:visibility-expression:all-features"===a?"hidden:group-visibility-expression:all-features":"hidden:visibility-expression:some-features"===a?"hidden:group-visibility-expression:some-features":t}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const t=new Set;for(const e of this._nestableInputs)x(t,e.type);return t}get _nestableInputs(){const{input:t}=this;return null==t?[]:"attachment"===t.type?t.inputTypes??[]:[t]}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get canUploadFiles(){const t=this._nestableInputs;return!t.length||t.some(F)}get hasCaptureInputs(){return this._nestableInputs.some(w)}get captureMediaType(){const t=new Set;for(const e of this._nestableInputs)if(w(e))switch(e.type){case"audio":t.add("audio");break;case"video":t.add("video");break;case"image":case"signature":t.add("image")}return 1===t.size?Array.from(t)[0]:null}get isCaptureOnly(){const t=this._nestableInputs;return!!t.length&&t.every(T)}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get hasInvalidAttachmentName(){return!!this.allowUserRename&&this.attachments.some(t=>0===t.name.trim().length)}get attachmentCount(){return this.attachments.length}get hasMinimumAttachmentCountNotMet(){const t=this.minAttachmentCount;return!(null==t||!this.effectiveVisible)&&(this.effectiveAttachmentCount<t&&!this.isCaptureOnly)}get hasReachedAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e===t}get hasExceededAttachmentLimit(){const t=this.maxAttachmentCount;return!(null==t||!this.effectiveVisible)&&this.effectiveAttachmentCount>t}get hasPendingAttachmentUpdateData(){return this._pendingStagedUpdateHydrations.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=c(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){return!(this._failedStagedUpdateHydrations.size>0||this.hasInvalidAttachmentName||this.hasExceededAttachmentLimit||this.hasMinimumAttachmentCountNotMet)}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._failedStagedUpdateHydrations.clear(),this._recomputeAttachments()}applyStashedEdits(t){const{adds:e,deletes:a,updates:i}=t;for(const n of e){const t=this._getAttachmentKey(n.info);this._stagedAdds.add({data:n.data,globalId:n.globalId??l(),info:n.info,key:t}),this._setTemporaryAttachmentUrl(t,n.data)}for(const n of i){const t=this._getAttachmentKey(n.info);this._stagedUpdates.set(t,{contentType:n.contentType,data:n.data,info:n.info,key:t,name:n.name,size:I(n)}),this._setTemporaryAttachmentUrl(t,n.data)}for(const n of a){const t=this._getAttachmentKey(n.info);this._stagedDeletes.add(t)}this._recomputeAttachments()}clearAttachmentChanges(){this.clearValidationCriteriaState(),this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._failedStagedUpdateHydrations.clear(),this._pendingStagedUpdateHydrations.clear(),this._recomputeAttachments()}clearValidationCriteriaState(){this._validationCriterionStates.clear(),this._hasUnsupportedFileTypeValidationError=!1}get hasInvalidValidationCriteria(){for(const t of this._validationCriterionStates.values())if("danger"===t)return!0;return!1}get hasUnsupportedFileTypeValidationError(){return this._hasUnsupportedFileTypeValidationError}get validationCriterionStates(){return this._validationCriterionStates}getValidationCriterionState(t){return this._validationCriterionStates.get(t)??null}stageAddAttachment(t){if(!this._assertEditable())throw new i("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false.");const{contentType:e,data:a,name:n}=t,s=t.globalId??l(),r=a instanceof Blob?a.size:void 0,o=n.trim(),d=new m({contentType:e??void 0,globalId:s,id:v--,keywords:this.attachmentKeyword??void 0,name:o,size:r});return this._setTemporaryAttachmentUrl(s,a),this._stagedAdds.add({key:s,globalId:s,info:d,data:a}),this._recomputeAttachments(),d}async stageAddAttachments(t,e){if(this.clearValidationCriteriaState(),!this._assertEditable())return[];const a=t.filter(t=>this.isFileAllowed(t));if(this._setUnsupportedFileTypeValidationError(a.length!==t.length),0===a.length)return[];const i=[],n=new Map,s=Date.now(),r={},o=this.effectiveAttachmentCount,l=o+a.length;if(null!=this.minAttachmentCount&&this.minAttachmentCount>0&&this._setValidationCriterionState(r,"minimum-number-of-files",l>=this.minAttachmentCount?"success":"danger"),null!=this.maxAttachmentCount){const t=l<=this.maxAttachmentCount;if(this._setValidationCriterionState(r,"maximum-number-of-files",t?"success":"danger"),!t)return this._setValidationCriteriaState(r),[]}let d=!0;for(let h=0;h<a.length;h++){const t=a[h];await this._validateAttachmentFile(t,o+h+1,r)||(d=!1)}if(!d)return this._setValidationCriteriaState(r),[];for(let h=0;h<a.length;h++){const t=a[h],r=t instanceof File?t.name:`attachment-${s}_${h+1}`,o=await this._resolveAttachmentFilename(r,e),l=this._makeUniqueFilenameForOperation(n,o);i.push(this.stageAddAttachment({contentType:t.type,data:t,name:l}))}return this._setValidationCriteriaState(r),i}findAttachment(t){if(t)return this.attachments.find(e=>u(e)===t)}getAttachmentEditState(t){const e=this._getAttachmentKey(t),a=e?this._initialAttachments.find(t=>this._getAttachmentKey(t)===e):void 0,i=a?.name??null,n=e?this._stagedUpdates.get(e):void 0,s=n?.name??t.name??null;return{initialName:i,isDeleted:!!e&&this._stagedDeletes.has(e),isRenamed:null!=s&&null!=i&&s!==i,isReplaced:!0===n?.isReplacement}}getAttachmentPreviewUrl(t,e){const a=this._getAttachmentKey(t);return(a?this._temporaryAttachmentUrls.get(a):void 0)??g({attachment:t,supportsResizeAttachments:this.supportsResize,layer:this.layer,thumbnailSize:e})}async ensureStagedUpdateData(t){const e=this._getAttachmentKey(t);if(!e)return!1;const a=this._stagedUpdates.get(e);if(!a||a.data||this._stagedDeletes.has(e))return this._failedStagedUpdateHydrations.delete(e),!1;const i=this._pendingStagedUpdateHydrations.get(e);if(i)return await i;const n=this._hydrateStagedUpdateData(t);this._pendingStagedUpdateHydrations.set(e,n);try{return await n}finally{this._pendingStagedUpdateHydrations.get(e)===n&&this._pendingStagedUpdateHydrations.delete(e)}}async waitForPendingAttachmentUpdateData(){await Promise.allSettled(Array.from(this._pendingStagedUpdateHydrations.values()))}discardStagedEdits(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.delete(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}isFileAllowed(t){const{categories:e}=this;if(!e.size)return!0;const a=p(t);return null!=a&&e.has(a)}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.add(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}stageRenameAttachment(t,e){if(!this._assertEditable())return;const a=this._getAttachmentKey(t);if(!a)return;const i=this._stagedAdds.find(t=>t.key===a);if(i){const a=y(t.name,e);return i.info.name=a,void this._recomputeAttachments()}const n=this._stagedUpdates.get(a),s=this._getInitialAttachment(a)?.name??null,r=0===t.name.trim().length?s??t.name:t.name,o=y(r,!0===n?.isReplacement&&null!=s&&e===s?z(s).base:e),l=null!=s&&o===s;if(l&&!0!==n?.isReplacement)return this._stagedUpdates.delete(a),this._failedStagedUpdateHydrations.delete(a),this._pendingStagedUpdateHydrations.delete(a),void this._recomputeAttachments();const d={key:a,...n,info:t};l?delete d.name:d.name=o,this._stagedUpdates.set(a,d),this._recomputeAttachments(),this.ensureStagedUpdateData(t)}async stageReplaceAttachment(t,e,a){if(this.clearValidationCriteriaState(),!this._assertEditable())return!1;if(!this.isFileAllowed(e))return this._setUnsupportedFileTypeValidationError(!0),!1;const i={},n=await this._validateAttachmentFile(e,void 0,i);if(this._setValidationCriteriaState(i),!n)return!1;const s=e instanceof File?e.name:t.name,r=await this._resolveAttachmentFilename(s,a);return this._stageReplaceAttachment(t,e,r),!0}toSubmitEdits(){const t=[],e=[],a=[],i=this.feature?.plainGraphic;if(!i||0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===this._stagedDeletes.size)return null;const n=this.attachmentKeyword;for(const s of this._stagedAdds)null!=s.data&&t.push({feature:i,contentType:s.info.contentType,data:s.data,info:s.info,globalId:s.info.globalId,keywords:n,name:s.info.name});for(const s of this._stagedUpdates.values()){const t=null==s.name||s.name.trim().length>0;if(null==s.data||!t)continue;const a=s.name??this._getInitialAttachment(s.key)?.name??s.info.name;e.push({feature:i,contentType:s.contentType,data:s.data,globalId:s.info.globalId,id:s.info.id,info:s.info,keywords:n,name:a})}for(const s of this._stagedDeletes.values()){const t=this._getInitialAttachment(s);t&&a.push({feature:i,contentType:t.contentType,globalId:t.globalId,id:t.id,info:t,keywords:n,name:t.name})}return 0===t.length&&0===e.length&&0===a.length?null:{label:this.template.label,keywords:n,adds:t,deletes:a,updates:e}}_assertEditable(){return!!this.editable||(n.getLogger(this).error("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false."),!1)}_recomputeAttachments(){const t=[];for(const e of this._stagedAdds)t.push(e.info);for(const e of this._initialAttachments){const a=this._getAttachmentKey(e);if(a&&this._stagedUpdates.has(a)){const i=this._stagedUpdates.get(a),n=e.clone();null!=i.name&&(n.name=i.name),null!=i.contentType&&(n.contentType=i.contentType),null!=i.size&&(n.size=i.size),t.push(n);continue}t.push(e)}this.attachments=t}async _computeAttachmentFilename(t,e){const a=this.template.filenameExpressionExecutor;if(!a)return t;const i=this.single.feature,r=i?.plainGraphic,o=this._expressionLayer,{attachmentKeyword:l,description:d,label:h}=this.template,c={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:o,$featureset:o,$datastore:o?.url,$feature:r,$map:e.map,$formElement:{attachmentKeyword:l,description:d,label:h}},m={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const e=a.isAsync?await a.executeAsync(c,m):a.execute(c,m);if("string"==typeof e&&e.trim().length>0){const{extension:a}=z(t);return V(e.trim(),a)}}catch(p){s(p)||n.getLogger(this).error("Failed evaluating attachment filename expression",p)}return t}async _resolveAttachmentFilename(t,e){return!1===this.useOriginalFilename?await this._computeAttachmentFilename(t,e):t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),i=t.get(a)??0;if(t.set(a,i+1),0===i)return e;const{base:n,extension:s}=z(e);return V(`${n}_${i}`,s)}_setValidationCriteriaState(t){this._validationCriterionStates.clear();for(const e of b){const a=t[e];a&&this._validationCriterionStates.set(e,a)}}_setUnsupportedFileTypeValidationError(t){this._hasUnsupportedFileTypeValidationError!==t&&(this._hasUnsupportedFileTypeValidationError=t)}_setValidationCriterionState(t,e,a){"danger"!==t[e]&&(t[e]=a)}async _validateAttachmentFile(t,e,a){let i=!0;const n=p(t);for(const s of this._nestableInputs){const e=f.getAttachmentCategoryForInputType(s.type);if(null==n||e===n){if("document"===s.type&&null!=s.maxFileSize){const e=t.size<=1048576*s.maxFileSize;this._setValidationCriterionState(a,"maximum-file-size",e?"success":"danger"),i=i&&e}if(("audio"===s.type||"video"===s.type)&&null!=s.maxDuration){const e=await f.getMediaDurationInSeconds(t,s.type),n=null!=e&&e<=s.maxDuration;this._setValidationCriterionState(a,"audio"===s.type?"maximum-audio-length":"maximum-video-length",n?"success":"danger"),i=i&&n}if("image"===s.type&&null!=s.maxImageSize){const e=await f.getImageDimensionsInPixels(t),n=e?Math.max(e.width,e.height):null,r=null==n||n<=s.maxImageSize;this._setValidationCriterionState(a,"maximum-image-size",r?"success":"danger"),i=i&&r}}}if(null!=e&&null!=this.maxAttachmentCount){const t=e<=this.maxAttachmentCount;this._setValidationCriterionState(a,"maximum-number-of-files",t?"success":"danger"),i=i&&t}return i}_stageReplaceAttachment(t,e,a){const i=this._getAttachmentKey(t);if(!i)return;const n=this._stagedAdds.find(t=>t.key===i);if(n)return n.data=e,n.info.name=a,n.info.contentType=e.type,n.info.size=e.size,this._setTemporaryAttachmentUrl(i,e),void this._recomputeAttachments();const s=this._stagedUpdates.get(i);this._setTemporaryAttachmentUrl(i,e),this._failedStagedUpdateHydrations.delete(i),this._pendingStagedUpdateHydrations.delete(i),this._stagedUpdates.set(i,{...s,key:i,info:t,isReplacement:!0,contentType:e.type||s?.contentType||t.contentType,data:e,name:a,size:e.size}),this._recomputeAttachments()}_getInitialAttachment(t){return this._initialAttachments.find(e=>this._getAttachmentKey(e)===t)}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}_getAttachmentKey(t){return u(t)}_clearStagedUpdateTracking(t){this._stagedUpdates.delete(t),this._failedStagedUpdateHydrations.delete(t),this._pendingStagedUpdateHydrations.delete(t)}async _hydrateStagedUpdateData(t){const a=this._getAttachmentKey(t),i=t.url;if(!a||!i)return!1;try{const{data:n}=await e(i,{responseType:"blob"});this._failedStagedUpdateHydrations.delete(a);const s=this._stagedUpdates.get(a);return!(!s||s.data||this._stagedDeletes.has(a))&&(this._stagedUpdates.set(a,{...s,info:t,isReplacement:s.isReplacement??!1,contentType:s.contentType??t.contentType??n.type,data:n}),!0)}catch(r){const t=this._stagedUpdates.get(a);return!t||t.data||this._stagedDeletes.has(a)||this._failedStagedUpdateHydrations.add(a),s(r)||n.getLogger(this).error("Failed to fetch attachment data for staged update",r),!1}}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([d()],C.prototype,"allowUserRename",null),t([d()],C.prototype,"addDisabled",null),t([d()],C.prototype,"effectiveAttachmentCount",null),t([d()],C.prototype,"effectiveVisible",null),t([d()],C.prototype,"effectiveVisibilityCode",null),t([d()],C.prototype,"accept",null),t([d()],C.prototype,"categories",null),t([d()],C.prototype,"attachmentKeyword",null),t([d()],C.prototype,"attachments",void 0),t([d()],C.prototype,"displayFilename",null),t([d({readOnly:!0})],C.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([d()],C.prototype,"canUploadFiles",null),t([d()],C.prototype,"hasCaptureInputs",null),t([d()],C.prototype,"captureMediaType",null),t([d()],C.prototype,"isCaptureOnly",null),t([d({readOnly:!0})],C.prototype,"defaultPageAttachments",null),t([d()],C.prototype,"displayCount",void 0),t([d()],C.prototype,"feature",null),t([d()],C.prototype,"group",void 0),t([d()],C.prototype,"hasAttachmentChanges",null),t([d()],C.prototype,"hasInvalidAttachmentName",null),t([d()],C.prototype,"attachmentCount",null),t([d()],C.prototype,"hasMinimumAttachmentCountNotMet",null),t([d()],C.prototype,"hasReachedAttachmentLimit",null),t([d()],C.prototype,"hasExceededAttachmentLimit",null),t([d({readOnly:!0})],C.prototype,"hasPendingAttachmentUpdateData",null),t([d()],C.prototype,"input",null),t([d()],C.prototype,"layer",null),t([d()],C.prototype,"maxAttachmentCount",null),t([d()],C.prototype,"minAttachmentCount",null),t([d({readOnly:!0})],C.prototype,"single",void 0),t([d({readOnly:!0})],C.prototype,"type",void 0),t([d({readOnly:!0})],C.prototype,"supportsResize",null),t([d()],C.prototype,"useOriginalFilename",null),t([d({readOnly:!0})],C.prototype,"valid",null),t([d()],C.prototype,"_initialAttachments",void 0),t([d()],C.prototype,"_expressionLayer",null),t([d()],C.prototype,"_stagedAdds",void 0),t([d()],C.prototype,"_stagedDeletes",void 0),t([d()],C.prototype,"_stagedUpdates",void 0),t([d()],C.prototype,"_failedStagedUpdateHydrations",void 0),t([d()],C.prototype,"_pendingStagedUpdateHydrations",void 0),t([d()],C.prototype,"_temporaryAttachmentUrls",void 0),t([d()],C.prototype,"_hasUnsupportedFileTypeValidationError",void 0),t([d()],C.prototype,"hasInvalidValidationCriteria",null),t([d()],C.prototype,"hasUnsupportedFileTypeValidationError",null),t([d()],C.prototype,"validationCriterionStates",null),C=t([h("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],C);const S=C;function x(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}function T(t){return"document"!==t.type&&"capture"===t.inputMethod}function w(t){return T(t)}function F(t){return"document"===t.type||"capture"!==t.inputMethod}function I(t){return t.data&&"string"!=typeof t.data?t.data.size:t.info.size}function z(t){const e=t.lastIndexOf(".");return-1===e?{base:t,extension:null}:{base:t.slice(0,e),extension:t.slice(e+1)}}function V(t,e){return e?`${t}.${e}`:t}export{S as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../request.js";import a from"../../../core/Collection.js";import i from"../../../core/Error.js";import n from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import o from"../../../core/ReactiveSet.js";import{generateBracedUUID as l}from"../../../core/uuid.js";import{property as d,subclass as h}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import m from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentCategoryForFile as p}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentKey as u,getAttachmentUrl as g,preserveAttachmentFilenameExtension as y,attachmentValidationUtils as f}from"../attachmentUtils.js";import _ from"./EditableInput.js";import A from"./SingleFeatureInputAdapter.js";import{visibilityCodeToBoolean as U}from"./support/inputUtils.js";let v=-1;const b=["maximum-audio-length","maximum-file-size","maximum-image-size","minimum-number-of-files","maximum-number-of-files","maximum-video-length"];let C=class extends _{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new A({input:this}),this.touched=!1,this.type="attachment",this._initialAttachments=[],this._stagedAdds=new a,this._stagedDeletes=new o,this._stagedUpdates=new r,this._failedStagedUpdateHydrations=new o,this._pendingStagedUpdateHydrations=new r,this._temporaryAttachmentUrls=new r,this._validationCriterionStates=new r,this._hasUnsupportedFileTypeValidationError=!1}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return!this.editable||null!=t&&e>=t}get effectiveAttachmentCount(){return this._initialAttachments.length-this._stagedDeletes.size+this._stagedAdds.length}get effectiveVisible(){return U(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:t}=this;if("visible"!==t)return t;const{group:e}=this;if(null==e)return t;const a=e.visibilityCode;return"hidden:visibility-expression:all-features"===a?"hidden:group-visibility-expression:all-features":"hidden:visibility-expression:some-features"===a?"hidden:group-visibility-expression:some-features":t}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const t=new Set;for(const e of this._nestableInputs)x(t,e.type);return t}get _nestableInputs(){const{input:t}=this;return null==t?[]:"attachment"===t.type?t.inputTypes??[]:[t]}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get canUploadFiles(){const t=this._nestableInputs;return!t.length||t.some(F)}get hasCaptureInputs(){return this._nestableInputs.some(w)}get captureMediaType(){const t=new Set;for(const e of this._nestableInputs)if(w(e))switch(e.type){case"audio":t.add("audio");break;case"video":t.add("video");break;case"image":case"signature":t.add("image")}return 1===t.size?Array.from(t)[0]:null}get isCaptureOnly(){const t=this._nestableInputs;return!!t.length&&t.every(T)}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get hasInvalidAttachmentName(){return!!this.allowUserRename&&this.attachments.some(t=>0===t.name.trim().length)}get attachmentCount(){return this.attachments.length}get hasMinimumAttachmentCountNotMet(){const t=this.minAttachmentCount;return!(null==t||!this.effectiveVisible)&&(this.effectiveAttachmentCount<t&&!this.isCaptureOnly)}get hasReachedAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e===t}get hasExceededAttachmentLimit(){const t=this.maxAttachmentCount;return!(null==t||!this.effectiveVisible)&&this.effectiveAttachmentCount>t}get hasPendingAttachmentUpdateData(){return this._pendingStagedUpdateHydrations.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=c(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){return!(this._failedStagedUpdateHydrations.size>0||this.hasInvalidAttachmentName||this.hasExceededAttachmentLimit||this.hasMinimumAttachmentCountNotMet)}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._failedStagedUpdateHydrations.clear(),this._recomputeAttachments()}applyStashedEdits(t){const{adds:e,deletes:a,updates:i}=t;for(const n of e){const t=this._getAttachmentKey(n.info);this._stagedAdds.add({data:n.data,globalId:n.globalId??l(),info:n.info,key:t}),this._setTemporaryAttachmentUrl(t,n.data)}for(const n of i){const t=this._getAttachmentKey(n.info);this._stagedUpdates.set(t,{contentType:n.contentType,data:n.data,info:n.info,key:t,name:n.name,size:I(n)}),this._setTemporaryAttachmentUrl(t,n.data)}for(const n of a){const t=this._getAttachmentKey(n.info);this._stagedDeletes.add(t)}this._recomputeAttachments()}clearAttachmentChanges(){this.clearValidationCriteriaState(),this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._failedStagedUpdateHydrations.clear(),this._pendingStagedUpdateHydrations.clear(),this._recomputeAttachments()}clearValidationCriteriaState(){this._validationCriterionStates.clear(),this._hasUnsupportedFileTypeValidationError=!1}get hasInvalidValidationCriteria(){for(const t of this._validationCriterionStates.values())if("danger"===t)return!0;return!1}get hasUnsupportedFileTypeValidationError(){return this._hasUnsupportedFileTypeValidationError}get validationCriterionStates(){return this._validationCriterionStates}getValidationCriterionState(t){return this._validationCriterionStates.get(t)??null}stageAddAttachment(t){if(!this._assertEditable())throw new i("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false.");const{contentType:e,data:a,name:n}=t,s=t.globalId??l(),r=a instanceof Blob?a.size:void 0,o=n.trim(),d=new m({contentType:e??void 0,globalId:s,id:v--,keywords:this.attachmentKeyword??void 0,name:o,size:r});return this._setTemporaryAttachmentUrl(s,a),this._stagedAdds.add({key:s,globalId:s,info:d,data:a}),this._recomputeAttachments(),d}async stageAddAttachments(t,e){if(this.clearValidationCriteriaState(),!this._assertEditable())return[];const a=t.filter(t=>this.isFileAllowed(t));if(this._setUnsupportedFileTypeValidationError(a.length!==t.length),0===a.length)return[];const i=[],n=new Map,s=Date.now(),r={},o=this.effectiveAttachmentCount,l=o+a.length;if(null!=this.minAttachmentCount&&this.minAttachmentCount>0&&this._setValidationCriterionState(r,"minimum-number-of-files",l>=this.minAttachmentCount?"success":"danger"),null!=this.maxAttachmentCount){const t=l<=this.maxAttachmentCount;if(this._setValidationCriterionState(r,"maximum-number-of-files",t?"success":"danger"),!t)return this._setValidationCriteriaState(r),[]}let d=!0;for(let h=0;h<a.length;h++){const t=a[h];await this._validateAttachmentFile(t,o+h+1,r)||(d=!1)}if(!d)return this._setValidationCriteriaState(r),[];for(let h=0;h<a.length;h++){const t=a[h],r=t instanceof File?t.name:`attachment-${s}_${h+1}`,o=await this._resolveAttachmentFilename(r,e),l=this._makeUniqueFilenameForOperation(n,o);i.push(this.stageAddAttachment({contentType:t.type,data:t,name:l}))}return this._setValidationCriteriaState(r),i}findAttachment(t){if(t)return this.attachments.find(e=>u(e)===t)}getAttachmentEditState(t){const e=this._getAttachmentKey(t),a=e?this._initialAttachments.find(t=>this._getAttachmentKey(t)===e):void 0,i=a?.name??null,n=e?this._stagedUpdates.get(e):void 0,s=n?.name??t.name??null;return{initialName:i,isDeleted:!!e&&this._stagedDeletes.has(e),isRenamed:null!=s&&null!=i&&s!==i,isReplaced:!0===n?.isReplacement}}getAttachmentPreviewUrl(t,e){const a=this._getAttachmentKey(t);return(a?this._temporaryAttachmentUrls.get(a):void 0)??g({attachment:t,supportsResizeAttachments:this.supportsResize,layer:this.layer,thumbnailSize:e})}async ensureStagedUpdateData(t){const e=this._getAttachmentKey(t);if(!e)return!1;const a=this._stagedUpdates.get(e);if(!a||a.data||this._stagedDeletes.has(e))return this._failedStagedUpdateHydrations.delete(e),!1;const i=this._pendingStagedUpdateHydrations.get(e);if(i)return await i;const n=this._hydrateStagedUpdateData(t);this._pendingStagedUpdateHydrations.set(e,n);try{return await n}finally{this._pendingStagedUpdateHydrations.get(e)===n&&this._pendingStagedUpdateHydrations.delete(e)}}async waitForPendingAttachmentUpdateData(){await Promise.allSettled(Array.from(this._pendingStagedUpdateHydrations.values()))}discardStagedEdits(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.delete(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}isFileAllowed(t){const{categories:e}=this;if(!e.size)return!0;const a=p(t);return null!=a&&e.has(a)}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.add(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}stageRenameAttachment(t,e){if(!this._assertEditable())return;const a=this._getAttachmentKey(t);if(!a)return;const i=this._stagedAdds.find(t=>t.key===a);if(i){const a=y(t.name,e);return i.info.name=a,void this._recomputeAttachments()}const n=this._stagedUpdates.get(a),s=this._getInitialAttachment(a)?.name??null,r=0===t.name.trim().length?s??t.name:t.name,o=y(r,!0===n?.isReplacement&&null!=s&&e===s?z(s).base:e),l=null!=s&&o===s;if(l&&!0!==n?.isReplacement)return this._stagedUpdates.delete(a),this._failedStagedUpdateHydrations.delete(a),this._pendingStagedUpdateHydrations.delete(a),void this._recomputeAttachments();const d={key:a,...n,info:t};l?delete d.name:d.name=o,this._stagedUpdates.set(a,d),this._recomputeAttachments(),this.ensureStagedUpdateData(t)}async stageReplaceAttachment(t,e,a){if(this.clearValidationCriteriaState(),!this._assertEditable())return!1;if(!this.isFileAllowed(e))return this._setUnsupportedFileTypeValidationError(!0),!1;const i={},n=await this._validateAttachmentFile(e,void 0,i);if(this._setValidationCriteriaState(i),!n)return!1;const s=e instanceof File?e.name:t.name,r=await this._resolveAttachmentFilename(s,a);return this._stageReplaceAttachment(t,e,r),!0}toSubmitEdits(){const t=[],e=[],a=[],i=this.feature?.plainGraphic;if(!i||0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===this._stagedDeletes.size)return null;const n=this.attachmentKeyword;for(const s of this._stagedAdds)null!=s.data&&t.push({feature:i,contentType:s.info.contentType,data:s.data,info:s.info,globalId:s.info.globalId,keywords:n,name:s.info.name});for(const s of this._stagedUpdates.values()){const t=null==s.name||s.name.trim().length>0;if(null==s.data||!t)continue;const a=s.name??this._getInitialAttachment(s.key)?.name??s.info.name;e.push({feature:i,contentType:s.contentType,data:s.data,globalId:s.info.globalId,id:s.info.id,info:s.info,keywords:n,name:a})}for(const s of this._stagedDeletes.values()){const t=this._getInitialAttachment(s);t&&a.push({feature:i,contentType:t.contentType,globalId:t.globalId,id:t.id,info:t,keywords:n,name:t.name})}return 0===t.length&&0===e.length&&0===a.length?null:{label:this.template.label,keywords:n,adds:t,deletes:a,updates:e}}touch(){this.touched=!0}_assertEditable(){return!!this.editable||(n.getLogger(this).error("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false."),!1)}_recomputeAttachments(){const t=[];for(const e of this._stagedAdds)t.push(e.info);for(const e of this._initialAttachments){const a=this._getAttachmentKey(e);if(a&&this._stagedUpdates.has(a)){const i=this._stagedUpdates.get(a),n=e.clone();null!=i.name&&(n.name=i.name),null!=i.contentType&&(n.contentType=i.contentType),null!=i.size&&(n.size=i.size),t.push(n);continue}t.push(e)}this.attachments=t}async _computeAttachmentFilename(t,e){const a=this.template.filenameExpressionExecutor;if(!a)return t;const i=this.single.feature,r=i?.plainGraphic,o=this._expressionLayer,{attachmentKeyword:l,description:d,label:h}=this.template,c={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:o,$featureset:o,$datastore:o?.url,$feature:r,$map:e.map,$formElement:{attachmentKeyword:l,description:d,label:h}},m={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const e=a.isAsync?await a.executeAsync(c,m):a.execute(c,m);if("string"==typeof e&&e.trim().length>0){const{extension:a}=z(t);return V(e.trim(),a)}}catch(p){s(p)||n.getLogger(this).error("Failed evaluating attachment filename expression",p)}return t}async _resolveAttachmentFilename(t,e){return!1===this.useOriginalFilename?await this._computeAttachmentFilename(t,e):t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),i=t.get(a)??0;if(t.set(a,i+1),0===i)return e;const{base:n,extension:s}=z(e);return V(`${n}_${i}`,s)}_setValidationCriteriaState(t){this._validationCriterionStates.clear();for(const e of b){const a=t[e];a&&this._validationCriterionStates.set(e,a)}}_setUnsupportedFileTypeValidationError(t){this._hasUnsupportedFileTypeValidationError!==t&&(this._hasUnsupportedFileTypeValidationError=t)}_setValidationCriterionState(t,e,a){"danger"!==t[e]&&(t[e]=a)}async _validateAttachmentFile(t,e,a){let i=!0;const n=p(t);for(const s of this._nestableInputs){const e=f.getAttachmentCategoryForInputType(s.type);if(null==n||e===n){if("document"===s.type&&null!=s.maxFileSize){const e=t.size<=1048576*s.maxFileSize;this._setValidationCriterionState(a,"maximum-file-size",e?"success":"danger"),i=i&&e}if(("audio"===s.type||"video"===s.type)&&null!=s.maxDuration){const e=await f.getMediaDurationInSeconds(t,s.type),n=null!=e&&e<=s.maxDuration;this._setValidationCriterionState(a,"audio"===s.type?"maximum-audio-length":"maximum-video-length",n?"success":"danger"),i=i&&n}if("image"===s.type&&null!=s.maxImageSize){const e=await f.getImageDimensionsInPixels(t),n=e?Math.max(e.width,e.height):null,r=null==n||n<=s.maxImageSize;this._setValidationCriterionState(a,"maximum-image-size",r?"success":"danger"),i=i&&r}}}if(null!=e&&null!=this.maxAttachmentCount){const t=e<=this.maxAttachmentCount;this._setValidationCriterionState(a,"maximum-number-of-files",t?"success":"danger"),i=i&&t}return i}_stageReplaceAttachment(t,e,a){const i=this._getAttachmentKey(t);if(!i)return;const n=this._stagedAdds.find(t=>t.key===i);if(n)return n.data=e,n.info.name=a,n.info.contentType=e.type,n.info.size=e.size,this._setTemporaryAttachmentUrl(i,e),void this._recomputeAttachments();const s=this._stagedUpdates.get(i);this._setTemporaryAttachmentUrl(i,e),this._failedStagedUpdateHydrations.delete(i),this._pendingStagedUpdateHydrations.delete(i),this._stagedUpdates.set(i,{...s,key:i,info:t,isReplacement:!0,contentType:e.type||s?.contentType||t.contentType,data:e,name:a,size:e.size}),this._recomputeAttachments()}_getInitialAttachment(t){return this._initialAttachments.find(e=>this._getAttachmentKey(e)===t)}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}_getAttachmentKey(t){return u(t)}_clearStagedUpdateTracking(t){this._stagedUpdates.delete(t),this._failedStagedUpdateHydrations.delete(t),this._pendingStagedUpdateHydrations.delete(t)}async _hydrateStagedUpdateData(t){const a=this._getAttachmentKey(t),i=t.url;if(!a||!i)return!1;try{const{data:n}=await e(i,{responseType:"blob"});this._failedStagedUpdateHydrations.delete(a);const s=this._stagedUpdates.get(a);return!(!s||s.data||this._stagedDeletes.has(a))&&(this._stagedUpdates.set(a,{...s,info:t,isReplacement:s.isReplacement??!1,contentType:s.contentType??t.contentType??n.type,data:n}),!0)}catch(r){const t=this._stagedUpdates.get(a);return!t||t.data||this._stagedDeletes.has(a)||this._failedStagedUpdateHydrations.add(a),s(r)||n.getLogger(this).error("Failed to fetch attachment data for staged update",r),!1}}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([d()],C.prototype,"allowUserRename",null),t([d()],C.prototype,"addDisabled",null),t([d()],C.prototype,"effectiveAttachmentCount",null),t([d()],C.prototype,"effectiveVisible",null),t([d()],C.prototype,"effectiveVisibilityCode",null),t([d()],C.prototype,"accept",null),t([d()],C.prototype,"categories",null),t([d()],C.prototype,"attachmentKeyword",null),t([d()],C.prototype,"attachments",void 0),t([d()],C.prototype,"displayFilename",null),t([d({readOnly:!0})],C.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([d()],C.prototype,"canUploadFiles",null),t([d()],C.prototype,"hasCaptureInputs",null),t([d()],C.prototype,"captureMediaType",null),t([d()],C.prototype,"isCaptureOnly",null),t([d({readOnly:!0})],C.prototype,"defaultPageAttachments",null),t([d()],C.prototype,"displayCount",void 0),t([d()],C.prototype,"feature",null),t([d()],C.prototype,"group",void 0),t([d()],C.prototype,"hasAttachmentChanges",null),t([d()],C.prototype,"hasInvalidAttachmentName",null),t([d()],C.prototype,"attachmentCount",null),t([d()],C.prototype,"hasMinimumAttachmentCountNotMet",null),t([d()],C.prototype,"hasReachedAttachmentLimit",null),t([d()],C.prototype,"hasExceededAttachmentLimit",null),t([d({readOnly:!0})],C.prototype,"hasPendingAttachmentUpdateData",null),t([d()],C.prototype,"input",null),t([d()],C.prototype,"layer",null),t([d()],C.prototype,"maxAttachmentCount",null),t([d()],C.prototype,"minAttachmentCount",null),t([d({readOnly:!0})],C.prototype,"single",void 0),t([d()],C.prototype,"touched",void 0),t([d({readOnly:!0})],C.prototype,"type",void 0),t([d({readOnly:!0})],C.prototype,"supportsResize",null),t([d()],C.prototype,"useOriginalFilename",null),t([d({readOnly:!0})],C.prototype,"valid",null),t([d()],C.prototype,"_initialAttachments",void 0),t([d()],C.prototype,"_expressionLayer",null),t([d()],C.prototype,"_stagedAdds",void 0),t([d()],C.prototype,"_stagedDeletes",void 0),t([d()],C.prototype,"_stagedUpdates",void 0),t([d()],C.prototype,"_failedStagedUpdateHydrations",void 0),t([d()],C.prototype,"_pendingStagedUpdateHydrations",void 0),t([d()],C.prototype,"_temporaryAttachmentUrls",void 0),t([d()],C.prototype,"_hasUnsupportedFileTypeValidationError",void 0),t([d()],C.prototype,"hasInvalidValidationCriteria",null),t([d()],C.prototype,"hasUnsupportedFileTypeValidationError",null),t([d()],C.prototype,"validationCriterionStates",null),C=t([h("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],C);const S=C;function x(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}function T(t){return"document"!==t.type&&"capture"===t.inputMethod}function w(t){return T(t)}function F(t){return"document"===t.type||"capture"!==t.inputMethod}function I(t){return t.data&&"string"!=typeof t.data?t.data.size:t.info.size}function z(t){const e=t.lastIndexOf(".");return-1===e?{base:t,extension:null}:{base:t.slice(0,e),extension:t.slice(e+1)}}function V(t,e){return e?`${t}.${e}`:t}export{S as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{property as i,subclass as n}from"../../../core/accessorSupport/decorators.js";import{deepFilterInputs as s,isGroupInput as r,isFieldInput as p,isAttachmentElementInput as o,isEditableInput as u,isUtilityNetworkAssociationsElementInput as a}from"./support/inputUtils.js";let d=class extends e{constructor(t){super(t),this.inputs=[],this.staleInputs=new Map,this.template=null}destroy(){this.inputs.forEach(t=>l(t))}get allFieldInputs(){return s(this.inputs,p)}get allAttachmentElementInputs(){return s(this.inputs,o)}get allEditableInputs(){return s(this.inputs,u)}get allGroupInputs(){return this.inputs.filter(r)}get allUtilityNetworkAssociationsElementInputs(){return s(this.inputs,a)}get description(){return this.template?.description??null}get hasInvalidHiddenInputs(){return this.invalidHiddenInputs.length>0}get invalidFeatures(){return Array.from(new Set(this.allFieldInputs.flatMap(t=>t.invalidFeatures)))}get invalidHiddenInputs(){return this.allFieldInputs.filter(t=>!t.valid&&!t.effectiveVisible)}get title(){return this.template?.title??null}get valid(){return this.allEditableInputs.filter(t=>t.visible).every(t=>t.valid)}};t([i()],d.prototype,"allFieldInputs",null),t([i()],d.prototype,"allAttachmentElementInputs",null),t([i()],d.prototype,"allEditableInputs",null),t([i()],d.prototype,"allGroupInputs",null),t([i()],d.prototype,"allUtilityNetworkAssociationsElementInputs",null),t([i()],d.prototype,"description",null),t([i()],d.prototype,"inputs",void 0),t([i()],d.prototype,"hasInvalidHiddenInputs",null),t([i()],d.prototype,"invalidFeatures",null),t([i()],d.prototype,"invalidHiddenInputs",null),t([i()],d.prototype,"template",void 0),t([i()],d.prototype,"title",null),t([i()],d.prototype,"valid",null),d=t([n("esri.widgets.BatchAttributeForm.inputs.BatchFormInputs")],d);const
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{property as i,subclass as n}from"../../../core/accessorSupport/decorators.js";import{deepFilterInputs as s,isGroupInput as r,isFieldInput as p,isAttachmentElementInput as o,isEditableInput as u,isUtilityNetworkAssociationsElementInput as a}from"./support/inputUtils.js";let d=class extends e{constructor(t){super(t),this.inputs=[],this.staleInputs=new Map,this.template=null}destroy(){this.inputs.forEach(t=>l(t))}get allFieldInputs(){return s(this.inputs,p)}get allAttachmentElementInputs(){return s(this.inputs,o)}get allEditableInputs(){return s(this.inputs,u)}get allGroupInputs(){return this.inputs.filter(r)}get allUtilityNetworkAssociationsElementInputs(){return s(this.inputs,a)}get description(){return this.template?.description??null}get hasInvalidHiddenInputs(){return this.invalidHiddenInputs.length>0}get invalidFeatures(){return Array.from(new Set(this.allFieldInputs.flatMap(t=>t.invalidFeatures)))}get invalidHiddenInputs(){return this.allFieldInputs.filter(t=>!t.valid&&!t.effectiveVisible)}get title(){return this.template?.title??null}get valid(){return this.allEditableInputs.filter(t=>t.visible).every(t=>t.valid)}touchAll(){this.allFieldInputs.forEach(c),this.allAttachmentElementInputs.forEach(c)}};t([i()],d.prototype,"allFieldInputs",null),t([i()],d.prototype,"allAttachmentElementInputs",null),t([i()],d.prototype,"allEditableInputs",null),t([i()],d.prototype,"allGroupInputs",null),t([i()],d.prototype,"allUtilityNetworkAssociationsElementInputs",null),t([i()],d.prototype,"description",null),t([i()],d.prototype,"inputs",void 0),t([i()],d.prototype,"hasInvalidHiddenInputs",null),t([i()],d.prototype,"invalidFeatures",null),t([i()],d.prototype,"invalidHiddenInputs",null),t([i()],d.prototype,"template",void 0),t([i()],d.prototype,"title",null),t([i()],d.prototype,"valid",null),d=t([n("esri.widgets.BatchAttributeForm.inputs.BatchFormInputs")],d);const h=d;function c(t){t.touch()}export{h as default};
|
|
@@ -82,8 +82,29 @@ export default class FieldInput extends EditableInput<any> {
|
|
|
82
82
|
};
|
|
83
83
|
/** Indicates whether the field is required. This property will be true if it is required for any associated layers of the input. */
|
|
84
84
|
get required(): boolean;
|
|
85
|
-
/**
|
|
86
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The status of the field input.
|
|
87
|
+
*
|
|
88
|
+
* Value | Description
|
|
89
|
+
* ------|------------
|
|
90
|
+
* "invalid" | The field value is not valid and an error message is present.
|
|
91
|
+
* "valid" | The field value is valid.
|
|
92
|
+
* "idle" | Either the value is invalid but the error message is suppressed because the user has not yet interacted with the field, or the field has a warning message.
|
|
93
|
+
*
|
|
94
|
+
* @since 5.2
|
|
95
|
+
*/
|
|
96
|
+
get status(): "invalid" | "valid" | "idle";
|
|
97
|
+
/**
|
|
98
|
+
* Indicates whether the field input representing this field has been
|
|
99
|
+
* interacted with by the user. This property is initially `false`. It becomes
|
|
100
|
+
* `true` when the user interacts with the field, or when the user attempts to
|
|
101
|
+
* submit the form — whichever occurs first.
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
* @since 5.2
|
|
105
|
+
* @see [@link widgets/BatchAttributeForm/inputs/FieldInput#userInvalid]
|
|
106
|
+
*/
|
|
107
|
+
get touched(): boolean;
|
|
87
108
|
/**
|
|
88
109
|
* Indicates whether the user has changed the value of this field.
|
|
89
110
|
*
|
|
@@ -128,4 +149,10 @@ export default class FieldInput extends EditableInput<any> {
|
|
|
128
149
|
* @param isChecked - Indicates whether the inline other-choice checkbox is checked.
|
|
129
150
|
*/
|
|
130
151
|
setExplicitMultipleChoiceOtherChoiceCheckedState(isChecked: boolean): void;
|
|
152
|
+
/**
|
|
153
|
+
* Marks the field input as touched, indicating that the user has interacted with it.
|
|
154
|
+
*
|
|
155
|
+
* @since 5.2
|
|
156
|
+
*/
|
|
157
|
+
touch(): void;
|
|
131
158
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{property as r,subclass as n}from"../../../core/accessorSupport/decorators.js";import{isDynamicChoiceInput as l,isMultipleChoiceInput as o}from"../../../form/elements/inputs/inputUtils.js";import a from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import{getDomainRange as u,validateDomainValue as p,dateTimeFieldValuesToNumericRange as d,isDomainValidForField as m}from"../../../layers/support/domainUtils.js";import{getFieldRange as h,isDateOnlyField as c,isTimeOnlyField as f,isTimestampOffsetField as y}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as g}from"../../../layers/support/layerUtils.js";import x from"../../../layers/support/RangeDomain.js";import{isNumber as b}from"../../../support/guards.js";import v from"./EditableInput.js";import{isMultipleChoiceController as C}from"./support/controllerUtils.js";import V from"./support/DynamicChoiceController.js";import{getFieldInputDataType as F,visibilityCodeToBoolean as E,isFieldInputWithShowNoValueOptionInput as _,differentValuesString as w}from"./support/inputUtils.js";import M from"./support/MultipleChoiceController.js";import{otherChoiceCheckedPlaceholderValue as D}from"./support/multipleChoiceInputUtils.js";import{timeResolutionToStepMap as O}from"../../support/dateUtils.js";import{valuesAreEquivalent as S,getMaxLength as k,getMinLength as T,dateIsValid as R,validateFormValue as N}from"../../support/forms/formUtils.js";let L=class extends v{constructor(e){super(e),this.getExternalErrorForFeature=null,this.getFieldValueOptionsForFeature=null,this.group=null,this.inputController=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}destroy(){this.inputController=i(this.inputController)}initialize(){this.input&&(l(this.input)&&(this.inputController=new V({fieldInput:this})),o(this.input)&&(this.inputController=new M({fieldInput:this})))}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return"batch-attribute-form-validation::features-have-different-errors";const t=e[0];for(const i of e)if(i.error!==t.error)return"batch-attribute-form-validation::features-have-different-errors";return t.error}get dataType(){return F(this.field)}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get label(){const{label:e}=this.template,t=this._computeStringLiteralText(e);if(t)return t;const{field:i,layers:r}=this;if(1===r.length){const e=r[0];if(g(e)){const t=e.getFieldAlias(i.name);if(null!=t&&""!==t)return t}}return i.alias||i.name}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if("visible"!==e)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return"hidden:visibility-expression:all-features"===i?"hidden:group-visibility-expression:all-features":"hidden:visibility-expression:some-features"===i?"hidden:group-visibility-expression:some-features":e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every(i=>S(i.getAttribute(e),t))}get field(){return this.template.field}get fieldName(){return this.field.name}get input(){return this.template.input}get invalidFeatures(){return this.errors.map(e=>e.feature)}get isSubtypeField(){return this.layers.some(e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1})}get showNoValueOptionEnabled(){const{input:e}=this;return!this.required&&(!_(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this;return _(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return"date"===this.dataType&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const{input:e}=this;return!e||"timestampoffset-picker"===e.type&&e.includeTimeOffset}get inputType(){return this.input?.type}get maxLength(){return k({dataType:this.dataType,field:this.field,input:this.input})}get minLength(){return T({dataType:this.dataType,field:this.field,input:this.input})}get multipleChoiceOtherChoiceCheckboxState(){return A(this.inputController)?.otherChoiceCheckboxState??{checked:!1,indeterminate:!1}}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=u(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every(e=>!e)?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get timeResolution(){const e=this.input;if(e&&("timestampoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?O.get(this.timeResolution):void 0}get valid(){return 0===this.errors.length||!this.editable}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:w}get valueIsOutOfDomain(){const{domain:e,value:t,field:i}=this;return!(!e||null==t)&&null!==p(i,t,e)}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?"hidden:no-domain-in-common":this._baseVisibilityCode:"hidden:field-definition"}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map(({name:e,code:t})=>({name:e,value:t})):[]}getExplicitMultipleChoiceOtherChoiceCheckedState(){return A(this.inputController)?.getExplicitOtherChoiceCheckedState()}getMultipleChoiceOtherChoiceRenderState(e){const t=A(this.inputController)?.otherChoiceRenderState;return t?{...t,label:t.label??e}:{fieldName:void 0,hint:"",label:e,shouldShow:!1,checkboxState:{checked:!1,indeterminate:!1},value:null,normalizedValue:null,maxLength:void 0,status:"idle"}}hasExplicitMultipleChoiceOtherChoiceCheckedState(){return A(this.inputController)?.hasExplicitOtherChoiceCheckedState()??!1}initializeExplicitMultipleChoiceOtherChoiceCheckedState(){A(this.inputController)?.initializeExplicitOtherChoiceCheckedState()}setExplicitMultipleChoiceOtherChoiceCheckedState(e){A(this.inputController)?.setExplicitOtherChoiceCheckedState(e)}get codedValueOptions(){const{getFieldValueOptionsForFeature:e}=this;if(1===this.features.length&&e){const t=this.features.at(0);return e({domain:this.domain??void 0,feature:t,fieldName:this.fieldName,layer:t.layer})}const t=this.codedValueDomainOptions,{value:i}=this,r=null==i||i===w||t.some(e=>e.value===i)?[]:[{name:`${i}`,value:i}];return{recommended:t,other:[],unsupported:r,containsEmptyOption:!1}}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"requiredExpression");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map(t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i})}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const{input:e}=this;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"timestampoffset-picker"!==t||(i=d(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&R(t)?t.getTime():null,min:null!=r&&R(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=u(i,r);if(!n)return e;const{max:l,min:o,rawMax:a,rawMin:s}=e,{type:p}=t.field;if("date"===p){const{max:e,min:t}=n;return{max:b(l)&&(null===e||null!=e&&l<=e)?l:e??null,min:b(o)&&(null===t||null!=t&&o>=t)?o:t??null}}if("date-only"===p||"time-only"===p||"timestamp-offset"===p){const{max:e,min:t,rawMax:i,rawMin:r}=n,u=b(l)&&a&&(null==e||l<e),p=b(o)&&s&&(null==t||o>t);return{max:u?l:e,min:p?o:t,rawMax:u?a:i,rawMin:p?s:r}}return{}}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,l=[],o=C(this.inputController)?this.inputController:void 0,a=o?.input;for(const s of this.features){const{layer:u}=s,p=u.getField(t)??this.field,d=u.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([d]),h=m&&"coded-value"!==m.type?m:null,c=this._requiredForFeature(s),f=s.getAttribute(t);let y=N(f,{dataType:e,domain:h,field:p,maxLength:i,minLength:r,multipleChoice:a,range:n,required:c})??this.getExternalErrorForFeature?.(s,t);if(!y&&a&&o){const{otherChoice:e}=a,t=o.otherChoiceFieldName,i=o.shouldShowOtherChoice,r=o.otherChoiceEffectiveCheckboxState;if(i&&e&&t&&r.checked){const e=u.getField(t),i=s.getAttribute(t),r=i===D?null:i;if(e){const t=F(e);y=N(r,{dataType:t,domain:e.domain,field:e,maxLength:k({dataType:t,field:e,input:null}),minLength:T({dataType:t,field:e,input:null}),multipleChoice:null,range:{max:void 0,min:void 0},required:!0})}}}y&&l.push({error:y,feature:s.source})}return l}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editableExpression");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibilityExpression");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"requiredExpression");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find(e=>null!=e),i=this.template.domain;if(!t)return i&&m(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some(e=>!e)){if(!i)return null;e=e.filter(e=>null!==e)}break;case"range":e=e.filter(e=>null!==e)}if(!e.every(e=>e?.type===t?.type))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map(({code:e,name:t})=>[e,t])),i=this.template.domain?new Map(this.template.domain.codedValues.map(({code:e,name:t})=>[e,t])):null;for(const l of e)for(const[e,i]of t){l.codedValues.some(t=>t.code===e&&t.name===i)||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map(([e,t])=>new a({code:e,name:t}));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];for(let r=1;r<e.length;r++){if(!t)return null;t=this._findMinMaxValuesBetweenTwoDomains(t,e[r])}if(t&&!m(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof x){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||y(r)?d(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new x,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:l}=this,o=this._getValidRangeValue(r.min,-1/0),a=this._getValidRangeValue(r.max,1/0),s=this._getValidRangeValue(n.min,-1/0),u=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(o,s),i.maxValue=Math.min(a,u),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(l)||f(l)||y(l))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return b(e)?e:t}};e([r()],L.prototype,"dataType",null),e([r()],L.prototype,"domain",null),e([r()],L.prototype,"distinctValues",null),e([r()],L.prototype,"editable",null),e([r()],L.prototype,"label",null),e([r()],L.prototype,"effectiveVisible",null),e([r()],L.prototype,"effectiveVisibilityCode",null),e([r()],L.prototype,"errors",null),e([r()],L.prototype,"featuresHaveSameValue",null),e([r()],L.prototype,"field",null),e([r()],L.prototype,"fieldName",null),e([r()],L.prototype,"getExternalErrorForFeature",void 0),e([r()],L.prototype,"getFieldValueOptionsForFeature",void 0),e([r()],L.prototype,"group",void 0),e([r()],L.prototype,"input",null),e([r()],L.prototype,"inputController",void 0),e([r()],L.prototype,"invalidFeatures",null),e([r()],L.prototype,"isSubtypeField",null),e([r()],L.prototype,"showNoValueOptionEnabled",null),e([r()],L.prototype,"showNoValueLabel",null),e([r()],L.prototype,"includeTime",null),e([r()],L.prototype,"includeTimeOffset",null),e([r({readOnly:!0})],L.prototype,"inputType",null),e([r()],L.prototype,"maxLength",null),e([r()],L.prototype,"minLength",null),e([r()],L.prototype,"multipleChoiceOtherChoiceCheckboxState",null),e([r()],L.prototype,"range",null),e([r()],L.prototype,"required",null),e([r()],L.prototype,"timeResolution",null),e([r()],L.prototype,"timeStep",null),e([r({readOnly:!0})],L.prototype,"type",void 0),e([r()],L.prototype,"userHasChangedValue",void 0),e([r()],L.prototype,"valid",null),e([r()],L.prototype,"value",null),e([r()],L.prototype,"valueIsOutOfDomain",null),e([r()],L.prototype,"visibilityCode",null),e([r()],L.prototype,"codedValueDomainOptions",null),e([r()],L.prototype,"codedValueOptions",null),e([r()],L.prototype,"_evaluatedRequiredExpression",null),e([r()],L.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],L.prototype,"_allDomains",null),e([r()],L.prototype,"_fieldShouldHaveDomain",null),e([r()],L.prototype,"_dateFormRange",null),e([r()],L.prototype,"_dateRange",null),L=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],L);const j=L;function A(e){return C(e)?e:null}export{j as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{property as r,subclass as n}from"../../../core/accessorSupport/decorators.js";import{isDynamicChoiceInput as l,isMultipleChoiceInput as o}from"../../../form/elements/inputs/inputUtils.js";import a from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import{getDomainRange as u,validateDomainValue as p,dateTimeFieldValuesToNumericRange as d,isDomainValidForField as m}from"../../../layers/support/domainUtils.js";import{getFieldRange as h,isDateOnlyField as c,isTimeOnlyField as f,isTimestampOffsetField as y}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as g}from"../../../layers/support/layerUtils.js";import v from"../../../layers/support/RangeDomain.js";import{isNumber as x}from"../../../support/guards.js";import b from"./EditableInput.js";import{isMultipleChoiceController as C}from"./support/controllerUtils.js";import V from"./support/DynamicChoiceController.js";import{getFieldInputDataType as F,visibilityCodeToBoolean as E,isFieldInputWithShowNoValueOptionInput as _,isWarning as M,isContingentValuesError as w,differentValuesString as D}from"./support/inputUtils.js";import O from"./support/MultipleChoiceController.js";import{otherChoiceCheckedPlaceholderValue as S}from"./support/multipleChoiceInputUtils.js";import{timeResolutionToStepMap as k}from"../../support/dateUtils.js";import{valuesAreEquivalent as T,getMaxLength as R,getMinLength as N,dateIsValid as L,validateFormValue as j}from"../../support/forms/formUtils.js";let A=class extends b{constructor(e){super(e),this.getExternalErrorForFeature=null,this.getFieldValueOptionsForFeature=null,this.group=null,this.inputController=null,this.touched=!1,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}destroy(){this.inputController=i(this.inputController)}initialize(){this.input&&(l(this.input)&&(this.inputController=new V({fieldInput:this})),o(this.input)&&(this.inputController=new O({fieldInput:this})))}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return"batch-attribute-form-validation::features-have-different-errors";const t=e[0];for(const i of e)if(i.error!==t.error)return"batch-attribute-form-validation::features-have-different-errors";return t.error}get dataType(){return F(this.field)}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get label(){const{label:e}=this.template,t=this._computeStringLiteralText(e);if(t)return t;const{field:i,layers:r}=this;if(1===r.length){const e=r[0];if(g(e)){const t=e.getFieldAlias(i.name);if(null!=t&&""!==t)return t}}return i.alias||i.name}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if("visible"!==e)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return"hidden:visibility-expression:all-features"===i?"hidden:group-visibility-expression:all-features":"hidden:visibility-expression:some-features"===i?"hidden:group-visibility-expression:some-features":e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every(i=>T(i.getAttribute(e),t))}get field(){return this.template.field}get fieldName(){return this.field.name}get input(){return this.template.input}get invalidFeatures(){return this.errors.map(e=>e.feature)}get isSubtypeField(){return this.layers.some(e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1})}get showNoValueOptionEnabled(){const{input:e}=this;return!this.required&&(!_(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this;return _(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return"date"===this.dataType&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const{input:e}=this;return!e||"timestampoffset-picker"===e.type&&e.includeTimeOffset}get inputType(){return this.input?.type}get maxLength(){return R({dataType:this.dataType,field:this.field,input:this.input})}get minLength(){return N({dataType:this.dataType,field:this.field,input:this.input})}get multipleChoiceOtherChoiceCheckboxState(){return q(this.inputController)?.otherChoiceCheckboxState??{checked:!1,indeterminate:!1}}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=u(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every(e=>!e)?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get status(){const{validationMessage:e}=this;return e?M(e)?"idle":"invalid":this.valid?"valid":"idle"}get timeResolution(){const e=this.input;if(e&&("timestampoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?k.get(this.timeResolution):void 0}get userInvalid(){return!!this.errors.some(({error:e})=>w(e))||!this.valid&&this.touched}get valid(){return 0===this.errors.length||!this.editable}get validationMessage(){return this.valueIsOutOfDomain&&this.touched?"batch-attribute-form-validation::out-of-subtype-domain":this.userInvalid?this.compositeError:null}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:D}get valueIsOutOfDomain(){const{domain:e,value:t,field:i}=this;return!(!e||null==t)&&null!==p(i,t,e)}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?"hidden:no-domain-in-common":this._baseVisibilityCode:"hidden:field-definition"}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map(({name:e,code:t})=>({name:e,value:t})):[]}getExplicitMultipleChoiceOtherChoiceCheckedState(){return q(this.inputController)?.getExplicitOtherChoiceCheckedState()}getMultipleChoiceOtherChoiceRenderState(e){const t=q(this.inputController)?.otherChoiceRenderState;return t?{...t,label:t.label??e}:{fieldName:void 0,hint:"",label:e,shouldShow:!1,checkboxState:{checked:!1,indeterminate:!1},value:null,normalizedValue:null,maxLength:void 0,status:"idle"}}hasExplicitMultipleChoiceOtherChoiceCheckedState(){return q(this.inputController)?.hasExplicitOtherChoiceCheckedState()??!1}initializeExplicitMultipleChoiceOtherChoiceCheckedState(){q(this.inputController)?.initializeExplicitOtherChoiceCheckedState()}setExplicitMultipleChoiceOtherChoiceCheckedState(e){q(this.inputController)?.setExplicitOtherChoiceCheckedState(e)}get codedValueOptions(){const{getFieldValueOptionsForFeature:e}=this;if(1===this.features.length&&e){const t=this.features.at(0);return e({domain:this.domain??void 0,feature:t,fieldName:this.fieldName,layer:t.layer})}const t=this.codedValueDomainOptions,{value:i}=this,r=null==i||i===D||t.some(e=>e.value===i)?[]:[{name:`${i}`,value:i}];return{recommended:t,other:[],unsupported:r,containsEmptyOption:!1}}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"requiredExpression");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map(t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i})}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const{input:e}=this;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"timestampoffset-picker"!==t||(i=d(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&L(t)?t.getTime():null,min:null!=r&&L(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=u(i,r);if(!n)return e;const{max:l,min:o,rawMax:a,rawMin:s}=e,{type:p}=t.field;if("date"===p){const{max:e,min:t}=n;return{max:x(l)&&(null===e||null!=e&&l<=e)?l:e??null,min:x(o)&&(null===t||null!=t&&o>=t)?o:t??null}}if("date-only"===p||"time-only"===p||"timestamp-offset"===p){const{max:e,min:t,rawMax:i,rawMin:r}=n,u=x(l)&&a&&(null==e||l<e),p=x(o)&&s&&(null==t||o>t);return{max:u?l:e,min:p?o:t,rawMax:u?a:i,rawMin:p?s:r}}return{}}touch(){this.touched=!0}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,l=[],o=C(this.inputController)?this.inputController:void 0,a=o?.input;for(const s of this.features){const{layer:u}=s,p=u.getField(t)??this.field,d=u.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([d]),h=m&&"coded-value"!==m.type?m:null,c=this._requiredForFeature(s),f=s.getAttribute(t);let y=j(f,{dataType:e,domain:h,field:p,maxLength:i,minLength:r,multipleChoice:a,range:n,required:c})??this.getExternalErrorForFeature?.(s,t);if(!y&&a&&o){const{otherChoice:e}=a,t=o.otherChoiceFieldName,i=o.shouldShowOtherChoice,r=o.otherChoiceEffectiveCheckboxState;if(i&&e&&t&&r.checked){const e=u.getField(t),i=s.getAttribute(t),r=i===S?null:i;if(e){const t=F(e);y=j(r,{dataType:t,domain:e.domain,field:e,maxLength:R({dataType:t,field:e,input:null}),minLength:N({dataType:t,field:e,input:null}),multipleChoice:null,range:{max:void 0,min:void 0},required:!0})}}}y&&l.push({error:y,feature:s.source})}return l}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editableExpression");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibilityExpression");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"requiredExpression");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find(e=>null!=e),i=this.template.domain;if(!t)return i&&m(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some(e=>!e)){if(!i)return null;e=e.filter(e=>null!==e)}break;case"range":e=e.filter(e=>null!==e)}if(!e.every(e=>e?.type===t?.type))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map(({code:e,name:t})=>[e,t])),i=this.template.domain?new Map(this.template.domain.codedValues.map(({code:e,name:t})=>[e,t])):null;for(const l of e)for(const[e,i]of t){l.codedValues.some(t=>t.code===e&&t.name===i)||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map(([e,t])=>new a({code:e,name:t}));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];for(let r=1;r<e.length;r++){if(!t)return null;t=this._findMinMaxValuesBetweenTwoDomains(t,e[r])}if(t&&!m(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof v){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||y(r)?d(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new v,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:l}=this,o=this._getValidRangeValue(r.min,-1/0),a=this._getValidRangeValue(r.max,1/0),s=this._getValidRangeValue(n.min,-1/0),u=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(o,s),i.maxValue=Math.min(a,u),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(l)||f(l)||y(l))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return x(e)?e:t}};e([r()],A.prototype,"dataType",null),e([r()],A.prototype,"domain",null),e([r()],A.prototype,"distinctValues",null),e([r()],A.prototype,"editable",null),e([r()],A.prototype,"label",null),e([r()],A.prototype,"effectiveVisible",null),e([r()],A.prototype,"effectiveVisibilityCode",null),e([r()],A.prototype,"errors",null),e([r()],A.prototype,"featuresHaveSameValue",null),e([r()],A.prototype,"field",null),e([r()],A.prototype,"fieldName",null),e([r()],A.prototype,"getExternalErrorForFeature",void 0),e([r()],A.prototype,"getFieldValueOptionsForFeature",void 0),e([r()],A.prototype,"group",void 0),e([r()],A.prototype,"input",null),e([r()],A.prototype,"inputController",void 0),e([r()],A.prototype,"invalidFeatures",null),e([r()],A.prototype,"isSubtypeField",null),e([r()],A.prototype,"showNoValueOptionEnabled",null),e([r()],A.prototype,"showNoValueLabel",null),e([r()],A.prototype,"includeTime",null),e([r()],A.prototype,"includeTimeOffset",null),e([r({readOnly:!0})],A.prototype,"inputType",null),e([r()],A.prototype,"maxLength",null),e([r()],A.prototype,"minLength",null),e([r()],A.prototype,"multipleChoiceOtherChoiceCheckboxState",null),e([r()],A.prototype,"range",null),e([r()],A.prototype,"required",null),e([r()],A.prototype,"status",null),e([r()],A.prototype,"timeResolution",null),e([r()],A.prototype,"timeStep",null),e([r()],A.prototype,"touched",void 0),e([r({readOnly:!0})],A.prototype,"type",void 0),e([r()],A.prototype,"userHasChangedValue",void 0),e([r()],A.prototype,"userInvalid",null),e([r()],A.prototype,"valid",null),e([r()],A.prototype,"validationMessage",null),e([r()],A.prototype,"value",null),e([r()],A.prototype,"valueIsOutOfDomain",null),e([r()],A.prototype,"visibilityCode",null),e([r()],A.prototype,"codedValueDomainOptions",null),e([r()],A.prototype,"codedValueOptions",null),e([r()],A.prototype,"_evaluatedRequiredExpression",null),e([r()],A.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],A.prototype,"_allDomains",null),e([r()],A.prototype,"_fieldShouldHaveDomain",null),e([r()],A.prototype,"_dateFormRange",null),e([r()],A.prototype,"_dateRange",null),A=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],A);const I=A;function q(e){return C(e)?e:null}export{I as default};
|
|
@@ -4,11 +4,7 @@ import type Choice from "../../../../form/elements/inputs/multipleChoice/Choice.
|
|
|
4
4
|
import type FieldInput from "../FieldInput.js";
|
|
5
5
|
import type { FieldValue } from "../../../../layers/support/fieldUtils.js";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Represents the current render state for inline multiple-choice "Other" controls.
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
7
|
+
/** Represents the current render state for inline multiple-choice "Other" controls. */
|
|
12
8
|
export interface MultipleChoiceOtherChoiceRenderState {}
|
|
13
9
|
|
|
14
10
|
/** @internal */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{isNumericField as t,isStringField as n,isTimeOnlyField as
|
|
2
|
+
import{isNumericField as t,isStringField as n,isTimeOnlyField as r}from"../../../../layers/support/fieldUtils.js";import{isAnyDateField as e}from"../../../../smartMapping/support/utils.js";import{ContingentValuesValidationError as u}from"../../../support/forms/formUtils.js";const o="esri_BatchAttributeForm_different_values";function i(t){return"visible"===t}function s(t){return"batch-attribute-form-validation::out-of-subtype-domain"===t}function c(t){return"field"===t.type}function p(t){return c(t)&&"multiple-choice"===t.input?.type}function f(t){return"group"===t.type}function l(t){return"relationship"===t.type}function a(t){return"text"===t.type}function m(t){return"attachment"===t.type}function d(t){return c(t)||m(t)||l(t)||N(t)}function y(t){return c(t)||m(t)||l(t)||N(t)||a(t)}function x(t){return y(t)&&null!=t.group}function N(t){return"utilityNetworkAssociations"===t.type}function I(t){const n=`${t.elementId}:${t.executorPurpose}`;return null!=t.textExpressionIndex?`${n}:${t.textExpressionIndex}`:n}const b=t=>null!=t&&(h(t,"combo-box")||h(t,"dynamic-choice")||h(t,"radio-buttons"));function h(t,n){return t?.type===n}function O(t,n,r=[]){for(const e of t)n(e)?r.push(e):f(e)&&O(e.inputs,n,r);return r}function _(t,n){return t.layers[0]?.getField(n)?.name??n}function A(u){return t(u)?"number":n(u)?"text":e(u)||r(u)?"date":"unsupported"}function E(t){return t===u.CONTINGENCY_VIOLATION_ERROR||t===u.CONTINGENCY_VIOLATION_WARNING}export{O as deepFilterInputs,o as differentValuesString,A as getFieldInputDataType,_ as getNormalizedFieldName,m as isAttachmentElementInput,E as isContingentValuesError,d as isEditableInput,c as isFieldInput,b as isFieldInputWithShowNoValueOptionInput,f as isGroupInput,y as isGroupableInput,x as isGroupedInput,h as isInputWithInputType,p as isMultipleChoiceFieldInput,l as isRelationshipElementInput,a as isTextElementInput,N as isUtilityNetworkAssociationsElementInput,s as isWarning,I as makeUseId,i as visibilityCodeToBoolean};
|
|
@@ -29,4 +29,11 @@ export type FormInput = GroupInput | FieldInput | RelationshipElementInput | Att
|
|
|
29
29
|
*
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
|
-
export interface AttachmentEditState {}
|
|
32
|
+
export interface AttachmentEditState {}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Various categories that attachments belong to based on the content type.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export type AttachmentTypeCategory = "audio" | "document" | "image" | "unknown" | "video";
|