@arcgis/core 4.25.0-next.20221021 → 4.25.0-next.20221022
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/WebMap.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0b0f3e93f658a012d5f0.js → 00df1053d3a8761fc0a3.js} +1 -1
- package/assets/esri/core/workers/chunks/0de7eca7acf74947cf2e.js +1 -0
- package/assets/esri/core/workers/chunks/{2474f0e8b8abc1387106.js → 2600954826b42f2b70c4.js} +1 -1
- package/assets/esri/core/workers/chunks/{af3f30f968363bb3930c.js → 353c4a51be72c4a77e1f.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d8201f0f33ba66bb96b.js → 5f46751fa500a9dfacf9.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9e93d9ea80361716f1d.js → 64190294f3dc9237b420.js} +1 -1
- package/assets/esri/core/workers/chunks/{883cfe319b15ebabf71e.js → 73ad8f3d3feff5882988.js} +1 -1
- package/assets/esri/core/workers/chunks/{177c8d5e2531c6f64581.js → 796504f93100aea7c6f5.js} +1 -1
- package/assets/esri/core/workers/chunks/8435ae4fe5a5332b1076.js +1 -0
- package/assets/esri/core/workers/chunks/{c8c0f091aab41e4effa5.js → 85690fabbfe60681f5e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{942da417257f8fd8e4cf.js → 858970a88406562a26cc.js} +1 -1
- package/assets/esri/core/workers/chunks/a17d20ffaa47d430d98c.js +1 -0
- package/assets/esri/core/workers/chunks/ac2903c5f1587dec2f80.js +1 -0
- package/assets/esri/core/workers/chunks/{7ba0cfe4d1c214f44fc7.js → b6d9750b16bbf8ce5307.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f40f4ac6e2af4b333f5.js → c4e5b929b152f8d36cc3.js} +1 -1
- package/assets/esri/core/workers/chunks/c7de993c0a85594a1969.js +1 -0
- package/assets/esri/core/workers/chunks/ca92022f53080fda75fe.js +1 -0
- package/assets/esri/core/workers/chunks/d7668e81467833a5a53d.js +1 -0
- package/assets/esri/core/workers/chunks/de83b062359c0459585f.js +1 -0
- package/assets/esri/core/workers/chunks/f57c3343f93d87423856.js +1 -0
- package/assets/esri/core/workers/chunks/f704ed07c514a0f436ec.js +1 -0
- package/assets/esri/themes/base/_color.scss +1 -0
- package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +58 -14
- package/assets/esri/themes/base/widgets/_LayerList.scss +57 -13
- 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/geometry/support/normalizeUtils.js +1 -1
- package/interfaces.d.ts +109 -6
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/Rasterizer.js +1 -1
- package/symbols/cim/rasterizingUtils.js +5 -0
- package/views/2d/engine/brushes.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleLayer.js +1 -1
- package/views/2d/engine/vtlBrushes.js +5 -0
- package/views/2d/engine/webgl/mesh/bufcut.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/widgets/BasemapLayerList/BasemapLayerListViewModel.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/LayerList/LayerListViewModel.js +1 -1
- package/widgets/LayerList/ListItem.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/0cfb97b9f38c31b3b33a.js +0 -1
- package/assets/esri/core/workers/chunks/2a63949c3aad9ace1b44.js +0 -1
- package/assets/esri/core/workers/chunks/3b5be512567d9c1c6fe6.js +0 -1
- package/assets/esri/core/workers/chunks/4450f17444947fe2f27f.js +0 -1
- package/assets/esri/core/workers/chunks/5abda500f5d5607155ab.js +0 -1
- package/assets/esri/core/workers/chunks/81139c01e8016cbbe324.js +0 -1
- package/assets/esri/core/workers/chunks/94027976cfca4ad5789b.js +0 -1
- package/assets/esri/core/workers/chunks/9d410721f42259efe666.js +0 -1
- package/assets/esri/core/workers/chunks/b17ff3dfdc638f9f5705.js +0 -1
- package/assets/esri/core/workers/chunks/d6eb078d94171fb9d3d4.js +0 -1
- package/rest/geometry/cut.js +0 -5
- package/rest/geometry/simplify.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function e(e,t,r,i,u,l
|
|
5
|
+
function e(e,t,r,i,u,o,l){D=0;const f=(i-r)*o,p=u&&u.length,c=p?(u[0]-r)*o:f;let v,s,h,d,Z,a=n(t,r,i,0,c,o,!0);if(a&&a.next!==a.prev){if(p&&(a=y(t,r,i,u,a,o)),f>80*o){v=h=t[0+r*o],s=d=t[1+r*o];for(let e=o;e<c;e+=o){const n=t[e+r*o],x=t[e+1+r*o];v=Math.min(v,n),s=Math.min(s,x),h=Math.max(h,n),d=Math.max(d,x)}Z=Math.max(h-v,d-s),Z=0!==Z?1/Z:0}x(a,e,o,v,s,Z,l,0)}}function n(e,n,t,x,r,i,l){let y;if(l===Z(e,n,t,x,r,i)>0)for(let o=x;o<r;o+=i)y=u(o+n*i,e[o+n*i],e[o+1+n*i],y);else for(let o=r-i;o>=x;o-=i)y=u(o+n*i,e[o+n*i],e[o+1+n*i],y);return y&&M(y,y.next)&&(o(y),y=y.next),y}function t(e,n=e){if(!e)return e;let t,x=e;do{if(t=!1,x.steiner||!M(x,x.next)&&0!==s(x.prev,x,x.next))x=x.next;else{if(o(x),x=n=x.prev,x===x.next)break;t=!0}}while(t||x!==n);return n}function x(e,n,u,l,y,f,p,v){if(!e)return;!v&&f&&(e=c(e,l,y,f));let s=e;for(;e.prev!==e.next;){const c=e.prev,h=e.next;if(f?i(e,l,y,f):r(e))n.push(c.index/u+p),n.push(e.index/u+p),n.push(h.index/u+p),o(e),e=h.next,s=h.next;else if((e=h)===s){v?1===v?x(e=b(e,n,u,p),n,u,l,y,f,p,2):2===v&&g(e,n,u,l,y,f,p):x(t(e),n,u,l,y,f,p,1);break}}}function r(e){const n=e.prev,t=e,x=e.next;if(s(n,t,x)>=0)return!1;let r=e.next.next;const i=r;let u=0;for(;r!==e.prev&&(0===u||r!==i);){if(u++,a(n.x,n.y,t.x,t.y,x.x,x.y,r.x,r.y)&&s(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function i(e,n,t,x){const r=e.prev,i=e,u=e.next;if(s(r,i,u)>=0)return!1;const o=r.x<i.x?r.x<u.x?r.x:u.x:i.x<u.x?i.x:u.x,l=r.y<i.y?r.y<u.y?r.y:u.y:i.y<u.y?i.y:u.y,y=r.x>i.x?r.x>u.x?r.x:u.x:i.x>u.x?i.x:u.x,f=r.y>i.y?r.y>u.y?r.y:u.y:i.y>u.y?i.y:u.y,p=z(o,l,n,t,x),c=z(y,f,n,t,x);let v=e.prevZ,h=e.nextZ;for(;v&&v.z>=p&&h&&h.z<=c;){if(v!==e.prev&&v!==e.next&&a(r.x,r.y,i.x,i.y,u.x,u.y,v.x,v.y)&&s(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,h!==e.prev&&h!==e.next&&a(r.x,r.y,i.x,i.y,u.x,u.y,h.x,h.y)&&s(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(;v&&v.z>=p;){if(v!==e.prev&&v!==e.next&&a(r.x,r.y,i.x,i.y,u.x,u.y,v.x,v.y)&&s(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;h&&h.z<=c;){if(h!==e.prev&&h!==e.next&&a(r.x,r.y,i.x,i.y,u.x,u.y,h.x,h.y)&&s(h.prev,h,h.next)>=0)return!1;h=h.nextZ}return!0}function u(e,n,t,x){const r=q.create(e,n,t);return x?(r.next=x.next,r.prev=x,x.next.prev=r,x.next=r):(r.prev=r,r.next=r),r}function o(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function l(e){let n=e,t=e;do{(n.x<t.x||n.x===t.x&&n.y<t.y)&&(t=n),n=n.next}while(n!==e);return t}function y(e,t,x,r,i,u){const o=new Array;for(let y=0,f=r.length;y<f;y++){const i=n(e,t,x,r[y]*u,y<f-1?r[y+1]*u:x*u,u,!1);i===i.next&&(i.steiner=!0),o.push(l(i))}o.sort(m);for(const n of o)i=f(n,i);return i}function f(e,n){const x=p(e,n);if(!x)return n;const r=j(x,e);return t(r,r.next),t(x,x.next)}function p(e,n){let t=n;const x=e.x,r=e.y;let i,u=-1/0;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const e=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(e<=x&&e>u){if(u=e,e===x){if(r===t.y)return t;if(r===t.next.y)return t.next}i=t.x<t.next.x?t:t.next}}t=t.next}while(t!==n);if(!i)return null;if(x===u)return i.prev;const o=i,l=i.x,y=i.y;let f,p=1/0;for(t=i.next;t!==o;)x>=t.x&&t.x>=l&&x!==t.x&&a(r<y?x:u,r,l,y,r<y?u:x,r,t.x,t.y)&&(f=Math.abs(r-t.y)/(x-t.x),(f<p||f===p&&t.x>i.x)&&w(t,e)&&(i=t,p=f)),t=t.next;return i}function c(e,n,t,x){for(let r;r!==e;r=r.next){if(r=r||e,null===r.z&&(r.z=z(r.x,r.y,n,t,x)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,c(e,n,t,x);r.prevZ=r.prev,r.nextZ=r.next}return e.prevZ.nextZ=null,e.prevZ=null,v(e)}function v(e){let n,t=1;for(;;){let x,r=e;e=null,n=null;let i=0;for(;r;){i++,x=r;let u=0;for(;u<t&&x;u++)x=x.nextZ;let o=t;for(;u>0||o>0&&x;){let t;0===u?(t=x,x=x.nextZ,o--):0!==o&&x?r.z<=x.z?(t=r,r=r.nextZ,u--):(t=x,x=x.nextZ,o--):(t=r,r=r.nextZ,u--),n?n.nextZ=t:e=t,t.prevZ=n,n=t}r=x}if(n.nextZ=null,t*=2,i<2)return e}}function s(e,n,t){return(n.y-e.y)*(t.x-n.x)-(n.x-e.x)*(t.y-n.y)}function h(e,n,t,x){return!!(M(e,n)&&M(t,x)||M(e,x)&&M(t,n))||s(e,n,t)>0!=s(e,n,x)>0&&s(t,x,e)>0!=s(t,x,n)>0}function d(e,n){let t=e;do{if(t.index!==e.index&&t.next.index!==e.index&&t.index!==n.index&&t.next.index!==n.index&&h(t,t.next,e,n))return!0;t=t.next}while(t!==e);return!1}function Z(e,n,t,x,r,i){let u=0;for(let o=x,l=r-i;o<r;o+=i)u+=(e[l+n*i]-e[o+n*i])*(e[o+1+n*i]+e[l+1+n*i]),l=o;return u}function a(e,n,t,x,r,i,u,o){return(r-u)*(n-o)-(e-u)*(i-o)>=0&&(e-u)*(x-o)-(t-u)*(n-o)>=0&&(t-u)*(i-o)-(r-u)*(x-o)>=0}function w(e,n){return s(e.prev,e,e.next)<0?s(e,n,e.next)>=0&&s(e,e.prev,n)>=0:s(e,n,e.prev)<0||s(e,e.next,n)<0}function z(e,n,t,x,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-t)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-x)*r)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function M(e,n){return e.x===n.x&&e.y===n.y}function m(e,n){return e.x-n.x}function b(e,n,t,x){let r=e;do{const i=r.prev,u=r.next.next;!M(i,u)&&h(i,r,r.next,u)&&w(i,u)&&w(u,i)&&(n.push(i.index/t+x),n.push(r.index/t+x),n.push(u.index/t+x),o(r),o(r.next),r=e=u),r=r.next}while(r!==e);return r}function g(e,n,r,i,u,o,l){let y=e;do{let e=y.next.next;for(;e!==y.prev;){if(y.index!==e.index&&k(y,e)){let f=j(y,e);return y=t(y,y.next),f=t(f,f.next),x(y,n,r,i,u,o,l,0),void x(f,n,r,i,u,o,l,0)}e=e.next}y=y.next}while(y!==e)}function k(e,n){return e.next.index!==n.index&&e.prev.index!==n.index&&!d(e,n)&&w(e,n)&&w(n,e)&&A(e,n)}function A(e,n){let t=e,x=!1;const r=(e.x+n.x)/2,i=(e.y+n.y)/2;do{t.y>i!=t.next.y>i&&t.next.y!==t.y&&r<(t.next.x-t.x)*(i-t.y)/(t.next.y-t.y)+t.x&&(x=!x),t=t.next}while(t!==e);return x}function j(e,n){const t=q.create(e.index,e.x,e.y),x=q.create(n.index,n.x,n.y),r=e.next,i=n.prev;return e.next=n,n.prev=e,t.next=r,r.prev=t,x.next=t,t.prev=x,i.next=x,x.prev=i,x}class q{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(e,n,t){const x=D<B.length?B[D++]:new q;return x.index=e,x.x=n,x.y=t,x.prev=null,x.next=null,x.z=null,x.prevZ=null,x.nextZ=null,x.steiner=!1,x}}const B=new Array,C=8096;let D=0;for(let E=0;E<C;E++)B.push(new q);export{e as bufcut};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as r,unwrap as i,isNone as n,unwrapOr as s}from"../../../../core/maybe.js";import{pt2px as l}from"../../../../core/screenUtils.js";import{sqlAnd as o}from"../../../../core/sql.js";import{diff as a}from"../../../../core/accessorSupport/diffUtils.js";import{validateLabelingInfo as u}from"../../../../layers/support/labelingInfo.js";import{WGLSymbologyType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{getTechniqueFromRenderer as p}from"../../engine/webgl/techniques/utils.js";import{getVVFlags as c}from"../../engine/webgl/util/vvFlagUtils.js";import{createSymbolSchema as y}from"./createSymbolSchema.js";export{createSymbolSchema}from"./createSymbolSchema.js";import{getPtMaxVVSize as m}from"./support/pixelBuffering.js";import{getSupportedHeatmapRenderer as g,simplifyVisualVariables as b}from"./support/rendererUtils.js";import{injectDynamicLevelDependentSizeVisualVariable as x,createClusterRenderer as h}from"../support/clusterUtils.js";import{toJSONGeometryType as v}from"../support/util.js";const T=t.getLogger("esri.views.2d.layers.features.schemaUtils"),S="ValidationError";function w(e){return e}function E(e,t){let i=0,n=0,s=d.DEFAULT;if(r(e)){if(n=m(e,t),"visualVariables"in e&&(i=c(e.visualVariables||[]),"dot-density"===e.type&&(s=d.DOT_DENSITY)),"heatmap"===e.type&&(s=d.HEATMAP),"dictionary"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.DEFAULT};if("pie-chart"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.PIE_CHART};if(s!==d.DOT_DENSITY&&s!==d.HEATMAP){const t=e.getSymbols();"backgroundFillSymbol"in e&&e.backgroundFillSymbol&&t.push(e.backgroundFillSymbol);let r=!0,i=!0;for(const e of t)if("cim"===e.type&&(i=!1),"simple-fill"===e.type||"picture-fill"===e.type){const t=e.outline,n=t&&"none"!==t.style&&"solid"!==t.style,s="simple-fill"===e.type&&"none"!==e.style&&"solid"!==e.style,l="picture-fill"===e.type||s||n;n&&(r=!1),l&&(i=!1)}r?s=i?d.OUTLINE_FILL_SIMPLE:d.OUTLINE_FILL:i&&(s=d.SIMPLE)}}return{vvFlags:i,maxVVSize:n,symbologyType:s}}let I=null;function F(e){if(has("esri-2d-update-debug")){const t=V(e,!0);console.debug("Created new schema",t),console.debug("Schema diff",a(I,t)),I=t}return V(e)}function V(e,t=!1){try{const i=P(e,t),n=C(e),s={};i.map((t=>O(s,e,t)));const l=r(e.subtypeCode)?`${e.subtypeField} = ${e.subtypeCode}`:null,a=o(e.definitionExpression,l);return{source:{definitionExpression:a,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:e.historicMoment?.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:e.timeExtent?.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:i,tileRenderer:n,targets:s}}catch(i){if(i.fieldName===S)return T.error(i),null;throw i}}function O(t,r,i){switch(i.target){case"feature":return void M(t,N(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;switch(n.type){case"selection":throw new e(S,"Mapview does not support `selection` reduction type",n);case"binning":return M(t,N(r),i),void L(t,n,r.fields.map((e=>e.toJSON())),i);case"cluster":return M(t,N(r),i),void R(t,n,r.fields.map((e=>e.toJSON())),i)}}}}function z(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function N(e){return[i(e.filter)?.toJSON()??null,i(i(e.featureEffect)?.filter)?.toJSON()??null]}function M(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),z(e.feature,r.attributes.fields),e}function j(t,r){const{onStatisticExpression:i,onStatisticField:n,statisticType:s}=t;switch(s){case"min":case"max":case"avg":case"avg_angle":case"sum":case"count":return"esriFieldTypeDouble";case"mode":{if(i){const{returnType:r}=i;return r?"string"===r?"esriFieldTypeString":"esriFieldTypeDouble":(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}const s=r.find((e=>e.name===n));return s?s.type:(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}}}function L(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"bin",filters:null,input:"feature",params:{fixedBinLevel:t.fixedBinLevel,fields:(t.fields??[]).map((e=>({...e.toJSON(),type:j(e,r)})))},attributes:{}}),z(e.aggregate,i.attributes.fields),e}function R(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"cluster",input:"feature",filters:null,attributes:{},params:{clusterRadius:l(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(l(t.clusterMaxSize)/64),fields:(t.fields??[])?.map((e=>({...e.toJSON(),type:j(e,r)})))}}),z(e.aggregate,i.attributes.fields),e}function U(e,t){return t.field?B(e,{...t,type:"field",field:t.field}):t.valueExpression?B(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function B(e,t){switch(t.type){case"expression":{const r=w(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=w(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function P(e,t=!1){const r=new Array;let i=0;return r.push(A(e,i++,t)),r}function k(e,t,r,i,n,s=!1){const l=B(e,{type:"label-expression",target:r,context:{mesh:!0},resultType:"string",label:{labelExpression:t.labelExpression,labelExpressionInfo:t.labelExpressionInfo?{expression:t.labelExpressionInfo.expression}:null,symbol:!!t.symbol,where:t.where}}),{fieldIndex:o}=l;return{...y(t,n,s),fieldIndex:o,target:r,index:i}}function D(t,r,i){const n="featureReduction"in r&&r.featureReduction;if(!n)return{fields:[],labels:[],matcher:null,rendererOverride:null};const s="aggregate",l=[];let o=null,a=v(r.geometryType),d=[],f=null;if(n)switch(n.type){case"selection":return T.error(new e(S,"Mapview does not support `selection` reduction type",n)),{fields:[],labels:[],matcher:null,rendererOverride:null};case"cluster":case"binning":if(l.push(...n.fields??[]),"cluster"===n.type?a="esriGeometryPoint":"binning"===n.type&&(a="esriGeometryPolygon"),n.renderer&&!n.renderer.authoringInfo?.isAutoGenerated){if("cluster"===n.type){const{renderer:e}=x(n.renderer,n,null);f=e}else f=n.renderer;const e=E(n.renderer,n);o=$(null,s,n.renderer,e,i),d=n&&n.labelsVisible&&n.labelingInfo||[]}else if("cluster"===n.type){if(f=h(l,r.renderer,n,null,!0),n.symbol){const e=E(f,n);o={type:"simple",symbol:y(n.symbol,e,i),symbologyType:e.symbologyType}}d=n&&n.labelsVisible&&n.labelingInfo||[]}}_(t,l);return{labels:u(d,"binning"===n.type?"esriGeometryPolygon":a),matcher:o,fields:l,rendererOverride:f}}function A(t,i,n=!1){const s={indexCount:0,fields:{}},l="featureReduction"in t&&t.featureReduction,o=l?"aggregate":"feature";if("sublayers"in t){const i={type:"subtype",subtypeField:t.subtypeField,renderers:{},symbologyType:d.DEFAULT},l={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:l,mesh:{matcher:i,aggregateMatcher:null,labels:a,sortKey:null}},f=new Set;let p=0;for(const{renderer:d,subtypeCode:c,labelingInfo:y,labelsVisible:m}of t.sublayers){const t=E(d),u=$(s,o,d,t,n),g=q(s,o,d),b=m&&y;if("visualVariables"in d&&d.visualVariables&&d.visualVariables.length)throw new e(S,"Visual variables are currently not supported for subtype layers");if("dictionary"===u.type)throw new e(S,"Dictionary renderer is not supported in subtype layers");if("subtype"===u.type)throw new e(S,"Nested subtype renderers is not supported");if(r(g)&&"subtype"===g.type)throw new e(S,"Nested subtype storage is not supported");if(r(g)&&r(g.attributeMapping))throw new e(S,"Non-visual-variable attributes are not supported in subtype layers");if("heatmap"===u.type)throw new e(S,"Heatmaps are not supported in subtype layers");if("pie-chart"===u.type)throw new e(S,"Pie-charts are not supported in subtype layers");if(f.has(c))throw new e(S,"Subtype codes for sublayers must be unique");f.add(c),i.renderers[c]=u,l.mapping[c]=g,b&&(a.classes[c]=b.map((e=>k(s,e,"feature",p++,t,n))))}return u}if("heatmap"===t.renderer.type&&"raster"===g()){const{radius:e,fieldOffset:r,field:i}=t.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{radius:e,fieldOffset:r,field:U(s,{target:o,field:i,resultType:"numeric"}).field}}}const a=D(s,t,n),f=v(t.geometryType),p=a.rendererOverride??t.renderer,c=E(p,l),y=$(s,o,p,c,n),m=q(s,o,p),b=J(s,t.orderBy),x=t.labelsVisible&&t.labelingInfo||[],h=u(x,f);let T=0;const w=[...h.map((e=>k(s,e,"feature",T++,c,n))),...a.labels.map((e=>k(s,e,"aggregate",T++,c,n)))];return{type:"symbol",target:o,attributes:s,aggregateFields:a.fields,storage:m,mesh:{matcher:y,labels:{type:"simple",classes:w},aggregateMatcher:a.matcher,sortKey:b}}}function C(e){return"heatmap"===e.renderer?.type&&"raster"===g()?{type:"heatmap"}:{type:"symbol"}}function J(t,r){if(n(r)||!r.length)return null;r.length>1&&T.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],s="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:s};if(i.valueExpression){return{fieldIndex:B(t,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:s}}return T.error(new e(S,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function _(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,onStatisticField:n,onStatisticExpression:s,statisticType:l}=i;let o=null,a=null;const u="numeric",d="feature";if(s){a=B(e,{type:"expression",target:d,valueExpression:s.expression,resultType:u}).fieldIndex}else{o=B(e,{type:"field",target:d,field:n,resultType:u}).field}B(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:o,inFieldIndex:a,statisticType:l})}}function q(e,t,r){let i;switch(r.type){case"simple":case"class-breaks":case"unique-value":case"dictionary":i={visualVariables:!0,attributes:null};break;default:i=p(r).getStorageSpec(r)}return G(e,t,i,r)}function G(e,t,i,s){if(n(i))return null;const{visualVariables:l,attributes:o}=i;let a=null;l&&"visualVariables"in s&&(a=H(e,t,s.visualVariables));const u=r(a)?4:0;let d=null;return r(o)&&(d=o.map(((r,i)=>{const{field:n,fieldIndex:s}=U(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i+u,field:n,fieldIndex:s}}))),{type:"simple",target:t,attributeMapping:d,vvMapping:a}}function H(e,t,r){if(!r||!r.length)return[];const i={storage:!0},n="numeric";return b(r).map((r=>{const s=f(r.type),{field:l,fieldIndex:o}=U(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:r.valueRepresentation??null};case"color":return{type:"color",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:l,fieldIndex:o}}})).filter((e=>e))}function $(e,t,r,i,n=!1){const l=s(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return K(l,r,i,n);case"class-breaks":return Q(l,t,r,i,n);case"unique-value":return W(l,t,r,i,n);case"dictionary":return X(l,r,i,n);case"heatmap":return Z(l,r,i,n);case"pie-chart":return Y(l,r,i,n)}}function K(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"simple",symbol:y(s,r,i),symbologyType:r.symbologyType}}function Y(e,t,r,i=!1){const n=t.getSymbols(),s=n[0],l=n.length>1?n[1]:null;return{type:"pie-chart",markerSymbol:y(s,r,i),fillSymbol:y(l,r,i),symbologyType:r.symbologyType}}function Q(e,t,r,i,n=!1){const s={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:o,fieldIndex:a}=U(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:s}),u=r.normalizationType,d="log"===u?"esriNormalizeByLog":"percent-of-total"===u?"esriNormalizeByPercentOfTotal":"field"===u?"esriNormalizeByField":null,f=r.classBreakInfos.map((e=>({symbol:y(e.symbol,i,n),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:o,fieldIndex:a,backgroundFillSymbol:y(l,i,n),defaultSymbol:y(r.defaultSymbol,i,n),intervals:f,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:d,isMaxInclusive:r.isMaxInclusive,symbologyType:i.symbologyType}}function W(t,r,i,n,s=!1){const l=[],o=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new e(S,"Expected renderer.field to be a string",i);const{field:u,fieldIndex:d}=U(t,{...a,field:i.field,valueExpression:i.valueExpression});for(const e of i.uniqueValueInfos)l.push({value:""+e.value,symbol:y(e.symbol,n,s)});return{type:"map",attributes:t.fields,field:u,fieldIndex:d,field2:U(t,{...a,field:i.field2}).field,field3:U(t,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:y(o,n),defaultSymbol:y(i.defaultSymbol,n),map:l,symbologyType:n.symbologyType}}function X(e,t,r,i=!1){return{type:"dictionary",config:t.config,fieldMap:t.fieldMap,scaleExpression:t.scaleExpression,url:t.url,symbolOptions:r,symbologyType:r.symbologyType}}function Z(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"heatmap",symbol:y(s,r,i),symbologyType:r.symbologyType}}export{_ as addAggregateFields,$ as createMatcherSchema,U as createRendererAttributeSchema,F as createSchema,E as createSymbolSchemaOptions};
|
|
5
|
+
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as r,unwrap as i,isNone as n,unwrapOr as s}from"../../../../core/maybe.js";import{pt2px as l}from"../../../../core/screenUtils.js";import{sqlAnd as o}from"../../../../core/sql.js";import{diff as a}from"../../../../core/accessorSupport/diffUtils.js";import{validateLabelingInfo as u}from"../../../../layers/support/labelingInfo.js";import{WGLSymbologyType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{getTechniqueFromRenderer as p}from"../../engine/webgl/techniques/utils.js";import{getVVFlags as c}from"../../engine/webgl/util/vvFlagUtils.js";import{createSymbolSchema as y}from"./createSymbolSchema.js";export{createSymbolSchema}from"./createSymbolSchema.js";import{getPtMaxVVSize as m}from"./support/pixelBuffering.js";import{getSupportedHeatmapRenderer as g,simplifyVisualVariables as b}from"./support/rendererUtils.js";import{injectDynamicLevelDependentSizeVisualVariable as x,createClusterRenderer as h}from"../support/clusterUtils.js";import{toJSONGeometryType as v}from"../support/util.js";const T=t.getLogger("esri.views.2d.layers.features.schemaUtils"),S="ValidationError";function E(e){return e}function w(e,t){let i=0,n=0,s=d.DEFAULT;if(r(e)){if(n=m(e,t),"visualVariables"in e&&(i=c(e.visualVariables||[]),"dot-density"===e.type&&(s=d.DOT_DENSITY)),"heatmap"===e.type&&(s=d.HEATMAP),"dictionary"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.DEFAULT};if("pie-chart"===e.type)return{maxVVSize:n,vvFlags:i,symbologyType:d.PIE_CHART};if(s!==d.DOT_DENSITY&&s!==d.HEATMAP){const t=e.getSymbols();"backgroundFillSymbol"in e&&e.backgroundFillSymbol&&t.push(e.backgroundFillSymbol);let r=!0,i=!0;for(const e of t)if("cim"===e.type&&(i=!1),"simple-fill"===e.type||"picture-fill"===e.type){const t=e.outline,n=t&&"none"!==t.style&&"solid"!==t.style,s="simple-fill"===e.type&&"none"!==e.style&&"solid"!==e.style,l="picture-fill"===e.type||s||n;n&&(r=!1),l&&(i=!1)}r?s=i?d.OUTLINE_FILL_SIMPLE:d.OUTLINE_FILL:i&&(s=d.SIMPLE)}}return{vvFlags:i,maxVVSize:n,symbologyType:s}}let I=null;function F(e){if(has("esri-2d-update-debug")){const t=V(e,!0);console.debug("Created new schema",t),console.debug("Schema diff",a(I,t)),I=t}return V(e)}function V(e,t=!1){try{const i=D(e,t),n=C(e),s={};i.map((t=>O(s,e,t)));const l=r(e.subtypeCode)?`${e.subtypeField} = ${e.subtypeCode}`:null,a=o(e.definitionExpression,l);return{source:{definitionExpression:a,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:e.historicMoment?.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:e.timeExtent?.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:i,tileRenderer:n,targets:s}}catch(i){if(i.fieldName===S)return T.error(i),null;throw i}}function O(t,r,i){switch(i.target){case"feature":return void M(t,N(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;switch(n.type){case"selection":throw new e(S,"Mapview does not support `selection` reduction type",n);case"binning":return M(t,N(r),i),void L(t,n,r.fields.map((e=>e.toJSON())),i);case"cluster":return M(t,N(r),i),void R(t,n,r.fields.map((e=>e.toJSON())),i)}}}}function z(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function N(e){return[i(e.filter)?.toJSON()??null,i(i(e.featureEffect)?.filter)?.toJSON()??null]}function M(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),z(e.feature,r.attributes.fields),e}function j(t,r){const{onStatisticExpression:i,onStatisticField:n,statisticType:s}=t;switch(s){case"min":case"max":case"avg":case"avg_angle":case"sum":case"count":return"esriFieldTypeDouble";case"mode":{if(i){const{returnType:r}=i;return r?"string"===r?"esriFieldTypeString":"esriFieldTypeDouble":(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}const s=r.find((e=>e.name===n));return s?s.type:(T.error(new e(S,"Unable to infer type of aggregateField with onStatisticExpression. ReturnType is not defined",t)),"esriFieldTypeString")}}}function L(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"bin",filters:null,input:"feature",params:{fixedBinLevel:t.fixedBinLevel,fields:(t.fields??[]).map((e=>({...e.toJSON(),type:j(e,r)})))},attributes:{}}),z(e.aggregate,i.attributes.fields),e}function R(e,t,r,i){return e.aggregate||(e.aggregate={name:"aggregate",type:"cluster",input:"feature",filters:null,attributes:{},params:{clusterRadius:l(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(l(t.clusterMaxSize)/64),fields:(t.fields??[])?.map((e=>({...e.toJSON(),type:j(e,r)})))}}),z(e.aggregate,i.attributes.fields),e}function U(e,t){return t.field?B(e,{...t,type:"field",field:t.field}):t.valueExpression?B(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function B(e,t){switch(t.type){case"expression":{const r=E(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=E(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function D(e,t=!1){const r=new Array;let i=0;return r.push(A(e,i++,t)),r}function P(e,t,r,i,n,s=!1){const l=B(e,{type:"label-expression",target:r,context:{mesh:!0},resultType:"string",label:{labelExpression:t.labelExpression,labelExpressionInfo:t.labelExpressionInfo?{expression:t.labelExpressionInfo.expression}:null,symbol:!!t.symbol,where:t.where}}),{fieldIndex:o}=l;return{...y(t,n,s),fieldIndex:o,target:r,index:i}}function k(t,r,i){const n="featureReduction"in r&&r.featureReduction;if(!n)return{fields:[],labels:[],matcher:null,rendererOverride:null};const s="aggregate",l=[];let o=null,a=v(r.geometryType),d=[],f=null;if(n)switch(n.type){case"selection":return T.error(new e(S,"Mapview does not support `selection` reduction type",n)),{fields:[],labels:[],matcher:null,rendererOverride:null};case"cluster":case"binning":if(l.push(...n.fields??[]),"cluster"===n.type?a="esriGeometryPoint":"binning"===n.type&&(a="esriGeometryPolygon"),n.renderer&&!n.renderer.authoringInfo?.isAutoGenerated){if("cluster"===n.type){const{renderer:e}=x(n.renderer,n,null);f=e}else f=n.renderer;const e=w(n.renderer,n);o=$(null,s,n.renderer,e,i),d=n&&n.labelsVisible&&n.labelingInfo||[]}else if("cluster"===n.type){if(f=h(l,r.renderer,n,null,!0),n.symbol){const e=w(f,n);o={type:"simple",symbol:y(n.symbol,e,i),symbologyType:e.symbologyType}}d=n&&n.labelsVisible&&n.labelingInfo||[]}}_(t,l);return{labels:u(d,"binning"===n.type?"esriGeometryPolygon":a),matcher:o,fields:l,rendererOverride:f}}function A(t,i,n=!1){const s={indexCount:0,fields:{}},l="featureReduction"in t&&t.featureReduction,o=l?"aggregate":"feature";if("sublayers"in t){const i={type:"subtype",subtypeField:t.subtypeField,renderers:{},symbologyType:d.DEFAULT},l={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:l,mesh:{matcher:i,aggregateMatcher:null,labels:a,sortKey:null}},f=new Set;let p=0;for(const{renderer:c,subtypeCode:y,labelingInfo:m,labelsVisible:g}of t.sublayers){const t={symbologyType:d.DEFAULT,vvFlags:0,maxVVSize:0},u=$(s,o,c,t,n),b=q(s,o,c),x=g&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new e(S,"Visual variables are currently not supported for subtype layers");if("dictionary"===u.type)throw new e(S,"Dictionary renderer is not supported in subtype layers");if("subtype"===u.type)throw new e(S,"Nested subtype renderers is not supported");if(r(b)&&"subtype"===b.type)throw new e(S,"Nested subtype storage is not supported");if(r(b)&&r(b.attributeMapping))throw new e(S,"Non-visual-variable attributes are not supported in subtype layers");if("heatmap"===u.type)throw new e(S,"Heatmaps are not supported in subtype layers");if("pie-chart"===u.type)throw new e(S,"Pie-charts are not supported in subtype layers");if(f.has(y))throw new e(S,"Subtype codes for sublayers must be unique");f.add(y),i.renderers[y]=u,l.mapping[y]=b,x&&(a.classes[y]=x.map((e=>P(s,e,"feature",p++,t,n))))}return u}if("heatmap"===t.renderer.type&&"raster"===g()){const{radius:e,fieldOffset:r,field:i}=t.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{radius:e,fieldOffset:r,field:U(s,{target:o,field:i,resultType:"numeric"}).field}}}const a=k(s,t,n),f=v(t.geometryType),p=a.rendererOverride??t.renderer,c=w(p,l),y=$(s,o,p,c,n),m=q(s,o,p),b=J(s,t.orderBy),x=t.labelsVisible&&t.labelingInfo||[],h=u(x,f);let T=0;const E=[...h.map((e=>P(s,e,"feature",T++,c,n))),...a.labels.map((e=>P(s,e,"aggregate",T++,c,n)))];return{type:"symbol",target:o,attributes:s,aggregateFields:a.fields,storage:m,mesh:{matcher:y,labels:{type:"simple",classes:E},aggregateMatcher:a.matcher,sortKey:b}}}function C(e){return"heatmap"===e.renderer?.type&&"raster"===g()?{type:"heatmap"}:{type:"symbol"}}function J(t,r){if(n(r)||!r.length)return null;r.length>1&&T.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],s="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:s};if(i.valueExpression){return{fieldIndex:B(t,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:s}}return T.error(new e(S,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function _(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,onStatisticField:n,onStatisticExpression:s,statisticType:l}=i;let o=null,a=null;const u="numeric",d="feature";if(s){a=B(e,{type:"expression",target:d,valueExpression:s.expression,resultType:u}).fieldIndex}else{o=B(e,{type:"field",target:d,field:n,resultType:u}).field}B(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:o,inFieldIndex:a,statisticType:l})}}function q(e,t,r){let i;switch(r.type){case"simple":case"class-breaks":case"unique-value":case"dictionary":i={visualVariables:!0,attributes:null};break;default:i=p(r).getStorageSpec(r)}return G(e,t,i,r)}function G(e,t,i,s){if(n(i))return null;const{visualVariables:l,attributes:o}=i;let a=null;l&&"visualVariables"in s&&(a=H(e,t,s.visualVariables));const u=r(a)?4:0;let d=null;return r(o)&&(d=o.map(((r,i)=>{const{field:n,fieldIndex:s}=U(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i+u,field:n,fieldIndex:s}}))),{type:"simple",target:t,attributeMapping:d,vvMapping:a}}function H(e,t,r){if(!r||!r.length)return[];const i={storage:!0},n="numeric";return b(r).map((r=>{const s=f(r.type),{field:l,fieldIndex:o}=U(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:r.valueRepresentation??null};case"color":return{type:"color",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:l,fieldIndex:o,normalizationField:U(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:l,fieldIndex:o}}})).filter((e=>e))}function $(e,t,r,i,n=!1){const l=s(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return K(l,r,i,n);case"class-breaks":return Q(l,t,r,i,n);case"unique-value":return W(l,t,r,i,n);case"dictionary":return X(l,r,i,n);case"heatmap":return Z(l,r,i,n);case"pie-chart":return Y(l,r,i,n)}}function K(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"simple",symbol:y(s,r,i),symbologyType:r.symbologyType}}function Y(e,t,r,i=!1){const n=t.getSymbols(),s=n[0],l=n.length>1?n[1]:null;return{type:"pie-chart",markerSymbol:y(s,r,i),fillSymbol:y(l,r,i),symbologyType:r.symbologyType}}function Q(e,t,r,i,n=!1){const s={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:o,fieldIndex:a}=U(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:s}),u=r.normalizationType,d="log"===u?"esriNormalizeByLog":"percent-of-total"===u?"esriNormalizeByPercentOfTotal":"field"===u?"esriNormalizeByField":null,f=r.classBreakInfos.map((e=>({symbol:y(e.symbol,i,n),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:o,fieldIndex:a,backgroundFillSymbol:y(l,i,n),defaultSymbol:y(r.defaultSymbol,i,n),intervals:f,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:d,isMaxInclusive:r.isMaxInclusive,symbologyType:i.symbologyType}}function W(t,r,i,n,s=!1){const l=[],o=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new e(S,"Expected renderer.field to be a string",i);const{field:u,fieldIndex:d}=U(t,{...a,field:i.field,valueExpression:i.valueExpression});for(const e of i.uniqueValueInfos)l.push({value:""+e.value,symbol:y(e.symbol,n,s)});return{type:"map",attributes:t.fields,field:u,fieldIndex:d,field2:U(t,{...a,field:i.field2}).field,field3:U(t,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:y(o,n),defaultSymbol:y(i.defaultSymbol,n),map:l,symbologyType:n.symbologyType}}function X(e,t,r,i=!1){return{type:"dictionary",config:t.config,fieldMap:t.fieldMap,scaleExpression:t.scaleExpression,url:t.url,symbolOptions:r,symbologyType:r.symbologyType}}function Z(e,t,r,i=!1){const n=t.getSymbols(),s=n.length?n[0]:null;return{type:"heatmap",symbol:y(s,r,i),symbologyType:r.symbologyType}}export{_ as addAggregateFields,$ as createMatcherSchema,U as createRendererAttributeSchema,F as createSchema,w as createSymbolSchemaOptions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../core/Collection.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../core/Collection.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{watch as r,initial as a}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import n from"../LayerList/ListItem.js";const m={view:"view",basemap:"basemap",baseLayers:"base-layers",referenceLayers:"reference-layers",baseLayersListMode:"reference-layers-list-mode",referenceLayersListMode:"base-layers-list-mode",baseLayerViews:"base-layer-views",referenceLayerViews:"reference-layer-views",children:"children"},l=s.ofType(n);let h=class extends(i(t.EventedAccessor)){constructor(e){super(e),this.baseItems=new l,this.baseListItemCreatedFunction=null,this.checkPublishStatusEnabled=!1,this.referenceListItemCreatedFunction=null,this.referenceItems=new l,this.view=null,this._compileBaseList=this._compileBaseList.bind(this),this._compileReferenceList=this._compileReferenceList.bind(this)}initialize(){this.handles.add([r((()=>[this.view?.map?.basemap,this.view,this.view?.ready,this.view?.basemapView]),(()=>this._watchBasemapLayers()),a),r((()=>[this.baseListItemCreatedFunction,this.checkPublishStatusEnabled]),(()=>this._baseListItemCreatedFunctionChanged())),r((()=>[this.referenceListItemCreatedFunction,this.checkPublishStatusEnabled]),(()=>this._referenceListItemCreatedFunctionChanged()))],m.view)}destroy(){this.view=null,this.baseItems.removeAll(),this.referenceItems.removeAll()}get basemapTitle(){return this.view?.map?.basemap?.title??null}set basemapTitle(e){this._override("basemapTitle",e)}get state(){return this.get("view.ready")?"ready":this.get("view")?"loading":"disabled"}triggerAction(e,s){e&&!e.disabled&&this.emit("trigger-action",{action:e,item:s})}transferListItem({listItem:e,from:s,to:t,newIndex:i}){const{referenceItems:r,baseItems:a}=this,{layer:c}=e,o=this.get("view.map.basemap.baseLayers"),n=this.get("view.map.basemap.referenceLayers");if(!o||!n||s===t)return;const m="reference"===t?r:a,l="reference"===s?n:o,h="reference"===t?n:o;("reference"===s?r:a).remove(e),l.remove(c),m.add(e,i),h.add(c,i)}_createItemChangeHandles({items:e,key:s,callback:t}){const{handles:i}=this;i.remove(s),t(),e&&i.add(e.on("change",(()=>t())),s)}_createListItem({layer:e,type:s}){const{view:t,baseListItemCreatedFunction:i,referenceListItemCreatedFunction:r,checkPublishStatusEnabled:a}=this;return new n({layer:e,checkPublishStatusEnabled:a,listItemCreatedFunction:"base"===s?i:r,view:t})}_watchLayersListMode({layers:e,key:s,callback:t}){const{handles:i}=this;i.remove(s),e&&e.forEach((e=>{i.add(r((()=>e.listMode),(()=>t())),s)}))}_compileListItems({layers:e,items:s,key:t,type:i,callback:r}){this._watchLayersListMode({layers:e,key:t,callback:r}),this._createNewItems({type:i,items:s,layers:e}),this._removeItems({items:s,layers:e}),this._sortItems(s,e)}_compileReferenceList(){const{referenceItems:e}=this,s=this.get("view.map.basemap.referenceLayers");this._compileListItems({type:"reference",layers:s,items:e,key:m.referenceLayersListMode,callback:this._compileReferenceList})}_compileBaseList(){const{baseItems:e}=this,s=this.get("view.map.basemap.baseLayers");this._compileListItems({type:"base",layers:s,items:e,key:m.baseLayersListMode,callback:this._compileBaseList})}_compileLists(){this._compileReferenceList(),this._compileBaseList()}_createNewItems({items:e,layers:s,type:t}){s&&s.forEach((s=>{e.find((e=>e.layer===s))||e.add(this._createListItem({type:t,layer:s}))}))}_removeItems({items:e,layers:s}){const{handles:t}=this;e&&e.forEach((i=>{if(!i)return;s&&s.find((e=>i.layer===e))||(t.remove(`${m.children}-${i.uid}`),e.remove(i))}))}_sortItems(e,s){e&&e.sort(((e,t)=>{const i=s.indexOf(e.layer),r=s.indexOf(t.layer);return i>r?-1:i<r?1:0}))}_removeAllBaseItems(){const{handles:e,baseItems:s}=this;s.forEach((s=>{e.remove(`${m.children}-${s.uid}`)})),s.removeAll()}_removeAllReferenceItems(){const{handles:e,referenceItems:s}=this;s.forEach((s=>{e.remove(`${m.children}-${s.uid}`)})),s.removeAll()}_baseListItemCreatedFunctionChanged(){this._removeAllBaseItems(),this._compileLists()}_referenceListItemCreatedFunctionChanged(){this._removeAllReferenceItems(),this._compileLists()}_watchBasemapLayers(){const{handles:e,view:s}=this;e.remove([m.baseLayers,m.referenceLayers,m.basemap,m.baseLayerViews,m.referenceLayerViews]),this._compileLists(),s&&s.ready&&e.add([r((()=>this.view?.map?.basemap?.baseLayers),(e=>this._createItemChangeHandles({items:e,key:m.baseLayers,callback:this._compileBaseList})),a),r((()=>this.view?.map?.basemap?.referenceLayers),(e=>this._createItemChangeHandles({items:e,key:m.referenceLayers,callback:this._compileReferenceList})),a),r((()=>this.view?.basemapView?.baseLayerViews),(e=>this._createItemChangeHandles({items:e,key:m.baseLayerViews,callback:this._compileBaseList})),a),r((()=>this.view?.basemapView?.referenceLayerViews),(e=>this._createItemChangeHandles({items:e,key:m.referenceLayerViews,callback:this._compileReferenceList})),a)],m.basemap)}};e([c({type:l,readOnly:!0})],h.prototype,"baseItems",void 0),e([c()],h.prototype,"basemapTitle",null),e([c()],h.prototype,"baseListItemCreatedFunction",void 0),e([c()],h.prototype,"checkPublishStatusEnabled",void 0),e([c()],h.prototype,"referenceListItemCreatedFunction",void 0),e([c({type:l,readOnly:!0})],h.prototype,"referenceItems",void 0),e([c({readOnly:!0})],h.prototype,"state",null),e([c()],h.prototype,"view",void 0),e([c()],h.prototype,"transferListItem",null),h=e([o("esri.widgets.BasemapLayerList.BasemapLayerListViewModel")],h);const d=h;export{d as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import has from"../core/has.js";import{watch as n,on as r,initial as a}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import c from"./Widget.js";import m from"./BasemapLayerList/BasemapLayerListViewModel.js";import h from"./LayerList/ListItem.js";import{findSelectedItem as u}from"./LayerList/support/layerListUtils.js";import{Heading as g,incrementHeadingLevel as p}from"./support/Heading.js";import{accessibleHandler as b}from"./support/decorators/accessibleHandler.js";import{messageBundle as _}from"./support/decorators/messageBundle.js";import{vmEvent as y}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import I from"sortablejs";const v=t.ofType(h);function L(e,t,i){e.splice(i,0,e.splice(t,1)[0])}const C=".*\\S+.*",T="esri-basemaplayerlist-new-ui",w="root-layers",A="data-layer-uid",S="layerUid",E={base:"esri-basemap-layer-list esri-widget esri-widget--panel",newUI:"esri-basemap-layer-list--new-ui",titleContainer:"esri-basemap-layer-list__title-container",mainHeading:"esri-basemap-layer-list__main-heading",editingCard:"esri-basemap-layer-list__editing-card",editingInput:"esri-basemap-layer-list__editing-input",editingActions:"esri-basemap-layer-list__editing-actions",editButton:"esri-basemap-layer-list__edit-button",editButtonIcon:"esri-basemap-layer-list__edit-button-icon",submitButton:"esri-basemap-layer-list__submit-button",cancelButton:"esri-basemap-layer-list__cancel-button",noItems:"esri-basemap-layer-list__no-items",horizontalRule:"esri-basemap-layer-list__hr",listHeading:"esri-basemap-layer-list__list-heading",list:"esri-basemap-layer-list__list",listRoot:"esri-basemap-layer-list__list--root",listExclusive:"esri-basemap-layer-list__list--exclusive",listInherited:"esri-basemap-layer-list__list--inherited",listIndependent:"esri-basemap-layer-list__list--independent",item:"esri-basemap-layer-list__item",itemOnlyChild:"esri-basemap-layer-list__item--only-child",itemContent:"esri-basemap-layer-list__item-content",itemMessage:"esri-basemap-layer-list__item--has-message",itemInvisible:"esri-basemap-layer-list__item--invisible",itemInvisibleAtScale:"esri-basemap-layer-list__item--invisible-at-scale",itemUpdating:"esri-basemap-layer-list__item--updating",itemChildren:"esri-basemap-layer-list__item--has-children",itemSelectable:"esri-basemap-layer-list__item--selectable",itemContainer:"esri-basemap-layer-list__item-container",actionsMenu:"esri-basemap-layer-list__item-actions-menu",actionsMenuItem:"esri-basemap-layer-list__item-actions-menu-item",actionsMenuItemActive:"esri-basemap-layer-list__item-actions-menu-item--active",actions:"esri-basemap-layer-list__item-actions",actionsList:"esri-basemap-layer-list__item-actions-list",action:"esri-basemap-layer-list__item-action",actionIcon:"esri-basemap-layer-list__item-action-icon",actionImage:"esri-basemap-layer-list__item-action-image",actionTitle:"esri-basemap-layer-list__item-action-title",actionToggle:"esri-basemap-layer-list__action-toggle",actionToggleOn:"esri-basemap-layer-list__action-toggle--on",label:"esri-basemap-layer-list__item-label",message:"esri-basemap-layer-list__item-message",title:"esri-basemap-layer-list__item-title",connectionStatus:"esri-basemap-layer-list__connection-status",connectionStatusDisconnected:"esri-basemap-layer-list__connection-status--disconnected",connectionStatusConnected:"esri-basemap-layer-list__connection-status--connected",toggleVisible:"esri-basemap-layer-list__item-toggle",toggleVisibleIcon:"esri-basemap-layer-list__item-toggle-icon",toggleIcon:"esri-basemap-layer-list__item-toggle-icon",radioIcon:"esri-basemap-layer-list__item-radio-icon",childToggle:"esri-basemap-layer-list__child-toggle",childToggleOpen:"esri-basemap-layer-list__child-toggle--open",childOpened:"esri-basemap-layer-list__child-toggle-icon--opened",childClosed:"esri-basemap-layer-list__child-toggle-icon--closed",childClosed_RTL:"esri-basemap-layer-list__child-toggle-icon--closed-rtl",sortableChosen:"esri-basemap-layer-list--chosen",button:"esri-button",buttonTertiary:"esri-button--tertiary",input:"esri-input",disabled:"esri-disabled",disabledElement:"esri-disabled-element",hidden:"esri-hidden",rotating:"esri-rotating",heading:"esri-widget__heading",iconEdit:"esri-icon-edit",iconCheckMark:"esri-icon-check-mark",iconClose:"esri-icon-close",iconEllipses:"esri-icon-handle-horizontal",iconVisible:"esri-icon-visible",iconInvisible:"esri-icon-non-visible",iconRadioSelected:"esri-icon-radio-checked",iconRadioUnselected:"esri-icon-radio-unchecked",iconNoticeTriangle:"esri-icon-notice-triangle",iconChildrenOpen:"esri-icon-down-arrow",iconDownArrow:"esri-icon-down-arrow",iconRightArrow:"esri-icon-right-triangle-arrow",iconLeftArrow:"esri-icon-left-triangle-arrow",iconLoading:"esri-icon-loading-indicator",iconDefaultAction:"esri-icon-default-action",widgetIcon:"esri-icon-layers"},k={actions:"actions",actionSection:"action-section",baseItems:"base-items",referenceItems:"reference-items"},R={exclusive:"exclusive",inherited:"inherited",independent:"independent"};function M(e){const{actionsOpen:t,children:i}=e;t&&(e.actionsOpen=!1),i.forEach((e=>M(e)))}const B={baseLayers:!0,referenceLayers:!0,statusIndicators:!0,errors:!1};let O=class extends(s(c)){constructor(e,t){super(e,t),this._tooltipReferenceMap=new Map,this._editingTitle=!1,this._editTitleInput=null,this._editTitleButton=null,this._focusOnElement=null,this._sortableBaseLayers=null,this._sortableReferenceLayers=null,this._sortableBaseLayersNode=null,this._sortableReferenceLayersNode=null,this._focusSortUid=null,this._newUI=has(T),this.visibleItems=null,this.editingEnabled=!1,this.headingLevel=2,this.iconClass=E.widgetIcon,this.messages=null,this.messagesCommon=null,this.multipleSelectionEnabled=!1,this.selectedItems=new v,this.viewModel=new m,this.visibleElements={...B}}initialize(){const{baseItems:e,referenceItems:t}=this;this._setVisibleItems(),this.addHandles([n((()=>this.visibleElements),(()=>{this._itemsChanged(e,k.baseItems),this._itemsChanged(t,k.referenceItems)})),r((()=>this.baseItems),"change",(()=>{this._itemsChanged(e,k.baseItems)})),r((()=>this.referenceItems),"change",(()=>this._itemsChanged(t,k.referenceItems))),n((()=>this.editingEnabled),(()=>this._toggleSorting()),a)])}loadDependencies(){return import("@esri/calcite-components/dist/components/calcite-tooltip.js")}destroy(){this._destroyBaseSortable(),this._destroyReferenceSortable(),this._tooltipReferenceMap.clear()}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...B,...e}}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[E.newUI]:this._newUI,[E.hidden]:"loading"===e,[E.disabled]:"disabled"===e},i=this.renderItemTooltips(),s=this.renderReferenceSection(),n=this.renderBaseSection(),r=s&&n?f("hr",{class:E.horizontalRule}):null,a=[this.renderTitleContainer(),s,r,n];return f("div",{class:this.classes(E.base,t)},[i,a])}renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?f("calcite-tooltip",{label:i.layerIncompatible,referenceElement:t.get(e.uid)},i.layerIncompatibleTooltip):null}renderItemTooltipNodes(e){const{incompatible:t,children:i}=e;return[t?this.renderItemTooltip(e):null,...t?[]:i?.toArray().map((e=>this.renderItemTooltipNodes(e)))]}renderItemTooltips(){return this.visibleItems.toArray().map((e=>this.renderItemTooltipNodes(e)))}renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return f("label",{class:E.editingInput},e.basemapTitle,f("input",{bind:this,class:E.input,title:e.basemapTitle,"aria-label":e.basemapTitle,placeholder:e.basemapTitle,type:"text",role:"textbox",required:!0,pattern:C,value:t,afterCreate:this._storeEditTitleInput,afterUpdate:this._focusEditElement}))}renderCancelButton(){const{messagesCommon:e}=this;return f("button",{title:e.cancel,"aria-label":e.cancel,type:"button",bind:this,class:this.classes(E.button,E.buttonTertiary),onclick:this._toggleEditingTitle},e.cancel)}renderSubmitButton(){const{messagesCommon:e}=this;return f("button",{title:e.form.submit,"aria-label":e.form.submit,type:"submit",bind:this,class:E.button},e.form.ok)}renderEditingForm(){return f("div",{class:E.editingCard},f("form",{bind:this,onsubmit:this._formSubmit},this.renderEditingInput(),f("div",{class:E.editingActions},this.renderCancelButton(),this.renderSubmitButton())))}renderBasemapTitle(){const{basemapTitle:e}=this.viewModel;return f(g,{level:this.headingLevel,class:this.classes(E.heading,E.mainHeading)},e)}renderEditTitleButton(){const{_editingTitle:e,editingEnabled:t,messagesCommon:i}=this;return t&&!e?f("button",{bind:this,class:E.editButton,title:i.edit,"aria-label":i.edit,onclick:this._toggleEditingTitle,afterCreate:this._storeEditTitleButton,afterUpdate:this._focusEditElement,"data-node-ref":"_editButtonNode",type:"button"},f("span",{"aria-hidden":"true",class:this.classes(E.iconEdit,E.editButtonIcon)})):null}renderTitleContainer(){return f("div",{class:E.titleContainer},this._editingTitle?this.renderEditingForm():this.renderBasemapTitle(),this.renderEditTitleButton())}renderNoLayersInfo(e,t){return f("div",{key:t,class:E.noItems},e)}renderList(e,t){const{messages:i}=this,s="reference"===t?this._destroyReferenceSortable:this._destroyBaseSortable;return f("ul",{key:t,"aria-label":i.widgetLabel,role:this.editingEnabled&&e.length?"listbox":void 0,afterCreate:this._sortNodeCreated,afterRemoved:s,"data-node-ref":t,bind:this,class:this.classes(E.list,E.listRoot,E.listIndependent)},e.map((i=>this.renderItem({item:i,parent:null,itemType:t,isOnlyChild:1===e.length}))))}renderBaseHeader(){return f(g,{key:"base-heading",level:p(this.headingLevel),class:this.classes(E.heading,E.listHeading)},this.messages.baseHeading)}renderBaseSection(){const{baseItems:e,messages:t,visibleElements:i}=this;if(!i.baseLayers)return null;const s=this._getItems(e),n="base";return[this.renderBaseHeader(),[0===s.length?this.renderNoLayersInfo(t.noBaseLayers,n):null,this.renderList(s,n)]]}renderReferenceHeader(){return f(g,{key:"reference-heading",level:p(this.headingLevel),class:this.classes(E.heading,E.listHeading)},this.messages.referenceHeading)}renderReferenceSection(){const{referenceItems:e,messages:t,visibleElements:i}=this;if(!i.referenceLayers)return null;const s=this._getItems(e),n="reference";return[this.renderReferenceHeader(),[0===s.length?this.renderNoLayersInfo(t.noReferenceLayers,n):null,this.renderList(s,n)]]}renderChildrenToggle(e,t){const{messagesCommon:i}=this,{children:s}=e,n=!!e.error,r=!!s.length&&!n,a={[E.childToggleOpen]:e.open},o=e.open?i.collapse:i.expand;return r?f("span",{onclick:this._toggleChildrenClick,onkeydown:this._toggleChildrenClick,"data-item":e,key:"toggle-children",class:this.classes(E.childToggle,a),tabindex:"0",role:"button","aria-controls":t,"aria-label":o,title:o},f("span",{"aria-hidden":"true",class:this.classes(E.childClosed,E.iconRightArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childOpened,E.iconDownArrow)}),f("span",{"aria-hidden":"true",class:this.classes(E.childClosed_RTL,E.iconLeftArrow)})):null}renderItemMessage(e){return e.error?f("div",{key:"esri-basemap-layer-list__error",class:E.message,role:"alert"},f("span",{"aria-hidden":"true",class:E.iconNoticeTriangle}),this.messages.layerError):e.incompatible?f("div",{key:"esri-basemap-layer-list__incompatible",class:E.message,role:"alert"},f("span",{bind:this,tabIndex:0,"aria-hidden":"true",class:E.iconNoticeTriangle,afterCreate:t=>this._setTooltipReference(t,e)}),this.messages.layerIncompatible):null}renderActionsMenuIcon(e,t){const{messagesCommon:i}=this,s={[E.actionsMenuItemActive]:e.actionsOpen};return f("div",{key:"actions-menu-toggle","data-item":e,bind:this,onclick:this._toggleActionsOpen,onkeydown:this._toggleActionsOpen,class:this.classes(E.actionsMenuItem,s),tabindex:"0",role:"button","aria-controls":t,"aria-label":i.options,title:i.options},f("span",{"aria-hidden":"true",class:E.iconEllipses}))}renderActionsMenu(e,t,i,s){const{panel:n}=e,r=n&&n.visible?this.renderPanelButton(n):null,a=1===i&&this._getSingleActionButton(t),o=a?this.renderAction({item:e,action:a,singleAction:!0}):null,l=!a&&i?this.renderActionsMenuIcon(e,s):null;return l||r||a?f("div",{key:"actions-menu",class:E.actionsMenu},r,o,l):null}renderChildList(e,t){const{editingEnabled:i}=this,{visibilityMode:s,children:n}=e,r=this._hasChildren(e),a=!r&&i&&"group"===e.layer?.type,{exclusive:o,inherited:l}=R,d={[E.listExclusive]:s===o,[E.listInherited]:s===l,[E.listIndependent]:s!==l&&s!==o};return r||a?f("ul",{bind:this,key:"list-items",id:t,"data-group":e.uid,"data-item":e,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,class:this.classes(E.list,d),"aria-expanded":e.open?"true":"false",role:i?"listbox":s===o?"radiogroup":"group",hidden:!e.open||null},n?.map((t=>this.renderItem({item:t,parent:e}))).toArray()):null}renderItemContent(e,t,i){const{id:s}=this,n=`${s}_${e.uid}`,r=`${n}_actions`,a=`${n}__list`,{panel:o}=e,l=this._filterActions(e.actionsSections),d=this._countActions(l);return[f("div",{key:"list-item-container",class:E.itemContainer},this.renderChildrenToggle(e,a),this.renderLabel(e,t,i),this.renderActionsMenu(e,l,d,r)),this.renderItemMessage(e),d?this.renderActionsSections(e,l,r):null,o&&o.open&&!o.disabled?o.render():null,this.renderChildList(e,a)]}renderItem({item:e,parent:t,itemType:i,isOnlyChild:s}){const{_newUI:n,id:r,editingEnabled:a,selectedItems:o,visibleElements:l}=this,d=`${`${r}_${e.uid}`}__title`,c=this._hasMessage(e),m=this._hasChildren(e),h={[E.itemChildren]:m,[E.itemMessage]:!!c,[E.itemUpdating]:e.updating&&!t&&l.statusIndicators,[E.itemInvisible]:n&&!e.visible,[E.itemInvisibleAtScale]:!e.visibleAtCurrentScale,[E.itemSelectable]:a};if(a){const n={[A]:e.layer?.uid};return f("li",{key:`item-with-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,h,{[E.itemOnlyChild]:s}),"aria-labelledby":d,onclick:this._toggleSelection,onkeydown:this._selectionKeydown,"data-item-type":i,"data-item":e,tabIndex:0,"aria-selected":u(e,o)?"true":"false",role:"option",...n},this.renderItemContent(e,t,d))}return f("li",{key:`item-no-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(E.item,h),"aria-labelledby":d},this.renderItemContent(e,t,d))}renderItemConnectionStatus(e){const{connectionStatus:t}=e;return t?f("span",{class:this.classes({[E.connectionStatus]:!0,[E.connectionStatusDisconnected]:"disconnected"===t,[E.connectionStatusConnected]:"connected"===t}),key:"layer-connection-status"}):null}renderItemTitle(e,t){const{messages:i}=this,s=e.title||i.untitledLayer,n=e.visibleAtCurrentScale?s:`${s} (${i.layerInvisibleAtScale})`;return f("span",{key:"layer-title-container",id:t,title:n,"aria-label":n,class:E.title},s)}renderItemToggleIcon(e,t){const{_newUI:i}=this,{exclusive:s}=R,n=t&&t.visibilityMode,r={[E.toggleVisibleIcon]:i,[E.toggleIcon]:i&&n!==s,[E.radioIcon]:i&&n===s,[E.iconRadioSelected]:n===s&&e.visible,[E.iconRadioUnselected]:n===s&&!e.visible,[E.iconVisible]:n!==s&&e.visible,[E.iconInvisible]:n!==s&&!e.visible};return f("span",{key:"item-toggle-icon",class:this.classes(r),"aria-hidden":"true"})}renderItemToggle(e,t,i){const{editingEnabled:s,messages:n}=this,{exclusive:r}=R,a=t&&t.visibilityMode,o=a===r?"radio":"switch";return f("span",s?{key:"item-toggle-selection-enabled",class:E.toggleVisible,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":a,tabIndex:0,"aria-checked":e.visible?"true":"false",title:e.visible?n.hideLayer:n.showLayer,role:o,"aria-labelledby":i}:{key:"item-toggle",class:E.toggleVisible},this.renderItemToggleIcon(e,t))}renderLabel(e,t,i){const{editingEnabled:s,_newUI:n,messages:r}=this,{inherited:a,exclusive:o}=R,l=t?.visibilityMode,d=l===o?"radio":"switch",c=[this.renderItemToggle(e,t,i),this.renderItemConnectionStatus(e),this.renderItemTitle(e,i)];n&&c.reverse();const m=f("div",s?{key:`item-label-no-selection-${e.uid}`,class:E.label}:{key:`item-label-with-selection-${e.uid}`,class:E.label,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":l,tabIndex:0,title:e.visible?r.hideLayer:r.showLayer,"aria-checked":e.visible?"true":"false",role:d,"aria-labelledby":i},c);return l===a||e.error?f("div",{key:`item-label-container-${e.uid}`,class:E.label},this.renderItemTitle(e,i)):m}renderPanelButton(e){const{className:t,open:i,title:s,image:n}=e,r=n||t?t:E.iconDefaultAction,a=this._getIconImageStyles(e),o={[E.actionsMenuItemActive]:i},l={[E.actionImage]:!!a["background-image"],[E.disabledElement]:e.disabled};return r&&(l[r]=!!r),f("div",{"aria-disabled":e.disabled.toString(),key:`panel-${e.uid}`,bind:this,"data-panel":e,onclick:this._triggerPanel,onkeydown:this._triggerPanel,class:this.classes(E.actionsMenuItem,o),role:"button",tabindex:e.disabled?null:0,title:s,"aria-label":s},f("span",{class:this.classes(l),styles:a}))}renderActionsSections(e,t,i){const s=t.toArray().map(((t,i)=>f("ul",{key:`${e}-action-section-${i}`,class:E.actionsList},this.renderActionSection(e,t))));return f("div",{role:"group","aria-expanded":e.actionsOpen?"true":"false",key:"actions-section",id:i,class:E.actions,hidden:!e.actionsOpen||null},s)}renderActionSection(e,t){return(t&&t.toArray()).map((t=>this.renderAction({item:e,action:t})))}renderActionIcon(e){const{active:t,className:i}=e,s=this._getIconImageStyles(e),n="button"!==e.type||e.image||i?i:E.iconDefaultAction,r={[E.actionImage]:!t&&!!s["background-image"],[E.iconLoading]:t,[E.rotating]:t};return n&&!t&&(r[n]=!0),f("span",{key:"action-icon","aria-hidden":"true",class:this.classes(E.actionIcon,r),styles:s})}renderActionTitle(e,t){return t?null:f("span",{key:"action-title",class:E.actionTitle},e)}renderAction(e){const{item:t,action:i,singleAction:s}=e,{active:n,disabled:r,title:a}=i,o={[E.actionsMenuItem]:s&&"button"===i.type,[E.action]:n||!s&&"toggle"!==i.type,[E.actionToggle]:!n&&"toggle"===i.type,[E.actionToggleOn]:!n&&"toggle"===i.type&&i.value,[E.disabledElement]:r},l=[this.renderActionIcon(i),this.renderActionTitle(a,s)];return s?f("div",{bind:this,"data-item":t,"data-action":i,role:"button",key:`single-action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:o,tabindex:"0",title:a,"aria-label":a},l):f("li",{bind:this,"data-item":t,"data-action":i,key:`action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:o,tabindex:"0",role:"button",title:a,"aria-label":a},l)}_setVisibleItems(){const{referenceItems:e,baseItems:t,visibleElements:i}=this,s=e.concat(t);this.visibleItems=s?.filter((e=>!e.hidden&&(i.errors||!e.error)))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.uid,e),this.scheduleRender()}_hasMessage(e){return!!e.error||e.incompatible}_hasChildren(e){return!!e.children.length&&!this._hasMessage(e)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_destroyReferenceSortable(){const{_sortableReferenceLayers:e}=this;e?.el&&e.destroy(),this._sortableReferenceLayersNode=null}_destroyBaseSortable(){const{_sortableBaseLayers:e}=this;e?.el&&e.destroy(),this._sortableBaseLayersNode=null}_toggleEditingTitle(){const{_editingTitle:e}=this,t=!e;this._editingTitle=t,this._focusOnElement=t?"edit-input":"edit-button",this.scheduleRender()}_storeEditTitleInput(e){this._editTitleInput=e,this._focusEditElement()}_focusEditElement(){this._editTitleInput&&"edit-input"===this._focusOnElement&&(this._focusOnElement=null,this._editTitleInput.focus()),this._editTitleButton&&"edit-button"===this._focusOnElement&&(this._focusOnElement=null,this._editTitleButton.focus())}_storeEditTitleButton(e){this._editTitleButton=e,this._focusEditElement()}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}_itemMovedList(e){const t=e.item["data-item"],i=e.to.dataset.nodeRef,s=e.from.dataset.nodeRef,{newIndex:n}=e;this.viewModel.transferListItem({listItem:t,from:s,to:i,newIndex:n})}_toggleSortingBaseLayers(){const{_sortableBaseLayers:e,_sortableBaseLayersNode:t,editingEnabled:i}=this;if(!t)return;const s=!i;if(e)e.option("disabled",s);else{const e=I.create(t,{dataIdAttr:A,group:w,filter:`.${E.itemOnlyChild}`,fallbackTolerance:4,disabled:s,onSort:()=>this._sortLayersToItems({type:"base",itemIds:e.toArray()}),onAdd:e=>this._itemMovedList(e),chosenClass:E.sortableChosen});this._sortableBaseLayers=e}}_toggleSortingReferenceLayers(){const{_sortableReferenceLayers:e,_sortableReferenceLayersNode:t,editingEnabled:i}=this;if(!t)return;const s=!i;if(e)e.option("disabled",s);else{const e=I.create(t,{dataIdAttr:A,group:w,disabled:s,fallbackTolerance:4,onSort:()=>this._sortLayersToItems({type:"reference",itemIds:e.toArray()}),onAdd:e=>this._itemMovedList(e),chosenClass:E.sortableChosen});this._sortableReferenceLayers=e}}_toggleSorting(){this._toggleSortingBaseLayers(),this._toggleSortingReferenceLayers()}_sortNodeCreated(e){const t=e.getAttribute("data-node-ref");"base"===t&&(this._sortableBaseLayersNode=e),"reference"===t&&(this._sortableReferenceLayersNode=e),this._toggleSorting()}_getItems(e){return e.toArray().filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).getItemAt(0)}_sortLayersToItems({type:e,itemIds:t}){const i="base"===e?this.get("view.map.basemap.baseLayers"):"reference"===e?this.get("view.map.basemap.referenceLayers"):null;i&&i.sort(((e,i)=>{const s=t.indexOf(e.uid),n=t.indexOf(i.uid);return s>n?-1:s<n?1:0}))}_focusListItem(e){const{_focusSortUid:t}=this;if(!e||!t)return;e["data-item"].layer?.uid===t&&(e.focus(),this._focusSortUid=null)}_selectionKeydown(e){const t=["ArrowDown","ArrowUp"],s=i(e);if(!t.includes(s))return void this._toggleSelection(e);e.stopPropagation();const n=e.currentTarget,r=n["data-item"],a=n.dataset.itemType,{_sortableBaseLayers:o,_sortableReferenceLayers:l,selectedItems:d}=this,c="base"===a?o:"reference"===a?l:null;if(!c)return;const m=u(r,d),h=c.toArray(),g=e.target,p=h.indexOf(g.dataset[S]),{baseItems:b,referenceItems:_}=this.viewModel;if(-1!==p){if("ArrowDown"===s){const e=p+1,t=e>=h.length;if(t&&"reference"===a&&m){const e=b.length;return this.viewModel.transferListItem({listItem:r,from:"reference",to:"base",newIndex:e}),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if(t&&"reference"===a){const e=b.getItemAt(0);return this._focusSortUid=e?.layer?.uid,void this.scheduleRender()}if(t)return;return m&&(L(h,p,e),c.sort(h),this._sortLayersToItems({type:a,itemIds:c.toArray()})),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if("ArrowUp"===s){const e=p-1,t=e<0;if(t&&"base"===a&&m){if(1===b.length)return;const e=0;return this.viewModel.transferListItem({listItem:r,from:"base",to:"reference",newIndex:e}),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if(t&&"base"===a){const e=_.getItemAt(_.length-1);return this._focusSortUid=e?.layer?.uid,void this.scheduleRender()}if(t)return;m&&(L(h,p,e),c.sort(h),this._sortLayersToItems({type:a,itemIds:c.toArray()})),this._focusSortUid=r.layer?.uid,this.scheduleRender()}}}_watchActionSectionChanges(e,t){this.handles.add(e.on("change",(()=>this.scheduleRender())),t),e.forEach((e=>this._renderOnActionChanges(e,t)))}_renderOnActionChanges(e,t){"toggle"!==e.type?"slider"!==e.type?this.handles.add([n((()=>[e.className,e.image,e.id,e.title,e.visible]),(()=>this.scheduleRender()),a)],t):this.handles.add([n((()=>[e.className,e.id,e.title,e.visible,e.value,e.displayValueEnabled,e.max,e.min,e.step]),(()=>this.scheduleRender()),a)],t):this.handles.add([n((()=>[e.className,e.image,e.id,e.title,e.visible,e.value]),(()=>this.scheduleRender()),a)],t)}_renderOnItemChanges(e,t){this.handles.add([n((()=>[e.actionsOpen,e.visible,e.open,e.updating,e.title,e.visibleAtCurrentScale,e.error,e.visibilityMode,e.panel,e.panel?.title,e.panel?.content,e.panel?.className]),(()=>this.scheduleRender()),a),n((()=>[e.hidden,e.error]),(()=>this._setVisibleItems())),e.actionsSections.on("change",(()=>this.scheduleRender())),e.children.on("change",(()=>this.scheduleRender()))],t),e.children.forEach((e=>this._renderOnItemChanges(e,t))),e.actionsSections.forEach((e=>this._watchActionSectionChanges(e,t)))}_itemsChanged(e,t){this.handles.remove(t),this._tooltipReferenceMap.clear(),this._setVisibleItems(),e.forEach((e=>this._renderOnItemChanges(e,t))),this.scheduleRender()}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_getIconImageStyles(e){const t="esri.widgets.LayerList.ListItemPanel"===e.declaredClass||"esri.support.Action.ActionButton"===e.declaredClass||"esri.support.Action.ActionToggle"===e.declaredClass?e.image:null;return{"background-image":t?`url("${t}")`:null}}_toggleActionsOpen(e){e.stopPropagation();const t=e.currentTarget["data-item"],{actionsOpen:i}=t,s=!i,{baseItems:n,referenceItems:r}=this;s&&(n.forEach((e=>M(e))),r.forEach((e=>M(e)))),t.actionsOpen=s}_triggerPanel(e){e.stopPropagation();const t=e.currentTarget["data-panel"];t&&!t.disabled&&(t.open=!t.open)}_triggerAction(e){e.stopPropagation();const t=e.currentTarget,i=t["data-action"],s=t["data-item"];"toggle"===i.type&&(i.value=!i.value),this.triggerAction(i,s)}_toggleVisibility(e){e.stopPropagation();const t=e.currentTarget,i=t.getAttribute("data-parent-visibility"),s=t["data-item"];i===R.exclusive&&s.visible||(s.visible=!s.visible)}_toggleChildrenClick(e){e.stopPropagation();const t=e.currentTarget["data-item"];t.open=!t.open}_toggleSelection(e){e.stopPropagation();const{multipleSelectionEnabled:t,selectedItems:i}=this,s=t&&(e.metaKey||e.ctrlKey),n=e.currentTarget["data-item"],r=u(n,i),{length:a}=i;if(!s)return a&&!(r&&1===a)?(i.removeAll(),void i.add(n)):void(r?i.remove(r):i.add(n));r?i.remove(r):i.add(n)}};e([o()],O.prototype,"visibleItems",void 0),e([o()],O.prototype,"basemapTitle",null),e([o()],O.prototype,"baseListItemCreatedFunction",null),e([o()],O.prototype,"editingEnabled",void 0),e([o()],O.prototype,"headingLevel",void 0),e([o()],O.prototype,"iconClass",void 0),e([o()],O.prototype,"label",null),e([o(),_("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],O.prototype,"messages",void 0),e([o(),_("esri/t9n/common")],O.prototype,"messagesCommon",void 0),e([o()],O.prototype,"multipleSelectionEnabled",void 0),e([o()],O.prototype,"referenceListItemCreatedFunction",null),e([o({readOnly:!0})],O.prototype,"baseItems",null),e([o({readOnly:!0})],O.prototype,"referenceItems",null),e([o()],O.prototype,"selectedItems",void 0),e([o()],O.prototype,"view",null),e([y("trigger-action"),o({type:m})],O.prototype,"viewModel",void 0),e([o()],O.prototype,"visibleElements",void 0),e([l("visibleElements")],O.prototype,"castVisibleElements",null),e([b()],O.prototype,"_toggleActionsOpen",null),e([b()],O.prototype,"_triggerPanel",null),e([b()],O.prototype,"_triggerAction",null),e([b()],O.prototype,"_toggleVisibility",null),e([b()],O.prototype,"_toggleChildrenClick",null),e([b()],O.prototype,"_toggleSelection",null),O=e([d("esri.widgets.BasemapLayerList")],O);const x=O;export{x as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import has from"../core/has.js";import{isSome as n}from"../core/maybe.js";import{watch as r,on as a,initial as l}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"./Widget.js";import h from"./BasemapLayerList/BasemapLayerListViewModel.js";import u from"./LayerList/ListItem.js";import{findSelectedItem as g}from"./LayerList/support/layerListUtils.js";import{Heading as p,incrementHeadingLevel as b}from"./support/Heading.js";import{accessibleHandler as _}from"./support/decorators/accessibleHandler.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as f}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import v from"sortablejs";const L=t.ofType(u);function C(e,t,i){e.splice(i,0,e.splice(t,1)[0])}const T=".*\\S+.*",w="esri-basemaplayerlist-new-ui",A="root-layers",S="data-layer-uid",E="layerUid",k={base:"esri-basemap-layer-list esri-widget esri-widget--panel",newUI:"esri-basemap-layer-list--new-ui",titleContainer:"esri-basemap-layer-list__title-container",mainHeading:"esri-basemap-layer-list__main-heading",editingCard:"esri-basemap-layer-list__editing-card",editingInput:"esri-basemap-layer-list__editing-input",editingActions:"esri-basemap-layer-list__editing-actions",editButton:"esri-basemap-layer-list__edit-button",editButtonIcon:"esri-basemap-layer-list__edit-button-icon",submitButton:"esri-basemap-layer-list__submit-button",cancelButton:"esri-basemap-layer-list__cancel-button",noItems:"esri-basemap-layer-list__no-items",horizontalRule:"esri-basemap-layer-list__hr",listHeading:"esri-basemap-layer-list__list-heading",list:"esri-basemap-layer-list__list",listRoot:"esri-basemap-layer-list__list--root",listExclusive:"esri-basemap-layer-list__list--exclusive",listInherited:"esri-basemap-layer-list__list--inherited",listIndependent:"esri-basemap-layer-list__list--independent",item:"esri-basemap-layer-list__item",itemOnlyChild:"esri-basemap-layer-list__item--only-child",itemContent:"esri-basemap-layer-list__item-content",itemMessage:"esri-basemap-layer-list__item--has-message",itemInvisible:"esri-basemap-layer-list__item--invisible",itemInvisibleAtScale:"esri-basemap-layer-list__item--invisible-at-scale",itemChildren:"esri-basemap-layer-list__item--has-children",itemSelectable:"esri-basemap-layer-list__item--selectable",itemContainer:"esri-basemap-layer-list__item-container",actionsMenu:"esri-basemap-layer-list__item-actions-menu",actionsMenuItem:"esri-basemap-layer-list__item-actions-menu-item",actionsMenuItemActive:"esri-basemap-layer-list__item-actions-menu-item--active",actions:"esri-basemap-layer-list__item-actions",actionsList:"esri-basemap-layer-list__item-actions-list",action:"esri-basemap-layer-list__item-action",actionIcon:"esri-basemap-layer-list__item-action-icon",actionImage:"esri-basemap-layer-list__item-action-image",actionTitle:"esri-basemap-layer-list__item-action-title",actionToggle:"esri-basemap-layer-list__action-toggle",actionToggleOn:"esri-basemap-layer-list__action-toggle--on",label:"esri-basemap-layer-list__item-label",message:"esri-basemap-layer-list__item-message",title:"esri-basemap-layer-list__item-title",publishing:"esri-basemap-layer-list__publishing",updating:"esri-basemap-layer-list__updating",connectionStatus:"esri-basemap-layer-list__connection-status",connectionStatusConnected:"esri-basemap-layer-list__connection-status--connected",toggleVisible:"esri-basemap-layer-list__item-toggle",toggleVisibleIcon:"esri-basemap-layer-list__item-toggle-icon",toggleIcon:"esri-basemap-layer-list__item-toggle-icon",radioIcon:"esri-basemap-layer-list__item-radio-icon",childToggle:"esri-basemap-layer-list__child-toggle",childToggleOpen:"esri-basemap-layer-list__child-toggle--open",childOpened:"esri-basemap-layer-list__child-toggle-icon--opened",childClosed:"esri-basemap-layer-list__child-toggle-icon--closed",childClosed_RTL:"esri-basemap-layer-list__child-toggle-icon--closed-rtl",sortableChosen:"esri-basemap-layer-list--chosen",button:"esri-button",buttonTertiary:"esri-button--tertiary",input:"esri-input",disabled:"esri-disabled",disabledElement:"esri-disabled-element",hidden:"esri-hidden",rotating:"esri-rotating",heading:"esri-widget__heading",iconEdit:"esri-icon-edit",iconCheckMark:"esri-icon-check-mark",iconClose:"esri-icon-close",iconEllipses:"esri-icon-handle-horizontal",iconVisible:"esri-icon-visible",iconInvisible:"esri-icon-non-visible",iconRadioSelected:"esri-icon-radio-checked",iconRadioUnselected:"esri-icon-radio-unchecked",iconNoticeTriangle:"esri-icon-notice-triangle",iconChildrenOpen:"esri-icon-down-arrow",iconDownArrow:"esri-icon-down-arrow",iconRightArrow:"esri-icon-right-triangle-arrow",iconLeftArrow:"esri-icon-left-triangle-arrow",iconLoading:"esri-icon-loading-indicator",iconDefaultAction:"esri-icon-default-action",widgetIcon:"esri-icon-layers"},R={actions:"actions",actionSection:"action-section",baseItems:"base-items",referenceItems:"reference-items"},M={exclusive:"exclusive",inherited:"inherited",independent:"independent"};function B(e){const{actionsOpen:t,children:i}=e;t&&(e.actionsOpen=!1),i.forEach((e=>B(e)))}const O={baseLayers:!0,referenceLayers:!0,statusIndicators:!0,errors:!1};let x=class extends(s(m)){constructor(e,t){super(e,t),this._tooltipReferenceMap=new Map,this._editingTitle=!1,this._editTitleInput=null,this._editTitleButton=null,this._focusOnElement=null,this._sortableBaseLayers=null,this._sortableReferenceLayers=null,this._sortableBaseLayersNode=null,this._sortableReferenceLayersNode=null,this._focusSortUid=null,this._newUI=has(w),this.visibleItems=null,this.editingEnabled=!1,this.headingLevel=2,this.iconClass=k.widgetIcon,this.messages=null,this.messagesCommon=null,this.multipleSelectionEnabled=!1,this.selectedItems=new L,this.viewModel=new h,this.visibleElements={...O}}initialize(){const{baseItems:e,referenceItems:t}=this;this._setVisibleItems(),this.addHandles([r((()=>this.visibleElements),(()=>{this._itemsChanged(e,R.baseItems),this._itemsChanged(t,R.referenceItems)})),a((()=>this.baseItems),"change",(()=>{this._itemsChanged(e,R.baseItems)})),a((()=>this.referenceItems),"change",(()=>this._itemsChanged(t,R.referenceItems))),r((()=>this.editingEnabled),(()=>this._toggleSorting()),l)])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-tooltip.js")])}destroy(){this._destroyBaseSortable(),this._destroyReferenceSortable(),this._tooltipReferenceMap.clear()}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...O,...e}}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[k.newUI]:this._newUI,[k.hidden]:"loading"===e,[k.disabled]:"disabled"===e},i=this.renderItemTooltips(),s=this.renderReferenceSection(),n=this.renderBaseSection(),r=s&&n?I("hr",{class:k.horizontalRule}):null,a=[this.renderTitleContainer(),s,r,n];return I("div",{class:this.classes(k.base,t)},[i,a])}renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?I("calcite-tooltip",{label:i.layerIncompatible,referenceElement:t.get(e.uid)},i.layerIncompatibleTooltip):null}renderItemTooltipNodes(e){const{incompatible:t,children:i}=e;return[t?this.renderItemTooltip(e):null,...t?[]:i?.toArray().map((e=>this.renderItemTooltipNodes(e)))]}renderItemTooltips(){return this.visibleItems.toArray().map((e=>this.renderItemTooltipNodes(e)))}renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return I("label",{class:k.editingInput},e.basemapTitle,I("input",{bind:this,class:k.input,title:e.basemapTitle,"aria-label":e.basemapTitle,placeholder:e.basemapTitle,type:"text",role:"textbox",required:!0,pattern:T,value:t,afterCreate:this._storeEditTitleInput,afterUpdate:this._focusEditElement}))}renderCancelButton(){const{messagesCommon:e}=this;return I("button",{title:e.cancel,"aria-label":e.cancel,type:"button",bind:this,class:this.classes(k.button,k.buttonTertiary),onclick:this._toggleEditingTitle},e.cancel)}renderSubmitButton(){const{messagesCommon:e}=this;return I("button",{title:e.form.submit,"aria-label":e.form.submit,type:"submit",bind:this,class:k.button},e.form.ok)}renderEditingForm(){return I("div",{class:k.editingCard},I("form",{bind:this,onsubmit:this._formSubmit},this.renderEditingInput(),I("div",{class:k.editingActions},this.renderCancelButton(),this.renderSubmitButton())))}renderBasemapTitle(){const{basemapTitle:e}=this.viewModel;return I(p,{level:this.headingLevel,class:this.classes(k.heading,k.mainHeading)},e)}renderEditTitleButton(){const{_editingTitle:e,editingEnabled:t,messagesCommon:i}=this;return t&&!e?I("button",{bind:this,class:k.editButton,title:i.edit,"aria-label":i.edit,onclick:this._toggleEditingTitle,afterCreate:this._storeEditTitleButton,afterUpdate:this._focusEditElement,"data-node-ref":"_editButtonNode",type:"button"},I("span",{"aria-hidden":"true",class:this.classes(k.iconEdit,k.editButtonIcon)})):null}renderTitleContainer(){return I("div",{class:k.titleContainer},this._editingTitle?this.renderEditingForm():this.renderBasemapTitle(),this.renderEditTitleButton())}renderNoLayersInfo(e,t){return I("div",{key:t,class:k.noItems},e)}renderList(e,t){const{messages:i}=this,s="reference"===t?this._destroyReferenceSortable:this._destroyBaseSortable;return I("ul",{key:t,"aria-label":i.widgetLabel,role:this.editingEnabled&&e.length?"listbox":void 0,afterCreate:this._sortNodeCreated,afterRemoved:s,"data-node-ref":t,bind:this,class:this.classes(k.list,k.listRoot,k.listIndependent)},e.map((i=>this.renderItem({item:i,parent:null,itemType:t,isOnlyChild:1===e.length}))))}renderBaseHeader(){return I(p,{key:"base-heading",level:b(this.headingLevel),class:this.classes(k.heading,k.listHeading)},this.messages.baseHeading)}renderBaseSection(){const{baseItems:e,messages:t,visibleElements:i}=this;if(!i.baseLayers)return null;const s=this._getItems(e),n="base";return[this.renderBaseHeader(),[0===s.length?this.renderNoLayersInfo(t.noBaseLayers,n):null,this.renderList(s,n)]]}renderReferenceHeader(){return I(p,{key:"reference-heading",level:b(this.headingLevel),class:this.classes(k.heading,k.listHeading)},this.messages.referenceHeading)}renderReferenceSection(){const{referenceItems:e,messages:t,visibleElements:i}=this;if(!i.referenceLayers)return null;const s=this._getItems(e),n="reference";return[this.renderReferenceHeader(),[0===s.length?this.renderNoLayersInfo(t.noReferenceLayers,n):null,this.renderList(s,n)]]}renderChildrenToggle(e,t){const{messagesCommon:i}=this,{children:s}=e,n=!!e.error,r=!!s.length&&!n,a={[k.childToggleOpen]:e.open},l=e.open?i.collapse:i.expand;return r?I("span",{onclick:this._toggleChildrenClick,onkeydown:this._toggleChildrenClick,"data-item":e,key:"toggle-children",class:this.classes(k.childToggle,a),tabindex:"0",role:"button","aria-controls":t,"aria-label":l,title:l},I("span",{"aria-hidden":"true",class:this.classes(k.childClosed,k.iconRightArrow)}),I("span",{"aria-hidden":"true",class:this.classes(k.childOpened,k.iconDownArrow)}),I("span",{"aria-hidden":"true",class:this.classes(k.childClosed_RTL,k.iconLeftArrow)})):null}renderItemMessage(e){return e.error?I("div",{key:"esri-basemap-layer-list__error",class:k.message,role:"alert"},I("span",{"aria-hidden":"true",class:k.iconNoticeTriangle}),this.messages.layerError):e.incompatible?I("div",{key:"esri-basemap-layer-list__incompatible",class:k.message,role:"alert"},I("span",{bind:this,tabIndex:0,"aria-hidden":"true",class:k.iconNoticeTriangle,afterCreate:t=>this._setTooltipReference(t,e)}),this.messages.layerIncompatible):null}renderActionsMenuIcon(e,t){const{messagesCommon:i}=this,s={[k.actionsMenuItemActive]:e.actionsOpen};return I("div",{key:"actions-menu-toggle","data-item":e,bind:this,onclick:this._toggleActionsOpen,onkeydown:this._toggleActionsOpen,class:this.classes(k.actionsMenuItem,s),tabindex:"0",role:"button","aria-controls":t,"aria-label":i.options,title:i.options},I("span",{"aria-hidden":"true",class:k.iconEllipses}))}renderActionsMenu(e,t,i,s){const{panel:n}=e,r=n&&n.visible?this.renderPanelButton(n):null,a=1===i&&this._getSingleActionButton(t),l=a?this.renderAction({item:e,action:a,singleAction:!0}):null,o=!a&&i?this.renderActionsMenuIcon(e,s):null;return o||r||a?I("div",{key:"actions-menu",class:k.actionsMenu},r,l,o):null}renderChildList(e,t){const{editingEnabled:i}=this,{visibilityMode:s,children:n}=e,r=this._hasChildren(e),a=!r&&i&&"group"===e.layer?.type,{exclusive:l,inherited:o}=M,c={[k.listExclusive]:s===l,[k.listInherited]:s===o,[k.listIndependent]:s!==o&&s!==l};return r||a?I("ul",{bind:this,key:"list-items",id:t,"data-group":e.uid,"data-item":e,afterCreate:this._sortNodeCreated,afterUpdate:this._sortNodeCreated,class:this.classes(k.list,c),"aria-expanded":e.open?"true":"false",role:i?"listbox":s===l?"radiogroup":"group",hidden:!e.open||null},n?.map((t=>this.renderItem({item:t,parent:e}))).toArray()):null}renderItemContent(e,t,i){const{id:s}=this,n=`${s}_${e.uid}`,r=`${n}_actions`,a=`${n}__list`,{panel:l}=e,o=this._filterActions(e.actionsSections),c=this._countActions(o);return[I("div",{key:"list-item-container",class:k.itemContainer},this.renderChildrenToggle(e,a),this.renderLabel(e,t,i),this.renderActionsMenu(e,o,c,r)),this.renderItemMessage(e),c?this.renderActionsSections(e,o,r):null,l&&l.open&&!l.disabled?l.render():null,this.renderChildList(e,a)]}renderItem({item:e,parent:t,itemType:i,isOnlyChild:s}){const{_newUI:n,id:r,editingEnabled:a,selectedItems:l}=this,o=`${`${r}_${e.uid}`}__title`,c=this._hasMessage(e),d=this._hasChildren(e),m={[k.itemChildren]:d,[k.itemMessage]:!!c,[k.itemInvisible]:n&&!e.visible,[k.itemInvisibleAtScale]:!e.visibleAtCurrentScale,[k.itemSelectable]:a};if(a){const n={[S]:e.layer?.uid};return I("li",{key:`item-with-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(k.item,m,{[k.itemOnlyChild]:s}),"aria-labelledby":o,onclick:this._toggleSelection,onkeydown:this._selectionKeydown,"data-item-type":i,"data-item":e,tabIndex:0,"aria-selected":g(e,l)?"true":"false",role:"option",...n},this.renderItemContent(e,t,o))}return I("li",{key:`item-no-selection-${e.uid}`,bind:this,afterCreate:this._focusListItem,afterUpdate:this._focusListItem,class:this.classes(k.item,m),"aria-labelledby":o},this.renderItemContent(e,t,o))}renderConnectionIcon(e){const{connectionStatus:t}=e;return n(t)?I("calcite-icon",{icon:"connected"===t?"check-circle":"offline",scale:"s"}):null}renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:r}=e,a=r&&!t,l=!!s;return I("span",{class:this.classes({[k.publishing]:n,[k.updating]:a,[k.connectionStatus]:l,[k.connectionStatusConnected]:l&&"connected"===s}),key:"layer-item-status"},this.renderConnectionIcon(e))}renderItemTitle(e,t){const{messages:i}=this,s=e.title||i.untitledLayer,n=e.visibleAtCurrentScale?s:`${s} (${i.layerInvisibleAtScale})`;return I("span",{key:"layer-title-container",id:t,title:n,"aria-label":n,class:k.title},s)}renderItemToggleIcon(e,t){const{_newUI:i}=this,{exclusive:s}=M,n=t&&t.visibilityMode,r={[k.toggleVisibleIcon]:i,[k.toggleIcon]:i&&n!==s,[k.radioIcon]:i&&n===s,[k.iconRadioSelected]:n===s&&e.visible,[k.iconRadioUnselected]:n===s&&!e.visible,[k.iconVisible]:n!==s&&e.visible,[k.iconInvisible]:n!==s&&!e.visible};return I("span",{key:"item-toggle-icon",class:this.classes(r),"aria-hidden":"true"})}renderItemToggle(e,t,i){const{editingEnabled:s,messages:n}=this,{exclusive:r}=M,a=t&&t.visibilityMode,l=a===r?"radio":"switch";return I("span",s?{key:"item-toggle-selection-enabled",class:k.toggleVisible,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":a,tabIndex:0,"aria-checked":e.visible?"true":"false",title:e.visible?n.hideLayer:n.showLayer,role:l,"aria-labelledby":i}:{key:"item-toggle",class:k.toggleVisible},this.renderItemToggleIcon(e,t))}renderLabel(e,t,i){const{editingEnabled:s,_newUI:n,messages:r}=this,{inherited:a,exclusive:l}=M,o=t?.visibilityMode,c=o===l?"radio":"switch",d=n?[this.renderItemTitle(e,i),this.renderItemStatus(e,t),this.renderItemToggle(e,t,i)]:[this.renderItemToggle(e,t,i),this.renderItemTitle(e,i),this.renderItemStatus(e,t)],m=I("div",s?{key:`item-label-no-selection-${e.uid}`,class:k.label}:{key:`item-label-with-selection-${e.uid}`,class:k.label,bind:this,onclick:this._toggleVisibility,onkeydown:this._toggleVisibility,"data-item":e,"data-parent-visibility":o,tabIndex:0,title:e.visible?r.hideLayer:r.showLayer,"aria-checked":e.visible?"true":"false",role:c,"aria-labelledby":i},d);return o===a||e.error?I("div",{key:`item-label-container-${e.uid}`,class:k.label},this.renderItemTitle(e,i),this.renderItemStatus(e,t)):m}renderPanelButton(e){const{className:t,open:i,title:s,image:n}=e,r=n||t?t:k.iconDefaultAction,a=this._getIconImageStyles(e),l={[k.actionsMenuItemActive]:i},o={[k.actionImage]:!!a["background-image"],[k.disabledElement]:e.disabled};return r&&(o[r]=!!r),I("div",{"aria-disabled":e.disabled.toString(),key:`panel-${e.uid}`,bind:this,"data-panel":e,onclick:this._triggerPanel,onkeydown:this._triggerPanel,class:this.classes(k.actionsMenuItem,l),role:"button",tabindex:e.disabled?null:0,title:s,"aria-label":s},I("span",{class:this.classes(o),styles:a}))}renderActionsSections(e,t,i){const s=t.toArray().map(((t,i)=>I("ul",{key:`${e}-action-section-${i}`,class:k.actionsList},this.renderActionSection(e,t))));return I("div",{role:"group","aria-expanded":e.actionsOpen?"true":"false",key:"actions-section",id:i,class:k.actions,hidden:!e.actionsOpen||null},s)}renderActionSection(e,t){return(t&&t.toArray()).map((t=>this.renderAction({item:e,action:t})))}renderActionIcon(e){const{active:t,className:i}=e,s=this._getIconImageStyles(e),n="button"!==e.type||e.image||i?i:k.iconDefaultAction,r={[k.actionImage]:!t&&!!s["background-image"],[k.iconLoading]:t,[k.rotating]:t};return n&&!t&&(r[n]=!0),I("span",{key:"action-icon","aria-hidden":"true",class:this.classes(k.actionIcon,r),styles:s})}renderActionTitle(e,t){return t?null:I("span",{key:"action-title",class:k.actionTitle},e)}renderAction(e){const{item:t,action:i,singleAction:s}=e,{active:n,disabled:r,title:a}=i,l={[k.actionsMenuItem]:s&&"button"===i.type,[k.action]:n||!s&&"toggle"!==i.type,[k.actionToggle]:!n&&"toggle"===i.type,[k.actionToggleOn]:!n&&"toggle"===i.type&&i.value,[k.disabledElement]:r},o=[this.renderActionIcon(i),this.renderActionTitle(a,s)];return s?I("div",{bind:this,"data-item":t,"data-action":i,role:"button",key:`single-action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",title:a,"aria-label":a},o):I("li",{bind:this,"data-item":t,"data-action":i,key:`action-${i.uid}`,onclick:this._triggerAction,onkeydown:this._triggerAction,classes:l,tabindex:"0",role:"button",title:a,"aria-label":a},o)}_setVisibleItems(){const{referenceItems:e,baseItems:t,visibleElements:i}=this,s=e.concat(t);this.visibleItems=s?.filter((e=>!e.hidden&&(i.errors||!e.error)))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.uid,e),this.scheduleRender()}_hasMessage(e){return!!e.error||e.incompatible}_hasChildren(e){return!!e.children.length&&!this._hasMessage(e)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_destroyReferenceSortable(){const{_sortableReferenceLayers:e}=this;e?.el&&e.destroy(),this._sortableReferenceLayersNode=null}_destroyBaseSortable(){const{_sortableBaseLayers:e}=this;e?.el&&e.destroy(),this._sortableBaseLayersNode=null}_toggleEditingTitle(){const{_editingTitle:e}=this,t=!e;this._editingTitle=t,this._focusOnElement=t?"edit-input":"edit-button",this.scheduleRender()}_storeEditTitleInput(e){this._editTitleInput=e,this._focusEditElement()}_focusEditElement(){this._editTitleInput&&"edit-input"===this._focusOnElement&&(this._focusOnElement=null,this._editTitleInput.focus()),this._editTitleButton&&"edit-button"===this._focusOnElement&&(this._focusOnElement=null,this._editTitleButton.focus())}_storeEditTitleButton(e){this._editTitleButton=e,this._focusEditElement()}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}_itemMovedList(e){const t=e.item["data-item"],i=e.to.dataset.nodeRef,s=e.from.dataset.nodeRef,{newIndex:n}=e;this.viewModel.transferListItem({listItem:t,from:s,to:i,newIndex:n})}_toggleSortingBaseLayers(){const{_sortableBaseLayers:e,_sortableBaseLayersNode:t,editingEnabled:i}=this;if(!t)return;const s=!i;if(e)e.option("disabled",s);else{const e=v.create(t,{dataIdAttr:S,group:A,filter:`.${k.itemOnlyChild}`,fallbackTolerance:4,disabled:s,onSort:()=>this._sortLayersToItems({type:"base",itemIds:e.toArray()}),onAdd:e=>this._itemMovedList(e),chosenClass:k.sortableChosen});this._sortableBaseLayers=e}}_toggleSortingReferenceLayers(){const{_sortableReferenceLayers:e,_sortableReferenceLayersNode:t,editingEnabled:i}=this;if(!t)return;const s=!i;if(e)e.option("disabled",s);else{const e=v.create(t,{dataIdAttr:S,group:A,disabled:s,fallbackTolerance:4,onSort:()=>this._sortLayersToItems({type:"reference",itemIds:e.toArray()}),onAdd:e=>this._itemMovedList(e),chosenClass:k.sortableChosen});this._sortableReferenceLayers=e}}_toggleSorting(){this._toggleSortingBaseLayers(),this._toggleSortingReferenceLayers()}_sortNodeCreated(e){const t=e.getAttribute("data-node-ref");"base"===t&&(this._sortableBaseLayersNode=e),"reference"===t&&(this._sortableReferenceLayersNode=e),this._toggleSorting()}_getItems(e){return e.toArray().filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).getItemAt(0)}_sortLayersToItems({type:e,itemIds:t}){const i="base"===e?this.get("view.map.basemap.baseLayers"):"reference"===e?this.get("view.map.basemap.referenceLayers"):null;i&&i.sort(((e,i)=>{const s=t.indexOf(e.uid),n=t.indexOf(i.uid);return s>n?-1:s<n?1:0}))}_focusListItem(e){const{_focusSortUid:t}=this;if(!e||!t)return;e["data-item"].layer?.uid===t&&(e.focus(),this._focusSortUid=null)}_selectionKeydown(e){const t=["ArrowDown","ArrowUp"],s=i(e);if(!t.includes(s))return void this._toggleSelection(e);e.stopPropagation();const n=e.currentTarget,r=n["data-item"],a=n.dataset.itemType,{_sortableBaseLayers:l,_sortableReferenceLayers:o,selectedItems:c}=this,d="base"===a?l:"reference"===a?o:null;if(!d)return;const m=g(r,c),h=d.toArray(),u=e.target,p=h.indexOf(u.dataset[E]),{baseItems:b,referenceItems:_}=this.viewModel;if(-1!==p){if("ArrowDown"===s){const e=p+1,t=e>=h.length;if(t&&"reference"===a&&m){const e=b.length;return this.viewModel.transferListItem({listItem:r,from:"reference",to:"base",newIndex:e}),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if(t&&"reference"===a){const e=b.getItemAt(0);return this._focusSortUid=e?.layer?.uid,void this.scheduleRender()}if(t)return;return m&&(C(h,p,e),d.sort(h),this._sortLayersToItems({type:a,itemIds:d.toArray()})),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if("ArrowUp"===s){const e=p-1,t=e<0;if(t&&"base"===a&&m){if(1===b.length)return;const e=0;return this.viewModel.transferListItem({listItem:r,from:"base",to:"reference",newIndex:e}),this._focusSortUid=r.layer?.uid,void this.scheduleRender()}if(t&&"base"===a){const e=_.getItemAt(_.length-1);return this._focusSortUid=e?.layer?.uid,void this.scheduleRender()}if(t)return;m&&(C(h,p,e),d.sort(h),this._sortLayersToItems({type:a,itemIds:d.toArray()})),this._focusSortUid=r.layer?.uid,this.scheduleRender()}}}_watchActionSectionChanges(e,t){this.handles.add(e.on("change",(()=>this.scheduleRender())),t),e.forEach((e=>this._renderOnActionChanges(e,t)))}_renderOnActionChanges(e,t){"toggle"!==e.type?"slider"!==e.type?this.handles.add([r((()=>[e.className,e.image,e.id,e.title,e.visible]),(()=>this.scheduleRender()),l)],t):this.handles.add([r((()=>[e.className,e.id,e.title,e.visible,e.value,e.displayValueEnabled,e.max,e.min,e.step]),(()=>this.scheduleRender()),l)],t):this.handles.add([r((()=>[e.className,e.image,e.id,e.title,e.visible,e.value]),(()=>this.scheduleRender()),l)],t)}_renderOnItemChanges(e,t){this.handles.add([r((()=>[e.actionsOpen,e.visible,e.open,e.updating,e.connectionStatus,e.publishing,e.title,e.visibleAtCurrentScale,e.error,e.visibilityMode,e.panel,e.panel?.title,e.panel?.content,e.panel?.className]),(()=>this.scheduleRender()),l),r((()=>[e.hidden,e.error]),(()=>this._setVisibleItems())),e.actionsSections.on("change",(()=>this.scheduleRender())),e.children.on("change",(()=>this.scheduleRender()))],t),e.children.forEach((e=>this._renderOnItemChanges(e,t))),e.actionsSections.forEach((e=>this._watchActionSectionChanges(e,t)))}_itemsChanged(e,t){this.handles.remove(t),this._tooltipReferenceMap.clear(),this._setVisibleItems(),e.forEach((e=>this._renderOnItemChanges(e,t))),this.scheduleRender()}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_getIconImageStyles(e){const t="esri.widgets.LayerList.ListItemPanel"===e.declaredClass||"esri.support.Action.ActionButton"===e.declaredClass||"esri.support.Action.ActionToggle"===e.declaredClass?e.image:null;return{"background-image":t?`url("${t}")`:null}}_toggleActionsOpen(e){e.stopPropagation();const t=e.currentTarget["data-item"],{actionsOpen:i}=t,s=!i,{baseItems:n,referenceItems:r}=this;s&&(n.forEach((e=>B(e))),r.forEach((e=>B(e)))),t.actionsOpen=s}_triggerPanel(e){e.stopPropagation();const t=e.currentTarget["data-panel"];t&&!t.disabled&&(t.open=!t.open)}_triggerAction(e){e.stopPropagation();const t=e.currentTarget,i=t["data-action"],s=t["data-item"];"toggle"===i.type&&(i.value=!i.value),this.triggerAction(i,s)}_toggleVisibility(e){e.stopPropagation();const t=e.currentTarget,i=t.getAttribute("data-parent-visibility"),s=t["data-item"];i===M.exclusive&&s.visible||(s.visible=!s.visible)}_toggleChildrenClick(e){e.stopPropagation();const t=e.currentTarget["data-item"];t.open=!t.open}_toggleSelection(e){e.stopPropagation();const{multipleSelectionEnabled:t,selectedItems:i}=this,s=t&&(e.metaKey||e.ctrlKey),n=e.currentTarget["data-item"],r=g(n,i),{length:a}=i;if(!s)return a&&!(r&&1===a)?(i.removeAll(),void i.add(n)):void(r?i.remove(r):i.add(n));r?i.remove(r):i.add(n)}};e([o()],x.prototype,"visibleItems",void 0),e([o()],x.prototype,"basemapTitle",null),e([o()],x.prototype,"baseListItemCreatedFunction",null),e([o()],x.prototype,"editingEnabled",void 0),e([o()],x.prototype,"headingLevel",void 0),e([o()],x.prototype,"iconClass",void 0),e([o()],x.prototype,"label",null),e([o(),y("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([o(),y("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([o()],x.prototype,"multipleSelectionEnabled",void 0),e([o()],x.prototype,"referenceListItemCreatedFunction",null),e([o({readOnly:!0})],x.prototype,"baseItems",null),e([o({readOnly:!0})],x.prototype,"referenceItems",null),e([o()],x.prototype,"selectedItems",void 0),e([o()],x.prototype,"view",null),e([f("trigger-action"),o({type:h})],x.prototype,"viewModel",void 0),e([o()],x.prototype,"visibleElements",void 0),e([c("visibleElements")],x.prototype,"castVisibleElements",null),e([_()],x.prototype,"_toggleActionsOpen",null),e([_()],x.prototype,"_triggerPanel",null),e([_()],x.prototype,"_triggerAction",null),e([_()],x.prototype,"_toggleVisibility",null),e([_()],x.prototype,"_toggleChildrenClick",null),e([_()],x.prototype,"_toggleSelection",null),x=e([d("esri.widgets.BasemapLayerList")],x);const U=x;export{U as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../core/HandleOwner.js";import{watch as n,initial as s}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import m from"../../../popup/content/TextContent.js";import h from"../../../popup/ElementExpressionInfo.js";import u from"../FeatureContent/FeatureContentViewModel.js";import d from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcadeUtils as y,createCompiledExpression as _}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends(r(o)){constructor(t){super(t),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.view=null,this._cancelQuery=()=>{const{_abortController:t}=this;t&&t.abort(),this._abortController=null},this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new d:"media"===t?new f:"text"===t?new u:null;this._set("contentElementViewModel",e)},this._compile=async()=>{this._cancelQuery();const t=new AbortController;this._abortController=t,await this._compileExpression(),this._abortController===t&&(this._abortController=null)},this._compileThrottled=i(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:t,graphic:e,interceptor:o,spatialReference:r,map:n,view:s,_abortController:i}=this;if(!(t&&e&&r&&n))return void this._set("contentElement",null);const l=await y();if(i!==this._abortController)return;const p=await _({arcadeUtils:l,expressionInfo:t,graphic:e,interceptor:o,map:n,spatialReference:r,view:s});if(!p||"esri.arcade.Dictionary"!==p.declaredClass)return void this._set("contentElement",null);const h=await p.castAsJsonAsync(i.signal),u=h?.type,d="media"===u?c.fromJSON(h):"text"===u?m.fromJSON(h):"fields"===u?a.fromJSON(h):null;this._set("contentElement",d)},this.handles.add([n((()=>[this.expressionInfo,this.graphic,this.map,this.spatialReference,this.view]),(()=>this._compileThrottled()),s),n((()=>[this.contentElement]),(()=>this._createVM()),s)])}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{_abortController:t,contentElement:e,contentElementViewModel:o}=this;return t?"loading":e||o?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}};t([l()],j.prototype,"_abortController",void 0),t([l({type:h})],j.prototype,"expressionInfo",void 0),t([l({type:e})],j.prototype,"graphic",void 0),t([l({readOnly:!0})],j.prototype,"contentElement",void 0),t([l({readOnly:!0})],j.prototype,"contentElementViewModel",void 0),t([l()],j.prototype,"interceptor",void 0),t([l()],j.prototype,"spatialReference",null),t([l({readOnly:!0})],j.prototype,"state",null),t([l()],j.prototype,"map",null),t([l()],j.prototype,"view",void 0),j=t([p("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],j);const C=j;export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{createArcadeProfile as e,createArcadeExecutor as r}from"../../arcade.js";import
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{createArcadeProfile as e,createArcadeExecutor as r}from"../../arcade.js";import s from"../../core/Accessor.js";import{debounce as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as i}from"../../core/support/WatchUpdatingTracking.js";import{fixFields as n}from"../../layers/support/fieldUtils.js";var u;const c=Symbol("FormExpressionArcadeExecutor"),p=t=>t&&"object"==typeof t&&t[c];let d=class extends s{constructor(t){super(t),this[u]=!0,this._lastEvaluatedValue=null,this._abortController=new AbortController,this._stale=!1,this._updatingTracking=new i,this._executeAsyncDebounced=o((async(t,e,r)=>{const s=await this.executor.executeAsync(t,{...e,abortSignal:r});return r.aborted?this._lastEvaluatedValue:(this._lastEvaluatedValue=s,this._stale=!1,s)}))}get isAsync(){return this.executor.isAsync}get fieldsUsed(){return this.executor.fieldsUsed}get syntaxTree(){return this.executor.syntaxTree}get updating(){return this._updatingTracking.updating}get stale(){return this._stale}get usesGeometry(){return this.executor.syntaxTree.usesGeometry}get variablesUsed(){return this.executor.variablesUsed}get lastEvaluatedValue(){return this._lastEvaluatedValue}abort(){this._abortController.abort()}execute(t,e){this._abortController=new AbortController;const r=this.executor.execute(t,{...e,abortSignal:this._abortController.signal});return this._lastEvaluatedValue=r,r}async executeAsync(t,e){return this._abortController=new AbortController,this._updatingTracking.addPromise(this._executeAsyncDebounced(t,e??{},this._abortController.signal))}markStale(){this._stale=!0}reset(){this.abort(),this._lastEvaluatedValue=null,this._stale=!1}};u=c,t([a()],d.prototype,"_lastEvaluatedValue",void 0),t([a()],d.prototype,"_stale",void 0),t([a()],d.prototype,"_updatingTracking",void 0),t([a({constructOnly:!0})],d.prototype,"executor",void 0),t([a()],d.prototype,"isAsync",null),t([a()],d.prototype,"fieldsUsed",null),t([a()],d.prototype,"syntaxTree",null),t([a()],d.prototype,"updating",null),t([a()],d.prototype,"stale",null),t([a()],d.prototype,"usesGeometry",null),t([a()],d.prototype,"variablesUsed",null),t([a()],d.prototype,"lastEvaluatedValue",null),d=t([l("esri.widgets.FeatureForm.FormExpressionArcadeExecutor")],d);const y=async(t,s)=>{const o=e("form-calculation"),a=await r(t,o,{});return s?.fieldsIndex&&(a.fieldsUsed=n(s.fieldsIndex,a.fieldsUsed)),new d({executor:a})};export{d as FormExpressionArcadeExecutor,y as createFormExpressionArcadeExecutor,p as isFormExpressionArcadeExecutor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import s from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{isSome as r}from"../../core/maybe.js";import{isAbortError as a,createResolver as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";const p="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let u=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:o,originalFeature:a,spatialReference:i}=this.arcadeContextInfo,n="feature"===t?.type?t:"scene"===t?.type&&r(t.associatedLayer)?t.associatedLayer:void 0;return[{$originalfeature:a,$editcontext:{editType:e},$layer:n,$featureset:n,$datastore:t?.url,$map:o},{spatialReference:i,console:s.getLogger(l).info}]}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:o}=this,r=new Set;for(const a of e)if(s[a]=o.getAttribute(a),t.has(a))for(const e of t.get(a))r.add(e);return this._evaluate([...r])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(p))return this._evaluate([...this._fieldReferencesLookup.get(p)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:s}=this,a=new Map(this.inputFields.map((e=>[e.name,e]))),i=new Map(s.map((e=>[e,new Array])));for(const n of s){for(const s of n.fieldsUsed){o(e,s,(()=>new Set)).add(n);const c=a.get(s),{valueExpressionExecutor:p,editableExpressionExecutor:l}=c;if(r(p)){i.get(p).push(n);o(t,p,(()=>new Set)).add(c)}if(r(l)){i.get(l).push(n);o(t,l,(()=>new Set)).add(c)}}if(n.usesGeometry){o(e,p,(()=>new Set)).add(n)}}return i}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:r}=this;for(const a of e)f(a,t,s);for(const[
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import s from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{isSome as r}from"../../core/maybe.js";import{isAbortError as a,createResolver as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";const p="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let u=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}get _baseContext(){const{editType:e,layer:t,map:o,originalFeature:a,spatialReference:i}=this.arcadeContextInfo,n="feature"===t?.type?t:"scene"===t?.type&&r(t.associatedLayer)?t.associatedLayer:void 0;return[{$originalfeature:a,$editcontext:{editType:e},$layer:n,$featureset:n,$datastore:t?.url,$map:o},{spatialReference:i,console:s.getLogger(l).info}]}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:o}=this,r=new Set;for(const a of e)if(s[a]=o.getAttribute(a),t.has(a))for(const e of t.get(a))r.add(e);return this._evaluate([...r])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(p))return this._evaluate([...this._fieldReferencesLookup.get(p)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:s}=this,a=new Map(this.inputFields.map((e=>[e.name,e]))),i=new Map(s.map((e=>[e,new Array])));for(const n of s){for(const s of n.fieldsUsed){o(e,s,(()=>new Set)).add(n);const c=a.get(s),{valueExpressionExecutor:p,editableExpressionExecutor:l}=c;if(r(p)){i.get(p).push(n);o(t,p,(()=>new Set)).add(c)}if(r(l)){i.get(l).push(n);o(t,l,(()=>new Set)).add(c)}}if(n.usesGeometry){o(e,p,(()=>new Set)).add(n)}}return i}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:r}=this;for(const a of e)f(a,t,s);for(const[n,{resolver:c,dependencyPromises:p}]of t){Promise.all(p).then((async()=>{const[e,t]=this._makeContext(r);return n.executeAsync(e,t)})).then((()=>{if(o.has(n))for(const e of o.get(n))this._latestFieldValues[e.name]=e.value;c.resolve()}),(e=>{!e||a(e)||d(e)||n.markStale(),c.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(a(e.reason)||d(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,o=this.feature.clone();return o.attributes=e,[{...t,$feature:o},s]}};e([n()],u.prototype,"_baseContext",null),e([n()],u.prototype,"feature",void 0),e([n()],u.prototype,"executors",void 0),e([n()],u.prototype,"inputFields",void 0),e([n()],u.prototype,"arcadeContextInfo",void 0),u=e([c(l)],u);const f=(e,t,s)=>{if(t.has(e))return;const o=i();t.set(e,{resolver:o,dependencyPromises:[]}),e.abort();const r=s.get(e);for(const a of r)f(a,t,s),t.get(a).dependencyPromises.push(o.promise)},d=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{u as FormExpressionsManager};
|
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.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isSome as i,isNone as a}from"../core/maybe.js";import{watch as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import d from"./FeatureForm/FeatureFormViewModel.js";import{Heading as p,incrementHeadingLevel as c}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{vmEvent as h}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as g}from"../intl/locale.js";const b={base:"esri-feature-form",form:"esri-feature-form__form",formHeader:"esri-feature-form__form-header",label:"esri-feature-form__label",inputFieldWrapper:"esri-feature-form__input-wrapper",inputFieldLoader:"esri-feature-form__input-loader",inputField:"esri-feature-form__input",inputDate:"esri-feature-form__input--date",inputTime:"esri-feature-form__input--time",inputRadioGroup:"esri-feature-form__input--radio-group",inputRadio:"esri-feature-form__input--radio",inputRadioLabel:"esri-feature-form__input--radio-label",inputDisabled:"esri-feature-form__input--disabled",inputSwitch:"esri-feature-form__input--switch",inputInvalid:"esri-feature-form__input--invalid",inputIconInvalid:"esri-feature-form__input-icon--invalid",errorMessage:"esri-feature-form__field-error-message",description:"esri-feature-form__description-text",dateInputPart:"esri-feature-form__date-input-part",loneDateInputPart:"esri-feature-form__date-input-part--lone",dateInputContainer:"esri-feature-form__date-input-container",dateFormatHint:"esri-feature-form__date-format-hint",group:"esri-feature-form__group",groupLabel:"esri-feature-form__group-label",groupHeader:"esri-feature-form__group-header",groupHeading:"esri-feature-form__group-header",groupTitle:"esri-feature-form__group-title",groupDescription:"esri-feature-form__group-description",groupToggleIcon:"esri-feature-form__group-toggle-icon",groupCollapsed:"esri-feature-form__group--collapsed",groupSequential:"esri-feature-form__group--sequential",groupActive:"esri-feature-form__group--active",collapseIcon:"esri-icon-up",errorIcon:"esri-icon-notice-triangle",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input",select:"esri-select"},v={datePattern:"D",timePattern:"tt"};function F(e){return e&&e.inputFields}const I="data-field-name";let y=class extends u{constructor(e,t){super(e,t),this._activeDateFieldEdit=null,this._activeInputName=null,this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.disabled=!1,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new d,this._handleRadioInputChange=e=>{this._commitInputValue(e.target)},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget,!0)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([s((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e&&e.name,this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-progress.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}destroy(){this._userUpdatedInputFieldNames.clear(),this._userUpdatedInputFieldNames=null}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 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}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return f("div",{class:this.classes(b.base,b.widget,b.panel)},"ready"===e?this.renderForm():null)}renderForm(){const{formTemplate:e}=this,t=i(e)&&e.title&&f(p,{key:"title",level:this.headingLevel},e.title),a=i(e)&&e.description&&f("p",{class:b.description,key:"description"},e.description),s=t||a?f("div",{class:b.formHeader},t,a):null;return f("form",{class:b.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},s,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.filter((e=>e.visible)).map(((e,t)=>F(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{formTemplate:a,disabled:s}=this,{description:n,inputFields:l,label:r,state:o}=e,u=l.filter((e=>e.visible)),d=this.viewModel.findField(this._activeInputName),m=!(!d||d.group!==e),h=`${this.id}_group_${t}`,_=`${this.id}_group-label_${t}`,g=`${this.id}_group-description_${t}`,v=n?f("p",{class:this.classes(b.groupDescription,b.description),id:g},n):null,F="sequential"===this.groupDisplay,I=F?m:"expanded"===o,y=I?b.collapseIcon:b.expandIcon;return f("fieldset",{"aria-expanded":I.toString(),"aria-labelledby":_,"aria-describedby":n?g:"",class:this.classes(b.group,F?b.groupSequential:null,I?null:b.groupCollapsed,m?b.groupActive:null,s?b.inputDisabled:null),disabled:s,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},f("button",{role:F?"presentation":void 0,class:b.groupHeader,type:"button",tabIndex:F?-1:0},f("div",{class:b.groupTitle},f(p,{class:b.groupLabel,id:_,level:i(a)&&a.title?c(this.headingLevel):this.headingLevel},r),v),F?null:f("span",{class:this.classes(y,b.groupToggleIcon)})),u.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let s;if(t)if(F(t))s=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;s=a.indexOf(i)+1}else s=0;for(let n=s;n<a.length;n++){const e=a[n];if(e.visible)return e}return null}renderLabeledField(e){const{feature:t,label:i,layer:a,type:s}=e;return f("label",{key:`${a.id}-${t.uid}-${e.name}`,class:b.label},[i,"unsupported"!==s?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:a,type:s,updating:n,value:l}=e,r=this.getCommonInputProps(e);if("coded-value"===t?.type){if(this._inputFieldHasInputType(e,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(a)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this.renderSwitchInputField(e,r);this._switchFieldsWithInitialIncompatibleValue.add(a)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),r):this.renderSelectInputField(e,this._getFieldValueOptions(a,t),r)}if("datetime-picker"===e.inputType||"date"===s)return this.renderDateInputField(e,r);const o="number"===s?f("input",{type:"number",...r,value:i(this._activeNumberFieldEdit)&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${r.value}`}):"text-area"===e.inputType?f("textarea",{...r}):f("input",{type:"text",...r});return n?f("div",{class:b.inputFieldWrapper},o,f("div",{class:b.inputFieldLoader},f("calcite-progress",{type:"indeterminate"}))):o}_parseDateTime(e,t,i){if(i){let a=_.fromJSDate(this._parseDate(e,i));const s=_.fromMillis(t.value??Date.now());return a="date"===i?a.set({hour:s.hour,minute:s.minute,second:s.second}):a.set({day:s.day,month:s.month,year:s.year}),a.isValid?a.toMillis():null}const a=_.fromJSDate(this._parseDate(e));return a.isValid?a.toMillis():null}renderDateInputField(e,t){const{value:i,includeTime:a}=e,{date:s,time:n}=this._formatDate(0),l=`${this.id}-${t.key}`,r=`${l}-date`,o=`${l}-time`,{_activeDateFieldEdit:u}=this;let{date:d,time:p}=this._formatDate(i);return u?.fieldName===e.name&&(d=u.date.input?.value??d,p=u.time.input?.value??p),f("div",{key:`${t.key}-date`,class:b.dateInputContainer},f("div",{class:this.classes(b.dateInputPart,a?null:b.loneDateInputPart)},f("input",{"aria-label":e.label,"aria-describedby":r,type:"text",...t,"data-date-part":"date",class:this.classes(t.class,b.inputDate),value:d}),f("div",{class:b.dateFormatHint,id:r},s)),a?f("div",{class:b.dateInputPart,key:"time-input"},f("input",{"aria-describedby":o,"aria-label":e.label,type:"text",...t,"data-date-part":"time",class:this.classes(t.class,b.inputTime),value:p}),f("div",{class:b.dateFormatHint,id:o},n)):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return f("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,disabled:t.disabled,class:this.classes(b.input,b.inputField,b.inputDisabled),onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value,[I]:t[I]})}renderSelectInputField(e,t,i){const{value:s}=e,{messages:n,messagesTemplates:l}=this,r=t.map((e=>e.map((e=>f("calcite-combobox-item",{value:`${e.value}`,"text-label":e.name,key:`#${e.value}`,selected:s===e.value}))))),[o,u]=r;this._registerIncompatibleValue(s,t.flat(),e,(e=>{u.unshift(f("calcite-combobox-item",{value:`${e}`,"text-label":`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[f("calcite-combobox-item-group",{key:"recommended",label:n.recommended},o),f("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=a(e.fieldElement)||this._inputFieldHasInputType(e,"combo-box")&&e.fieldElement.input.showNoValueOption;if(!e.required&&p){const t="",i=this._inputFieldHasInputType(e,"combo-box")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(f("calcite-combobox-item",{value:t,"text-label":this.messages.empty,key:"empty-option"},i))}return f("calcite-combobox",{...i,"selection-mode":"single",disabled:i.disabled||i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const s=this._fieldToInitialIncompatibleDomainValue,n=s.has(i.name);(n||null!=e&&""!==e&&!t.some((t=>t.value===e))||n)&&(n||s.set(i.name,e),a?.(s.get(i.name)))}renderRadioButtonsInputField(e,t,i){const{value:s}=e,n=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:e.name,value:t.value,selected:t.value===s,props:i})));this._registerIncompatibleValue(s,t,e);const l=a(e.fieldElement)||this._inputFieldHasInputType(e,"radio-buttons")&&e.fieldElement.input.showNoValueOption;if(!e.required&&l){const t="",a=this._inputFieldHasInputType(e,"radio-buttons")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty,l=s===t||null===s;n.unshift(this.renderRadioButton({key:"empty-option",label:a,name:e.name,value:t,selected:l,props:i}))}return f("div",{key:`${i.key}-radio`,class:b.inputRadioGroup},n)}renderSwitchInputField(e,t){const{value:i}=e,a=!!this._inputFieldHasInputType(e,"switch")&&i===e.fieldElement.input.onValue;return f("calcite-switch",{...t,class:b.inputSwitch,onCalciteSwitchChange:e=>{this._parseValue(e.currentTarget)},checked:a,disabled:t.disabled||t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:s,props:n}){return f("label",{key:e,class:b.inputRadioLabel},f("input",{...n,class:b.inputRadio,name:t,type:"radio",value:i,checked:a,onchange:this._handleRadioInputChange}),s)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:i(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:null;return i(t)?f("calcite-input-message",{status:"invalid",icon:!0,active:!0},t):e.description?f("div",{key:"description",class:b.description},e.description):void 0}getCommonInputProps(e){const{disabled:t,groupDisplay:a}=this,{editable:s,group:n,hint:l,maxLength:r,minLength:o,name:u,required:d,type:p,valid:c,value:m}=e,h=this._userUpdatedInputFieldNames.has(u),f=!s,_="all"===a&&i(n)&&"collapsed"===n.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(b.input,b.inputField,t||f?b.inputDisabled:null,h&&!c?b.inputInvalid:null),key:u,label:u,minlength:o>-1?`${o}`:"",maxlength:r>-1?`${r}`:"",...this._getNumberFieldConstraints(e),disabled:t,readOnly:f,value:null==m?"":`${m}`,[I]:u,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===p?this._handleNumberInputMouseDown:null,placeholder:"number"===p||"text"===p?l:"",required:d,tabIndex:_?-1:0}}_isInputFieldInGroup(e){return!F(e)&&i(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const n of this.viewModel.allInputFields){const{name:i,value:s}=n;!a(s)&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=s)}const i=this.viewModel.joinedContingentValues.slice(),s=new Map;for(const n of i){const i=n.values[e];if(a(i)||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:r}="null"===i.objectType?{code:"",name:this.messages.empty}:i.codedValue;if(s.has(l))continue;Object.entries(t).every((([e,t])=>!n.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,n.values[e])))&&s.set(l,{name:r,value:l})}return[...s.values()]}_getInputFieldFromInput(e){return this.viewModel.findField(e.getAttribute(I))}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getInputFieldFromInput(e),a=t.findField(this._activeInputName),s=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&a===i&&("radio-buttons"!==i.inputType||s||e.checked)&&(this._fieldFocusNeeded=!1,this._isInputFieldInGroup(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getInputFieldFromInput(t);this._activeInputName=i.name,"date"===i.type?this._syncDateFieldEdits(t):this._isNumberInputField(i)&&this._setUpNumberFieldEdit(t)}_isNumberInputField({domain:e,inputType:t="text-box",type:i}){return"number"===i&&"text-box"===t&&(!e||"coded-value"!==e.type)}_handleInputBlur(e){const t=e.target,a=this._getInputFieldFromInput(t);if("date"===a.type){const i=e.relatedTarget,s=i&&this._getInputFieldFromInput(i);if(s&&"date"===a.type&&"date"===s.type&&a.field===s.field){if(""!==t.value&&""===i.value){const s=i.getAttribute("data-date-part");i.value=this._formatDate(a.value??Date.now())[s],this._parseDate(t.value,t.getAttribute("data-date-part"))&&this._commitInputValue(e.target,!0,!1)}return}}"number"===a.type&&i(this._activeNumberFieldEdit)&&(this._activeNumberFieldEdit.input.value=`${a.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitInputValue(e,t=!1,a=!0){const s=this._getInputFieldFromInput(e);if(this._activeDateFieldEdit){const{date:i,time:n}=this._activeDateFieldEdit,l=this._parseDateTime(e.value,s,i.active?"date":"time"),r=null!==this.viewModel.getValue(s.name),o=i.input&&(n.input||!s.includeTime),u=null===l;if(t){if(u)return;(o||!a||r)&&this._updateDateFieldValue(s,l)}else{if(""===i.input?.value||""===n.input?.value)this._updateDateFieldValue(s,null);else if(o){const e=`${i.input.value} ${n.input?.value??""}`,t=this._parseDateTime(e,s);!(null!==t)&&r||this._updateDateFieldValue(s,t)}this._activeDateFieldEdit=null}}else i(this._activeNumberFieldEdit)&&this._isNumberInputField(s)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(e)}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:s}=e,n=this._getInputFieldFromInput(e.target);if("Enter"===t)this._isInputFieldInGroup(n)&&"collapsed"===n.group.state&&(n.group.state="expanded");else{const{type:l}=n.field,r="single"===l||"double"===l,o=!i&&!a&&!s;if(("integer"===l||"small-integer"===l||r)&&o&&1===t.length){const i=Number(t),a=["-","+"],s=["e","."],n=r?[...a,...s]:a;isNaN(i)&&!n.includes(t)&&e.preventDefault()}}}_setUpNumberFieldEdit(e){const t=this._getInputFieldFromInput(e);this._activeNumberFieldEdit={fieldName:t.name,input:e,value:e.value}}_syncDateFieldEdits(e){const t=this._getInputFieldFromInput(e);if("date"!==t.type)return;const i=e.getAttribute("data-date-part"),a="date"===i?{value:e.value,input:e,active:!0}:{...this._activeDateFieldEdit?.date,active:!1},s="time"===i?{value:e.value,input:e,active:!0}:{...this._activeDateFieldEdit?.time,active:!1};this._activeDateFieldEdit={fieldName:t.name,date:a,time:s}}_updateFieldValue(e){const t=e.getAttribute(I);if(this.viewModel.setValue(t,this._parseValue(e)),this._userUpdatedInputFieldNames.add(t),this.viewModel.fieldsWithContingentValues.has(t)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>i(t))));this.viewModel.validateContingencyConstraints(e)}}_updateDateFieldValue(e,t){this.viewModel.setValue(e.name,t),this._userUpdatedInputFieldNames.add(e.name)}_parseValue(e){const t=this._getInputFieldFromInput(e),i=e.value;if(this._inputFieldHasInputType(t,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;if("number"===a)return i?parseFloat(i):null;if("date"===a){if(!i)return null;const a=Number(i);if(!isNaN(a))return a;const s=e.getAttribute("data-date-part"),n=this._parseDate(i,s);if(!n)return null;let l=_.fromJSDate(n);const r=t.domain,o=_.now();let u=o;if(r&&"range"===r.type){const e=_.fromMillis(r.maxValue);o<e&&(u=e)}const d=this.viewModel.getValue(t.name),p=null!=d?_.fromMillis(d):u;return l="date"===s?l.set({hour:p.hour,minute:p.minute,second:p.second}):l.set({day:p.day,month:p.month,year:p.year}),l.toMillis()}return i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,a="sequential"===this.groupDisplay,s=`.${b.groupHeader}`;if(!(i&&!e.target.closest(s))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name,a){const a=e.target.closest(s);if(i&&!a)return;this.viewModel.inputFields.forEach((e=>{F(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=a,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_formatDate(e){if(null==e)return{date:"",time:""};const t=_.fromMillis(e,{locale:g(),numberingSystem:"latn"});return{date:t.toLocaleString({year:"numeric",month:"2-digit",day:"2-digit"}),time:t.toFormat(v.timePattern)}}_parseDate(e,t){if(null==e||""===e)return null;const{timePattern:i,datePattern:a}=v,s=t?"date"===t?a:i:`${a} ${i}`,n=_.fromFormat(e,s,{locale:g(),numberingSystem:"latn"});return n.isValid?n.toJSDate():null}_inputFieldHasInputType(e,t){return i(e.fieldElement)&&e.fieldElement.input?.type===t}_valueIsValidContingentValue(e,i){switch(i.objectType){case"any":return!0;case"null":return null==e;case"code":return e===i.codedValue?.code;case"range":return e>=i.minValue&&e<=i.maxValue;default:return t(i.objectType),!1}}};e([n()],y.prototype,"disabled",void 0),e([n()],y.prototype,"feature",null),e([n()],y.prototype,"formTemplate",null),e([n()],y.prototype,"groupDisplay",void 0),e([n()],y.prototype,"headingLevel",void 0),e([n()],y.prototype,"label",null),e([n()],y.prototype,"layer",null),e([n(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],y.prototype,"messages",void 0),e([n(),m("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],y.prototype,"messagesTemplates",void 0),e([n()],y.prototype,"spatialReference",null),e([n()],y.prototype,"strict",null),e([n(),h(["value-change","submit"])],y.prototype,"viewModel",void 0),y=e([l("esri.widgets.FeatureForm")],y);const w=y;export{w as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isSome as i,isNone as a}from"../core/maybe.js";import{watch as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import d from"./FeatureForm/FeatureFormViewModel.js";import{Heading as p,incrementHeadingLevel as c}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{vmEvent as h}from"./support/decorators/vmEvent.js";import{tsx as f}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as g}from"../intl/locale.js";const b={base:"esri-feature-form",form:"esri-feature-form__form",formHeader:"esri-feature-form__form-header",label:"esri-feature-form__label",inputFieldWrapper:"esri-feature-form__input-wrapper",inputFieldLoader:"esri-feature-form__input-loader",inputField:"esri-feature-form__input",inputDate:"esri-feature-form__input--date",inputTime:"esri-feature-form__input--time",inputRadioGroup:"esri-feature-form__input--radio-group",inputRadio:"esri-feature-form__input--radio",inputRadioLabel:"esri-feature-form__input--radio-label",inputDisabled:"esri-feature-form__input--disabled",inputSwitch:"esri-feature-form__input--switch",inputInvalid:"esri-feature-form__input--invalid",inputIconInvalid:"esri-feature-form__input-icon--invalid",errorMessage:"esri-feature-form__field-error-message",description:"esri-feature-form__description-text",dateInputPart:"esri-feature-form__date-input-part",loneDateInputPart:"esri-feature-form__date-input-part--lone",dateInputContainer:"esri-feature-form__date-input-container",dateFormatHint:"esri-feature-form__date-format-hint",group:"esri-feature-form__group",groupLabel:"esri-feature-form__group-label",groupHeader:"esri-feature-form__group-header",groupHeading:"esri-feature-form__group-header",groupTitle:"esri-feature-form__group-title",groupDescription:"esri-feature-form__group-description",groupToggleIcon:"esri-feature-form__group-toggle-icon",groupCollapsed:"esri-feature-form__group--collapsed",groupSequential:"esri-feature-form__group--sequential",groupActive:"esri-feature-form__group--active",collapseIcon:"esri-icon-up",errorIcon:"esri-icon-notice-triangle",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input",select:"esri-select"},v={datePattern:"D",timePattern:"tt"};function F(e){return e&&e.inputFields}const I="data-field-name";let y=class extends u{constructor(e,t){super(e,t),this._activeDateFieldEdit=null,this._activeInputName=null,this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.disabled=!1,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new d,this._handleRadioInputChange=e=>{this._commitInputValue(e.target)},this._handleInputInput=e=>{this._commitInputValue(e.currentTarget,!0)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([s((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e&&e.name,this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-progress.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}destroy(){this._userUpdatedInputFieldNames.clear(),this._userUpdatedInputFieldNames=null}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 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}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return f("div",{class:this.classes(b.base,b.widget,b.panel)},"ready"===e?this.renderForm():null)}renderForm(){const{formTemplate:e}=this,t=i(e)&&e.title&&f(p,{key:"title",level:this.headingLevel},e.title),a=i(e)&&e.description&&f("p",{class:b.description,key:"description"},e.description),s=t||a?f("div",{class:b.formHeader},t,a):null;return f("form",{class:b.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},s,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.filter((e=>e.visible)).map(((e,t)=>F(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{formTemplate:a,disabled:s}=this,{description:n,inputFields:l,label:r,state:o}=e,u=l.filter((e=>e.visible)),d=this.viewModel.findField(this._activeInputName),m=!(!d||d.group!==e),h=`${this.id}_group_${t}`,_=`${this.id}_group-label_${t}`,g=`${this.id}_group-description_${t}`,v=n?f("p",{class:this.classes(b.groupDescription,b.description),id:g},n):null,F="sequential"===this.groupDisplay,I=F?m:"expanded"===o,y=I?b.collapseIcon:b.expandIcon;return f("fieldset",{"aria-expanded":I.toString(),"aria-labelledby":_,"aria-describedby":n?g:"",class:this.classes(b.group,F?b.groupSequential:null,I?null:b.groupCollapsed,m?b.groupActive:null,s?b.inputDisabled:null),disabled:s,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},f("button",{role:F?"presentation":void 0,class:b.groupHeader,type:"button",tabIndex:F?-1:0},f("div",{class:b.groupTitle},f(p,{class:b.groupLabel,id:_,level:i(a)&&a.title?c(this.headingLevel):this.headingLevel},r),v),F?null:f("span",{class:this.classes(y,b.groupToggleIcon)})),u.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let s;if(t)if(F(t))s=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;s=a.indexOf(i)+1}else s=0;for(let n=s;n<a.length;n++){const e=a[n];if(e.visible)return e}return null}renderLabeledField(e){const{feature:t,label:i,layer:a,type:s}=e;return f("label",{key:`${a.id}-${t.uid}-${e.name}`,class:b.label},[i,"unsupported"!==s?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:a,type:s,updating:n,value:l}=e,r=this.getCommonInputProps(e);if("coded-value"===t?.type){if(this._inputFieldHasInputType(e,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(a)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this.renderSwitchInputField(e,r);this._switchFieldsWithInitialIncompatibleValue.add(a)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),r):this.renderSelectInputField(e,this._getFieldValueOptions(a,t),r)}if("datetime-picker"===e.inputType||"date"===s)return this.renderDateInputField(e,r);const o="number"===s?f("input",{type:"number",...r,value:i(this._activeNumberFieldEdit)&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${r.value}`}):"text-area"===e.inputType?f("textarea",{...r}):f("input",{type:"text",...r});return n?f("div",{class:b.inputFieldWrapper},o,f("div",{class:b.inputFieldLoader},f("calcite-progress",{type:"indeterminate"}))):o}_parseDateTime(e,t,i){if(i){let a=_.fromJSDate(this._parseDate(e,i));const s=_.fromMillis(t.value??Date.now());return a="date"===i?a.set({hour:s.hour,minute:s.minute,second:s.second}):a.set({day:s.day,month:s.month,year:s.year}),a.isValid?a.toMillis():null}const a=_.fromJSDate(this._parseDate(e));return a.isValid?a.toMillis():null}renderDateInputField(e,t){const{value:i,includeTime:a}=e,{date:s,time:n}=this._formatDate(0),l=`${this.id}-${t.key}`,r=`${l}-date`,o=`${l}-time`,{_activeDateFieldEdit:u}=this;let{date:d,time:p}=this._formatDate(i);return u?.fieldName===e.name&&(d=u.date.input?.value??d,p=u.time.input?.value??p),f("div",{key:`${t.key}-date`,class:b.dateInputContainer},f("div",{class:this.classes(b.dateInputPart,a?null:b.loneDateInputPart)},f("input",{"aria-label":e.label,"aria-describedby":r,type:"text",...t,"data-date-part":"date",class:this.classes(t.class,b.inputDate),value:d}),f("div",{class:b.dateFormatHint,id:r},s)),a?f("div",{class:b.dateInputPart,key:"time-input"},f("input",{"aria-describedby":o,"aria-label":e.label,type:"text",...t,"data-date-part":"time",class:this.classes(t.class,b.inputTime),value:p}),f("div",{class:b.dateFormatHint,id:o},n)):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return f("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,disabled:t.disabled,class:this.classes(b.input,b.inputField,b.inputDisabled),onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value,[I]:t[I]})}renderSelectInputField(e,t,i){const{value:s}=e,{messages:n,messagesTemplates:l}=this,r=t.map((e=>e.map((e=>f("calcite-combobox-item",{value:`${e.value}`,"text-label":e.name,key:`#${e.value}`,selected:s===e.value}))))),[o,u]=r;this._registerIncompatibleValue(s,t.flat(),e,(e=>{u.unshift(f("calcite-combobox-item",{value:`${e}`,"text-label":`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[f("calcite-combobox-item-group",{key:"recommended",label:n.recommended},o),f("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=a(e.fieldElement)||this._inputFieldHasInputType(e,"combo-box")&&e.fieldElement.input.showNoValueOption;if(!e.required&&p){const t="",i=this._inputFieldHasInputType(e,"combo-box")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(f("calcite-combobox-item",{value:t,"text-label":this.messages.empty,key:"empty-option"},i))}return f("calcite-combobox",{...i,"selection-mode":"single",disabled:i.disabled||i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const s=this._fieldToInitialIncompatibleDomainValue,n=s.has(i.name);(n||null!=e&&""!==e&&!t.some((t=>t.value===e))||n)&&(n||s.set(i.name,e),a?.(s.get(i.name)))}renderRadioButtonsInputField(e,t,i){const{value:s}=e,n=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:e.name,value:t.value,selected:t.value===s,props:i})));this._registerIncompatibleValue(s,t,e);const l=a(e.fieldElement)||this._inputFieldHasInputType(e,"radio-buttons")&&e.fieldElement.input.showNoValueOption;if(!e.required&&l){const t="",a=this._inputFieldHasInputType(e,"radio-buttons")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty,l=s===t||null===s;n.unshift(this.renderRadioButton({key:"empty-option",label:a,name:e.name,value:t,selected:l,props:i}))}return f("div",{key:`${i.key}-radio`,class:b.inputRadioGroup},n)}renderSwitchInputField(e,t){const{value:i}=e,a=!!this._inputFieldHasInputType(e,"switch")&&i===e.fieldElement.input.onValue;return f("calcite-switch",{...t,class:b.inputSwitch,onCalciteSwitchChange:e=>{this._parseValue(e.currentTarget)},checked:a,disabled:t.disabled||t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:s,props:n}){return f("label",{key:e,class:b.inputRadioLabel},f("input",{...n,class:b.inputRadio,name:t,type:"radio",value:i,checked:a,onchange:this._handleRadioInputChange}),s)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:i(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:i(e.valueExpressionExecutor)&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return i(t)?f("calcite-input-message",{status:"invalid",icon:!0,active:!0},t):e.description?f("div",{key:"description",class:b.description},e.description):void 0}getCommonInputProps(e){const{disabled:t,groupDisplay:a}=this,{editable:s,group:n,hint:l,maxLength:r,minLength:o,name:u,required:d,type:p,valid:c,value:m}=e,h=this._userUpdatedInputFieldNames.has(u),f=!s,_="all"===a&&i(n)&&"collapsed"===n.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":c?"false":"true",class:this.classes(b.input,b.inputField,t||f?b.inputDisabled:null,h&&!c?b.inputInvalid:null),key:u,label:u,minlength:o>-1?`${o}`:"",maxlength:r>-1?`${r}`:"",...this._getNumberFieldConstraints(e),disabled:t,readOnly:f,value:null==m?"":`${m}`,[I]:u,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===p?this._handleNumberInputMouseDown:null,placeholder:"number"===p||"text"===p?l:"",required:d,tabIndex:_?-1:0}}_isInputFieldInGroup(e){return!F(e)&&i(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const n of this.viewModel.allInputFields){const{name:i,value:s}=n;!a(s)&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=s)}const i=this.viewModel.joinedContingentValues.slice(),s=new Map;for(const n of i){const i=n.values[e];if(a(i)||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:r}="null"===i.objectType?{code:"",name:this.messages.empty}:i.codedValue;if(s.has(l))continue;Object.entries(t).every((([e,t])=>!n.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,n.values[e])))&&s.set(l,{name:r,value:l})}return[...s.values()]}_getInputFieldFromInput(e){return this.viewModel.findField(e.getAttribute(I))}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getInputFieldFromInput(e),a=t.findField(this._activeInputName),s=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&a===i&&("radio-buttons"!==i.inputType||s||e.checked)&&(this._fieldFocusNeeded=!1,this._isInputFieldInGroup(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getInputFieldFromInput(t);this._activeInputName=i.name,"date"===i.type?this._syncDateFieldEdits(t):this._isNumberInputField(i)&&this._setUpNumberFieldEdit(t)}_isNumberInputField({domain:e,inputType:t="text-box",type:i}){return"number"===i&&"text-box"===t&&(!e||"coded-value"!==e.type)}_handleInputBlur(e){const t=e.target,a=this._getInputFieldFromInput(t);if("date"===a.type){const i=e.relatedTarget,s=i&&this._getInputFieldFromInput(i);if(s&&"date"===a.type&&"date"===s.type&&a.field===s.field){if(""!==t.value&&""===i.value){const s=i.getAttribute("data-date-part");i.value=this._formatDate(a.value??Date.now())[s],this._parseDate(t.value,t.getAttribute("data-date-part"))&&this._commitInputValue(e.target,!0,!1)}return}}"number"===a.type&&i(this._activeNumberFieldEdit)&&(this._activeNumberFieldEdit.input.value=`${a.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitInputValue(e,t=!1,a=!0){const s=this._getInputFieldFromInput(e);if(this._activeDateFieldEdit){const{date:i,time:n}=this._activeDateFieldEdit,l=this._parseDateTime(e.value,s,i.active?"date":"time"),r=null!==this.viewModel.getValue(s.name),o=i.input&&(n.input||!s.includeTime),u=null===l;if(t){if(u)return;(o||!a||r)&&this._updateDateFieldValue(s,l)}else{if(""===i.input?.value||""===n.input?.value)this._updateDateFieldValue(s,null);else if(o){const e=`${i.input.value} ${n.input?.value??""}`,t=this._parseDateTime(e,s);!(null!==t)&&r||this._updateDateFieldValue(s,t)}this._activeDateFieldEdit=null}}else i(this._activeNumberFieldEdit)&&this._isNumberInputField(s)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(e)}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:s}=e,n=this._getInputFieldFromInput(e.target);if("Enter"===t)this._isInputFieldInGroup(n)&&"collapsed"===n.group.state&&(n.group.state="expanded");else{const{type:l}=n.field,r="single"===l||"double"===l,o=!i&&!a&&!s;if(("integer"===l||"small-integer"===l||r)&&o&&1===t.length){const i=Number(t),a=["-","+"],s=["e","."],n=r?[...a,...s]:a;isNaN(i)&&!n.includes(t)&&e.preventDefault()}}}_setUpNumberFieldEdit(e){const t=this._getInputFieldFromInput(e);this._activeNumberFieldEdit={fieldName:t.name,input:e,value:e.value}}_syncDateFieldEdits(e){const t=this._getInputFieldFromInput(e);if("date"!==t.type)return;const i=e.getAttribute("data-date-part"),a="date"===i?{value:e.value,input:e,active:!0}:{...this._activeDateFieldEdit?.date,active:!1},s="time"===i?{value:e.value,input:e,active:!0}:{...this._activeDateFieldEdit?.time,active:!1};this._activeDateFieldEdit={fieldName:t.name,date:a,time:s}}_updateFieldValue(e){const t=e.getAttribute(I);if(this.viewModel.setValue(t,this._parseValue(e)),this._userUpdatedInputFieldNames.add(t),this.viewModel.fieldsWithContingentValues.has(t)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>i(t))));this.viewModel.validateContingencyConstraints(e)}}_updateDateFieldValue(e,t){this.viewModel.setValue(e.name,t),this._userUpdatedInputFieldNames.add(e.name)}_parseValue(e){const t=this._getInputFieldFromInput(e),i=e.value;if(this._inputFieldHasInputType(t,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;if("number"===a)return i?parseFloat(i):null;if("date"===a){if(!i)return null;const a=Number(i);if(!isNaN(a))return a;const s=e.getAttribute("data-date-part"),n=this._parseDate(i,s);if(!n)return null;let l=_.fromJSDate(n);const r=t.domain,o=_.now();let u=o;if(r&&"range"===r.type){const e=_.fromMillis(r.maxValue);o<e&&(u=e)}const d=this.viewModel.getValue(t.name),p=null!=d?_.fromMillis(d):u;return l="date"===s?l.set({hour:p.hour,minute:p.minute,second:p.second}):l.set({day:p.day,month:p.month,year:p.year}),l.toMillis()}return i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,a="sequential"===this.groupDisplay,s=`.${b.groupHeader}`;if(!(i&&!e.target.closest(s))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name,a){const a=e.target.closest(s);if(i&&!a)return;this.viewModel.inputFields.forEach((e=>{F(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=a,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_formatDate(e){if(null==e)return{date:"",time:""};const t=_.fromMillis(e,{locale:g(),numberingSystem:"latn"});return{date:t.toLocaleString({year:"numeric",month:"2-digit",day:"2-digit"}),time:t.toFormat(v.timePattern)}}_parseDate(e,t){if(null==e||""===e)return null;const{timePattern:i,datePattern:a}=v,s=t?"date"===t?a:i:`${a} ${i}`,n=_.fromFormat(e,s,{locale:g(),numberingSystem:"latn"});return n.isValid?n.toJSDate():null}_inputFieldHasInputType(e,t){return i(e.fieldElement)&&e.fieldElement.input?.type===t}_valueIsValidContingentValue(e,i){switch(i.objectType){case"any":return!0;case"null":return null==e;case"code":return e===i.codedValue?.code;case"range":return e>=i.minValue&&e<=i.maxValue;default:return t(i.objectType),!1}}};e([n()],y.prototype,"disabled",void 0),e([n()],y.prototype,"feature",null),e([n()],y.prototype,"formTemplate",null),e([n()],y.prototype,"groupDisplay",void 0),e([n()],y.prototype,"headingLevel",void 0),e([n()],y.prototype,"label",null),e([n()],y.prototype,"layer",null),e([n(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],y.prototype,"messages",void 0),e([n(),m("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],y.prototype,"messagesTemplates",void 0),e([n()],y.prototype,"spatialReference",null),e([n()],y.prototype,"strict",null),e([n(),h(["value-change","submit"])],y.prototype,"viewModel",void 0),y=e([l("esri.widgets.FeatureForm")],y);const w=y;export{w as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import s from"../../core/Evented.js";import i from"../../core/Handles.js";import{watch as r,initial as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import s from"../../core/Evented.js";import i from"../../core/Handles.js";import{watch as r,initial as a}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"./ListItem.js";import{getItemLayers as c,findLayerListMode as d}from"./support/layerListUtils.js";const h={view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children"},m="hide",p=t.ofType(n);let y=class extends s.EventedAccessor{constructor(e){super(e),this._handles=new i,this.checkPublishStatusEnabled=!1,this.listItemCreatedFunction=null,this.operationalItems=new p,this.view=null}initialize(){this._handles.add([r((()=>[this.view,this.view?.ready]),(()=>this._viewHandles()),a),r((()=>[this.listItemCreatedFunction,this.checkPublishStatusEnabled]),(()=>this._recompileList()))],h.view)}destroy(){this._handles.destroy(),this._handles=null,this.view=null,this.operationalItems.removeAll()}get state(){const e=this.get("view");return this.get("view.ready")?"ready":e?"loading":"disabled"}triggerAction(e,t){e&&!e.disabled&&this.emit("trigger-action",{action:e,item:t})}moveListItem(e,t,s,i){const r=e?.layer;if(!r)return;const a=this.view?.map?.layers,o=t?c(t):a,l=s?c(s):a;if(!o||!l)return;const{operationalItems:n}=this,d=t?.children||n,h=s?.children||n,m=l.length-i;e.parent=s||null,d.includes(e)&&d.remove(e),o.includes(r)&&o.remove(r),h.includes(e)||h.add(e,m),l.includes(r)||l.add(r,m)}_createLayerViewHandles(e){const{_handles:t}=this;t.remove(h.layerViews),this._compileList(),e&&t.add(e.on("change",(()=>this._compileList())),h.layerViews)}_createMapLayerHandles(e){const{_handles:t}=this;t.remove(h.mapLayers),this._compileList(),e&&t.add(e.on("change",(()=>this._compileList())),h.mapLayers)}_createListItem(e){const{view:t,listItemCreatedFunction:s,checkPublishStatusEnabled:i}=this;return new n({checkPublishStatusEnabled:i,layer:e,listItemCreatedFunction:s,view:t})}_removeAllItems(){const{_handles:e,operationalItems:t}=this;t.forEach((t=>{e.remove(`${h.children}-${t.uid}`)})),t.removeAll()}_getViewableLayers(e){if(e)return e.filter((e=>d(e)!==m))}_watchLayersListMode(e){const{_handles:t}=this;t.remove(h.layerListMode),e&&e.forEach((e=>{"listMode"in e&&t.add(r((()=>e.listMode),(()=>this._compileList())),h.layerListMode)}))}_compileList(){const e=this.get("view.map.layers");this._watchLayersListMode(e);const t=this._getViewableLayers(e);t&&t.length?(this._createNewItems(t),this._removeItems(t),this._sortItems(t)):this._removeAllItems()}_createNewItems(e){const{operationalItems:t}=this;e.forEach((e=>{t.find((t=>t.layer===e))||t.add(this._createListItem(e))}))}_removeItems(e){const{_handles:t,operationalItems:s}=this,i=[];s.forEach((s=>{s&&e&&e.includes(s.layer)||(t.remove(`${h.children}-${s.uid}`),i.push(s))})),s.removeMany(i)}_sortItems(e){const{operationalItems:t}=this;t.sort(((t,s)=>{const i=e.indexOf(t.layer),r=e.indexOf(s.layer);return i>r?-1:i<r?1:0}))}_recompileList(){this._removeAllItems(),this._compileList()}_viewHandles(){const{_handles:e,view:t}=this;e.remove([h.mapLayers,h.layerViews,h.viewLayers]),this._compileList(),t&&t.ready&&e.add([r((()=>this.view?.map?.allLayers),(e=>this._createMapLayerHandles(e)),a),r((()=>this.view?.allLayerViews),(e=>this._createLayerViewHandles(e)),a)],h.viewLayers)}};e([o()],y.prototype,"checkPublishStatusEnabled",void 0),e([o()],y.prototype,"listItemCreatedFunction",void 0),e([o({type:p})],y.prototype,"operationalItems",void 0),e([o({readOnly:!0})],y.prototype,"state",null),e([o()],y.prototype,"view",void 0),y=e([l("esri.widgets.LayerList.LayerListViewModel")],y);const v=y;export{v as default};
|