@cleen/ui 0.1.196 → 0.1.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/index.d.ts +9 -3
- package/dist/charts/index.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/charts/index.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
144
|
-
|
|
143
|
+
/** Function to format x-axis labels, e.g. "m" for millions */
|
|
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
|
};
|
package/dist/charts/index.js
CHANGED
|
@@ -1,4 +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 Ve 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 Ke="[&_.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:b=350,className:g,style:C,renderTooltip:p},v){let T=p?{...n.tooltip,custom:(i=>{let x=p({seriesIndex:i.seriesIndex,dataPointIndex:i.dataPointIndex,series:i.series,w:i.w});return x?Xe(x):""})}: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&&Ke,g),style:C,children:ae(Ve,{options:o,series:r,type:t,width:c,height:b,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:b,highlightAnnotations:g,options:C,height:p=360,...v},T){let o=M(()=>t.sort((s,f)=>s.x-f.x),[t]),S=M(()=>{let s=new Map;return t.forEach(f=>s.set(f.x,f.y)),s},[t]),i=o[Math.floor(o.length/2)],x=M(()=>{let{below:s,middle:f,above:y}=t.reduce((u,a)=>(a.x<i.x-2*n?u.below.push(a):a.x>=i.x+2*n?(a.x===i.x+2*n&&u.middle.push(a),u.above.push(a)):(a.x===i.x-2*n&&u.below.push(a),u.middle.push(a)),u),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:s},{name:r?.middle||"Middle grounds",data:f},{name:r?.above||"Above threshold",data:y}]},[n,t,r,i]),O=M(()=>{if(!c)return[];let s=me(i.x,n);return Object.entries(c).map(([f,y])=>{let u=s[f];return{x:u,y:S.get(u)||0,...z(se,y)}})},[c,n,S]),N=M(()=>{if(!b)return[];let s=fe(i.x,n,o[0].x,o[o.length-1].x);return b.map(f=>{let y=he(f,s);return{...z(pe,f),...y}})},[b,n,o]),{highlightPointAnnotations:R,highlightLineAnnotations:l}=M(()=>{if(!g)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let s=[],f=[],y=({x:a,line:h})=>{f.push(z(ce,{x:a,...h}))},u=({x:a,y:h,point:m})=>{s.push(z(de,{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:s,highlightLineAnnotations:f}},[g]);return et(P,{series:x,options:{...z(ue,C),annotations:{...C?.annotations,points:[...O,...R,...C?.annotations?.points||[]],xaxis:[...N,...l,...C?.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:!1}}},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 at}from"react/jsx-runtime";var ot=(e,t)=>{let r=Number(e.toFixed(2));return r===0||!t?`${r}`:`${r}${t}`},nt=rt(function({series:t,highlightRange:r,valueUnit:n,classNames:c,styles:b,options:g,height:C=320,...p},v){let T=Se(()=>t.map(({category:S,from:i,to:x})=>({name:S,data:[{x:S,y:[i,x]}]})),[t]),o=Se(()=>{let S=t.map(x=>x.color??ge),i=t.map(x=>x.striped?"pattern":"solid");return{colors:S,fill:{type:i,opacity:1,pattern:xe},xaxis:{labels:{formatter:x=>ot(Number(x),n)}},...r?{annotations:{xaxis:r.map(({from:x,to:O,color:N,opacity:R})=>({x,x2:O,fillColor:N??ye,opacity:R??.12,borderColor:"transparent"}))}}:{}}},[t,r,n]);return at(P,{type:"rangeBar",ref:v,series:T,options:Ce(Ce(be,o),g??{}),height:C,className:c?.container,style:b?.container,...p})});import{applyDefaults as it}from"@cleen/ui-core";import{forwardRef as lt}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 pt}from"react/jsx-runtime";var st=lt(function({options:t,...r},n){return pt(P,{type:"radar",ref:n,options:it(Ae,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 Ie,Tooltip as ft,Rectangle as ve,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 k,jsxs as D}from"react/jsx-runtime";var yt=typeof I.height=="number"?I.height:420,ke=40,Te=60,Oe=8,xt=8,bt="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",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 Ne(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 Re=["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 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 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)||kt(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??Re[e%Re.length])}function Le(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:C,hoverState:p,index:v,outgoingEdgesById:T,payload:o,stroke:S,strokeWidth:i})=>{if(o===void 0||n===void 0||c===void 0||b===void 0||g===void 0||v===void 0)return null;let x=T?.get(o.id)??[],O=x.length>0,N=te(v,o.color),R=$(r),l=Rt(p,o.id,C,e,t),s=new Set(x.map(h=>h.color).filter(Ee)),f=Array.from(s)[0],y=O&&x.length>1&&s.size>1&&s.size===x.length,u=y?x:[],a=u.reduce((h,m)=>h+(m.value??0),0);return D(Ie,{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=$(h.color??N.color),E=m===0,_=m===u.length-1;return k(ve,{x:n,y:A,width:b,height:w,fill:L.color,fillOpacity:L.opacity*l,stroke:S,strokeWidth:i,radius:[E?2:0,E?2:0,_?2:0,_?2:0]},`${h.source}-${h.target}-${m}`)}):k(ve,{x:n,y:c,width:b,height:g,fill:O&&s.size===1?$(f??N.color).color:N.color,fillOpacity:(O&&s.size===1?$(f??N.color).opacity:N.opacity)*l,stroke:S,strokeWidth:i,radius:[2,2,2,2]}),k("text",{textAnchor:O?"end":"start",x:O?n-8:n+b+8,y:c+g/2,dy:"0.35em",fontSize:"14",fill:R.color,fillOpacity:R.opacity*l,fontWeight:600,children:o.name})]},`CustomNode${v}`)},Lt=({sourceX:e,targetX:t,sourceY:r,targetY:n,sourceControlX:c,targetControlX:b,linkWidth:g,index:C,payload:p,opacity:v,chartId:T,dimOnHover:o,dimOpacity:S,edgeGradientFill:i,highlightOnHover:x,hoverState:O})=>{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 N=v??I.edgeOpacity??.4,R=wt(O,p.edgeKey,N,x,o,S),l=p.color?$(p.color):null,s=l??te(typeof p.source=="object"?p.source.index:0,typeof p.source=="object"?p.source.color:void 0),f=l??te(typeof p.target=="object"?p.target.index:1,typeof p.target=="object"?p.target.color:void 0),y=He(`linkGradient-${T}-${p.edgeKey}-${C??p.value}`),u=i!==!1&&l===null;return D(Ie,{children:[u?k("defs",{children:D("linearGradient",{id:y,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[k("stop",{offset:"0%",stopColor:s.color,stopOpacity:s.opacity*R}),k("stop",{offset:"100%",stopColor:f.color,stopOpacity:f.opacity*R})]})}):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:`
|
|
2
2
|
M${e},${r}
|
|
3
3
|
C${c},${r} ${b},${n} ${t},${n}
|
|
4
|
-
`,stroke:u?`url(#${y})`:s.color,strokeWidth:Math.max(1,g),fill:"none",strokeOpacity:u?1:s.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),[C,p]=mt(null),v=dt(),T=He(v),o=ct(I,t),S=vt(o.height),i=o.highlightOnHover||o.dimOnHover,x=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(Ee);return{nodes:a,links:h}},[e]),O=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]),N=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,Le(w.title)),0),d=e.nodes.reduce((A,w)=>a.has(w.id)?A:Math.max(A,Le(w.title)),0);return{top:ke,right:Math.max(Te,d+Oe+16),bottom:ke,left:Math.max(Te,m+Oe+16)}},[e]),l=(a,h)=>{if(i){if(h==="node"&&Ne(a.payload)){p(Ot(a.payload));return}h==="link"&&J(a.payload)&&p(Nt(a.payload))}},s=()=>{i&&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=_e(m);if(!d)return null;let A=J(d),w=Q(m)?m.value:h[0]?.value,L=Q(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?we(d.source,d.sourceId):"",F=A?we(d.target,d.targetId):"",j=A?ee(d.title,d.label,d.name,d.originalEdge?.title,d.originalEdge?.label,d.originalEdge?.name,Pe(L),H&&F?`${H} \u2192 ${F}`:void 0):ee(d.title,Pe(L)),Y=A?`${H} \u2192 ${F}`:"";if(b){let Ge=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},ne=b(Ge);return ne?k(Et,{children:ne}):null}return!j&&!Y&&!_?null:D("div",{className:G(bt),style:N,children:[j?k("p",{className:G(Z,Ct),style:{color:o.fontColor,overflowWrap:"anywhere"},children:j}):null,Y?k("p",{className:G(Z,St),style:{color:o.fontColor,overflowWrap:"anywhere"},children:Y}):null,_?k("p",{className:G(Z,At),style:{color:o.fontColor},children:_}):null]})},u={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:u,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:!C,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray-200))",borderRadius:8,color:o.fontColor,cursor:C?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:C?1:.5,padding:"6px 10px"},children:"Reset focus"}),k("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,k("div",{style:{flex:1,minHeight:0},children:k(ht,{width:"100%",height:"100%",children:k(gt,{data:x,align:o.align,margin:R,node:k(Pt,{dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,fontColor:o.fontColor??I.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:o.highlightOnHover,hoverState:C,outgoingEdgesById:O,stroke:o.nodeBorderColor??"transparent",strokeWidth:o.nodeBorderWidth}),nodePadding:o.nodePadding,nodeWidth:o.nodeWidth,link:k(Lt,{chartId:T,dimOnHover:o.dimOnHover,dimOpacity:o.dimOpacity,edgeGradientFill:o.edgeGradientFill,highlightOnHover:o.highlightOnHover,hoverState:C,opacity:o.edgeOpacity}),onClick:(a,h)=>{h==="node"&&c&&Ne(a.payload)&&c(a.payload)},onMouseEnter:l,onMouseLeave:s,children:o.enableTooltip?k(ft,{content:k(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 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 Bt=Ft(function({options:t,variant:r="default",rows:n,className:c,style:b,...g},C){let v=_t(r==="matrix"?Be:Fe,t);if(r==="matrix"&&n?.length){let T=Math.min(...n.map(i=>i.y)),o=Math.max(...n.map(i=>i.y)),S=Array.isArray(v.yaxis)?{}:v.yaxis??{};return Me("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(i=>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:i.label}),i.gapsLabel?W("span",{className:"cleen-text-[14px] cleen-leading-[1.2] cleen-text-gray-700",children:i.gapsLabel}):null]},`${i.label}-${i.y}`))}),W(P,{type:"scatter",ref:C,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(i=>({y:i.y,borderColor:i.lineColor||"rgba(var(--cleen-gray-200))",strokeDashArray:0})),...v.annotations?.yaxis||[]]}},...g})]})}return W(P,{type:"scatter",ref:C,className:c,style:b,options:v,...g})});import{applyDefaults as Mt}from"@cleen/ui-core";import{forwardRef as $t,useEffect as De,useMemo as ze,useRef as V,useState as Dt}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 K,jsxs as Gt}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)}),zt=$t(function({options:t,labelLayout:r="apex",renderTileLabel:n,className:c,style:b,...g},C){let p=V(null),[v,T]=Dt([]),o=r==="overlay"&&typeof n=="function",S=V(()=>null);S.current=()=>{let l=p.current;if(!l)return null;let s=l.getBoundingClientRect(),f=l.querySelectorAll(".apexcharts-treemap-rect");return f.length?Array.from(f).map((y,u)=>{let a=y.getBoundingClientRect();return{x:a.left-s.left,y:a.top-s.top,width:a.width,height:a.height,dataIndex:u}}):null};let i=V(0),x=V(()=>{});x.current=()=>{cancelAnimationFrame(i.current);let l=0,s=null,f=()=>{let y=S.current();if(y&&s&&re(s,y)){T(u=>re(u,y)?u:y);return}y&&(s=y),l<30?(l++,i.current=requestAnimationFrame(f)):y&&T(u=>re(u,y)?u:y)};i.current=requestAnimationFrame(f)};let O=ze(()=>{let l=Mt($e,t??{});if(!o)return l;let s=l.chart?.events??{},f=y=>(...u)=>{x.current(),y?.(...u)};return{...l,dataLabels:{...l.dataLabels,enabled:!1},chart:{...l.chart,animations:{enabled:!1},events:{...s,mounted:f(s.mounted),updated:f(s.updated)}}}},[t,o]);De(()=>{if(o)return x.current(),()=>cancelAnimationFrame(i.current)},[o]),De(()=>{if(!o)return;let l=p.current;if(!l||typeof ResizeObserver>"u")return;let s=new ResizeObserver(()=>x.current());return s.observe(l),()=>s.disconnect()},[o]);let N=ze(()=>{let l=g.series;return!Array.isArray(l)||l.length===0?[]:(l[0]??{}).data??[]},[g.series]);if(!o)return K(P,{type:"treemap",ref:C,options:O,className:c,style:b,...g});let R={...b,position:"relative"};return Gt("div",{ref:p,className:c,style:R,children:[K(P,{type:"treemap",ref:C,options:O,...g}),v.length>0&&K("div",{style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"hidden"},children:v.map(l=>K("div",{style:{position:"absolute",left:l.x,top:l.y,width:l.width,height:l.height},children:n({point:N[l.dataIndex],width:l.width,height:l.height})},l.dataIndex))})]})});import"react";import{jsx as oe,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((C,p)=>`${p/(r.length-1)*e},${t-C/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:[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,nt as FootballFieldChart,st as RadarChart,It as SankeyChart,Bt as ScatterChart,Wt as SimpleChart,zt as TreemapChart};
|
|
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/dist/index.d.ts
CHANGED
|
@@ -1960,6 +1960,8 @@ interface DropzoneProps extends NativeInputProps {
|
|
|
1960
1960
|
uploaded?: (totalBytes: number) => ReactNode;
|
|
1961
1961
|
};
|
|
1962
1962
|
showUploadedFiles?: boolean;
|
|
1963
|
+
loadingWhileUploading?: boolean;
|
|
1964
|
+
isLoading?: boolean;
|
|
1963
1965
|
containerRef?: RefObject<HTMLDivElement>;
|
|
1964
1966
|
infoLabels?: InfoLabelsProps;
|
|
1965
1967
|
className?: string;
|