@cleen/ui 0.1.130 → 0.1.131

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,4 +1,4 @@
1
- import{cn as Ie}from"@cleen/ui-core";import{forwardRef as Ee}from"react";import{renderToStaticMarkup as _e}from"react-dom/server";import He from"react-apexcharts";var j={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 re}from"react/jsx-runtime";var Be="[&_.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",oe=Ee(function({type:t="line",series:r,options:o={},width:u="100%",height:f=350,className:g,style:x,renderTooltip:c},C){let T=c?{...o.tooltip,custom:(l=>{let A=c({seriesIndex:l.seriesIndex,dataPointIndex:l.dataPointIndex,series:l.series,w:l.w});return A?_e(A):""})}:o.tooltip,n={...j,...o,chart:{...j.chart,...o.chart,type:t},...T?{tooltip:T}:{}},S=!!n.tooltip?.custom;return re("div",{className:Ie("cleen",S&&Be,g),style:x,children:re(He,{options:n,series:r,type:t,width:u,height:f,ref:C})})}),P=oe;import{applyDefaults as $e}from"@cleen/ui-core";import{forwardRef as Me}from"react";var ne={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 De}from"react/jsx-runtime";var Fe=Me(function({options:t,...r},o){return De(P,{type:"bar",ref:o,options:$e(ne,t??{}),...r})});import{applyDefaults as z}from"@cleen/ui-core";import{forwardRef as ze,useMemo as M}from"react";import{ColorHelpers as $}from"@cleen/ui-core";var ae={marker:{size:2,fillColor:"rgba(var(--cleen-gray), 0.8)",strokeColor:"rgba(var(--cleen-gray), 0.8)",offsetY:-16,shape:"triangle"},label:{borderWidth:0,offsetY:-20,style:{color:"rgba(var(--cleen-gray), 0.8)",background:"transparent",fontSize:"11px"}}},ie={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},le={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},se={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},pe={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[$.getComputedColor("var(--cleen-error)"),$.getComputedColor("var(--cleen-primary)"),$.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[$.getComputedColor("var(--cleen-error)")||"",$.getComputedColor("var(--cleen-primary)")||"",$.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 ce=(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}),de=(e,t,r,o)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:o}),ue=(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 We}from"react/jsx-runtime";var Ge=ze(function({serie:t,labels:r,sigma:o,pointAnnotations:u,rangeAnnotations:f,highlightAnnotations:g,options:x,height:c=360,...C},T){let n=M(()=>t.sort((d,y)=>d.x-y.x),[t]),S=M(()=>{let d=new Map;return t.forEach(y=>d.set(y.x,y.y)),d},[t]),l=n[Math.floor(n.length/2)],A=M(()=>{let{below:d,middle:y,above:k}=t.reduce((h,a)=>(a.x<l.x-2*o?h.below.push(a):a.x>=l.x+2*o?(a.x===l.x+2*o&&h.middle.push(a),h.above.push(a)):(a.x===l.x-2*o&&h.below.push(a),h.middle.push(a)),h),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:d},{name:r?.middle||"Middle grounds",data:y},{name:r?.above||"Above threshold",data:k}]},[o,t,r,l]),N=M(()=>{if(!u)return[];let d=ce(l.x,o);return Object.entries(u).map(([y,k])=>{let h=d[y];return{x:h,y:S.get(h)||0,...z(ae,k)}})},[u,o,S]),O=M(()=>{if(!f)return[];let d=de(l.x,o,n[0].x,n[n.length-1].x);return f.map(y=>{let k=ue(y,d);return{...z(ie,y),...k}})},[f,o,n]),{highlightPointAnnotations:w,highlightLineAnnotations:R}=M(()=>{if(!g)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let d=[],y=[],k=({x:a,line:p})=>{y.push(z(le,{x:a,...p}))},h=({x:a,y:p,point:s})=>{d.push(z(se,{x:a,y:p,...s}))};return g?.forEach(a=>{switch(a.show){case"line":k(a);break;case"point":h(a);break;case"both":k(a),h(a);break;default:break}}),{highlightPointAnnotations:d,highlightLineAnnotations:y}},[g]);return We(P,{series:A,options:{...z(pe,x),annotations:{...x?.annotations,points:[...N,...w,...x?.annotations?.points||[]],xaxis:[...O,...R,...x?.annotations?.xaxis||[]]}},height:c,ref:T,type:"area",...C})});import{applyDefaults as Ue}from"@cleen/ui-core";import{forwardRef as Xe}from"react";var me={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 Ve}from"react/jsx-runtime";var Ke=Xe(function({options:t,...r},o){return Ve(P,{type:"radar",ref:o,options:Ue(me,t),...r})});import{applyDefaults as je,cn as Ye}from"@cleen/ui-core";import{forwardRef as qe}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), 0.8)"}},yaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray), .2)"},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)"}}},xaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray), .2)"},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)"}}},title:{align:"left",floating:!0,style:{color:"rgba(var(--cleen-black))"}}},ge={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), 0.12)",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), 0.8)",fontSize:"14px",fontWeight:400}},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)",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 G,jsxs as he}from"react/jsx-runtime";var Ze=qe(function({options:t,variant:r="default",rows:o,className:u,style:f,...g},x){let C=je(r==="matrix"?ge:fe,t);if(r==="matrix"&&o?.length){let T=Math.min(...o.map(l=>l.y)),n=Math.max(...o.map(l=>l.y)),S=Array.isArray(C.yaxis)?{}:C.yaxis??{};return he("div",{className:Ye("cleen cleen-grid cleen-grid-cols-[156px_minmax(0,1fr)] cleen-items-stretch cleen-gap-3 cleen-w-full",u),style:f,children:[G("div",{className:"cleen-grid cleen-pt-[18px] cleen-pb-[54px]",style:{gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`},children:o.map(l=>he("div",{className:"cleen-flex cleen-flex-col cleen-justify-center cleen-items-end cleen-gap-1 cleen-pr-2",children:[G("span",{className:"cleen-text-[18px] cleen-font-bold cleen-leading-[1.1] cleen-text-[rgba(var(--cleen-black))]",children:l.label}),l.gapsLabel?G("span",{className:"cleen-text-[14px] cleen-leading-[1.2] cleen-text-[rgba(var(--cleen-gray),0.8)]",children:l.gapsLabel}):null]},`${l.label}-${l.y}`))}),G(P,{type:"scatter",ref:x,className:"cleen-w-full cleen-h-full",options:{...C,yaxis:{...S,min:T-.5,max:n+.5,tickAmount:Math.max(n-T,1),axisBorder:{...S.axisBorder,show:!1},axisTicks:{...S.axisTicks,show:!1},labels:{...S.labels,show:!1}},annotations:{...C.annotations,yaxis:[...o.map(l=>({y:l.y,borderColor:l.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...C.annotations?.yaxis||[]]}},...g})]})}return G(P,{type:"scatter",ref:x,className:u,style:f,options:C,...g})});import{applyDefaults as Je,cn as W}from"@cleen/ui-core";import{useId as Qe,useMemo as U,useRef as et,useState as tt}from"react";import{Layer as Ne,Rectangle as ye,ResponsiveContainer as rt,Sankey as ot,Tooltip as nt}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), 0.2)"};import{Fragment as St,jsx as b,jsxs as D}from"react/jsx-runtime";var at=typeof I.height=="number"?I.height:420,xe=40,be=60,Ce=8,it=8,lt="cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)] cleen-flex cleen-flex-col cleen-gap-2",Y="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-whitespace-pre-line cleen-break-words",st="cleen-font-semibold",pt="cleen-font-medium cleen-text-[13px] cleen-mt-1 cleen-opacity-[0.72]",ct="cleen-font-medium cleen-text-[13px] cleen-mt-[6px]";function dt(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 at}function Se(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function ut(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var ke=["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 Oe(e){return e!=null}function mt(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 Ae(e,t){return typeof e=="object"&&e!==null?e.title:t}function q(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function Z(e){return typeof e=="object"&&e!==null&&"payload"in e}function Re(e){if(Z(e))return Re(e.payload);if(q(e)||ut(e))return e}function J(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function ve(e){let t=J(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function Pe(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function F(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 o=e.match(/^rgba\(\s*(\d+\s*,\s*\d+\s*,\s*\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);return o?{color:`rgb(${o[1]})`,opacity:Number.parseFloat(o[2])}:{color:e,opacity:1}}function Q(e,t){return F(t??ke[e%ke.length])}function Te(e){return e.length*it}function ft(e){let t=new Set,r=new Set([e.id]);for(let o of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(o.edgeKey),r.add(X(o.source,o.sourceId)),r.add(X(o.target,o.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function gt(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([X(e.source,e.sourceId),X(e.target,e.targetId)])}}function ht(e,t,r,o,u){return!e||e.activeNodeIds.has(t)?1:o?u??I.dimOpacity??.2:r?.55:1}function yt(e,t,r,o,u,f){return e?e.activeLinkKeys.has(t)?o?Math.max(r,.9):r:u?f??I.dimOpacity??.2:o?Math.min(r,.3):r:r}var xt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:o,y:u,width:f,height:g,highlightOnHover:x,hoverState:c,index:C,outgoingEdgesById:T,payload:n,stroke:S,strokeWidth:l})=>{if(n===void 0||o===void 0||u===void 0||f===void 0||g===void 0||C===void 0)return null;let A=T?.get(n.id)??[],N=A.length>0,O=Q(C,n.color),w=F(r),R=ht(c,n.id,x,e,t),d=new Set(A.map(p=>p.color).filter(Oe)),y=Array.from(d)[0],k=N&&A.length>1&&d.size>1&&d.size===A.length,h=k?A:[],a=h.reduce((p,s)=>p+(s.value??0),0);return D(Ne,{children:[k&&a>0?h.map((p,s)=>{let i=h.slice(0,s).reduce((H,B)=>H+(B.value??0),0),m=u+i/a*g,v=(p.value??0)/a*g,L=F(p.color??O.color),E=s===0,_=s===h.length-1;return b(ye,{x:o,y:m,width:f,height:v,fill:L.color,fillOpacity:L.opacity*R,stroke:S,strokeWidth:l,radius:[E?2:0,E?2:0,_?2:0,_?2:0]},`${p.source}-${p.target}-${s}`)}):b(ye,{x:o,y:u,width:f,height:g,fill:N&&d.size===1?F(y??O.color).color:O.color,fillOpacity:(N&&d.size===1?F(y??O.color).opacity:O.opacity)*R,stroke:S,strokeWidth:l,radius:[2,2,2,2]}),b("text",{textAnchor:N?"end":"start",x:N?o-8:o+f+8,y:u+g/2,dy:"0.35em",fontSize:"14",fill:w.color,fillOpacity:w.opacity*R,fontWeight:600,children:n.name})]},`CustomNode${C}`)},bt=({sourceX:e,targetX:t,sourceY:r,targetY:o,sourceControlX:u,targetControlX:f,linkWidth:g,index:x,payload:c,opacity:C,chartId:T,dimOnHover:n,dimOpacity:S,edgeGradientFill:l,highlightOnHover:A,hoverState:N})=>{if(c===void 0||e===void 0||t===void 0||r===void 0||o===void 0||u===void 0||f===void 0||g===void 0)return null;let O=C??I.edgeOpacity??.4,w=yt(N,c.edgeKey,O,A,n,S),R=c.color?F(c.color):null,d=R??Q(typeof c.source=="object"?c.source.index:0,typeof c.source=="object"?c.source.color:void 0),y=R??Q(typeof c.target=="object"?c.target.index:1,typeof c.target=="object"?c.target.color:void 0),k=Pe(`linkGradient-${T}-${c.edgeKey}-${x??c.value}`),h=l!==!1&&R===null;return D(Ne,{children:[h?b("defs",{children:D("linearGradient",{id:k,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[b("stop",{offset:"0%",stopColor:d.color,stopOpacity:d.opacity*w}),b("stop",{offset:"100%",stopColor:y.color,stopOpacity:y.opacity*w})]})}):null,b("path",{d:`
1
+ import{cn as Ie}from"@cleen/ui-core";import{forwardRef as _e}from"react";import{renderToStaticMarkup as Ee}from"react-dom/server";import He from"react-apexcharts";var j={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 re}from"react/jsx-runtime";var Be="[&_.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",oe=_e(function({type:t="line",series:r,options:o={},width:u="100%",height:f=350,className:g,style:x,renderTooltip:c},C){let T=c?{...o.tooltip,custom:(l=>{let A=c({seriesIndex:l.seriesIndex,dataPointIndex:l.dataPointIndex,series:l.series,w:l.w});return A?Ee(A):""})}:o.tooltip,n={...j,...o,chart:{...j.chart,...o.chart,type:t},...T?{tooltip:T}:{}},S=!!n.tooltip?.custom;return re("div",{className:Ie("cleen",S&&Be,g),style:x,children:re(He,{options:n,series:r,type:t,width:u,height:f,ref:C})})}),P=oe;import{applyDefaults as $e}from"@cleen/ui-core";import{forwardRef as Me}from"react";var ne={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 De}from"react/jsx-runtime";var Fe=Me(function({options:t,...r},o){return De(P,{type:"bar",ref:o,options:$e(ne,t??{}),...r})});import{applyDefaults as z}from"@cleen/ui-core";import{forwardRef as ze,useMemo as M}from"react";import{ColorHelpers as $}from"@cleen/ui-core";var ae={marker:{size:2,fillColor:"rgba(var(--cleen-gray), 0.8)",strokeColor:"rgba(var(--cleen-gray), 0.8)",offsetY:-16,shape:"triangle"},label:{borderWidth:0,offsetY:-20,style:{color:"rgba(var(--cleen-gray), 0.8)",background:"transparent",fontSize:"11px"}}},ie={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},le={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},se={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},pe={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[$.getComputedColor("var(--cleen-error)"),$.getComputedColor("var(--cleen-primary)"),$.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[$.getComputedColor("var(--cleen-error)")||"",$.getComputedColor("var(--cleen-primary)")||"",$.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 ce=(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}),de=(e,t,r,o)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:o}),ue=(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 We}from"react/jsx-runtime";var Ge=ze(function({serie:t,labels:r,sigma:o,pointAnnotations:u,rangeAnnotations:f,highlightAnnotations:g,options:x,height:c=360,...C},T){let n=M(()=>t.sort((d,y)=>d.x-y.x),[t]),S=M(()=>{let d=new Map;return t.forEach(y=>d.set(y.x,y.y)),d},[t]),l=n[Math.floor(n.length/2)],A=M(()=>{let{below:d,middle:y,above:k}=t.reduce((h,a)=>(a.x<l.x-2*o?h.below.push(a):a.x>=l.x+2*o?(a.x===l.x+2*o&&h.middle.push(a),h.above.push(a)):(a.x===l.x-2*o&&h.below.push(a),h.middle.push(a)),h),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:d},{name:r?.middle||"Middle grounds",data:y},{name:r?.above||"Above threshold",data:k}]},[o,t,r,l]),N=M(()=>{if(!u)return[];let d=ce(l.x,o);return Object.entries(u).map(([y,k])=>{let h=d[y];return{x:h,y:S.get(h)||0,...z(ae,k)}})},[u,o,S]),O=M(()=>{if(!f)return[];let d=de(l.x,o,n[0].x,n[n.length-1].x);return f.map(y=>{let k=ue(y,d);return{...z(ie,y),...k}})},[f,o,n]),{highlightPointAnnotations:w,highlightLineAnnotations:R}=M(()=>{if(!g)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let d=[],y=[],k=({x:a,line:p})=>{y.push(z(le,{x:a,...p}))},h=({x:a,y:p,point:s})=>{d.push(z(se,{x:a,y:p,...s}))};return g?.forEach(a=>{switch(a.show){case"line":k(a);break;case"point":h(a);break;case"both":k(a),h(a);break;default:break}}),{highlightPointAnnotations:d,highlightLineAnnotations:y}},[g]);return We(P,{series:A,options:{...z(pe,x),annotations:{...x?.annotations,points:[...N,...w,...x?.annotations?.points||[]],xaxis:[...O,...R,...x?.annotations?.xaxis||[]]}},height:c,ref:T,type:"area",...C})});import{applyDefaults as Ue}from"@cleen/ui-core";import{forwardRef as Xe}from"react";var me={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 Ve}from"react/jsx-runtime";var Ke=Xe(function({options:t,...r},o){return Ve(P,{type:"radar",ref:o,options:Ue(me,t),...r})});import{applyDefaults as je,cn as Ye}from"@cleen/ui-core";import{forwardRef as qe}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), 0.8)"}},yaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray), .2)"},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)"}}},xaxis:{axisBorder:{show:!0,color:"rgba(var(--cleen-gray), .2)"},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)"}}},title:{align:"left",floating:!0,style:{color:"rgba(var(--cleen-black))"}}},ge={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), 0.12)",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), 0.8)",fontSize:"14px",fontWeight:400}},labels:{style:{colors:"rgba(var(--cleen-gray), 0.8)",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 G,jsxs as he}from"react/jsx-runtime";var Ze=qe(function({options:t,variant:r="default",rows:o,className:u,style:f,...g},x){let C=je(r==="matrix"?ge:fe,t);if(r==="matrix"&&o?.length){let T=Math.min(...o.map(l=>l.y)),n=Math.max(...o.map(l=>l.y)),S=Array.isArray(C.yaxis)?{}:C.yaxis??{};return he("div",{className:Ye("cleen cleen-grid cleen-grid-cols-[156px_minmax(0,1fr)] cleen-items-stretch cleen-gap-3 cleen-w-full",u),style:f,children:[G("div",{className:"cleen-grid cleen-pt-[18px] cleen-pb-[54px]",style:{gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`},children:o.map(l=>he("div",{className:"cleen-flex cleen-flex-col cleen-justify-center cleen-items-end cleen-gap-1 cleen-pr-2",children:[G("span",{className:"cleen-text-[18px] cleen-font-bold cleen-leading-[1.1] cleen-text-[rgba(var(--cleen-black))]",children:l.label}),l.gapsLabel?G("span",{className:"cleen-text-[14px] cleen-leading-[1.2] cleen-text-[rgba(var(--cleen-gray),0.8)]",children:l.gapsLabel}):null]},`${l.label}-${l.y}`))}),G(P,{type:"scatter",ref:x,className:"cleen-w-full cleen-h-full",options:{...C,yaxis:{...S,min:T-.5,max:n+.5,tickAmount:Math.max(n-T,1),axisBorder:{...S.axisBorder,show:!1},axisTicks:{...S.axisTicks,show:!1},labels:{...S.labels,show:!1}},annotations:{...C.annotations,yaxis:[...o.map(l=>({y:l.y,borderColor:l.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...C.annotations?.yaxis||[]]}},...g})]})}return G(P,{type:"scatter",ref:x,className:u,style:f,options:C,...g})});import{applyDefaults as Je,cn as W}from"@cleen/ui-core";import{useId as Qe,useMemo as U,useRef as et,useState as tt}from"react";import{Layer as Ne,Rectangle as ye,ResponsiveContainer as rt,Sankey as ot,Tooltip as nt}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), 0.2)"};import{Fragment as St,jsx as b,jsxs as D}from"react/jsx-runtime";var at=typeof I.height=="number"?I.height:420,xe=40,be=60,Ce=8,it=8,lt="cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)] cleen-flex cleen-flex-col cleen-gap-2",Y="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-whitespace-pre-line cleen-break-words",st="cleen-font-semibold",pt="cleen-font-medium cleen-text-[13px] cleen-mt-1 cleen-opacity-[0.72]",ct="cleen-font-medium cleen-text-[13px] cleen-mt-[6px]";function dt(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 at}function Se(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function ut(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var ke=["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 Oe(e){return e!=null}function mt(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 Ae(e,t){return typeof e=="object"&&e!==null?e.title:t}function q(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function Z(e){return typeof e=="object"&&e!==null&&"payload"in e}function Re(e){if(Z(e))return Re(e.payload);if(q(e)||ut(e))return e}function J(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function ve(e){let t=J(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function Pe(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function F(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 o=e.match(/^rgba\(\s*(\d+\s*,\s*\d+\s*,\s*\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);return o?{color:`rgb(${o[1]})`,opacity:Number.parseFloat(o[2])}:{color:e,opacity:1}}function Q(e,t){return F(t??ke[e%ke.length])}function Te(e){return e.length*it}function ft(e){let t=new Set,r=new Set([e.id]);for(let o of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(o.edgeKey),r.add(X(o.source,o.sourceId)),r.add(X(o.target,o.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function gt(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([X(e.source,e.sourceId),X(e.target,e.targetId)])}}function ht(e,t,r,o,u){return!e||e.activeNodeIds.has(t)?1:o?u??I.dimOpacity??.2:r?.55:1}function yt(e,t,r,o,u,f){return e?e.activeLinkKeys.has(t)?o?Math.max(r,.9):r:u?f??I.dimOpacity??.2:o?Math.min(r,.3):r:r}var xt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:o,y:u,width:f,height:g,highlightOnHover:x,hoverState:c,index:C,outgoingEdgesById:T,payload:n,stroke:S,strokeWidth:l})=>{if(n===void 0||o===void 0||u===void 0||f===void 0||g===void 0||C===void 0)return null;let A=T?.get(n.id)??[],N=A.length>0,O=Q(C,n.color),w=F(r),R=ht(c,n.id,x,e,t),d=new Set(A.map(p=>p.color).filter(Oe)),y=Array.from(d)[0],k=N&&A.length>1&&d.size>1&&d.size===A.length,h=k?A:[],a=h.reduce((p,s)=>p+(s.value??0),0);return D(Ne,{children:[k&&a>0?h.map((p,s)=>{let i=h.slice(0,s).reduce((H,B)=>H+(B.value??0),0),m=u+i/a*g,v=(p.value??0)/a*g,L=F(p.color??O.color),_=s===0,E=s===h.length-1;return b(ye,{x:o,y:m,width:f,height:v,fill:L.color,fillOpacity:L.opacity*R,stroke:S,strokeWidth:l,radius:[_?2:0,_?2:0,E?2:0,E?2:0]},`${p.source}-${p.target}-${s}`)}):b(ye,{x:o,y:u,width:f,height:g,fill:N&&d.size===1?F(y??O.color).color:O.color,fillOpacity:(N&&d.size===1?F(y??O.color).opacity:O.opacity)*R,stroke:S,strokeWidth:l,radius:[2,2,2,2]}),b("text",{textAnchor:N?"end":"start",x:N?o-8:o+f+8,y:u+g/2,dy:"0.35em",fontSize:"14",fill:w.color,fillOpacity:w.opacity*R,fontWeight:600,children:n.name})]},`CustomNode${C}`)},bt=({sourceX:e,targetX:t,sourceY:r,targetY:o,sourceControlX:u,targetControlX:f,linkWidth:g,index:x,payload:c,opacity:C,chartId:T,dimOnHover:n,dimOpacity:S,edgeGradientFill:l,highlightOnHover:A,hoverState:N})=>{if(c===void 0||e===void 0||t===void 0||r===void 0||o===void 0||u===void 0||f===void 0||g===void 0)return null;let O=C??I.edgeOpacity??.4,w=yt(N,c.edgeKey,O,A,n,S),R=c.color?F(c.color):null,d=R??Q(typeof c.source=="object"?c.source.index:0,typeof c.source=="object"?c.source.color:void 0),y=R??Q(typeof c.target=="object"?c.target.index:1,typeof c.target=="object"?c.target.color:void 0),k=Pe(`linkGradient-${T}-${c.edgeKey}-${x??c.value}`),h=l!==!1&&R===null;return D(Ne,{children:[h?b("defs",{children:D("linearGradient",{id:k,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[b("stop",{offset:"0%",stopColor:d.color,stopOpacity:d.opacity*w}),b("stop",{offset:"100%",stopColor:y.color,stopOpacity:y.opacity*w})]})}):null,b("path",{d:`
2
2
  M${e},${r}
3
3
  C${u},${r} ${f},${o} ${t},${o}
4
- `,stroke:h?`url(#${k})`:d.color,strokeWidth:Math.max(1,g),fill:"none",strokeOpacity:h?1:d.opacity*w,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${c.edgeKey}`)};function Ct({data:e,options:t,className:r,style:o,onNodeClick:u,renderTooltip:f}){let g=et(null),[x,c]=tt(null),C=Qe(),T=Pe(C),n=Je(I,t),S=dt(n.height),l=n.highlightOnHover||n.dimOnHover,A=U(()=>{let a=e.nodes.map((s,i)=>({...s,index:i,name:s.title})),p=e.edges.map((s,i)=>{let m=e.nodes.findIndex(L=>L.id===s.source),v=e.nodes.findIndex(L=>L.id===s.target);return m<0||v<0?null:{...s,edgeKey:mt(s,i),originalEdge:s,source:m,sourceId:s.source,target:v,targetId:s.target,value:s.value}}).filter(Oe);return{nodes:a,links:p}},[e]),N=U(()=>{let a=new Map;for(let p of e.edges){let s=a.get(p.source)??[];s.push(p),a.set(p.source,s)}return a},[e]),O=U(()=>({backgroundColor:n.tooltipBGColor,border:`1px solid ${n.tooltipBorderColor}`,borderRadius:8,boxShadow:"0 12px 32px rgba(15, 23, 42, 0.12)",color:n.fontColor,padding:"10px 12px"}),[n.fontColor,n.tooltipBGColor,n.tooltipBorderColor]),w=U(()=>{let a=new Set(e.edges.map(m=>m.source)),p=new Set(e.edges.map(m=>m.target)),s=e.nodes.reduce((m,v)=>p.has(v.id)?m:Math.max(m,Te(v.title)),0),i=e.nodes.reduce((m,v)=>a.has(v.id)?m:Math.max(m,Te(v.title)),0);return{top:xe,right:Math.max(be,i+Ce+16),bottom:xe,left:Math.max(be,s+Ce+16)}},[e]),R=(a,p)=>{if(l){if(p==="node"&&Se(a.payload)){c(ft(a.payload));return}p==="link"&&q(a.payload)&&c(gt(a.payload))}},d=()=>{l&&c(null)},y=()=>{if(typeof window>"u")return;let a=g.current?.querySelector("svg");if(!a)return;let p=new XMLSerializer().serializeToString(a),s=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(s),m=document.createElement("a");m.href=i,m.download="sankey-chart.svg",m.click(),window.setTimeout(()=>URL.revokeObjectURL(i),0)},k=({active:a,payload:p})=>{if(!a||!p?.length)return null;let s=p[0]?.payload,i=Re(s);if(!i)return null;let m=q(i),v=Z(s)?s.value:p[0]?.value,L=Z(s)?s.name:void 0,E=Number(i.value??v??0),_=n.valueFormatter?n.valueFormatter(Number(i.value??v??0),m?i.originalEdge:void 0):`${i.value??v??""}`,H=m?Ae(i.source,i.sourceId):"",B=m?Ae(i.target,i.targetId):"",K=m?J(i.title,i.label,i.name,i.originalEdge?.title,i.originalEdge?.label,i.originalEdge?.name,ve(L),H&&B?`${H} \u2192 ${B}`:void 0):J(i.title,ve(L)),V=m?`${H} \u2192 ${B}`:"";if(f){let Le=m?{type:"link",edge:i.originalEdge,sourceNodeId:i.sourceId,sourceNodeTitle:H,targetNodeId:i.targetId,targetNodeTitle:B,value:Number.isFinite(E)?E:0,payload:i.originalEdge}:{type:"node",node:i,value:Number.isFinite(E)?E:0,payload:i},te=f(Le);return te?b(St,{children:te}):null}return!K&&!V&&!_?null:D("div",{className:W(lt),style:O,children:[K?b("p",{className:W(Y,st),style:{color:n.fontColor,overflowWrap:"anywhere"},children:K}):null,V?b("p",{className:W(Y,pt),style:{color:n.fontColor,overflowWrap:"anywhere"},children:V}):null,_?b("p",{className:W(Y,ct),style:{color:n.fontColor},children:_}):null]})},h={display:"flex",flexDirection:"column",gap:n.enableToolbar?12:0,width:n.width??"100%",height:S,minHeight:S,...o};return D("div",{className:W("cleen cleen-w-full",r),ref:g,style:h,children:[n.enableToolbar?D("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[b("button",{type:"button",onClick:()=>c(null),disabled:!x,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:x?1:.5,padding:"6px 10px"},children:"Reset focus"}),b("button",{type:"button",onClick:y,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:"pointer",fontSize:13,fontWeight:600,padding:"6px 10px"},children:"Download SVG"})]}):null,b("div",{style:{flex:1,minHeight:0},children:b(rt,{width:"100%",height:"100%",children:b(ot,{data:A,align:n.align,margin:w,node:b(xt,{dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,fontColor:n.fontColor??I.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:n.highlightOnHover,hoverState:x,outgoingEdgesById:N,stroke:n.nodeBorderColor??"transparent",strokeWidth:n.nodeBorderWidth}),nodePadding:n.nodePadding,nodeWidth:n.nodeWidth,link:b(bt,{chartId:T,dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,edgeGradientFill:n.edgeGradientFill,highlightOnHover:n.highlightOnHover,hoverState:x,opacity:n.edgeOpacity}),onClick:(a,p)=>{p==="node"&&u&&Se(a.payload)&&u(a.payload)},onMouseEnter:R,onMouseLeave:d,children:n.enableTooltip?b(nt,{content:b(k,{}),cursor:!1}):null})})})]})}import{applyDefaults as kt}from"@cleen/ui-core";import{forwardRef as At}from"react";var we={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 Tt}from"react/jsx-runtime";var vt=At(function({options:t,...r},o){return Tt(P,{type:"treemap",ref:o,options:kt(we,t??{}),...r})});import"react";import{jsx as ee,jsxs as Ot}from"react/jsx-runtime";var Nt=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:o="",style:u})=>{let f=Math.max(...r,1),g=r.map((x,c)=>`${c/(r.length-1)*e},${t-x/f*t}`).join(" ");return Ot("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:o,style:u,role:"img","aria-label":"Simple line chart",children:[ee("rect",{width:"100%",height:"100%",fill:"transparent"}),ee("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:g,strokeLinecap:"round",strokeLinejoin:"round"}),ee("polygon",{points:`${g} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{Fe as BarChart,Ge as BellCurve,oe as Chart,Ke as RadarChart,Ct as SankeyChart,Ze as ScatterChart,Nt as SimpleChart,vt as TreemapChart};
4
+ `,stroke:h?`url(#${k})`:d.color,strokeWidth:Math.max(1,g),fill:"none",strokeOpacity:h?1:d.opacity*w,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${c.edgeKey}`)};function Ct({data:e,options:t,className:r,style:o,onNodeClick:u,renderTooltip:f}){let g=et(null),[x,c]=tt(null),C=Qe(),T=Pe(C),n=Je(I,t),S=dt(n.height),l=n.highlightOnHover||n.dimOnHover,A=U(()=>{let a=e.nodes.map((s,i)=>({...s,index:i,name:s.title})),p=e.edges.map((s,i)=>{let m=e.nodes.findIndex(L=>L.id===s.source),v=e.nodes.findIndex(L=>L.id===s.target);return m<0||v<0?null:{...s,edgeKey:mt(s,i),originalEdge:s,source:m,sourceId:s.source,target:v,targetId:s.target,value:s.value}}).filter(Oe);return{nodes:a,links:p}},[e]),N=U(()=>{let a=new Map;for(let p of e.edges){let s=a.get(p.source)??[];s.push(p),a.set(p.source,s)}return a},[e]),O=U(()=>({backgroundColor:n.tooltipBGColor,border:`1px solid ${n.tooltipBorderColor}`,borderRadius:8,boxShadow:"0 12px 32px rgba(15, 23, 42, 0.12)",color:n.fontColor,padding:"10px 12px"}),[n.fontColor,n.tooltipBGColor,n.tooltipBorderColor]),w=U(()=>{let a=new Set(e.edges.map(m=>m.source)),p=new Set(e.edges.map(m=>m.target)),s=e.nodes.reduce((m,v)=>p.has(v.id)?m:Math.max(m,Te(v.title)),0),i=e.nodes.reduce((m,v)=>a.has(v.id)?m:Math.max(m,Te(v.title)),0);return{top:xe,right:Math.max(be,i+Ce+16),bottom:xe,left:Math.max(be,s+Ce+16)}},[e]),R=(a,p)=>{if(l){if(p==="node"&&Se(a.payload)){c(ft(a.payload));return}p==="link"&&q(a.payload)&&c(gt(a.payload))}},d=()=>{l&&c(null)},y=()=>{if(typeof window>"u")return;let a=g.current?.querySelector("svg");if(!a)return;let p=new XMLSerializer().serializeToString(a),s=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(s),m=document.createElement("a");m.href=i,m.download="sankey-chart.svg",m.click(),window.setTimeout(()=>URL.revokeObjectURL(i),0)},k=({active:a,payload:p})=>{if(!a||!p?.length)return null;let s=p[0]?.payload,i=Re(s);if(!i)return null;let m=q(i),v=Z(s)?s.value:p[0]?.value,L=Z(s)?s.name:void 0,_=Number(i.value??v??0),E=n.valueFormatter?n.valueFormatter(Number(i.value??v??0),m?i.originalEdge:void 0):`${i.value??v??""}`,H=m?Ae(i.source,i.sourceId):"",B=m?Ae(i.target,i.targetId):"",K=m?J(i.title,i.label,i.name,i.originalEdge?.title,i.originalEdge?.label,i.originalEdge?.name,ve(L),H&&B?`${H} \u2192 ${B}`:void 0):J(i.title,ve(L)),V=m?`${H} \u2192 ${B}`:"";if(f){let Le=m?{type:"link",edge:i.originalEdge,sourceNodeId:i.sourceId,sourceNodeTitle:H,targetNodeId:i.targetId,targetNodeTitle:B,value:Number.isFinite(_)?_:0,payload:i.originalEdge}:{type:"node",node:i,value:Number.isFinite(_)?_:0,payload:i},te=f(Le);return te?b(St,{children:te}):null}return!K&&!V&&!E?null:D("div",{className:W(lt),style:O,children:[K?b("p",{className:W(Y,st),style:{color:n.fontColor,overflowWrap:"anywhere"},children:K}):null,V?b("p",{className:W(Y,pt),style:{color:n.fontColor,overflowWrap:"anywhere"},children:V}):null,E?b("p",{className:W(Y,ct),style:{color:n.fontColor},children:E}):null]})},h={display:"flex",flexDirection:"column",gap:n.enableToolbar?12:0,width:n.width??"100%",height:S,minHeight:S,...o};return D("div",{className:W("cleen cleen-w-full",r),ref:g,style:h,children:[n.enableToolbar?D("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[b("button",{type:"button",onClick:()=>c(null),disabled:!x,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:x?1:.5,padding:"6px 10px"},children:"Reset focus"}),b("button",{type:"button",onClick:y,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:"pointer",fontSize:13,fontWeight:600,padding:"6px 10px"},children:"Download SVG"})]}):null,b("div",{style:{flex:1,minHeight:0},children:b(rt,{width:"100%",height:"100%",children:b(ot,{data:A,align:n.align,margin:w,node:b(xt,{dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,fontColor:n.fontColor??I.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:n.highlightOnHover,hoverState:x,outgoingEdgesById:N,stroke:n.nodeBorderColor??"transparent",strokeWidth:n.nodeBorderWidth}),nodePadding:n.nodePadding,nodeWidth:n.nodeWidth,link:b(bt,{chartId:T,dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,edgeGradientFill:n.edgeGradientFill,highlightOnHover:n.highlightOnHover,hoverState:x,opacity:n.edgeOpacity}),onClick:(a,p)=>{p==="node"&&u&&Se(a.payload)&&u(a.payload)},onMouseEnter:R,onMouseLeave:d,children:n.enableTooltip?b(nt,{content:b(k,{}),cursor:!1}):null})})})]})}import{applyDefaults as kt}from"@cleen/ui-core";import{forwardRef as At}from"react";var we={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 Tt}from"react/jsx-runtime";var vt=At(function({options:t,...r},o){return Tt(P,{type:"treemap",ref:o,options:kt(we,t??{}),...r})});import"react";import{jsx as ee,jsxs as Ot}from"react/jsx-runtime";var Nt=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:o="",style:u})=>{let f=Math.max(...r,1),g=r.map((x,c)=>`${c/(r.length-1)*e},${t-x/f*t}`).join(" ");return Ot("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:o,style:u,role:"img","aria-label":"Simple line chart",children:[ee("rect",{width:"100%",height:"100%",fill:"transparent"}),ee("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:g,strokeLinecap:"round",strokeLinejoin:"round"}),ee("polygon",{points:`${g} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{Fe as BarChart,Ge as BellCurve,oe as Chart,Ke as RadarChart,Ct as SankeyChart,Ze as ScatterChart,Nt as SimpleChart,vt as TreemapChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleen/ui",
3
- "version": "0.1.130",
3
+ "version": "0.1.131",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",