@cleen/ui 0.1.68 → 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.
- package/dist/charts/index.d.ts +48 -5
- package/dist/charts/index.js +4 -1
- package/package.json +2 -3
package/dist/charts/index.d.ts
CHANGED
|
@@ -2,7 +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
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
interface ChartProps {
|
|
8
8
|
/**
|
|
@@ -118,10 +118,53 @@ interface ScatterChartProps extends Omit<ChartProps, 'type'> {
|
|
|
118
118
|
*/
|
|
119
119
|
declare const ScatterChart: react.ForwardRefExoticComponent<ScatterChartProps & react.RefAttributes<ReactApexChart>>;
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
type SankeyChartAlign = 'justify' | 'left';
|
|
122
|
+
interface SankeyChartNode {
|
|
123
|
+
id: string;
|
|
124
|
+
title: string;
|
|
125
|
+
color?: string;
|
|
123
126
|
}
|
|
124
|
-
|
|
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;
|
|
125
168
|
|
|
126
169
|
declare const TreemapChart: react.ForwardRefExoticComponent<Omit<ChartProps, "type"> & react.RefAttributes<ReactApexChart>>;
|
|
127
170
|
|
|
@@ -134,4 +177,4 @@ type SimpleChartProps = {
|
|
|
134
177
|
};
|
|
135
178
|
declare const SimpleChart: react__default.FC<SimpleChartProps>;
|
|
136
179
|
|
|
137
|
-
export { BellCurve, type BellCurveProps, Chart, type ChartProps, RadarChart, SankeyChart, type SankeyChartProps, ScatterChart, type ScatterChartProps, type ScatterChartVariant, SimpleChart, type SimpleChartProps, TreemapChart };
|
|
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 };
|
package/dist/charts/index.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{cn as q}from"@cleen/ui-core";import{forwardRef as J}from"react";import Q from"react-apexcharts";var T={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 v}from"react/jsx-runtime";var N=J(function({type:e="line",series:r,options:o={},width:p="100%",height:l=350,className:f,style:x},A){let c={...T,...o,chart:{...T.chart,...o.chart,type:e}};return v("div",{className:q("cleen",f),style:x,children:v(Q,{options:c,series:r,type:e,width:p,height:l,ref:A})})}),g=N;import{applyDefaults as C}from"@cleen/ui-core";import{forwardRef as Z,useMemo as b}from"react";import{ColorHelpers as d}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"}}},w={label:{borderColor:"transparent",style:{color:"rgba(var(--cleen-white))",background:"rgba(var(--cleen-primary))"}},fillColor:"rgba(var(--cleen-primary))"},_={label:{borderWidth:0,offsetY:-15,orientation:"horizontal",style:{color:"rgba(var(--cleen-primary))",background:"transparent",fontSize:"16px",fontWeight:700}},borderColor:"rgba(var(--cleen-primary))"},I={marker:{size:8,fillColor:"rgba(var(--cleen-primary))",strokeColor:"rgba(var(--cleen-white))"}},H={chart:{zoom:{enabled:!1},toolbar:{show:!1},animations:{enabled:!1}},stroke:{curve:"monotoneCubic",width:2.5},colors:[d.getComputedColor("var(--cleen-error)"),d.getComputedColor("var(--cleen-primary)"),d.getComputedColor("var(--cleen-success)")],fill:{type:"gradient",gradient:{shade:"light",type:"vertical",shadeIntensity:.6,gradientToColors:[d.getComputedColor("var(--cleen-error)")||"",d.getComputedColor("var(--cleen-primary)")||"",d.getComputedColor("var(--cleen-success)")||""],inverseColors:!1,opacityFrom:.95,opacityTo:.6}},yaxis:{show:!1},tooltip:{enabled:!0,x:{formatter:function(t){return`Score: ${typeof t=="string"?Number(t):t}`}},y:{formatter:function(t){return`${Number(t).toFixed(4)}`}}},grid:{show:!1},legend:{show:!1}};var L=(t,e)=>({middle:t,leftSigma:t-e,left2Sigma:t-2*e,left:t-3*e,rightSigma:t+2*e,right2Sigma:t+2*e,right:t+3*e}),z=(t,e,r,o)=>({middle:t,leftSigma:t-e,left2Sigma:t-2*e,left:r,rightSigma:t+e,right2Sigma:t+2*e,right:o}),B=(t,e)=>{let r={};switch(t.type){case"range":r={x:e[t.x],x2:e[t.x2]};break;case"offset":r={x:t.x-t.offset,x2:t.x+t.offset};break;case"region":t.x>=e.left&&t.x<e.left2Sigma?r={x:e.left,x2:e.left2Sigma}:t.x>=e.left2Sigma&&t.x<e.leftSigma?r={x:e.left2Sigma,x2:e.leftSigma}:t.x>=e.leftSigma&&t.x<e.middle?r={x:e.leftSigma,x2:e.middle}:t.x>=e.middle&&t.x<e.rightSigma?r={x:e.middle,x2:e.rightSigma}:t.x>=e.rightSigma&&t.x<e.right2Sigma?r={x:e.rightSigma,x2:e.right2Sigma}:t.x>=e.right2Sigma&&t.x<e.right&&(r={x:e.right2Sigma,x2:e.right});break;default:r={x:t.x,x2:t.x2};break}return r};import{jsx as ee}from"react/jsx-runtime";var j=Z(function({serie:e,labels:r,sigma:o,pointAnnotations:p,rangeAnnotations:l,highlightAnnotations:f,options:x,height:A=360,...c},O){let h=b(()=>e.sort((s,i)=>s.x-i.x),[e]),u=b(()=>{let s=new Map;return e.forEach(i=>s.set(i.x,i.y)),s},[e]),a=h[Math.floor(h.length/2)],G=b(()=>{let{below:s,middle:i,above:y}=e.reduce((m,n)=>(n.x<a.x-2*o?m.below.push(n):n.x>=a.x+2*o?(n.x===a.x+2*o&&m.middle.push(n),m.above.push(n)):(n.x===a.x-2*o&&m.below.push(n),m.middle.push(n)),m),{below:[],middle:[],above:[]});return[{name:r?.below||"Below threshold",data:s},{name:r?.middle||"Middle grounds",data:i},{name:r?.above||"Above threshold",data:y}]},[o,e,r,a]),U=b(()=>{if(!p)return[];let s=L(a.x,o);return Object.entries(p).map(([i,y])=>{let m=s[i];return{x:m,y:u.get(m)||0,...C(R,y)}})},[p,o,u]),W=b(()=>{if(!l)return[];let s=z(a.x,o,h[0].x,h[h.length-1].x);return l.map(i=>{let y=B(i,s);return{...C(w,i),...y}})},[l,o,h]),{highlightPointAnnotations:V,highlightLineAnnotations:Y}=b(()=>{if(!f)return{highlightLineAnnotations:[],highlightPointAnnotations:[]};let s=[],i=[],y=({x:n,line:P})=>{i.push(C(_,{x:n,...P}))},m=({x:n,y:P,point:K})=>{s.push(C(I,{x:n,y:P,...K}))};return f?.forEach(n=>{switch(n.show){case"line":y(n);break;case"point":m(n);break;case"both":y(n),m(n);break;default:break}}),{highlightPointAnnotations:s,highlightLineAnnotations:i}},[f]);return ee(g,{series:G,options:{...C(H,x),annotations:{...x?.annotations,points:[...U,...V,...x?.annotations?.points||[]],xaxis:[...W,...Y,...x?.annotations?.xaxis||[]]}},height:A,ref:O,type:"area",...c})});import{applyDefaults as te}from"@cleen/ui-core";import{forwardRef as re}from"react";var D={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 oe=re(function({options:e,...r},o){return ae(g,{type:"radar",ref:o,options:te(D,e),...r})});import{applyDefaults as ne,cn as ie}from"@cleen/ui-core";import{forwardRef as se}from"react";var E={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))"}}},X={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(t){let e=Number(t);return Number.isNaN(e)?`${t}`:`$${Math.round(e)}k`}}},tooltip:{enabled:!0,theme:"light",x:{formatter(t){let e=Number(t);return Number.isNaN(e)?`${t}`:`$${Math.round(e)}k`}}}};import{jsx as S,jsxs as $}from"react/jsx-runtime";var pe=se(function({options:e,variant:r="default",rows:o,className:p,style:l,...f},x){let c=ne(r==="matrix"?X:E,e);if(r==="matrix"&&o?.length){let O=Math.min(...o.map(a=>a.y)),h=Math.max(...o.map(a=>a.y)),u=Array.isArray(c.yaxis)?{}:c.yaxis??{};return $("div",{className:ie("cleen",p),style:{display:"grid",gridTemplateColumns:"156px minmax(0, 1fr)",alignItems:"stretch",gap:"12px",width:"100%",...l},children:[S("div",{style:{display:"grid",gridTemplateRows:`repeat(${o.length}, minmax(0, 1fr))`,padding:"18px 0 54px"},children:o.map(a=>$("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-end",gap:"4px",paddingRight:"8px"},children:[S("span",{style:{fontSize:"18px",fontWeight:700,lineHeight:1.1,color:"rgba(var(--cleen-black))"},children:a.label}),a.gapsLabel?S("span",{style:{fontSize:"14px",lineHeight:1.2,color:"rgba(var(--cleen-gray), 0.8)"},children:a.gapsLabel}):null]},`${a.label}-${a.y}`))}),S(g,{type:"scatter",ref:x,className:"cleen-w-full",style:{height:"100%"},options:{...c,yaxis:{...u,min:O-.5,max:h+.5,tickAmount:Math.max(h-O,1),axisBorder:{...u.axisBorder,show:!1},axisTicks:{...u.axisTicks,show:!1},labels:{...u.labels,show:!1}},annotations:{...c.annotations,yaxis:[...o.map(a=>({y:a.y,borderColor:a.lineColor||"rgba(var(--cleen-gray), 0.12)",strokeDashArray:0})),...c.annotations?.yaxis||[]]}},...f})]})}return S(g,{type:"scatter",ref:x,className:p,style:l,options:c,...f})});import"apexsankey";import{applyDefaults as le,cn as me}from"@cleen/ui-core";import{forwardRef as fe}from"react";import{ApexSankey as xe}from"react-apexsankey";var M={width:"100%",height:420,enableToolbar:!1,enableTooltip:!0,highlightOnHover:!0,dimOnHover:!0,edgeOpacity:.4,nodeWidth:20,fontColor:"rgba(var(--cleen-gray), 0.8)",tooltipBGColor:"rgba(var(--cleen-white))",tooltipBorderColor:"rgba(var(--cleen-gray), 0.2)"};import{jsx as he}from"react/jsx-runtime";var ce=fe(function({options:e,className:r,style:o,...p},l){return he(xe,{ref:l,className:me("cleen",r),style:o,options:le(M,e),...p})});import{applyDefaults as ge}from"@cleen/ui-core";import{forwardRef as ye}from"react";var F={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 Ae}from"react/jsx-runtime";var ue=ye(function({options:e,...r},o){return Ae(g,{type:"treemap",ref:o,options:ge(F,e),...r})});import"react";import{jsx as k,jsxs as be}from"react/jsx-runtime";var de=({width:t=240,height:e=80,data:r=[12,28,18,30,24,36],className:o="",style:p})=>{let l=Math.max(...r,1),f=r.map((x,A)=>`${A/(r.length-1)*t},${e-x/l*e}`).join(" ");return be("svg",{width:t,height:e,viewBox:`0 0 ${t} ${e}`,className:o,style:p,role:"img","aria-label":"Simple line chart",children:[k("rect",{width:"100%",height:"100%",fill:"transparent"}),k("polyline",{fill:"none",stroke:"rgba(59,130,246,0.9)",strokeWidth:2,points:f,strokeLinecap:"round",strokeLinejoin:"round"}),k("polygon",{points:`${f} ${t},${e} 0,${e}`,fill:"rgba(59,130,246,0.08)"})]})};export{j as BellCurve,N as Chart,oe as RadarChart,ce as SankeyChart,pe as ScatterChart,de as SimpleChart,ue as TreemapChart};
|
|
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.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -32,16 +32,15 @@
|
|
|
32
32
|
"@cleen/ui-core": "*",
|
|
33
33
|
"@wavesurfer/react": "^1.0.12",
|
|
34
34
|
"apexcharts": "^5.10.1",
|
|
35
|
-
"apexsankey": "^1.7.1",
|
|
36
35
|
"embla-carousel-auto-scroll": "^8.6.0",
|
|
37
36
|
"embla-carousel-autoplay": "^8.6.0",
|
|
38
37
|
"embla-carousel-react": "^8.6.0",
|
|
39
38
|
"react-apexcharts": "^2.1.0",
|
|
40
|
-
"react-apexsankey": "^1.0.0",
|
|
41
39
|
"react-day-picker": "^9.11.1",
|
|
42
40
|
"react-icons": "^5.3.0",
|
|
43
41
|
"react-select": "^5.10.2",
|
|
44
42
|
"react-toastify": "^11.0.5",
|
|
43
|
+
"recharts": "^3.8.1",
|
|
45
44
|
"wavesurfer.js": "^7.12.1"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|