@tmf_ciclica/ciclicastorybook 1.2.134 → 1.2.136
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/dist/index.cjs.js +1 -1
- package/dist/index.es.js +13 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -84,4 +84,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
84
84
|
<strong>${E(ne.key)}</strong><br/>
|
|
85
85
|
${ne.xKey}<br/>
|
|
86
86
|
${y(Ce)}
|
|
87
|
-
`),ce.select(this).style("opacity",.8),p&&p(q,{key:ne.key,value:Ce,data:ne.data})}).on("mousemove",function(q){x&&se&&se.style("top",q.pageY-10+"px").style("left",q.pageX+10+"px")}).on("mouseout",function(){x&&se&&se.style("visibility","hidden"),ce.select(this).style("opacity",1)}),C&&Xe.on("click",function(q,ne){const Ce=ne.value;C(q,{key:ne.key,value:Ce,data:ne.data})}),ee&&ee.length>1){const q=ce.line().x(ne=>ne.x).y(ne=>ne.y).curve(ce.curveMonotoneX);le.append("path").datum(ee).attr("class","line").attr("d",q).attr("fill","none").attr("stroke","#ff6b6b").attr("stroke-width",2).attr("stroke-linecap","round").attr("stroke-linejoin","round"),le.selectAll(".line-point").data(ee).enter().append("circle").attr("class","line-point").attr("cx",ne=>ne.x).attr("cy",ne=>ne.y).attr("r",4).attr("fill","#ff6b6b").attr("stroke","white").attr("stroke-width",1)}return()=>{se&&se.remove()}},[e,t,n,r,P,a,f,u,d,h,g,y,b,p,C,w,T,j,v,x,S,A]),l.jsx("div",{ref:z,className:`${ys.svgContainer} ${c}`,style:{width:o,height:i+a.top+a.bottom,overflowX:"auto"},children:l.jsx("svg",{ref:O,className:ys.svg})})};qi.propTypes={data:s.arrayOf(s.object).isRequired,keys:s.arrayOf(s.string).isRequired,colors:s.oneOfType([s.arrayOf(s.string),s.object]),lineData:s.arrayOf(s.number),width:s.oneOfType([s.string,s.number]),height:s.number,margin:s.shape({top:s.number,right:s.number,bottom:s.number,left:s.number}),className:s.string,showXAxisLabels:s.bool,showYAxisLabels:s.bool,showGrid:s.bool,xAxisTickRotation:s.number,yAxisTickFormat:s.func,barPadding:s.number,animationDuration:s.number,onBarHover:s.func,onBarClick:s.func,title:s.string,xAxisLabel:s.string,yAxisLabel:s.string,stackOrder:s.oneOf(["reverse","ascending","descending","insideOut","none"]),showTooltip:s.bool,reverseKeys:s.bool,minBarSlotWidth:s.number,wrapXAxisLabels:s.bool};const Lf="_externalContainer_1er0i_2",Mf="_externalSintetic_1er0i_9",Rf="_titles_1er0i_13",Df="_titleContainer_1er0i_22",If="_yearTitles_1er0i_36",Pf="_yearTitle_1er0i_36",Bf="_yearDatas_1er0i_50",Vf="_yearDataContainer_1er0i_58",Ff="_yearDataContent_1er0i_66",zf="_bigNumber_1er0i_79",qf="_circle_1er0i_82",Wf="_totalContainer_1er0i_99",Uf="_total_1er0i_99",Ie={externalContainer:Lf,externalSintetic:Mf,titles:Rf,titleContainer:Df,yearTitles:If,yearTitle:Pf,yearDatas:Bf,yearDataContainer:Vf,yearDataContent:Ff,bigNumber:zf,circle:qf,totalContainer:Wf,total:Uf},Zf=e=>{if(e>=1e3||e<=-1e3)return parseInt(e.toFixed());if(e>=100||e<=-100)return parseFloat(e.toFixed(1));if(e>=10||e<=-10)return parseFloat(e.toFixed(2));if(e>0||e<0)return parseFloat(e.toFixed(3));if(e===0)return e},Hf=(e,t)=>{let n=0;return t.forEach(r=>{r[e]&&(n+=r[e])}),n},Wi=({data:e,keys:t,colors:n,locales:r,total:o=!1,years:i=!1,activeGraphics:a="ind",units:c={},translate:u,getTotal:d=Hf,columnWidth:h=50})=>{const g=u||(f=>f),y=f=>f==="demanda_red"||f==="reduccio_demanda_red"?(c.demanda||"").replace("(","").replace(")",""):c[f]||"";return l.jsxs("div",{className:`${Ie.externalContainer} ${a==="sin"?Ie.externalSintetic:""}`,children:[i===!0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{}),l.jsx("div",{className:Ie.yearTitles,children:e.map((f,b)=>l.jsx("div",{className:Ie.yearTitle,style:{width:h},children:f.anyo},b))})]}),l.jsx("div",{className:Ie.titles,children:t.map((f,b)=>l.jsxs("div",{className:Ie.titleContainer,children:[g(r[f]),a!=="sin"&&l.jsx("span",{className:Ie.circle,style:{background:n[f]}})]},b))}),o===!0&&l.jsx("div",{className:Ie.totalContainer,children:t.map((f,b)=>{var p;return l.jsxs("div",{className:`${Ie.total} ${d(f,e)>9999||d(f,e)<-9999?Ie.bigNumber:""}`,children:[(p=d(f,e))==null?void 0:p.toLocaleString("es-ES")," ",y(f)]},b)})}),l.jsx("div",{className:Ie.yearDatas,children:e.map((f,b)=>l.jsx("div",{className:Ie.yearDataContainer,style:{width:h},children:t.map((p,C)=>{var w,T;return isNaN(f[p])?null:l.jsx("div",{className:`${Ie.yearDataContent} ${f[p]>9999||f[p]<-9999?Ie.bigNumber:""}`,children:f[p]<1e4||f[p]>-1e4?(w=Zf(f[p]))==null?void 0:w.toLocaleString("es-ES"):(T=f[p])==null?void 0:T.toLocaleString("es-ES")},C)})},b))})]})};Wi.propTypes={data:s.arrayOf(s.shape({anyo:s.oneOfType([s.string,s.number]).isRequired})).isRequired,keys:s.arrayOf(s.string).isRequired,colors:s.objectOf(s.string).isRequired,locales:s.objectOf(s.string).isRequired,total:s.bool,years:s.bool,activeGraphics:s.oneOf(["ind","sin"]),units:s.objectOf(s.string),translate:s.func,getTotal:s.func,columnWidth:s.number};const Kf="_speedGraphic_d1k72_2",_r={speedGraphic:Kf},Ui=({minValue:e=0,maxValue:t=100,value:n=50,title:r=!1,percent:o=!1,unit:i=!1,greenColor:a="#00CF1E",orangeColor:c="#FFAC00",redColor:u="#FF1E37"})=>{n<e&&(n=e),n>t&&(n=t);const d=(n-e)/(t-e),h=270+d*180,g=o?Math.round(d*100):n;return l.jsxs("div",{className:_r.speedGraphic,children:[l.jsxs("svg",{width:"244",height:"130",viewBox:"0 0 244 130",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M0 122C0 111.944 1.2433 101.927 3.70162 92.1756L26.2619 97.8633C24.2724 105.755 23.2662 113.862 23.2662 122H0Z",fill:a}),l.jsx("path",{d:"M16.3442 61.0012C21.3714 52.2936 27.4557 44.2409 34.4588 37.0263L51.1534 53.2313C45.4859 59.0701 40.5619 65.5871 36.4934 72.6341L16.3442 61.0012Z",fill:a}),l.jsx("path",{d:"M60.9088 16.3976C69.6119 11.3628 78.9041 7.42322 88.5739 4.66843L94.9485 27.0443C87.1228 29.2737 79.6027 32.462 72.5592 36.5367L60.9088 16.3976Z",fill:c}),l.jsx("path",{d:"M121.797 0.000169508C131.851 -0.0165912 141.869 1.20965 151.623 3.65101L145.974 26.2209C138.08 24.2451 129.972 23.2527 121.835 23.2663L121.797 0.000169508Z",fill:c}),l.jsx("path",{d:"M182.623 16.1279C191.348 21.124 199.422 27.1797 206.662 34.157L190.516 50.9092C184.657 45.2625 178.123 40.3617 171.061 36.3183L182.623 16.1279Z",fill:u}),l.jsx("path",{d:"M227.238 60.2836C232.325 68.9568 236.319 78.2255 239.131 87.8788L216.794 94.3859C214.518 86.5735 211.285 79.0725 207.169 72.0533L227.238 60.2836Z",fill:u}),l.jsx("path",{d:"M4.15505 90.4316C6.75674 80.7194 10.5491 71.3662 15.4458 62.5846L35.7663 73.9155C31.8035 81.0224 28.7343 88.5919 26.6288 96.4519L4.15505 90.4316Z",fill:a}),l.jsx("path",{d:"M35.733 35.733C42.8426 28.6233 50.8039 22.4198 59.4357 17.2636L71.3671 37.2375C64.3814 41.4104 57.9384 46.4308 52.1846 52.1846L35.733 35.733Z",fill:a}),l.jsx("path",{d:"M90.3004 4.19027C100.01 1.57776 110.005 0.175523 120.058 0.0154601L120.428 23.2787C112.292 23.4082 104.203 24.543 96.3457 26.6573L90.3004 4.19027Z",fill:c}),l.jsx("path",{d:"M153.423 4.11614C163.138 6.70584 172.496 10.4866 181.284 15.3725L169.978 35.707C162.866 31.7529 155.293 28.6932 147.43 26.5973L153.423 4.11614Z",fill:c}),l.jsx("path",{d:"M239.602 89.538C242.532 100.152 244.011 111.114 244 122.125L220.734 122.101C220.743 113.19 219.546 104.319 217.175 95.7287L239.602 89.538Z",fill:u}),l.jsx("path",{d:"M207.769 35.2376C214.919 42.3062 221.168 50.2316 226.374 58.8336L206.469 70.8798C202.256 63.9183 197.199 57.5043 191.412 51.7837L207.769 35.2376Z",fill:u}),l.jsx("g",{transform:`rotate(${h} 122 122)`,children:l.jsx("path",{id:"aguja",d:"M121 119.5V33",stroke:"#605B56","stroke-width":"2"})})]}),l.jsxs("div",{className:_r.value,children:[g,o&&"%",i&&i]}),r&&l.jsx("div",{className:_r.title,children:r})]})};Ui.propTypes={minValue:s.number.isRequired,maxValue:s.number.isRequired,value:s.number.isRequired,percent:s.bool,title:s.string,unit:s.string,greenColor:s.string,orangeColor:s.string,redColor:s.string};const wr="#ffffff",Gf="#ffffff";function it(e,t,n,r){const o=(r-90)*Math.PI/180;return{x:e+n*Math.cos(o),y:t+n*Math.sin(o)}}function bs(e,t,n,r,o,i){if(Math.abs(i-o)>=359.99)return n===0?`M ${e-r} ${t} A ${r} ${r} 0 1 1 ${e+r} ${t} A ${r} ${r} 0 1 1 ${e-r} ${t} Z`:[`M ${e-r} ${t} A ${r} ${r} 0 1 1 ${e+r} ${t} A ${r} ${r} 0 1 1 ${e-r} ${t} Z`,`M ${e-n} ${t} A ${n} ${n} 0 1 0 ${e+n} ${t} A ${n} ${n} 0 1 0 ${e-n} ${t} Z`].join(" ");const a=it(e,t,r,o),c=it(e,t,r,i),u=i-o>180?1:0;if(n===0)return`M ${e} ${t} L ${a.x} ${a.y} A ${r} ${r} 0 ${u} 1 ${c.x} ${c.y} Z`;const d=it(e,t,n,i),h=it(e,t,n,o);return[`M ${a.x} ${a.y}`,`A ${r} ${r} 0 ${u} 1 ${c.x} ${c.y}`,`L ${d.x} ${d.y}`,`A ${n} ${n} 0 ${u} 0 ${h.x} ${h.y}`,"Z"].join(" ")}function Yf(e){const t=e.reduce((r,o)=>r+(o.value||0),0);let n=0;return e.map(r=>{const o=r.value/t*360,i=n;return n+=o,{...r,sa:i,ea:n}})}function vs(e,t,n,r,o){const i=n+(r-n)/2,a=it(e,t,o,i);return{tx:a.x-e,ty:a.y-t}}const Zi=({type:e="cheese",data:t=[],title:n,size:r=260,donutThickness:o=56,gapWidth:i=3,gapColor:a,backgroundColor:c="transparent",fontColor:u="black",fontColorInside:d="white",containerStyles:h={},alignLeft:g=!1})=>{const[y,f]=_.useState(null),b=r/2,p=r/2,C=r/2-14,w=e==="donut"?C-o:0,T=e==="donut"?C-o/2:C*.62,j=_.useMemo(()=>Yf(t),[t]),v=y!==null?j[y]:null,x=j.some($=>$.ea-$.sa>=359.99),S=a||(c==="transparent"?Gf:c);return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px",padding:"0px",background:c,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",...h},children:[l.jsxs("div",{style:{minHeight:"40px",display:"flex",flexDirection:"column",gap:"2px"},children:[n&&l.jsx("h2",{style:{margin:0,color:u,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.5px"},children:n}),l.jsx("div",{style:{height:"22px",display:"flex",alignItems:"center",gap:"8px",transition:"opacity 0.15s",opacity:v?1:0},children:v&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{display:"inline-block",width:"10px",height:"10px",borderRadius:"50%",background:v.color||wr,flexShrink:0}}),l.jsxs("span",{style:{color:u,fontSize:"14px",fontWeight:"600"},children:[v.title," — ",v.value,"%"]})]})})]}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:g?"flex-start":"center",gap:"16px"},children:[l.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,style:{overflow:"visible"},children:[j.map(($,A)=>{const O=y===A,{tx:z,ty:P}=O&&!x?vs(b,p,$.sa,$.ea,10):{tx:0,ty:0};return l.jsx("g",{transform:`translate(${z}, ${P})`,style:{transition:"transform 0.18s ease",pointerEvents:"none"},children:l.jsx("path",{d:bs(b,p,w,C,$.sa,$.ea),fill:$.color||wr,style:{filter:O?"brightness(1.25)":"brightness(1)",transition:"filter 0.18s ease"}})},A)}),!x&&j.map(($,A)=>{const O=it(b,p,C,$.sa),z=e==="cheese"?b:it(b,p,w,$.sa).x,P=e==="cheese"?p:it(b,p,w,$.sa).y;return l.jsx("line",{x1:z,y1:P,x2:O.x,y2:O.y,stroke:S,strokeWidth:i,strokeLinecap:"butt",style:{pointerEvents:"none"}},`gap-${A}`)}),j.map(($,A)=>{if($.ea-$.sa<20)return null;const O=y===A,{tx:z,ty:P}=O&&!x?vs(b,p,$.sa,$.ea,10):{tx:0,ty:0},m=$.sa+($.ea-$.sa)/2,E=it(b,p,T,m);return l.jsxs("text",{x:E.x+z,y:E.y+P,textAnchor:"middle",dominantBaseline:"middle",fill:d,fontSize:"14",fontWeight:"700",fontFamily:"'Segoe UI', sans-serif",pointerEvents:"none",style:{transition:"x 0.18s ease, y 0.18s ease"},children:[$.value,"%"]},`lbl-${A}`)}),j.map(($,A)=>l.jsx("path",{d:bs(b,p,w,C,$.sa,$.ea),fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>f(A),onMouseLeave:()=>f(null)},`hit-${A}`))]}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"12px 24px",justifyContent:g?"flex-start":"center"},children:t.map(($,A)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",opacity:y===null||y===A?1:.4,transition:"opacity 0.15s"},onMouseEnter:()=>f(A),onMouseLeave:()=>f(null),children:[l.jsx("span",{style:{width:"32px",height:"14px",borderRadius:"3px",background:$.color||wr,flexShrink:0}}),l.jsx("span",{style:{color:u,fontSize:"13px",fontWeight:"400"},children:$.title})]},A))})]})]})};Zi.propTypes={type:s.oneOf(["cheese","donut"]),data:s.arrayOf(s.shape({value:s.number.isRequired,title:s.string.isRequired,color:s.string})).isRequired,title:s.string,size:s.number,donutThickness:s.number,gapWidth:s.number,gapColor:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,containerStyles:s.object,alignLeft:s.bool};const xs=["#a8d8cf","#3bbfa0","#5dd4b8","#7ed4c2","#2aa88a"],Hi=({data:e=[],title:t,backgroundColor:n="#0d3d4a",fontColor:r="#ffffff",barHeight:o=52,animated:i=!0,borderRadius:a,containerStyles:c={},fontColorInside:u="white",borderFontColorInside:d})=>{const[h,g]=_.useState(i?0:1);_.useEffect(()=>{if(!i)return;const b=requestAnimationFrame(()=>g(1));return()=>cancelAnimationFrame(b)},[i]);const y=Math.max(...e.map(b=>b.value),1),f=a??"6px";return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"0px",background:n,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",minWidth:"420px",...c},children:[t&&l.jsx("h2",{style:{margin:"0 0 20px 0",color:r,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.4px"},children:t}),l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"18px"},children:e.map((b,p)=>{const C=b.color||xs[p%xs.length],w=b.value/y*100*h;return l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[l.jsx("span",{style:{color:r,fontSize:"14px",fontWeight:"400",opacity:.9},children:b.title}),l.jsxs("div",{style:{position:"relative",height:`${o}px`,background:"transparent",borderRadius:f,overflow:"hidden"},children:[l.jsx("div",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${w}%`,background:C,borderRadius:f,transition:i?"width 0.8s cubic-bezier(0.16, 1, 0.3, 1)":"none"}}),l.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:u||n,fontSize:"18px",fontWeight:"700",pointerEvents:"none",letterSpacing:"-0.3px",...d?{WebkitTextStroke:`1px ${d}`,paintOrder:"stroke fill"}:{}},children:b.value})]})]},p)})})]})};Hi.propTypes={data:s.arrayOf(s.shape({title:s.string.isRequired,value:s.number.isRequired,color:s.string})),title:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,borderFontColorInside:s.string,barHeight:s.number,animated:s.bool,borderRadius:s.oneOfType([s.string,s.number]),containerStyles:s.object};const Cs=["#a8d8cf","#3bbfa0","#5dd4b8","#7ed4c2","#2aa88a"],Ki=({data:e=[],title:t,backgroundColor:n="black",fontColor:r="#ffffff",fontColorInside:o="#0d3d4a",borderFontColorInside:i,barWidth:a=52,maxBarHeight:c=200,animated:u=!0,separatorColor:d,containerStyles:h={}})=>{const[g,y]=_.useState(u?0:1);_.useEffect(()=>{if(!u)return;const C=requestAnimationFrame(()=>requestAnimationFrame(()=>y(1)));return()=>cancelAnimationFrame(C)},[u]);const f=Math.max(...e.map(C=>C.value),1),b=d||(r==="#ffffff"?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.15)"),p={fontSize:"15px",fontWeight:"700",letterSpacing:"-0.3px",lineHeight:1,pointerEvents:"none",whiteSpace:"nowrap",...i?{WebkitTextStroke:`1px ${i}`,paintOrder:"stroke fill"}:{}};return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"0",background:n,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",...h},children:[t&&l.jsx("h2",{style:{margin:"0 0 24px 0",color:r,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.4px"},children:t}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[l.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"12px",height:`${c}px`},children:e.map((C,w)=>{const T=C.color||Cs[w%Cs.length],j=C.value===0,v=j?0:C.value/f*c*g;return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",width:`${a}px`,height:"100%"},children:j?l.jsx("span",{style:{...p,color:o,marginBottom:"6px"},children:C.value}):l.jsx("div",{style:{position:"relative",width:"100%",height:`${v}px`,background:T,borderRadius:"6px 6px 0 0",transition:u?"height 0.85s cubic-bezier(0.16, 1, 0.3, 1)":"none",display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"10px"},children:l.jsx("span",{style:{...p,color:o},children:C.value})})},w)})}),l.jsx("div",{style:{height:"1.5px",background:b,borderRadius:"1px"}}),l.jsx("div",{style:{display:"flex",gap:"12px",marginTop:"10px"},children:e.map((C,w)=>l.jsx("div",{style:{width:`${a}px`,textAlign:"center",color:r,fontSize:"13px",fontWeight:"400",opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C.title},w))})]})]})};Ki.propTypes={data:s.arrayOf(s.shape({title:s.string.isRequired,value:s.number.isRequired,color:s.string})).isRequired,title:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,borderFontColorInside:s.string,barWidth:s.number,maxBarHeight:s.number,animated:s.bool,separatorColor:s.string,containerStyles:s.object};const Xf="_percentageBarContainer_1g3hk_3",Qf="_barContainer_1g3hk_10",Jf="_segment_1g3hk_19",ep="_handle_1g3hk_36",tp="_labelsContainer_1g3hk_68",np="_labelItem_1g3hk_73",rp="_labelsListContainer_1g3hk_85",op="_labelColor_1g3hk_105",sp="_labelText_1g3hk_114",ip="_labelValue_1g3hk_122",ap="_labelTranslation_1g3hk_127",Me={percentageBarContainer:Xf,barContainer:Qf,segment:Jf,handle:ep,labelsContainer:tp,labelItem:np,labelsListContainer:rp,labelColor:op,labelText:sp,labelValue:ip,labelTranslation:ap},lp=2,_s=e=>{const t=e.reduce((n,r)=>n+r.value,0);return t===0?e.map(()=>100/e.length):e.map(n=>n.value/t*100)},ws=(e,t)=>{try{const r=new Function("x",`return (${t})`)(e);return isNaN(r)?"N/A":r.toFixed(2)}catch{return"N/A"}},Gi=({items:e,showLabels:t="bar",showTranslations:n=!0,onChange:r,minPercentage:o=lp})=>{const[i,a]=_.useState(()=>_s(e)),c=_.useRef(null),u=_.useRef(null);_.useEffect(()=>{e&&e.length>0&&a(_s(e))},[e]);const d=_.useCallback(y=>{if(!c.current||!u.current)return;const{dividerIndex:f}=c.current,b=u.current.getBoundingClientRect(),p=(y.touches?y.touches[0].clientX:y.clientX)-b.left,C=Math.max(0,Math.min(100,p/b.width*100));a(w=>{const T=[...w],j=w.slice(0,f).reduce(($,A)=>$+A,0),v=j+w[f]+w[f+1];let x=C-j,S=v-C;return x<o&&(x=o,S=v-j-o),S<o&&(S=o,x=v-j-o),T[f]=x,T[f+1]=S,T})},[o]),h=_.useCallback(()=>{c.current&&(c.current=null,document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",h),a(y=>(r&&r(e.map((f,b)=>({...f,value:y[b]}))),y)))},[d,r,e]),g=(y,f)=>{f.preventDefault(),c.current={dividerIndex:y},document.addEventListener("mousemove",d),document.addEventListener("mouseup",h),document.addEventListener("touchmove",d,{passive:!1}),document.addEventListener("touchend",h)};return l.jsxs("div",{className:Me.percentageBarContainer,children:[l.jsx("div",{className:Me.barContainer,ref:u,children:e.map((y,f)=>{var b;return l.jsx("div",{className:Me.segment,style:{width:`${i[f]}%`,backgroundColor:y.color||"#ccc"},children:f>0&&l.jsx("div",{className:Me.handle,onMouseDown:p=>g(f-1,p),onTouchStart:p=>g(f-1,p),role:"slider","aria-label":`Divisor entre ${(b=e[f-1])==null?void 0:b.title} y ${y.title}`,"aria-valuenow":Math.round(i[f]),tabIndex:0})},y.id??f)})}),t==="bar"&&l.jsx("div",{className:Me.labelsContainer,children:e.map((y,f)=>l.jsxs("div",{className:Me.labelItem,style:{width:`${i[f]}%`},children:[l.jsx("span",{className:Me.labelColor,style:{backgroundColor:y.color}}),l.jsx("span",{className:Me.labelText,children:y.title}),l.jsxs("span",{className:Me.labelValue,children:[i[f].toFixed(1),"%"]}),n&&y.translationFormula&&l.jsxs("span",{className:Me.labelTranslation,children:["(",ws(i[f],y.translationFormula),")"]})]},y.id??f))}),t==="list"&&l.jsx("div",{className:Me.labelsListContainer,children:e.map((y,f)=>l.jsxs("div",{className:Me.labelItem,children:[l.jsx("span",{className:Me.labelColor,style:{backgroundColor:y.color}}),l.jsx("span",{className:Me.labelText,children:y.title}),l.jsxs("span",{className:Me.labelValue,children:[i[f].toFixed(1),"%"]}),n&&y.translationFormula&&l.jsxs("span",{className:Me.labelTranslation,children:["(",ws(i[f],y.translationFormula),")"]})]},y.id??f))})]})};Gi.propTypes={items:s.arrayOf(s.shape({id:s.oneOfType([s.string,s.number]),title:s.string.isRequired,value:s.number.isRequired,color:s.string.isRequired,translationFormula:s.string})).isRequired,showLabels:s.string,showTranslations:s.bool,onChange:s.func,minPercentage:s.number};const cp="_header_13kbt_2",up="_leftComponents_13kbt_13",dp="_centerComponents_13kbt_14",fp="_rightComponents_13kbt_15",pp="_componentsContainer_13kbt_32",_t={header:cp,leftComponents:up,centerComponents:dp,rightComponents:fp,componentsContainer:pp},Yi=({cssProps:e,leftComponents:t=[],centerComponents:n=[],rightComponents:r=[],zIndex:o=10,height:i=60,backgroundColor:a="#605B56",isFooter:c=!1})=>l.jsxs("div",{className:_t.header,style:{...e,zIndex:o,height:i,backgroundColor:a,top:c?"auto":0,bottom:c?0:"auto"},children:[l.jsx("div",{className:_t.leftComponents,children:t.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))}),l.jsx("div",{className:_t.centerComponents,children:n.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))}),l.jsx("div",{className:_t.rightComponents,children:r.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))})]});Yi.propTypes={leftComponents:s.arrayOf(s.node),centerComponents:s.arrayOf(s.node),rightComponents:s.arrayOf(s.node),cssProps:s.object,zIndex:s.number,height:s.number,backgroundColor:s.string,isFooter:s.bool};const mp="_sidebar_1kaqu_2",hp="_open_1kaqu_16",gp="_content_1kaqu_20",yp="_closeButton_1kaqu_25",On={sidebar:mp,open:hp,content:gp,closeButton:yp},bp="data:image/svg+xml,%3csvg%20width='19'%20height='19'%20viewBox='0%200%2019%2019'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%203699'%3e%3cpath%20id='Vector%20223'%20d='M1%201L18.1566%2018.1566'%20stroke='%23605B56'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20id='Vector%20224'%20d='M18.1575%201L1.00083%2018.1566'%20stroke='%23605B56'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/g%3e%3c/svg%3e",Xi=({width:e="300px",children:t,showRightBar:n,onCloseBar:r})=>{const o=()=>{r()};return l.jsx("div",{className:`${On.sidebar} ${n?On.open:""}`,style:{width:n?e:0},children:n&&l.jsxs("div",{className:On.content,children:[l.jsx("button",{className:On.closeButton,onClick:o,children:l.jsx("img",{src:bp,alt:"Close Sidebar"})}),t]})})};Xi.propTypes={width:s.string,children:s.node,showRightBar:s.bool,onCloseBar:s.func};exports.AmbitSelector=Os;exports.BarChart=Vr;exports.BurgerMenu=eo;exports.ButtonsBar=Bi;exports.ButtonsList=As;exports.CategorySelector=Dr;exports.DropdownList=ht;exports.EditAmbit=ol;exports.ErrorMessage=Zt;exports.FiltersAmbit=Bs;exports.Form=zd;exports.GeneralButton=ln;exports.Graphic=Vs;exports.GraphicLegend=Wi;exports.Groupedbarchart=zi;exports.HeaderSection=Yi;exports.HorizontalBarChart=Hi;exports.IndicatorsList=qs;exports.LangSelector=Ws;exports.Legend=Us;exports.ListSelector=Ei;exports.Loader=Fi;exports.LogInButton=ji;exports.LogoApp=Zs;exports.MapboxMap=Qs;exports.MaplibreMap=Js;exports.ModalAlert=Pi;exports.PercentageBar=Gi;exports.PieChart=Zi;exports.RadioButtonInput=Ii;exports.RankingSlider=Xr;exports.RightSidebar=Xi;exports.SectionBar=ei;exports.SelectInput=Di;exports.SpeedGraphic=Ui;exports.Stackedbarchart=qi;exports.StatusText=Jr;exports.Steps=Qr;exports.Switch=Vi;exports.TextInput=Rr;exports.TimeSlider=Ti;exports.Tooltip=et;exports.TopNavMenu=ki;exports.VerticalBarChart=Ki;
|
|
87
|
+
`),ce.select(this).style("opacity",.8),p&&p(q,{key:ne.key,value:Ce,data:ne.data})}).on("mousemove",function(q){x&&se&&se.style("top",q.pageY-10+"px").style("left",q.pageX+10+"px")}).on("mouseout",function(){x&&se&&se.style("visibility","hidden"),ce.select(this).style("opacity",1)}),C&&Xe.on("click",function(q,ne){const Ce=ne.value;C(q,{key:ne.key,value:Ce,data:ne.data})}),ee&&ee.length>1){const q=ce.line().x(ne=>ne.x).y(ne=>ne.y).curve(ce.curveMonotoneX);le.append("path").datum(ee).attr("class","line").attr("d",q).attr("fill","none").attr("stroke","#ff6b6b").attr("stroke-width",2).attr("stroke-linecap","round").attr("stroke-linejoin","round"),le.selectAll(".line-point").data(ee).enter().append("circle").attr("class","line-point").attr("cx",ne=>ne.x).attr("cy",ne=>ne.y).attr("r",4).attr("fill","#ff6b6b").attr("stroke","white").attr("stroke-width",1)}return()=>{se&&se.remove()}},[e,t,n,r,P,a,f,u,d,h,g,y,b,p,C,w,T,j,v,x,S,A]),l.jsx("div",{ref:z,className:`${ys.svgContainer} ${c}`,style:{width:o,height:i+a.top+a.bottom,overflowX:"auto"},children:l.jsx("svg",{ref:O,className:ys.svg})})};qi.propTypes={data:s.arrayOf(s.object).isRequired,keys:s.arrayOf(s.string).isRequired,colors:s.oneOfType([s.arrayOf(s.string),s.object]),lineData:s.arrayOf(s.number),width:s.oneOfType([s.string,s.number]),height:s.number,margin:s.shape({top:s.number,right:s.number,bottom:s.number,left:s.number}),className:s.string,showXAxisLabels:s.bool,showYAxisLabels:s.bool,showGrid:s.bool,xAxisTickRotation:s.number,yAxisTickFormat:s.func,barPadding:s.number,animationDuration:s.number,onBarHover:s.func,onBarClick:s.func,title:s.string,xAxisLabel:s.string,yAxisLabel:s.string,stackOrder:s.oneOf(["reverse","ascending","descending","insideOut","none"]),showTooltip:s.bool,reverseKeys:s.bool,minBarSlotWidth:s.number,wrapXAxisLabels:s.bool};const Lf="_externalContainer_1er0i_2",Mf="_externalSintetic_1er0i_9",Rf="_titles_1er0i_13",Df="_titleContainer_1er0i_22",If="_yearTitles_1er0i_36",Pf="_yearTitle_1er0i_36",Bf="_yearDatas_1er0i_50",Vf="_yearDataContainer_1er0i_58",Ff="_yearDataContent_1er0i_66",zf="_bigNumber_1er0i_79",qf="_circle_1er0i_82",Wf="_totalContainer_1er0i_99",Uf="_total_1er0i_99",Ie={externalContainer:Lf,externalSintetic:Mf,titles:Rf,titleContainer:Df,yearTitles:If,yearTitle:Pf,yearDatas:Bf,yearDataContainer:Vf,yearDataContent:Ff,bigNumber:zf,circle:qf,totalContainer:Wf,total:Uf},Zf=e=>{if(e>=1e3||e<=-1e3)return parseInt(e.toFixed());if(e>=100||e<=-100)return parseFloat(e.toFixed(1));if(e>=10||e<=-10)return parseFloat(e.toFixed(2));if(e>0||e<0)return parseFloat(e.toFixed(3));if(e===0)return e},Hf=(e,t)=>{let n=0;return t.forEach(r=>{r[e]&&(n+=r[e])}),n},Wi=({data:e,keys:t,colors:n,locales:r,total:o=!1,years:i=!1,activeGraphics:a="ind",units:c={},translate:u,getTotal:d=Hf,columnWidth:h=50})=>{const g=u||(f=>f),y=f=>f==="demanda_red"||f==="reduccio_demanda_red"?(c.demanda||"").replace("(","").replace(")",""):c[f]||"";return l.jsxs("div",{className:`${Ie.externalContainer} ${a==="sin"?Ie.externalSintetic:""}`,children:[i===!0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{}),l.jsx("div",{className:Ie.yearTitles,children:e.map((f,b)=>l.jsx("div",{className:Ie.yearTitle,style:{width:h},children:f.anyo},b))})]}),l.jsx("div",{className:Ie.titles,children:t.map((f,b)=>l.jsxs("div",{className:Ie.titleContainer,children:[g(r[f]),a!=="sin"&&l.jsx("span",{className:Ie.circle,style:{background:n[f]}})]},b))}),o===!0&&l.jsx("div",{className:Ie.totalContainer,children:t.map((f,b)=>{var p;return l.jsxs("div",{className:`${Ie.total} ${d(f,e)>9999||d(f,e)<-9999?Ie.bigNumber:""}`,children:[(p=d(f,e))==null?void 0:p.toLocaleString("es-ES")," ",y(f)]},b)})}),l.jsx("div",{className:Ie.yearDatas,children:e.map((f,b)=>l.jsx("div",{className:Ie.yearDataContainer,style:{width:h},children:t.map((p,C)=>{var w,T;return isNaN(f[p])?null:l.jsx("div",{className:`${Ie.yearDataContent} ${f[p]>9999||f[p]<-9999?Ie.bigNumber:""}`,children:f[p]<1e4||f[p]>-1e4?(w=Zf(f[p]))==null?void 0:w.toLocaleString("es-ES"):(T=f[p])==null?void 0:T.toLocaleString("es-ES")},C)})},b))})]})};Wi.propTypes={data:s.arrayOf(s.shape({anyo:s.oneOfType([s.string,s.number]).isRequired})).isRequired,keys:s.arrayOf(s.string).isRequired,colors:s.objectOf(s.string).isRequired,locales:s.objectOf(s.string).isRequired,total:s.bool,years:s.bool,activeGraphics:s.oneOf(["ind","sin"]),units:s.objectOf(s.string),translate:s.func,getTotal:s.func,columnWidth:s.number};const Kf="_speedGraphic_d1k72_2",_r={speedGraphic:Kf},Ui=({minValue:e=0,maxValue:t=100,value:n=50,title:r=!1,percent:o=!1,unit:i=!1,greenColor:a="#00CF1E",orangeColor:c="#FFAC00",redColor:u="#FF1E37"})=>{n<e&&(n=e),n>t&&(n=t);const d=(n-e)/(t-e),h=270+d*180,g=o?Math.round(d*100):n;return l.jsxs("div",{className:_r.speedGraphic,children:[l.jsxs("svg",{width:"244",height:"130",viewBox:"0 0 244 130",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M0 122C0 111.944 1.2433 101.927 3.70162 92.1756L26.2619 97.8633C24.2724 105.755 23.2662 113.862 23.2662 122H0Z",fill:a}),l.jsx("path",{d:"M16.3442 61.0012C21.3714 52.2936 27.4557 44.2409 34.4588 37.0263L51.1534 53.2313C45.4859 59.0701 40.5619 65.5871 36.4934 72.6341L16.3442 61.0012Z",fill:a}),l.jsx("path",{d:"M60.9088 16.3976C69.6119 11.3628 78.9041 7.42322 88.5739 4.66843L94.9485 27.0443C87.1228 29.2737 79.6027 32.462 72.5592 36.5367L60.9088 16.3976Z",fill:c}),l.jsx("path",{d:"M121.797 0.000169508C131.851 -0.0165912 141.869 1.20965 151.623 3.65101L145.974 26.2209C138.08 24.2451 129.972 23.2527 121.835 23.2663L121.797 0.000169508Z",fill:c}),l.jsx("path",{d:"M182.623 16.1279C191.348 21.124 199.422 27.1797 206.662 34.157L190.516 50.9092C184.657 45.2625 178.123 40.3617 171.061 36.3183L182.623 16.1279Z",fill:u}),l.jsx("path",{d:"M227.238 60.2836C232.325 68.9568 236.319 78.2255 239.131 87.8788L216.794 94.3859C214.518 86.5735 211.285 79.0725 207.169 72.0533L227.238 60.2836Z",fill:u}),l.jsx("path",{d:"M4.15505 90.4316C6.75674 80.7194 10.5491 71.3662 15.4458 62.5846L35.7663 73.9155C31.8035 81.0224 28.7343 88.5919 26.6288 96.4519L4.15505 90.4316Z",fill:a}),l.jsx("path",{d:"M35.733 35.733C42.8426 28.6233 50.8039 22.4198 59.4357 17.2636L71.3671 37.2375C64.3814 41.4104 57.9384 46.4308 52.1846 52.1846L35.733 35.733Z",fill:a}),l.jsx("path",{d:"M90.3004 4.19027C100.01 1.57776 110.005 0.175523 120.058 0.0154601L120.428 23.2787C112.292 23.4082 104.203 24.543 96.3457 26.6573L90.3004 4.19027Z",fill:c}),l.jsx("path",{d:"M153.423 4.11614C163.138 6.70584 172.496 10.4866 181.284 15.3725L169.978 35.707C162.866 31.7529 155.293 28.6932 147.43 26.5973L153.423 4.11614Z",fill:c}),l.jsx("path",{d:"M239.602 89.538C242.532 100.152 244.011 111.114 244 122.125L220.734 122.101C220.743 113.19 219.546 104.319 217.175 95.7287L239.602 89.538Z",fill:u}),l.jsx("path",{d:"M207.769 35.2376C214.919 42.3062 221.168 50.2316 226.374 58.8336L206.469 70.8798C202.256 63.9183 197.199 57.5043 191.412 51.7837L207.769 35.2376Z",fill:u}),l.jsx("g",{transform:`rotate(${h} 122 122)`,children:l.jsx("path",{id:"aguja",d:"M121 119.5V33",stroke:"#605B56","stroke-width":"2"})})]}),l.jsxs("div",{className:_r.value,children:[g,o&&"%",i&&i]}),r&&l.jsx("div",{className:_r.title,children:r})]})};Ui.propTypes={minValue:s.number.isRequired,maxValue:s.number.isRequired,value:s.number.isRequired,percent:s.bool,title:s.string,unit:s.string,greenColor:s.string,orangeColor:s.string,redColor:s.string};const wr="#ffffff",Gf="#ffffff";function it(e,t,n,r){const o=(r-90)*Math.PI/180;return{x:e+n*Math.cos(o),y:t+n*Math.sin(o)}}function bs(e,t,n,r,o,i){if(Math.abs(i-o)>=359.99)return n===0?`M ${e-r} ${t} A ${r} ${r} 0 1 1 ${e+r} ${t} A ${r} ${r} 0 1 1 ${e-r} ${t} Z`:[`M ${e-r} ${t} A ${r} ${r} 0 1 1 ${e+r} ${t} A ${r} ${r} 0 1 1 ${e-r} ${t} Z`,`M ${e-n} ${t} A ${n} ${n} 0 1 0 ${e+n} ${t} A ${n} ${n} 0 1 0 ${e-n} ${t} Z`].join(" ");const a=it(e,t,r,o),c=it(e,t,r,i),u=i-o>180?1:0;if(n===0)return`M ${e} ${t} L ${a.x} ${a.y} A ${r} ${r} 0 ${u} 1 ${c.x} ${c.y} Z`;const d=it(e,t,n,i),h=it(e,t,n,o);return[`M ${a.x} ${a.y}`,`A ${r} ${r} 0 ${u} 1 ${c.x} ${c.y}`,`L ${d.x} ${d.y}`,`A ${n} ${n} 0 ${u} 0 ${h.x} ${h.y}`,"Z"].join(" ")}function Yf(e){const t=e.reduce((r,o)=>r+(o.value||0),0);let n=0;return e.map(r=>{const o=r.value/t*360,i=n;return n+=o,{...r,sa:i,ea:n}})}function vs(e,t,n,r,o){const i=n+(r-n)/2,a=it(e,t,o,i);return{tx:a.x-e,ty:a.y-t}}const Zi=({type:e="cheese",data:t=[],title:n,size:r=260,donutThickness:o=56,gapWidth:i=3,gapColor:a,backgroundColor:c="transparent",fontColor:u="black",fontColorInside:d="white",containerStyles:h={},alignLeft:g=!1})=>{const[y,f]=_.useState(null),b=r/2,p=r/2,C=r/2-14,w=e==="donut"?C-o:0,T=e==="donut"?C-o/2:C*.62,j=_.useMemo(()=>Yf(t),[t]),v=y!==null?j[y]:null,x=j.some($=>$.ea-$.sa>=359.99),S=a||(c==="transparent"?Gf:c);return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px",padding:"0px",background:c,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",...h},children:[l.jsxs("div",{style:{minHeight:"40px",display:"flex",flexDirection:"column",gap:"2px"},children:[n&&l.jsx("h2",{style:{margin:0,color:u,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.5px"},children:n}),l.jsx("div",{style:{height:"22px",display:"flex",alignItems:"center",gap:"8px",transition:"opacity 0.15s",opacity:v?1:0},children:v&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{display:"inline-block",width:"10px",height:"10px",borderRadius:"50%",background:v.color||wr,flexShrink:0}}),l.jsxs("span",{style:{color:u,fontSize:"14px",fontWeight:"600"},children:[v.title," — ",v.value,"%"]})]})})]}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:g?"flex-start":"center",gap:"16px"},children:[l.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,style:{overflow:"visible"},children:[j.map(($,A)=>{const O=y===A,{tx:z,ty:P}=O&&!x?vs(b,p,$.sa,$.ea,10):{tx:0,ty:0};return l.jsx("g",{transform:`translate(${z}, ${P})`,style:{transition:"transform 0.18s ease",pointerEvents:"none"},children:l.jsx("path",{d:bs(b,p,w,C,$.sa,$.ea),fill:$.color||wr,style:{filter:O?"brightness(1.25)":"brightness(1)",transition:"filter 0.18s ease"}})},A)}),!x&&j.map(($,A)=>{const O=it(b,p,C,$.sa),z=e==="cheese"?b:it(b,p,w,$.sa).x,P=e==="cheese"?p:it(b,p,w,$.sa).y;return l.jsx("line",{x1:z,y1:P,x2:O.x,y2:O.y,stroke:S,strokeWidth:i,strokeLinecap:"butt",style:{pointerEvents:"none"}},`gap-${A}`)}),j.map(($,A)=>{if($.ea-$.sa<20)return null;const O=y===A,{tx:z,ty:P}=O&&!x?vs(b,p,$.sa,$.ea,10):{tx:0,ty:0},m=$.sa+($.ea-$.sa)/2,E=it(b,p,T,m);return l.jsxs("text",{x:E.x+z,y:E.y+P,textAnchor:"middle",dominantBaseline:"middle",fill:d,fontSize:"14",fontWeight:"700",fontFamily:"'Segoe UI', sans-serif",pointerEvents:"none",style:{transition:"x 0.18s ease, y 0.18s ease"},children:[$.value,"%"]},`lbl-${A}`)}),j.map(($,A)=>l.jsx("path",{d:bs(b,p,w,C,$.sa,$.ea),fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>f(A),onMouseLeave:()=>f(null)},`hit-${A}`))]}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"12px 24px",justifyContent:g?"flex-start":"center"},children:t.map(($,A)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",opacity:y===null||y===A?1:.4,transition:"opacity 0.15s"},onMouseEnter:()=>f(A),onMouseLeave:()=>f(null),children:[l.jsx("span",{style:{width:"32px",height:"14px",borderRadius:"3px",background:$.color||wr,flexShrink:0}}),l.jsx("span",{style:{color:u,fontSize:"13px",fontWeight:"400"},children:$.title})]},A))})]})]})};Zi.propTypes={type:s.oneOf(["cheese","donut"]),data:s.arrayOf(s.shape({value:s.number.isRequired,title:s.string.isRequired,color:s.string})).isRequired,title:s.string,size:s.number,donutThickness:s.number,gapWidth:s.number,gapColor:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,containerStyles:s.object,alignLeft:s.bool};const xs=["#a8d8cf","#3bbfa0","#5dd4b8","#7ed4c2","#2aa88a"],Hi=({data:e=[],title:t,backgroundColor:n="#0d3d4a",fontColor:r="#ffffff",barHeight:o=52,animated:i=!0,borderRadius:a,containerStyles:c={},fontColorInside:u="white",borderFontColorInside:d})=>{const[h,g]=_.useState(i?0:1);_.useEffect(()=>{if(!i)return;const b=requestAnimationFrame(()=>g(1));return()=>cancelAnimationFrame(b)},[i]);const y=Math.max(...e.map(b=>b.value),1),f=a??"6px";return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"0px",background:n,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",minWidth:"420px",...c},children:[t&&l.jsx("h2",{style:{margin:"0 0 20px 0",color:r,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.4px"},children:t}),l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"18px"},children:e.map((b,p)=>{const C=b.color||xs[p%xs.length],w=b.value/y*100*h;return l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[l.jsx("span",{style:{color:r,fontSize:"14px",fontWeight:"400",opacity:.9},children:b.title}),l.jsxs("div",{style:{position:"relative",height:`${o}px`,background:"transparent",borderRadius:f,overflow:"hidden"},children:[l.jsx("div",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${w}%`,background:C,borderRadius:f,transition:i?"width 0.8s cubic-bezier(0.16, 1, 0.3, 1)":"none"}}),l.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:u||n,fontSize:"18px",fontWeight:"700",pointerEvents:"none",letterSpacing:"-0.3px",...d?{WebkitTextStroke:`1px ${d}`,paintOrder:"stroke fill"}:{}},children:b.value})]})]},p)})})]})};Hi.propTypes={data:s.arrayOf(s.shape({title:s.string.isRequired,value:s.number.isRequired,color:s.string})),title:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,borderFontColorInside:s.string,barHeight:s.number,animated:s.bool,borderRadius:s.oneOfType([s.string,s.number]),containerStyles:s.object};const Cs=["#a8d8cf","#3bbfa0","#5dd4b8","#7ed4c2","#2aa88a"],Ki=({data:e=[],title:t,backgroundColor:n="black",fontColor:r="#ffffff",fontColorInside:o="#0d3d4a",borderFontColorInside:i,barWidth:a=52,maxBarHeight:c=200,animated:u=!0,separatorColor:d,containerStyles:h={}})=>{const[g,y]=_.useState(u?0:1);_.useEffect(()=>{if(!u)return;const C=requestAnimationFrame(()=>requestAnimationFrame(()=>y(1)));return()=>cancelAnimationFrame(C)},[u]);const f=Math.max(...e.map(C=>C.value),1),b=d||(r==="#ffffff"?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.15)"),p={fontSize:"15px",fontWeight:"700",letterSpacing:"-0.3px",lineHeight:1,pointerEvents:"none",whiteSpace:"nowrap",...i?{WebkitTextStroke:`1px ${i}`,paintOrder:"stroke fill"}:{}};return l.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"0",background:n,borderRadius:"16px",fontFamily:"'Segoe UI', sans-serif",...h},children:[t&&l.jsx("h2",{style:{margin:"0 0 24px 0",color:r,fontSize:"22px",fontWeight:"700",letterSpacing:"-0.4px"},children:t}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[l.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"12px",height:`${c}px`},children:e.map((C,w)=>{const T=C.color||Cs[w%Cs.length],j=C.value===0,v=j?0:C.value/f*c*g;return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",width:`${a}px`,height:"100%"},children:j?l.jsx("span",{style:{...p,color:o,marginBottom:"6px"},children:C.value}):l.jsx("div",{style:{position:"relative",width:"100%",height:`${v}px`,background:T,borderRadius:"6px 6px 0 0",transition:u?"height 0.85s cubic-bezier(0.16, 1, 0.3, 1)":"none",display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"10px"},children:l.jsx("span",{style:{...p,color:o},children:C.value})})},w)})}),l.jsx("div",{style:{height:"1.5px",background:b,borderRadius:"1px"}}),l.jsx("div",{style:{display:"flex",gap:"12px",marginTop:"10px"},children:e.map((C,w)=>l.jsx("div",{style:{width:`${a}px`,textAlign:"center",color:r,fontSize:"13px",fontWeight:"400",opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C.title},w))})]})]})};Ki.propTypes={data:s.arrayOf(s.shape({title:s.string.isRequired,value:s.number.isRequired,color:s.string})).isRequired,title:s.string,backgroundColor:s.string,fontColor:s.string,fontColorInside:s.string,borderFontColorInside:s.string,barWidth:s.number,maxBarHeight:s.number,animated:s.bool,separatorColor:s.string,containerStyles:s.object};const Xf="_percentageBarContainer_1g3hk_3",Qf="_barContainer_1g3hk_10",Jf="_segment_1g3hk_19",ep="_handle_1g3hk_36",tp="_labelsContainer_1g3hk_68",np="_labelItem_1g3hk_73",rp="_labelsListContainer_1g3hk_85",op="_labelColor_1g3hk_105",sp="_labelText_1g3hk_114",ip="_labelValue_1g3hk_122",ap="_labelTranslation_1g3hk_127",Me={percentageBarContainer:Xf,barContainer:Qf,segment:Jf,handle:ep,labelsContainer:tp,labelItem:np,labelsListContainer:rp,labelColor:op,labelText:sp,labelValue:ip,labelTranslation:ap},lp=2,_s=e=>{const t=e.reduce((n,r)=>n+r.value,0);return t===0?e.map(()=>100/e.length):e.map(n=>n.value/t*100)},ws=(e,t)=>{try{const r=new Function("x",`return (${t})`)(e);return isNaN(r)?"N/A":r.toFixed(2)}catch{return"N/A"}},Gi=({items:e,showLabels:t="bar",showTranslations:n=!0,onChange:r,minPercentage:o=lp})=>{const[i,a]=_.useState(()=>_s(e)),c=_.useRef(null),u=_.useRef(null);_.useEffect(()=>{e&&e.length>0&&a(_s(e))},[e]);const d=_.useCallback(y=>{if(!c.current||!u.current)return;const{dividerIndex:f}=c.current,b=u.current.getBoundingClientRect(),p=(y.touches?y.touches[0].clientX:y.clientX)-b.left,C=Math.max(0,Math.min(100,p/b.width*100));a(w=>{const T=[...w],j=w.slice(0,f).reduce(($,A)=>$+A,0),v=j+w[f]+w[f+1];let x=C-j,S=v-C;if(x<o&&(x=o,S=v-j-o),S<o&&(S=o,x=v-j-o),T[f]=x,T[f+1]=S,r)try{r(e.map(($,A)=>({...$,value:T[A]})))}catch($){console.error("PercentageBar onChange error:",$)}return T})},[o,r,e]),h=_.useCallback(()=>{c.current&&(c.current=null,document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",h),a(y=>(r&&r(e.map((f,b)=>({...f,value:y[b]}))),y)))},[d,r,e]),g=(y,f)=>{f.preventDefault(),c.current={dividerIndex:y},document.addEventListener("mousemove",d),document.addEventListener("mouseup",h),document.addEventListener("touchmove",d,{passive:!1}),document.addEventListener("touchend",h)};return l.jsxs("div",{className:Me.percentageBarContainer,children:[l.jsx("div",{className:Me.barContainer,ref:u,children:e.map((y,f)=>{var b;return l.jsx("div",{className:Me.segment,style:{width:`${i[f]}%`,backgroundColor:y.color||"#ccc"},children:f>0&&l.jsx("div",{className:Me.handle,onMouseDown:p=>g(f-1,p),onTouchStart:p=>g(f-1,p),role:"slider","aria-label":`Divisor entre ${(b=e[f-1])==null?void 0:b.title} y ${y.title}`,"aria-valuenow":Math.round(i[f]),tabIndex:0})},y.id??f)})}),t==="bar"&&l.jsx("div",{className:Me.labelsContainer,children:e.map((y,f)=>l.jsxs("div",{className:Me.labelItem,style:{width:`${i[f]}%`},children:[l.jsx("span",{className:Me.labelColor,style:{backgroundColor:y.color}}),l.jsx("span",{className:Me.labelText,children:y.title}),l.jsxs("span",{className:Me.labelValue,children:[i[f].toFixed(1),"%"]}),n&&y.translationFormula&&l.jsxs("span",{className:Me.labelTranslation,children:["(",ws(i[f],y.translationFormula),")"]})]},y.id??f))}),t==="list"&&l.jsx("div",{className:Me.labelsListContainer,children:e.map((y,f)=>l.jsxs("div",{className:Me.labelItem,children:[l.jsx("span",{className:Me.labelColor,style:{backgroundColor:y.color}}),l.jsx("span",{className:Me.labelText,children:y.title}),l.jsxs("span",{className:Me.labelValue,children:[i[f].toFixed(1),"%"]}),n&&y.translationFormula&&l.jsxs("span",{className:Me.labelTranslation,children:["(",ws(i[f],y.translationFormula),")"]})]},y.id??f))})]})};Gi.propTypes={items:s.arrayOf(s.shape({id:s.oneOfType([s.string,s.number]),title:s.string.isRequired,value:s.number.isRequired,color:s.string.isRequired,translationFormula:s.string})).isRequired,showLabels:s.string,showTranslations:s.bool,onChange:s.func,minPercentage:s.number};const cp="_header_13kbt_2",up="_leftComponents_13kbt_13",dp="_centerComponents_13kbt_14",fp="_rightComponents_13kbt_15",pp="_componentsContainer_13kbt_32",_t={header:cp,leftComponents:up,centerComponents:dp,rightComponents:fp,componentsContainer:pp},Yi=({cssProps:e,leftComponents:t=[],centerComponents:n=[],rightComponents:r=[],zIndex:o=10,height:i=60,backgroundColor:a="#605B56",isFooter:c=!1})=>l.jsxs("div",{className:_t.header,style:{...e,zIndex:o,height:i,backgroundColor:a,top:c?"auto":0,bottom:c?0:"auto"},children:[l.jsx("div",{className:_t.leftComponents,children:t.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))}),l.jsx("div",{className:_t.centerComponents,children:n.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))}),l.jsx("div",{className:_t.rightComponents,children:r.map((u,d)=>l.jsx("div",{className:_t.componentsContainer,children:u},d))})]});Yi.propTypes={leftComponents:s.arrayOf(s.node),centerComponents:s.arrayOf(s.node),rightComponents:s.arrayOf(s.node),cssProps:s.object,zIndex:s.number,height:s.number,backgroundColor:s.string,isFooter:s.bool};const mp="_sidebar_1kaqu_2",hp="_open_1kaqu_16",gp="_content_1kaqu_20",yp="_closeButton_1kaqu_25",On={sidebar:mp,open:hp,content:gp,closeButton:yp},bp="data:image/svg+xml,%3csvg%20width='19'%20height='19'%20viewBox='0%200%2019%2019'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%203699'%3e%3cpath%20id='Vector%20223'%20d='M1%201L18.1566%2018.1566'%20stroke='%23605B56'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20id='Vector%20224'%20d='M18.1575%201L1.00083%2018.1566'%20stroke='%23605B56'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3c/g%3e%3c/svg%3e",Xi=({width:e="300px",children:t,showRightBar:n,onCloseBar:r})=>{const o=()=>{r()};return l.jsx("div",{className:`${On.sidebar} ${n?On.open:""}`,style:{width:n?e:0},children:n&&l.jsxs("div",{className:On.content,children:[l.jsx("button",{className:On.closeButton,onClick:o,children:l.jsx("img",{src:bp,alt:"Close Sidebar"})}),t]})})};Xi.propTypes={width:s.string,children:s.node,showRightBar:s.bool,onCloseBar:s.func};exports.AmbitSelector=Os;exports.BarChart=Vr;exports.BurgerMenu=eo;exports.ButtonsBar=Bi;exports.ButtonsList=As;exports.CategorySelector=Dr;exports.DropdownList=ht;exports.EditAmbit=ol;exports.ErrorMessage=Zt;exports.FiltersAmbit=Bs;exports.Form=zd;exports.GeneralButton=ln;exports.Graphic=Vs;exports.GraphicLegend=Wi;exports.Groupedbarchart=zi;exports.HeaderSection=Yi;exports.HorizontalBarChart=Hi;exports.IndicatorsList=qs;exports.LangSelector=Ws;exports.Legend=Us;exports.ListSelector=Ei;exports.Loader=Fi;exports.LogInButton=ji;exports.LogoApp=Zs;exports.MapboxMap=Qs;exports.MaplibreMap=Js;exports.ModalAlert=Pi;exports.PercentageBar=Gi;exports.PieChart=Zi;exports.RadioButtonInput=Ii;exports.RankingSlider=Xr;exports.RightSidebar=Xi;exports.SectionBar=ei;exports.SelectInput=Di;exports.SpeedGraphic=Ui;exports.Stackedbarchart=qi;exports.StatusText=Jr;exports.Steps=Qr;exports.Switch=Vi;exports.TextInput=Rr;exports.TimeSlider=Ti;exports.Tooltip=et;exports.TopNavMenu=ki;exports.VerticalBarChart=Ki;
|
package/dist/index.es.js
CHANGED
|
@@ -12087,10 +12087,21 @@ const ap = "_percentageBarContainer_1g3hk_3", lp = "_barContainer_1g3hk_10", cp
|
|
|
12087
12087
|
a((x) => {
|
|
12088
12088
|
const k = [...x], $ = x.slice(0, f).reduce((N, L) => N + L, 0), v = $ + x[f] + x[f + 1];
|
|
12089
12089
|
let C = _ - $, w = v - _;
|
|
12090
|
-
|
|
12090
|
+
if (C < o && (C = o, w = v - $ - o), w < o && (w = o, C = v - $ - o), k[f] = C, k[f + 1] = w, r)
|
|
12091
|
+
try {
|
|
12092
|
+
r(
|
|
12093
|
+
e.map((N, L) => ({
|
|
12094
|
+
...N,
|
|
12095
|
+
value: k[L]
|
|
12096
|
+
}))
|
|
12097
|
+
);
|
|
12098
|
+
} catch (N) {
|
|
12099
|
+
console.error("PercentageBar onChange error:", N);
|
|
12100
|
+
}
|
|
12101
|
+
return k;
|
|
12091
12102
|
});
|
|
12092
12103
|
},
|
|
12093
|
-
[o]
|
|
12104
|
+
[o, r, e]
|
|
12094
12105
|
), h = co(() => {
|
|
12095
12106
|
l.current && (l.current = null, document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", h), document.removeEventListener("touchmove", d), document.removeEventListener("touchend", h), a((y) => (r && r(
|
|
12096
12107
|
e.map((f, b) => ({
|