@rafal.lemieszewski/tide-ui 0.88.0 → 0.88.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),l=require("recharts"),Oe=require("../../lib/utils.cjs"),V=(i,f=0)=>{const p=i.toFixed(f).split("."),x=p[0].replace(/\B(?=(\d{3})+(?!\d))/g," ");return f>0&&p[1]?`${x}.${p[1]}`:x},Me=(i,f,a,p=20)=>{if(!i.length)return p;let x=0;i.forEach(S=>{f.forEach(n=>{const b=S[n];typeof b=="number"?x=Math.max(x,Math.abs(b)):Array.isArray(b)&&b.forEach(c=>{typeof c=="number"&&(x=Math.max(x,Math.abs(c)))})})});const w=(a?a(x,0):x.toString()).length;return Math.max(p,w*6+12)},W={bar:["var(--color-chart-bar-1)","var(--color-chart-bar-2)","var(--color-chart-bar-3)","var(--color-chart-bar-4)","var(--color-chart-bar-5)","var(--color-chart-bar-6)"],line:["var(--color-chart-line-1)","var(--color-chart-line-2)","var(--color-chart-line-3)","var(--color-chart-line-4)","var(--color-chart-line-5)"],scatter:["var(--color-chart-scatter-1)","var(--color-chart-scatter-2)","var(--color-chart-scatter-3)","var(--color-chart-scatter-4)","var(--color-chart-scatter-5)","var(--color-chart-scatter-6)"],area:["var(--color-chart-area-1)","var(--color-chart-area-2)","var(--color-chart-area-3)","var(--color-chart-area-4)","var(--color-chart-area-5)","var(--color-chart-area-6)"],accessible:["#0066CC","#CC6600","#009966","#CC0066","#6600CC","#CC9900","#006666","#CC0000"]},T=i=>{switch(i){case"dashed":return"5 5";case"dotted":return"2 2";case"solid":default:return}},Be=(i="circle")=>f=>{const{cx:a,cy:p,r:x,fill:C,stroke:w,strokeWidth:S}=f,n=x||4;switch(i){case"triangle":const b=n*1.5,c=n*1.3,y=`M ${a},${p-b} L ${a+c},${p+b/2} L ${a-c},${p+b/2} Z`;return e.jsx("path",{d:y,fill:C,stroke:w,strokeWidth:S||0});case"square":const j=n*1.4;return e.jsx("rect",{x:a-j,y:p-j,width:j*2,height:j*2,fill:C,stroke:w,strokeWidth:S||0});case"circle":default:return e.jsx("circle",{cx:a,cy:p,r:n,fill:C,stroke:w,strokeWidth:S||0})}},Ae=i=>({verticalAlign:"bottom",align:"center"}),se=({active:i,payload:f,label:a,config:p,tooltipMaxWidth:x="max-w-xs",chartType:C,referenceMarkers:w})=>{if(!i||!f||!f.length)return null;const S=w?.filter(n=>n.xValue===a)||[];return e.jsxs("div",{className:`rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${x} z-[9999]`,role:"tooltip","aria-label":"Chart data tooltip",children:[e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:a}),f.map((n,b)=>{const c=p[n.dataKey];let y;if(c?.type==="range-area"&&n.payload){const N=n.payload[n.dataKey];Array.isArray(N)&&N.length===2?y=`${V(N[0])} – ${V(N[1])}`:y=typeof n.value=="number"?V(n.value):n.value}else y=typeof n.value=="number"?V(n.value):n.value;const j=()=>{switch(C){case"line":const N=p[n.dataKey]?.strokeStyle,q=T(N);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:q?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:q==="5 5"?"6px 100%":q==="2 2"?"2px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"composed":switch(p[n.dataKey]?.type){case"line":const I=p[n.dataKey]?.strokeStyle,$=T(I);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:$?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:$==="5 5"?"6px 100%":$==="2 2"?"2px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-2.5 h-2.5 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":case"area":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c?.label||n.dataKey,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:y})]},b)}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-[var(--space-m)]"}),S.map((n,b)=>e.jsxs(u.Fragment,{children:[n.tooltipLabel&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:n.tooltipLabel}),!n.tooltipLabel&&b===0&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:"Reference Markers:"}),n.dataPoints.map((c,y)=>{const j=()=>{switch(c.shape||"circle"){case"triangle":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M 5,2 L 8,8 L 2,8 Z",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"square":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("rect",{x:"2",y:"2",width:"6",height:"6",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"circle":default:return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c.fill||"var(--color-chart-line-1)",border:c.stroke?`${c.strokeWidth||1}px solid ${c.stroke}`:"none"}})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c.label||`Marker ${y+1}`,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:V(c.yValue)})]},`marker-${b}-point-${y}`)})]},`marker-section-${b}`))]})]})};function Ve({type:i,data:f,config:a,className:p,height:x=300,width:C,minWidth:w=300,onDataPointClick:S,onDataPointHover:n,highlightedIndex:b,showGrid:c=!0,showLegend:y=!0,showTooltip:j=!0,colorScheme:N,responsive:q=!0,maintainAspectRatio:Ie=!1,legendHeight:I,margin:$,yAxisWidth:xe,yAxisTickCount:ve,xAxisTickFormatter:$e,yAxisTickFormatter:X,showRightYAxis:le=!1,rightYAxisWidth:he,rightYAxisTickCount:oe,rightYAxisDomain:ne,rightYAxisTickFormatter:ie,title:P,description:ce,showDataTable:ze=!1,tooltipMaxWidth:F="max-w-xs",tooltipAllowEscapeViewBox:_,legendOrder:E,legendPosition:Fe="bottom",referenceMarkers:be,todayMarker:z,yAxisDomain:R,scrollable:D=!1,scrollableWidth:je,...Ke}){const[ke,We]=u.useState(0),k=u.useRef(null),fe=u.useRef(!1),ge=u.useRef(0),Ce=u.useRef(0),Pe=u.useCallback(t=>{k.current&&(fe.current=!0,ge.current=t.pageX-k.current.offsetLeft,Ce.current=k.current.scrollLeft,k.current.style.cursor="grabbing")},[]),De=u.useCallback(t=>{if(!fe.current||!k.current)return;t.preventDefault();const r=t.pageX-k.current.offsetLeft;k.current.scrollLeft=Ce.current-(r-ge.current)},[]),we=u.useCallback(()=>{fe.current=!1,k.current&&(k.current.style.cursor="grab")},[]),g=u.useMemo(()=>{if(N)return W[N];switch(i){case"bar":case"horizontal-bar":return W.bar;case"line":return W.line;case"scatter":return W.scatter;case"composed":return W.bar;default:return W.bar}},[i,N]),h=Object.keys(a).filter(t=>t!=="name"),v=u.useMemo(()=>f.map(t=>{const r={...t};return h.forEach(o=>{if(a[o].type==="range-area"){const s=t[o];Array.isArray(s)&&s.length===2&&(r[o]=s,r[`${o}_min`]=s[0],r[`${o}_max`]=s[1])}}),r}),[f,a,h]),pe=u.useMemo(()=>{if(!z)return null;const t=v.find(r=>r.name===z.xValue);return{xValue:z.xValue,showLine:!0,lineLabel:z.label??"Today",lineStyle:{stroke:"var(--color-border-error-bold)",strokeWidth:2},dataPoints:h.filter(r=>t&&t[r]!=null).map(r=>({yValue:t[r],yAxisId:a[r].yAxisId||"left",fill:"var(--color-background-error-bold)",size:4,pulsing:!0}))}},[z,v,h,a]),me=u.useMemo(()=>[...be??[],...pe?[pe]:[]],[be,pe]),U=u.useCallback(t=>{const r=t?.activeTooltipIndex??0;We(r),n?.(t?.activePayload?.[0]?.payload,r)},[n]),Z=u.useCallback(()=>{n?.(null)},[n]),G=u.useCallback(t=>{const r=t?.activeTooltipIndex??0;S?.(t?.activePayload?.[0]?.payload,r)},[S]),J=u.useMemo(()=>ke>=Math.floor(v.length/2),[ke,v.length]),de=()=>{const t={top:8,right:0,left:0,bottom:0};return{top:$?.top??t.top,right:$?.right??t.right,left:$?.left??t.left,bottom:$?.bottom??t.bottom}},Se=u.useMemo(()=>xe||Me(v,h,X,20),[xe,v,h,X]),O=u.useMemo(()=>{if(!D||R)return R;const t=v.flatMap(r=>h.map(o=>{const s=r[o];return Array.isArray(s)||typeof s=="number"?s:0}).flat());return[Math.min(0,...t),Math.max(...t)]},[D,R,v,h]),Q=u.useMemo(()=>D?je??Math.max(v.length*60,600):void 0,[D,je,v.length]),Ne=u.useMemo(()=>{if(!le)return 0;if(he)return he;const t=h.filter(r=>a[r].yAxisId==="right");return t.length===0?0:Me(v,t,ie,20)},[le,he,v,h,a,ie]),Le=u.useMemo(()=>h.some(r=>(a[r].yAxisId||"left")==="left")?"left":"right",[h,a]),Y=I?{...Ae(),wrapperStyle:{position:"absolute",bottom:0,left:0,right:0,height:I,paddingTop:8,zIndex:1}}:Ae(),H={data:v,margin:de()},ee={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:!1,tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},tickFormatter:$e},K={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Se,tickFormatter:X,...ve&&{tickCount:ve},...R&&{domain:R}},re={stroke:"var(--color-border-primary-subtle)",horizontal:!0,vertical:!1},te=({payload:t})=>{if(!t||!t.length)return null;const r=t.filter(d=>a[d.dataKey]),o=E?[...r].sort((d,A)=>{const L=E.indexOf(d.dataKey),M=E.indexOf(A.dataKey);return L===-1?1:M===-1?-1:L-M}):r,m=de().left+5;return e.jsx("div",{style:{paddingLeft:`${m}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:o.map((d,A)=>{const L=()=>{switch(i){case"line":const M=a[d.dataKey]?.strokeStyle,B=T(M);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:B?`linear-gradient(to right, ${d.color} 50%, transparent 50%)`:d.color,backgroundSize:B==="5 5"?"8px 100%":B==="2 2"?"3px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-[6px] h-[6px] rounded-full flex-shrink-0",style:{backgroundColor:d.color},"aria-hidden":"true"});case"composed":switch(a[d.dataKey]?.type){case"line":const Re=a[d.dataKey]?.strokeStyle,ye=T(Re);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:ye?`linear-gradient(to right, ${d.color} 50%, transparent 50%)`:d.color,backgroundSize:ye==="5 5"?"8px 100%":ye==="2 2"?"3px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-[8px] h-[8px] flex-shrink-0",style:{backgroundColor:d.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:d.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:d.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[L(),e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:d.value})]},A)})})})},Te=()=>{const t=E?[...E,...Object.keys(a).filter(s=>!E.includes(s))]:Object.keys(a),o=de().left+5;return e.jsx("div",{style:{paddingLeft:`${o}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:t.map((s,m)=>{const d=a[s];if(!d)return null;const A=d.color??"currentColor",L=T(d.strokeStyle),M=e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:L?`linear-gradient(to right, ${A} 50%, transparent 50%)`:A,backgroundSize:L==="5 5"?"8px 100%":L==="2 2"?"3px 100%":"100% 100%"}})});return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[M,e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:d.label})]},m)})})})},ue=(t="full")=>{switch(i){case"bar":return e.jsxs(l.BarChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{...K,hide:t==="data-only",width:t==="data-only"?0:K.width,...t!=="full"&&O?{domain:O}:{}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r)})]});case"horizontal-bar":return e.jsxs(l.BarChart,{...H,layout:"vertical",onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re,horizontal:!1,vertical:!0}),e.jsx(l.XAxis,{type:"number",...ee}),e.jsx(l.YAxis,{type:"category",dataKey:"name",...K}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:40},r)})]});case"line":return e.jsxs(l.LineChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...K,hide:t==="data-only",width:t==="data-only"?0:K.width,...t!=="full"&&O?{domain:O}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i,referenceMarkers:me}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r)}),t!=="yaxis-only"&&me.map((r,o)=>r.showLine!==!1?e.jsx(l.ReferenceLine,{x:r.xValue,yAxisId:"left",stroke:r.lineStyle?.stroke||"#000000",strokeWidth:r.lineStyle?.strokeWidth||2,strokeDasharray:r.lineStyle?.strokeDasharray,label:r.lineLabel?s=>{const{viewBox:m}=s;return m?e.jsx("text",{x:m.x+6,y:m.y+8,dominantBaseline:"middle",fill:"var(--color-text-error-bold)",fontSize:10,fontFamily:"inherit",fontWeight:700,children:r.lineLabel}):null}:void 0},`marker-line-${o}`):null),t!=="yaxis-only"&&me.map((r,o)=>e.jsx(u.Fragment,{children:r.dataPoints?.map((s,m)=>e.jsx(l.ReferenceDot,{x:r.xValue,y:s.yValue,yAxisId:s.yAxisId||"left",r:s.size||4,fill:s.fill||"var(--color-chart-line-1)",stroke:s.stroke||"transparent",strokeWidth:s.strokeWidth||0,shape:s.pulsing?d=>{const{cx:A,cy:L}=d,M=s.size||4,B=s.fill||"var(--color-background-error-bold)";return e.jsxs("g",{children:[e.jsxs("circle",{cx:A,cy:L,r:M+1,fill:B,opacity:.3,children:[e.jsx("animate",{attributeName:"r",from:String(M+1),to:String(M+8),dur:"1.5s",repeatCount:"indefinite"}),e.jsx("animate",{attributeName:"opacity",from:"0.35",to:"0",dur:"1.5s",repeatCount:"indefinite"})]}),e.jsx("circle",{cx:A,cy:L,r:M,fill:B})]})}:Be(s.shape||"circle")},`marker-${o}-point-${m}`))},`marker-dots-${o}`))]});case"scatter":return e.jsxs(l.ScatterChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"x",type:"number",...ee}),e.jsx(l.YAxis,{dataKey:"y",type:"number",...K}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.filter(r=>r!=="x"&&r!=="y"&&r!=="name").map((r,o)=>{const s=a[r]?.color||g[o%g.length];return e.jsx(l.Scatter,{name:a[r]?.label||r,data:f.map(m=>({x:m.x,y:m.y,[r]:m[r]})),fill:s,className:"cursor-pointer transition-colors",isAnimationActive:!1},r)})]});case"composed":return e.jsxs(l.ComposedChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...K,hide:t==="data-only",width:t==="data-only"?0:K.width,...t!=="full"&&O?{domain:O}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="bar"?e.jsx(l.Bar,{dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length],m=a[r].type||"bar";return m==="area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??s,strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):m==="range-area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??"none",strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="line"?e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null})]});default:return e.jsx("div",{children:"Unsupported chart type"})}},Ee=()=>ze?e.jsx("div",{className:"sr-only",children:e.jsxs("table",{role:"table","aria-label":P?`Data for ${P}`:"Chart data",children:[e.jsxs("caption",{className:"sr-only",children:[P&&`${P}. `,ce||`${i} chart showing ${h.length} data series across ${f.length} categories.`]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Category"}),h.map(t=>e.jsx("th",{scope:"col",children:a[t]?.label||t},t))]})}),e.jsx("tbody",{children:f.map((t,r)=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:t.name||`Item ${r+1}`}),h.map(o=>e.jsx("td",{children:X?X(t[o],r):t[o]},o))]},r))})]})}):null,ae=u.useRef(null);return u.useEffect(()=>{const t=ae.current;if(!t)return;const r=setTimeout(()=>{t.querySelectorAll(".recharts-cartesian-axis-tick").forEach(s=>{const m=s.querySelector("text"),d=s.querySelector(".recharts-cartesian-axis-tick-line");m?.textContent?.trim()==="0"&&d&&d.setAttribute("stroke-width","2")})},100);return()=>clearTimeout(r)},[f,i]),u.useEffect(()=>{if(!D||!z||!k.current||!Q)return;const t=v.findIndex(o=>o.name===z.xValue);if(t<0)return;const r=setTimeout(()=>{if(!k.current)return;const o=k.current.offsetWidth,s=t/(v.length-1)*Q;k.current.scrollLeft=Math.max(0,s-o/2)},50);return()=>clearTimeout(r)},[D,z,Q,v]),e.jsxs("div",{ref:ae,className:Oe.cn("w-full",p),style:{minWidth:w},role:"img","aria-label":P||`${i} chart`,"aria-describedby":ce?`${ae.current?.id||"chart"}-desc`:void 0,...Ke,children:[P&&e.jsx("h3",{className:"sr-only",id:`${ae.current?.id||"chart"}-title`,children:P}),ce&&e.jsx("p",{className:"sr-only",id:`${ae.current?.id||"chart"}-desc`,children:ce}),(()=>{const t=I?x-I:x;if(D&&i!=="horizontal-bar"&&i!=="scatter"){const o=Se+(de().left??0);return e.jsxs("div",{style:{height:y&&I?x:t},children:[e.jsxs("div",{className:"flex w-full",style:{height:t},children:[e.jsx("div",{style:{width:o,flexShrink:0,overflow:"hidden"},children:e.jsx(l.ResponsiveContainer,{width:o,height:t,children:ue("yaxis-only")||e.jsx("div",{children:"Chart error"})})}),e.jsx("div",{ref:k,className:"flex-1 overflow-x-scroll overflow-y-hidden scrollbar-hide select-none",style:{cursor:"grab"},onMouseDown:Pe,onMouseMove:De,onMouseUp:we,onMouseLeave:we,children:e.jsx("div",{style:{width:Q,height:t},children:e.jsx(l.ResponsiveContainer,{width:Q,height:t,children:ue("data-only")||e.jsx("div",{children:"Chart error"})})})})]}),y&&Te()]})}const r=q?e.jsx(l.ResponsiveContainer,{width:C||"100%",height:t,children:ue()||e.jsx("div",{children:"Chart error"})}):e.jsx("div",{style:{width:C||"100%",height:t,minWidth:w},children:ue()||e.jsx("div",{children:"Chart error"})});return I?e.jsx("div",{style:{width:C||"100%"},children:r}):r})(),e.jsx(Ee,{})]})}const qe=(i,f="bar")=>{const a=W[f];return Array.from({length:i},(p,x)=>a[x%a.length])},Xe=(i,f,a)=>Array.isArray(i)?i.reduce((x,C,w)=>(x[C]={label:f?.[w]||C,color:a?.[w]},x),{}):i;exports.Chart=Ve;exports.chartColorSchemes=W;exports.createChartConfig=Xe;exports.formatNumber=V;exports.generateChartColors=qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),l=require("recharts"),Oe=require("../../lib/utils.cjs"),q=(i,f=0)=>{const p=i.toFixed(f).split("."),d=p[0].replace(/\B(?=(\d{3})+(?!\d))/g," ");return f>0&&p[1]?`${d}.${p[1]}`:d},Me=(i,f,a,p=20)=>{if(!i.length)return p;let d=0;i.forEach(S=>{f.forEach(n=>{const b=S[n];typeof b=="number"?d=Math.max(d,Math.abs(b)):Array.isArray(b)&&b.forEach(c=>{typeof c=="number"&&(d=Math.max(d,Math.abs(c)))})})});const w=(a?a(d,0):d.toString()).length;return Math.max(p,w*6+12)},K={bar:["var(--color-chart-bar-1)","var(--color-chart-bar-2)","var(--color-chart-bar-3)","var(--color-chart-bar-4)","var(--color-chart-bar-5)","var(--color-chart-bar-6)"],line:["var(--color-chart-line-1)","var(--color-chart-line-2)","var(--color-chart-line-3)","var(--color-chart-line-4)","var(--color-chart-line-5)"],scatter:["var(--color-chart-scatter-1)","var(--color-chart-scatter-2)","var(--color-chart-scatter-3)","var(--color-chart-scatter-4)","var(--color-chart-scatter-5)","var(--color-chart-scatter-6)"],area:["var(--color-chart-area-1)","var(--color-chart-area-2)","var(--color-chart-area-3)","var(--color-chart-area-4)","var(--color-chart-area-5)","var(--color-chart-area-6)"],accessible:["#0066CC","#CC6600","#009966","#CC0066","#6600CC","#CC9900","#006666","#CC0000"]},T=i=>{switch(i){case"dashed":return"5 5";case"dotted":return"2 2";case"solid":default:return}},Be=(i="circle")=>f=>{const{cx:a,cy:p,r:d,fill:C,stroke:w,strokeWidth:S}=f,n=d||4;switch(i){case"triangle":const b=n*1.5,c=n*1.3,y=`M ${a},${p-b} L ${a+c},${p+b/2} L ${a-c},${p+b/2} Z`;return e.jsx("path",{d:y,fill:C,stroke:w,strokeWidth:S||0});case"square":const j=n*1.4;return e.jsx("rect",{x:a-j,y:p-j,width:j*2,height:j*2,fill:C,stroke:w,strokeWidth:S||0});case"circle":default:return e.jsx("circle",{cx:a,cy:p,r:n,fill:C,stroke:w,strokeWidth:S||0})}},Ae=i=>({verticalAlign:"bottom",align:"center"}),se=({active:i,payload:f,label:a,config:p,tooltipMaxWidth:d="max-w-xs",chartType:C,referenceMarkers:w})=>{if(!i||!f||!f.length)return null;const S=w?.filter(n=>n.xValue===a)||[];return e.jsxs("div",{className:`rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${d} z-[9999]`,role:"tooltip","aria-label":"Chart data tooltip",children:[e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:a}),f.map((n,b)=>{const c=p[n.dataKey];let y;if(c?.type==="range-area"&&n.payload){const N=n.payload[n.dataKey];Array.isArray(N)&&N.length===2?y=`${q(N[0])} – ${q(N[1])}`:y=typeof n.value=="number"?q(n.value):n.value}else y=typeof n.value=="number"?q(n.value):n.value;const j=()=>{switch(C){case"line":const N=p[n.dataKey]?.strokeStyle,E=T(N);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:E?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:E==="5 5"?"6px 100%":E==="2 2"?"2px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"composed":switch(p[n.dataKey]?.type){case"line":const I=p[n.dataKey]?.strokeStyle,$=T(I);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:$?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:$==="5 5"?"6px 100%":$==="2 2"?"2px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-2.5 h-2.5 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":case"area":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c?.label||n.dataKey,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:y})]},b)}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-[var(--space-m)]"}),S.map((n,b)=>e.jsxs(x.Fragment,{children:[n.tooltipLabel&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:n.tooltipLabel}),!n.tooltipLabel&&b===0&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:"Reference Markers:"}),n.dataPoints.map((c,y)=>{const j=()=>{switch(c.shape||"circle"){case"triangle":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M 5,2 L 8,8 L 2,8 Z",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"square":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("rect",{x:"2",y:"2",width:"6",height:"6",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"circle":default:return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c.fill||"var(--color-chart-line-1)",border:c.stroke?`${c.strokeWidth||1}px solid ${c.stroke}`:"none"}})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c.label||`Marker ${y+1}`,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:q(c.yValue)})]},`marker-${b}-point-${y}`)})]},`marker-section-${b}`))]})]})};function Ve({type:i,data:f,config:a,className:p,height:d=300,width:C,minWidth:w=240,onDataPointClick:S,onDataPointHover:n,highlightedIndex:b,showGrid:c=!0,showLegend:y=!0,showTooltip:j=!0,colorScheme:N,responsive:E=!0,maintainAspectRatio:Ie=!1,legendHeight:I,margin:$,yAxisWidth:xe,yAxisTickCount:ve,xAxisTickFormatter:$e,yAxisTickFormatter:X,showRightYAxis:le=!1,rightYAxisWidth:he,rightYAxisTickCount:oe,rightYAxisDomain:ne,rightYAxisTickFormatter:ie,title:P,description:ce,showDataTable:ze=!1,tooltipMaxWidth:F="max-w-xs",tooltipAllowEscapeViewBox:_,legendOrder:R,legendPosition:Fe="bottom",referenceMarkers:be,todayMarker:z,yAxisDomain:O,scrollable:D=!1,scrollableWidth:je,...We}){const[ke,Ke]=x.useState(0),k=x.useRef(null),fe=x.useRef(!1),ge=x.useRef(0),Ce=x.useRef(0),Pe=x.useCallback(t=>{k.current&&(fe.current=!0,ge.current=t.pageX-k.current.offsetLeft,Ce.current=k.current.scrollLeft,k.current.style.cursor="grabbing")},[]),De=x.useCallback(t=>{if(!fe.current||!k.current)return;t.preventDefault();const r=t.pageX-k.current.offsetLeft;k.current.scrollLeft=Ce.current-(r-ge.current)},[]),we=x.useCallback(()=>{fe.current=!1,k.current&&(k.current.style.cursor="grab")},[]),g=x.useMemo(()=>{if(N)return K[N];switch(i){case"bar":case"horizontal-bar":return K.bar;case"line":return K.line;case"scatter":return K.scatter;case"composed":return K.bar;default:return K.bar}},[i,N]),h=Object.keys(a).filter(t=>t!=="name"),v=x.useMemo(()=>f.map(t=>{const r={...t};return h.forEach(o=>{if(a[o].type==="range-area"){const s=t[o];Array.isArray(s)&&s.length===2&&(r[o]=s,r[`${o}_min`]=s[0],r[`${o}_max`]=s[1])}}),r}),[f,a,h]),pe=x.useMemo(()=>{if(!z)return null;const t=v.find(r=>r.name===z.xValue);return{xValue:z.xValue,showLine:!0,lineLabel:z.label??"Today",lineStyle:{stroke:"var(--color-border-error-bold)",strokeWidth:2},dataPoints:h.filter(r=>t&&t[r]!=null).map(r=>({yValue:t[r],yAxisId:a[r].yAxisId||"left",fill:"var(--color-background-error-bold)",size:4,pulsing:!0}))}},[z,v,h,a]),me=x.useMemo(()=>[...be??[],...pe?[pe]:[]],[be,pe]),U=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;Ke(r),n?.(t?.activePayload?.[0]?.payload,r)},[n]),Z=x.useCallback(()=>{n?.(null)},[n]),G=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;S?.(t?.activePayload?.[0]?.payload,r)},[S]),J=x.useMemo(()=>ke>=Math.floor(v.length/2),[ke,v.length]),de=()=>{const t={top:8,right:0,left:0,bottom:0};return{top:$?.top??t.top,right:$?.right??t.right,left:$?.left??t.left,bottom:$?.bottom??t.bottom}},Se=x.useMemo(()=>xe||Me(v,h,X,20),[xe,v,h,X]),B=x.useMemo(()=>{if(!D||O)return O;const t=v.flatMap(r=>h.map(o=>{const s=r[o];return Array.isArray(s)||typeof s=="number"?s:0}).flat());return[Math.min(0,...t),Math.max(...t)]},[D,O,v,h]),Q=x.useMemo(()=>D?je??Math.max(v.length*60,600):void 0,[D,je,v.length]),Ne=x.useMemo(()=>{if(!le)return 0;if(he)return he;const t=h.filter(r=>a[r].yAxisId==="right");return t.length===0?0:Me(v,t,ie,20)},[le,he,v,h,a,ie]),Le=x.useMemo(()=>h.some(r=>(a[r].yAxisId||"left")==="left")?"left":"right",[h,a]),Y=I?{...Ae(),wrapperStyle:{position:"absolute",bottom:0,left:0,right:0,height:I,paddingTop:8,zIndex:1}}:Ae(),H={data:v,margin:de()},ee={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:!1,tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},tickFormatter:$e},W={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Se,tickFormatter:X,...ve&&{tickCount:ve},...O&&{domain:O}},re={stroke:"var(--color-border-primary-subtle)",horizontal:!0,vertical:!1},te=({payload:t})=>{if(!t||!t.length)return null;const r=t.filter(u=>a[u.dataKey]),o=R?[...r].sort((u,A)=>{const L=R.indexOf(u.dataKey),M=R.indexOf(A.dataKey);return L===-1?1:M===-1?-1:L-M}):r,m=de().left+5;return e.jsx("div",{style:{paddingLeft:`${m}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:o.map((u,A)=>{const L=()=>{switch(i){case"line":const M=a[u.dataKey]?.strokeStyle,V=T(M);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:V?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:V==="5 5"?"8px 100%":V==="2 2"?"3px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-[6px] h-[6px] rounded-full flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"composed":switch(a[u.dataKey]?.type){case"line":const Re=a[u.dataKey]?.strokeStyle,ye=T(Re);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:ye?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:ye==="5 5"?"8px 100%":ye==="2 2"?"3px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-[8px] h-[8px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[L(),e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.value})]},A)})})})},Te=()=>{const t=R?[...R,...Object.keys(a).filter(s=>!R.includes(s))]:Object.keys(a),o=de().left+5;return e.jsx("div",{style:{paddingLeft:`${o}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:t.map((s,m)=>{const u=a[s];if(!u)return null;const A=u.color??"currentColor",L=T(u.strokeStyle),M=e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:L?`linear-gradient(to right, ${A} 50%, transparent 50%)`:A,backgroundSize:L==="5 5"?"8px 100%":L==="2 2"?"3px 100%":"100% 100%"}})});return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[M,e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.label})]},m)})})})},ue=(t="full")=>{switch(i){case"bar":return e.jsxs(l.BarChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r)})]});case"horizontal-bar":return e.jsxs(l.BarChart,{...H,layout:"vertical",onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re,horizontal:!1,vertical:!0}),e.jsx(l.XAxis,{type:"number",...ee}),e.jsx(l.YAxis,{type:"category",dataKey:"name",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:40},r)})]});case"line":return e.jsxs(l.LineChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i,referenceMarkers:me}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r)}),t!=="yaxis-only"&&me.map((r,o)=>r.showLine!==!1?e.jsx(l.ReferenceLine,{x:r.xValue,yAxisId:"left",stroke:r.lineStyle?.stroke||"#000000",strokeWidth:r.lineStyle?.strokeWidth||2,strokeDasharray:r.lineStyle?.strokeDasharray,label:r.lineLabel?s=>{const{viewBox:m}=s;return m?e.jsx("text",{x:m.x+6,y:m.y+8,dominantBaseline:"middle",fill:"var(--color-text-error-bold)",fontSize:10,fontFamily:"inherit",fontWeight:700,children:r.lineLabel}):null}:void 0},`marker-line-${o}`):null),t!=="yaxis-only"&&me.map((r,o)=>e.jsx(x.Fragment,{children:r.dataPoints?.map((s,m)=>e.jsx(l.ReferenceDot,{x:r.xValue,y:s.yValue,yAxisId:s.yAxisId||"left",r:s.size||4,fill:s.fill||"var(--color-chart-line-1)",stroke:s.stroke||"transparent",strokeWidth:s.strokeWidth||0,shape:s.pulsing?u=>{const{cx:A,cy:L}=u,M=s.size||4,V=s.fill||"var(--color-background-error-bold)";return e.jsxs("g",{children:[e.jsxs("circle",{cx:A,cy:L,r:M+1,fill:V,opacity:.3,children:[e.jsx("animate",{attributeName:"r",from:String(M+1),to:String(M+8),dur:"1.5s",repeatCount:"indefinite"}),e.jsx("animate",{attributeName:"opacity",from:"0.35",to:"0",dur:"1.5s",repeatCount:"indefinite"})]}),e.jsx("circle",{cx:A,cy:L,r:M,fill:V})]})}:Be(s.shape||"circle")},`marker-${o}-point-${m}`))},`marker-dots-${o}`))]});case"scatter":return e.jsxs(l.ScatterChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"x",type:"number",...ee}),e.jsx(l.YAxis,{dataKey:"y",type:"number",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.filter(r=>r!=="x"&&r!=="y"&&r!=="name").map((r,o)=>{const s=a[r]?.color||g[o%g.length];return e.jsx(l.Scatter,{name:a[r]?.label||r,data:f.map(m=>({x:m.x,y:m.y,[r]:m[r]})),fill:s,className:"cursor-pointer transition-colors",isAnimationActive:!1},r)})]});case"composed":return e.jsxs(l.ComposedChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="bar"?e.jsx(l.Bar,{dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length],m=a[r].type||"bar";return m==="area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??s,strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):m==="range-area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??"none",strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="line"?e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null})]});default:return e.jsx("div",{children:"Unsupported chart type"})}},Ee=()=>ze?e.jsx("div",{className:"sr-only",children:e.jsxs("table",{role:"table","aria-label":P?`Data for ${P}`:"Chart data",children:[e.jsxs("caption",{className:"sr-only",children:[P&&`${P}. `,ce||`${i} chart showing ${h.length} data series across ${f.length} categories.`]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Category"}),h.map(t=>e.jsx("th",{scope:"col",children:a[t]?.label||t},t))]})}),e.jsx("tbody",{children:f.map((t,r)=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:t.name||`Item ${r+1}`}),h.map(o=>e.jsx("td",{children:X?X(t[o],r):t[o]},o))]},r))})]})}):null,ae=x.useRef(null);return x.useEffect(()=>{const t=ae.current;if(!t)return;const r=setTimeout(()=>{t.querySelectorAll(".recharts-cartesian-axis-tick").forEach(s=>{const m=s.querySelector("text"),u=s.querySelector(".recharts-cartesian-axis-tick-line");m?.textContent?.trim()==="0"&&u&&u.setAttribute("stroke-width","2")})},100);return()=>clearTimeout(r)},[f,i]),x.useEffect(()=>{if(!D||!z||!k.current||!Q)return;const t=v.findIndex(o=>o.name===z.xValue);if(t<0)return;const r=setTimeout(()=>{if(!k.current)return;const o=k.current.offsetWidth,s=t/(v.length-1)*Q;k.current.scrollLeft=Math.max(0,s-o/2)},50);return()=>clearTimeout(r)},[D,z,Q,v]),e.jsxs("div",{ref:ae,className:Oe.cn("w-full",p),style:{minWidth:E?0:w,...typeof d=="string"?{height:d}:{}},role:"img","aria-label":P||`${i} chart`,"aria-describedby":ce?`${ae.current?.id||"chart"}-desc`:void 0,...We,children:[P&&e.jsx("h3",{className:"sr-only",id:`${ae.current?.id||"chart"}-title`,children:P}),ce&&e.jsx("p",{className:"sr-only",id:`${ae.current?.id||"chart"}-desc`,children:ce}),(()=>{const t=typeof d=="string"?d:I?d-I:d;if(D&&i!=="horizontal-bar"&&i!=="scatter"){const o=Se+(de().left??0);return e.jsxs("div",{style:{height:y&&I?d:t},children:[e.jsxs("div",{className:"flex w-full",style:{height:t},children:[e.jsx("div",{style:{width:o,flexShrink:0,overflow:"hidden"},children:e.jsx(l.ResponsiveContainer,{width:o,height:t,children:ue("yaxis-only")||e.jsx("div",{children:"Chart error"})})}),e.jsx("div",{ref:k,className:"flex-1 overflow-x-scroll overflow-y-hidden scrollbar-hide select-none",style:{cursor:"grab"},onMouseDown:Pe,onMouseMove:De,onMouseUp:we,onMouseLeave:we,children:e.jsx("div",{style:{width:Q,height:t},children:e.jsx(l.ResponsiveContainer,{width:Q,height:t,children:ue("data-only")||e.jsx("div",{children:"Chart error"})})})})]}),y&&Te()]})}const r=E?e.jsx(l.ResponsiveContainer,{width:C||"100%",height:t,children:ue()||e.jsx("div",{children:"Chart error"})}):e.jsx("div",{style:{width:C||"100%",height:t,minWidth:w},children:ue()||e.jsx("div",{children:"Chart error"})});return I?e.jsx("div",{style:{width:C||"100%"},children:r}):r})(),e.jsx(Ee,{})]})}const qe=(i,f="bar")=>{const a=K[f];return Array.from({length:i},(p,d)=>a[d%a.length])},Xe=(i,f,a)=>Array.isArray(i)?i.reduce((d,C,w)=>(d[C]={label:f?.[w]||C,color:a?.[w]},d),{}):i;exports.Chart=Ve;exports.chartColorSchemes=K;exports.createChartConfig=Xe;exports.formatNumber=q;exports.generateChartColors=qe;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as u, jsx as r, Fragment as He } from "react/jsx-runtime";
|
|
2
2
|
import S, { useState as Ye, useMemo as $, useCallback as Se } from "react";
|
|
3
3
|
import { ResponsiveContainer as Ne, ComposedChart as er, CartesianGrid as se, XAxis as oe, YAxis as T, Tooltip as ne, Legend as ie, Bar as Le, Area as Te, Line as Oe, ScatterChart as rr, Scatter as tr, LineChart as ar, ReferenceLine as lr, ReferenceDot as sr, BarChart as Re } from "recharts";
|
|
4
4
|
import { cn as or } from "../../lib/utils.js";
|
|
5
5
|
const ce = (n, f = 0) => {
|
|
6
|
-
const p = n.toFixed(f).split("."),
|
|
7
|
-
return f > 0 && p[1] ? `${
|
|
6
|
+
const p = n.toFixed(f).split("."), c = p[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
|
7
|
+
return f > 0 && p[1] ? `${c}.${p[1]}` : c;
|
|
8
8
|
}, Ve = (n, f, a, p = 20) => {
|
|
9
9
|
if (!n.length) return p;
|
|
10
|
-
let
|
|
10
|
+
let c = 0;
|
|
11
11
|
n.forEach((N) => {
|
|
12
12
|
f.forEach((o) => {
|
|
13
13
|
const v = N[o];
|
|
14
|
-
typeof v == "number" ?
|
|
15
|
-
typeof i == "number" && (
|
|
14
|
+
typeof v == "number" ? c = Math.max(c, Math.abs(v)) : Array.isArray(v) && v.forEach((i) => {
|
|
15
|
+
typeof i == "number" && (c = Math.max(c, Math.abs(i)));
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
const w = (a ? a(
|
|
19
|
+
const w = (a ? a(c, 0) : c.toString()).length;
|
|
20
20
|
return Math.max(p, w * 6 + 12);
|
|
21
21
|
}, O = {
|
|
22
22
|
bar: [
|
|
@@ -106,7 +106,7 @@ const ce = (n, f = 0) => {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
}, nr = (n = "circle") => (f) => {
|
|
109
|
-
const { cx: a, cy: p, r:
|
|
109
|
+
const { cx: a, cy: p, r: c, fill: g, stroke: w, strokeWidth: N } = f, o = c || 4;
|
|
110
110
|
switch (n) {
|
|
111
111
|
case "triangle":
|
|
112
112
|
const v = o * 1.5, i = o * 1.3, m = `M ${a},${p - v} L ${a + i},${p + v / 2} L ${a - i},${p + v / 2} Z`;
|
|
@@ -147,14 +147,14 @@ const ce = (n, f = 0) => {
|
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
|
-
}, Be = (n) => ({ verticalAlign: "bottom", align: "center" }), de = ({ active: n, payload: f, label: a, config: p, tooltipMaxWidth:
|
|
150
|
+
}, Be = (n) => ({ verticalAlign: "bottom", align: "center" }), de = ({ active: n, payload: f, label: a, config: p, tooltipMaxWidth: c = "max-w-xs", chartType: g, referenceMarkers: w }) => {
|
|
151
151
|
if (!n || !f || !f.length)
|
|
152
152
|
return null;
|
|
153
153
|
const N = w?.filter((o) => o.xValue === a) || [];
|
|
154
|
-
return /* @__PURE__ */
|
|
154
|
+
return /* @__PURE__ */ u(
|
|
155
155
|
"div",
|
|
156
156
|
{
|
|
157
|
-
className: `rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${
|
|
157
|
+
className: `rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${c} z-[9999]`,
|
|
158
158
|
role: "tooltip",
|
|
159
159
|
"aria-label": "Chart data tooltip",
|
|
160
160
|
children: [
|
|
@@ -167,11 +167,11 @@ const ce = (n, f = 0) => {
|
|
|
167
167
|
Array.isArray(L) && L.length === 2 ? m = `${ce(L[0])} – ${ce(L[1])}` : m = typeof o.value == "number" ? ce(o.value) : o.value;
|
|
168
168
|
} else
|
|
169
169
|
m = typeof o.value == "number" ? ce(o.value) : o.value;
|
|
170
|
-
return /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ u("div", { className: "flex items-center gap-[var(--space-xs)]", children: [
|
|
171
171
|
(() => {
|
|
172
172
|
switch (g) {
|
|
173
173
|
case "line":
|
|
174
|
-
const L = p[o.dataKey]?.strokeStyle,
|
|
174
|
+
const L = p[o.dataKey]?.strokeStyle, V = R(L);
|
|
175
175
|
return /* @__PURE__ */ r(
|
|
176
176
|
"div",
|
|
177
177
|
{
|
|
@@ -182,8 +182,8 @@ const ce = (n, f = 0) => {
|
|
|
182
182
|
{
|
|
183
183
|
className: "w-full h-full",
|
|
184
184
|
style: {
|
|
185
|
-
background:
|
|
186
|
-
backgroundSize:
|
|
185
|
+
background: V ? `linear-gradient(to right, ${o.color} 50%, transparent 50%)` : o.color,
|
|
186
|
+
backgroundSize: V === "5 5" ? "6px 100%" : V === "2 2" ? "2px 100%" : "100% 100%"
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
)
|
|
@@ -201,7 +201,7 @@ const ce = (n, f = 0) => {
|
|
|
201
201
|
case "composed":
|
|
202
202
|
switch (p[o.dataKey]?.type) {
|
|
203
203
|
case "line":
|
|
204
|
-
const A = p[o.dataKey]?.strokeStyle,
|
|
204
|
+
const A = p[o.dataKey]?.strokeStyle, W = R(A);
|
|
205
205
|
return /* @__PURE__ */ r(
|
|
206
206
|
"div",
|
|
207
207
|
{
|
|
@@ -212,8 +212,8 @@ const ce = (n, f = 0) => {
|
|
|
212
212
|
{
|
|
213
213
|
className: "w-full h-full",
|
|
214
214
|
style: {
|
|
215
|
-
background:
|
|
216
|
-
backgroundSize:
|
|
215
|
+
background: W ? `linear-gradient(to right, ${o.color} 50%, transparent 50%)` : o.color,
|
|
216
|
+
backgroundSize: W === "5 5" ? "6px 100%" : W === "2 2" ? "2px 100%" : "100% 100%"
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
)
|
|
@@ -254,19 +254,19 @@ const ce = (n, f = 0) => {
|
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
256
|
})(),
|
|
257
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ u("span", { className: "text-body-sm text-[var(--color-text-primary)] min-w-0 break-words", children: [
|
|
258
258
|
i?.label || o.dataKey,
|
|
259
259
|
":"
|
|
260
260
|
] }),
|
|
261
261
|
/* @__PURE__ */ r("span", { className: "text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]", children: m })
|
|
262
262
|
] }, v);
|
|
263
263
|
}),
|
|
264
|
-
N.length > 0 && /* @__PURE__ */
|
|
264
|
+
N.length > 0 && /* @__PURE__ */ u(He, { children: [
|
|
265
265
|
/* @__PURE__ */ r("div", { className: "my-[var(--space-m)]" }),
|
|
266
|
-
N.map((o, v) => /* @__PURE__ */
|
|
266
|
+
N.map((o, v) => /* @__PURE__ */ u(S.Fragment, { children: [
|
|
267
267
|
o.tooltipLabel && /* @__PURE__ */ r("p", { className: "text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]", children: o.tooltipLabel }),
|
|
268
268
|
!o.tooltipLabel && v === 0 && /* @__PURE__ */ r("p", { className: "text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]", children: "Reference Markers:" }),
|
|
269
|
-
o.dataPoints.map((i, m) => /* @__PURE__ */
|
|
269
|
+
o.dataPoints.map((i, m) => /* @__PURE__ */ u("div", { className: "flex items-center gap-[var(--space-xs)]", children: [
|
|
270
270
|
(() => {
|
|
271
271
|
switch (i.shape || "circle") {
|
|
272
272
|
case "triangle":
|
|
@@ -306,7 +306,7 @@ const ce = (n, f = 0) => {
|
|
|
306
306
|
);
|
|
307
307
|
}
|
|
308
308
|
})(),
|
|
309
|
-
/* @__PURE__ */
|
|
309
|
+
/* @__PURE__ */ u("span", { className: "text-body-sm text-[var(--color-text-primary)] min-w-0 break-words", children: [
|
|
310
310
|
i.label || `Marker ${m + 1}`,
|
|
311
311
|
":"
|
|
312
312
|
] }),
|
|
@@ -323,9 +323,9 @@ function pr({
|
|
|
323
323
|
data: f,
|
|
324
324
|
config: a,
|
|
325
325
|
className: p,
|
|
326
|
-
height:
|
|
326
|
+
height: c = 300,
|
|
327
327
|
width: g,
|
|
328
|
-
minWidth: w =
|
|
328
|
+
minWidth: w = 240,
|
|
329
329
|
onDataPointClick: N,
|
|
330
330
|
onDataPointHover: o,
|
|
331
331
|
highlightedIndex: v,
|
|
@@ -333,10 +333,10 @@ function pr({
|
|
|
333
333
|
showLegend: m = !0,
|
|
334
334
|
showTooltip: C = !0,
|
|
335
335
|
colorScheme: L,
|
|
336
|
-
responsive:
|
|
336
|
+
responsive: V = !0,
|
|
337
337
|
maintainAspectRatio: je = !1,
|
|
338
338
|
legendHeight: A,
|
|
339
|
-
margin:
|
|
339
|
+
margin: W,
|
|
340
340
|
yAxisWidth: ve,
|
|
341
341
|
yAxisTickCount: Ie,
|
|
342
342
|
xAxisTickFormatter: qe,
|
|
@@ -351,23 +351,23 @@ function pr({
|
|
|
351
351
|
showDataTable: _e = !1,
|
|
352
352
|
tooltipMaxWidth: X = "max-w-xs",
|
|
353
353
|
tooltipAllowEscapeViewBox: U,
|
|
354
|
-
legendOrder:
|
|
354
|
+
legendOrder: B,
|
|
355
355
|
legendPosition: ir = "bottom",
|
|
356
356
|
referenceMarkers: Me,
|
|
357
|
-
todayMarker:
|
|
358
|
-
yAxisDomain:
|
|
357
|
+
todayMarker: K,
|
|
358
|
+
yAxisDomain: j,
|
|
359
359
|
scrollable: E = !1,
|
|
360
360
|
scrollableWidth: $e,
|
|
361
361
|
...Fe
|
|
362
362
|
}) {
|
|
363
|
-
const [ze, Xe] = Ye(0), b = S.useRef(null), ke = S.useRef(!1), Ae = S.useRef(0),
|
|
364
|
-
b.current && (ke.current = !0, Ae.current = t.pageX - b.current.offsetLeft,
|
|
363
|
+
const [ze, Xe] = Ye(0), b = S.useRef(null), ke = S.useRef(!1), Ae = S.useRef(0), We = S.useRef(0), Ue = S.useCallback((t) => {
|
|
364
|
+
b.current && (ke.current = !0, Ae.current = t.pageX - b.current.offsetLeft, We.current = b.current.scrollLeft, b.current.style.cursor = "grabbing");
|
|
365
365
|
}, []), Ze = S.useCallback((t) => {
|
|
366
366
|
if (!ke.current || !b.current) return;
|
|
367
367
|
t.preventDefault();
|
|
368
368
|
const e = t.pageX - b.current.offsetLeft;
|
|
369
|
-
b.current.scrollLeft =
|
|
370
|
-
}, []),
|
|
369
|
+
b.current.scrollLeft = We.current - (e - Ae.current);
|
|
370
|
+
}, []), Ke = S.useCallback(() => {
|
|
371
371
|
ke.current = !1, b.current && (b.current.style.cursor = "grab");
|
|
372
372
|
}, []), k = $(() => {
|
|
373
373
|
if (L)
|
|
@@ -395,12 +395,12 @@ function pr({
|
|
|
395
395
|
}
|
|
396
396
|
}), e;
|
|
397
397
|
}), [f, a, h]), ge = $(() => {
|
|
398
|
-
if (!
|
|
399
|
-
const t = y.find((e) => e.name ===
|
|
398
|
+
if (!K) return null;
|
|
399
|
+
const t = y.find((e) => e.name === K.xValue);
|
|
400
400
|
return {
|
|
401
|
-
xValue:
|
|
401
|
+
xValue: K.xValue,
|
|
402
402
|
showLine: !0,
|
|
403
|
-
lineLabel:
|
|
403
|
+
lineLabel: K.label ?? "Today",
|
|
404
404
|
lineStyle: {
|
|
405
405
|
stroke: "var(--color-border-error-bold)",
|
|
406
406
|
strokeWidth: 2
|
|
@@ -413,7 +413,7 @@ function pr({
|
|
|
413
413
|
pulsing: !0
|
|
414
414
|
}))
|
|
415
415
|
};
|
|
416
|
-
}, [
|
|
416
|
+
}, [K, y, h, a]), we = $(() => [
|
|
417
417
|
...Me ?? [],
|
|
418
418
|
...ge ? [ge] : []
|
|
419
419
|
], [Me, ge]), Z = Se((t) => {
|
|
@@ -427,14 +427,14 @@ function pr({
|
|
|
427
427
|
}, [N]), G = $(() => ze >= Math.floor(y.length / 2), [ze, y.length]), me = () => {
|
|
428
428
|
const t = { top: 8, right: 0, left: 0, bottom: 0 };
|
|
429
429
|
return {
|
|
430
|
-
top:
|
|
431
|
-
right:
|
|
430
|
+
top: W?.top ?? t.top,
|
|
431
|
+
right: W?.right ?? t.right,
|
|
432
432
|
// Don't add rightYAxisWidth - Recharts handles it via YAxis width prop
|
|
433
|
-
left:
|
|
434
|
-
bottom:
|
|
433
|
+
left: W?.left ?? t.left,
|
|
434
|
+
bottom: W?.bottom ?? t.bottom
|
|
435
435
|
};
|
|
436
|
-
}, Pe = $(() => ve || Ve(y, h, F, 20), [ve, y, h, F]),
|
|
437
|
-
if (!E ||
|
|
436
|
+
}, Pe = $(() => ve || Ve(y, h, F, 20), [ve, y, h, F]), q = $(() => {
|
|
437
|
+
if (!E || j) return j;
|
|
438
438
|
const t = y.flatMap(
|
|
439
439
|
(e) => h.map((s) => {
|
|
440
440
|
const l = e[s];
|
|
@@ -442,7 +442,7 @@ function pr({
|
|
|
442
442
|
}).flat()
|
|
443
443
|
);
|
|
444
444
|
return [Math.min(0, ...t), Math.max(...t)];
|
|
445
|
-
}, [E,
|
|
445
|
+
}, [E, j, y, h]), H = $(
|
|
446
446
|
() => E ? $e ?? Math.max(y.length * 60, 600) : void 0,
|
|
447
447
|
[E, $e, y.length]
|
|
448
448
|
), De = $(() => {
|
|
@@ -486,7 +486,7 @@ function pr({
|
|
|
486
486
|
tickFormatter: F,
|
|
487
487
|
...Ie && { tickCount: Ie },
|
|
488
488
|
// Force specific number of ticks when provided
|
|
489
|
-
...
|
|
489
|
+
...j && { domain: j }
|
|
490
490
|
// Custom Y-axis domain when provided
|
|
491
491
|
}, te = {
|
|
492
492
|
stroke: "var(--color-border-primary-subtle)",
|
|
@@ -494,8 +494,8 @@ function pr({
|
|
|
494
494
|
vertical: !1
|
|
495
495
|
}, ae = ({ payload: t }) => {
|
|
496
496
|
if (!t || !t.length) return null;
|
|
497
|
-
const e = t.filter((
|
|
498
|
-
const M =
|
|
497
|
+
const e = t.filter((d) => a[d.dataKey]), s = B ? [...e].sort((d, z) => {
|
|
498
|
+
const M = B.indexOf(d.dataKey), I = B.indexOf(z.dataKey);
|
|
499
499
|
return M === -1 ? 1 : I === -1 ? -1 : M - I;
|
|
500
500
|
}) : e, x = me().left + 5;
|
|
501
501
|
return /* @__PURE__ */ r(
|
|
@@ -505,11 +505,11 @@ function pr({
|
|
|
505
505
|
paddingLeft: `${x}px`,
|
|
506
506
|
paddingRight: "16px"
|
|
507
507
|
},
|
|
508
|
-
children: /* @__PURE__ */ r("div", { className: "flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]", children: s.map((
|
|
508
|
+
children: /* @__PURE__ */ r("div", { className: "flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]", children: s.map((d, z) => /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-[var(--space-xs)]", children: [
|
|
509
509
|
(() => {
|
|
510
510
|
switch (n) {
|
|
511
511
|
case "line":
|
|
512
|
-
const I = a[
|
|
512
|
+
const I = a[d.dataKey]?.strokeStyle, _ = R(I);
|
|
513
513
|
return /* @__PURE__ */ r(
|
|
514
514
|
"div",
|
|
515
515
|
{
|
|
@@ -520,8 +520,8 @@ function pr({
|
|
|
520
520
|
{
|
|
521
521
|
className: "w-full h-full",
|
|
522
522
|
style: {
|
|
523
|
-
background:
|
|
524
|
-
backgroundSize:
|
|
523
|
+
background: _ ? `linear-gradient(to right, ${d.color} 50%, transparent 50%)` : d.color,
|
|
524
|
+
backgroundSize: _ === "5 5" ? "8px 100%" : _ === "2 2" ? "3px 100%" : "100% 100%"
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
)
|
|
@@ -532,14 +532,14 @@ function pr({
|
|
|
532
532
|
"div",
|
|
533
533
|
{
|
|
534
534
|
className: "w-[6px] h-[6px] rounded-full flex-shrink-0",
|
|
535
|
-
style: { backgroundColor:
|
|
535
|
+
style: { backgroundColor: d.color },
|
|
536
536
|
"aria-hidden": "true"
|
|
537
537
|
}
|
|
538
538
|
);
|
|
539
539
|
case "composed":
|
|
540
|
-
switch (a[
|
|
540
|
+
switch (a[d.dataKey]?.type) {
|
|
541
541
|
case "line":
|
|
542
|
-
const Ge = a[
|
|
542
|
+
const Ge = a[d.dataKey]?.strokeStyle, Ce = R(Ge);
|
|
543
543
|
return /* @__PURE__ */ r(
|
|
544
544
|
"div",
|
|
545
545
|
{
|
|
@@ -550,7 +550,7 @@ function pr({
|
|
|
550
550
|
{
|
|
551
551
|
className: "w-full h-full",
|
|
552
552
|
style: {
|
|
553
|
-
background: Ce ? `linear-gradient(to right, ${
|
|
553
|
+
background: Ce ? `linear-gradient(to right, ${d.color} 50%, transparent 50%)` : d.color,
|
|
554
554
|
backgroundSize: Ce === "5 5" ? "8px 100%" : Ce === "2 2" ? "3px 100%" : "100% 100%"
|
|
555
555
|
}
|
|
556
556
|
}
|
|
@@ -563,7 +563,7 @@ function pr({
|
|
|
563
563
|
"div",
|
|
564
564
|
{
|
|
565
565
|
className: "w-[8px] h-[8px] flex-shrink-0",
|
|
566
|
-
style: { backgroundColor:
|
|
566
|
+
style: { backgroundColor: d.color },
|
|
567
567
|
"aria-hidden": "true"
|
|
568
568
|
}
|
|
569
569
|
);
|
|
@@ -573,7 +573,7 @@ function pr({
|
|
|
573
573
|
"div",
|
|
574
574
|
{
|
|
575
575
|
className: "w-[6px] h-[6px] flex-shrink-0",
|
|
576
|
-
style: { backgroundColor:
|
|
576
|
+
style: { backgroundColor: d.color },
|
|
577
577
|
"aria-hidden": "true"
|
|
578
578
|
}
|
|
579
579
|
);
|
|
@@ -585,22 +585,22 @@ function pr({
|
|
|
585
585
|
"div",
|
|
586
586
|
{
|
|
587
587
|
className: "w-[6px] h-[6px] flex-shrink-0",
|
|
588
|
-
style: { backgroundColor:
|
|
588
|
+
style: { backgroundColor: d.color },
|
|
589
589
|
"aria-hidden": "true"
|
|
590
590
|
}
|
|
591
591
|
);
|
|
592
592
|
}
|
|
593
593
|
})(),
|
|
594
|
-
/* @__PURE__ */ r("span", { className: "[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap", children:
|
|
594
|
+
/* @__PURE__ */ r("span", { className: "[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap", children: d.value })
|
|
595
595
|
] }, z)) })
|
|
596
596
|
}
|
|
597
597
|
);
|
|
598
598
|
}, Je = () => {
|
|
599
|
-
const t =
|
|
599
|
+
const t = B ? [...B, ...Object.keys(a).filter((l) => !B.includes(l))] : Object.keys(a), s = me().left + 5;
|
|
600
600
|
return /* @__PURE__ */ r("div", { style: { paddingLeft: `${s}px`, paddingRight: "16px" }, children: /* @__PURE__ */ r("div", { className: "flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]", children: t.map((l, x) => {
|
|
601
|
-
const
|
|
602
|
-
if (!
|
|
603
|
-
const z =
|
|
601
|
+
const d = a[l];
|
|
602
|
+
if (!d) return null;
|
|
603
|
+
const z = d.color ?? "currentColor", M = R(d.strokeStyle), I = /* @__PURE__ */ r("div", { className: "w-[12px] h-[2px] flex-shrink-0 relative", "aria-hidden": "true", children: /* @__PURE__ */ r(
|
|
604
604
|
"div",
|
|
605
605
|
{
|
|
606
606
|
className: "w-full h-full",
|
|
@@ -610,15 +610,15 @@ function pr({
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
) });
|
|
613
|
-
return /* @__PURE__ */
|
|
613
|
+
return /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-[var(--space-xs)]", children: [
|
|
614
614
|
I,
|
|
615
|
-
/* @__PURE__ */ r("span", { className: "[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap", children:
|
|
615
|
+
/* @__PURE__ */ r("span", { className: "[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap", children: d.label })
|
|
616
616
|
] }, x);
|
|
617
617
|
}) }) });
|
|
618
618
|
}, ye = (t = "full") => {
|
|
619
619
|
switch (n) {
|
|
620
620
|
case "bar":
|
|
621
|
-
return /* @__PURE__ */
|
|
621
|
+
return /* @__PURE__ */ u(
|
|
622
622
|
Re,
|
|
623
623
|
{
|
|
624
624
|
...ee,
|
|
@@ -634,7 +634,7 @@ function pr({
|
|
|
634
634
|
...P,
|
|
635
635
|
hide: t === "data-only",
|
|
636
636
|
width: t === "data-only" ? 0 : P.width,
|
|
637
|
-
...t !== "full" &&
|
|
637
|
+
...t !== "full" && q ? { domain: q } : {}
|
|
638
638
|
}
|
|
639
639
|
),
|
|
640
640
|
t !== "yaxis-only" && C && /* @__PURE__ */ r(
|
|
@@ -677,7 +677,7 @@ function pr({
|
|
|
677
677
|
}
|
|
678
678
|
);
|
|
679
679
|
case "horizontal-bar":
|
|
680
|
-
return /* @__PURE__ */
|
|
680
|
+
return /* @__PURE__ */ u(
|
|
681
681
|
Re,
|
|
682
682
|
{
|
|
683
683
|
...ee,
|
|
@@ -728,7 +728,7 @@ function pr({
|
|
|
728
728
|
}
|
|
729
729
|
);
|
|
730
730
|
case "line":
|
|
731
|
-
return /* @__PURE__ */
|
|
731
|
+
return /* @__PURE__ */ u(
|
|
732
732
|
ar,
|
|
733
733
|
{
|
|
734
734
|
...ee,
|
|
@@ -745,7 +745,7 @@ function pr({
|
|
|
745
745
|
...P,
|
|
746
746
|
hide: t === "data-only",
|
|
747
747
|
width: t === "data-only" ? 0 : P.width,
|
|
748
|
-
...t !== "full" &&
|
|
748
|
+
...t !== "full" && q ? { domain: q } : {}
|
|
749
749
|
}
|
|
750
750
|
),
|
|
751
751
|
t !== "yaxis-only" && ue && /* @__PURE__ */ r(
|
|
@@ -852,14 +852,14 @@ function pr({
|
|
|
852
852
|
fill: l.fill || "var(--color-chart-line-1)",
|
|
853
853
|
stroke: l.stroke || "transparent",
|
|
854
854
|
strokeWidth: l.strokeWidth || 0,
|
|
855
|
-
shape: l.pulsing ? (
|
|
856
|
-
const { cx: z, cy: M } =
|
|
857
|
-
return /* @__PURE__ */
|
|
858
|
-
/* @__PURE__ */
|
|
855
|
+
shape: l.pulsing ? (d) => {
|
|
856
|
+
const { cx: z, cy: M } = d, I = l.size || 4, _ = l.fill || "var(--color-background-error-bold)";
|
|
857
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
858
|
+
/* @__PURE__ */ u("circle", { cx: z, cy: M, r: I + 1, fill: _, opacity: 0.3, children: [
|
|
859
859
|
/* @__PURE__ */ r("animate", { attributeName: "r", from: String(I + 1), to: String(I + 8), dur: "1.5s", repeatCount: "indefinite" }),
|
|
860
860
|
/* @__PURE__ */ r("animate", { attributeName: "opacity", from: "0.35", to: "0", dur: "1.5s", repeatCount: "indefinite" })
|
|
861
861
|
] }),
|
|
862
|
-
/* @__PURE__ */ r("circle", { cx: z, cy: M, r: I, fill:
|
|
862
|
+
/* @__PURE__ */ r("circle", { cx: z, cy: M, r: I, fill: _ })
|
|
863
863
|
] });
|
|
864
864
|
} : nr(l.shape || "circle")
|
|
865
865
|
},
|
|
@@ -869,7 +869,7 @@ function pr({
|
|
|
869
869
|
}
|
|
870
870
|
);
|
|
871
871
|
case "scatter":
|
|
872
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */ u(
|
|
873
873
|
rr,
|
|
874
874
|
{
|
|
875
875
|
...ee,
|
|
@@ -917,7 +917,7 @@ function pr({
|
|
|
917
917
|
}
|
|
918
918
|
);
|
|
919
919
|
case "composed":
|
|
920
|
-
return /* @__PURE__ */
|
|
920
|
+
return /* @__PURE__ */ u(
|
|
921
921
|
er,
|
|
922
922
|
{
|
|
923
923
|
...ee,
|
|
@@ -934,7 +934,7 @@ function pr({
|
|
|
934
934
|
...P,
|
|
935
935
|
hide: t === "data-only",
|
|
936
936
|
width: t === "data-only" ? 0 : P.width,
|
|
937
|
-
...t !== "full" &&
|
|
937
|
+
...t !== "full" && q ? { domain: q } : {}
|
|
938
938
|
}
|
|
939
939
|
),
|
|
940
940
|
t !== "yaxis-only" && ue && /* @__PURE__ */ r(
|
|
@@ -1060,16 +1060,16 @@ function pr({
|
|
|
1060
1060
|
default:
|
|
1061
1061
|
return /* @__PURE__ */ r("div", { children: "Unsupported chart type" });
|
|
1062
1062
|
}
|
|
1063
|
-
}, Qe = () => _e ? /* @__PURE__ */ r("div", { className: "sr-only", children: /* @__PURE__ */
|
|
1064
|
-
/* @__PURE__ */
|
|
1063
|
+
}, Qe = () => _e ? /* @__PURE__ */ r("div", { className: "sr-only", children: /* @__PURE__ */ u("table", { role: "table", "aria-label": D ? `Data for ${D}` : "Chart data", children: [
|
|
1064
|
+
/* @__PURE__ */ u("caption", { className: "sr-only", children: [
|
|
1065
1065
|
D && `${D}. `,
|
|
1066
1066
|
xe || `${n} chart showing ${h.length} data series across ${f.length} categories.`
|
|
1067
1067
|
] }),
|
|
1068
|
-
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */
|
|
1068
|
+
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */ u("tr", { children: [
|
|
1069
1069
|
/* @__PURE__ */ r("th", { scope: "col", children: "Category" }),
|
|
1070
1070
|
h.map((t) => /* @__PURE__ */ r("th", { scope: "col", children: a[t]?.label || t }, t))
|
|
1071
1071
|
] }) }),
|
|
1072
|
-
/* @__PURE__ */ r("tbody", { children: f.map((t, e) => /* @__PURE__ */
|
|
1072
|
+
/* @__PURE__ */ r("tbody", { children: f.map((t, e) => /* @__PURE__ */ u("tr", { children: [
|
|
1073
1073
|
/* @__PURE__ */ r("th", { scope: "row", children: t.name || `Item ${e + 1}` }),
|
|
1074
1074
|
h.map((s) => /* @__PURE__ */ r("td", { children: F ? F(t[s], e) : t[s] }, s))
|
|
1075
1075
|
] }, e)) })
|
|
@@ -1079,14 +1079,14 @@ function pr({
|
|
|
1079
1079
|
if (!t) return;
|
|
1080
1080
|
const e = setTimeout(() => {
|
|
1081
1081
|
t.querySelectorAll(".recharts-cartesian-axis-tick").forEach((l) => {
|
|
1082
|
-
const x = l.querySelector("text"),
|
|
1083
|
-
x?.textContent?.trim() === "0" &&
|
|
1082
|
+
const x = l.querySelector("text"), d = l.querySelector(".recharts-cartesian-axis-tick-line");
|
|
1083
|
+
x?.textContent?.trim() === "0" && d && d.setAttribute("stroke-width", "2");
|
|
1084
1084
|
});
|
|
1085
1085
|
}, 100);
|
|
1086
1086
|
return () => clearTimeout(e);
|
|
1087
1087
|
}, [f, n]), S.useEffect(() => {
|
|
1088
|
-
if (!E || !
|
|
1089
|
-
const t = y.findIndex((s) => s.name ===
|
|
1088
|
+
if (!E || !K || !b.current || !H) return;
|
|
1089
|
+
const t = y.findIndex((s) => s.name === K.xValue);
|
|
1090
1090
|
if (t < 0) return;
|
|
1091
1091
|
const e = setTimeout(() => {
|
|
1092
1092
|
if (!b.current) return;
|
|
@@ -1094,12 +1094,12 @@ function pr({
|
|
|
1094
1094
|
b.current.scrollLeft = Math.max(0, l - s / 2);
|
|
1095
1095
|
}, 50);
|
|
1096
1096
|
return () => clearTimeout(e);
|
|
1097
|
-
}, [E,
|
|
1097
|
+
}, [E, K, H, y]), /* @__PURE__ */ u(
|
|
1098
1098
|
"div",
|
|
1099
1099
|
{
|
|
1100
1100
|
ref: le,
|
|
1101
1101
|
className: or("w-full", p),
|
|
1102
|
-
style: { minWidth: w },
|
|
1102
|
+
style: { minWidth: V ? 0 : w, ...typeof c == "string" ? { height: c } : {} },
|
|
1103
1103
|
role: "img",
|
|
1104
1104
|
"aria-label": D || `${n} chart`,
|
|
1105
1105
|
"aria-describedby": xe ? `${le.current?.id || "chart"}-desc` : void 0,
|
|
@@ -1108,11 +1108,11 @@ function pr({
|
|
|
1108
1108
|
D && /* @__PURE__ */ r("h3", { className: "sr-only", id: `${le.current?.id || "chart"}-title`, children: D }),
|
|
1109
1109
|
xe && /* @__PURE__ */ r("p", { className: "sr-only", id: `${le.current?.id || "chart"}-desc`, children: xe }),
|
|
1110
1110
|
(() => {
|
|
1111
|
-
const t = A ?
|
|
1111
|
+
const t = typeof c == "string" ? c : A ? c - A : c;
|
|
1112
1112
|
if (E && n !== "horizontal-bar" && n !== "scatter") {
|
|
1113
1113
|
const s = Pe + (me().left ?? 0);
|
|
1114
|
-
return /* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1114
|
+
return /* @__PURE__ */ u("div", { style: { height: m && A ? c : t }, children: [
|
|
1115
|
+
/* @__PURE__ */ u("div", { className: "flex w-full", style: { height: t }, children: [
|
|
1116
1116
|
/* @__PURE__ */ r("div", { style: { width: s, flexShrink: 0, overflow: "hidden" }, children: /* @__PURE__ */ r(Ne, { width: s, height: t, children: ye("yaxis-only") || /* @__PURE__ */ r("div", { children: "Chart error" }) }) }),
|
|
1117
1117
|
/* @__PURE__ */ r(
|
|
1118
1118
|
"div",
|
|
@@ -1122,8 +1122,8 @@ function pr({
|
|
|
1122
1122
|
style: { cursor: "grab" },
|
|
1123
1123
|
onMouseDown: Ue,
|
|
1124
1124
|
onMouseMove: Ze,
|
|
1125
|
-
onMouseUp:
|
|
1126
|
-
onMouseLeave:
|
|
1125
|
+
onMouseUp: Ke,
|
|
1126
|
+
onMouseLeave: Ke,
|
|
1127
1127
|
children: /* @__PURE__ */ r("div", { style: { width: H, height: t }, children: /* @__PURE__ */ r(Ne, { width: H, height: t, children: ye("data-only") || /* @__PURE__ */ r("div", { children: "Chart error" }) }) })
|
|
1128
1128
|
}
|
|
1129
1129
|
)
|
|
@@ -1131,7 +1131,7 @@ function pr({
|
|
|
1131
1131
|
m && Je()
|
|
1132
1132
|
] });
|
|
1133
1133
|
}
|
|
1134
|
-
const e =
|
|
1134
|
+
const e = V ? /* @__PURE__ */ r(
|
|
1135
1135
|
Ne,
|
|
1136
1136
|
{
|
|
1137
1137
|
width: g || "100%",
|
|
@@ -1148,11 +1148,11 @@ function pr({
|
|
|
1148
1148
|
}
|
|
1149
1149
|
const xr = (n, f = "bar") => {
|
|
1150
1150
|
const a = O[f];
|
|
1151
|
-
return Array.from({ length: n }, (p,
|
|
1152
|
-
}, mr = (n, f, a) => Array.isArray(n) ? n.reduce((
|
|
1151
|
+
return Array.from({ length: n }, (p, c) => a[c % a.length]);
|
|
1152
|
+
}, mr = (n, f, a) => Array.isArray(n) ? n.reduce((c, g, w) => (c[g] = {
|
|
1153
1153
|
label: f?.[w] || g,
|
|
1154
1154
|
color: a?.[w]
|
|
1155
|
-
},
|
|
1155
|
+
}, c), {}) : n;
|
|
1156
1156
|
export {
|
|
1157
1157
|
pr as Chart,
|
|
1158
1158
|
O as chartColorSchemes,
|
|
@@ -61,7 +61,7 @@ export interface ChartProps {
|
|
|
61
61
|
data: ChartDataPoint[];
|
|
62
62
|
config: ChartConfig;
|
|
63
63
|
className?: string;
|
|
64
|
-
height?: number;
|
|
64
|
+
height?: number | string;
|
|
65
65
|
width?: number;
|
|
66
66
|
minWidth?: number;
|
|
67
67
|
onDataPointClick?: (data: ChartDataPoint, index: number) => void;
|
|
@@ -61,7 +61,7 @@ export interface ChartProps {
|
|
|
61
61
|
data: ChartDataPoint[];
|
|
62
62
|
config: ChartConfig;
|
|
63
63
|
className?: string;
|
|
64
|
-
height?: number;
|
|
64
|
+
height?: number | string;
|
|
65
65
|
width?: number;
|
|
66
66
|
minWidth?: number;
|
|
67
67
|
onDataPointClick?: (data: ChartDataPoint, index: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rafal.lemieszewski/tide-ui",
|
|
3
|
-
"version": "0.88.
|
|
3
|
+
"version": "0.88.1",
|
|
4
4
|
"description": "A comprehensive React component library built with Tailwind CSS and Radix UI primitives",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/lib/index.cjs",
|
|
@@ -300,6 +300,7 @@
|
|
|
300
300
|
"playwright": "^1.54.2",
|
|
301
301
|
"publint": "^0.3.17",
|
|
302
302
|
"react-day-picker": "^9.13.2",
|
|
303
|
+
"react-dom": "^19.2.4",
|
|
303
304
|
"react-hook-form": "^7.71.2",
|
|
304
305
|
"react-resizable-panels": "^3.0.6",
|
|
305
306
|
"recharts": "^3.7.0",
|