@arcgis/core 4.28.5 → 4.28.7
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/README.md +15 -25
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0c08d59c5d65921ba5ae.js +1 -0
- package/assets/esri/core/workers/chunks/0dbf3fa096d02d83b222.js +1 -0
- package/assets/esri/core/workers/chunks/16453ca31cc3e09fde46.js +1 -0
- package/assets/esri/core/workers/chunks/{1da721608993783dc9cf.js → 24d04cca452ba2fec5d4.js} +1 -1
- package/assets/esri/core/workers/chunks/2c121541cde5c24b1fbe.js +1 -0
- package/assets/esri/core/workers/chunks/2efd2496f7310142f928.js +1 -0
- package/assets/esri/core/workers/chunks/42880f0fac5f1606201c.js +1 -0
- package/assets/esri/core/workers/chunks/5b17de91091fc17d9821.js +1 -0
- package/assets/esri/core/workers/chunks/70eba80261d7fdc624ad.js +1 -0
- package/assets/esri/core/workers/chunks/{3dcb2a82e1e4b520c9c9.js → 7b901d0b68e5cc17533a.js} +1 -1
- package/assets/esri/core/workers/chunks/7f68c2cc1048d136fd1b.js +1 -0
- package/assets/esri/core/workers/chunks/85d6dd6703b228248e30.js +1 -0
- package/assets/esri/core/workers/chunks/adc138e5d9983a5752d4.js +1 -0
- package/assets/esri/core/workers/chunks/b35e87cf2b8244e3584f.js +1 -0
- package/assets/esri/core/workers/chunks/b49f830a8d74c4564ed8.js +1 -0
- package/assets/esri/core/workers/chunks/b6d77edf9eec757e88da.js +1 -0
- package/assets/esri/core/workers/chunks/c9306fb3ec1a2d5e137a.js +1 -0
- package/assets/esri/core/workers/chunks/cd201c627e9396edf6b9.js +1 -0
- package/assets/esri/core/workers/chunks/ceeaa8d1b0034b59eae7.js +1 -0
- package/assets/esri/core/workers/chunks/dc4a71e72e56cbdff49a.js +1 -0
- package/assets/esri/core/workers/chunks/f78b1bfacd95a6ccf7b4.js +1 -0
- package/assets/esri/themes/base/widgets/_LabeledSwitch.scss +6 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/sql/sqlCompareUtils.js +1 -1
- package/core/sql/sqlDateParsingUtils.js +1 -1
- package/kernel.js +1 -1
- package/layers/support/FieldsIndex.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/LabeledSwitch.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/16b56e541afa438dfb7f.js +0 -1
- package/assets/esri/core/workers/chunks/340ab726ba40fe3a99c8.js +0 -1
- package/assets/esri/core/workers/chunks/46b4a17ec898ab744861.js +0 -1
- package/assets/esri/core/workers/chunks/4747741429e8ff7112bb.js +0 -1
- package/assets/esri/core/workers/chunks/4f0412b52844aa9c7bd4.js +0 -1
- package/assets/esri/core/workers/chunks/5b80ae1eb79f1db75dc6.js +0 -1
- package/assets/esri/core/workers/chunks/80fcb63476829b6a48d2.js +0 -1
- package/assets/esri/core/workers/chunks/84725021c43f1122056a.js +0 -1
- package/assets/esri/core/workers/chunks/8cdece03397d01767593.js +0 -1
- package/assets/esri/core/workers/chunks/9607460895182d31aef9.js +0 -1
- package/assets/esri/core/workers/chunks/a0a86383e69932a25e50.js +0 -1
- package/assets/esri/core/workers/chunks/a3bf50d9e24ad1de9847.js +0 -1
- package/assets/esri/core/workers/chunks/a5db3be5eeb3005df3c1.js +0 -1
- package/assets/esri/core/workers/chunks/a87ab14d6a6ccc9004a0.js +0 -1
- package/assets/esri/core/workers/chunks/a8cf23c3a55c1834178c.js +0 -1
- package/assets/esri/core/workers/chunks/ba00df2e707550939a6f.js +0 -1
- package/assets/esri/core/workers/chunks/cfa6d1b63b794febe70a.js +0 -1
- package/assets/esri/core/workers/chunks/e0382138cf58191a9697.js +0 -1
- package/assets/esri/core/workers/chunks/fe0c6814ef56604540b3.js +0 -1
package/core/sql/WhereClause.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as l}from"./sqlCompareUtils.js";import{isDate as o,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w}from"luxon";const J=new Set(["current_timestamp","current_date","current_time"]);class A{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return L(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return x(e)}static applyIn(e,t){return k(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return l(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=")&&l(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<")||l(e,t[1],">")}static ternaryNot(e){return F(e)}static ternaryAnd(e,t){return b(e,t)}static ternaryOr(e,t){return D(e,t)}}class I{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return o(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return o(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(o(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new I(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=C){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=C){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=C){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=C){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=C){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||J.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(A)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(l(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],o(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return F(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return b(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=x(this._evaluateNode(u.right,c,h,p));return k(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=x(this._evaluateNode(u.right,c,h,p));return F(k(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=",this.timeZone)&&l(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<",this.timeZone)||l(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return F(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return l(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return u.parsedValue??=v(u.value,"unknown"),u.parsedValue;case"timestamp":return u.parsedValue??=f(u.value,"unknown"),u.parsedValue;case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return L(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function x(e){return Array.isArray(e)?e:[e]}function F(e){return null!==e?!0!==e:null}function b(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function D(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function k(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const E="-[]/{}()*+?.\\^$|";var Z;function V(e,t){const a=t;let r="",s=Z.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case Z.Normal:t===a?s=Z.Escaped:E.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case Z.Escaped:E.includes(t)?r+="\\"+t:r+=t,s=Z.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return V(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function L(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a.getTimeZone(n.name)??"UTC")}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(Z||(Z={}));const C={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{I as WhereClause,C as defaultAttributeAdapter};
|
|
5
|
+
import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as l}from"./sqlCompareUtils.js";import{isDate as o,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w,FixedOffsetZone as J}from"luxon";const A=new Set(["current_timestamp","current_date","current_time"]);class I{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return C(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return F(e)}static applyIn(e,t){return E(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return l(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=")&&l(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<")||l(e,t[1],">")}static ternaryNot(e){return b(e)}static ternaryAnd(e,t){return D(e,t)}static ternaryOr(e,t){return k(e,t)}}class x{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return o(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return o(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(o(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new x(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=U){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=U){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=U){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=U){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=U){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||A.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(I)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(l(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],o(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return b(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return k(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=F(this._evaluateNode(u.right,c,h,p));return E(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=F(this._evaluateNode(u.right,c,h,p));return b(E(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=",this.timeZone)&&l(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<",this.timeZone)||l(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return b(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return l(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return u.parsedValue??=v(u.value,"unknown"),u.parsedValue;case"timestamp":return u.parsedValue??=f(u.value,"unknown"),u.parsedValue;case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return C(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function F(e){return Array.isArray(e)?e:[e]}function b(e){return null!==e?!0!==e:null}function D(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function k(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function E(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const Z="-[]/{}()*+?.\\^$|";var V;function L(e,t){const a=t;let r="",s=V.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case V.Normal:t===a?s=V.Escaped:Z.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case V.Escaped:Z.includes(t)?r+="\\"+t:r+=t,s=V.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return L(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function C(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a?.getLuxonTimeZone(n.name)??J.utcInstance)}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(V||(V={}));const U={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{x as WhereClause,U as defaultAttributeAdapter};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{SqlError as r,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{isDateTime as t,isTimestampOffset as n,isDateOnly as
|
|
5
|
+
import{SqlError as r,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{isDateTime as t,isTimestampOffset as n,isDateOnly as i,isTimeOnly as o,isNumber as a,isString as s}from"./sqlDateParsingUtils.js";import{SqlTimeStampOffset as u}from"./SqlTimestampOffset.js";import{isUnknownTimeZone as f}from"./UnknownTimeZone.js";import{DateTime as c}from"luxon";const l=321408e5,w=26784e5,p=864e5,d=36e5,m=6e4;function h(r){return!!t(r)||!!n(r)}function O(r){return!!t(r)||(!!i(r)||(!!n(r)||!!o(r)))}function v(o){if(t(o))return o.toMillis();if(i(o))return o.toNumber();if(n(o))return o.toMilliseconds();throw new r(e.InvalidDataType)}function I(l,w,p,d){if(null==l||null==w)return null;if(a(l)){if(a(w))return D(l,w,p);if(s(w))return T(l,w,p);if(O(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator)}else if(s(l)){if(a(w))return M(l,w,p);if(s(w))return z(l,w,p);if(t(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator);if(o(w))throw new r(e.InvalidOperator);if(n(w))throw new r(e.InvalidOperator)}else if(t(l)){if(h(w)){if(l instanceof c&&f(l.zone)){if(w instanceof c&&!1===f(w.zone))return j(l,w,p);if(w instanceof u)return j(l,w,p)}else if(w instanceof c&&f(w.zone)){if(l instanceof c&&!1===f(l.zone))return j(l,w,p);if(l instanceof u)return j(l,w,p)}return D(v(l),v(w),p)}if(s(w))throw new r(e.InvalidOperator);if(i(w))return N(l,w,p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}else if(i(l)){if(n(w))return b(l,w,p);if(t(w))return x(l,w,p);if(s(w))throw new r(e.InvalidOperator);if(i(w))return D(l.toNumber(),w.toNumber(),p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}else if(o(l)){if(o(w))return D(l.toNumber(),w.toNumber(),p);if(s(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator);if(h(w))throw new r(e.InvalidOperator)}else if(n(l)){if(h(w))return w instanceof c&&f(w.zone)?j(l,w,p):D(v(l),v(w),p);if(s(w))throw new r(e.InvalidOperator);if(i(w))return y(l,w,p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}switch(p){case"<>":return l!==w;case"=":return l===w;case">":return l>w;case"<":return l<w;case">=":return l>=w;case"<=":return l<=w}}function D(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function T(r,e,t){const n=parseFloat(e);if(!isNaN(n))return D(r,n,t);const i=r.toString();switch(t){case"<>":return i!==e;case"=":return i===e;case">":return i>e;case"<":return i<e;case">=":return i>=e;case"<=":return i<=e}}function M(r,e,t){const n=parseFloat(r);if(!isNaN(n))return D(n,e,t);const i=e.toString();switch(t){case"<>":return r!==i;case"=":return r===i;case">":return r>i;case"<":return r<i;case">=":return r>=i;case"<=":return r<=i}}function z(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function N(r,e,t){const n=e.toDateTimeLuxon(r.zone);return D((r=r.startOf("day")).toMillis(),n.toMillis(),t)}function y(r,e,t){const n=e.toDateTimeLuxon(r.toDateTime().zone);return D((r=r.startOfDay()).toMilliseconds(),n.toMillis(),t)}function x(r,e,t){const n=r.toDateTimeLuxon(e.zone);return e=e.startOf("day"),D(n.toMillis(),e.toMillis(),t)}function b(r,e,t){const n=r.toDateTimeLuxon(e.toDateTime().zone);return e=e.startOfDay(),D(n.toMillis(),e.toMilliseconds(),t)}function j(r,e,t){r instanceof u&&(r=r.toDateTime()),e instanceof u&&(e=e.toDateTime());const n=L(r),i=L(e);switch(t){case"<>":return n!==i;case"=":return n===i;case">":return n>i;case"<":return n<i;case">=":return n>=i;case"<=":return n<=i}}function L(r){return r.year*l+r.month*w+r.day*p+r.hour*d+r.minute*m+1e3*r.second+r.millisecond}export{v as dateValueInMilliseconds,O as isDateOrTimeValue,h as isDateTimeComparableValue,I as sqlCompare};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{SqlError as n,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{DateOnly as t}from"./DateOnly.js";import{SqlInterval as r}from"./SqlInterval.js";import{SqlTimeStampOffset as a}from"./SqlTimestampOffset.js";import{TimeOnly as
|
|
5
|
+
import{SqlError as n,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{DateOnly as t}from"./DateOnly.js";import{SqlInterval as r}from"./SqlInterval.js";import{SqlTimeStampOffset as a}from"./SqlTimestampOffset.js";import{TimeOnly as o}from"./TimeOnly.js";import{UnknownTimeZone as s,substituteUnknownTimezone as i}from"./UnknownTimeZone.js";import{Zone as f,DateTime as p}from"luxon";const l=/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/,d=/^(\d{1,2}):(\d{1,2})$/,c=/^(\d{1,2}):(\d{1,2}):(\d{1,2}).([0-9]+)$/,u=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,m=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$/,I=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,w=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,h=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/;function T(n,e){if(e instanceof f)return e===s.instance?p.fromMillis(n.getTime(),{zone:s.instance}):p.fromJSDate(n,{zone:e});switch(e){case"system":case"local":case null:return p.fromJSDate(n);default:return"unknown"===e?.toLowerCase()?p.fromMillis(n.getTime(),{zone:s.instance}):p.fromJSDate(n,{zone:e})}}function v(n){return"number"==typeof n}function y(n){return"string"==typeof n||n instanceof String}function S(n){return n instanceof r}function x(n){return n instanceof Date}function j(n){return n instanceof p}function $(n){return n instanceof t}function z(n){return n instanceof o}function D(n){return n instanceof a}function O(t){let r=l.exec(t);if(null!==r){const[,t,a,s]=r,i=o.fromParts(parseInt(t,10),parseInt(a,10),parseInt(s,10),0);if(null!==i)return i;throw new n(e.InvalidTime)}if(r=d.exec(t),null!==r){const[,t,a]=r,s=o.fromParts(parseInt(t,10),parseInt(a,10),0,0);if(null!==s)return s;throw new n(e.InvalidTime)}if(r=c.exec(t),null!==r){const[,t,a,s,i]=r,f=o.fromParts(parseInt(t,10),parseInt(a,10),parseInt(s,10),parseInt(i,10));if(null!==f)return f;throw new n(e.InvalidTime)}throw new n(e.InvalidTime)}function P(t,r,o=!1){let s=m.exec(t);if(null!==s){const[,t,a,o,f,l,d,c]=s,u=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:parseInt(f,10),minute:parseInt(l,10),second:parseInt(d,10),millisecond:c?parseInt(c.replace(".",""),10):0},{zone:i(r)});if(!1===u.isValid)throw new n(e.InvalidTimeStamp);return u}if(s=I.exec(t),null!==s){const[,t,r,o,i,f,p,l,d,c,u]=s,m=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(o,10),parseInt(i,10),parseInt(f,10),parseInt(p,10),l?parseInt(l.replace(".",""),10):0,"-"===d,parseInt(c,10),parseInt(u,10));if(!1===m.isValid)throw new n(e.InvalidTimeStamp);return m}if(s=w.exec(t),null!==s){const[,t,r,o,i,f,p,l,d]=s,c=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(o,10),parseInt(i,10),parseInt(f,10),0,0,"-"===p,parseInt(l,10),parseInt(d,10));if(!1===c.isValid)throw new n(e.InvalidTimeStamp);return c}if(s=h.exec(t),null!==s){const[,t,a,o,f,l]=s,d=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:parseInt(f,10),minute:parseInt(l,10),second:0},{zone:i(r)});if(!1===d.isValid)throw new n(e.InvalidTimeStamp);return d}if(s=u.exec(t),null!==s){const[,t,a,o]=s,f=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:0,minute:0,second:0},{zone:i(r)});if(!1===f.isValid)throw new n(e.InvalidTimeStamp);return f}throw new n(e.InvalidTimeStamp)}function V(r,a){const o=u.exec(r);if(null===o)try{return P(r,a)}catch{throw new n(e.InvalidDate)}const[,s,i,f]=o,p=t.fromParts(parseInt(s,10),parseInt(i,10),parseInt(f,10));if(null===p)throw new n(e.InvalidDate);return p}export{T as convertToExecutingTimeZone,x as isDate,$ as isDateOnly,j as isDateTime,v as isNumber,S as isSqlInterval,y as isString,z as isTimeOnly,D as isTimestampOffset,V as parseDate,O as parseTime,P as parseTimestamp};
|
package/kernel.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.7";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{isSerializable as i}from"../../core/JSONSupport.js";import t from"../../core/Logger.js";import{isDateField as
|
|
5
|
+
import e from"../../core/Error.js";import{isSerializable as i}from"../../core/JSONSupport.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{UnknownTimeZone as n}from"../../core/sql/UnknownTimeZone.js";import{isDateField as r,isNumericField as l,isObjectIDField as o,isGlobalIDField as d,getFieldDefaultValue as a,isTimeOnlyField as m,normalizeFieldName as u}from"./fieldUtils.js";import{utc as f,unknown as F,fromTimeReference as h}from"../../time/timeZoneUtils.js";import{FixedOffsetZone as c,IANAZone as p}from"luxon";function y(e){return"timeZone"in e}function _(e){return"timeZone"in e}function g(e){return"dateFieldsTimeZone"in e}const T=new Map;class Z{static fromJSON(e){return new Z(e.fields,e.timeZoneByFieldName)}static fromLayer(e){return new Z(e.fields??[],S(e))}static fromLayerJSON(e){return new Z(e.fields??[],S(e))}constructor(e=[],i){this._fieldsMap=new Map,this._normalizedFieldsMap=new Map,this._dateFieldsSet=new Set,this._numericFieldsSet=new Set,this._requiredFields=null,this.dateFields=[],this.numericFields=[],this.fields=e||[],this._timeZoneByFieldName=i?new Map(i):null;const t=[];for(const s of this.fields){const e=s?.name,i=M(e);if(e&&i){const n=w(e);this._fieldsMap.set(e,s),this._fieldsMap.set(n,s),this._normalizedFieldsMap.set(i,s),t.push(`${n}:${s.type}:${this._timeZoneByFieldName?.get(e)}`),r(s)?(this.dateFields.push(s),this._dateFieldsSet.add(s)):l(s)&&(this._numericFieldsSet.add(s),this.numericFields.push(s)),o(s)||d(s)||(s.editable=null==s.editable||!!s.editable,s.nullable=null==s.nullable||!!s.nullable)}}t.sort(),this.uid=t.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const e of this.fields)o(e)||d(e)||e.nullable||void 0!==a(e)||this._requiredFields.push(e)}return this._requiredFields}equals(e){return this.uid===e?.uid}has(e){return null!=this.get(e)}get(e){if(!e)return;let i=this._fieldsMap.get(e);return i||(i=this._fieldsMap.get(w(e))??this._normalizedFieldsMap.get(M(e)),i&&this._fieldsMap.set(e,i),i)}getTimeZone(i){const s=this.get(i&&"string"!=typeof i?i.name:i);return s?this._timeZoneByFieldName?this._timeZoneByFieldName.get(s.name):"date"===s.type||"esriFieldTypeDate"===s.type?(t.getLogger("esri.layers.support.FieldsIndex").error(new e("getTimeZone:no-timezone-information",`no time zone information for field '${s.name}'`)),f):N.has(s.type)?F:null:null}getLuxonTimeZone(e){const i=this.getTimeZone(e);return i?i===F?n.instance:i===f?c.utcInstance:s(T,i,(()=>p.create(i))):null}isDateField(e){return this._dateFieldsSet.has(this.get(e))}isTimeOnlyField(e){return m(this.get(e))}isNumericField(e){return this._numericFieldsSet.has(this.get(e))}normalizeFieldName(e){return this.get(e)?.name??void 0}toJSON(){return{fields:this.fields.map((e=>i(e)?e.toJSON():e)),timeZoneByFieldName:this._timeZoneByFieldName?Array.from(this._timeZoneByFieldName.entries()):null}}}function w(e){return e.trim().toLowerCase()}function M(e){return u(e)?.toLowerCase()??""}const N=new Set(["time-only","date-only","timestamp-offset","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"]);function S(e){const i=new Map;if(!e.fields)return i;const t=!0===e.datesInUnknownTimezone,{timeInfo:s,editFieldsInfo:n}=e,r=(s?"startField"in s?s.startField:s.startTimeField:"")??"",l=(s?"endField"in s?s.endField:s.endTimeField:"")??"",o=g(e)?e.dateFieldsTimeZone??null:e.dateFieldsTimeReference?h(e.dateFieldsTimeReference):null,d=n?y(n)?n.timeZone??o:n.dateFieldsTimeReference?h(n.dateFieldsTimeReference):o??f:null,a=s?_(s)?s.timeZone??o:s.timeReference?h(s.timeReference):o:null,m=new Map([[w(n?.creationDateField??""),d],[w(n?.editDateField??""),d],[w(r),a],[w(l),a]]);for(const{name:u,type:f}of e.fields)if(N.has(f))i.set(u,F);else if("date"!==f&&"esriFieldTypeDate"!==f)i.set(u,null);else if(t)i.set(u,F);else{const e=m.get(w(u??""))??o;i.set(u,e)}return i}export{Z as default};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const b="20231103",c="20d65e53b5fc8739cf2fd1a2abb2fa9c964db5d3";export{b as buildDate,c as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as t}from"../../../../core/maybe.js";import{t as s}from"../../../../chunks/common.js";import{k as i,c as e,r,h as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f32.js";import{f as n}from"../../../../chunks/vec2f64.js";import{s as c}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import
|
|
5
|
+
import{disposeMaybe as t}from"../../../../core/maybe.js";import{t as s}from"../../../../chunks/common.js";import{k as i,c as e,r,h as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f32.js";import{f as n}from"../../../../chunks/vec2f64.js";import{s as c}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import l from"./VertexStream.js";import{stencil as m}from"./shaders/StencilPrograms.js";import{CompareFunction as _,StencilOperation as d}from"../../../webgl/enums.js";import{createProgram as p}from"../../../webgl/ProgramTemplate.js";const u=n(-.5,-.5);class f{constructor(){this._centerNdc=h(),this._pxToNdc=h(),this._worldDimensionsPx=h(),this._mat3=a(),this._initialized=!1}dispose(){this._program=t(this._program),this._quad=t(this._quad)}render(t,s,i){const{context:e}=t,r=this._updateGeometry(t,i);if(null!=s){const{r:t,g:i,b:r,a:o}=s;e.setClearColor(o*t/255,o*i/255,o*r/255,o)}else e.setClearColor(0,0,0,0);if(e.setStencilFunction(_.ALWAYS,0,255),e.setStencilWriteMask(255),!r)return e.setClearStencil(1),void e.clear(e.gl.STENCIL_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);e.setClearStencil(0),e.clear(e.gl.STENCIL_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),this._initialized||this._initialize(e),e.setDepthWriteEnabled(!1),e.setDepthTestEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setBlendingEnabled(!1),e.setStencilOp(d.KEEP,d.KEEP,d.REPLACE),e.setStencilFunction(_.ALWAYS,1,255),e.setStencilTestEnabled(!0),e.useProgram(this._program),this._program.setUniformMatrix3fv("u_worldExtent",this._mat3),this._quad.draw(),this._quad.unbind()}_initialize(t){if(this._initialized)return;const s=p(t,m);s&&(this._program=s,this._quad=new l(t,[0,0,1,0,0,1,1,1]),this._initialized=!0)}_updateGeometry(t,a){const{state:n,pixelRatio:h}=t,{size:l,rotation:m}=n,_=Math.round(l[0]*h),d=Math.round(l[1]*h);if(!n.spatialReference.isWrappable)return!1;const p=s(m),f=Math.abs(Math.cos(p)),g=Math.abs(Math.sin(p)),E=Math.round(_*f+d*g),S=Math.round(n.worldScreenWidth);if(E<=S)return!1;const b=_*g+d*f,x=S*h,C=(a.left-a.right)*h/_,T=(a.bottom-a.top)*h/d;c(this._worldDimensionsPx,x,b,1),c(this._pxToNdc,2/_,-2/d,1),c(this._centerNdc,C,T,1);const j=this._mat3;return i(j,this._centerNdc),e(j,j,this._pxToNdc),0!==m&&r(j,j,p),e(j,j,this._worldDimensionsPx),o(j,j,u),!0}}export{f as WorldExtentRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e)return this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t)),this._colorAttachments.delete(t),e}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
|
|
5
|
+
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as r}from"../../views/support/layerViewUtils.js";import a from"./UpdateFeatureWorkflowData.js";import{handleKeys as l,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as n,setUpGeometryUpdate as h,isTerminalUpdateEventType as u,swapForEditingSession as p,cloneGraphicExceptMesh as w}from"./workflowUtils.js";var m;const y={...l,highlights:Symbol(),sketch:Symbol()};let f=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._webStyleCache=new Map}initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.sketch);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),this._initializeSketchViewModel()}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;r(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{edits:i,viewModel:s}=e,o=i.feature,{featureFormViewModel:r,sketchViewModel:a,view:l}=s;a.allowDeleteKey=!1;const c=n(o),d=await h({feature:o,featureClone:t,visualVariableAttributes:c,sketchViewModel:a,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(i.updateAttributes(t),i.updateGeometry(e),r.feature.geometry=e,null!=c.rotation){const{field:e}=c.rotation;r.setValue(e,t[e])}if(null!=c.size){const{field:e}=c.size;r.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&u(s.toolEventInfo.type))&&r.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(d,y.sketch)}_initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,s=e.edits.feature,{sketchViewModel:o}=e.viewModel,{geometryUpdatesEnabled:r}=e.editableItem,a=o.updateOnGraphicClick;o.updateOnGraphicClick=!1,this.addHandles([i((()=>{o.updateOnGraphicClick=a}))]),r&&this.addHandles([p(o,s,t)]);const{highlights:l,sketch:c}=y;return{enter:async()=>{!this.hasHandles(c)&&r?await this._configureSketchViewModel():this.hasHandles(l)||this._configureHighlight()},exit:()=>this.removeHandles([c,l])}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e),this._sketchGraphicClone=w(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await a.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([s()],f.prototype,"_layerViewEditSession",void 0),e([s()],f.prototype,"_sketchGraphicClone",void 0),f=m=e([o("esri.widgets.Editor.UpdateFeatureWorkflow")],f);export{f as UpdateFeatureWorkflow,y as handleKeys};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as r}from"../../views/support/layerViewUtils.js";import a from"./UpdateFeatureWorkflowData.js";import{handleKeys as l,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as n,setUpGeometryUpdate as h,isTerminalUpdateEventType as u,swapForEditingSession as p,cloneGraphicExceptMesh as w}from"./workflowUtils.js";var m;const y={...l,highlights:Symbol(),sketch:Symbol()};let f=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._webStyleCache=new Map}initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.sketch);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),this._initializeSketchViewModel()}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;r(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{edits:i,viewModel:s}=e,o=i.feature,{featureFormViewModel:r,sketchViewModel:a,view:l}=s;a.allowDeleteKey=!1;const c=n(o),d=await h({feature:o,featureClone:t,visualVariableAttributes:c,sketchViewModel:a,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(i.updateAttributes(t),i.updateGeometry(e),r.feature.geometry=e,null!=c.rotation){const{field:e}=c.rotation;r.setValue(e,t[e])}if(null!=c.size){const{field:e}=c.size;r.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&u(s.toolEventInfo.type))&&r.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(d,y.sketch)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,s=e.edits.feature,{sketchViewModel:o}=e.viewModel,{geometryUpdatesEnabled:r}=e.editableItem,a=o.updateOnGraphicClick;o.updateOnGraphicClick=!1,this.addHandles([i((()=>{o.updateOnGraphicClick=a}))]),r&&this.addHandles([await p(o,s,t)]);const{highlights:l,sketch:c}=y;return{enter:async()=>{!this.hasHandles(c)&&r?await this._configureSketchViewModel():this.hasHandles(l)||this._configureHighlight()},exit:()=>this.removeHandles([c,l])}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e),this._sketchGraphicClone=w(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await a.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([s()],f.prototype,"_layerViewEditSession",void 0),e([s()],f.prototype,"_sketchGraphicClone",void 0),f=m=e([o("esri.widgets.Editor.UpdateFeatureWorkflow")],f);export{f as UpdateFeatureWorkflow,y as handleKeys};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as a,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as l,debounce as o}from"../../core/promiseUtils.js";import{watch as c,whenOnce as u}from"../../core/reactiveUtils.js";import{px2pt as p}from"../../core/screenUtils.js";import{diff as y}from"../../core/accessorSupport/diffUtils.js";import{featureHasFields as d,fixFields as f,getDisplayFieldName as m}from"../../layers/support/fieldUtils.js";import{calculateTolerance as h}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as b}from"../../renderers/support/lengthUtils.js";import{getTransformationType as g,TransformationType as w}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as v,getSize as S}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as j,i3sPatchingEnabled as U}from"../../support/featureFlags.js";import{to3D as V}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as F}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as L,filterGraphicHits as T}from"../../views/support/hitTestSelectUtils.js";import{getAllTemplatesForLayer as x}from"../support/templateUtils.js";function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!P(t.renderer))return{rotation:null,size:null};let r=null,a=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=v(t,e)));1===i.length&&(r=E(i[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&g(t)===w.RealWorldSize&&null!=S(t,e)));return 1===n.length&&(a=M(n[0],t)),{rotation:r,size:a}}function E(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,i=t.fields&&t.fields.filter((e=>e.name===a)),n=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:a,fieldType:n,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,C((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function A(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function O(e,t,r){if(null==t)return 0;const{symbol:a}=V(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const i=a.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min(ie.icon,(await e(i,ie.icon))[0])||ie.icon}case"text":return i.size||ie.text;case"line":return i.size||ie.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return A(await t(i,e.scale/ie.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/ie.viewScaleSizeFactor;case"extrude":return i.size||e.scale/ie.viewScaleSizeFactor;default:return 0}}function M(e,t){const r=e.field,a=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),n=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=b[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:n,getDefault:async(e,t)=>C(o(await O(t,e,a)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,C(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:le(e.valueUnit),axis:e.axis}}function C(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function P(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function R(e,t,r){const a=await I(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=y(e.symbol,a)&&(e.symbol=a)}function D(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function G(e,t,r,n){(await Z(e,t,n)).remove();const s=e.on("create",(async a=>{if("cancel"===a.state){(await Z(e,t,n)).remove()}if("complete"===a.state){const i=a.graphic;i.sourceLayer||(i.sourceLayer=t.layer),i.attributes||(i.attributes={...t.template?.prototype.attributes});const s="2d"===e.view?.type?e.view?.scale:null;await R(i,n,s),r(i)}}));return a([s,i((()=>e.cancel()))])}async function Z(e,t,r){const a=t.layer,n={...t.template?.prototype.attributes,...t.attributeOverrides};let s=null;const{view:l}=e,u="2d"===l?.type;if(await q(e,a,n,r,u?l.scale:null),u){const t=o((t=>q(e,a,n,r,t)));s=c((()=>l.scale),(e=>t(e)))}const{data:p,editing:y}=a.capabilities;return e.layer.elevationInfo=a.elevationInfo,await e.create(D(a.geometryType),{graphicProperties:{attributes:n,sourceLayer:a},hasZ:p.supportsZ,defaultZ:(u?y.zDefault:null)??e.defaultCreateOptions.defaultZ,geometryToPlace:t.geometryToPlace??void 0}),s??i()}async function q(t,r,a,i,n){const s=new e({sourceLayer:r,attributes:a}),{rotation:l,size:o}=k(s);let c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n}),u=!1;for(const e of[o,l]){if(null==e)continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}Q(t.tooltipOptions,o,l)}function Q(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function B(e,t){return e?e.find((e=>e.layer===t)):void 0}async function W(e,t,r,a){switch(t.type){case"3d":return _(e,t,r,a);case"2d":return H(e,t,r,a)}}async function _(e,r,a,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:l}=await a.async((async()=>{const{results:t}=await s(L(r,a),i),n=new Map,l=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};T(t).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&n.has(t)));return 0!==o.length&&a.stopPropagation(),{updatable:o,graphicsByLayer:n}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const r=l.get(e),a=J(e);if(r.every((e=>d(a,e))))return r;const n=[];for(const i of r){n.push(i.getObjectId());const e=Object.keys(i.attributes);t(a,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=f(e.fieldsIndex,a),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function H(e,t,r,a){if(0===e.length)return[];let i=null;const n=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),a);if(0===n.length)return[];const l=new Set;i=T(n),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(n.map((async({layer:e})=>{const n=e.createQuery();n.returnGeometry=!1,n.outFields=J(e);const s="renderer"in e?h({renderer:e.renderer,event:r}):0;n.geometry=F(r.mapPoint,s,t),n.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(n,{signal:a});return i?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function J(e){return f(e.fieldsIndex,[e.objectIdField,m({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function K(e,t,r){const{sourceLayer:a}=e,i=a.createQuery();i.objectIds=[e.getAttribute(a.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=a.capabilities.data.supportsM,i.returnZ=a.capabilities.data.supportsZ,j()&&U()&&"scene"===a.type&&null!=a.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const n=await a.queryFeatures(i,{signal:r});l(r);return n.features[0]}async function N(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:i,webStyleCache:n}=e;let s=!1;const{rotation:l,size:o}=i;if([l,o].forEach((async e=>{if(null==e)return;const a=t.getAttribute(e.field);if(null!=a)e.initValue(a);else{const a=await e.getDefault(t.symbol,r.view);e.initValue(a),t.setAttribute(e.field,a),s=!0}})),s){const e="2d"===r.view?.type?r.view.scale:null;await R(t,n,e)}const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),Q(r.tooltipOptions,o,l),r.layer.elevationInfo=a.elevationInfo,r.update(t,c)}function X(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Y(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function $(e,t,r,a,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,s=X(r.toolEventInfo);if(null!=n&&null!=s)if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:a}=n;t.setAttribute(r,a(s.angle,e))}const l=a.size,o=Y(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:a}=l;t.setAttribute(r,a(o.xScale,e))}await R(t,i,"2d"===e.type?e.scale:null)}async function ee({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:s,onUpdate:l,webStyleCache:u}){await R(t,u,"2d"===s.type?s.scale:null);let p=null;if("2d"===n?.view?.type){const e=o((e=>R(t,u,e)));p=c((()=>n?.view?.scale),(t=>e(t)))}s.map.add(n.layer);const y=t.sourceLayer,d=pe(s,y);await ae(s,t),await N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});let f=null;d.then((e=>f=e)).catch((()=>{}));const m=r.size,h=r.rotation,b=c((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const i=e[a];i!==t.getAttribute(a)&&(t.setAttribute(a,i),null==m||m.isUpdatingInteractively||m.field!==a||m.initValue(i),null==h||h.isUpdatingInteractively||h.field!==a||h.initValue(i),(null==f||f.requiredFields.includes(a))&&(r=!0))}r&&await R(t,u,"2d"===s.type?s.scale:null)})),g=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});await $(s,t,e,r,u),l(fe(t),e)})),w=n.on(["undo","redo"],(async e=>{l(fe(e.graphics[0]),e)}));return a([w,g,i((()=>n.cancel())),b,p])}function te(e,t,n){const s=e.view;e.layer.add(n);const o=t.sourceLayer,c=t.layer,p=t.getAttribute(c.objectIdField);let y=null;function d(e){y?.abort(),y=r((async t=>{const r=await pe(s,o);l(t),r.setVisibility?.(p,e)}))}return d(!1),a([re(s,n,(e=>d(!e))),i((async()=>{d(!0);try{const e=await pe(s,o);await u((()=>!e.updating))}finally{e.layer.remove(n)}}))])}function re(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),c((()=>i.displaying),r)])}return c((()=>t.visible),r)}async function ae(e,t){if("3d"===e.type){const r=new z({graphic:t}),a=e.trackGraphicState(r);await u((()=>r.displaying)),a.remove()}else await u((()=>t.visible))}const ie={icon:p(24),text:p(12),line:p(1),viewScaleSizeFactor:100};function ne(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function se(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,a=x(e);1===a.length&&"scene"!==e.type&&(r.template=a[0],t.shift())}return t}function le(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function oe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ce(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:a}=t,i=r.editableItems.find((e=>e.layer===a));if(i)return i.attachmentsOnCreateEnabled;const n=a.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===a));return!(!(n&&"supportsAttachment"in n&&n.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ue=e=>/-stop/.test(e)||/vertex-/.test(e),pe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ye(e){return"createInteractiveEditSession"in e}const de=Symbol();function fe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function me(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{de as UsesSketchViewModelSymbol,se as avoidFeatureTemplateSelectionWithOnlyOneItem,ye as canCreateInteractiveEditSession,fe as cloneGraphicExceptMesh,ne as createWorkflowSteps,W as fetchCandidates,K as fetchFullFeature,B as findLayerInfo,k as getVisualVariableAttributes,ue as isTerminalUpdateEventType,oe as prepareAttachmentsForCreateWorkflow,G as setUpFeatureAdd,ee as setUpGeometryUpdate,ce as shouldShowAttachmentsForCreateWorkflow,me as showProgressCursor,ie as sizeDefaults,le as sizeVariableUnitToLengthUnit,Z as startCreatingNewFeature,N as startUpdatingFeature,te as swapForEditingSession,R as updateGraphicSymbolWhenRequired,$ as visualVariableInteractiveUpdate,pe as whenEditorLayerView,ae as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as a,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as l,debounce as o}from"../../core/promiseUtils.js";import{watch as c,whenOnce as u}from"../../core/reactiveUtils.js";import{px2pt as p}from"../../core/screenUtils.js";import{diff as y}from"../../core/accessorSupport/diffUtils.js";import{featureHasFields as d,fixFields as f,getDisplayFieldName as m}from"../../layers/support/fieldUtils.js";import{calculateTolerance as h}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as b}from"../../renderers/support/lengthUtils.js";import{getTransformationType as g,TransformationType as w}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as v,getSize as S}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as j,i3sPatchingEnabled as U}from"../../support/featureFlags.js";import{to3D as V}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as F}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as L,filterGraphicHits as T}from"../../views/support/hitTestSelectUtils.js";import{getAllTemplatesForLayer as x}from"../support/templateUtils.js";function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!P(t.renderer))return{rotation:null,size:null};let r=null,a=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=v(t,e)));1===i.length&&(r=E(i[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&g(t)===w.RealWorldSize&&null!=S(t,e)));return 1===n.length&&(a=M(n[0],t)),{rotation:r,size:a}}function E(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,i=t.fields&&t.fields.filter((e=>e.name===a)),n=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:a,fieldType:n,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,C((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function A(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function O(e,t,r){if(null==t)return 0;const{symbol:a}=V(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const i=a.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min(ie.icon,(await e(i,ie.icon))[0])||ie.icon}case"text":return i.size||ie.text;case"line":return i.size||ie.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return A(await t(i,e.scale/ie.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/ie.viewScaleSizeFactor;case"extrude":return i.size||e.scale/ie.viewScaleSizeFactor;default:return 0}}function M(e,t){const r=e.field,a=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),n=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=b[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:n,getDefault:async(e,t)=>C(o(await O(t,e,a)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,C(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:le(e.valueUnit),axis:e.axis}}function C(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function P(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function R(e,t,r){const a=await I(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=y(e.symbol,a)&&(e.symbol=a)}function D(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function G(e,t,r,n){(await Z(e,t,n)).remove();const s=e.on("create",(async a=>{if("cancel"===a.state){(await Z(e,t,n)).remove()}if("complete"===a.state){const i=a.graphic;i.sourceLayer||(i.sourceLayer=t.layer),i.attributes||(i.attributes={...t.template?.prototype.attributes});const s="2d"===e.view?.type?e.view?.scale:null;await R(i,n,s),r(i)}}));return a([s,i((()=>e.cancel()))])}async function Z(e,t,r){const a=t.layer,n={...t.template?.prototype.attributes,...t.attributeOverrides};let s=null;const{view:l}=e,u="2d"===l?.type;if(await q(e,a,n,r,u?l.scale:null),u){const t=o((t=>q(e,a,n,r,t)));s=c((()=>l.scale),(e=>t(e)))}const{data:p,editing:y}=a.capabilities;return e.layer.elevationInfo=a.elevationInfo,await e.create(D(a.geometryType),{graphicProperties:{attributes:n,sourceLayer:a},hasZ:p.supportsZ,defaultZ:(u?y.zDefault:null)??e.defaultCreateOptions.defaultZ,geometryToPlace:t.geometryToPlace??void 0}),s??i()}async function q(t,r,a,i,n){const s=new e({sourceLayer:r,attributes:a}),{rotation:l,size:o}=k(s);let c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n}),u=!1;for(const e of[o,l]){if(null==e)continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}Q(t.tooltipOptions,o,l)}function Q(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function B(e,t){return e?e.find((e=>e.layer===t)):void 0}async function W(e,t,r,a){switch(t.type){case"3d":return _(e,t,r,a);case"2d":return H(e,t,r,a)}}async function _(e,r,a,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:l}=await a.async((async()=>{const{results:t}=await s(L(r,a),i),n=new Map,l=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};T(t).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&n.has(t)));return 0!==o.length&&a.stopPropagation(),{updatable:o,graphicsByLayer:n}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const r=l.get(e),a=J(e);if(r.every((e=>d(a,e))))return r;const n=[];for(const i of r){n.push(i.getObjectId());const e=Object.keys(i.attributes);t(a,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=f(e.fieldsIndex,a),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function H(e,t,r,a){if(0===e.length)return[];let i=null;const n=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),a);if(0===n.length)return[];const l=new Set;i=T(n),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(n.map((async({layer:e})=>{const n=e.createQuery();n.returnGeometry=!1,n.outFields=J(e);const s="renderer"in e?h({renderer:e.renderer,event:r}):0;n.geometry=F(r.mapPoint,s,t),n.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(n,{signal:a});return i?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function J(e){return f(e.fieldsIndex,[e.objectIdField,m({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function K(e,t,r){const{sourceLayer:a}=e,i=a.createQuery();i.objectIds=[e.getAttribute(a.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=a.capabilities.data.supportsM,i.returnZ=a.capabilities.data.supportsZ,j()&&U()&&"scene"===a.type&&null!=a.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const n=await a.queryFeatures(i,{signal:r});l(r);return n.features[0]}async function N(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:i,webStyleCache:n}=e;let s=!1;const{rotation:l,size:o}=i;if([l,o].forEach((async e=>{if(null==e)return;const a=t.getAttribute(e.field);if(null!=a)e.initValue(a);else{const a=await e.getDefault(t.symbol,r.view);e.initValue(a),t.setAttribute(e.field,a),s=!0}})),s){const e="2d"===r.view?.type?r.view.scale:null;await R(t,n,e)}const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),Q(r.tooltipOptions,o,l),r.layer.elevationInfo=a.elevationInfo,r.update(t,c)}function X(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Y(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function $(e,t,r,a,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,s=X(r.toolEventInfo);if(null!=n&&null!=s)if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:a}=n;t.setAttribute(r,a(s.angle,e))}const l=a.size,o=Y(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:a}=l;t.setAttribute(r,a(o.xScale,e))}await R(t,i,"2d"===e.type?e.scale:null)}async function ee({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:s,onUpdate:l,webStyleCache:u}){await R(t,u,"2d"===s.type?s.scale:null);let p=null;if("2d"===n?.view?.type){const e=o((e=>R(t,u,e)));p=c((()=>n?.view?.scale),(t=>e(t)))}s.map.add(n.layer);const y=t.sourceLayer,d=pe(s,y);await N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});let f=null;d.then((e=>f=e)).catch((()=>{}));const m=r.size,h=r.rotation,b=c((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const i=e[a];i!==t.getAttribute(a)&&(t.setAttribute(a,i),null==m||m.isUpdatingInteractively||m.field!==a||m.initValue(i),null==h||h.isUpdatingInteractively||h.field!==a||h.initValue(i),(null==f||f.requiredFields.includes(a))&&(r=!0))}r&&await R(t,u,"2d"===s.type?s.scale:null)})),g=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});await $(s,t,e,r,u),l(fe(t),e)})),w=n.on(["undo","redo"],(async e=>{l(fe(e.graphics[0]),e)}));return a([w,g,i((()=>n.cancel())),b,p])}async function te(e,t,n){const s=e.view;e.layer.add(n);const o=t.sourceLayer,c=t.layer,p=t.getAttribute(c.objectIdField);let y=null;function d(e){y?.abort(),y=r((async t=>{const r=await pe(s,o);l(t),r.setVisibility?.(p,e)}))}return await ae(s,n),d(!1),a([re(s,n,(e=>d(!e))),i((async()=>{d(!0);try{const e=await pe(s,o);await u((()=>!e.updating))}finally{e.layer.remove(n)}}))])}function re(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),c((()=>i.displaying),r)])}return c((()=>t.visible),r)}async function ae(e,t){if("3d"===e.type){const r=new z({graphic:t}),a=e.trackGraphicState(r);await u((()=>r.displaying)),a.remove()}else await u((()=>t.visible))}const ie={icon:p(24),text:p(12),line:p(1),viewScaleSizeFactor:100};function ne(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function se(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,a=x(e);1===a.length&&"scene"!==e.type&&(r.template=a[0],t.shift())}return t}function le(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function oe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ce(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:a}=t,i=r.editableItems.find((e=>e.layer===a));if(i)return i.attachmentsOnCreateEnabled;const n=a.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===a));return!(!(n&&"supportsAttachment"in n&&n.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ue=e=>/-stop/.test(e)||/vertex-/.test(e),pe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ye(e){return"createInteractiveEditSession"in e}const de=Symbol();function fe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function me(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{de as UsesSketchViewModelSymbol,se as avoidFeatureTemplateSelectionWithOnlyOneItem,ye as canCreateInteractiveEditSession,fe as cloneGraphicExceptMesh,ne as createWorkflowSteps,W as fetchCandidates,K as fetchFullFeature,B as findLayerInfo,k as getVisualVariableAttributes,ue as isTerminalUpdateEventType,oe as prepareAttachmentsForCreateWorkflow,G as setUpFeatureAdd,ee as setUpGeometryUpdate,ce as shouldShowAttachmentsForCreateWorkflow,me as showProgressCursor,ie as sizeDefaults,le as sizeVariableUnitToLengthUnit,Z as startCreatingNewFeature,N as startUpdatingFeature,te as swapForEditingSession,R as updateGraphicSymbolWhenRequired,$ as visualVariableInteractiveUpdate,pe as whenEditorLayerView,ae as whenGraphicDisplayed};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as i,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as i,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u,getIntlOptionsForField as p}from"../support/dateUtils.js";import{substitute as m}from"../../intl/substitute.js";const d=e=>"field"===e?.type,c=e=>"group"===e?.type,f=e=>"relationship"===e?.type,y=e=>!c(e)&&null!=e.group,b=e=>"field"===e.type,T=e=>"group"===e.type,E=e=>"relationship"===e.type,g=e=>e.reduce(((e,t)=>c(t)?[...e,...t.inputs]:[...e,t]),[]),v=e=>g(e).filter(d),O=e=>g(e).filter(f),j=e=>null!=e&&(x(e,"combo-box")||x(e,"radio-buttons")),x=(e,t)=>null!=e&&e.input?.type===t,V=e=>null!=e&&(x(e,"text-box")||x(e,"text-area")),h=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),U=e=>"items"in e,N={typeFieldName:null,types:[]};function _(t){const{attributes:r,fieldsIndex:o,label:i,timeZone:l}=t;if(!r||"object"!=typeof r)return i;const a=Object.keys(r).filter((e=>n(i,e))),s=a.map((e=>r[e])),u=a.map((e=>o.get(e))).filter(e);return I(i,A({values:s,fields:u,timeZone:l}))}function A(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(s(e)||i(e))&&(o=u(e,o,{timeZone:r,...p(e)})),[e.name,o]}));return Object.fromEntries(o)}function I(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const L=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:N:N,F=(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 D;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(D||(D={}));const R={type:"number"},Z={type:"number",intlOptions:{notation:"scientific"}},w={day:"2-digit",month:"2-digit",year:"numeric"},C={hour:"numeric",minute:"numeric",second:"numeric"},S={...w,...C};function G(e){return e>=1e7||e<=-1e7}const H=(e,t,n)=>{const{dataType:r,error:i,minLength:s,value:u,required:p}=e;if(!t||!i)return null;if(p&&null===u)return t.validationErrors.cannotBeNull;if(i===o.VALUE_OUT_OF_RANGE||i===l.OUT_OF_RANGE){const{field:o,range:i}=e,l={type:"date",intlOptions:{..."time-only"===o.type?C:"date-only"===o.type?w:S,timeZone:n??void 0}};return m(t.validationErrors.outsideRange,i,{format:{max:"date"===r?l:null!=i.max&&G(i.max)?Z:R,min:"date"===r?l:null!=i.min&&G(i.min)?Z:R}})}return i===o.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===a.INVALID_TYPE?t.validationErrors.invalidType:i===D.TOO_SHORT?m(t.validationErrors.tooShort,{min:s}):null},P=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":r||n||"table"},k=e=>{const t=[];if(e.formTemplate){const{description:r,title:o}=e.formTemplate;e.fields?.forEach((e=>{const i=o&&n(o,e.name),l=r&&n(r,e.name);(i||l)&&t.push(e.name)}))}return t};function q(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(b)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function B(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function M(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}}export{D as LengthValidationError,F as capabilitiesAllowEditType,v as flattenFieldInputs,g as flattenInputs,O as flattenRelationshipInputs,q as formTemplateHasInvalidFields,A as getComputedAttributes,H as getErrorMessageForFieldInput,k as getFieldsInTitleAndDesc,P as getIconForFeature,L as getNormalizedFeatureTypeInfo,b as isFieldElement,x as isFieldElementWithInputType,j as isFieldElementWithShowNoValueOptionInput,V as isFieldElementWithTextInput,d as isFieldInput,T as isGroupElement,c as isGroupInput,y as isInputInGroupInput,h as isNumberFieldInput,E as isRelationshipElement,f as isRelationshipInput,U as isTemplateItemGroup,_ as parseFormTemplateString,I as substituteFieldTemplatesInString,B as valueIsInvalidSwitchValue,M as valueIsValidContingentValue};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,numberingSystem as w,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as O,normalizeTimeOnlyString as k,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as x,incrementHeadingLevel as V}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const E="data-field-name",U="esri.widgets.FeatureForm",S=o.getLogger(U);let $=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"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 label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,D.widget,D.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(x,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?V(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?j(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=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?L("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):L("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):L("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("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,F(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[E],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,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 L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[E],key:`${a}-time-input`,numberingSystem:w,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,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:l,[E]:i,onfocus:this._onComponentFocus},m=R(d),h=R(c),v=R(a);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.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:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:c,[E]:o,onfocus:this._onComponentFocus},h=O(a,u),v=O(l,u),_=O(d,u);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("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 L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[E],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:j(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=j(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[E]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(E))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=k(s),r=k(e.value)):r="timestamp-offset"===i?null!=e.value?I({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?M({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],$.prototype,"_listObserverNode",void 0),e([s()],$.prototype,"_relatedRecordsEnabled",null),e([s()],$.prototype,"disabled",null),e([s()],$.prototype,"feature",null),e([s()],$.prototype,"formTemplate",null),e([s()],$.prototype,"groupDisplay",void 0),e([s()],$.prototype,"headingLevel",void 0),e([s()],$.prototype,"label",null),e([s()],$.prototype,"layer",null),e([s()],$.prototype,"map",null),e([s(),N("esri/widgets/FeatureForm/t9n/FeatureForm")],$.prototype,"messages",void 0),e([s(),N("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([s(),N("esri/widgets/Feature/t9n/Feature")],$.prototype,"messagesFeature",void 0),e([s(),N("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],$.prototype,"messagesTemplates",void 0),e([s()],$.prototype,"relatedRecordCallbacks",null),e([s()],$.prototype,"relationshipId",null),e([s()],$.prototype,"spatialReference",null),e([s()],$.prototype,"strict",null),e([s()],$.prototype,"timeZone",null),e([s()],$.prototype,"view",null),e([s(),T(["value-change","submit"])],$.prototype,"viewModel",void 0),$=e([r(U)],$);const A=$;export{A as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import C from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,getIntlOptionsForField as w,numberingSystem as R,prepareISOFieldValueForDateComponents as O,prepareUnixFieldValueForDateComponents as k,normalizeTimeOnlyString as I,getISOFieldValueFromDateComponents as M,getUnixFieldValueFromDateComponents as D}from"./support/dateUtils.js";import{globalCss as x}from"./support/globalCss.js";import{Heading as V,incrementHeadingLevel as N}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as L}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";const U="data-field-name",S="esri.widgets.FeatureForm",$=o.getLogger(S);let A=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new C,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({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 label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i($,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i($,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return j("div",{class:this.classes(p.base,x.widget,x.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return j("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&j(V,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&j("p",{class:p.description,key:"description"},e.formDescription);return j("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:j("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return j("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?N(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?E(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[j("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?j("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?j("label",{...s},r):j("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?j("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return j("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,F(i,t.value,{timeZone:this.timeZone,...w(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 j("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[U],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:R,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 j("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[U],key:`${a}-time-input`,numberingSystem:R,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,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:R,overlayPositioning:"fixed",readOnly:l,[U]:i,onfocus:this._onComponentFocus},m=O(d),h=O(c),v=O(a);return j("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),j("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?j("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.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:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:R,overlayPositioning:"fixed",readOnly:c,[U]:o,onfocus:this._onComponentFocus},h=k(a,u),v=k(l,u),_=k(d,u);return j("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?j("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 j("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>j("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(j("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[j("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),j("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(j("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return j("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return j("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[U],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return j("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return j("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},j("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?j("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return j("calcite-list-item",{description:E(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},j("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 j("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return j("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},j("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),j("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 j("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},j("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return j("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},j("span",null,e.label),t?j("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return j("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=E(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return j("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[U]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(U))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=I(s),r=I(e.value)):r="timestamp-offset"===i?null!=e.value?M({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?D({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:$.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],A.prototype,"_listObserverNode",void 0),e([s()],A.prototype,"_relatedRecordsEnabled",null),e([s()],A.prototype,"disabled",null),e([s()],A.prototype,"feature",null),e([s()],A.prototype,"formTemplate",null),e([s()],A.prototype,"groupDisplay",void 0),e([s()],A.prototype,"headingLevel",void 0),e([s()],A.prototype,"label",null),e([s()],A.prototype,"layer",null),e([s()],A.prototype,"map",null),e([s(),T("esri/widgets/FeatureForm/t9n/FeatureForm")],A.prototype,"messages",void 0),e([s(),T("esri/t9n/common")],A.prototype,"messagesCommon",void 0),e([s(),T("esri/widgets/Feature/t9n/Feature")],A.prototype,"messagesFeature",void 0),e([s(),T("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],A.prototype,"messagesTemplates",void 0),e([s()],A.prototype,"relatedRecordCallbacks",null),e([s()],A.prototype,"relationshipId",null),e([s()],A.prototype,"spatialReference",null),e([s()],A.prototype,"strict",null),e([s()],A.prototype,"timeZone",null),e([s()],A.prototype,"view",null),e([s(),L(["value-change","submit"])],A.prototype,"viewModel",void 0),A=e([r(S)],A);const H=A;export{H as default};
|