UNPKG

@arcgis/map-components

Version:
2 lines 3.06 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import a from"./KYU6MBFA.js";import{Q as v,S as b,b as u,c as g}from"./WUJCCZQC.js";export default $arcgis.t(([{renderColorRampPreviewHTML:R},{e:p,g:w,h:x}])=>{var E=10,y=20,h=10,z=20;function m(s){return typeof s=="number"}function C(s="vertical"){let e="stroke:rgb(200, 200, 200);stroke-width:1";return s==="vertical"?u`<svg height=4 width=10>${g`<line style=${v(e)} x1=0 x2=10 y1=2 y2=2 />`}</svg>`:u`<svg height=10 width=10>${g`<line style=${v(e)} x1=5 x2=5 y1=0 y2=10 />`}</svg>`}function S(s,e="vertical"){let n={height:`${y}px`,opacity:s?.toString()};return u`<div class="univariate-above-below-symbol" style=${v(n)}>${C(e)}</div>`}function $(s,e,n,o="vertical",i){s.infos.forEach((t,l)=>{if(i&&l===2){t.preview=b(S(n,o));return}else{let r=(m(t.size)?p(t.size):0)+(o==="horizontal"?z:h),c=t.preview,f=c?.tagName.toLowerCase()==="div",a=f?c:document.createElement("div");a.className="univariate-above-below-symbol",o==="horizontal"?a.style.width=`${r}px`:a.style.height=`${r}px`,!f&&c&&a.appendChild(c),x(a,w(e,t.label)),t.preview=a}})}function P(s,e="classic"){let n=s.infos,o=n.at(0),i=n.at(-1),t=m(o.size)?p(o.size):0,l=m(i.size)?p(i.size):0;return e==="classic"?(t+h)/2:(t-l)/2}function T(s,e){if(!s)return null;let n=s.infos.map(i=>i.color),o=R(e.type==="full"?n:e.type==="above"?n.slice(0,3):n.slice(2,5),{width:e.width??void 0,height:e.height??void 0,align:e.rampAlignment,cssEffectFilter:e.cssEffectFilter,ariaLabel:e.ariaLabel??void 0});return o.className="color-ramp",e.opacity!=null&&(o.style.opacity=e.opacity.toString()),o}function k(s,e,n,o="vertical"){let i=0,t=s.infos,l=Math.floor(t.length/2),r=e==="full"||e==="above"?0:l,c=e==="full"||e==="below"?t.length-1:l;for(let f=r;f<=c;f++)if(n&&f===l)i+=o==="horizontal"?E:y;else{let a=t[f].size,d=(m(a)?p(a):0)+(o==="horizontal"?z:h);i+=d}return Math.round(i)}function j(s,e,n,o="vertical"){let i=k(s,e,n,o),t=s.infos,l=Math.floor(t.length/2),r=e==="full"||e==="above"?0:l,c=e==="full"||e==="below"?t.length-1:l,f=m(t[r].size)?t[r].size:0,a=m(t[c].size)?t[c].size:0,d=e==="full"?f+a:e==="above"?f:a,L=n?o==="vertical"?y:E:0,M=o==="vertical"?h*(e==="full"?2:1):z*(e==="full"?2:1);return Math.round(i-(p(d)/2+L/2+M/2))}function q(s,e,n,o="vertical"){let i=s.infos,t=i.find(({type:r})=>r==="size-ramp"),l=i.find(({type:r})=>r==="color-ramp");return t&&(t={...t},t.infos=[...t.infos],$(t,e,n,o,!0)),l&&(l={...l},l.infos=[...l.infos]),o==="horizontal"&&(t?.infos.reverse(),l?.infos.reverse()),{sizeRampElement:t,colorRampElement:l}}function B(s,e,n="vertical"){let o=s.infos,i=o.find(({type:l})=>l==="size-ramp"),t=o.find(({type:l})=>l==="color-ramp");return i&&(i={...i},i.infos=[...i.infos],$(i,e,null,n,!1)),t&&(t={...t},t.infos=[...t.infos]),n==="horizontal"&&(i?.infos.reverse(),t?.infos.reverse()),{sizeRampElement:i,colorRampElement:t}}var D={marginLeft:"3px"},H={display:"table-cell",verticalAlign:"middle"},W={display:"flex",alignItems:"flex-start"};return{a:P,b:T,c:k,d:j,e:q,f:B,g:D,h:H,i:W}},"symbols/support/symbolUtils",a)