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