@cleen/ui 0.1.128 → 0.1.130
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 +39 -62
- package/dist/charts/index.js +3 -3
- package/package.json +1 -1
package/dist/charts/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { CSSProperties } from 'react';
|
|
2
|
+
import react__default, { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
import { ApexOptions } from 'apexcharts';
|
|
4
4
|
import ReactApexChart from 'react-apexcharts';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -33,6 +33,17 @@ interface ChartProps {
|
|
|
33
33
|
* Additional CSS style props applied to the wrapper of the chart
|
|
34
34
|
*/
|
|
35
35
|
style?: CSSProperties;
|
|
36
|
+
/**
|
|
37
|
+
* Render the tooltip as a React element; Cleen serializes it via renderToStaticMarkup
|
|
38
|
+
* and resets ApexCharts' default tooltip wrapper styling automatically.
|
|
39
|
+
* Receives the raw ApexCharts tooltip callback arguments.
|
|
40
|
+
*/
|
|
41
|
+
renderTooltip?: (opts: {
|
|
42
|
+
seriesIndex: number;
|
|
43
|
+
dataPointIndex: number;
|
|
44
|
+
series: unknown[];
|
|
45
|
+
w: unknown;
|
|
46
|
+
}) => ReactNode;
|
|
36
47
|
}
|
|
37
48
|
/**
|
|
38
49
|
* Chart component built on ApexCharts
|
|
@@ -40,6 +51,16 @@ interface ChartProps {
|
|
|
40
51
|
*/
|
|
41
52
|
declare const Chart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ReactApexChart>>;
|
|
42
53
|
|
|
54
|
+
type BarChartTooltipResolverContext = NonNullable<Parameters<NonNullable<ChartProps['renderTooltip']>>[0]>;
|
|
55
|
+
type BarChartRenderTooltip = ChartProps['renderTooltip'];
|
|
56
|
+
type BarChartProps = Omit<ChartProps, 'type'>;
|
|
57
|
+
/**
|
|
58
|
+
* Bar chart component built on ApexCharts.
|
|
59
|
+
* Pass `renderTooltip` to return a React element as the tooltip;
|
|
60
|
+
* Chart serializes it via renderToStaticMarkup and resets Apex's default wrapper styling.
|
|
61
|
+
*/
|
|
62
|
+
declare const BarChart: react.ForwardRefExoticComponent<BarChartProps & react.RefAttributes<ReactApexChart>>;
|
|
63
|
+
|
|
43
64
|
type ApexAnnotations = NonNullable<ApexOptions['annotations']>;
|
|
44
65
|
type PointAnnotations = NonNullable<ApexAnnotations['points']>;
|
|
45
66
|
type PointAnnotation = PointAnnotations[number];
|
|
@@ -103,6 +124,8 @@ declare const RadarChart: react.ForwardRefExoticComponent<Omit<ChartProps, "type
|
|
|
103
124
|
|
|
104
125
|
type ScatterChartVariant = 'default' | 'matrix';
|
|
105
126
|
|
|
127
|
+
type ScatterChartTooltipResolverContext = NonNullable<Parameters<NonNullable<ChartProps['renderTooltip']>>[0]>;
|
|
128
|
+
type ScatterChartRenderTooltip = ChartProps['renderTooltip'];
|
|
106
129
|
interface ScatterChartProps extends Omit<ChartProps, 'type'> {
|
|
107
130
|
variant?: ScatterChartVariant;
|
|
108
131
|
rows?: Array<{
|
|
@@ -113,8 +136,10 @@ interface ScatterChartProps extends Omit<ChartProps, 'type'> {
|
|
|
113
136
|
}>;
|
|
114
137
|
}
|
|
115
138
|
/**
|
|
116
|
-
* Scatter chart component built on ApexCharts
|
|
117
|
-
*
|
|
139
|
+
* Scatter chart component built on ApexCharts.
|
|
140
|
+
* Pass `renderTooltip` to return a React element as the tooltip;
|
|
141
|
+
* Chart serializes it via renderToStaticMarkup and resets Apex's default wrapper styling.
|
|
142
|
+
* Use `variant="matrix"` with `rows` to render a labelled matrix layout.
|
|
118
143
|
*/
|
|
119
144
|
declare const ScatterChart: react.ForwardRefExoticComponent<ScatterChartProps & react.RefAttributes<ReactApexChart>>;
|
|
120
145
|
|
|
@@ -159,12 +184,6 @@ interface SankeyChartOptions {
|
|
|
159
184
|
valueFormatter?: (value: number, edge?: SankeyChartEdge) => string;
|
|
160
185
|
}
|
|
161
186
|
|
|
162
|
-
type SankeyTooltipPrimitive = string | number | null | undefined;
|
|
163
|
-
interface SankeyChartTooltipContent {
|
|
164
|
-
tooltipTitle?: SankeyTooltipPrimitive;
|
|
165
|
-
tooltipText?: SankeyTooltipPrimitive;
|
|
166
|
-
tooltipFooter?: SankeyTooltipPrimitive;
|
|
167
|
-
}
|
|
168
187
|
interface SankeyChartTooltipResolverContext {
|
|
169
188
|
type: 'node' | 'link';
|
|
170
189
|
node?: SankeyChartNode;
|
|
@@ -176,66 +195,24 @@ interface SankeyChartTooltipResolverContext {
|
|
|
176
195
|
value: number;
|
|
177
196
|
payload: SankeyChartNode | SankeyChartEdge;
|
|
178
197
|
}
|
|
179
|
-
type
|
|
180
|
-
interface SankeyChartTooltipStyles {
|
|
181
|
-
container?: CSSProperties;
|
|
182
|
-
title?: CSSProperties;
|
|
183
|
-
text?: CSSProperties;
|
|
184
|
-
footer?: CSSProperties;
|
|
185
|
-
}
|
|
186
|
-
interface SankeyChartTooltipClassNames {
|
|
187
|
-
container?: string;
|
|
188
|
-
title?: string;
|
|
189
|
-
text?: string;
|
|
190
|
-
footer?: string;
|
|
191
|
-
}
|
|
198
|
+
type SankeyChartRenderTooltip = (context: SankeyChartTooltipResolverContext) => ReactNode;
|
|
192
199
|
interface SankeyChartProps {
|
|
193
200
|
data: SankeyChartData;
|
|
194
201
|
options?: SankeyChartOptions;
|
|
195
202
|
className?: string;
|
|
196
203
|
style?: CSSProperties;
|
|
197
204
|
onNodeClick?: (node: SankeyChartNode) => void;
|
|
198
|
-
|
|
199
|
-
tooltipClassNames?: SankeyChartTooltipClassNames;
|
|
200
|
-
tooltipStyles?: SankeyChartTooltipStyles;
|
|
205
|
+
renderTooltip?: SankeyChartRenderTooltip;
|
|
201
206
|
}
|
|
202
|
-
declare function SankeyChart({ data, options, className, style, onNodeClick,
|
|
207
|
+
declare function SankeyChart({ data, options, className, style, onNodeClick, renderTooltip, }: SankeyChartProps): react_jsx_runtime.JSX.Element;
|
|
203
208
|
|
|
204
|
-
type
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
x?: TooltipPrimitive;
|
|
212
|
-
y?: TooltipPrimitive;
|
|
213
|
-
[key: string]: unknown;
|
|
214
|
-
}
|
|
215
|
-
interface TreemapChartTooltipResolverContext {
|
|
216
|
-
point: TreemapChartDataPoint;
|
|
217
|
-
seriesName?: string;
|
|
218
|
-
seriesIndex: number;
|
|
219
|
-
dataPointIndex: number;
|
|
220
|
-
}
|
|
221
|
-
type TreemapChartTooltipResolver = (context: TreemapChartTooltipResolverContext) => TreemapChartTooltipContent | null | undefined;
|
|
222
|
-
interface TreemapChartTooltipStyles {
|
|
223
|
-
container?: CSSProperties;
|
|
224
|
-
title?: CSSProperties;
|
|
225
|
-
text?: CSSProperties;
|
|
226
|
-
footer?: CSSProperties;
|
|
227
|
-
}
|
|
228
|
-
interface TreemapChartTooltipClassNames {
|
|
229
|
-
container?: string;
|
|
230
|
-
title?: string;
|
|
231
|
-
text?: string;
|
|
232
|
-
footer?: string;
|
|
233
|
-
}
|
|
234
|
-
interface TreemapChartProps extends Omit<ChartProps, 'type'> {
|
|
235
|
-
getTooltipContent?: TreemapChartTooltipResolver;
|
|
236
|
-
tooltipStyles?: TreemapChartTooltipStyles;
|
|
237
|
-
tooltipClassNames?: TreemapChartTooltipClassNames;
|
|
238
|
-
}
|
|
209
|
+
type TreemapChartRenderTooltip = ChartProps['renderTooltip'];
|
|
210
|
+
type TreemapChartProps = Omit<ChartProps, 'type'>;
|
|
211
|
+
/**
|
|
212
|
+
* Treemap chart component built on ApexCharts.
|
|
213
|
+
* Pass `renderTooltip` to return a React element as the tooltip;
|
|
214
|
+
* Chart serializes it via renderToStaticMarkup and resets Apex's default wrapper styling.
|
|
215
|
+
*/
|
|
239
216
|
declare const TreemapChart: react.ForwardRefExoticComponent<TreemapChartProps & react.RefAttributes<ReactApexChart>>;
|
|
240
217
|
|
|
241
218
|
type SimpleChartProps = {
|
|
@@ -247,4 +224,4 @@ type SimpleChartProps = {
|
|
|
247
224
|
};
|
|
248
225
|
declare const SimpleChart: react__default.FC<SimpleChartProps>;
|
|
249
226
|
|
|
250
|
-
export { BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, SankeyChart, type SankeyChartAlign, type SankeyChartData, type SankeyChartEdge, type SankeyChartNode, type SankeyChartOptions, type SankeyChartProps, type
|
|
227
|
+
export { BarChart, type BarChartProps, type BarChartRenderTooltip, type BarChartTooltipResolverContext, BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, SankeyChart, type SankeyChartAlign, type SankeyChartData, type SankeyChartEdge, type SankeyChartNode, type SankeyChartOptions, type SankeyChartProps, type SankeyChartRenderTooltip, type SankeyChartTooltipResolverContext, ScatterChart, type ScatterChartProps, type ScatterChartRenderTooltip, type ScatterChartTooltipResolverContext, type ScatterChartVariant, SimpleChart, type SimpleChartProps, TreemapChart, type TreemapChartProps, type TreemapChartRenderTooltip };
|
package/dist/charts/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cn as Ye}from"@cleen/ui-core";import{forwardRef as qe}from"react";import Ze from"react-apexcharts";var ee={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 fe}from"react/jsx-runtime";var ge=qe(function({type:t="line",series:r,options:o={},width:a="100%",height:s=350,className:p,style:f},l){let u={...ee,...o,chart:{...ee.chart,...o.chart,type:t}};return fe("div",{className:Ye("cleen",p),style:f,children:fe(Ze,{options:u,series:r,type:t,width:a,height:s,ref:l})})}),w=ge;import{applyDefaults as G}from"@cleen/ui-core";import{forwardRef as Je,useMemo as D}from"react";import{ColorHelpers as F}from"@cleen/ui-core";var he={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"}}},ye={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},xe={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))"}},Ce={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[F.getComputedColor("var(--cleen-error)"),F.getComputedColor("var(--cleen-primary)"),F.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[F.getComputedColor("var(--cleen-error)")||"",F.getComputedColor("var(--cleen-primary)")||"",F.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 be=(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}),Te=(e,t,r,o)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:o}),Ae=(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:o,pointAnnotations:a,rangeAnnotations:s,highlightAnnotations:p,options:f,height:l=360,...u},C){let x=D(()=>t.sort((g,T)=>g.x-T.x),[t]),k=D(()=>{let g=new Map;return t.forEach(T=>g.set(T.x,T.y)),g},[t]),n=x[Math.floor(x.length/2)],d=D(()=>{let{below:g,middle:T,above:O}=t.reduce((b,h)=>(h.x<n.x-2*o?b.below.push(h):h.x>=n.x+2*o?(h.x===n.x+2*o&&b.middle.push(h),b.above.push(h)):(h.x===n.x-2*o&&b.below.push(h),b.middle.push(h)),b),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:g},{name:r?.middle||"Middle grounds",data:T},{name:r?.above||"Above threshold",data:O}]},[o,t,r,n]),N=D(()=>{if(!a)return[];let g=be(n.x,o);return Object.entries(a).map(([T,O])=>{let b=g[T];return{x:b,y:k.get(b)||0,...G(he,O)}})},[a,o,k]),R=D(()=>{if(!s)return[];let g=Te(n.x,o,x[0].x,x[x.length-1].x);return s.map(T=>{let O=Ae(T,g);return{...G(ye,T),...O}})},[s,o,x]),{highlightPointAnnotations:L,highlightLineAnnotations:_}=D(()=>{if(!p)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let g=[],T=[],O=({x:h,line:P})=>{T.push(G(xe,{x:h,...P}))},b=({x:h,y:P,point:E})=>{g.push(G(Se,{x:h,y:P,...E}))};return p?.forEach(h=>{switch(h.show){case"line":O(h);break;case"point":b(h);break;case"both":O(h),b(h);break;default:break}}),{highlightPointAnnotations:g,highlightLineAnnotations:T}},[p]);return et(w,{series:d,options:{...G(Ce,f),annotations:{...f?.annotations,points:[...N,...L,...f?.annotations?.points||[]],xaxis:[...R,..._,...f?.annotations?.xaxis||[]]}},height:l,ref:C,type:"area",...u})});import{applyDefaults as tt}from"@cleen/ui-core";import{forwardRef as rt}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 nt}from"react/jsx-runtime";var ot=rt(function({options:t,...r},o){return nt(w,{type:"radar",ref:o,options:tt(ke,t),...r})});import{applyDefaults as it,cn as Ne}from"@cleen/ui-core";import{forwardRef as at}from"react";var ve={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))"}}},Oe={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 U,jsxs as Re}from"react/jsx-runtime";var Pe="[&_.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",lt=at(function({options:t,variant:r="default",rows:o,className:a,style:s,...p},f){let u=it(r==="matrix"?Oe:ve,t),C=!!u?.tooltip?.custom;if(r==="matrix"&&o?.length){let x=Math.min(...o.map(d=>d.y)),k=Math.max(...o.map(d=>d.y)),n=Array.isArray(u.yaxis)?{}:u.yaxis??{};return Re("div",{className:Ne("cleen",C&&Pe,a),style:{display:"grid",gridTemplateColumns:"156px minmax(0, 1fr)",alignItems:"stretch",gap:"12px",width:"100%",...s},children:[U("div",{style:{display:"grid",gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`,padding:"18px 0 54px"},children:o.map(d=>Re("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-end",gap:"4px",paddingRight:"8px"},children:[U("span",{style:{fontSize:"18px",fontWeight:700,lineHeight:1.1,color:"rgba(var(--cleen-black))"},children:d.label}),d.gapsLabel?U("span",{style:{fontSize:"14px",lineHeight:1.2,color:"rgba(var(--cleen-gray), 0.8)"},children:d.gapsLabel}):null]},`${d.label}-${d.y}`))}),U(w,{type:"scatter",ref:f,className:"cleen-w-full",style:{height:"100%"},options:{...u,yaxis:{...n,min:x-.5,max:k+.5,tickAmount:Math.max(k-x,1),axisBorder:{...n.axisBorder,show:!1},axisTicks:{...n.axisTicks,show:!1},labels:{...n.labels,show:!1}},annotations:{...u.annotations,yaxis:[...o.map(d=>({y:d.y,borderColor:d.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...u.annotations?.yaxis||[]]}},...p})]})}return U(w,{type:"scatter",ref:f,className:Ne(C&&Pe,a),style:s,options:u,...p})});import{applyDefaults as st,cn as X}from"@cleen/ui-core";import{useId as pt,useMemo as Z,useRef as ct,useState as dt}from"react";import{Layer as De,Rectangle as _e,ResponsiveContainer as ut,Sankey as mt,Tooltip as ft}from"recharts";var $={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{jsx as A,jsxs as z}from"react/jsx-runtime";var gt=typeof $.height=="number"?$.height:420,Le=40,Ee=60,Ie=8,ht=8,yt="cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)] cleen-flex cleen-flex-col cleen-gap-2",te="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-whitespace-pre-line cleen-break-words",xt="cleen-font-semibold cleen-text-[#181D27]",St="cleen-font-medium cleen-text-[#414651]",Ct="cleen-font-medium cleen-text-[#9DA4AE]",bt="cleen-font-semibold",Tt="cleen-font-medium cleen-text-[13px] cleen-mt-1 cleen-opacity-[0.72]",At="cleen-font-medium cleen-text-[13px] cleen-mt-[6px]",re={overflowWrap:"anywhere"};function kt(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t=e.trim();if(!t.endsWith("%")&&t!=="auto"){let r=Number.parseFloat(t);if(Number.isFinite(r))return r}}return gt}function we(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function vt(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var $e=["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 Be(e){return e!=null}function Ot(e,t){return[e.source,e.target,e.type??"",e.label??"",e.value,t].join("-").replace(/\s+/g,"_")}function Q(e,t){return typeof e=="object"&&e!==null?e.id:t}function He(e,t){return typeof e=="object"&&e!==null?e.title:t}function ne(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function ie(e){return typeof e=="object"&&e!==null&&"payload"in e}function ze(e){if(ie(e))return ze(e.payload);if(ne(e)||vt(e))return e}function J(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function Me(e){let t=J(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function oe(e){return typeof e=="number"?String(e):e?.trim()??""}function We(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function B(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 ae(e,t){return B(t??$e[e%$e.length])}function Fe(e){return e.length*ht}function Nt(e){let t=new Set,r=new Set([e.id]);for(let o of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(o.edgeKey),r.add(Q(o.source,o.sourceId)),r.add(Q(o.target,o.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function Pt(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([Q(e.source,e.sourceId),Q(e.target,e.targetId)])}}function Rt(e,t,r,o,a){return!e||e.activeNodeIds.has(t)?1:o?a??$.dimOpacity??.2:r?.55:1}function _t(e,t,r,o,a,s){return e?e.activeLinkKeys.has(t)?o?Math.max(r,.9):r:a?s??$.dimOpacity??.2:o?Math.min(r,.3):r:r}var Lt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:o,y:a,width:s,height:p,highlightOnHover:f,hoverState:l,index:u,outgoingEdgesById:C,payload:x,stroke:k,strokeWidth:n})=>{if(x===void 0||o===void 0||a===void 0||s===void 0||p===void 0||u===void 0)return null;let d=C?.get(x.id)??[],N=d.length>0,R=ae(u,x.color),L=B(r),_=Rt(l,x.id,f,e,t),g=new Set(d.map(P=>P.color).filter(Be)),T=Array.from(g)[0],O=N&&d.length>1&&g.size>1&&g.size===d.length,b=O?d:[],h=b.reduce((P,E)=>P+(E.value??0),0);return z(De,{children:[O&&h>0?b.map((P,E)=>{let y=b.slice(0,E).reduce((I,W)=>I+(W.value??0),0),S=a+y/h*p,c=(P.value??0)/h*p,i=B(P.color??R.color),m=E===0,v=E===b.length-1;return A(_e,{x:o,y:S,width:s,height:c,fill:i.color,fillOpacity:i.opacity*_,stroke:k,strokeWidth:n,radius:[m?2:0,m?2:0,v?2:0,v?2:0]},`${P.source}-${P.target}-${E}`)}):A(_e,{x:o,y:a,width:s,height:p,fill:N&&g.size===1?B(T??R.color).color:R.color,fillOpacity:(N&&g.size===1?B(T??R.color).opacity:R.opacity)*_,stroke:k,strokeWidth:n,radius:[2,2,2,2]}),A("text",{textAnchor:N?"end":"start",x:N?o-8:o+s+8,y:a+p/2,dy:"0.35em",fontSize:"14",fill:L.color,fillOpacity:L.opacity*_,fontWeight:600,children:x.name})]},`CustomNode${u}`)},Et=({sourceX:e,targetX:t,sourceY:r,targetY:o,sourceControlX:a,targetControlX:s,linkWidth:p,index:f,payload:l,opacity:u,chartId:C,dimOnHover:x,dimOpacity:k,edgeGradientFill:n,highlightOnHover:d,hoverState:N})=>{if(l===void 0||e===void 0||t===void 0||r===void 0||o===void 0||a===void 0||s===void 0||p===void 0)return null;let R=u??$.edgeOpacity??.4,L=_t(N,l.edgeKey,R,d,x,k),_=l.color?B(l.color):null,g=_??ae(typeof l.source=="object"?l.source.index:0,typeof l.source=="object"?l.source.color:void 0),T=_??ae(typeof l.target=="object"?l.target.index:1,typeof l.target=="object"?l.target.color:void 0),O=We(`linkGradient-${C}-${l.edgeKey}-${f??l.value}`),b=n!==!1&&_===null;return z(De,{children:[b?A("defs",{children:z("linearGradient",{id:O,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[A("stop",{offset:"0%",stopColor:g.color,stopOpacity:g.opacity*L}),A("stop",{offset:"100%",stopColor:T.color,stopOpacity:T.opacity*L})]})}):null,A("path",{d:`
|
|
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:`
|
|
2
2
|
M${e},${r}
|
|
3
|
-
C${
|
|
4
|
-
`,stroke:
|
|
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};
|