@arcgis/core 4.30.0-next.20240612 → 4.30.0-next.20240613
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/6ae4a5e81fd398d2ebca.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -4
- package/assets/esri/themes/base/widgets/_SnappingControls.scss +5 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ShadowHighlight.glsl.js +4 -29
- package/chunks/Viewshed.glsl.js +145 -84
- package/interfaces.d.ts +208 -47
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/package.json +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/svgUtils.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js +23 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ViewshedTechniqueConfiguration.js +5 -0
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
- package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
- package/widgets/support/SnappingControls/SnappingListItem.js +1 -1
- package/widgets/support/SnappingControls/snappingLayerListUtils.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/assets/esri/core/workers/chunks/17e8791bad1e2c3a0bb1.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{watch as i,sync as l}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import a from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as u,dateTimeFieldValuesToNumericRange as o,validateDomainValue as p}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as d,getLowerCaseEditTrackingFields as m,isNumericField as y,isStringField as f,isTimeOnlyField as h,getFieldRange as c,TypeValidationError as g,NumericRangeValidationError as b,validateFieldValue as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as v}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as E}from"../Feature/support/featureUtils.js";import _ from"./EditableInput.js";import{parseFormTemplateString as V,getNormalizedFeatureTypeInfo as w,isFieldElementWithInputType as T,valueIsInvalidSwitchValue as F,isFieldElementWithTextInput as D,isFieldElementWithShowNoValueOptionInput as N,LengthValidationError as O}from"./featureFormUtils.js";import{isNumber as I}from"../support/dataUtils.js";import{timeResolutionToStepMap as j,isArcadeDate as A,arcadeDateToFieldValue as L,dateTimeIsInRange as R}from"../support/dateUtils.js";var M;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(M||(M={}));const U="__internal-type-based-coded-value-domain__";let S=class extends _{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}initialize(){this.addHandles(i((()=>this.feature),(()=>this._fieldInputWasVisibleDuringLifetime=!1),l))}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?u(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=o(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&k(e)?e.getTime():null,min:null!=t&&k(t)?t.getTime():null}}const{max:s,min:a}=r;if(i){const{max:e,min:t}=i,l=I(e)&&(null==s||null!=s&&e<s),n=I(t)&&(null==a||null!=a&&t>a);return{max:l?e:s??null,min:n?t:a??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:a,max:s,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=u(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:s}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:I(l)&&(null===e||null!=e&&l<e)?l:e??null,min:I(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:a,rawMin:u}=i,o=I(l)&&r&&(null==e||l<e);return{max:o?l:e,min:I(n)&&s&&(null==t||n>t)?n:t,rawMax:o?r:a,rawMin:o?s:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&d(e,t)}get _isEditTrackingField(){return m(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get valueIsOutOfDomain(){const{domain:e,value:t,field:i}=this;return!(!e||null==t)&&null!==p(i,t,e)}get dataType(){const{field:e}=this;return y(e)?M.Number:f(e)?M.Text:v(e)||h(e)?M.Date:M.Unsupported}get dateDataType(){if(this.dataType===M.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?V({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=w(e);if(this.isSubtypeField&&"subtypes"in e&&e.subtypes)return new a({name:U,codedValues:e.subtypes.map((({code:e,name:t})=>new s({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new a({name:U,codedValues:i.map((({code:e,name:t})=>new s({code:e,name:t})))});const{feature:l}=this,n=e?.getFieldDomain(this.name,{feature:l}),r=this.element?.domain;return null!=r&&this._isDomainCompatible(r)?r:n}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==M.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==M.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=T(e,"switch")?e.input:null;return!t||F(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return E(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?V({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=u(i,e)||c(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:s,min:a}=u(i)||{};return{max:null!=s&&(null===n||null!=n&&s<n)?s:n,min:null!=a&&(null===r||null!=r&&a>r)?a:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,isSubtypeField:n}=this;if(!e)return!1;if(!1===i?.nullable)return!0;if(n)return!0;return!(!l||!1===this.group?.visible||null==t)&&t}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!N(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return N(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?j.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.visibilityExpressionExecutor?.lastEvaluatedValue||!1===this.group?.visibilityExpressionExecutor?.lastEvaluatedValue))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===M.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(A(e))return L(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&f(t)||"number"===i&&y(t))return!0}return!!("range"===e?.type&&y(t)||v(t)||h(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:u}=this,o=s&&null==u,d=void 0!==a;return!o&&l.getAttribute(i.name)===u&&d?null:o?g.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof u&&u.length<n?O.TOO_SHORT:"date"!==e||null==u||R({type:i.type,range:r,value:u})?t?null!==u||s?p(i,u):null:x(i,u):b.OUT_OF_RANGE}};e([n()],S.prototype,"_dateFormRange",null),e([n()],S.prototype,"_dateRange",null),e([n()],S.prototype,"_storedValue",void 0),e([n()],S.prototype,"_configAllowsEdits",null),e([n()],S.prototype,"_layerAndFieldAllowEdits",null),e([n()],S.prototype,"_isVisibleByDefault",null),e([n()],S.prototype,"_isEditTrackingField",null),e([n()],S.prototype,"_shouldUseValueExpression",null),e([n()],S.prototype,"isSubtypeField",null),e([n()],S.prototype,"valueIsOutOfDomain",null),e([n()],S.prototype,"dataType",null),e([n()],S.prototype,"dateDataType",null),e([n()],S.prototype,"description",null),e([n()],S.prototype,"domain",null),e([n()],S.prototype,"editable",null),e([n({readOnly:!0})],S.prototype,"error",void 0),e([n({constructOnly:!0})],S.prototype,"preservesValueWhenHidden",void 0),e([n()],S.prototype,"evaluatedRequiredExpression",null),e([n()],S.prototype,"evaluatedValueExpression",null),e([n()],S.prototype,"field",void 0),e([n()],S.prototype,"group",void 0),e([n({readOnly:!0})],S.prototype,"hint",null),e([n()],S.prototype,"includeDate",null),e([n()],S.prototype,"includeTime",null),e([n()],S.prototype,"includeTimeOffset",null),e([n()],S.prototype,"initialFeature",null),e([n({readOnly:!0})],S.prototype,"inputType",null),e([n()],S.prototype,"hasInvalidSwitchValue",null),e([n()],S.prototype,"isRelationshipKeyField",null),e([n()],S.prototype,"label",null),e([n()],S.prototype,"maxLength",null),e([n()],S.prototype,"minLength",null),e([n({readOnly:!0})],S.prototype,"name",null),e([n()],S.prototype,"range",null),e([n()],S.prototype,"required",null),e([n()],S.prototype,"requiredExpressionExecutor",void 0),e([n()],S.prototype,"showNoValueOptionEnabled",null),e([n()],S.prototype,"submittable",null),e([n()],S.prototype,"timeResolution",null),e([n()],S.prototype,"timeStep",null),e([n({readOnly:!0})],S.prototype,"type",void 0),e([n()],S.prototype,"updating",null),e([n()],S.prototype,"valid",null),e([n({value:null})],S.prototype,"value",null),e([n()],S.prototype,"valueExpressionExecutor",void 0),e([n()],S.prototype,"visible",null),S=e([r("esri.widgets.FeatureForm.FieldInput")],S);const k=e=>e&&!Number.isNaN(e.valueOf()),q=S;export{q as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{watch as i,sync as l}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import u from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as a,dateTimeFieldValuesToNumericRange as o,validateDomainValue as p}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as d,getLowerCaseEditTrackingFields as m,isNumericField as f,isStringField as y,isTimeOnlyField as h,getFieldRange as c,TypeValidationError as g,NumericRangeValidationError as b,validateFieldValue as x}from"../../layers/support/fieldUtils.js";import{isAnyDateField as v}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as E}from"../Feature/support/featureUtils.js";import _ from"./EditableInput.js";import{parseFormTemplateString as V,getNormalizedFeatureTypeInfo as w,isFieldElementWithInputType as T,valueIsInvalidSwitchValue as F,isFieldElementWithTextInput as D,isFieldElementWithShowNoValueOptionInput as O,LengthValidationError as N}from"./featureFormUtils.js";import{isNumber as I}from"../support/dataUtils.js";import{timeResolutionToStepMap as j,isArcadeDate as L,arcadeDateToFieldValue as A,dateTimeIsInRange as R}from"../support/dateUtils.js";var M;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(M||(M={}));const U="__internal-type-based-coded-value-domain__";let S=class extends _{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}initialize(){this.addHandles(i((()=>this.feature),(()=>this._fieldInputWasVisibleDuringLifetime=!1),l))}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?a(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=o(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&k(e)?e.getTime():null,min:null!=t&&k(t)?t.getTime():null}}const{max:s,min:u}=r;if(i){const{max:e,min:t}=i,l=I(e)&&(null==s||null!=s&&e<s),n=I(t)&&(null==u||null!=u&&t>u);return{max:l?e:s??null,min:n?t:u??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:u,max:s,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=a(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:s}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:I(l)&&(null===e||null!=e&&l<e)?l:e??null,min:I(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:u,rawMin:a}=i,o=I(l)&&r&&(null==e||l<e);return{max:o?l:e,min:I(n)&&s&&(null==t||n>t)?n:t,rawMax:o?r:u,rawMin:o?s:a}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&d(e,t)}get _isEditTrackingField(){return m(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get valueIsOutOfDomain(){const{domain:e,value:t,field:i}=this;return!(!e||null==t)&&null!==p(i,t,e)}get dataType(){const{field:e}=this;return f(e)?M.Number:y(e)?M.Text:v(e)||h(e)?M.Date:M.Unsupported}get dateDataType(){if(this.dataType===M.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?V({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=w(e);if(this.isSubtypeField&&"subtypes"in e&&e.subtypes)return new u({name:U,codedValues:e.subtypes.map((({code:e,name:t})=>new s({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new u({name:U,codedValues:i.map((({code:e,name:t})=>new s({code:e,name:t})))});const{feature:l}=this,n=e?.getFieldDomain(this.name,{feature:l}),r=this.element?.domain;return null!=r&&this._isDomainCompatible(r)?r:n}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==M.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==M.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=T(e,"switch")?e.input:null;return!t||F(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return E(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?V({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=D(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=a(i,e)||c(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:s,min:u}=a(i)||{};return{max:null!=s&&(null===n||null!=n&&s<n)?s:n,min:null!=u&&(null===r||null!=r&&u>r)?u:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,isSubtypeField:n}=this;if(!e)return!1;if(!1===i?.nullable)return!0;if(n)return!0;return!(!l||!1===this.group?.visible||null==t)&&t}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!O(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return O(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?j.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.visibilityExpressionExecutor?.lastEvaluatedValue||!1===this.group?.visibilityExpressionExecutor?.lastEvaluatedValue))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===M.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(L(e))return A(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&f(t))return!0}return!!("range"===e?.type&&f(t)||v(t)||h(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:u,value:a,maxLength:o}=this,d=s&&null==a,m=void 0!==u;if(!d&&l.getAttribute(i.name)===a&&m)return null;if(d)return g.INVALID_TYPE;if("text"===e&&"string"==typeof a){if(n>-1&&a.length<n)return N.TOO_SHORT;if(o>-1&&a.length>o)return N.TOO_LONG}return"date"!==e||null==a||R({type:i.type,range:r,value:a})?t?null!==a||s?p(i,a):null:x(i,a):b.OUT_OF_RANGE}};e([n()],S.prototype,"_dateFormRange",null),e([n()],S.prototype,"_dateRange",null),e([n()],S.prototype,"_storedValue",void 0),e([n()],S.prototype,"_configAllowsEdits",null),e([n()],S.prototype,"_layerAndFieldAllowEdits",null),e([n()],S.prototype,"_isVisibleByDefault",null),e([n()],S.prototype,"_isEditTrackingField",null),e([n()],S.prototype,"_shouldUseValueExpression",null),e([n()],S.prototype,"isSubtypeField",null),e([n()],S.prototype,"valueIsOutOfDomain",null),e([n()],S.prototype,"dataType",null),e([n()],S.prototype,"dateDataType",null),e([n()],S.prototype,"description",null),e([n()],S.prototype,"domain",null),e([n()],S.prototype,"editable",null),e([n({readOnly:!0})],S.prototype,"error",void 0),e([n({constructOnly:!0})],S.prototype,"preservesValueWhenHidden",void 0),e([n()],S.prototype,"evaluatedRequiredExpression",null),e([n()],S.prototype,"evaluatedValueExpression",null),e([n()],S.prototype,"field",void 0),e([n()],S.prototype,"group",void 0),e([n({readOnly:!0})],S.prototype,"hint",null),e([n()],S.prototype,"includeDate",null),e([n()],S.prototype,"includeTime",null),e([n()],S.prototype,"includeTimeOffset",null),e([n()],S.prototype,"initialFeature",null),e([n({readOnly:!0})],S.prototype,"inputType",null),e([n()],S.prototype,"hasInvalidSwitchValue",null),e([n()],S.prototype,"isRelationshipKeyField",null),e([n()],S.prototype,"label",null),e([n()],S.prototype,"maxLength",null),e([n()],S.prototype,"minLength",null),e([n({readOnly:!0})],S.prototype,"name",null),e([n()],S.prototype,"range",null),e([n()],S.prototype,"required",null),e([n()],S.prototype,"requiredExpressionExecutor",void 0),e([n()],S.prototype,"showNoValueOptionEnabled",null),e([n()],S.prototype,"submittable",null),e([n()],S.prototype,"timeResolution",null),e([n()],S.prototype,"timeStep",null),e([n({readOnly:!0})],S.prototype,"type",void 0),e([n()],S.prototype,"updating",null),e([n()],S.prototype,"valid",null),e([n({value:null})],S.prototype,"value",null),e([n()],S.prototype,"valueExpressionExecutor",void 0),e([n()],S.prototype,"visible",null),S=e([r("esri.widgets.FeatureForm.FieldInput")],S);const k=e=>e&&!Number.isNaN(e.valueOf()),q=S;export{q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-feature-form",t=`${e}__group`,r=`${e}__input`,
|
|
5
|
+
const e="esri-feature-form",t=`${e}__group`,r=`${e}__input`,a=`${e}__related-records`,i={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,labelTextContent:`${e}__label-text-content`,fieldInput:`${r}`,inputRadio:`${r}--radio`,inputRadioGroup:`${r}--radio-group`,inputRadioLabel:`${r}--radio-label`,inputDisabled:`${r}--disabled`,inputSwitch:`${r}--switch`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordsHeader:`${a}_header`,relatedRecordsLabel:`${a}_label`,relatedRecordsList:`${a}_list`,dateInputContainer:`${`${e}__date`}-input-container`,textElement:`${e}__text-element`,group:t,groupSequential:`${t}--sequential`,groupActive:`${t}--active`};export{i as css};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{equalsShallow as n}from"../../core/lang.js";import r from"../../core/Logger.js";import{templateHasKey as o,replace as i}from"../../core/string.js";import{isFieldElement as s}from"../../form/support/formUtils.js";import{DomainValidationError as
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{equalsShallow as n}from"../../core/lang.js";import r from"../../core/Logger.js";import{templateHasKey as o,replace as i}from"../../core/string.js";import{isFieldElement as s}from"../../form/support/formUtils.js";import{DomainValidationError as l}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as u,NumericRangeValidationError as a,TypeValidationError as p}from"../../layers/support/fieldUtils.js";import{isAnyDateField as m}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as d,getIntlOptionsForField as c}from"../support/dateUtils.js";import{substitute as f}from"../../intl/substitute.js";const y=e=>"field"===e?.type,b=e=>"group"===e?.type,g=e=>"relationship"===e?.type,x=e=>"text"===e.type,T=e=>!b(e)&&null!=e.group,O=e=>e.reduce(((e,t)=>b(t)?[...e,...t.inputs]:[...e,t]),[]),j=e=>O(e).filter(y),h=e=>O(e).filter(g),v=e=>null!=e&&(E(e,"combo-box")||E(e,"radio-buttons")),E=(e,t)=>null!=e&&e.input?.type===t,V=e=>null!=e&&(E(e,"text-box")||E(e,"text-area")),N=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),F=e=>"items"in e,U={typeFieldName:null,types:[]};function L(t){const{attributes:n,fieldsIndex:r,label:i,timeZone:s}=t;if(!n||"object"!=typeof n)return i;const l=Object.keys(n).filter((e=>o(i,e))),u=l.map((e=>n[e])),a=l.map((e=>r.get(e))).filter(e);return C(i,Z({values:u,fields:a,timeZone:s}))}const _="expression/",A="expr/",I="field/";function R(e){const[t,n]=e.split(_);return""===t&&n?n:(r.getLogger("esri.widgets.FeatureForm/featureFormUtils").error("extractExpressionNameFromString:invalid-input",`The string ${e} is not a valid expression reference of the form '${_}/expressionName'`),"")}function $(e){return`${_}${e}`}function D(e){return`${I}${e}`}function w(e){return e.startsWith(_)}function S(e){return e.startsWith(A)}function Z(e){const{fields:t,values:n}=e,r=e.timeZone??void 0,o=t.map(((e,t)=>{let o=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(m(e)||u(e))&&(o=d(e,o,{timeZone:r,...c(e)})),[e.name,o]}));return Object.fromEntries(o)}function C(e,t){return i(i(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const G=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"feature"===e.type&&e.subtypes?.length?{typeFieldName:e.subtypeField,types:e.subtypes}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,M=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var H;!function(e){e.TOO_SHORT="length-validation-error::too-short",e.TOO_LONG="length-validation-error::too-long"}(H||(H={}));const P={type:"number"},W={type:"number",intlOptions:{notation:"scientific"}};function k(e){return e>=1e7||e<=-1e7}function q(e,{validationErrors:t}){return null!=e.max&&null!=e.min?t.outsideRange:null!=e.max?t.outsideRangeMax:t.outsideRangeMin}const B=(e,t,n)=>{const{dataType:r,error:o,minLength:i,value:s,required:u}=e,m=t?.validationErrors;if(!m||!o)return null;if(u&&null===s)return m.cannotBeNull;if(o===l.VALUE_OUT_OF_RANGE||o===a.OUT_OF_RANGE){const{field:o,range:i}=e,s={type:"date",intlOptions:{timeZone:"date"===o.type&&n?n:void 0,...c(o)}},l=q(i,t);return f(l,i,{format:{max:"date"===r?s:null!=i.max&&k(i.max)?W:P,min:"date"===r?s:null!=i.min&&k(i.min)?W:P}})}return o===l.INVALID_CODED_VALUE?m.invalidCodedValue:o===p.INVALID_TYPE?m.invalidType:o===H.TOO_SHORT?f(m.tooShort,{min:i}):(H.TOO_LONG,null)},Y=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":"mesh"===r||"mesh"===n||"multipatch"===n?"cube":"multipoint"===r||"multipoint"===n?"point":r||n||"table"},z=e=>{const t=[];if(e.formTemplate){const{description:n,title:r}=e.formTemplate;e.fields?.forEach((e=>{const i=r&&o(r,e.name),s=n&&o(n,e.name);(i||s)&&t.push(e.name)}))}return t};function J(e,t){const n=t??("formTemplate"in e&&e.formTemplate);if(n){return(n.elements?.filter(s)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function K(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function Q(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}function X(e,t,r){if(!e||!("subtypes"in e))return!1;const o=e.subtypes?.find((e=>e.code===r));if(!o)return!1;const i=e.subtypes?.find((e=>e.code===t));return!n(o.defaultValues,i?.defaultValues)&&Object.values(o.defaultValues).some((e=>null!=e))}export{H as LengthValidationError,M as capabilitiesAllowEditType,R as extractExpressionNameFromString,j as flattenFieldInputs,O as flattenInputs,h as flattenRelationshipInputs,J as formTemplateHasInvalidFields,Z as getComputedAttributes,B as getErrorMessageForFieldInput,z as getFieldsInTitleAndDesc,Y as getIconForFeature,G as getNormalizedFeatureTypeInfo,w as isExpressionReference,E as isFieldElementWithInputType,v as isFieldElementWithShowNoValueOptionInput,V as isFieldElementWithTextInput,y as isFieldInput,b as isGroupInput,T as isInputInGroupInput,S as isLegacyFieldMapsExpressionReference,N as isNumberFieldInput,g as isRelationshipInput,F as isTemplateItemGroup,x as isTextElementInput,L as parseFormTemplateString,$ as prependExpressionPrefix,D as prependFieldPrefix,C as substituteFieldTemplatesInString,X as subtypeChangeShouldPrompt,K as valueIsInvalidSwitchValue,Q as valueIsValidContingentValue};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{Prompt as p}from"./Editor/components/Prompt.js";import{css as u}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as m,isRelationshipInput as h,isTextElementInput as v,flattenInputs as g,isInputInGroupInput as _,isFieldElementWithInputType as b,getErrorMessageForFieldInput as C,getIconForFeature as f,isNumberFieldInput as y,subtypeChangeShouldPrompt as F}from"./FeatureForm/featureFormUtils.js";import w from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{isString as O}from"./support/dataUtils.js";import{getLabelForDateFieldValue as k,getIntlOptionsForField as I,numberingSystem as x,prepareISOFieldValueForDateComponents as M,prepareUnixFieldValueForDateComponents as D,normalizeTimeOnlyString as N,getISOFieldValueFromDateComponents as V,getUnixFieldValueFromDateComponents as T}from"./support/dateUtils.js";import{globalCss as L}from"./support/globalCss.js";import{Heading as S,incrementHeadingLevel as j}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as U}from"./support/decorators/vmEvent.js";import{tsx as P}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";const $="data-field-name";let H=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new w,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return R({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return P("div",{class:this.classes(u.base,L.widget,L.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return P("div",null,P("form",{class:u.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?P(p,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&P(S,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&P("p",{class:u.description,key:"description"},e.formDescription);return P("div",{class:u.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return c(e)?this._renderGroup(e):m(e)?this._renderLabeledField(e):h(e)?this._renderRelationshipInput(e):v(e)?this._renderTextElementInput(e):void 0}_renderDescriptionOrEmpty(e,t){return null==e?null:P("div",{class:this.classes(u.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:n,id:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),c=p?.group===e,m="sequential"===this.groupDisplay;return P("calcite-block",{class:this.classes(u.group,m?u.groupSequential:null,c?u.groupActive:null,t?u.inputDisabled:null),collapsible:!0,"data-group":e,description:n||void 0,disabled:t,heading:`${r}`,headingLevel:i?.title?j(o):o,id:a,key:a,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=g(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(c(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let n;if(_(t)&&!t.group.open){const i=t.group.inputs.filter(m);n="forward"===e?i[i.length-1]:i[0]}else n=t;o=i.indexOf(n)+1}else o=0;for(let n=o;n<i.length;n++){const e=i[n];if(e.visible&&m(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?A(this.messages.requiredFieldLabel,{name:o}):o,class:u.label,key:`${n.id}-${i.uid}-${e.name}`},r=[P("div",{class:u.labelTextContent,key:"labelTextContainer"},o,a?P("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?P("label",{...s},r):P("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?P("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return P("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,k(i,t.value,{timeZone:this.timeZone,...I(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return P("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[$],key:`${s}-date-input`,max:O(l)?l:void 0,min:O(d)?d:void 0,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return P("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[$],key:`${a}-time-input`,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:c}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:x,overlayPositioning:"fixed",readOnly:d,[$]:i,onfocus:this._onComponentFocus},h=M(p,n),v=M(c,n),g=M(s,n);return P("div",{class:u.dateInputContainer,key:`${l}-date-time-container`},P("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),P("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:g.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?P("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:p}=t,{timeZone:c}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:x,overlayPositioning:"fixed",readOnly:p,[$]:o,onfocus:this._onComponentFocus},h=D(a,c),v=D(l,c),g=D(d,c);return P("div",{class:u.dateInputContainer,key:`${r}-date-time-container`},P("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:g?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?P("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return P("calcite-input",{...i,class:this.classes(u.fieldInput,u.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{viewModel:a,_inputsWithChanges:s}=this,r="INSERT"===a.arcadeEditType,l=s.has(n),d=null==o&&(!r||l),p=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return P("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:p,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:n,messagesTemplates:a,viewModel:s,_inputsWithChanges:r}=this,[l,d,p]=t.map((e=>e.map((({name:e,value:t})=>P("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(P("calcite-combobox-item-group",{key:"other",label:a.other},d)),p.length>0&&u.push(P("calcite-combobox-item-group",{key:"unsupported",label:n.subtypes.unsupportedDomainGroupTitle},p)),u.length>0?u.unshift(P("calcite-combobox-item-group",{key:"recommended",label:n.recommended},l)):u.push(...l);const c="INSERT"===s.arcadeEditType,m=r.has(o),h=null==i&&(!c||m);return e.showNoValueOptionEnabled&&u.unshift(P("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||n.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return P("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:u.inputRadioGroup,"data-field-name":i[$],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!b(e.element,"switch")&&i===e.element.input.onValue;return P("calcite-switch",{...t,checked:o,class:u.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return P("calcite-label",{class:u.inputRadioLabel,key:e,layout:"inline"},P("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:u.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?C(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?P("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?P("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return P("calcite-list-item",{description:A(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},P("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return P("calcite-button",{alignment:"center",appearance:"outline-fill",class:u.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return P("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},P("calcite-icon",{icon:f(i),slot:"content-start"}),P("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return P("calcite-label",{class:this.classes(u.label,u.relatedRecordsLabel),key:`relationship-${i}-container`},P("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return P("div",{class:u.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},P("span",null,e.label),t?P("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return P("calcite-list",{class:u.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=A(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return P("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:u.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return P("div",{class:u.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:p,valid:c,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(u.fieldInput,v?u.inputDisabled:null,h&&!c?u.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[$]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute($))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);y(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,_(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=N(r),l=N(e.value)):l="timestamp-offset"===o?null!=e.value?V({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?T({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&F(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:n}=e,{layer:a,messages:s,viewModel:r,messagesCommon:l}=this;if(this._updateFieldValue(n,t),!a||!("subtypes"in a)||!a.subtypes?.length)return;const d=a.subtypes.find((e=>e.code===t)),p=a.subtypes.find((e=>e.code===i))?.name??`${i}`;if(!d)return;r.hasPendingSubtypeChoice=!0;const u=o();let c="update-fields";const m=[{label:s.subtypes.useDefaultValuesOption,value:"update-fields"},{label:s.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:s.subtypes.changeWarningTitle,message:A(s.subtypes.changeWarning,{originalType:p,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>c=e,actions:{primary:{label:l.apply,action:()=>u.resolve(c),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":r.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{r.hasPendingSubtypeChoice=!1,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&_(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return b(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges}}};e([s()],H.prototype,"_listObserverNode",void 0),e([s()],H.prototype,"_relatedRecordsEnabled",null),e([s()],H.prototype,"_prompt",void 0),e([s()],H.prototype,"disabled",null),e([s()],H.prototype,"feature",null),e([s()],H.prototype,"formTemplate",null),e([s()],H.prototype,"groupDisplay",void 0),e([s()],H.prototype,"headingLevel",void 0),e([s()],H.prototype,"icon",null),e([s()],H.prototype,"label",null),e([s()],H.prototype,"layer",null),e([s()],H.prototype,"map",null),e([s(),E("esri/widgets/FeatureForm/t9n/FeatureForm")],H.prototype,"messages",void 0),e([s(),E("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([s(),E("esri/widgets/Feature/t9n/Feature")],H.prototype,"messagesFeature",void 0),e([s(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],H.prototype,"messagesTemplates",void 0),e([s()],H.prototype,"relatedRecordCallbacks",null),e([s()],H.prototype,"relationshipId",null),e([s()],H.prototype,"spatialReference",null),e([s()],H.prototype,"strict",null),e([s()],H.prototype,"timeZone",null),e([s()],H.prototype,"showPrompt",null),e([s()],H.prototype,"clearPrompt",null),e([s(),U(["value-change","submit"])],H.prototype,"viewModel",void 0),e([s()],H.prototype,"test",null),H=e([r("esri.widgets.FeatureForm")],H);const Z=H;export{Z as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as n,whenOnce as s}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{Prompt as p}from"./Editor/components/Prompt.js";import{css as u}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as m,isRelationshipInput as h,isTextElementInput as v,flattenInputs as g,isInputInGroupInput as _,isFieldElementWithInputType as b,getErrorMessageForFieldInput as C,getIconForFeature as f,isNumberFieldInput as y,subtypeChangeShouldPrompt as F}from"./FeatureForm/featureFormUtils.js";import w from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{isString as O}from"./support/dataUtils.js";import{getLabelForDateFieldValue as k,getIntlOptionsForField as I,numberingSystem as x,prepareISOFieldValueForDateComponents as M,prepareUnixFieldValueForDateComponents as D,normalizeTimeOnlyString as N,getISOFieldValueFromDateComponents as V,getUnixFieldValueFromDateComponents as T}from"./support/dateUtils.js";import{globalCss as L}from"./support/globalCss.js";import{Heading as S,incrementHeadingLevel as j}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as U}from"./support/decorators/vmEvent.js";import{tsx as P}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";const $="data-field-name";let H=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new w,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),s((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return R({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return P("div",{class:this.classes(u.base,L.widget,L.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return P("div",null,P("form",{class:u.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?P(p,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&P(S,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&P("p",{class:u.description,key:"description"},e.formDescription);return P("div",{class:u.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return c(e)?this._renderGroup(e):m(e)?this._renderLabeledField(e):h(e)?this._renderRelationshipInput(e):v(e)?this._renderTextElementInput(e):void 0}_renderDescriptionOrEmpty(e,t){return null==e?null:P("div",{class:this.classes(u.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:n,id:s,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),c=p?.group===e,m="sequential"===this.groupDisplay;return P("calcite-block",{class:this.classes(u.group,m?u.groupSequential:null,c?u.groupActive:null,t?u.inputDisabled:null),collapsible:!0,"data-group":e,description:n||void 0,disabled:t,heading:`${r}`,headingLevel:i?.title?j(o):o,id:s,key:s,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=g(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(c(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let n;if(_(t)&&!t.group.open){const i=t.group.inputs.filter(m);n="forward"===e?i[i.length-1]:i[0]}else n=t;o=i.indexOf(n)+1}else o=0;for(let n=o;n<i.length;n++){const e=i[n];if(e.visible&&m(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:s}=e,a={"aria-label":s?A(this.messages.requiredFieldLabel,{name:o}):o,class:u.label,key:`${n.id}-${i.uid}-${e.name}`},r=[P("div",{class:u.labelTextContent,key:"labelTextContainer"},o,s?P("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?P("label",{...a},r):P("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,s=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),s):this._renderComboBoxComponent(e,t,s):this._renderSwitchComponent(e,s)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,s):"number"===t?this._renderNumberComponent(e,s):this._renderStringComponent(e,s)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?P("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):P("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return P("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,k(i,t.value,{timeZone:this.timeZone,...I(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:s,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return P("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:s,"data-date-part":"date","data-field-name":t[$],key:`${a}-date-input`,max:O(l)?l:void 0,min:O(d)?d:void 0,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:s,readOnly:a}=t;return P("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[$],key:`${s}-time-input`,numberingSystem:x,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:s,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:c}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:x,overlayPositioning:"fixed",readOnly:d,[$]:i,onfocus:this._onComponentFocus},h=M(p,n),v=M(c,n),g=M(a,n);return P("div",{class:u.dateInputContainer,key:`${l}-date-time-container`},P("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),P("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:g.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?P("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:g.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:s}=e,{class:a,key:r,max:l,min:d,readOnly:p}=t,{timeZone:c}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:x,overlayPositioning:"fixed",readOnly:p,[$]:o,onfocus:this._onComponentFocus},h=D(s,c),v=D(l,c),g=D(d,c);return P("div",{class:u.dateInputContainer,key:`${r}-date-time-container`},P("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:g?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?P("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return P("calcite-input",{...i,class:this.classes(u.fieldInput,u.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{viewModel:s,_inputsWithChanges:a}=this,r="INSERT"===s.arcadeEditType,l=a.has(n),d=null==o&&(!r||l),p=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return P("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:p,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:n,messagesTemplates:s,viewModel:a,_inputsWithChanges:r}=this,[l,d,p]=t.map((e=>e.map((({name:e,value:t})=>P("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(P("calcite-combobox-item-group",{key:"other",label:s.other},d)),p.length>0&&u.push(P("calcite-combobox-item-group",{key:"unsupported",label:n.subtypes.unsupportedDomainGroupTitle},p)),u.length>0?u.unshift(P("calcite-combobox-item-group",{key:"recommended",label:n.recommended},l)):u.push(...l);const c="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!c||m);return e.showNoValueOptionEnabled&&u.unshift(P("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||n.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,s=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;s.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return P("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:u.inputRadioGroup,"data-field-name":i[$],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},s)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!b(e.element,"switch")&&i===e.element.input.onValue;return P("calcite-switch",{...t,checked:o,class:u.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:s}){return P("calcite-label",{class:u.inputRadioLabel,key:e,layout:"inline"},P("calcite-radio-button",{...s,afterCreate:void 0,afterUpdate:void 0,checked:o,class:u.inputRadio,disabled:s.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?C(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?P("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?P("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const s=this.messages;return P("calcite-list-item",{description:A(s.totalCount,{count:t}),label:s.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},P("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:s}=this;if(t&&s?.addRelatedRecord&&o)return P("calcite-button",{alignment:"center",appearance:"outline-fill",class:u.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:s,relatedRecordCallbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&s&&a.editRelatedRecord({parentFeature:s,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return P("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},P("calcite-icon",{icon:f(i),slot:"content-start"}),P("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),s=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return P("calcite-label",{class:this.classes(u.label,u.relatedRecordsLabel),key:`relationship-${i}-container`},P("div",null,this._renderRelatedRecordsHeaderContainer(e),n,s),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return P("div",{class:u.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},P("span",null,e.label),t?P("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return P("calcite-list",{class:u.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),s=e.layer?.fieldsIndex.get(o),a=n?.label||s?.alias||o,r=A(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return P("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},P("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return P("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:u.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return P("div",{class:u.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:s,minLength:a,name:r,range:{max:l,min:d},required:p,valid:c,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(u.fieldInput,v?u.inputDisabled:null),status:h&&!c?"invalid":"idle",key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:s>-1?s:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[$]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute($))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);y(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,_(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:s}=i,a=this._dateComponentMap.get(n);if(!a)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=N(r),l=N(e.value)):l="timestamp-offset"===o?null!=e.value?V({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?T({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:s.max,min:s.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&F(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:n}=e,{layer:s,messages:a,viewModel:r,messagesCommon:l}=this;if(this._updateFieldValue(n,t),!s||!("subtypes"in s)||!s.subtypes?.length)return;const d=s.subtypes.find((e=>e.code===t)),p=s.subtypes.find((e=>e.code===i))?.name??`${i}`;if(!d)return;r.hasPendingSubtypeChoice=!0;const u=o();let c="update-fields";const m=[{label:a.subtypes.useDefaultValuesOption,value:"update-fields"},{label:a.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:a.subtypes.changeWarningTitle,message:A(a.subtypes.changeWarning,{originalType:p,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>c=e,actions:{primary:{label:l.apply,action:()=>u.resolve(c),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":r.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{r.hasPendingSubtypeChoice=!1,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&_(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return b(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges}}};e([a()],H.prototype,"_listObserverNode",void 0),e([a()],H.prototype,"_relatedRecordsEnabled",null),e([a()],H.prototype,"_prompt",void 0),e([a()],H.prototype,"disabled",null),e([a()],H.prototype,"feature",null),e([a()],H.prototype,"formTemplate",null),e([a()],H.prototype,"groupDisplay",void 0),e([a()],H.prototype,"headingLevel",void 0),e([a()],H.prototype,"icon",null),e([a()],H.prototype,"label",null),e([a()],H.prototype,"layer",null),e([a()],H.prototype,"map",null),e([a(),E("esri/widgets/FeatureForm/t9n/FeatureForm")],H.prototype,"messages",void 0),e([a(),E("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([a(),E("esri/widgets/Feature/t9n/Feature")],H.prototype,"messagesFeature",void 0),e([a(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],H.prototype,"messagesTemplates",void 0),e([a()],H.prototype,"relatedRecordCallbacks",null),e([a()],H.prototype,"relationshipId",null),e([a()],H.prototype,"spatialReference",null),e([a()],H.prototype,"strict",null),e([a()],H.prototype,"timeZone",null),e([a()],H.prototype,"showPrompt",null),e([a()],H.prototype,"clearPrompt",null),e([a(),U(["value-change","submit"])],H.prototype,"viewModel",void 0),e([a()],H.prototype,"test",null),H=e([r("esri.widgets.FeatureForm")],H);const Z=H;export{Z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o="sublayer"===i.type&&s?.feature?s.feature:e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o=s?.feature??e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:n}=e,{formatFunction:o}=this,i=r.sanitize(n);if(o&&t){const{index:e,item:{feature:n}}=t;return o({column:this,feature:n,index:e,value:i})}return i},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,n=this.createHeaderContent();this.removeCellContent(t),t.appendChild(n)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:n})=>{const o=this.getCellValue(t,n),i=this.cellValueFormatFunction({column:t,rowData:n,value:o});let r=null;r=i instanceof HTMLElement?i:s(this.messagesURIUtils,i),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([n((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),n((()=>this.hidden),(()=>this.closeMenu())),n((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)})),n((()=>this.effectiveLabel),(e=>{const{sortElement:t}=this;t&&t.textContent!==e&&(t.setAttribute("title",e),t.textContent=e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:n,iconClass:o,label:i,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:o,iconStart:n,selected:s,textContent:i,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],n=this.visibleElements?.columnMenuItems;if(!1!==n?.sortAscending){const n=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(n)}if(!1!==n?.sortDescending){const n=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(n)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:n}=this,o=!!n?.open,i=this.createCalciteAction({icon:n?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=4,s.placement="top-end",s.appendChild(i),s.overlayPositioning="fixed",o&&(s.open=o,this._menuIsOpen=!0),s.addEventListener("calciteDropdownOpen",(()=>this._menuIsOpen=!0)),s.addEventListener("calciteDropdownClose",(()=>this._menuIsOpen=!1)),s.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=n?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e,t){return e.path&&t?.item?t.item[e.path]:""}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:n,initialSortPriority:o}=this,i=document.createElement("vaadin-grid-sorter");return i.classList.add(c.sorter),i.setAttribute("path",n),i.setAttribute("title",e),i.textContent=e,t&&i.setAttribute("direction",t),null!=o&&(i._initialOrder=o),i.addEventListener("direction-changed",(()=>{this.direction!==i.direction&&this._set("direction",i.direction)})),i}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:n,disabled:o,icon:i,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=n??"",t.disabled=!!o,t.icon=i??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:n,className:o,disabled:i,iconEnd:s,iconFlipRtl:r,loading:l,onclick:c,scale:a,textContent:d}=e;return t.className=o??"",t.scale=a??"s",t.appearance=n??"transparent",t.disabled=!!i,t.iconEnd=s??"",r&&(t.iconFlipRtl=r),t.loading=!!l,t.textContent=t.title=d??"",t.onclick=c??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:n,hidden:o,iconClass:i,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(i&&!s){const e=document.createElement("span"),n=document.createElement("span");n.classList.add(c.headerMenuIcon,i),e.textContent=e.title=d,e.insertBefore(n,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!n,t.hidden="function"==typeof o?o():!!o,t.selected=!!a,t.onclick=l??null,t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:n,scale:o,textLabel:i}=e,s=document.createElement("calcite-icon"),r=i??t;return s.icon=n,s.scale=o??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,n=document.createElement("div");if(n.classList.add(c.headerContent),t&&n.appendChild(t),this.sortable)n.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const o=t.appendChild(document.createElement("span"));o.textContent=e,o.setAttribute("title",e),n.appendChild(t)}return this.menuIsVisible&&n.appendChild(this.menu),n}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}};e([o()],a.prototype,"_menuIsOpen",void 0),e([o()],a.prototype,"autoWidth",void 0),e([o()],a.prototype,"cellValueFormatFunction",void 0),e([o()],a.prototype,"customMenuItems",null),e([o()],a.prototype,"defaultMenuItems",null),e([o()],a.prototype,"direction",void 0),e([o()],a.prototype,"effectiveLabel",null),e([o({constructOnly:!0})],a.prototype,"fieldName",void 0),e([o()],a.prototype,"flexGrow",void 0),e([o()],a.prototype,"footerRenderFunction",void 0),e([o()],a.prototype,"formatFunction",void 0),e([o()],a.prototype,"frozen",void 0),e([o()],a.prototype,"frozenToEnd",void 0),e([o()],a.prototype,"grid",void 0),e([o()],a.prototype,"iconNode",null),e([o()],a.prototype,"invalid",null),e([o()],a.prototype,"headerRenderFunction",void 0),e([o()],a.prototype,"hidden",void 0),e([o()],a.prototype,"icon",void 0),e([o({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([o()],a.prototype,"label",void 0),e([o()],a.prototype,"menu",null),e([o()],a.prototype,"menuItems",null),e([o()],a.prototype,"menuConfig",void 0),e([o()],a.prototype,"menuIsOpen",null),e([o()],a.prototype,"menuIsVisible",null),e([o()],a.prototype,"messages",void 0),e([o()],a.prototype,"messagesCommon",void 0),e([o()],a.prototype,"messagesURIUtils",void 0),e([o()],a.prototype,"renderFunction",void 0),e([o()],a.prototype,"resizable",void 0),e([o()],a.prototype,"sortable",void 0),e([o({readOnly:!0})],a.prototype,"sortElement",void 0),e([o()],a.prototype,"store",void 0),e([o()],a.prototype,"textAlign",void 0),e([o()],a.prototype,"textWrap",void 0),e([o()],a.prototype,"timeZone",void 0),e([o()],a.prototype,"timeZoneName",void 0),e([o()],a.prototype,"visibleElements",void 0),e([o()],a.prototype,"width",void 0),a=e([i("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:n}=e,{formatFunction:o}=this,i=r.sanitize(n);if(o&&t){const{index:e,item:{feature:n}}=t;return o({column:this,feature:n,index:e,value:i})}return i},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,n=this.createHeaderContent();this.removeCellContent(t),t.appendChild(n)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:n})=>{const o=this.getCellValue(t,n),i=this.cellValueFormatFunction({column:t,rowData:n,value:o});let r=null;r=i instanceof HTMLElement?i:s(this.messagesURIUtils,i),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([n((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),n((()=>this.hidden),(()=>this.closeMenu())),n((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)})),n((()=>this.effectiveLabel),(e=>{const{sortElement:t}=this;t&&t.textContent!==e&&(t.setAttribute("title",e),t.textContent=e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:n,iconClass:o,label:i,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:o,iconStart:n,selected:s,textContent:i,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],n=this.visibleElements?.columnMenuItems;if(!1!==n?.sortAscending){const n=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(n)}if(!1!==n?.sortDescending){const n=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(n)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:n}=this,o=!!n?.open,i=this.createCalciteAction({icon:n?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=n?.maxItems??4,s.placement="top-end",s.appendChild(i),s.overlayPositioning="fixed",s.scale=n?.scale??"m",o&&(s.open=o,this._menuIsOpen=!0),s.addEventListener("calciteDropdownOpen",(()=>this._menuIsOpen=!0)),s.addEventListener("calciteDropdownClose",(()=>this._menuIsOpen=!1)),s.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=n?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e,t){return e.path&&t?.item?t.item[e.path]:""}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:n,initialSortPriority:o}=this,i=document.createElement("vaadin-grid-sorter");return i.classList.add(c.sorter),i.setAttribute("path",n),i.setAttribute("title",e),i.textContent=e,t&&i.setAttribute("direction",t),null!=o&&(i._initialOrder=o),i.addEventListener("direction-changed",(()=>{this.direction!==i.direction&&this._set("direction",i.direction)})),i}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:n,disabled:o,icon:i,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=n??"",t.disabled=!!o,t.icon=i??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:n,className:o,disabled:i,iconEnd:s,iconFlipRtl:r,loading:l,onclick:c,scale:a,textContent:d}=e;return t.className=o??"",t.scale=a??"s",t.appearance=n??"transparent",t.disabled=!!i,t.iconEnd=s??"",r&&(t.iconFlipRtl=r),t.loading=!!l,t.textContent=t.title=d??"",t.onclick=c??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:n,hidden:o,iconClass:i,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(i&&!s){const e=document.createElement("span"),n=document.createElement("span");n.classList.add(c.headerMenuIcon,i),e.textContent=e.title=d,e.insertBefore(n,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!n,t.hidden="function"==typeof o?o():!!o,t.selected=!!a,t.onclick=l??null,t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:n,scale:o,textLabel:i}=e,s=document.createElement("calcite-icon"),r=i??t;return s.icon=n,s.scale=o??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,n=document.createElement("div");if(n.classList.add(c.headerContent),t&&n.appendChild(t),this.sortable)n.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const o=t.appendChild(document.createElement("span"));o.textContent=e,o.setAttribute("title",e),n.appendChild(t)}return this.menuIsVisible&&n.appendChild(this.menu),n}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}};e([o()],a.prototype,"_menuIsOpen",void 0),e([o()],a.prototype,"autoWidth",void 0),e([o()],a.prototype,"cellValueFormatFunction",void 0),e([o()],a.prototype,"customMenuItems",null),e([o()],a.prototype,"defaultMenuItems",null),e([o()],a.prototype,"direction",void 0),e([o()],a.prototype,"effectiveLabel",null),e([o({constructOnly:!0})],a.prototype,"fieldName",void 0),e([o()],a.prototype,"flexGrow",void 0),e([o()],a.prototype,"footerRenderFunction",void 0),e([o()],a.prototype,"formatFunction",void 0),e([o()],a.prototype,"frozen",void 0),e([o()],a.prototype,"frozenToEnd",void 0),e([o()],a.prototype,"grid",void 0),e([o()],a.prototype,"iconNode",null),e([o()],a.prototype,"invalid",null),e([o()],a.prototype,"headerRenderFunction",void 0),e([o()],a.prototype,"hidden",void 0),e([o()],a.prototype,"icon",void 0),e([o({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([o()],a.prototype,"label",void 0),e([o()],a.prototype,"menu",null),e([o()],a.prototype,"menuItems",null),e([o()],a.prototype,"menuConfig",void 0),e([o()],a.prototype,"menuIsOpen",null),e([o()],a.prototype,"menuIsVisible",null),e([o()],a.prototype,"messages",void 0),e([o()],a.prototype,"messagesCommon",void 0),e([o()],a.prototype,"messagesURIUtils",void 0),e([o()],a.prototype,"renderFunction",void 0),e([o()],a.prototype,"resizable",void 0),e([o()],a.prototype,"sortable",void 0),e([o({readOnly:!0})],a.prototype,"sortElement",void 0),e([o()],a.prototype,"store",void 0),e([o()],a.prototype,"textAlign",void 0),e([o()],a.prototype,"textWrap",void 0),e([o()],a.prototype,"timeZone",void 0),e([o()],a.prototype,"timeZoneName",void 0),e([o()],a.prototype,"visibleElements",void 0),e([o()],a.prototype,"width",void 0),a=e([i("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d as default};
|