@cleen/ui 0.1.123 → 0.1.125
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 +49 -2
- package/dist/charts/index.js +3 -3
- package/package.json +1 -1
package/dist/charts/index.d.ts
CHANGED
|
@@ -159,14 +159,47 @@ interface SankeyChartOptions {
|
|
|
159
159
|
valueFormatter?: (value: number, edge?: SankeyChartEdge) => string;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
type SankeyTooltipPrimitive = string | number | null | undefined;
|
|
163
|
+
interface SankeyChartTooltipContent {
|
|
164
|
+
tooltipTitle?: SankeyTooltipPrimitive;
|
|
165
|
+
tooltipText?: SankeyTooltipPrimitive;
|
|
166
|
+
tooltipFooter?: SankeyTooltipPrimitive;
|
|
167
|
+
}
|
|
168
|
+
interface SankeyChartTooltipResolverContext {
|
|
169
|
+
type: 'node' | 'link';
|
|
170
|
+
node?: SankeyChartNode;
|
|
171
|
+
edge?: SankeyChartEdge;
|
|
172
|
+
sourceNodeId?: string;
|
|
173
|
+
sourceNodeTitle?: string;
|
|
174
|
+
targetNodeId?: string;
|
|
175
|
+
targetNodeTitle?: string;
|
|
176
|
+
value: number;
|
|
177
|
+
payload: SankeyChartNode | SankeyChartEdge;
|
|
178
|
+
}
|
|
179
|
+
type SankeyChartTooltipResolver = (context: SankeyChartTooltipResolverContext) => SankeyChartTooltipContent | null | undefined;
|
|
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
|
+
}
|
|
162
192
|
interface SankeyChartProps {
|
|
163
193
|
data: SankeyChartData;
|
|
164
194
|
options?: SankeyChartOptions;
|
|
165
195
|
className?: string;
|
|
166
196
|
style?: CSSProperties;
|
|
167
197
|
onNodeClick?: (node: SankeyChartNode) => void;
|
|
198
|
+
getTooltipContent?: SankeyChartTooltipResolver;
|
|
199
|
+
tooltipClassNames?: SankeyChartTooltipClassNames;
|
|
200
|
+
tooltipStyles?: SankeyChartTooltipStyles;
|
|
168
201
|
}
|
|
169
|
-
declare function SankeyChart({ data, options, className, style, onNodeClick, }: SankeyChartProps): react_jsx_runtime.JSX.Element;
|
|
202
|
+
declare function SankeyChart({ data, options, className, style, onNodeClick, getTooltipContent, tooltipClassNames, tooltipStyles, }: SankeyChartProps): react_jsx_runtime.JSX.Element;
|
|
170
203
|
|
|
171
204
|
type TooltipPrimitive = string | number | null | undefined;
|
|
172
205
|
interface TreemapChartTooltipContent {
|
|
@@ -186,8 +219,22 @@ interface TreemapChartTooltipResolverContext {
|
|
|
186
219
|
dataPointIndex: number;
|
|
187
220
|
}
|
|
188
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
|
+
}
|
|
189
234
|
interface TreemapChartProps extends Omit<ChartProps, 'type'> {
|
|
190
235
|
getTooltipContent?: TreemapChartTooltipResolver;
|
|
236
|
+
tooltipStyles?: TreemapChartTooltipStyles;
|
|
237
|
+
tooltipClassNames?: TreemapChartTooltipClassNames;
|
|
191
238
|
}
|
|
192
239
|
declare const TreemapChart: react.ForwardRefExoticComponent<TreemapChartProps & react.RefAttributes<ReactApexChart>>;
|
|
193
240
|
|
|
@@ -200,4 +247,4 @@ type SimpleChartProps = {
|
|
|
200
247
|
};
|
|
201
248
|
declare const SimpleChart: react__default.FC<SimpleChartProps>;
|
|
202
249
|
|
|
203
|
-
export { BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, SankeyChart, type SankeyChartAlign, type SankeyChartData, type SankeyChartEdge, type SankeyChartNode, type SankeyChartOptions, type SankeyChartProps, ScatterChart, type ScatterChartProps, type ScatterChartVariant, SimpleChart, type SimpleChartProps, TreemapChart };
|
|
250
|
+
export { BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, SankeyChart, type SankeyChartAlign, type SankeyChartData, type SankeyChartEdge, type SankeyChartNode, type SankeyChartOptions, type SankeyChartProps, type SankeyChartTooltipClassNames, type SankeyChartTooltipContent, type SankeyChartTooltipResolver, type SankeyChartTooltipResolverContext, type SankeyChartTooltipStyles, ScatterChart, type ScatterChartProps, type ScatterChartVariant, SimpleChart, type SimpleChartProps, TreemapChart, type TreemapChartDataPoint, type TreemapChartProps, type TreemapChartTooltipClassNames, type TreemapChartTooltipContent, type TreemapChartTooltipResolver, type TreemapChartTooltipResolverContext, type TreemapChartTooltipStyles };
|
package/dist/charts/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cn as Ie}from"@cleen/ui-core";import{forwardRef as Le}from"react";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 ee}from"react/jsx-runtime";var te=Le(function({type:t="line",series:r,options:o={},width:d="100%",height:g=350,className:c,style:u},p){let y={...j,...o,chart:{...j.chart,...o.chart,type:t}};return ee("div",{className:Ie("cleen",c),style:u,children:ee(He,{options:y,series:r,type:t,width:d,height:g,ref:p})})}),R=te;import{applyDefaults as z}from"@cleen/ui-core";import{forwardRef as Ee,useMemo as $}from"react";import{ColorHelpers as E}from"@cleen/ui-core";var re={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"}}},oe={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},ne={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},ie={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},ae={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[E.getComputedColor("var(--cleen-error)"),E.getComputedColor("var(--cleen-primary)"),E.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[E.getComputedColor("var(--cleen-error)")||"",E.getComputedColor("var(--cleen-primary)")||"",E.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 se=(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}),le=(e,t,r,o)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:o}),pe=(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 _e}from"react/jsx-runtime";var $e=Ee(function({serie:t,labels:r,sigma:o,pointAnnotations:d,rangeAnnotations:g,highlightAnnotations:c,options:u,height:p=360,...y},n){let x=$(()=>t.sort((f,b)=>f.x-b.x),[t]),S=$(()=>{let f=new Map;return t.forEach(b=>f.set(b.x,b.y)),f},[t]),m=x[Math.floor(x.length/2)],A=$(()=>{let{below:f,middle:b,above:v}=t.reduce((i,a)=>(a.x<m.x-2*o?i.below.push(a):a.x>=m.x+2*o?(a.x===m.x+2*o&&i.middle.push(a),i.above.push(a)):(a.x===m.x-2*o&&i.below.push(a),i.middle.push(a)),i),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:f},{name:r?.middle||"Middle grounds",data:b},{name:r?.above||"Above threshold",data:v}]},[o,t,r,m]),T=$(()=>{if(!d)return[];let f=se(m.x,o);return Object.entries(d).map(([b,v])=>{let i=f[b];return{x:i,y:S.get(i)||0,...z(re,v)}})},[d,o,S]),O=$(()=>{if(!g)return[];let f=le(m.x,o,x[0].x,x[x.length-1].x);return g.map(b=>{let v=pe(b,f);return{...z(oe,b),...v}})},[g,o,x]),{highlightPointAnnotations:P,highlightLineAnnotations:N}=$(()=>{if(!c)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let f=[],b=[],v=({x:a,line:s})=>{b.push(z(ne,{x:a,...s}))},i=({x:a,y:s,point:l})=>{f.push(z(ie,{x:a,y:s,...l}))};return c?.forEach(a=>{switch(a.show){case"line":v(a);break;case"point":i(a);break;case"both":v(a),i(a);break;default:break}}),{highlightPointAnnotations:f,highlightLineAnnotations:b}},[c]);return _e(R,{series:A,options:{...z(ae,u),annotations:{...u?.annotations,points:[...T,...P,...u?.annotations?.points||[]],xaxis:[...O,...N,...u?.annotations?.xaxis||[]]}},height:p,ref:n,type:"area",...y})});import{applyDefaults as Fe}from"@cleen/ui-core";import{forwardRef as ze}from"react";var ce={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 De}from"react/jsx-runtime";var Be=ze(function({options:t,...r},o){return De(R,{type:"radar",ref:o,options:Fe(ce,t),...r})});import{applyDefaults as Me,cn as We}from"@cleen/ui-core";import{forwardRef as Ge}from"react";var de={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))"}}},ue={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 B,jsxs as me}from"react/jsx-runtime";var Ue=Ge(function({options:t,variant:r="default",rows:o,className:d,style:g,...c},u){let y=Me(r==="matrix"?ue:de,t);if(r==="matrix"&&o?.length){let n=Math.min(...o.map(m=>m.y)),x=Math.max(...o.map(m=>m.y)),S=Array.isArray(y.yaxis)?{}:y.yaxis??{};return me("div",{className:We("cleen",d),style:{display:"grid",gridTemplateColumns:"156px minmax(0, 1fr)",alignItems:"stretch",gap:"12px",width:"100%",...g},children:[B("div",{style:{display:"grid",gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`,padding:"18px 0 54px"},children:o.map(m=>me("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-end",gap:"4px",paddingRight:"8px"},children:[B("span",{style:{fontSize:"18px",fontWeight:700,lineHeight:1.1,color:"rgba(var(--cleen-black))"},children:m.label}),m.gapsLabel?B("span",{style:{fontSize:"14px",lineHeight:1.2,color:"rgba(var(--cleen-gray), 0.8)"},children:m.gapsLabel}):null]},`${m.label}-${m.y}`))}),B(R,{type:"scatter",ref:u,className:"cleen-w-full",style:{height:"100%"},options:{...y,yaxis:{...S,min:n-.5,max:x+.5,tickAmount:Math.max(x-n,1),axisBorder:{...S.axisBorder,show:!1},axisTicks:{...S.axisTicks,show:!1},labels:{...S.labels,show:!1}},annotations:{...y.annotations,yaxis:[...o.map(m=>({y:m.y,borderColor:m.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...y.annotations?.yaxis||[]]}},...c})]})}return B(R,{type:"scatter",ref:u,className:d,style:g,options:y,...c})});import{applyDefaults as Xe,cn as je}from"@cleen/ui-core";import{useId as Ke,useMemo as M,useRef as Ve,useState as Ye}from"react";import{Layer as ke,Rectangle as ge,ResponsiveContainer as qe,Sankey as Ze,Tooltip as Je}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{jsx as C,jsxs as F}from"react/jsx-runtime";var Qe=typeof I.height=="number"?I.height:420,fe=40,he=60,ye=8,et=8;function tt(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 Qe}function xe(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}function rt(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e&&"index"in e&&"name"in e}var be=["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 Ae(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 G(e,t){return typeof e=="object"&&e!==null?e.id:t}function Ce(e,t){return typeof e=="object"&&e!==null?e.title:t}function K(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function V(e){return typeof e=="object"&&e!==null&&"payload"in e}function Te(e){if(V(e))return Te(e.payload);if(K(e)||rt(e))return e}function W(...e){return e.map(t=>typeof t=="number"?String(t):t?.trim()??"").find(t=>t.length>0)}function Se(e){let t=W(e);if(t)return/[\p{L}\p{N}]/u.test(t)?t:void 0}function Oe(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 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 Y(e,t){return _(t??be[e%be.length])}function ve(e){return e.length*et}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(G(o.source,o.sourceId)),r.add(G(o.target,o.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function it(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([G(e.source,e.sourceId),G(e.target,e.targetId)])}}function at(e,t,r,o,d){return!e||e.activeNodeIds.has(t)?1:o?d??I.dimOpacity??.2:r?.55:1}function st(e,t,r,o,d,g){return e?e.activeLinkKeys.has(t)?o?Math.max(r,.9):r:d?g??I.dimOpacity??.2:o?Math.min(r,.3):r:r}var lt=({dimOnHover:e,dimOpacity:t,fontColor:r,x:o,y:d,width:g,height:c,highlightOnHover:u,hoverState:p,index:y,outgoingEdgesById:n,payload:x,stroke:S,strokeWidth:m})=>{if(x===void 0||o===void 0||d===void 0||g===void 0||c===void 0||y===void 0)return null;let A=n?.get(x.id)??[],T=A.length>0,O=Y(y,x.color),P=_(r),N=at(p,x.id,u,e,t),f=new Set(A.map(s=>s.color).filter(Ae)),b=Array.from(f)[0],v=T&&A.length>1&&f.size>1&&f.size===A.length,i=v?A:[],a=i.reduce((s,l)=>s+(l.value??0),0);return F(ke,{children:[v&&a>0?i.map((s,l)=>{let h=i.slice(0,l).reduce((U,X)=>U+(X.value??0),0),k=d+h/a*c,w=(s.value??0)/a*c,D=_(s.color??O.color),L=l===0,H=l===i.length-1;return C(ge,{x:o,y:k,width:g,height:w,fill:D.color,fillOpacity:D.opacity*N,stroke:S,strokeWidth:m,radius:[L?2:0,L?2:0,H?2:0,H?2:0]},`${s.source}-${s.target}-${l}`)}):C(ge,{x:o,y:d,width:g,height:c,fill:T&&f.size===1?_(b??O.color).color:O.color,fillOpacity:(T&&f.size===1?_(b??O.color).opacity:O.opacity)*N,stroke:S,strokeWidth:m,radius:[2,2,2,2]}),C("text",{textAnchor:T?"end":"start",x:T?o-8:o+g+8,y:d+c/2,dy:"0.35em",fontSize:"14",fill:P.color,fillOpacity:P.opacity*N,fontWeight:600,children:x.name})]},`CustomNode${y}`)},pt=({sourceX:e,targetX:t,sourceY:r,targetY:o,sourceControlX:d,targetControlX:g,linkWidth:c,index:u,payload:p,opacity:y,chartId:n,dimOnHover:x,dimOpacity:S,edgeGradientFill:m,highlightOnHover:A,hoverState:T})=>{if(p===void 0||e===void 0||t===void 0||r===void 0||o===void 0||d===void 0||g===void 0||c===void 0)return null;let O=y??I.edgeOpacity??.4,P=st(T,p.edgeKey,O,A,x,S),N=p.color?_(p.color):null,f=N??Y(typeof p.source=="object"?p.source.index:0,typeof p.source=="object"?p.source.color:void 0),b=N??Y(typeof p.target=="object"?p.target.index:1,typeof p.target=="object"?p.target.color:void 0),v=Oe(`linkGradient-${n}-${p.edgeKey}-${u??p.value}`),i=m!==!1&&N===null;return F(ke,{children:[i?C("defs",{children:F("linearGradient",{id:v,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[C("stop",{offset:"0%",stopColor:f.color,stopOpacity:f.opacity*P}),C("stop",{offset:"100%",stopColor:b.color,stopOpacity:b.opacity*P})]})}):null,C("path",{d:`
|
|
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:`
|
|
2
2
|
M${e},${r}
|
|
3
|
-
C${
|
|
4
|
-
`,stroke:
|
|
3
|
+
C${a},${r} ${s},${o} ${t},${o}
|
|
4
|
+
`,stroke:b?`url(#${O})`:g.color,strokeWidth:Math.max(1,p),fill:"none",strokeOpacity:b?1:g.opacity*L,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${l.edgeKey}`)};function It({data:e,options:t,className:r,style:o,onNodeClick:a,getTooltipContent:s,tooltipClassNames:p,tooltipStyles:f}){let l=ct(null),[u,C]=dt(null),x=pt(),k=We(x),n=st($,t),d=kt(n.height),N=n.highlightOnHover||n.dimOnHover,R=Z(()=>{let y=e.nodes.map((c,i)=>({...c,index:i,name:c.title})),S=e.edges.map((c,i)=>{let m=e.nodes.findIndex(I=>I.id===c.source),v=e.nodes.findIndex(I=>I.id===c.target);return m<0||v<0?null:{...c,edgeKey:Ot(c,i),originalEdge:c,source:m,sourceId:c.source,target:v,targetId:c.target,value:c.value}}).filter(Be);return{nodes:y,links:S}},[e]),L=Z(()=>{let y=new Map;for(let S of e.edges){let c=y.get(S.source)??[];c.push(S),y.set(S.source,c)}return y},[e]),_=Z(()=>({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]),g=Z(()=>{let y=new Set(e.edges.map(m=>m.source)),S=new Set(e.edges.map(m=>m.target)),c=e.nodes.reduce((m,v)=>S.has(v.id)?m:Math.max(m,Fe(v.title)),0),i=e.nodes.reduce((m,v)=>y.has(v.id)?m:Math.max(m,Fe(v.title)),0);return{top:Le,right:Math.max(Ee,i+Ie+16),bottom:Le,left:Math.max(Ee,c+Ie+16)}},[e]),T=(y,S)=>{if(N){if(S==="node"&&we(y.payload)){C(Nt(y.payload));return}S==="link"&&ne(y.payload)&&C(Pt(y.payload))}},O=()=>{N&&C(null)},b=()=>{if(typeof window>"u")return;let y=l.current?.querySelector("svg");if(!y)return;let S=new XMLSerializer().serializeToString(y),c=new Blob([S],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(c),m=document.createElement("a");m.href=i,m.download="sankey-chart.svg",m.click(),window.setTimeout(()=>URL.revokeObjectURL(i),0)},h=({title:y,text:S,footer:c,titleClassName:i,textClassName:m,footerClassName:v,titleStyle:I,textStyle:W,footerStyle:M})=>!y&&!S&&!c?null:z("div",{className:X(yt,p?.container),style:{..._,...f?.container},children:[y?A("p",{className:X(te,i,p?.title),style:{...re,...I??{},...f?.title},children:y}):null,S?A("p",{className:X(te,m,p?.text),style:{...re,...W??{},...f?.text},children:S}):null,c?A("p",{className:X(te,v,p?.footer),style:{...re,...M??{},...f?.footer},children:c}):null]}),P=({active:y,payload:S})=>{if(!y||!S?.length)return null;let c=S[0]?.payload,i=ze(c);if(!i)return null;let m=ne(i),v=ie(c)?c.value:S[0]?.value,I=ie(c)?c.name:void 0,W=n.valueFormatter?n.valueFormatter(Number(i.value??v??0),m?i.originalEdge:void 0):`${i.value??v??""}`,M=Number(i.value??v??0),K=m?He(i.source,i.sourceId):"",Y=m?He(i.target,i.targetId):"",Xe=J(K&&Y?`${K} \u2192 ${Y}`:void 0),Ve=m?J(i.title,i.label,i.name,i.originalEdge?.title,i.originalEdge?.label,i.originalEdge?.name,Me(I),Xe):J(i.title,Me(I)),je=m?`${K} \u2192 ${Y}`:"";if(s){let Ke=m?{type:"link",edge:i.originalEdge,sourceNodeId:i.sourceId,sourceNodeTitle:K,targetNodeId:i.targetId,targetNodeTitle:Y,value:Number.isFinite(M)?M:0,payload:i.originalEdge}:{type:"node",node:i,value:Number.isFinite(M)?M:0,payload:i},q=s(Ke);if(q!=null){let de=oe(q.tooltipTitle),ue=oe(q.tooltipText),me=oe(q.tooltipFooter);return!de&&!ue&&!me?null:h({title:de,text:ue,footer:me,titleClassName:xt,textClassName:St,footerClassName:Ct})}}return h({title:Ve,text:je,footer:W,titleClassName:bt,textClassName:Tt,footerClassName:At,titleStyle:{color:n.fontColor},textStyle:{color:n.fontColor},footerStyle:{color:n.fontColor}})},E={display:"flex",flexDirection:"column",gap:n.enableToolbar?12:0,width:n.width??"100%",height:d,minHeight:d,...o};return z("div",{className:X("cleen cleen-w-full",r),ref:l,style:E,children:[n.enableToolbar?z("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[A("button",{type:"button",onClick:()=>C(null),disabled:!u,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:u?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:u?1:.5,padding:"6px 10px"},children:"Reset focus"}),A("button",{type:"button",onClick:b,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,A("div",{style:{flex:1,minHeight:0},children:A(ut,{width:"100%",height:"100%",children:A(mt,{data:R,align:n.align,margin:g,node:A(Lt,{dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,fontColor:n.fontColor??$.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:n.highlightOnHover,hoverState:u,outgoingEdgesById:L,stroke:n.nodeBorderColor??"transparent",strokeWidth:n.nodeBorderWidth}),nodePadding:n.nodePadding,nodeWidth:n.nodeWidth,link:A(Et,{chartId:k,dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,edgeGradientFill:n.edgeGradientFill,highlightOnHover:n.highlightOnHover,hoverState:u,opacity:n.edgeOpacity}),onClick:(y,S)=>{S==="node"&&a&&we(y.payload)&&a(y.payload)},onMouseEnter:T,onMouseLeave:O,children:n.enableTooltip?A(ft,{content:A(P,{}),cursor:!1}):null})})})]})}import{applyDefaults as wt,cn as $t}from"@cleen/ui-core";import{forwardRef as Ht}from"react";var Ge={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 qt}from"react/jsx-runtime";var Mt="cleen-relative cleen-z-10 cleen-min-w-[220px] cleen-max-w-[min(360px,90vw)]",Ft="cleen-flex cleen-flex-col cleen-gap-2 cleen-rounded-lg cleen-p-3",Dt="cleen-flex cleen-flex-col cleen-gap-2",se="cleen-m-0 cleen-text-xs cleen-leading-[18px] cleen-break-words",Bt=`${se} cleen-font-semibold cleen-text-[#181D27]`,zt=`${se} cleen-font-medium cleen-text-[#414651]`,Wt=`${se} cleen-font-medium cleen-text-[#9DA4AE]`,Gt="cleen-absolute cleen-left-1/2 cleen-top-full cleen-size-4",Ut=new Set(["fontWeight","lineHeight","opacity","zIndex","flexGrow","flexShrink","order"]),pe=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),V=e=>e?Object.entries(e).map(([t,r])=>{if(r==null||r==="")return"";let o=t.startsWith("--")?t:t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`),a=typeof r=="number"?Ut.has(t)?`${r}`:`${r}px`:`${r}`;return`${o}:${a}`}).filter(Boolean).join(";"):"",H=e=>e?` class="${pe(e)}"`:"",j=e=>e?` style="${pe(e)}"`:"",Xt=e=>String(e??"").trim(),le=e=>{let t=Xt(e);return t?t.split(/\r?\n/).map(r=>pe(r)).join("<br />"):""},Ue=e=>typeof e=="object"&&e!==null,Vt=e=>{let t=Array.isArray(e.w?.config?.series)?e.w.config.series:[],r=e.seriesIndex>=0?t[e.seriesIndex]:void 0,o=Ue(r)?r:void 0,a=o?.data,s=Array.isArray(a)?a:[],p=e.dataPointIndex>=0?s[e.dataPointIndex]:void 0,f=Ue(p)?p:{},l=o?.name;return{point:f,seriesName:typeof l=="string"?l:void 0}},jt=(e,{tooltipStyles:t,tooltipClassNames:r}={})=>{let o=le(e.tooltipTitle),a=le(e.tooltipText),s=le(e.tooltipFooter);if(!o&&!a&&!s)return"";let p=`${Ft} ${r?.container??""}`.trim(),f=`${Bt} ${r?.title??""}`.trim(),l=`${zt} ${r?.text??""}`.trim(),u=`${Wt} ${r?.footer??""}`.trim(),C=V(t?.container),x=V(t?.title),k=V(t?.text),n=V(t?.footer),d=V({transform:"translate(-50%, -8px) rotate(45deg)",backgroundColor:t?.container?.backgroundColor,borderRight:t?.container?.border,borderBottom:t?.container?.border,boxShadow:t?.container?.boxShadow});return`<div${H(Mt)}><div${H(p)}${j(C)}><div${H(Dt)}>${o?`<p${H(f)}${j(x)}>${o}</p>`:""}${a?`<p${H(l)}${j(k)}>${a}</p>`:""}</div>${s?`<p${H(u)}${j(n)}>${s}</p>`:""}</div><div${H(Gt)}${j(d)}></div></div>`},Kt="[&_.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",Yt=Ht(function({options:t,getTooltipContent:r,tooltipStyles:o,tooltipClassNames:a,className:s,...p},f){let l=!t?.tooltip?.custom||!!r,u=l?{...t,tooltip:{...t?.tooltip,custom:(C=>{let x=Number.isInteger(C.seriesIndex)&&C.seriesIndex>=0?C.seriesIndex:-1,k=Number.isInteger(C.dataPointIndex)&&C.dataPointIndex>=0?C.dataPointIndex:-1,{point:n,seriesName:d}=Vt({...C,seriesIndex:x,dataPointIndex:k}),N=r?.({point:n,seriesName:d,seriesIndex:x,dataPointIndex:k})??{tooltipTitle:n.tooltipTitle??n.x,tooltipText:n.tooltipText,tooltipFooter:n.tooltipFooter??n.y};return jt(N,{tooltipStyles:o,tooltipClassNames:a})})}}:t??{};return qt(w,{type:"treemap",ref:f,className:$t(l&&Kt,s),options:wt(Ge,u),...p})});import"react";import{jsx as ce,jsxs as Jt}from"react/jsx-runtime";var Zt=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:o="",style:a})=>{let s=Math.max(...r,1),p=r.map((f,l)=>`${l/(r.length-1)*e},${t-f/s*t}`).join(" ");return Jt("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:o,style:a,role:"img","aria-label":"Simple line chart",children:[ce("rect",{width:"100%",height:"100%",fill:"transparent"}),ce("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:p,strokeLinecap:"round",strokeLinejoin:"round"}),ce("polygon",{points:`${p} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{Qe as BellCurve,ge as Chart,ot as RadarChart,It as SankeyChart,lt as ScatterChart,Zt as SimpleChart,Yt as TreemapChart};
|