@cleen/ui 0.1.67 → 0.1.69

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.
@@ -2,6 +2,7 @@ import * as react from 'react';
2
2
  import react__default, { CSSProperties } from 'react';
3
3
  import { ApexOptions } from 'apexcharts';
4
4
  import ReactApexChart from 'react-apexcharts';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
 
6
7
  interface ChartProps {
7
8
  /**
@@ -100,11 +101,72 @@ declare const BellCurve: react.ForwardRefExoticComponent<BellCurveProps & react.
100
101
  */
101
102
  declare const RadarChart: react.ForwardRefExoticComponent<Omit<ChartProps, "type"> & react.RefAttributes<ReactApexChart>>;
102
103
 
104
+ type ScatterChartVariant = 'default' | 'matrix';
105
+
106
+ interface ScatterChartProps extends Omit<ChartProps, 'type'> {
107
+ variant?: ScatterChartVariant;
108
+ rows?: Array<{
109
+ label: string;
110
+ gapsLabel?: string;
111
+ y: number;
112
+ lineColor?: string;
113
+ }>;
114
+ }
103
115
  /**
104
116
  * Scatter chart component built on ApexCharts
105
117
  * Provides a flexible wrapper for scatter chart visualizations using a predefined set of default styling options.
106
118
  */
107
- declare const ScatterChart: react.ForwardRefExoticComponent<Omit<ChartProps, "type"> & react.RefAttributes<ReactApexChart>>;
119
+ declare const ScatterChart: react.ForwardRefExoticComponent<ScatterChartProps & react.RefAttributes<ReactApexChart>>;
120
+
121
+ type SankeyChartAlign = 'justify' | 'left';
122
+ interface SankeyChartNode {
123
+ id: string;
124
+ title: string;
125
+ color?: string;
126
+ }
127
+ interface SankeyChartEdge {
128
+ source: string;
129
+ target: string;
130
+ value: number;
131
+ type?: string;
132
+ color?: string;
133
+ label?: string;
134
+ }
135
+ interface SankeyChartData {
136
+ nodes: SankeyChartNode[];
137
+ edges: SankeyChartEdge[];
138
+ }
139
+ interface SankeyChartOptions {
140
+ width?: number | string;
141
+ height?: number | string;
142
+ nodeWidth?: number;
143
+ nodePadding?: number;
144
+ nodeBorderWidth?: number;
145
+ nodeBorderColor?: string | null;
146
+ edgeOpacity?: number;
147
+ edgeGradientFill?: boolean;
148
+ enableToolbar?: boolean;
149
+ enableTooltip?: boolean;
150
+ highlightOnHover?: boolean;
151
+ dimOnHover?: boolean;
152
+ dimOpacity?: number;
153
+ fontColor?: string;
154
+ tooltipBGColor?: string;
155
+ tooltipBorderColor?: string;
156
+ align?: SankeyChartAlign;
157
+ valueFormatter?: (value: number, edge?: SankeyChartEdge) => string;
158
+ }
159
+
160
+ interface SankeyChartProps {
161
+ data: SankeyChartData;
162
+ options?: SankeyChartOptions;
163
+ className?: string;
164
+ style?: CSSProperties;
165
+ onNodeClick?: (node: SankeyChartNode) => void;
166
+ }
167
+ declare function SankeyChart({ data, options, className, style, onNodeClick, }: SankeyChartProps): react_jsx_runtime.JSX.Element;
168
+
169
+ declare const TreemapChart: react.ForwardRefExoticComponent<Omit<ChartProps, "type"> & react.RefAttributes<ReactApexChart>>;
108
170
 
109
171
  type SimpleChartProps = {
110
172
  width?: number;
@@ -115,4 +177,4 @@ type SimpleChartProps = {
115
177
  };
116
178
  declare const SimpleChart: react__default.FC<SimpleChartProps>;
117
179
 
118
- export { BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, ScatterChart, SimpleChart, type SimpleChartProps };
180
+ 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 };
@@ -1 +1,4 @@
1
- import{cn as U}from"@cleen/ui-core";import{forwardRef as W}from"react";import Y from"react-apexcharts";var S={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 T}from"react/jsx-runtime";var v=W(function({type:e="line",series:t,options:o={},width:f="100%",height:h=350,className:i,style:s},y){let d={...S,...o,chart:{...S.chart,...o.chart,type:e}};return T("div",{className:U("cleen",i),style:s,children:T(Y,{options:d,series:t,type:e,width:f,height:h,ref:y})})}),g=v;import{applyDefaults as b}from"@cleen/ui-core";import{forwardRef as K,useMemo as A}from"react";import{ColorHelpers as u}from"@cleen/ui-core";var R={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"}}},N={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},w={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},_={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},k={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[u.getComputedColor("var(--cleen-error)"),u.getComputedColor("var(--cleen-primary)"),u.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[u.getComputedColor("var(--cleen-error)")||"",u.getComputedColor("var(--cleen-primary)")||"",u.getComputedColor("var(--cleen-success)")||""],inverseColors:!1,opacityFrom:.95,opacityTo:.6}},yaxis:{show:!1},tooltip:{enabled:!0,x:{formatter:function(r){return`Score: ${typeof r=="string"?Number(r):r}`}},y:{formatter:function(r){return`${Number(r).toFixed(4)}`}}},grid:{show:!1},legend:{show:!1}};var I=(r,e)=>({middle:r,leftSigma:r-e,left2Sigma:r-2*e,left:r-3*e,rightSigma:r+2*e,right2Sigma:r+2*e,right:r+3*e}),H=(r,e,t,o)=>({middle:r,leftSigma:r-e,left2Sigma:r-2*e,left:t,rightSigma:r+e,right2Sigma:r+2*e,right:o}),L=(r,e)=>{let t={};switch(r.type){case"range":t={x:e[r.x],x2:e[r.x2]};break;case"offset":t={x:r.x-r.offset,x2:r.x+r.offset};break;case"region":r.x>=e.left&&r.x<e.left2Sigma?t={x:e.left,x2:e.left2Sigma}:r.x>=e.left2Sigma&&r.x<e.leftSigma?t={x:e.left2Sigma,x2:e.leftSigma}:r.x>=e.leftSigma&&r.x<e.middle?t={x:e.leftSigma,x2:e.middle}:r.x>=e.middle&&r.x<e.rightSigma?t={x:e.middle,x2:e.rightSigma}:r.x>=e.rightSigma&&r.x<e.right2Sigma?t={x:e.rightSigma,x2:e.right2Sigma}:r.x>=e.right2Sigma&&r.x<e.right&&(t={x:e.right2Sigma,x2:e.right});break;default:t={x:r.x,x2:r.x2};break}return t};import{jsx as J}from"react/jsx-runtime";var q=K(function({serie:e,labels:t,sigma:o,pointAnnotations:f,rangeAnnotations:h,highlightAnnotations:i,options:s,height:y=360,...d},X){let x=A(()=>e.sort((l,n)=>l.x-n.x),[e]),P=A(()=>{let l=new Map;return e.forEach(n=>l.set(n.x,n.y)),l},[e]),c=x[Math.floor(x.length/2)],E=A(()=>{let{below:l,middle:n,above:m}=e.reduce((p,a)=>(a.x<c.x-2*o?p.below.push(a):a.x>=c.x+2*o?(a.x===c.x+2*o&&p.middle.push(a),p.above.push(a)):(a.x===c.x-2*o&&p.below.push(a),p.middle.push(a)),p),{below:[],middle:[],above:[]});return[{name:t?.below||"Below threshold",data:l},{name:t?.middle||"Middle grounds",data:n},{name:t?.above||"Above threshold",data:m}]},[o,e,t,c]),D=A(()=>{if(!f)return[];let l=I(c.x,o);return Object.entries(f).map(([n,m])=>{let p=l[n];return{x:p,y:P.get(p)||0,...b(R,m)}})},[f,o,P]),G=A(()=>{if(!h)return[];let l=H(c.x,o,x[0].x,x[x.length-1].x);return h.map(n=>{let m=L(n,l);return{...b(N,n),...m}})},[h,o,x]),{highlightPointAnnotations:$,highlightLineAnnotations:F}=A(()=>{if(!i)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let l=[],n=[],m=({x:a,line:C})=>{n.push(b(w,{x:a,...C}))},p=({x:a,y:C,point:M})=>{l.push(b(_,{x:a,y:C,...M}))};return i?.forEach(a=>{switch(a.show){case"line":m(a);break;case"point":p(a);break;case"both":m(a),p(a);break;default:break}}),{highlightPointAnnotations:l,highlightLineAnnotations:n}},[i]);return J(g,{series:E,options:{...b(k,s),annotations:{...s?.annotations,points:[...D,...$,...s?.annotations?.points||[]],xaxis:[...G,...F,...s?.annotations?.xaxis||[]]}},height:y,ref:X,type:"area",...d})});import{applyDefaults as Q}from"@cleen/ui-core";import{forwardRef as V}from"react";var B={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 j}from"react/jsx-runtime";var Z=V(function({options:e,...t},o){return j(g,{type:"radar",ref:o,options:Q(B,e),...t})});import{applyDefaults as ee}from"@cleen/ui-core";import{forwardRef as re}from"react";var z={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))"}}};import{jsx as oe}from"react/jsx-runtime";var te=re(function({options:e,...t},o){return oe(g,{type:"scatter",ref:o,options:ee(z,e),...t})});import"react";import{jsx as O,jsxs as ne}from"react/jsx-runtime";var ae=({width:r=240,height:e=80,data:t=[12,28,18,30,24,36],className:o="",style:f})=>{let h=Math.max(...t,1),i=t.map((s,y)=>`${y/(t.length-1)*r},${e-s/h*e}`).join(" ");return ne("svg",{width:r,height:e,viewBox:`0 0 ${r} ${e}`,className:o,style:f,role:"img","aria-label":"Simple line chart",children:[O("rect",{width:"100%",height:"100%",fill:"transparent"}),O("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:i,strokeLinecap:"round",strokeLinejoin:"round"}),O("polygon",{points:`${i} ${r},${e} 0,${e}`,fill:"rgba(59,130,246,0.08)"})]})};export{q as BellCurve,v as Chart,Z as RadarChart,te as ScatterChart,ae as SimpleChart};
1
+ import{cn as me}from"@cleen/ui-core";import{forwardRef as he}from"react";import ye from"react-apexcharts";var B={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 W}from"react/jsx-runtime";var X=he(function({type:t="line",series:r,options:o={},width:c="100%",height:u=350,className:d,style:f},p){let y={...B,...o,chart:{...B.chart,...o.chart,type:t}};return W("div",{className:me("cleen",d),style:f,children:W(ye,{options:y,series:r,type:t,width:c,height:u,ref:p})})}),k=X;import{applyDefaults as _}from"@cleen/ui-core";import{forwardRef as be,useMemo as H}from"react";import{ColorHelpers as L}from"@cleen/ui-core";var U={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"}}},K={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},j={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},V={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},Y={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[L.getComputedColor("var(--cleen-error)"),L.getComputedColor("var(--cleen-primary)"),L.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[L.getComputedColor("var(--cleen-error)")||"",L.getComputedColor("var(--cleen-primary)")||"",L.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 q=(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}),Z=(e,t,r,o)=>({middle:e,leftSigma:e-t,left2Sigma:e-2*t,left:r,rightSigma:e+t,right2Sigma:e+2*t,right:o}),J=(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 Se}from"react/jsx-runtime";var xe=be(function({serie:t,labels:r,sigma:o,pointAnnotations:c,rangeAnnotations:u,highlightAnnotations:d,options:f,height:p=360,...y},n){let S=H(()=>t.sort((g,h)=>g.x-h.x),[t]),C=H(()=>{let g=new Map;return t.forEach(h=>g.set(h.x,h.y)),g},[t]),s=S[Math.floor(S.length/2)],A=H(()=>{let{below:g,middle:h,above:l}=t.reduce((i,a)=>(a.x<s.x-2*o?i.below.push(a):a.x>=s.x+2*o?(a.x===s.x+2*o&&i.middle.push(a),i.above.push(a)):(a.x===s.x-2*o&&i.below.push(a),i.middle.push(a)),i),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:g},{name:r?.middle||"Middle grounds",data:h},{name:r?.above||"Above threshold",data:l}]},[o,t,r,s]),O=H(()=>{if(!c)return[];let g=q(s.x,o);return Object.entries(c).map(([h,l])=>{let i=g[h];return{x:i,y:C.get(i)||0,..._(U,l)}})},[c,o,C]),T=H(()=>{if(!u)return[];let g=Z(s.x,o,S[0].x,S[S.length-1].x);return u.map(h=>{let l=J(h,g);return{..._(K,h),...l}})},[u,o,S]),{highlightPointAnnotations:R,highlightLineAnnotations:P}=H(()=>{if(!d)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let g=[],h=[],l=({x:a,line:b})=>{h.push(_(j,{x:a,...b}))},i=({x:a,y:b,point:m})=>{g.push(_(V,{x:a,y:b,...m}))};return d?.forEach(a=>{switch(a.show){case"line":l(a);break;case"point":i(a);break;case"both":l(a),i(a);break;default:break}}),{highlightPointAnnotations:g,highlightLineAnnotations:h}},[d]);return Se(k,{series:A,options:{..._(Y,f),annotations:{...f?.annotations,points:[...O,...R,...f?.annotations?.points||[]],xaxis:[...T,...P,...f?.annotations?.xaxis||[]]}},height:p,ref:n,type:"area",...y})});import{applyDefaults as Ce}from"@cleen/ui-core";import{forwardRef as ve}from"react";var Q={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 Ae}from"react/jsx-runtime";var ke=ve(function({options:t,...r},o){return Ae(k,{type:"radar",ref:o,options:Ce(Q,t),...r})});import{applyDefaults as Oe,cn as Te}from"@cleen/ui-core";import{forwardRef as Ne}from"react";var ee={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))"}}},te={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 E,jsxs as re}from"react/jsx-runtime";var Re=Ne(function({options:t,variant:r="default",rows:o,className:c,style:u,...d},f){let y=Oe(r==="matrix"?te:ee,t);if(r==="matrix"&&o?.length){let n=Math.min(...o.map(s=>s.y)),S=Math.max(...o.map(s=>s.y)),C=Array.isArray(y.yaxis)?{}:y.yaxis??{};return re("div",{className:Te("cleen",c),style:{display:"grid",gridTemplateColumns:"156px minmax(0, 1fr)",alignItems:"stretch",gap:"12px",width:"100%",...u},children:[E("div",{style:{display:"grid",gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`,padding:"18px 0 54px"},children:o.map(s=>re("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-end",gap:"4px",paddingRight:"8px"},children:[E("span",{style:{fontSize:"18px",fontWeight:700,lineHeight:1.1,color:"rgba(var(--cleen-black))"},children:s.label}),s.gapsLabel?E("span",{style:{fontSize:"14px",lineHeight:1.2,color:"rgba(var(--cleen-gray), 0.8)"},children:s.gapsLabel}):null]},`${s.label}-${s.y}`))}),E(k,{type:"scatter",ref:f,className:"cleen-w-full",style:{height:"100%"},options:{...y,yaxis:{...C,min:n-.5,max:S+.5,tickAmount:Math.max(S-n,1),axisBorder:{...C.axisBorder,show:!1},axisTicks:{...C.axisTicks,show:!1},labels:{...C.labels,show:!1}},annotations:{...y.annotations,yaxis:[...o.map(s=>({y:s.y,borderColor:s.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...y.annotations?.yaxis||[]]}},...d})]})}return E(k,{type:"scatter",ref:f,className:c,style:u,options:y,...d})});import{applyDefaults as Pe,cn as we}from"@cleen/ui-core";import{useId as Le,useMemo as z,useRef as He,useState as Ie}from"react";import{Layer as de,Rectangle as _e,ResponsiveContainer as Ee,Sankey as $e,Tooltip as Be}from"recharts";var N={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 x,jsxs as I}from"react/jsx-runtime";var ze=typeof N.height=="number"?N.height:420,oe=40,ne=60,ae=8,De=8;function Me(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 ze}function ie(e){return typeof e=="object"&&e!==null&&"id"in e&&"title"in e}var le=["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 Fe(e){return e!=null}function Ge(e,t){return[e.source,e.target,e.type??"",e.label??"",e.value,t].join("-").replace(/\s+/g,"_")}function $(e,t){return typeof e=="object"&&e!==null?e.id:t}function se(e,t){return typeof e=="object"&&e!==null?e.title:t}function pe(e){return typeof e=="object"&&e!==null&&"edgeKey"in e&&"sourceId"in e&&"targetId"in e}function ue(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function M(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 D(e,t){return M(t??le[e%le.length])}function ce(e){return e.length*De}function We(e){let t=new Set,r=new Set([e.id]);for(let o of[...e.sourceLinks??[],...e.targetLinks??[]])t.add(o.edgeKey),r.add($(o.source,o.sourceId)),r.add($(o.target,o.targetId));return{activeLinkKeys:t,activeNodeIds:r}}function Xe(e){return{activeLinkKeys:new Set([e.edgeKey]),activeNodeIds:new Set([$(e.source,e.sourceId),$(e.target,e.targetId)])}}function Ue(e,t,r,o,c){return!e||e.activeNodeIds.has(t)?1:o?c??N.dimOpacity??.2:r?.55:1}function Ke(e,t,r,o,c,u){return e?e.activeLinkKeys.has(t)?o?Math.max(r,.9):r:c?u??N.dimOpacity??.2:o?Math.min(r,.3):r:r}var je=({dimOnHover:e,dimOpacity:t,fontColor:r,x:o,y:c,width:u,height:d,highlightOnHover:f,hoverState:p,index:y,payload:n,stroke:S,strokeWidth:C})=>{if(n===void 0||o===void 0||c===void 0||u===void 0||d===void 0||y===void 0)return null;let s=(n.sourceLinks?.length??0)===0,A=D(y,n.color),O=M(r),T=Ue(p,n.id,f,e,t);return I(de,{children:[x(_e,{x:o,y:c,width:u,height:d,fill:A.color,fillOpacity:A.opacity*T,stroke:S,strokeWidth:C,radius:[2,2,2,2]}),x("text",{textAnchor:s?"end":"start",x:s?o-8:o+u+8,y:c+d/2,dy:"0.35em",fontSize:"14",fill:O.color,fillOpacity:O.opacity*T,fontWeight:600,children:n.name})]},`CustomNode${y}`)},Ve=({sourceX:e,targetX:t,sourceY:r,targetY:o,sourceControlX:c,targetControlX:u,linkWidth:d,index:f,payload:p,opacity:y,chartId:n,dimOnHover:S,dimOpacity:C,edgeGradientFill:s,highlightOnHover:A,hoverState:O})=>{if(p===void 0||e===void 0||t===void 0||r===void 0||o===void 0||c===void 0||u===void 0||d===void 0)return null;let T=y??N.edgeOpacity??.4,R=Ke(O,p.edgeKey,T,A,S,C),P=p.color?M(p.color):null,g=P??D(typeof p.source=="object"?p.source.index:0,typeof p.source=="object"?p.source.color:void 0),h=P??D(typeof p.target=="object"?p.target.index:1,typeof p.target=="object"?p.target.color:void 0),l=ue(`linkGradient-${n}-${p.edgeKey}-${f??p.value}`),i=s!==!1&&P===null;return I(de,{children:[i?x("defs",{children:I("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[x("stop",{offset:"0%",stopColor:g.color,stopOpacity:g.opacity*R}),x("stop",{offset:"100%",stopColor:h.color,stopOpacity:h.opacity*R})]})}):null,x("path",{d:`
2
+ M${e},${r}
3
+ C${c},${r} ${u},${o} ${t},${o}
4
+ `,stroke:i?`url(#${l})`:g.color,strokeWidth:Math.max(1,d),fill:"none",strokeOpacity:i?1:g.opacity*R,className:"cleen-transition-opacity cleen-duration-300 hover:cleen-opacity-100"})]},`CustomLink${p.edgeKey}`)};function Ye({data:e,options:t,className:r,style:o,onNodeClick:c}){let u=He(null),[d,f]=Ie(null),p=Le(),y=ue(p),n=Pe(N,t),S=Me(n.height),C=n.highlightOnHover||n.dimOnHover,s=z(()=>{let l=e.nodes.map((a,b)=>({...a,index:b,name:a.title})),i=e.edges.map((a,b)=>{let m=e.nodes.findIndex(w=>w.id===a.source),v=e.nodes.findIndex(w=>w.id===a.target);return m<0||v<0?null:{...a,edgeKey:Ge(a,b),originalEdge:a,source:m,sourceId:a.source,target:v,targetId:a.target,value:a.value}}).filter(Fe);return{nodes:l,links:i}},[e]),A=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]),O=z(()=>{let l=new Set(e.edges.map(m=>m.source)),i=new Set(e.edges.map(m=>m.target)),a=e.nodes.reduce((m,v)=>i.has(v.id)?m:Math.max(m,ce(v.title)),0),b=e.nodes.reduce((m,v)=>l.has(v.id)?m:Math.max(m,ce(v.title)),0);return{top:oe,right:Math.max(ne,b+ae+16),bottom:oe,left:Math.max(ne,a+ae+16)}},[e]),T=(l,i)=>{if(C){if(i==="node"&&ie(l.payload)){f(We(l.payload));return}i==="link"&&pe(l.payload)&&f(Xe(l.payload))}},R=()=>{C&&f(null)},P=()=>{if(typeof window>"u")return;let l=u.current?.querySelector("svg");if(!l)return;let i=new XMLSerializer().serializeToString(l),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(a),m=document.createElement("a");m.href=b,m.download="sankey-chart.svg",m.click(),window.setTimeout(()=>URL.revokeObjectURL(b),0)},g=({active:l,payload:i})=>{if(!l||!i?.length)return null;let a=i[0]?.payload;if(!a)return null;let b=pe(a),m=n.valueFormatter?n.valueFormatter(Number(a.value??i[0]?.value??0),b?a.originalEdge:void 0):`${a.value??i[0]?.value??""}`,v=b?se(a.source,a.sourceId):"",w=b?se(a.target,a.targetId):"",ge=b?a.label??`${v} \u2192 ${w}`:a.title,G=b?`${v} \u2192 ${w}`:"";return I("div",{style:A,children:[x("div",{style:{color:n.fontColor,fontWeight:600},children:ge}),G?x("div",{style:{color:n.fontColor,fontSize:13,marginTop:4,opacity:.72},children:G}):null,x("div",{style:{color:n.fontColor,fontSize:13,marginTop:6},children:m})]})},h={display:"flex",flexDirection:"column",gap:n.enableToolbar?12:0,width:n.width??"100%",height:S,minHeight:S,...o};return I("div",{className:we("cleen cleen-w-full",r),ref:u,style:h,children:[n.enableToolbar?I("div",{className:"cleen-flex cleen-items-center cleen-justify-end cleen-gap-2",children:[x("button",{type:"button",onClick:()=>f(null),disabled:!d,style:{backgroundColor:"rgba(var(--cleen-white))",border:"1px solid rgba(var(--cleen-gray), 0.2)",borderRadius:8,color:n.fontColor,cursor:d?"pointer":"not-allowed",fontSize:13,fontWeight:600,opacity:d?1:.5,padding:"6px 10px"},children:"Reset focus"}),x("button",{type:"button",onClick:P,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,x("div",{style:{flex:1,minHeight:0},children:x(Ee,{width:"100%",height:"100%",children:x($e,{data:s,align:n.align,margin:O,node:x(je,{dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,fontColor:n.fontColor??N.fontColor??"rgba(var(--cleen-neutral-800, 38, 38, 38))",highlightOnHover:n.highlightOnHover,hoverState:d,stroke:n.nodeBorderColor??"transparent",strokeWidth:n.nodeBorderWidth}),nodePadding:n.nodePadding,nodeWidth:n.nodeWidth,link:x(Ve,{chartId:y,dimOnHover:n.dimOnHover,dimOpacity:n.dimOpacity,edgeGradientFill:n.edgeGradientFill,highlightOnHover:n.highlightOnHover,hoverState:d,opacity:n.edgeOpacity}),onClick:(l,i)=>{i==="node"&&c&&ie(l.payload)&&c(l.payload)},onMouseEnter:T,onMouseLeave:R,children:n.enableTooltip?x(Be,{content:x(g,{}),cursor:!1}):null})})})]})}import{applyDefaults as qe}from"@cleen/ui-core";import{forwardRef as Ze}from"react";var fe={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 Qe}from"react/jsx-runtime";var Je=Ze(function({options:t,...r},o){return Qe(k,{type:"treemap",ref:o,options:qe(fe,t),...r})});import"react";import{jsx as F,jsxs as tt}from"react/jsx-runtime";var et=({width:e=240,height:t=80,data:r=[12,28,18,30,24,36],className:o="",style:c})=>{let u=Math.max(...r,1),d=r.map((f,p)=>`${p/(r.length-1)*e},${t-f/u*t}`).join(" ");return tt("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,className:o,style:c,role:"img","aria-label":"Simple line chart",children:[F("rect",{width:"100%",height:"100%",fill:"transparent"}),F("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:d,strokeLinecap:"round",strokeLinejoin:"round"}),F("polygon",{points:`${d} ${e},${t} 0,${t}`,fill:"rgba(59,130,246,0.08)"})]})};export{xe as BellCurve,X as Chart,ke as RadarChart,Ye as SankeyChart,Re as ScatterChart,et as SimpleChart,Je as TreemapChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleen/ui",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@cleen/ui-core": "*",
33
33
  "@wavesurfer/react": "^1.0.12",
34
- "apexcharts": "^5.3.0",
34
+ "apexcharts": "^5.10.1",
35
35
  "embla-carousel-auto-scroll": "^8.6.0",
36
36
  "embla-carousel-autoplay": "^8.6.0",
37
37
  "embla-carousel-react": "^8.6.0",
@@ -40,6 +40,7 @@
40
40
  "react-icons": "^5.3.0",
41
41
  "react-select": "^5.10.2",
42
42
  "react-toastify": "^11.0.5",
43
+ "recharts": "^3.8.1",
43
44
  "wavesurfer.js": "^7.12.1"
44
45
  },
45
46
  "peerDependencies": {