@cleen/ui 0.1.197 → 0.1.199

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.
@@ -135,13 +135,19 @@ type FootballFieldHighlightRange = {
135
135
  color?: string;
136
136
  opacity?: number;
137
137
  };
138
- interface FootballFieldChartProps extends Omit<ChartProps, 'type' | 'series' | 'className' | 'style'> {
138
+ interface FootballFieldChartProps extends Omit<ChartProps, 'type' | 'series' | 'className' | 'style' | 'renderTooltip'> {
139
139
  /** Valuation ranges, one row per item, rendered top to bottom */
140
140
  series: FootballFieldSeriesItem[];
141
141
  /** Shaded full-height background band marking an overlap zone */
142
142
  highlightRange?: FootballFieldHighlightRange[];
143
143
  /** Function to format x-axis labels, e.g. "m" for millions */
144
144
  formatXValue?: (value: number) => string;
145
+ /**
146
+ * Custom tooltip for a hovered bar. Receives the hovered series item as passed in
147
+ * (category/from/to/striped/color); return a React element and the chart serializes it.
148
+ * Falls back to the built-in category + formatted-range tooltip.
149
+ */
150
+ renderTooltip?: (item: FootballFieldSeriesItem) => ReactNode;
145
151
  classNames?: {
146
152
  container?: string;
147
153
  };
@@ -1,7 +1,4 @@
1
- import{cn as We}from"@cleen/ui-core";import{forwardRef as Ue}from"react";import{renderToStaticMarkup as Xe}from"react-dom/server";import Ke from"react-apexcharts";var q={chart:{toolbar:{show:!0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0}},animations:{enabled:!0}},dataLabels:{enabled:!1},stroke:{curve:"smooth",width:2},xaxis:{labels:{style:{fontSize:"12px"}}},yaxis:{labels:{style:{fontSize:"12px"}}},legend:{position:"top",horizontalAlign:"left"},tooltip:{enabled:!0,theme:"light"}};import{jsx as ae}from"react/jsx-runtime";var Ve="[&_.apexcharts-tooltip]:!cleen-bg-transparent [&_.apexcharts-tooltip]:!cleen-border-0 [&_.apexcharts-tooltip]:!cleen-shadow-none [&_.apexcharts-tooltip]:!cleen-p-0 [&_.apexcharts-tooltip]:!cleen-overflow-visible [&_.apexcharts-tooltip]:!cleen-whitespace-normal",ie=Ue(function({type:t="line",series:r,options:n={},width:c="100%",height:C=350,className:g,style:x,renderTooltip:p},v){let T=p?{...n.tooltip,custom:(l=>{let b=p({seriesIndex:l.seriesIndex,dataPointIndex:l.dataPointIndex,series:l.series,w:l.w});return b?Xe(b):""})}:n.tooltip,o={...q,...n,chart:{...q.chart,...n.chart,type:t},...T?{tooltip:T}:{}},S=!!o.tooltip?.custom;return ae("div",{className:We("cleen",S&&Ve,g),style:x,children:ae(Ke,{options:o,series:r,type:t,width:c,height:C,ref:v})})}),P=ie;import{applyDefaults as je}from"@cleen/ui-core";import{forwardRef as Ye}from"react";var le={chart:{type:"bar",zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1},fontFamily:"inherit",background:"transparent",parentHeightOffset:0},dataLabels:{enabled:!1},legend:{show:!1}};import{jsx as Ze}from"react/jsx-runtime";var qe=Ye(function({options:t,...r},n){return Ze(P,{type:"bar",ref:n,options:je(le,t??{}),...r})});import{applyDefaults as z}from"@cleen/ui-core";import{forwardRef as Je,useMemo as M}from"react";import{ColorHelpers as B}from"@cleen/ui-core";var se={marker:{size:2,fillColor:"rgba(var(--cleen-gray-500))",strokeColor:"rgba(var(--cleen-gray-500))",offsetY:-16,shape:"triangle"},label:{borderWidth:0,offsetY:-20,style:{color:"rgba(var(--cleen-gray-500))",background:"transparent",fontSize:"11px"}}},pe={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},ce={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},de={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},ue={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[B.getComputedColor("var(--cleen-error)"),B.getComputedColor("var(--cleen-primary)"),B.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[B.getComputedColor("var(--cleen-error)")||"",B.getComputedColor("var(--cleen-primary)")||"",B.getComputedColor("var(--cleen-success)")||""],inverseColors:!1,opacityFrom:.95,opacityTo:.6}},yaxis:{show:!1},tooltip:{enabled:!0,x:{formatter:function(e){return`Score: ${typeof e=="string"?Number(e):e}`}},y:{formatter:function(e){return`${Number(e).toFixed(4)}`}}},grid:{show:!1},legend:{show:!1}};var me=(e,t)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:e-3*t,rightSigma:e+2*t,right2Sigma:e+2*t,right:e+3*t}),fe=(e,t,r,n)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:n}),he=(e,t)=>{let r={};switch(e.type){case"range":r={x:t[e.x],x2:t[e.x2]};break;case"offset":r={x:e.x-e.offset,x2:e.x+e.offset};break;case"region":e.x>=t.left&&e.x<t.left2Sigma?r={x:t.left,x2:t.left2Sigma}:e.x>=t.left2Sigma&&e.x<t.leftSigma?r={x:t.left2Sigma,x2:t.leftSigma}:e.x>=t.leftSigma&&e.x<t.middle?r={x:t.leftSigma,x2:t.middle}:e.x>=t.middle&&e.x<t.rightSigma?r={x:t.middle,x2:t.rightSigma}:e.x>=t.rightSigma&&e.x<t.right2Sigma?r={x:t.rightSigma,x2:t.right2Sigma}:e.x>=t.right2Sigma&&e.x<t.right&&(r={x:t.right2Sigma,x2:t.right});break;default:r={x:e.x,x2:e.x2};break}return r};import{jsx as et}from"react/jsx-runtime";var Qe=Je(function({serie:t,labels:r,sigma:n,pointAnnotations:c,rangeAnnotations:C,highlightAnnotations:g,options:x,height:p=360,...v},T){let o=M(()=>t.sort((i,d)=>i.x-d.x),[t]),S=M(()=>{let i=new Map;return t.forEach(d=>i.set(d.x,d.y)),i},[t]),l=o[Math.floor(o.length/2)],b=M(()=>{let{below:i,middle:d,above:y}=t.reduce((m,a)=>(a.x<l.x-2*n?m.below.push(a):a.x>=l.x+2*n?(a.x===l.x+2*n&&m.middle.push(a),m.above.push(a)):(a.x===l.x-2*n&&m.below.push(a),m.middle.push(a)),m),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:i},{name:r?.middle||"Middle grounds",data:d},{name:r?.above||"Above threshold",data:y}]},[n,t,r,l]),O=M(()=>{if(!c)return[];let i=me(l.x,n);return Object.entries(c).map(([d,y])=>{let m=i[d];return{x:m,y:S.get(m)||0,...z(se,y)}})},[c,n,S]),R=M(()=>{if(!C)return[];let i=fe(l.x,n,o[0].x,o[o.length-1].x);return C.map(d=>{let y=he(d,i);return{...z(pe,d),...y}})},[C,n,o]),{highlightPointAnnotations:N,highlightLineAnnotations:s}=M(()=>{if(!g)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let i=[],d=[],y=({x:a,line:h})=>{d.push(z(ce,{x:a,...h}))},m=({x:a,y:h,point:f})=>{i.push(z(de,{x:a,y:h,...f}))};return g?.forEach(a=>{switch(a.show){case"line":y(a);break;case"point":m(a);break;case"both":y(a),m(a);break;default:break}}),{highlightPointAnnotations:i,highlightLineAnnotations:d}},[g]);return et(P,{series:b,options:{...z(ue,x),annotations:{...x?.annotations,points:[...O,...N,...x?.annotations?.points||[]],xaxis:[...R,...s,...x?.annotations?.xaxis||[]]}},height:p,ref:T,type:"area",...v})});import{applyDefaults as Ce}from"@cleen/ui-core";import{forwardRef as rt,useMemo as Se}from"react";var ge="rgba(var(--cleen-primary-300))",ye="rgba(var(--cleen-primary-500))";var xe={style:"slantedLines",width:12,height:12,strokeWidth:2},be={chart:{type:"rangeBar",zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1},fontFamily:"inherit",background:"transparent",parentHeightOffset:0},plotOptions:{bar:{horizontal:!0,barHeight:"50%",rangeBarGroupRows:!0,borderRadius:2}},dataLabels:{enabled:!1},legend:{show:!1},grid:{borderColor:"rgba(var(--cleen-gray-200))",xaxis:{lines:{show:!0}},yaxis:{lines:{show:!0}}},xaxis:{type:"numeric",tickAmount:8,axisBorder:{show:!1},axisTicks:{show:!1},labels:{style:{colors:"rgba(var(--cleen-gray-500))",fontSize:"12px"}}},yaxis:{labels:{style:{colors:"rgba(var(--cleen-gray-700))",fontSize:"12px"}}},tooltip:{enabled:!0,theme:"light"}};import{jsx as nt}from"react/jsx-runtime";var ot=rt(function({series:t,highlightRange:r,classNames:n,styles:c,options:C,height:g=320,formatXValue:x,...p},v){let T=Se(()=>t.map(({category:S,from:l,to:b})=>({name:S,data:[{x:S,y:[l,b]}]})),[t]),o=Se(()=>{let S=t.map(b=>b.color??ge),l=t.map(b=>b.striped?"pattern":"solid");return{colors:S,fill:{type:l,opacity:1,pattern:xe},xaxis:{labels:{formatter:x}},tooltip:{custom:({seriesIndex:b,dataPointIndex:O,w:R})=>{let N=R.globals.labels[O],s=R.config.series?.[b],[i,d]=s?.data?.[0]?.y??[];return`<div class="cleen-p-2 cleen-bg-white cleen-border cleen-border-gray-200 cleen-rounded cleen-shadow">
2
- <strong class="cleen-text-gray-900">${N}</strong><br/>
3
- <p class="cleen-text-gray-900">${x?.(i)??i} - ${x?.(d)??d}</p>
4
- </div>`}},...r?{annotations:{xaxis:r.map(({from:b,to:O,color:R,opacity:N})=>({x:b,x2:O,fillColor:R??ye,opacity:N??.12,borderColor:"transparent"}))}}:{}}},[t,r,x]);return nt(P,{type:"rangeBar",ref:v,series:T,options:Ce(Ce(be,o),C??{}),height:g,className:n?.container,style:c?.container,...p})});import{applyDefaults as at}from"@cleen/ui-core";import{forwardRef as it}from"react";var Ae={chart:{type:"radar",zoom:{enabled:!1},toolbar:{show:!1}},stroke:{width:2},fill:{opacity:.25},markers:{size:4,colors:"transparent",strokeColors:"transparent"},tooltip:{marker:{show:!1}},legend:{show:!1}};import{jsx as st}from"react/jsx-runtime";var lt=it(function({options:t,...r},n){return st(P,{type:"radar",ref:n,options:at(Ae,t),...r})});import{applyDefaults as pt,cn as G}from"@cleen/ui-core";import{useId as ct,useMemo as U,useRef as dt,useState as ut}from"react";import{Layer as Ie,Tooltip as mt,Rectangle as ve,ResponsiveContainer as ft,Sankey as ht}from"recharts";var I={width:"100%",height:420,nodePadding:24,enableToolbar:!1,enableTooltip:!0,highlightOnHover:!0,dimOnHover:!0,dimOpacity:.2,edgeOpacity:.4,edgeGradientFill:!0,nodeWidth:20,nodeBorderWidth:0,nodeBorderColor:null,align:"justify",fontColor:"rgba(var(--cleen-neutral-800, 38, 38, 38))",tooltipBGColor:"rgba(var(--cleen-white))",tooltipBorderColor:"rgba(var(--cleen-gray-200))"};import{Fragment as It,jsx as k,jsxs as D}from"react/jsx-runtime";var gt=typeof I.height=="number"?I.height:420,ke=40,Te=60,Oe=8,yt=8,xt="cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)] cleen-flex cleen-flex-col cleen-gap-2",Z="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-whitespace-pre-line cleen-break-words",bt="cleen-font-semibold",Ct="cleen-font-medium cleen-text-[13px] cleen-mt-1 cleen-opacity-[0.72]",St="cleen-font-medium cleen-text-[13px] cleen-mt-[6px]";function At(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t=e.trim();if(!t.endsWith("%")&&t!=="auto"){let r=Number.parseFloat(t);if(Number.isFinite(r))return r}}return gt}function Re(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function vt(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var Ne=["rgba(var(--cleen-primary, 59, 130, 246))","rgba(var(--cleen-success, 34, 197, 94))","rgba(var(--cleen-warning, 245, 158, 11))","rgba(var(--cleen-error, 239, 68, 68))","rgba(var(--cleen-purple, 147, 51, 234))","rgba(var(--cleen-cyan, 6, 182, 212))","rgba(var(--cleen-orange, 249, 115, 22))","rgba(var(--cleen-pink, 236, 72, 153))","rgba(var(--cleen-teal, 20, 184, 166))","rgba(var(--cleen-indigo, 99, 102, 241))","rgba(var(--cleen-rose, 244, 63, 94))","rgba(var(--cleen-amber, 245, 158, 11))"];function Ee(e){return e!=null}function kt(e,t){return[e.source,e.target,e.type??"",e.label??"",e.value,t].join("-").replace(/\s+/g,"_")}function X(e,t){return typeof e=="object"&&e!==null?e.id:t}function we(e,t){return typeof e=="object"&&e!==null?e.title:t}function J(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function Q(e){return typeof e=="object"&&e!==null&&"payload"in e}function _e(e){if(Q(e))return _e(e.payload);if(J(e)||vt(e))return e}function ee(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function Pe(e){let t=ee(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function He(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function $(e){let t=e.match(/^rgba\((var\(.+\)),\s*([0-9]*\.?[0-9]+)\)$/i);if(t)return{color:`rgb(${t[1]})`,opacity:Number.parseFloat(t[2])};let r=e.match(/^rgba\((var\(.+\))\)$/i);if(r)return{color:`rgb(${r[1]})`,opacity:1};let n=e.match(/^rgba\(\s*(\d+\s*,\s*\d+\s*,\s*\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);return n?{color:`rgb(${n[1]})`,opacity:Number.parseFloat(n[2])}:{color:e,opacity:1}}function te(e,t){return $(t??Ne[e%Ne.length])}function Le(e){return e.length*yt}function Tt(e){let t=new Set,r=new Set([e.id]);for(let n of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(n.edgeKey),r.add(X(n.source,n.sourceId)),r.add(X(n.target,n.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function Ot(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([X(e.source,e.sourceId),X(e.target,e.targetId)])}}function Rt(e,t,r,n,c){return!e||e.activeNodeIds.has(t)?1:n?c??I.dimOpacity??.2:r?.55:1}function Nt(e,t,r,n,c,C){return e?e.activeLinkKeys.has(t)?n?Math.max(r,.9):r:c?C??I.dimOpacity??.2:n?Math.min(r,.3):r:r}var wt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:n,y:c,width:C,height:g,highlightOnHover:x,hoverState:p,index:v,outgoingEdgesById:T,payload:o,stroke:S,strokeWidth:l})=>{if(o===void 0||n===void 0||c===void 0||C===void 0||g===void 0||v===void 0)return null;let b=T?.get(o.id)??[],O=b.length>0,R=te(v,o.color),N=$(r),s=Rt(p,o.id,x,e,t),i=new Set(b.map(h=>h.color).filter(Ee)),d=Array.from(i)[0],y=O&&b.length>1&&i.size>1&&i.size===b.length,m=y?b:[],a=m.reduce((h,f)=>h+(f.value??0),0);return D(Ie,{children:[y&&a>0?m.map((h,f)=>{let u=m.slice(0,f).reduce((H,F)=>H+(F.value??0),0),A=c+u/a*g,w=(h.value??0)/a*g,L=$(h.color??R.color),E=f===0,_=f===m.length-1;return k(ve,{x:n,y:A,width:C,height:w,fill:L.color,fillOpacity:L.opacity*s,stroke:S,strokeWidth:l,radius:[E?2:0,E?2:0,_?2:0,_?2:0]},`${h.source}-${h.target}-${f}`)}):k(ve,{x:n,y:c,width:C,height:g,fill:O&&i.size===1?$(d??R.color).color:R.color,fillOpacity:(O&&i.size===1?$(d??R.color).opacity:R.opacity)*s,stroke:S,strokeWidth:l,radius:[2,2,2,2]}),k("text",{textAnchor:O?"end":"start",x:O?n-8:n+C+8,y:c+g/2,dy:"0.35em",fontSize:"14",fill:N.color,fillOpacity:N.opacity*s,fontWeight:600,children:o.name})]},`CustomNode${v}`)},Pt=({sourceX:e,targetX:t,sourceY:r,targetY:n,sourceControlX:c,targetControlX:C,linkWidth:g,index:x,payload:p,opacity:v,chartId:T,dimOnHover:o,dimOpacity:S,edgeGradientFill:l,highlightOnHover:b,hoverState:O})=>{if(p===void 0||e===void 0||t===void 0||r===void 0||n===void 0||c===void 0||C===void 0||g===void 0)return null;let R=v??I.edgeOpacity??.4,N=Nt(O,p.edgeKey,R,b,o,S),s=p.color?$(p.color):null,i=s??te(typeof p.source=="object"?p.source.index:0,typeof p.source=="object"?p.source.color:void 0),d=s??te(typeof p.target=="object"?p.target.index:1,typeof p.target=="object"?p.target.color:void 0),y=He(`linkGradient-${T}-${p.edgeKey}-${x??p.value}`),m=l!==!1&&s===null;return D(Ie,{children:[m?k("defs",{children:D("linearGradient",{id:y,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[k("stop",{offset:"0%",stopColor:i.color,stopOpacity:i.opacity*N}),k("stop",{offset:"100%",stopColor:d.color,stopOpacity:d.opacity*N})]})}):null,k("path",{d:`
1
+ import{cn as Xe}from"@cleen/ui-core";import{forwardRef as Ke}from"react";import{renderToStaticMarkup as Ve}from"react-dom/server";import je from"react-apexcharts";var q={chart:{toolbar:{show:!0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0}},animations:{enabled:!0}},dataLabels:{enabled:!1},stroke:{curve:"smooth",width:2},xaxis:{labels:{style:{fontSize:"12px"}}},yaxis:{labels:{style:{fontSize:"12px"}}},legend:{position:"top",horizontalAlign:"left"},tooltip:{enabled:!0,theme:"light"}};import{jsx as le}from"react/jsx-runtime";var Ye="[&_.apexcharts-tooltip]:!cleen-bg-transparent [&_.apexcharts-tooltip]:!cleen-border-0 [&_.apexcharts-tooltip]:!cleen-shadow-none [&_.apexcharts-tooltip]:!cleen-p-0 [&_.apexcharts-tooltip]:!cleen-overflow-visible [&_.apexcharts-tooltip]:!cleen-whitespace-normal",se=Ke(function({type:t="line",series:r,options:n={},width:c="100%",height:b=350,className:g,style:x,renderTooltip:p},k){let N=p?{...n.tooltip,custom:(s=>{let S=p({seriesIndex:s.seriesIndex,dataPointIndex:s.dataPointIndex,series:s.series,w:s.w});return S?Ve(S):""})}:n.tooltip,o={...q,...n,chart:{...q.chart,...n.chart,type:t},...N?{tooltip:N}:{}},T=!!o.tooltip?.custom;return le("div",{className:Xe("cleen",T&&Ye,g),style:x,children:le(je,{options:o,series:r,type:t,width:c,height:b,ref:k})})}),P=se;import{applyDefaults as qe}from"@cleen/ui-core";import{forwardRef as Ze}from"react";var pe={chart:{type:"bar",zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1},fontFamily:"inherit",background:"transparent",parentHeightOffset:0},dataLabels:{enabled:!1},legend:{show:!1}};import{jsx as Qe}from"react/jsx-runtime";var Je=Ze(function({options:t,...r},n){return Qe(P,{type:"bar",ref:n,options:qe(pe,t??{}),...r})});import{applyDefaults as z}from"@cleen/ui-core";import{forwardRef as et,useMemo as M}from"react";import{ColorHelpers as B}from"@cleen/ui-core";var ce={marker:{size:2,fillColor:"rgba(var(--cleen-gray-500))",strokeColor:"rgba(var(--cleen-gray-500))",offsetY:-16,shape:"triangle"},label:{borderWidth:0,offsetY:-20,style:{color:"rgba(var(--cleen-gray-500))",background:"transparent",fontSize:"11px"}}},de={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},ue={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},me={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},fe={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[B.getComputedColor("var(--cleen-error)"),B.getComputedColor("var(--cleen-primary)"),B.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[B.getComputedColor("var(--cleen-error)")||"",B.getComputedColor("var(--cleen-primary)")||"",B.getComputedColor("var(--cleen-success)")||""],inverseColors:!1,opacityFrom:.95,opacityTo:.6}},yaxis:{show:!1},tooltip:{enabled:!0,x:{formatter:function(e){return`Score: ${typeof e=="string"?Number(e):e}`}},y:{formatter:function(e){return`${Number(e).toFixed(4)}`}}},grid:{show:!1},legend:{show:!1}};var he=(e,t)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:e-3*t,rightSigma:e+2*t,right2Sigma:e+2*t,right:e+3*t}),ge=(e,t,r,n)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:n}),ye=(e,t)=>{let r={};switch(e.type){case"range":r={x:t[e.x],x2:t[e.x2]};break;case"offset":r={x:e.x-e.offset,x2:e.x+e.offset};break;case"region":e.x>=t.left&&e.x<t.left2Sigma?r={x:t.left,x2:t.left2Sigma}:e.x>=t.left2Sigma&&e.x<t.leftSigma?r={x:t.left2Sigma,x2:t.leftSigma}:e.x>=t.leftSigma&&e.x<t.middle?r={x:t.leftSigma,x2:t.middle}:e.x>=t.middle&&e.x<t.rightSigma?r={x:t.middle,x2:t.rightSigma}:e.x>=t.rightSigma&&e.x<t.right2Sigma?r={x:t.rightSigma,x2:t.right2Sigma}:e.x>=t.right2Sigma&&e.x<t.right&&(r={x:t.right2Sigma,x2:t.right});break;default:r={x:e.x,x2:e.x2};break}return r};import{jsx as rt}from"react/jsx-runtime";var tt=et(function({serie:t,labels:r,sigma:n,pointAnnotations:c,rangeAnnotations:b,highlightAnnotations:g,options:x,height:p=360,...k},N){let o=M(()=>t.sort((l,f)=>l.x-f.x),[t]),T=M(()=>{let l=new Map;return t.forEach(f=>l.set(f.x,f.y)),l},[t]),s=o[Math.floor(o.length/2)],S=M(()=>{let{below:l,middle:f,above:y}=t.reduce((u,a)=>(a.x<s.x-2*n?u.below.push(a):a.x>=s.x+2*n?(a.x===s.x+2*n&&u.middle.push(a),u.above.push(a)):(a.x===s.x-2*n&&u.below.push(a),u.middle.push(a)),u),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:l},{name:r?.middle||"Middle grounds",data:f},{name:r?.above||"Above threshold",data:y}]},[n,t,r,s]),v=M(()=>{if(!c)return[];let l=he(s.x,n);return Object.entries(c).map(([f,y])=>{let u=l[f];return{x:u,y:T.get(u)||0,...z(ce,y)}})},[c,n,T]),C=M(()=>{if(!b)return[];let l=ge(s.x,n,o[0].x,o[o.length-1].x);return b.map(f=>{let y=ye(f,l);return{...z(de,f),...y}})},[b,n,o]),{highlightPointAnnotations:R,highlightLineAnnotations:i}=M(()=>{if(!g)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let l=[],f=[],y=({x:a,line:h})=>{f.push(z(ue,{x:a,...h}))},u=({x:a,y:h,point:m})=>{l.push(z(me,{x:a,y:h,...m}))};return g?.forEach(a=>{switch(a.show){case"line":y(a);break;case"point":u(a);break;case"both":y(a),u(a);break;default:break}}),{highlightPointAnnotations:l,highlightLineAnnotations:f}},[g]);return rt(P,{series:S,options:{...z(fe,x),annotations:{...x?.annotations,points:[...v,...R,...x?.annotations?.points||[]],xaxis:[...C,...i,...x?.annotations?.xaxis||[]]}},height:p,ref:N,type:"area",...k})});import{applyDefaults as Ae}from"@cleen/ui-core";import{forwardRef as nt,useMemo as Z}from"react";var xe="rgba(var(--cleen-primary-300))",be="rgba(var(--cleen-primary-500))";var Ce={style:"slantedLines",width:12,height:12,strokeWidth:2},Se={chart:{type:"rangeBar",zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1},fontFamily:"inherit",background:"transparent",parentHeightOffset:0},plotOptions:{bar:{horizontal:!0,barHeight:"50%",rangeBarGroupRows:!0,borderRadius:2}},dataLabels:{enabled:!1},legend:{show:!1},grid:{borderColor:"rgba(var(--cleen-gray-200))",xaxis:{lines:{show:!0}},yaxis:{lines:{show:!0}}},xaxis:{type:"numeric",tickAmount:8,axisBorder:{show:!1},axisTicks:{show:!1},labels:{style:{colors:"rgba(var(--cleen-gray-500))",fontSize:"12px"}}},yaxis:{labels:{style:{colors:"rgba(var(--cleen-gray-700))",fontSize:"12px"}}},tooltip:{enabled:!0,theme:"light"}};import{jsx as J,jsxs as ve}from"react/jsx-runtime";var at=nt(function({series:t,highlightRange:r,classNames:n,styles:c,options:b,height:g=320,formatXValue:x,renderTooltip:p,...k},N){let o=Z(()=>t.map(({category:S,from:v,to:C})=>({name:S,data:[{x:S,y:[v,C]}]})),[t]),T=Z(()=>{let S=p??(v=>{let C=R=>R==null?"":x?.(R)??String(R);return ve("div",{className:"cleen-p-2 cleen-bg-white cleen-border cleen-border-gray-200 cleen-rounded cleen-shadow",children:[J("strong",{className:"cleen-text-gray-900",children:v.category}),J("br",{}),ve("p",{className:"cleen-text-gray-900",children:[C(v.from)," - ",C(v.to)]})]})});return({seriesIndex:v})=>{let C=t[v];return C?S(C):null}},[t,p,x]),s=Z(()=>{let S=t.map(C=>C.color??xe),v=t.map(C=>C.striped?"pattern":"solid");return{colors:S,fill:{type:v,opacity:1,pattern:Ce},xaxis:{labels:{formatter:x}},...r?{annotations:{xaxis:r.map(({from:C,to:R,color:i,opacity:l})=>({x:C,x2:R,fillColor:i??be,opacity:l??.12,borderColor:"transparent"}))}}:{}}},[t,r,x]);return J(P,{type:"rangeBar",ref:N,series:o,options:Ae(Ae(Se,s),b??{}),height:g,className:n?.container,style:c?.container,renderTooltip:T,...k})});import{applyDefaults as it}from"@cleen/ui-core";import{forwardRef as lt}from"react";var ke={chart:{type:"radar",zoom:{enabled:!1},toolbar:{show:!1}},stroke:{width:2},fill:{opacity:.25},markers:{size:4,colors:"transparent",strokeColors:"transparent"},tooltip:{marker:{show:!1}},legend:{show:!1}};import{jsx as pt}from"react/jsx-runtime";var st=lt(function({options:t,...r},n){return pt(P,{type:"radar",ref:n,options:it(ke,t),...r})});import{applyDefaults as ct,cn as G}from"@cleen/ui-core";import{useId as dt,useMemo as U,useRef as ut,useState as mt}from"react";import{Layer as _e,Tooltip as ft,Rectangle as Te,ResponsiveContainer as ht,Sankey as gt}from"recharts";var I={width:"100%",height:420,nodePadding:24,enableToolbar:!1,enableTooltip:!0,highlightOnHover:!0,dimOnHover:!0,dimOpacity:.2,edgeOpacity:.4,edgeGradientFill:!0,nodeWidth:20,nodeBorderWidth:0,nodeBorderColor:null,align:"justify",fontColor:"rgba(var(--cleen-neutral-800, 38, 38, 38))",tooltipBGColor:"rgba(var(--cleen-white))",tooltipBorderColor:"rgba(var(--cleen-gray-200))"};import{Fragment as Et,jsx as O,jsxs as $}from"react/jsx-runtime";var yt=typeof I.height=="number"?I.height:420,Oe=40,Ne=60,Re=8,xt=8,bt="cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)] cleen-flex cleen-flex-col cleen-gap-2",Q="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-whitespace-pre-line cleen-break-words",Ct="cleen-font-semibold",St="cleen-font-medium cleen-text-[13px] cleen-mt-1 cleen-opacity-[0.72]",At="cleen-font-medium cleen-text-[13px] cleen-mt-[6px]";function vt(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t=e.trim();if(!t.endsWith("%")&&t!=="auto"){let r=Number.parseFloat(t);if(Number.isFinite(r))return r}}return yt}function we(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function kt(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var Pe=["rgba(var(--cleen-primary, 59, 130, 246))","rgba(var(--cleen-success, 34, 197, 94))","rgba(var(--cleen-warning, 245, 158, 11))","rgba(var(--cleen-error, 239, 68, 68))","rgba(var(--cleen-purple, 147, 51, 234))","rgba(var(--cleen-cyan, 6, 182, 212))","rgba(var(--cleen-orange, 249, 115, 22))","rgba(var(--cleen-pink, 236, 72, 153))","rgba(var(--cleen-teal, 20, 184, 166))","rgba(var(--cleen-indigo, 99, 102, 241))","rgba(var(--cleen-rose, 244, 63, 94))","rgba(var(--cleen-amber, 245, 158, 11))"];function He(e){return e!=null}function Tt(e,t){return[e.source,e.target,e.type??"",e.label??"",e.value,t].join("-").replace(/\s+/g,"_")}function X(e,t){return typeof e=="object"&&e!==null?e.id:t}function Le(e,t){return typeof e=="object"&&e!==null?e.title:t}function ee(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function te(e){return typeof e=="object"&&e!==null&&"payload"in e}function Fe(e){if(te(e))return Fe(e.payload);if(ee(e)||kt(e))return e}function re(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function Ie(e){let t=re(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function Be(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function D(e){let t=e.match(/^rgba\((var\(.+\)),\s*([0-9]*\.?[0-9]+)\)$/i);if(t)return{color:`rgb(${t[1]})`,opacity:Number.parseFloat(t[2])};let r=e.match(/^rgba\((var\(.+\))\)$/i);if(r)return{color:`rgb(${r[1]})`,opacity:1};let n=e.match(/^rgba\(\s*(\d+\s*,\s*\d+\s*,\s*\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);return n?{color:`rgb(${n[1]})`,opacity:Number.parseFloat(n[2])}:{color:e,opacity:1}}function oe(e,t){return D(t??Pe[e%Pe.length])}function Ee(e){return e.length*xt}function Ot(e){let t=new Set,r=new Set([e.id]);for(let n of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(n.edgeKey),r.add(X(n.source,n.sourceId)),r.add(X(n.target,n.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function Nt(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([X(e.source,e.sourceId),X(e.target,e.targetId)])}}function Rt(e,t,r,n,c){return!e||e.activeNodeIds.has(t)?1:n?c??I.dimOpacity??.2:r?.55:1}function wt(e,t,r,n,c,b){return e?e.activeLinkKeys.has(t)?n?Math.max(r,.9):r:c?b??I.dimOpacity??.2:n?Math.min(r,.3):r:r}var Pt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:n,y:c,width:b,height:g,highlightOnHover:x,hoverState:p,index:k,outgoingEdgesById:N,payload:o,stroke:T,strokeWidth:s})=>{if(o===void 0||n===void 0||c===void 0||b===void 0||g===void 0||k===void 0)return null;let S=N?.get(o.id)??[],v=S.length>0,C=oe(k,o.color),R=D(r),i=Rt(p,o.id,x,e,t),l=new Set(S.map(h=>h.color).filter(He)),f=Array.from(l)[0],y=v&&S.length>1&&l.size>1&&l.size===S.length,u=y?S:[],a=u.reduce((h,m)=>h+(m.value??0),0);return $(_e,{children:[y&&a>0?u.map((h,m)=>{let d=u.slice(0,m).reduce((H,F)=>H+(F.value??0),0),A=c+d/a*g,w=(h.value??0)/a*g,L=D(h.color??C.color),E=m===0,_=m===u.length-1;return O(Te,{x:n,y:A,width:b,height:w,fill:L.color,fillOpacity:L.opacity*i,stroke:T,strokeWidth:s,radius:[E?2:0,E?2:0,_?2:0,_?2:0]},`${h.source}-${h.target}-${m}`)}):O(Te,{x:n,y:c,width:b,height:g,fill:v&&l.size===1?D(f??C.color).color:C.color,fillOpacity:(v&&l.size===1?D(f??C.color).opacity:C.opacity)*i,stroke:T,strokeWidth:s,radius:[2,2,2,2]}),O("text",{textAnchor:v?"end":"start",x:v?n-8:n+b+8,y:c+g/2,dy:"0.35em",fontSize:"14",fill:R.color,fillOpacity:R.opacity*i,fontWeight:600,children:o.name})]},`CustomNode${k}`)},Lt=({sourceX:e,targetX:t,sourceY:r,targetY:n,sourceControlX:c,targetControlX:b,linkWidth:g,index:x,payload:p,opacity:k,chartId:N,dimOnHover:o,dimOpacity:T,edgeGradientFill:s,highlightOnHover:S,hoverState:v})=>{if(p===void 0||e===void 0||t===void 0||r===void 0||n===void 0||c===void 0||b===void 0||g===void 0)return null;let C=k??I.edgeOpacity??.4,R=wt(v,p.edgeKey,C,S,o,T),i=p.color?D(p.color):null,l=i??oe(typeof p.source=="object"?p.source.index:0,typeof p.source=="object"?p.source.color:void 0),f=i??oe(typeof p.target=="object"?p.target.index:1,typeof p.target=="object"?p.target.color:void 0),y=Be(`linkGradient-${N}-${p.edgeKey}-${x??p.value}`),u=s!==!1&&i===null;return $(_e,{children:[u?O("defs",{children:$("linearGradient",{id:y,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[O("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity*R}),O("stop",{offset:"100%",stopColor:f.color,stopOpacity:f.opacity*R})]})}):null,O("path",{d:`
5
2
  M${e},${r}
6
- C${c},${r} ${C},${n} ${t},${n}
7
- `,stroke:m?`url(#${y})`:i.color,strokeWidth:Math.max(1,g),fill:"none",strokeOpacity:m?1:i.opacity*N,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${p.edgeKey}`)};function Lt({data:e,options:t,className:r,style:n,onNodeClick:c,renderTooltip:C}){let g=dt(null),[x,p]=ut(null),v=ct(),T=He(v),o=pt(I,t),S=At(o.height),l=o.highlightOnHover||o.dimOnHover,b=U(()=>{let a=e.nodes.map((f,u)=>({...f,index:u,name:f.title})),h=e.edges.map((f,u)=>{let A=e.nodes.findIndex(L=>L.id===f.source),w=e.nodes.findIndex(L=>L.id===f.target);return A<0||w<0?null:{...f,edgeKey:kt(f,u),originalEdge:f,source:A,sourceId:f.source,target:w,targetId:f.target,value:f.value}}).filter(Ee);return{nodes:a,links:h}},[e]),O=U(()=>{let a=new Map;for(let h of e.edges){let f=a.get(h.source)??[];f.push(h),a.set(h.source,f)}return a},[e]),R=U(()=>({backgroundColor:o.tooltipBGColor,border:`1px solid ${o.tooltipBorderColor}`,borderRadius:8,boxShadow:"0 12px 32px rgba(15, 23, 42, 0.12)",color:o.fontColor,padding:"10px 12px"}),[o.fontColor,o.tooltipBGColor,o.tooltipBorderColor]),N=U(()=>{let a=new Set(e.edges.map(A=>A.source)),h=new Set(e.edges.map(A=>A.target)),f=e.nodes.reduce((A,w)=>h.has(w.id)?A:Math.max(A,Le(w.title)),0),u=e.nodes.reduce((A,w)=>a.has(w.id)?A:Math.max(A,Le(w.title)),0);return{top:ke,right:Math.max(Te,u+Oe+16),bottom:ke,left:Math.max(Te,f+Oe+16)}},[e]),s=(a,h)=>{if(l){if(h==="node"&&Re(a.payload)){p(Tt(a.payload));return}h==="link"&&J(a.payload)&&p(Ot(a.payload))}},i=()=>{l&&p(null)},d=()=>{if(typeof window>"u")return;let a=g.current?.querySelector("svg");if(!a)return;let h=new XMLSerializer().serializeToString(a),f=new Blob([h],{type:"image/svg+xml;charset=utf-8"}),u=URL.createObjectURL(f),A=document.createElement("a");A.href=u,A.download="sankey-chart.svg",A.click(),window.setTimeout(()=>URL.revokeObjectURL(u),0)},y=({active:a,payload:h})=>{if(!a||!h?.length)return null;let f=h[0]?.payload,u=_e(f);if(!u)return null;let A=J(u),w=Q(f)?f.value:h[0]?.value,L=Q(f)?f.name:void 0,E=Number(u.value??w??0),_=o.valueFormatter?o.valueFormatter(Number(u.value??w??0),A?u.originalEdge:void 0):`${u.value??w??""}`,H=A?we(u.source,u.sourceId):"",F=A?we(u.target,u.targetId):"",j=A?ee(u.title,u.label,u.name,u.originalEdge?.title,u.originalEdge?.label,u.originalEdge?.name,Pe(L),H&&F?`${H} \u2192 ${F}`:void 0):ee(u.title,Pe(L)),Y=A?`${H} \u2192 ${F}`:"";if(C){let Ge=A?{type:"link",edge:u.originalEdge,sourceNodeId:u.sourceId,sourceNodeTitle:H,targetNodeId:u.targetId,targetNodeTitle:F,value:Number.isFinite(E)?E:0,payload:u.originalEdge}:{type:"node",node:u,value:Number.isFinite(E)?E:0,payload:u},ne=C(Ge);return ne?k(It,{children:ne}):null}return!j&&!Y&&!_?null:D("div",{className:G(xt),style:R,children:[j?k("p",{className:G(Z,bt),style:{color:o.fontColor,overflowWrap:"anywhere"},children:j}):null,Y?k("p",{className:G(Z,Ct),style:{color:o.fontColor,overflowWrap:"anywhere"},children:Y}):null,_?k("p",{className:G(Z,St),style:{color:o.fontColor},children:_}):null]})},m={display:"flex",flexDirection:"column",gap:o.enableToolbar?12:0,width:o.width??"100%",height:S,minHeight:S,...n};return D("div",{className:G("cleen cleen-w-full",r),ref:g,style:m,children:[o.enableToolbar?D("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[k("button",{type:"button",onClick:()=>p(null),disabled:!x,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray-200))",borderRadius:8,color:o.fontColor,cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:x?1:.5,padding:"6px 10px"},children:"Reset focus"}),k("button",{type:"button",onClick:d,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray-200))",borderRadius:8,color:o.fontColor,cursor:"pointer",fontSize:13,fontWeight:600,padding:"6px 10px"},children:"Download SVG"})]}):null,k("div",{style:{flex:1,minHeight:0},children:k(ft,{width:"100%",height:"100%",children:k(ht,{data:b,align:o.align,margin:N,node:k(wt,{dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,fontColor:o.fontColor??I.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:o.highlightOnHover,hoverState:x,outgoingEdgesById:O,stroke:o.nodeBorderColor??"transparent",strokeWidth:o.nodeBorderWidth}),nodePadding:o.nodePadding,nodeWidth:o.nodeWidth,link:k(Pt,{chartId:T,dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,edgeGradientFill:o.edgeGradientFill,highlightOnHover:o.highlightOnHover,hoverState:x,opacity:o.edgeOpacity}),onClick:(a,h)=>{h==="node"&&c&&Re(a.payload)&&c(a.payload)},onMouseEnter:s,onMouseLeave:i,children:o.enableTooltip?k(mt,{content:k(y,{}),cursor:!1,allowEscapeViewBox:{x:!1,y:!0},isAnimationActive:!1,wrapperStyle:{transition:"none"}}):null})})})]})}import{applyDefaults as Et,cn as _t}from"@cleen/ui-core";import{forwardRef as Ht}from"react";var Fe={chart:{type:"scatter",zoom:{enabled:!1},toolbar:{show:!1}},markers:{shape:"square",size:8,strokeWidth:0},grid:{strokeDashArray:8},legend:{show:!0,horizontalAlign:"right",position:"top",labels:{colors:"rgba(var(--cleen-gray-700))"}},yaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray-200))"},labels:{style:{colors:"rgba(var(--cleen-gray-700))"}}},xaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray-200))"},labels:{style:{colors:"rgba(var(--cleen-gray-700))"}}},title:{align:"left",floating:!0,style:{color:"rgba(var(--cleen-black))"}}},Be={chart:{type:"scatter",zoom:{enabled:!1},toolbar:{show:!1}},stroke:{width:0},fill:{opacity:1},markers:{shape:"circle",size:14,strokeWidth:2,hover:{sizeOffset:0}},grid:{strokeDashArray:0,borderColor:"rgba(var(--cleen-gray-200))",padding:{left:0,right:12},xaxis:{lines:{show:!0}},yaxis:{lines:{show:!1}}},legend:{show:!1},xaxis:{min:0,max:210,tickAmount:4,axisBorder:{show:!1},axisTicks:{show:!1},decimalsInFloat:0,title:{text:"Estimated impact \u2192",style:{color:"rgba(var(--cleen-gray-700))",fontSize:"14px",fontWeight:400}},labels:{style:{colors:"rgba(var(--cleen-gray-700))",fontSize:"14px"},formatter(e){let t=Number(e);return Number.isNaN(t)?`${e}`:`$${Math.round(t)}k`}}},tooltip:{enabled:!0,theme:"light",x:{formatter(e){let t=Number(e);return Number.isNaN(t)?`${e}`:`$${Math.round(t)}k`}}}};import{jsx as W,jsxs as Me}from"react/jsx-runtime";var Ft=Ht(function({options:t,variant:r="default",rows:n,className:c,style:C,...g},x){let v=Et(r==="matrix"?Be:Fe,t);if(r==="matrix"&&n?.length){let T=Math.min(...n.map(l=>l.y)),o=Math.max(...n.map(l=>l.y)),S=Array.isArray(v.yaxis)?{}:v.yaxis??{};return Me("div",{className:_t("cleen cleen-grid cleen-grid-cols-[156px_minmax(0,1fr)] cleen-items-stretch cleen-gap-3 cleen-w-full",c),style:C,children:[W("div",{className:"cleen-grid cleen-pt-[18px] cleen-pb-[54px]",style:{gridTemplateRows:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map(l=>Me("div",{className:"cleen-flex cleen-flex-col cleen-justify-center cleen-items-end cleen-gap-1 cleen-pr-2",children:[W("span",{className:"cleen-text-[18px] cleen-font-bold cleen-leading-[1.1] cleen-text-[rgba(var(--cleen-black))]",children:l.label}),l.gapsLabel?W("span",{className:"cleen-text-[14px] cleen-leading-[1.2] cleen-text-gray-700",children:l.gapsLabel}):null]},`${l.label}-${l.y}`))}),W(P,{type:"scatter",ref:x,className:"cleen-w-full cleen-h-full",options:{...v,yaxis:{...S,min:T-.5,max:o+.5,tickAmount:Math.max(o-T,1),axisBorder:{...S.axisBorder,show:!1},axisTicks:{...S.axisTicks,show:!1},labels:{...S.labels,show:!1}},annotations:{...v.annotations,yaxis:[...n.map(l=>({y:l.y,borderColor:l.lineColor||"rgba(var(--cleen-gray-200))",strokeDashArray:0})),...v.annotations?.yaxis||[]]}},...g})]})}return W(P,{type:"scatter",ref:x,className:c,style:C,options:v,...g})});import{applyDefaults as Bt}from"@cleen/ui-core";import{forwardRef as Mt,useEffect as De,useMemo as ze,useRef as K,useState as $t}from"react";var $e={chart:{type:"treemap",zoom:{enabled:!1},toolbar:{show:!1}},legend:{show:!1},dataLabels:{enabled:!0,style:{fontSize:"12px",fontWeight:400}},plotOptions:{treemap:{enableShades:!0,distributed:!1}},title:{align:"left",style:{color:"rgba(var(--cleen-black))"}}};import{jsx as V,jsxs as zt}from"react/jsx-runtime";var re=(e,t)=>e.length!==t.length?!1:e.every((r,n)=>{let c=t[n];return Math.round(r.x)===Math.round(c.x)&&Math.round(r.y)===Math.round(c.y)&&Math.round(r.width)===Math.round(c.width)&&Math.round(r.height)===Math.round(c.height)}),Dt=Mt(function({options:t,labelLayout:r="apex",renderTileLabel:n,className:c,style:C,...g},x){let p=K(null),[v,T]=$t([]),o=r==="overlay"&&typeof n=="function",S=K(()=>null);S.current=()=>{let s=p.current;if(!s)return null;let i=s.getBoundingClientRect(),d=s.querySelectorAll(".apexcharts-treemap-rect");return d.length?Array.from(d).map((y,m)=>{let a=y.getBoundingClientRect();return{x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height,dataIndex:m}}):null};let l=K(0),b=K(()=>{});b.current=()=>{cancelAnimationFrame(l.current);let s=0,i=null,d=()=>{let y=S.current();if(y&&i&&re(i,y)){T(m=>re(m,y)?m:y);return}y&&(i=y),s<30?(s++,l.current=requestAnimationFrame(d)):y&&T(m=>re(m,y)?m:y)};l.current=requestAnimationFrame(d)};let O=ze(()=>{let s=Bt($e,t??{});if(!o)return s;let i=s.chart?.events??{},d=y=>(...m)=>{b.current(),y?.(...m)};return{...s,dataLabels:{...s.dataLabels,enabled:!1},chart:{...s.chart,animations:{enabled:!1},events:{...i,mounted:d(i.mounted),updated:d(i.updated)}}}},[t,o]);De(()=>{if(o)return b.current(),()=>cancelAnimationFrame(l.current)},[o]),De(()=>{if(!o)return;let s=p.current;if(!s||typeof ResizeObserver>"u")return;let i=new ResizeObserver(()=>b.current());return i.observe(s),()=>i.disconnect()},[o]);let R=ze(()=>{let s=g.series;return!Array.isArray(s)||s.length===0?[]:(s[0]??{}).data??[]},[g.series]);if(!o)return V(P,{type:"treemap",ref:x,options:O,className:c,style:C,...g});let N={...C,position:"relative"};return zt("div",{ref:p,className:c,style:N,children:[V(P,{type:"treemap",ref:x,options:O,...g}),v.length>0&&V("div",{style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"hidden"},children:v.map(s=>V("div",{style:{position:"absolute",left:s.x,top:s.y,width:s.width,height:s.height},children:n({point:R[s.dataIndex],width:s.width,height:s.height})},s.dataIndex))})]})});import"react";import{jsx as oe,jsxs as Wt}from"react/jsx-runtime";var Gt=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:n="",style:c})=>{let C=Math.max(...r,1),g=r.map((x,p)=>`${p/(r.length-1)*e},${t-x/C*t}`).join(" ");return Wt("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:n,style:c,role:"img","aria-label":"Simple line chart",children:[oe("rect",{width:"100%",height:"100%",fill:"transparent"}),oe("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:g,strokeLinecap:"round",strokeLinejoin:"round"}),oe("polygon",{points:`${g} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{qe as BarChart,Qe as BellCurve,ie as Chart,ot as FootballFieldChart,lt as RadarChart,Lt as SankeyChart,Ft as ScatterChart,Gt as SimpleChart,Dt as TreemapChart};
3
+ C${c},${r} ${b},${n} ${t},${n}
4
+ `,stroke:u?`url(#${y})`:l.color,strokeWidth:Math.max(1,g),fill:"none",strokeOpacity:u?1:l.opacity*R,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${p.edgeKey}`)};function It({data:e,options:t,className:r,style:n,onNodeClick:c,renderTooltip:b}){let g=ut(null),[x,p]=mt(null),k=dt(),N=Be(k),o=ct(I,t),T=vt(o.height),s=o.highlightOnHover||o.dimOnHover,S=U(()=>{let a=e.nodes.map((m,d)=>({...m,index:d,name:m.title})),h=e.edges.map((m,d)=>{let A=e.nodes.findIndex(L=>L.id===m.source),w=e.nodes.findIndex(L=>L.id===m.target);return A<0||w<0?null:{...m,edgeKey:Tt(m,d),originalEdge:m,source:A,sourceId:m.source,target:w,targetId:m.target,value:m.value}}).filter(He);return{nodes:a,links:h}},[e]),v=U(()=>{let a=new Map;for(let h of e.edges){let m=a.get(h.source)??[];m.push(h),a.set(h.source,m)}return a},[e]),C=U(()=>({backgroundColor:o.tooltipBGColor,border:`1px solid ${o.tooltipBorderColor}`,borderRadius:8,boxShadow:"0 12px 32px rgba(15, 23, 42, 0.12)",color:o.fontColor,padding:"10px 12px"}),[o.fontColor,o.tooltipBGColor,o.tooltipBorderColor]),R=U(()=>{let a=new Set(e.edges.map(A=>A.source)),h=new Set(e.edges.map(A=>A.target)),m=e.nodes.reduce((A,w)=>h.has(w.id)?A:Math.max(A,Ee(w.title)),0),d=e.nodes.reduce((A,w)=>a.has(w.id)?A:Math.max(A,Ee(w.title)),0);return{top:Oe,right:Math.max(Ne,d+Re+16),bottom:Oe,left:Math.max(Ne,m+Re+16)}},[e]),i=(a,h)=>{if(s){if(h==="node"&&we(a.payload)){p(Ot(a.payload));return}h==="link"&&ee(a.payload)&&p(Nt(a.payload))}},l=()=>{s&&p(null)},f=()=>{if(typeof window>"u")return;let a=g.current?.querySelector("svg");if(!a)return;let h=new XMLSerializer().serializeToString(a),m=new Blob([h],{type:"image/svg+xml;charset=utf-8"}),d=URL.createObjectURL(m),A=document.createElement("a");A.href=d,A.download="sankey-chart.svg",A.click(),window.setTimeout(()=>URL.revokeObjectURL(d),0)},y=({active:a,payload:h})=>{if(!a||!h?.length)return null;let m=h[0]?.payload,d=Fe(m);if(!d)return null;let A=ee(d),w=te(m)?m.value:h[0]?.value,L=te(m)?m.name:void 0,E=Number(d.value??w??0),_=o.valueFormatter?o.valueFormatter(Number(d.value??w??0),A?d.originalEdge:void 0):`${d.value??w??""}`,H=A?Le(d.source,d.sourceId):"",F=A?Le(d.target,d.targetId):"",j=A?re(d.title,d.label,d.name,d.originalEdge?.title,d.originalEdge?.label,d.originalEdge?.name,Ie(L),H&&F?`${H} \u2192 ${F}`:void 0):re(d.title,Ie(L)),Y=A?`${H} \u2192 ${F}`:"";if(b){let Ue=A?{type:"link",edge:d.originalEdge,sourceNodeId:d.sourceId,sourceNodeTitle:H,targetNodeId:d.targetId,targetNodeTitle:F,value:Number.isFinite(E)?E:0,payload:d.originalEdge}:{type:"node",node:d,value:Number.isFinite(E)?E:0,payload:d},ie=b(Ue);return ie?O(Et,{children:ie}):null}return!j&&!Y&&!_?null:$("div",{className:G(bt),style:C,children:[j?O("p",{className:G(Q,Ct),style:{color:o.fontColor,overflowWrap:"anywhere"},children:j}):null,Y?O("p",{className:G(Q,St),style:{color:o.fontColor,overflowWrap:"anywhere"},children:Y}):null,_?O("p",{className:G(Q,At),style:{color:o.fontColor},children:_}):null]})},u={display:"flex",flexDirection:"column",gap:o.enableToolbar?12:0,width:o.width??"100%",height:T,minHeight:T,...n};return $("div",{className:G("cleen cleen-w-full",r),ref:g,style:u,children:[o.enableToolbar?$("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[O("button",{type:"button",onClick:()=>p(null),disabled:!x,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray-200))",borderRadius:8,color:o.fontColor,cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:x?1:.5,padding:"6px 10px"},children:"Reset focus"}),O("button",{type:"button",onClick:f,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray-200))",borderRadius:8,color:o.fontColor,cursor:"pointer",fontSize:13,fontWeight:600,padding:"6px 10px"},children:"Download SVG"})]}):null,O("div",{style:{flex:1,minHeight:0},children:O(ht,{width:"100%",height:"100%",children:O(gt,{data:S,align:o.align,margin:R,node:O(Pt,{dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,fontColor:o.fontColor??I.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:o.highlightOnHover,hoverState:x,outgoingEdgesById:v,stroke:o.nodeBorderColor??"transparent",strokeWidth:o.nodeBorderWidth}),nodePadding:o.nodePadding,nodeWidth:o.nodeWidth,link:O(Lt,{chartId:N,dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,edgeGradientFill:o.edgeGradientFill,highlightOnHover:o.highlightOnHover,hoverState:x,opacity:o.edgeOpacity}),onClick:(a,h)=>{h==="node"&&c&&we(a.payload)&&c(a.payload)},onMouseEnter:i,onMouseLeave:l,children:o.enableTooltip?O(ft,{content:O(y,{}),cursor:!1,allowEscapeViewBox:{x:!1,y:!0},isAnimationActive:!1,wrapperStyle:{transition:"none"}}):null})})})]})}import{applyDefaults as _t,cn as Ht}from"@cleen/ui-core";import{forwardRef as Ft}from"react";var Me={chart:{type:"scatter",zoom:{enabled:!1},toolbar:{show:!1}},markers:{shape:"square",size:8,strokeWidth:0},grid:{strokeDashArray:8},legend:{show:!0,horizontalAlign:"right",position:"top",labels:{colors:"rgba(var(--cleen-gray-700))"}},yaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray-200))"},labels:{style:{colors:"rgba(var(--cleen-gray-700))"}}},xaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray-200))"},labels:{style:{colors:"rgba(var(--cleen-gray-700))"}}},title:{align:"left",floating:!0,style:{color:"rgba(var(--cleen-black))"}}},De={chart:{type:"scatter",zoom:{enabled:!1},toolbar:{show:!1}},stroke:{width:0},fill:{opacity:1},markers:{shape:"circle",size:14,strokeWidth:2,hover:{sizeOffset:0}},grid:{strokeDashArray:0,borderColor:"rgba(var(--cleen-gray-200))",padding:{left:0,right:12},xaxis:{lines:{show:!0}},yaxis:{lines:{show:!1}}},legend:{show:!1},xaxis:{min:0,max:210,tickAmount:4,axisBorder:{show:!1},axisTicks:{show:!1},decimalsInFloat:0,title:{text:"Estimated impact \u2192",style:{color:"rgba(var(--cleen-gray-700))",fontSize:"14px",fontWeight:400}},labels:{style:{colors:"rgba(var(--cleen-gray-700))",fontSize:"14px"},formatter(e){let t=Number(e);return Number.isNaN(t)?`${e}`:`$${Math.round(t)}k`}}},tooltip:{enabled:!0,theme:"light",x:{formatter(e){let t=Number(e);return Number.isNaN(t)?`${e}`:`$${Math.round(t)}k`}}}};import{jsx as W,jsxs as $e}from"react/jsx-runtime";var Bt=Ft(function({options:t,variant:r="default",rows:n,className:c,style:b,...g},x){let k=_t(r==="matrix"?De:Me,t);if(r==="matrix"&&n?.length){let N=Math.min(...n.map(s=>s.y)),o=Math.max(...n.map(s=>s.y)),T=Array.isArray(k.yaxis)?{}:k.yaxis??{};return $e("div",{className:Ht("cleen cleen-grid cleen-grid-cols-[156px_minmax(0,1fr)] cleen-items-stretch cleen-gap-3 cleen-w-full",c),style:b,children:[W("div",{className:"cleen-grid cleen-pt-[18px] cleen-pb-[54px]",style:{gridTemplateRows:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map(s=>$e("div",{className:"cleen-flex cleen-flex-col cleen-justify-center cleen-items-end cleen-gap-1 cleen-pr-2",children:[W("span",{className:"cleen-text-[18px] cleen-font-bold cleen-leading-[1.1] cleen-text-[rgba(var(--cleen-black))]",children:s.label}),s.gapsLabel?W("span",{className:"cleen-text-[14px] cleen-leading-[1.2] cleen-text-gray-700",children:s.gapsLabel}):null]},`${s.label}-${s.y}`))}),W(P,{type:"scatter",ref:x,className:"cleen-w-full cleen-h-full",options:{...k,yaxis:{...T,min:N-.5,max:o+.5,tickAmount:Math.max(o-N,1),axisBorder:{...T.axisBorder,show:!1},axisTicks:{...T.axisTicks,show:!1},labels:{...T.labels,show:!1}},annotations:{...k.annotations,yaxis:[...n.map(s=>({y:s.y,borderColor:s.lineColor||"rgba(var(--cleen-gray-200))",strokeDashArray:0})),...k.annotations?.yaxis||[]]}},...g})]})}return W(P,{type:"scatter",ref:x,className:c,style:b,options:k,...g})});import{applyDefaults as Mt}from"@cleen/ui-core";import{forwardRef as Dt,useEffect as Ge,useMemo as We,useRef as K,useState as $t}from"react";var ze={chart:{type:"treemap",zoom:{enabled:!1},toolbar:{show:!1}},legend:{show:!1},dataLabels:{enabled:!0,style:{fontSize:"12px",fontWeight:400}},plotOptions:{treemap:{enableShades:!0,distributed:!1}},title:{align:"left",style:{color:"rgba(var(--cleen-black))"}}};import{jsx as V,jsxs as Gt}from"react/jsx-runtime";var ne=(e,t)=>e.length!==t.length?!1:e.every((r,n)=>{let c=t[n];return Math.round(r.x)===Math.round(c.x)&&Math.round(r.y)===Math.round(c.y)&&Math.round(r.width)===Math.round(c.width)&&Math.round(r.height)===Math.round(c.height)}),zt=Dt(function({options:t,labelLayout:r="apex",renderTileLabel:n,className:c,style:b,...g},x){let p=K(null),[k,N]=$t([]),o=r==="overlay"&&typeof n=="function",T=K(()=>null);T.current=()=>{let i=p.current;if(!i)return null;let l=i.getBoundingClientRect(),f=i.querySelectorAll(".apexcharts-treemap-rect");return f.length?Array.from(f).map((y,u)=>{let a=y.getBoundingClientRect();return{x:a.left-l.left,y:a.top-l.top,width:a.width,height:a.height,dataIndex:u}}):null};let s=K(0),S=K(()=>{});S.current=()=>{cancelAnimationFrame(s.current);let i=0,l=null,f=()=>{let y=T.current();if(y&&l&&ne(l,y)){N(u=>ne(u,y)?u:y);return}y&&(l=y),i<30?(i++,s.current=requestAnimationFrame(f)):y&&N(u=>ne(u,y)?u:y)};s.current=requestAnimationFrame(f)};let v=We(()=>{let i=Mt(ze,t??{});if(!o)return i;let l=i.chart?.events??{},f=y=>(...u)=>{S.current(),y?.(...u)};return{...i,dataLabels:{...i.dataLabels,enabled:!1},chart:{...i.chart,animations:{enabled:!1},events:{...l,mounted:f(l.mounted),updated:f(l.updated)}}}},[t,o]);Ge(()=>{if(o)return S.current(),()=>cancelAnimationFrame(s.current)},[o]),Ge(()=>{if(!o)return;let i=p.current;if(!i||typeof ResizeObserver>"u")return;let l=new ResizeObserver(()=>S.current());return l.observe(i),()=>l.disconnect()},[o]);let C=We(()=>{let i=g.series;return!Array.isArray(i)||i.length===0?[]:(i[0]??{}).data??[]},[g.series]);if(!o)return V(P,{type:"treemap",ref:x,options:v,className:c,style:b,...g});let R={...b,position:"relative"};return Gt("div",{ref:p,className:c,style:R,children:[V(P,{type:"treemap",ref:x,options:v,...g}),k.length>0&&V("div",{style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"hidden"},children:k.map(i=>V("div",{style:{position:"absolute",left:i.x,top:i.y,width:i.width,height:i.height},children:n({point:C[i.dataIndex],width:i.width,height:i.height})},i.dataIndex))})]})});import"react";import{jsx as ae,jsxs as Ut}from"react/jsx-runtime";var Wt=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:n="",style:c})=>{let b=Math.max(...r,1),g=r.map((x,p)=>`${p/(r.length-1)*e},${t-x/b*t}`).join(" ");return Ut("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:n,style:c,role:"img","aria-label":"Simple line chart",children:[ae("rect",{width:"100%",height:"100%",fill:"transparent"}),ae("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:g,strokeLinecap:"round",strokeLinejoin:"round"}),ae("polygon",{points:`${g} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{Je as BarChart,tt as BellCurve,se as Chart,at as FootballFieldChart,st as RadarChart,It as SankeyChart,Bt as ScatterChart,Wt as SimpleChart,zt as TreemapChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleen/ui",
3
- "version": "0.1.197",
3
+ "version": "0.1.199",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",