@baseline-ui/charts 0.59.0 → 0.60.0
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/index.css +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/index.css
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* This notice may not be removed from this file.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
.ofrh9o0{width:100%;flex:1;min-height:0;position:relative}.ofrh9o0 .recharts-surface{overflow:visible}.ofrh9o0 :focus:not(:focus-visible){outline:none}.ofrh9o0 .recharts-surface:focus-visible{outline:none}.ofrh9o0:has(.recharts-surface:focus-visible):after{content:"";position:absolute;top:0;bottom:0;right:
|
|
10
|
+
.ofrh9o0{width:100%;flex:1;min-height:0;position:relative;direction:ltr}.ofrh9o0 .recharts-surface{overflow:visible}.ofrh9o0 :focus:not(:focus-visible){outline:none}.ofrh9o0 .recharts-surface:focus-visible{outline:none}.ofrh9o0:has(.recharts-surface:focus-visible):after{content:"";position:absolute;top:0;bottom:0;right:calc(-1 * var(--chart-focus-right-overflow, 0px));left:calc(-1 * var(--chart-focus-left-overflow, 0px));outline:2px solid var(--bui-color-focused-default);border-radius:var(--bui-rounded-xs);pointer-events:none}.ofrh9o1{width:100%;list-style:none;margin:0;padding:0;row-gap:var(--bui-spacing-xs);column-gap:var(--bui-spacing-xl)}.ofrh9o2,.ofrh9o3{width:12px;height:12px}._1o5hr0b0{fill:var(--bui-color-text-primary)}._1ojkdm40{fill:var(--bui-color-text-primary)}._1sy8dya0{fill:var(--bui-color-text-oninteractive);pointer-events:none}._1sy8dya1{outline:none}
|
package/dist/index.d.mts
CHANGED
|
@@ -58,6 +58,8 @@ interface ChartBaseProps extends AriaLabelingProps {
|
|
|
58
58
|
showTooltip?: boolean;
|
|
59
59
|
/** Whether to show the legend. */
|
|
60
60
|
showLegend?: boolean;
|
|
61
|
+
/** Defaults to the ambient `I18nProvider` locale direction. */
|
|
62
|
+
dir?: "ltr" | "rtl";
|
|
61
63
|
}
|
|
62
64
|
/** Base props shared by cartesian (axis-bearing) charts. */
|
|
63
65
|
interface CartesianChartBaseProps extends ChartBaseProps {
|
|
@@ -110,7 +112,7 @@ interface BarChartProps extends CartesianChartBaseProps {
|
|
|
110
112
|
barRadius?: number;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
declare function BarChart({ data, bars, xAxisDataKey, variant, barSize, barGap, barRadius, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, ...ariaProps }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare function BarChart({ data, bars, xAxisDataKey, variant, barSize, barGap, barRadius, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, dir, ...ariaProps }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
114
116
|
|
|
115
117
|
type CurveType = NonNullable<LineProps["type"]>;
|
|
116
118
|
interface LineChartLine {
|
|
@@ -143,7 +145,7 @@ interface LineChartProps extends CartesianChartBaseProps {
|
|
|
143
145
|
variant?: LineChartVariant;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
declare function LineChart({ data, lines, xAxisDataKey, variant, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, ...ariaProps }: LineChartProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function LineChart({ data, lines, xAxisDataKey, variant, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, dir, ...ariaProps }: LineChartProps): react_jsx_runtime.JSX.Element;
|
|
147
149
|
|
|
148
150
|
interface PieChartSlice {
|
|
149
151
|
/**
|
|
@@ -171,6 +173,6 @@ interface PieChartProps extends ChartBaseProps {
|
|
|
171
173
|
showLabels?: boolean;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
declare function PieChart({ data, width, height, innerRadius, outerRadius, showTooltip, showLegend, showLabels, className, style, ...ariaProps }: PieChartProps): react_jsx_runtime.JSX.Element;
|
|
176
|
+
declare function PieChart({ data, width, height, innerRadius, outerRadius, showTooltip, showLegend, showLabels, className, style, dir, ...ariaProps }: PieChartProps): react_jsx_runtime.JSX.Element;
|
|
175
177
|
|
|
176
178
|
export { BarChart, type BarChartBar, type BarChartProps, type BarChartVariant, LineChart, type LineChartLine, type LineChartProps, type LineChartVariant, PieChart, type PieChartProps, type PieChartSlice };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ interface ChartBaseProps extends AriaLabelingProps {
|
|
|
58
58
|
showTooltip?: boolean;
|
|
59
59
|
/** Whether to show the legend. */
|
|
60
60
|
showLegend?: boolean;
|
|
61
|
+
/** Defaults to the ambient `I18nProvider` locale direction. */
|
|
62
|
+
dir?: "ltr" | "rtl";
|
|
61
63
|
}
|
|
62
64
|
/** Base props shared by cartesian (axis-bearing) charts. */
|
|
63
65
|
interface CartesianChartBaseProps extends ChartBaseProps {
|
|
@@ -110,7 +112,7 @@ interface BarChartProps extends CartesianChartBaseProps {
|
|
|
110
112
|
barRadius?: number;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
declare function BarChart({ data, bars, xAxisDataKey, variant, barSize, barGap, barRadius, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, ...ariaProps }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare function BarChart({ data, bars, xAxisDataKey, variant, barSize, barGap, barRadius, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, dir, ...ariaProps }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
114
116
|
|
|
115
117
|
type CurveType = NonNullable<LineProps["type"]>;
|
|
116
118
|
interface LineChartLine {
|
|
@@ -143,7 +145,7 @@ interface LineChartProps extends CartesianChartBaseProps {
|
|
|
143
145
|
variant?: LineChartVariant;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
declare function LineChart({ data, lines, xAxisDataKey, variant, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, ...ariaProps }: LineChartProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function LineChart({ data, lines, xAxisDataKey, variant, width, height, showTooltip, showLegend, showGrid, showXAxis, showYAxis, className, style, dir, ...ariaProps }: LineChartProps): react_jsx_runtime.JSX.Element;
|
|
147
149
|
|
|
148
150
|
interface PieChartSlice {
|
|
149
151
|
/**
|
|
@@ -171,6 +173,6 @@ interface PieChartProps extends ChartBaseProps {
|
|
|
171
173
|
showLabels?: boolean;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
declare function PieChart({ data, width, height, innerRadius, outerRadius, showTooltip, showLegend, showLabels, className, style, ...ariaProps }: PieChartProps): react_jsx_runtime.JSX.Element;
|
|
176
|
+
declare function PieChart({ data, width, height, innerRadius, outerRadius, showTooltip, showLegend, showLabels, className, style, dir, ...ariaProps }: PieChartProps): react_jsx_runtime.JSX.Element;
|
|
175
177
|
|
|
176
178
|
export { BarChart, type BarChartBar, type BarChartProps, type BarChartVariant, LineChart, type LineChartLine, type LineChartProps, type LineChartVariant, PieChart, type PieChartProps, type PieChartSlice };
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* This notice may not be removed from this file.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
var ee="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z6jg _1yep5z6jh _1yep5z6ji",te="ofrh9o1 _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j1 _1yep5z6j2 _1yep5z6j3 _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z6le",re="_1yep5z6iv _1yep5z6iw _1yep5z6ix _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",oe="ofrh9o2 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk",ne="ofrh9o0",ae="_1yep5z66 _1yep5z67 _1yep5z68 _1yep5z62i _1yep5z62j _1yep5z62k _1yep5z63o _1yep5z63p _1yep5z63q _1yep5z61c _1yep5z61d _1yep5z61e _1yep5z6al _1yep5z6am _1yep5z6an _1yep5z6b9 _1yep5z6ba _1yep5z6bb _1yep5z6bx _1yep5z6by _1yep5z6bz _1yep5z6cl _1yep5z6cm _1yep5z6cn _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69f _1yep5z69g _1yep5z69h _1yep5z6lz _1yep5z6m1 _1yep5z6g1 _1yep5z6h4 _1yep5z6d7",se="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",ie="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69c _1yep5z69d _1yep5z69e",le="ofrh9o3 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk";function S({rootClassName:e,className:t,style:o,width:r,height:n,variant:a,legend:s,surfaceRef:f,surfaceStyle:i,children:u,...l}){return jsxRuntime.jsxs("div",{...l,className:core.classNames(ee,e,t),"data-variant":a,style:{width:r,height:n,...o},children:[s,jsxRuntime.jsx("div",{ref:f,className:core.classNames(ne,"BaselineUI-Chart-Surface"),style:i,children:u})]})}function P({series:e,resolveColor:t,paddingLeft:o}){return jsxRuntime.jsx("ul",{className:`${te} BaselineUI-Chart-Legend`,style:o==null?void 0:{paddingLeft:o},children:e.map((r,n)=>jsxRuntime.jsxs("li",{className:`${re} BaselineUI-Chart-LegendItem`,children:[jsxRuntime.jsx("span",{className:`${oe} BaselineUI-Chart-LegendSwatch`,style:{backgroundColor:t(r,n)}}),jsxRuntime.jsx(core.Text,{type:"label",size:"sm",children:r.name??r.dataKey})]},r.dataKey))})}var Ee=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},ke=(e,t)=>{if(!t)return e;let o=Ee(e);return o==null?(process.env.NODE_ENV!=="production"&&e!=null&&core.devWarnOnce("ChartTooltip:nonNumeric",`[ChartTooltip] \`formatterProps\` was provided but a non-numeric value was received (got ${JSON.stringify(e)}). The value will render unformatted.`),e):jsxRuntime.jsx(core.NumberFormat,{value:o,...t})};function N({active:e,payload:t,label:o,formatterProps:r}){return !e||!t?.length?null:jsxRuntime.jsxs("div",{className:`${ae} BaselineUI-Chart-Tooltip`,children:[o==null?null:jsxRuntime.jsx(core.Text,{elementType:"div",type:"label",size:"sm",children:String(o)}),jsxRuntime.jsx("div",{className:ie,children:t.map(n=>jsxRuntime.jsxs("div",{className:`${se} BaselineUI-Chart-TooltipItem`,children:[jsxRuntime.jsx("span",{className:`${le} BaselineUI-Chart-TooltipSwatch`,style:{backgroundColor:n.color}}),jsxRuntime.jsxs(core.Text,{type:"label",size:"sm",children:[n.name,": ",ke(n.value,r)]})]},String(n.dataKey)))})]})}function R(e,t){let o=null,r=()=>{o==null&&(o=requestAnimationFrame(()=>{o=null,t();}));};t();let n=new ResizeObserver(r);n.observe(e);let a=new MutationObserver(r);return a.observe(e,{childList:true,subtree:true}),()=>{o!=null&&cancelAnimationFrame(o),n.disconnect(),a.disconnect();}}var ue=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function O(e){let[t,o]=react.useState(0);return react.useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelectorAll(ue);if(i.length===0){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[useLeftmostYAxisLabelOffset] Could not find "${ue}" \u2014 Recharts may have renamed its internals. Legend will fall back to flush-left alignment.`)),o(0);return}n=true;let u=r.getBoundingClientRect().left,l=1/0;for(let C of i)l=Math.min(l,C.getBoundingClientRect().left);if(!Number.isFinite(l)){o(0);return}o(Math.max(0,l-u));})},[e]),t}var me=".recharts-cartesian-grid";function q(e){let[t,o]=react.useState(0);return react.useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelector(me);if(!i){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[usePlotAreaWidth] Could not find "${me}" \u2014 Recharts may have renamed its internals. Bar layouts will fall back to requested sizes.`));return}n=true;let u=i.getBoundingClientRect().width;o(l=>Math.abs(l-u)<.5?l:u);})},[e]),t}var fe=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function D(e){let[t,o]=react.useState(0);return react.useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelectorAll(fe);if(i.length===0){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[useYAxisLeftOverflow] Could not find "${fe}" \u2014 Recharts may have renamed its internals. The focus outline will not extend over overflowing axis labels.`)),o(0);return}n=true;let u=r.getBoundingClientRect().left,l=1/0;for(let h of i)l=Math.min(l,h.getBoundingClientRect().left);if(!Number.isFinite(l)){o(0);return}let C=Math.max(0,Math.ceil(u-l));o(h=>h===C?h:C);})},[e]),t}var H="_1o5hr0b0 _1yep5z6dy",de="_1yep5z69r _1yep5z69s _1yep5z69t";var W=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.warning.medium,tokens.themeVars.color.support.error.medium],Xe=12,Je=2,Ze=4,M=1,Qe={width:1,height:1},et=({plotWidth:e,categoryCount:t,barCount:o,barSize:r,barGap:n})=>{if(e<=0||t<=0||o<=0)return {barSize:r,barGap:n};let a=e/t-M,s=o-1;if(o*r+s*n<=a)return {barSize:r,barGap:n};let i=o*r+s*M;if(s>0&&i<=a){let l=Math.floor((a-o*r)/s);return {barSize:r,barGap:Math.max(M,l)}}let u=Math.floor((a-s*M)/o);return {barSize:Math.max(1,u),barGap:M}},ye=(e,t)=>e.color??W[t%W.length],tt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>W.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("BarChart:paletteWrap",`[BarChart] More than ${W.length} bar series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each bar.`);},X=(e,t)=>{if(e.stackId!=null)return e.stackId;if(t==="stacked")return "default"},rt=(e,t)=>{let o=new Map,r=new Map;for(let[n,a]of e.entries()){let s=X(a,t);s==null?o.set(n,true):r.set(s,n);}for(let n of r.values())o.set(n,true);return o},Ce=false,ot=({offset:e,xAxis:t})=>{process.env.NODE_ENV!=="production"&&!Ce&&(!e||!t||typeof t.scale?.domain!="function")&&(Ce=true,console.warn("[BarChart] Recharts passed an unexpected shape to verticalCoordinatesGenerator (missing offset/xAxis/scale.domain). Vertical grid lines will not render \u2014 likely caused by a Recharts upgrade."));let o=t?.scale?.domain?.(),r=Array.isArray(o)?o.length:0,n=e?.width??0;if(r===0||n===0)return [];let a=e?.left??0,s=n/r;return Array.from({length:r},(f,i)=>a+s*(i+1))};function nt({data:e,bars:t,xAxisDataKey:o,variant:r="default",barSize:n=Xe,barGap:a=Ze,barRadius:s=Je,width:f="100%",height:i=300,showTooltip:u=true,showLegend:l=false,showGrid:C=true,showXAxis:h=true,showYAxis:E=true,className:d,style:k,...I}){tt(t);let c=react.useRef(null),m=O(c),b=q(c),T=D(c),p=react.useMemo(()=>rt(t,r),[t,r]),_=react.useMemo(()=>{let y=new Set,B=0;for(let Q of t){let j=X(Q,r);j==null?B+=1:y.add(j);}return B+y.size},[t,r]),{barSize:$,barGap:v}=et({plotWidth:b,categoryCount:e.length,barCount:_,barSize:n,barGap:a});return jsxRuntime.jsx(S,{...I,rootClassName:core.classNames("BaselineUI-BarChart",de),className:d,style:k,width:f,height:i,variant:r,legend:l?jsxRuntime.jsx(P,{series:t,resolveColor:ye,paddingLeft:m}):null,surfaceRef:c,surfaceStyle:{"--chart-focus-left-overflow":`${T}px`},children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:Qe,children:jsxRuntime.jsxs(recharts.BarChart,{accessibilityLayer:true,barGap:v,data:e,children:[C?jsxRuntime.jsx(recharts.CartesianGrid,{stroke:tokens.themeVars.color.border.strong,strokeDasharray:"3 3",verticalCoordinatesGenerator:ot}):null,h?jsxRuntime.jsx(recharts.XAxis,{dataKey:o,stroke:tokens.themeVars.color.border.inverse,tick:{className:H}}):null,E?jsxRuntime.jsx(recharts.YAxis,{stroke:tokens.themeVars.color.border.inverse,tick:{className:H}}):null,u?jsxRuntime.jsx(recharts.Tooltip,{content:N,cursor:{fill:tokens.themeVars.color.background.overlay.interactive}}):null,t.map((y,B)=>{let j=p.get(B)??false?[s,s,0,0]:[0,0,0,0];return jsxRuntime.jsx(recharts.Bar,{barSize:$,dataKey:y.dataKey,fill:ye(y,B),name:y.name??y.dataKey,radius:j,stackId:X(y,r)},y.dataKey)})]})})})}var J="_1ojkdm40 _1yep5z6dy",_e="_1yep5z69r _1yep5z69s _1yep5z69t";var U=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.warning.medium,tokens.themeVars.color.support.error.medium],F={width:40,height:20,strokeWidth:1,margin:{top:1,right:1,bottom:1,left:1}},yt={width:1,height:1},Z=(e,t)=>e.color??U[t%U.length],Ct=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>U.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("LineChart:paletteWrap",`[LineChart] More than ${U.length} line series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each line.`);};function _t({data:e,lines:t,xAxisDataKey:o,variant:r="default",width:n,height:a,showTooltip:s,showLegend:f=false,showGrid:i,showXAxis:u,showYAxis:l,className:C,style:h,...E}){Ct(t);let d=r==="sparkline",k=n??(d?F.width:"100%"),I=a??(d?F.height:300),c=s??!d,m=i??!d,b=u??!d,T=l??!d,p=react.useRef(null),_=O(p),$=D(p);return jsxRuntime.jsx(S,{...E,rootClassName:core.classNames("BaselineUI-LineChart",_e),className:C,style:h,width:k,height:I,variant:r,legend:f?jsxRuntime.jsx(P,{series:t,resolveColor:Z,paddingLeft:_}):null,surfaceRef:p,surfaceStyle:{"--chart-focus-left-overflow":`${$}px`},children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:yt,children:jsxRuntime.jsxs(recharts.LineChart,{accessibilityLayer:!d,data:e,margin:d?F.margin:void 0,children:[m?jsxRuntime.jsx(recharts.CartesianGrid,{stroke:tokens.themeVars.color.border.strong,strokeDasharray:"3 3"}):null,b?jsxRuntime.jsx(recharts.XAxis,{dataKey:o,stroke:tokens.themeVars.color.border.inverse,tick:{className:J}}):null,T?jsxRuntime.jsx(recharts.YAxis,{stroke:tokens.themeVars.color.border.inverse,tick:{className:J}}):null,c?jsxRuntime.jsx(recharts.Tooltip,{content:N,cursor:{stroke:tokens.themeVars.color.border.interactive.enabled,strokeDasharray:"3 3"}}):null,t.map((v,y)=>jsxRuntime.jsx(recharts.Line,{activeDot:d?false:{r:4,strokeWidth:2,stroke:tokens.themeVars.color.background.positive.subtle,fill:Z(v,y),style:{filter:"drop-shadow(0 0 4px rgba(0,0,0,0.4))"}},dataKey:v.dataKey,dot:v.dot??false,name:v.name??v.dataKey,stroke:Z(v,y),strokeWidth:v.strokeWidth??(d?F.strokeWidth:2),type:v.type??"monotone"},v.dataKey))]})})})}var ve="_1yep5z69o _1yep5z69p _1yep5z69q",ge="_1sy8dya1",be="_1sy8dya0 _1yep5z6dy";var G=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.error.medium,tokens.themeVars.color.support.warning.medium],At=90,Et=-270,kt=.05,It={width:1,height:1},xe=(e,t)=>e.color??G[t%G.length],Bt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>G.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("PieChart:paletteWrap",`[PieChart] More than ${G.length} slices with default colors \u2014 colors will repeat and slices may become visually indistinguishable. Set an explicit \`color\` on each slice.`);},Ot=({cx:e,cy:t,midAngle:o,innerRadius:r=0,outerRadius:n=0,percent:a=0})=>{if(e==null||t==null||o==null||a<kt)return null;let s=r+(n-r)*.65,f=-o*(Math.PI/180),i=e+s*Math.cos(f),u=t+s*Math.sin(f);return jsxRuntime.jsx("text",{className:be,x:i,y:u,textAnchor:"middle",dominantBaseline:"central",children:jsxRuntime.jsx(core.NumberFormat,{value:a,style:"percent",maximumFractionDigits:0})})},Dt={style:"percent",maximumFractionDigits:0},Mt=3,jt=({cx:e,cy:t,innerRadius:o,outerRadius:r=0,startAngle:n,endAngle:a,fill:s})=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(recharts.Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r+Mt,startAngle:n,endAngle:a,fill:s}),jsxRuntime.jsx(recharts.Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r,startAngle:n,endAngle:a,fill:s,stroke:tokens.themeVars.color.focused.inset,strokeWidth:1})]}),Le=new WeakSet;function Vt({data:e,width:t="100%",height:o=300,innerRadius:r,outerRadius:n,showTooltip:a=true,showLegend:s=true,showLabels:f=true,className:i,style:u,...l}){Bt(e);let C=react.useRef(null),{sortedData:h,sliceData:E}=react.useMemo(()=>{let c=e.filter(p=>p.value>=0);process.env.NODE_ENV!=="production"&&c.length!==e.length&&console.warn("[PieChart] Negative slice values were dropped. PieChart expects all `value`s to be >= 0.");let m=c.toSorted((p,_)=>_.value-p.value),b=m.reduce((p,_)=>p+_.value,0);process.env.NODE_ENV!=="production"&&b<=0&&e.length>0&&!Le.has(e)&&(Le.add(e),console.warn("[PieChart] Received data with a non-positive total. The chart will render empty."));let T=m.map(p=>({...p,fraction:b>0?p.value/b:0}));return {sortedData:m,sliceData:T}},[e]);react.useEffect(()=>{let c=C.current;if(!c)return;let m=()=>{let p=c.querySelector(".recharts-active-shape")?.parentElement,_=p?.parentElement;p&&_&&_.lastElementChild!==p&&_.append(p);};m();let b=new MutationObserver(m);return b.observe(c,{subtree:true,attributes:true,attributeFilter:["class"]}),()=>{b.disconnect();}},[]);let d=n??"100%",k=r??0,I=h.map((c,m)=>({dataKey:`${c.name}-${m}`,name:c.name}));return jsxRuntime.jsx(S,{...l,rootClassName:core.classNames("BaselineUI-PieChart",ve),className:i,style:u,width:t,height:o,variant:"default",legend:s?jsxRuntime.jsx(P,{series:I,resolveColor:(c,m)=>xe(h[m],m)}):null,surfaceRef:C,children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:It,children:jsxRuntime.jsxs(recharts.PieChart,{accessibilityLayer:true,children:[a?jsxRuntime.jsx(recharts.Tooltip,{content:c=>jsxRuntime.jsx(N,{...c,formatterProps:Dt})}):null,jsxRuntime.jsx(recharts.Pie,{data:E,dataKey:"fraction",nameKey:"name",innerRadius:k,outerRadius:d,startAngle:At,endAngle:Et,isAnimationActive:false,label:f?Ot:false,labelLine:false,stroke:tokens.themeVars.color.focused.inset,strokeWidth:1,activeShape:jt,rootTabIndex:-1,children:h.map((c,m)=>jsxRuntime.jsx(recharts.Cell,{className:ge,fill:xe(c,m)},`${c.name}-${m}`))})]})})})}exports.BarChart=nt;exports.LineChart=_t;exports.PieChart=Vt;
|
|
10
|
+
var ie="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z6jg _1yep5z6jh _1yep5z6ji",se="ofrh9o1 _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j1 _1yep5z6j2 _1yep5z6j3 _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z6le",le="_1yep5z6iv _1yep5z6iw _1yep5z6ix _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",ce="ofrh9o2 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk",pe="ofrh9o0",ue="_1yep5z66 _1yep5z67 _1yep5z68 _1yep5z62i _1yep5z62j _1yep5z62k _1yep5z63o _1yep5z63p _1yep5z63q _1yep5z61c _1yep5z61d _1yep5z61e _1yep5z6al _1yep5z6am _1yep5z6an _1yep5z6b9 _1yep5z6ba _1yep5z6bb _1yep5z6bx _1yep5z6by _1yep5z6bz _1yep5z6cl _1yep5z6cm _1yep5z6cn _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69f _1yep5z69g _1yep5z69h _1yep5z6lz _1yep5z6m1 _1yep5z6g1 _1yep5z6h4 _1yep5z6d7",me="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",fe="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69c _1yep5z69d _1yep5z69e",de="ofrh9o3 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk";function E({rootClassName:e,className:t,style:o,width:r,height:n,variant:a,dir:i,legend:y,surfaceRef:u,surfaceStyle:d,children:c,...b}){return jsxRuntime.jsxs("div",{...b,className:core.classNames(ie,e,t),"data-variant":a,dir:i,style:{width:r,height:n,...o},children:[y,jsxRuntime.jsx("div",{ref:u,className:core.classNames(pe,"BaselineUI-Chart-Surface"),style:d,children:c})]})}function A({series:e,resolveColor:t,paddingInlineStart:o}){return jsxRuntime.jsx("ul",{className:`${se} BaselineUI-Chart-Legend`,style:o==null?void 0:{paddingInlineStart:o},children:e.map((r,n)=>jsxRuntime.jsxs("li",{className:`${le} BaselineUI-Chart-LegendItem`,children:[jsxRuntime.jsx("span",{className:`${ce} BaselineUI-Chart-LegendSwatch`,style:{backgroundColor:t(r,n)}}),jsxRuntime.jsx(core.Text,{type:"label",size:"sm",children:r.name??r.dataKey})]},r.dataKey))})}var Oe=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},Be=(e,t)=>{if(!t)return e;let o=Oe(e);return o==null?(process.env.NODE_ENV!=="production"&&e!=null&&core.devWarnOnce("ChartTooltip:nonNumeric",`[ChartTooltip] \`formatterProps\` was provided but a non-numeric value was received (got ${JSON.stringify(e)}). The value will render unformatted.`),e):jsxRuntime.jsx(core.NumberFormat,{value:o,...t})};function D({active:e,payload:t,label:o,formatterProps:r}){return !e||!t?.length?null:jsxRuntime.jsxs("div",{className:`${ue} BaselineUI-Chart-Tooltip`,children:[o==null?null:jsxRuntime.jsx(core.Text,{elementType:"div",type:"label",size:"sm",children:String(o)}),jsxRuntime.jsx("div",{className:fe,children:t.map(n=>jsxRuntime.jsxs("div",{className:`${me} BaselineUI-Chart-TooltipItem`,children:[jsxRuntime.jsx("span",{className:`${de} BaselineUI-Chart-TooltipSwatch`,style:{backgroundColor:n.color}}),jsxRuntime.jsxs(core.Text,{type:"label",size:"sm",children:[n.name,": ",Be(n.value,r)]})]},String(n.dataKey)))})]})}function k(e){let{direction:t}=core.useLocale();return e??t}function O(e,t){let o=null,r=()=>{o==null&&(o=requestAnimationFrame(()=>{o=null,t();}));};t();let n=new ResizeObserver(r);n.observe(e);let a=new MutationObserver(r);return a.observe(e,{childList:true,subtree:true}),()=>{o!=null&&cancelAnimationFrame(o),n.disconnect(),a.disconnect();}}var Z=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function j(e,t){let[o,r]=react.useState(0);return react.useLayoutEffect(()=>{let n=e.current;if(!n)return;let a=false,i=false,y=false,u=false,d=0,c=m=>{r(h=>h===m?h:m);};c(0);let b=()=>{process.env.NODE_ENV!=="production"&&!i&&!a&&d>5&&(i=true,console.warn(`[useLeftmostYAxisLabelOffset] Could not find "${Z}" \u2014 Recharts may have renamed its internals. Legend will fall back to flush alignment.`));},L=()=>{process.env.NODE_ENV!=="production"&&!u&&a&&(u=true,console.warn("[useLeftmostYAxisLabelOffset] Y-axis labels disappeared after a successful measurement \u2014 falling back to flush alignment. This may indicate a Recharts upgrade or an unexpected empty render."));},v=()=>{process.env.NODE_ENV!=="production"&&!y&&(y=true,console.warn(`[useLeftmostYAxisLabelOffset] Found "${Z}" but no label returned a finite bounding rect \u2014 Recharts' measurement contract may have changed. Legend will fall back to flush alignment.`));};return O(n,()=>{let m=n.querySelectorAll(Z);if(m.length===0){d+=1,a?L():b(),c(0);return}a=true;let h=n.getBoundingClientRect();if(t==="rtl"){let f=-1/0;for(let s of m){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(f=Math.max(f,l.right));}if(!Number.isFinite(f)){v(),c(0);return}c(Math.max(0,h.right-f));return}let p=1/0;for(let f of m){let s=f.getBoundingClientRect();s.width===0&&s.height===0||(p=Math.min(p,s.left));}if(!Number.isFinite(p)){v(),c(0);return}c(Math.max(0,p-h.left));})},[e,t]),o}var Ce=".recharts-cartesian-grid";function Q(e){let[t,o]=react.useState(0);return react.useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,i=0;return O(r,()=>{let u=r.querySelector(Ce);if(!u){i+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&i>5&&(a=true,console.warn(`[usePlotAreaWidth] Could not find "${Ce}" \u2014 Recharts may have renamed its internals. Bar layouts will fall back to requested sizes.`));return}n=true;let d=u.getBoundingClientRect().width;o(c=>Math.abs(c-d)<.5?c:d);})},[e]),t}var ee=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function V(e,t){let[o,r]=react.useState(0);return react.useLayoutEffect(()=>{let n=e.current;if(!n)return;let a=false,i=false,y=false,u=false,d=0,c=m=>{r(h=>h===m?h:m);};c(0);let b=()=>{process.env.NODE_ENV!=="production"&&!i&&!a&&d>5&&(i=true,console.warn(`[useYAxisLeftOverflow] Could not find "${ee}" \u2014 Recharts may have renamed its internals. The focus outline will not extend over overflowing axis labels.`));},L=()=>{process.env.NODE_ENV!=="production"&&!u&&a&&(u=true,console.warn("[useYAxisLeftOverflow] Y-axis labels disappeared after a successful measurement \u2014 focus outline will no longer extend over overflowing labels. This may indicate a Recharts upgrade or an unexpected empty render."));},v=()=>{process.env.NODE_ENV!=="production"&&!y&&(y=true,console.warn(`[useYAxisLeftOverflow] Found "${ee}" but no label returned a finite bounding rect \u2014 Recharts' measurement contract may have changed. The focus outline will not extend over overflowing axis labels.`));};return O(n,()=>{let m=n.querySelectorAll(ee);if(m.length===0){d+=1,a?L():b(),c(0);return}a=true;let h=n.getBoundingClientRect();if(t==="rtl"){let f=-1/0;for(let s of m){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(f=Math.max(f,l.right));}if(!Number.isFinite(f)){v(),c(0);return}c(Math.max(0,Math.ceil(f-h.right)));return}let p=1/0;for(let f of m){let s=f.getBoundingClientRect();s.width===0&&s.height===0||(p=Math.min(p,s.left));}if(!Number.isFinite(p)){v(),c(0);return}c(Math.max(0,Math.ceil(h.left-p)));})},[e,t]),o}var te="_1o5hr0b0 _1yep5z6dy",ge="_1yep5z69r _1yep5z69s _1yep5z69t";var G=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.warning.medium,tokens.themeVars.color.support.error.medium],tt=12,rt=2,ot=4,F=1,nt={width:1,height:1},at=({plotWidth:e,categoryCount:t,barCount:o,barSize:r,barGap:n})=>{if(e<=0||t<=0||o<=0)return {barSize:r,barGap:n};let a=e/t-F,i=o-1;if(o*r+i*n<=a)return {barSize:r,barGap:n};let u=o*r+i*F;if(i>0&&u<=a){let c=Math.floor((a-o*r)/i);return {barSize:r,barGap:Math.max(F,c)}}let d=Math.floor((a-i*F)/o);return {barSize:Math.max(1,d),barGap:F}},_e=(e,t)=>e.color??G[t%G.length],it=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>G.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("BarChart:paletteWrap",`[BarChart] More than ${G.length} bar series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each bar.`);},re=(e,t)=>{if(e.stackId!=null)return e.stackId;if(t==="stacked")return "default"},st=(e,t)=>{let o=new Map,r=new Map;for(let[n,a]of e.entries()){let i=re(a,t);i==null?o.set(n,true):r.set(i,n);}for(let n of r.values())o.set(n,true);return o},be=false,lt=({offset:e,xAxis:t})=>{process.env.NODE_ENV!=="production"&&!be&&(!e||!t||typeof t.scale?.domain!="function")&&(be=true,console.warn("[BarChart] Recharts passed an unexpected shape to verticalCoordinatesGenerator (missing offset/xAxis/scale.domain). Vertical grid lines will not render \u2014 likely caused by a Recharts upgrade."));let o=t?.scale?.domain?.(),r=Array.isArray(o)?o.length:0,n=e?.width??0;if(r===0||n===0)return [];let a=e?.left??0,i=n/r;return Array.from({length:r},(y,u)=>a+i*(u+1))};function ct({data:e,bars:t,xAxisDataKey:o,variant:r="default",barSize:n=tt,barGap:a=ot,barRadius:i=rt,width:y="100%",height:u=300,showTooltip:d=true,showLegend:c=false,showGrid:b=true,showXAxis:L=true,showYAxis:v=true,className:N,style:m,dir:h,...p}){it(t);let f=k(h),s=f==="rtl",l=react.useRef(null),w=j(l,f),I=Q(l),C=V(l,f),g=react.useMemo(()=>st(t,r),[t,r]),H=react.useMemo(()=>{let _=new Set,M=0;for(let ae of t){let $=re(ae,r);$==null?M+=1:_.add($);}return M+_.size},[t,r]),{barSize:W,barGap:x}=at({plotWidth:I,categoryCount:e.length,barCount:H,barSize:n,barGap:a});return jsxRuntime.jsx(E,{...p,rootClassName:core.classNames("BaselineUI-BarChart",ge),className:N,style:m,width:y,height:u,variant:r,dir:f,legend:c?jsxRuntime.jsx(A,{series:t,resolveColor:_e,paddingInlineStart:w}):null,surfaceRef:l,surfaceStyle:{"--chart-focus-left-overflow":s?"0px":`${C}px`,"--chart-focus-right-overflow":s?`${C}px`:"0px"},children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:nt,children:jsxRuntime.jsxs(recharts.BarChart,{accessibilityLayer:true,barGap:x,data:e,children:[b?jsxRuntime.jsx(recharts.CartesianGrid,{stroke:tokens.themeVars.color.border.strong,strokeDasharray:"3 3",verticalCoordinatesGenerator:lt}):null,L?jsxRuntime.jsx(recharts.XAxis,{dataKey:o,reversed:s,stroke:tokens.themeVars.color.border.inverse,tick:{className:te}}):null,v?jsxRuntime.jsx(recharts.YAxis,{orientation:s?"right":"left",stroke:tokens.themeVars.color.border.inverse,tick:{className:te}}):null,d?jsxRuntime.jsx(recharts.Tooltip,{content:D,cursor:{fill:tokens.themeVars.color.background.overlay.interactive}}):null,t.map((_,M)=>{let $=g.get(M)??false?[i,i,0,0]:[0,0,0,0];return jsxRuntime.jsx(recharts.Bar,{barSize:W,dataKey:_.dataKey,fill:_e(_,M),name:_.name??_.dataKey,radius:$,stackId:re(_,r)},_.dataKey)})]})})})}var oe="_1ojkdm40 _1yep5z6dy",xe="_1yep5z69r _1yep5z69s _1yep5z69t";var K=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.warning.medium,tokens.themeVars.color.support.error.medium],Y={width:40,height:20,strokeWidth:1,margin:{top:1,right:1,bottom:1,left:1}},bt={width:1,height:1},ne=(e,t)=>e.color??K[t%K.length],xt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>K.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("LineChart:paletteWrap",`[LineChart] More than ${K.length} line series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each line.`);};function zt({data:e,lines:t,xAxisDataKey:o,variant:r="default",width:n,height:a,showTooltip:i,showLegend:y=false,showGrid:u,showXAxis:d,showYAxis:c,className:b,style:L,dir:v,...N}){xt(t);let m=k(v),h=m==="rtl",p=r==="sparkline",f=n??(p?Y.width:"100%"),s=a??(p?Y.height:300),l=i??!p,w=u??!p,I=d??!p,C=c??!p,g=react.useRef(null),H=j(g,m),W=V(g,m);return jsxRuntime.jsx(E,{...N,rootClassName:core.classNames("BaselineUI-LineChart",xe),className:b,style:L,width:f,height:s,variant:r,dir:m,legend:y?jsxRuntime.jsx(A,{series:t,resolveColor:ne,paddingInlineStart:H}):null,surfaceRef:g,surfaceStyle:{"--chart-focus-left-overflow":h?"0px":`${W}px`,"--chart-focus-right-overflow":h?`${W}px`:"0px"},children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:bt,children:jsxRuntime.jsxs(recharts.LineChart,{accessibilityLayer:!p,data:e,margin:p?Y.margin:void 0,children:[w?jsxRuntime.jsx(recharts.CartesianGrid,{stroke:tokens.themeVars.color.border.strong,strokeDasharray:"3 3"}):null,I?jsxRuntime.jsx(recharts.XAxis,{dataKey:o,reversed:h,stroke:tokens.themeVars.color.border.inverse,tick:{className:oe}}):null,C?jsxRuntime.jsx(recharts.YAxis,{orientation:h?"right":"left",stroke:tokens.themeVars.color.border.inverse,tick:{className:oe}}):null,l?jsxRuntime.jsx(recharts.Tooltip,{content:D,cursor:{stroke:tokens.themeVars.color.border.interactive.enabled,strokeDasharray:"3 3"}}):null,t.map((x,_)=>jsxRuntime.jsx(recharts.Line,{activeDot:p?false:{r:4,strokeWidth:2,stroke:tokens.themeVars.color.background.positive.subtle,fill:ne(x,_),style:{filter:"drop-shadow(0 0 4px rgba(0,0,0,0.4))"}},dataKey:x.dataKey,dot:x.dot??false,name:x.name??x.dataKey,stroke:ne(x,_),strokeWidth:x.strokeWidth??(p?Y.strokeWidth:2),type:x.type??"monotone"},x.dataKey))]})})})}var ze="_1yep5z69o _1yep5z69p _1yep5z69q",we="_1sy8dya1",Le="_1sy8dya0 _1yep5z6dy";var q=[tokens.themeVars.color.support.info.medium,tokens.themeVars.color.support.success.medium,tokens.themeVars.color.support.error.medium,tokens.themeVars.color.support.warning.medium],Ot=90,Bt=-270,Mt=.05,jt={width:1,height:1},Se=(e,t)=>e.color??q[t%q.length],Vt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>q.length,o=e.some(r=>r.color==null);t&&o&&core.devWarnOnce("PieChart:paletteWrap",`[PieChart] More than ${q.length} slices with default colors \u2014 colors will repeat and slices may become visually indistinguishable. Set an explicit \`color\` on each slice.`);},Ft=({cx:e,cy:t,midAngle:o,innerRadius:r=0,outerRadius:n=0,percent:a=0})=>{if(e==null||t==null||o==null||a<Mt)return null;let i=r+(n-r)*.65,y=-o*(Math.PI/180),u=e+i*Math.cos(y),d=t+i*Math.sin(y);return jsxRuntime.jsx("text",{className:Le,x:u,y:d,textAnchor:"middle",dominantBaseline:"central",children:jsxRuntime.jsx(core.NumberFormat,{value:a,style:"percent",maximumFractionDigits:0})})},Wt={style:"percent",maximumFractionDigits:0},$t=3,Ut=({cx:e,cy:t,innerRadius:o,outerRadius:r=0,startAngle:n,endAngle:a,fill:i})=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(recharts.Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r+$t,startAngle:n,endAngle:a,fill:i}),jsxRuntime.jsx(recharts.Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r,startAngle:n,endAngle:a,fill:i,stroke:tokens.themeVars.color.focused.inset,strokeWidth:1})]}),Pe=new WeakSet;function Gt({data:e,width:t="100%",height:o=300,innerRadius:r,outerRadius:n,showTooltip:a=true,showLegend:i=true,showLabels:y=true,className:u,style:d,dir:c,...b}){Vt(e);let L=k(c),v=react.useRef(null),{sortedData:N,sliceData:m}=react.useMemo(()=>{let s=e.filter(C=>C.value>=0);process.env.NODE_ENV!=="production"&&s.length!==e.length&&console.warn("[PieChart] Negative slice values were dropped. PieChart expects all `value`s to be >= 0.");let l=s.toSorted((C,g)=>g.value-C.value),w=l.reduce((C,g)=>C+g.value,0);process.env.NODE_ENV!=="production"&&w<=0&&e.length>0&&!Pe.has(e)&&(Pe.add(e),console.warn("[PieChart] Received data with a non-positive total. The chart will render empty."));let I=l.map(C=>({...C,fraction:w>0?C.value/w:0}));return {sortedData:l,sliceData:I}},[e]);react.useEffect(()=>{let s=v.current;if(!s)return;let l=()=>{let C=s.querySelector(".recharts-active-shape")?.parentElement,g=C?.parentElement;C&&g&&g.lastElementChild!==C&&g.append(C);};l();let w=new MutationObserver(l);return w.observe(s,{subtree:true,attributes:true,attributeFilter:["class"]}),()=>{w.disconnect();}},[]);let h=n??"100%",p=r??0,f=N.map((s,l)=>({dataKey:`${s.name}-${l}`,name:s.name}));return jsxRuntime.jsx(E,{...b,rootClassName:core.classNames("BaselineUI-PieChart",ze),className:u,style:d,width:t,height:o,variant:"default",dir:L,legend:i?jsxRuntime.jsx(A,{series:f,resolveColor:(s,l)=>Se(N[l],l)}):null,surfaceRef:v,children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",initialDimension:jt,children:jsxRuntime.jsxs(recharts.PieChart,{accessibilityLayer:true,children:[a?jsxRuntime.jsx(recharts.Tooltip,{content:s=>jsxRuntime.jsx(D,{...s,formatterProps:Wt})}):null,jsxRuntime.jsx(recharts.Pie,{data:m,dataKey:"fraction",nameKey:"name",innerRadius:p,outerRadius:h,startAngle:Ot,endAngle:Bt,isAnimationActive:false,label:y?Ft:false,labelLine:false,stroke:tokens.themeVars.color.focused.inset,strokeWidth:1,activeShape:Ut,rootTabIndex:-1,children:N.map((s,l)=>jsxRuntime.jsx(recharts.Cell,{className:we,fill:Se(s,l)},`${s.name}-${l}`))})]})})})}exports.BarChart=ct;exports.LineChart=zt;exports.PieChart=Gt;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {classNames,devWarnOnce,Text,NumberFormat}from'@baseline-ui/core';import {themeVars}from'@baseline-ui/tokens';import {useRef,useMemo,useEffect,useState,useLayoutEffect}from'react';import {ResponsiveContainer,BarChart,CartesianGrid,XAxis,YAxis,Tooltip,Bar,LineChart,Line,PieChart,Pie,Cell,Sector}from'recharts';import {jsx,jsxs}from'react/jsx-runtime';/**
|
|
1
|
+
import {classNames,devWarnOnce,useLocale,Text,NumberFormat}from'@baseline-ui/core';import {themeVars}from'@baseline-ui/tokens';import {useRef,useMemo,useEffect,useState,useLayoutEffect}from'react';import {ResponsiveContainer,BarChart,CartesianGrid,XAxis,YAxis,Tooltip,Bar,LineChart,Line,PieChart,Pie,Cell,Sector}from'recharts';import {jsx,jsxs}from'react/jsx-runtime';/**
|
|
2
2
|
* Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
@@ -7,4 +7,4 @@ import {classNames,devWarnOnce,Text,NumberFormat}from'@baseline-ui/core';import
|
|
|
7
7
|
* This notice may not be removed from this file.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
var ee="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z6jg _1yep5z6jh _1yep5z6ji",te="ofrh9o1 _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j1 _1yep5z6j2 _1yep5z6j3 _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z6le",re="_1yep5z6iv _1yep5z6iw _1yep5z6ix _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",oe="ofrh9o2 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk",ne="ofrh9o0",ae="_1yep5z66 _1yep5z67 _1yep5z68 _1yep5z62i _1yep5z62j _1yep5z62k _1yep5z63o _1yep5z63p _1yep5z63q _1yep5z61c _1yep5z61d _1yep5z61e _1yep5z6al _1yep5z6am _1yep5z6an _1yep5z6b9 _1yep5z6ba _1yep5z6bb _1yep5z6bx _1yep5z6by _1yep5z6bz _1yep5z6cl _1yep5z6cm _1yep5z6cn _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69f _1yep5z69g _1yep5z69h _1yep5z6lz _1yep5z6m1 _1yep5z6g1 _1yep5z6h4 _1yep5z6d7",se="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",ie="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69c _1yep5z69d _1yep5z69e",le="ofrh9o3 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk";function S({rootClassName:e,className:t,style:o,width:r,height:n,variant:a,legend:s,surfaceRef:f,surfaceStyle:i,children:u,...l}){return jsxs("div",{...l,className:classNames(ee,e,t),"data-variant":a,style:{width:r,height:n,...o},children:[s,jsx("div",{ref:f,className:classNames(ne,"BaselineUI-Chart-Surface"),style:i,children:u})]})}function P({series:e,resolveColor:t,paddingLeft:o}){return jsx("ul",{className:`${te} BaselineUI-Chart-Legend`,style:o==null?void 0:{paddingLeft:o},children:e.map((r,n)=>jsxs("li",{className:`${re} BaselineUI-Chart-LegendItem`,children:[jsx("span",{className:`${oe} BaselineUI-Chart-LegendSwatch`,style:{backgroundColor:t(r,n)}}),jsx(Text,{type:"label",size:"sm",children:r.name??r.dataKey})]},r.dataKey))})}var Ee=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},ke=(e,t)=>{if(!t)return e;let o=Ee(e);return o==null?(process.env.NODE_ENV!=="production"&&e!=null&&devWarnOnce("ChartTooltip:nonNumeric",`[ChartTooltip] \`formatterProps\` was provided but a non-numeric value was received (got ${JSON.stringify(e)}). The value will render unformatted.`),e):jsx(NumberFormat,{value:o,...t})};function N({active:e,payload:t,label:o,formatterProps:r}){return !e||!t?.length?null:jsxs("div",{className:`${ae} BaselineUI-Chart-Tooltip`,children:[o==null?null:jsx(Text,{elementType:"div",type:"label",size:"sm",children:String(o)}),jsx("div",{className:ie,children:t.map(n=>jsxs("div",{className:`${se} BaselineUI-Chart-TooltipItem`,children:[jsx("span",{className:`${le} BaselineUI-Chart-TooltipSwatch`,style:{backgroundColor:n.color}}),jsxs(Text,{type:"label",size:"sm",children:[n.name,": ",ke(n.value,r)]})]},String(n.dataKey)))})]})}function R(e,t){let o=null,r=()=>{o==null&&(o=requestAnimationFrame(()=>{o=null,t();}));};t();let n=new ResizeObserver(r);n.observe(e);let a=new MutationObserver(r);return a.observe(e,{childList:true,subtree:true}),()=>{o!=null&&cancelAnimationFrame(o),n.disconnect(),a.disconnect();}}var ue=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function O(e){let[t,o]=useState(0);return useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelectorAll(ue);if(i.length===0){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[useLeftmostYAxisLabelOffset] Could not find "${ue}" \u2014 Recharts may have renamed its internals. Legend will fall back to flush-left alignment.`)),o(0);return}n=true;let u=r.getBoundingClientRect().left,l=1/0;for(let C of i)l=Math.min(l,C.getBoundingClientRect().left);if(!Number.isFinite(l)){o(0);return}o(Math.max(0,l-u));})},[e]),t}var me=".recharts-cartesian-grid";function q(e){let[t,o]=useState(0);return useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelector(me);if(!i){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[usePlotAreaWidth] Could not find "${me}" \u2014 Recharts may have renamed its internals. Bar layouts will fall back to requested sizes.`));return}n=true;let u=i.getBoundingClientRect().width;o(l=>Math.abs(l-u)<.5?l:u);})},[e]),t}var fe=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function D(e){let[t,o]=useState(0);return useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,s=0;return R(r,()=>{let i=r.querySelectorAll(fe);if(i.length===0){s+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&s>5&&(a=true,console.warn(`[useYAxisLeftOverflow] Could not find "${fe}" \u2014 Recharts may have renamed its internals. The focus outline will not extend over overflowing axis labels.`)),o(0);return}n=true;let u=r.getBoundingClientRect().left,l=1/0;for(let h of i)l=Math.min(l,h.getBoundingClientRect().left);if(!Number.isFinite(l)){o(0);return}let C=Math.max(0,Math.ceil(u-l));o(h=>h===C?h:C);})},[e]),t}var H="_1o5hr0b0 _1yep5z6dy",de="_1yep5z69r _1yep5z69s _1yep5z69t";var W=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.warning.medium,themeVars.color.support.error.medium],Xe=12,Je=2,Ze=4,M=1,Qe={width:1,height:1},et=({plotWidth:e,categoryCount:t,barCount:o,barSize:r,barGap:n})=>{if(e<=0||t<=0||o<=0)return {barSize:r,barGap:n};let a=e/t-M,s=o-1;if(o*r+s*n<=a)return {barSize:r,barGap:n};let i=o*r+s*M;if(s>0&&i<=a){let l=Math.floor((a-o*r)/s);return {barSize:r,barGap:Math.max(M,l)}}let u=Math.floor((a-s*M)/o);return {barSize:Math.max(1,u),barGap:M}},ye=(e,t)=>e.color??W[t%W.length],tt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>W.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("BarChart:paletteWrap",`[BarChart] More than ${W.length} bar series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each bar.`);},X=(e,t)=>{if(e.stackId!=null)return e.stackId;if(t==="stacked")return "default"},rt=(e,t)=>{let o=new Map,r=new Map;for(let[n,a]of e.entries()){let s=X(a,t);s==null?o.set(n,true):r.set(s,n);}for(let n of r.values())o.set(n,true);return o},Ce=false,ot=({offset:e,xAxis:t})=>{process.env.NODE_ENV!=="production"&&!Ce&&(!e||!t||typeof t.scale?.domain!="function")&&(Ce=true,console.warn("[BarChart] Recharts passed an unexpected shape to verticalCoordinatesGenerator (missing offset/xAxis/scale.domain). Vertical grid lines will not render \u2014 likely caused by a Recharts upgrade."));let o=t?.scale?.domain?.(),r=Array.isArray(o)?o.length:0,n=e?.width??0;if(r===0||n===0)return [];let a=e?.left??0,s=n/r;return Array.from({length:r},(f,i)=>a+s*(i+1))};function nt({data:e,bars:t,xAxisDataKey:o,variant:r="default",barSize:n=Xe,barGap:a=Ze,barRadius:s=Je,width:f="100%",height:i=300,showTooltip:u=true,showLegend:l=false,showGrid:C=true,showXAxis:h=true,showYAxis:E=true,className:d,style:k,...I}){tt(t);let c=useRef(null),m=O(c),b=q(c),T=D(c),p=useMemo(()=>rt(t,r),[t,r]),_=useMemo(()=>{let y=new Set,B=0;for(let Q of t){let j=X(Q,r);j==null?B+=1:y.add(j);}return B+y.size},[t,r]),{barSize:$,barGap:v}=et({plotWidth:b,categoryCount:e.length,barCount:_,barSize:n,barGap:a});return jsx(S,{...I,rootClassName:classNames("BaselineUI-BarChart",de),className:d,style:k,width:f,height:i,variant:r,legend:l?jsx(P,{series:t,resolveColor:ye,paddingLeft:m}):null,surfaceRef:c,surfaceStyle:{"--chart-focus-left-overflow":`${T}px`},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:Qe,children:jsxs(BarChart,{accessibilityLayer:true,barGap:v,data:e,children:[C?jsx(CartesianGrid,{stroke:themeVars.color.border.strong,strokeDasharray:"3 3",verticalCoordinatesGenerator:ot}):null,h?jsx(XAxis,{dataKey:o,stroke:themeVars.color.border.inverse,tick:{className:H}}):null,E?jsx(YAxis,{stroke:themeVars.color.border.inverse,tick:{className:H}}):null,u?jsx(Tooltip,{content:N,cursor:{fill:themeVars.color.background.overlay.interactive}}):null,t.map((y,B)=>{let j=p.get(B)??false?[s,s,0,0]:[0,0,0,0];return jsx(Bar,{barSize:$,dataKey:y.dataKey,fill:ye(y,B),name:y.name??y.dataKey,radius:j,stackId:X(y,r)},y.dataKey)})]})})})}var J="_1ojkdm40 _1yep5z6dy",_e="_1yep5z69r _1yep5z69s _1yep5z69t";var U=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.warning.medium,themeVars.color.support.error.medium],F={width:40,height:20,strokeWidth:1,margin:{top:1,right:1,bottom:1,left:1}},yt={width:1,height:1},Z=(e,t)=>e.color??U[t%U.length],Ct=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>U.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("LineChart:paletteWrap",`[LineChart] More than ${U.length} line series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each line.`);};function _t({data:e,lines:t,xAxisDataKey:o,variant:r="default",width:n,height:a,showTooltip:s,showLegend:f=false,showGrid:i,showXAxis:u,showYAxis:l,className:C,style:h,...E}){Ct(t);let d=r==="sparkline",k=n??(d?F.width:"100%"),I=a??(d?F.height:300),c=s??!d,m=i??!d,b=u??!d,T=l??!d,p=useRef(null),_=O(p),$=D(p);return jsx(S,{...E,rootClassName:classNames("BaselineUI-LineChart",_e),className:C,style:h,width:k,height:I,variant:r,legend:f?jsx(P,{series:t,resolveColor:Z,paddingLeft:_}):null,surfaceRef:p,surfaceStyle:{"--chart-focus-left-overflow":`${$}px`},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:yt,children:jsxs(LineChart,{accessibilityLayer:!d,data:e,margin:d?F.margin:void 0,children:[m?jsx(CartesianGrid,{stroke:themeVars.color.border.strong,strokeDasharray:"3 3"}):null,b?jsx(XAxis,{dataKey:o,stroke:themeVars.color.border.inverse,tick:{className:J}}):null,T?jsx(YAxis,{stroke:themeVars.color.border.inverse,tick:{className:J}}):null,c?jsx(Tooltip,{content:N,cursor:{stroke:themeVars.color.border.interactive.enabled,strokeDasharray:"3 3"}}):null,t.map((v,y)=>jsx(Line,{activeDot:d?false:{r:4,strokeWidth:2,stroke:themeVars.color.background.positive.subtle,fill:Z(v,y),style:{filter:"drop-shadow(0 0 4px rgba(0,0,0,0.4))"}},dataKey:v.dataKey,dot:v.dot??false,name:v.name??v.dataKey,stroke:Z(v,y),strokeWidth:v.strokeWidth??(d?F.strokeWidth:2),type:v.type??"monotone"},v.dataKey))]})})})}var ve="_1yep5z69o _1yep5z69p _1yep5z69q",ge="_1sy8dya1",be="_1sy8dya0 _1yep5z6dy";var G=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.error.medium,themeVars.color.support.warning.medium],At=90,Et=-270,kt=.05,It={width:1,height:1},xe=(e,t)=>e.color??G[t%G.length],Bt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>G.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("PieChart:paletteWrap",`[PieChart] More than ${G.length} slices with default colors \u2014 colors will repeat and slices may become visually indistinguishable. Set an explicit \`color\` on each slice.`);},Ot=({cx:e,cy:t,midAngle:o,innerRadius:r=0,outerRadius:n=0,percent:a=0})=>{if(e==null||t==null||o==null||a<kt)return null;let s=r+(n-r)*.65,f=-o*(Math.PI/180),i=e+s*Math.cos(f),u=t+s*Math.sin(f);return jsx("text",{className:be,x:i,y:u,textAnchor:"middle",dominantBaseline:"central",children:jsx(NumberFormat,{value:a,style:"percent",maximumFractionDigits:0})})},Dt={style:"percent",maximumFractionDigits:0},Mt=3,jt=({cx:e,cy:t,innerRadius:o,outerRadius:r=0,startAngle:n,endAngle:a,fill:s})=>jsxs("g",{children:[jsx(Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r+Mt,startAngle:n,endAngle:a,fill:s}),jsx(Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r,startAngle:n,endAngle:a,fill:s,stroke:themeVars.color.focused.inset,strokeWidth:1})]}),Le=new WeakSet;function Vt({data:e,width:t="100%",height:o=300,innerRadius:r,outerRadius:n,showTooltip:a=true,showLegend:s=true,showLabels:f=true,className:i,style:u,...l}){Bt(e);let C=useRef(null),{sortedData:h,sliceData:E}=useMemo(()=>{let c=e.filter(p=>p.value>=0);process.env.NODE_ENV!=="production"&&c.length!==e.length&&console.warn("[PieChart] Negative slice values were dropped. PieChart expects all `value`s to be >= 0.");let m=c.toSorted((p,_)=>_.value-p.value),b=m.reduce((p,_)=>p+_.value,0);process.env.NODE_ENV!=="production"&&b<=0&&e.length>0&&!Le.has(e)&&(Le.add(e),console.warn("[PieChart] Received data with a non-positive total. The chart will render empty."));let T=m.map(p=>({...p,fraction:b>0?p.value/b:0}));return {sortedData:m,sliceData:T}},[e]);useEffect(()=>{let c=C.current;if(!c)return;let m=()=>{let p=c.querySelector(".recharts-active-shape")?.parentElement,_=p?.parentElement;p&&_&&_.lastElementChild!==p&&_.append(p);};m();let b=new MutationObserver(m);return b.observe(c,{subtree:true,attributes:true,attributeFilter:["class"]}),()=>{b.disconnect();}},[]);let d=n??"100%",k=r??0,I=h.map((c,m)=>({dataKey:`${c.name}-${m}`,name:c.name}));return jsx(S,{...l,rootClassName:classNames("BaselineUI-PieChart",ve),className:i,style:u,width:t,height:o,variant:"default",legend:s?jsx(P,{series:I,resolveColor:(c,m)=>xe(h[m],m)}):null,surfaceRef:C,children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:It,children:jsxs(PieChart,{accessibilityLayer:true,children:[a?jsx(Tooltip,{content:c=>jsx(N,{...c,formatterProps:Dt})}):null,jsx(Pie,{data:E,dataKey:"fraction",nameKey:"name",innerRadius:k,outerRadius:d,startAngle:At,endAngle:Et,isAnimationActive:false,label:f?Ot:false,labelLine:false,stroke:themeVars.color.focused.inset,strokeWidth:1,activeShape:jt,rootTabIndex:-1,children:h.map((c,m)=>jsx(Cell,{className:ge,fill:xe(c,m)},`${c.name}-${m}`))})]})})})}export{nt as BarChart,_t as LineChart,Vt as PieChart};
|
|
10
|
+
var ie="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z6jg _1yep5z6jh _1yep5z6ji",se="ofrh9o1 _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j1 _1yep5z6j2 _1yep5z6j3 _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z6le",le="_1yep5z6iv _1yep5z6iw _1yep5z6ix _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",ce="ofrh9o2 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk",pe="ofrh9o0",ue="_1yep5z66 _1yep5z67 _1yep5z68 _1yep5z62i _1yep5z62j _1yep5z62k _1yep5z63o _1yep5z63p _1yep5z63q _1yep5z61c _1yep5z61d _1yep5z61e _1yep5z6al _1yep5z6am _1yep5z6an _1yep5z6b9 _1yep5z6ba _1yep5z6bb _1yep5z6bx _1yep5z6by _1yep5z6bz _1yep5z6cl _1yep5z6cm _1yep5z6cn _1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69f _1yep5z69g _1yep5z69h _1yep5z6lz _1yep5z6m1 _1yep5z6g1 _1yep5z6h4 _1yep5z6d7",me="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6jj _1yep5z6jk _1yep5z6jl _1yep5z69f _1yep5z69g _1yep5z69h",fe="_1yep5z6is _1yep5z6it _1yep5z6iu _1yep5z6j4 _1yep5z6j5 _1yep5z6j6 _1yep5z69c _1yep5z69d _1yep5z69e",de="ofrh9o3 _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6lk";function E({rootClassName:e,className:t,style:o,width:r,height:n,variant:a,dir:i,legend:y,surfaceRef:u,surfaceStyle:d,children:c,...b}){return jsxs("div",{...b,className:classNames(ie,e,t),"data-variant":a,dir:i,style:{width:r,height:n,...o},children:[y,jsx("div",{ref:u,className:classNames(pe,"BaselineUI-Chart-Surface"),style:d,children:c})]})}function A({series:e,resolveColor:t,paddingInlineStart:o}){return jsx("ul",{className:`${se} BaselineUI-Chart-Legend`,style:o==null?void 0:{paddingInlineStart:o},children:e.map((r,n)=>jsxs("li",{className:`${le} BaselineUI-Chart-LegendItem`,children:[jsx("span",{className:`${ce} BaselineUI-Chart-LegendSwatch`,style:{backgroundColor:t(r,n)}}),jsx(Text,{type:"label",size:"sm",children:r.name??r.dataKey})]},r.dataKey))})}var Oe=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},Be=(e,t)=>{if(!t)return e;let o=Oe(e);return o==null?(process.env.NODE_ENV!=="production"&&e!=null&&devWarnOnce("ChartTooltip:nonNumeric",`[ChartTooltip] \`formatterProps\` was provided but a non-numeric value was received (got ${JSON.stringify(e)}). The value will render unformatted.`),e):jsx(NumberFormat,{value:o,...t})};function D({active:e,payload:t,label:o,formatterProps:r}){return !e||!t?.length?null:jsxs("div",{className:`${ue} BaselineUI-Chart-Tooltip`,children:[o==null?null:jsx(Text,{elementType:"div",type:"label",size:"sm",children:String(o)}),jsx("div",{className:fe,children:t.map(n=>jsxs("div",{className:`${me} BaselineUI-Chart-TooltipItem`,children:[jsx("span",{className:`${de} BaselineUI-Chart-TooltipSwatch`,style:{backgroundColor:n.color}}),jsxs(Text,{type:"label",size:"sm",children:[n.name,": ",Be(n.value,r)]})]},String(n.dataKey)))})]})}function k(e){let{direction:t}=useLocale();return e??t}function O(e,t){let o=null,r=()=>{o==null&&(o=requestAnimationFrame(()=>{o=null,t();}));};t();let n=new ResizeObserver(r);n.observe(e);let a=new MutationObserver(r);return a.observe(e,{childList:true,subtree:true}),()=>{o!=null&&cancelAnimationFrame(o),n.disconnect(),a.disconnect();}}var Z=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function j(e,t){let[o,r]=useState(0);return useLayoutEffect(()=>{let n=e.current;if(!n)return;let a=false,i=false,y=false,u=false,d=0,c=m=>{r(h=>h===m?h:m);};c(0);let b=()=>{process.env.NODE_ENV!=="production"&&!i&&!a&&d>5&&(i=true,console.warn(`[useLeftmostYAxisLabelOffset] Could not find "${Z}" \u2014 Recharts may have renamed its internals. Legend will fall back to flush alignment.`));},L=()=>{process.env.NODE_ENV!=="production"&&!u&&a&&(u=true,console.warn("[useLeftmostYAxisLabelOffset] Y-axis labels disappeared after a successful measurement \u2014 falling back to flush alignment. This may indicate a Recharts upgrade or an unexpected empty render."));},v=()=>{process.env.NODE_ENV!=="production"&&!y&&(y=true,console.warn(`[useLeftmostYAxisLabelOffset] Found "${Z}" but no label returned a finite bounding rect \u2014 Recharts' measurement contract may have changed. Legend will fall back to flush alignment.`));};return O(n,()=>{let m=n.querySelectorAll(Z);if(m.length===0){d+=1,a?L():b(),c(0);return}a=true;let h=n.getBoundingClientRect();if(t==="rtl"){let f=-1/0;for(let s of m){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(f=Math.max(f,l.right));}if(!Number.isFinite(f)){v(),c(0);return}c(Math.max(0,h.right-f));return}let p=1/0;for(let f of m){let s=f.getBoundingClientRect();s.width===0&&s.height===0||(p=Math.min(p,s.left));}if(!Number.isFinite(p)){v(),c(0);return}c(Math.max(0,p-h.left));})},[e,t]),o}var Ce=".recharts-cartesian-grid";function Q(e){let[t,o]=useState(0);return useLayoutEffect(()=>{let r=e.current;if(!r)return;let n=false,a=false,i=0;return O(r,()=>{let u=r.querySelector(Ce);if(!u){i+=1,process.env.NODE_ENV!=="production"&&!a&&!n&&i>5&&(a=true,console.warn(`[usePlotAreaWidth] Could not find "${Ce}" \u2014 Recharts may have renamed its internals. Bar layouts will fall back to requested sizes.`));return}n=true;let d=u.getBoundingClientRect().width;o(c=>Math.abs(c-d)<.5?c:d);})},[e]),t}var ee=".recharts-yAxis-tick-labels .recharts-cartesian-axis-tick-value";function V(e,t){let[o,r]=useState(0);return useLayoutEffect(()=>{let n=e.current;if(!n)return;let a=false,i=false,y=false,u=false,d=0,c=m=>{r(h=>h===m?h:m);};c(0);let b=()=>{process.env.NODE_ENV!=="production"&&!i&&!a&&d>5&&(i=true,console.warn(`[useYAxisLeftOverflow] Could not find "${ee}" \u2014 Recharts may have renamed its internals. The focus outline will not extend over overflowing axis labels.`));},L=()=>{process.env.NODE_ENV!=="production"&&!u&&a&&(u=true,console.warn("[useYAxisLeftOverflow] Y-axis labels disappeared after a successful measurement \u2014 focus outline will no longer extend over overflowing labels. This may indicate a Recharts upgrade or an unexpected empty render."));},v=()=>{process.env.NODE_ENV!=="production"&&!y&&(y=true,console.warn(`[useYAxisLeftOverflow] Found "${ee}" but no label returned a finite bounding rect \u2014 Recharts' measurement contract may have changed. The focus outline will not extend over overflowing axis labels.`));};return O(n,()=>{let m=n.querySelectorAll(ee);if(m.length===0){d+=1,a?L():b(),c(0);return}a=true;let h=n.getBoundingClientRect();if(t==="rtl"){let f=-1/0;for(let s of m){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(f=Math.max(f,l.right));}if(!Number.isFinite(f)){v(),c(0);return}c(Math.max(0,Math.ceil(f-h.right)));return}let p=1/0;for(let f of m){let s=f.getBoundingClientRect();s.width===0&&s.height===0||(p=Math.min(p,s.left));}if(!Number.isFinite(p)){v(),c(0);return}c(Math.max(0,Math.ceil(h.left-p)));})},[e,t]),o}var te="_1o5hr0b0 _1yep5z6dy",ge="_1yep5z69r _1yep5z69s _1yep5z69t";var G=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.warning.medium,themeVars.color.support.error.medium],tt=12,rt=2,ot=4,F=1,nt={width:1,height:1},at=({plotWidth:e,categoryCount:t,barCount:o,barSize:r,barGap:n})=>{if(e<=0||t<=0||o<=0)return {barSize:r,barGap:n};let a=e/t-F,i=o-1;if(o*r+i*n<=a)return {barSize:r,barGap:n};let u=o*r+i*F;if(i>0&&u<=a){let c=Math.floor((a-o*r)/i);return {barSize:r,barGap:Math.max(F,c)}}let d=Math.floor((a-i*F)/o);return {barSize:Math.max(1,d),barGap:F}},_e=(e,t)=>e.color??G[t%G.length],it=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>G.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("BarChart:paletteWrap",`[BarChart] More than ${G.length} bar series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each bar.`);},re=(e,t)=>{if(e.stackId!=null)return e.stackId;if(t==="stacked")return "default"},st=(e,t)=>{let o=new Map,r=new Map;for(let[n,a]of e.entries()){let i=re(a,t);i==null?o.set(n,true):r.set(i,n);}for(let n of r.values())o.set(n,true);return o},be=false,lt=({offset:e,xAxis:t})=>{process.env.NODE_ENV!=="production"&&!be&&(!e||!t||typeof t.scale?.domain!="function")&&(be=true,console.warn("[BarChart] Recharts passed an unexpected shape to verticalCoordinatesGenerator (missing offset/xAxis/scale.domain). Vertical grid lines will not render \u2014 likely caused by a Recharts upgrade."));let o=t?.scale?.domain?.(),r=Array.isArray(o)?o.length:0,n=e?.width??0;if(r===0||n===0)return [];let a=e?.left??0,i=n/r;return Array.from({length:r},(y,u)=>a+i*(u+1))};function ct({data:e,bars:t,xAxisDataKey:o,variant:r="default",barSize:n=tt,barGap:a=ot,barRadius:i=rt,width:y="100%",height:u=300,showTooltip:d=true,showLegend:c=false,showGrid:b=true,showXAxis:L=true,showYAxis:v=true,className:N,style:m,dir:h,...p}){it(t);let f=k(h),s=f==="rtl",l=useRef(null),w=j(l,f),I=Q(l),C=V(l,f),g=useMemo(()=>st(t,r),[t,r]),H=useMemo(()=>{let _=new Set,M=0;for(let ae of t){let $=re(ae,r);$==null?M+=1:_.add($);}return M+_.size},[t,r]),{barSize:W,barGap:x}=at({plotWidth:I,categoryCount:e.length,barCount:H,barSize:n,barGap:a});return jsx(E,{...p,rootClassName:classNames("BaselineUI-BarChart",ge),className:N,style:m,width:y,height:u,variant:r,dir:f,legend:c?jsx(A,{series:t,resolveColor:_e,paddingInlineStart:w}):null,surfaceRef:l,surfaceStyle:{"--chart-focus-left-overflow":s?"0px":`${C}px`,"--chart-focus-right-overflow":s?`${C}px`:"0px"},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:nt,children:jsxs(BarChart,{accessibilityLayer:true,barGap:x,data:e,children:[b?jsx(CartesianGrid,{stroke:themeVars.color.border.strong,strokeDasharray:"3 3",verticalCoordinatesGenerator:lt}):null,L?jsx(XAxis,{dataKey:o,reversed:s,stroke:themeVars.color.border.inverse,tick:{className:te}}):null,v?jsx(YAxis,{orientation:s?"right":"left",stroke:themeVars.color.border.inverse,tick:{className:te}}):null,d?jsx(Tooltip,{content:D,cursor:{fill:themeVars.color.background.overlay.interactive}}):null,t.map((_,M)=>{let $=g.get(M)??false?[i,i,0,0]:[0,0,0,0];return jsx(Bar,{barSize:W,dataKey:_.dataKey,fill:_e(_,M),name:_.name??_.dataKey,radius:$,stackId:re(_,r)},_.dataKey)})]})})})}var oe="_1ojkdm40 _1yep5z6dy",xe="_1yep5z69r _1yep5z69s _1yep5z69t";var K=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.warning.medium,themeVars.color.support.error.medium],Y={width:40,height:20,strokeWidth:1,margin:{top:1,right:1,bottom:1,left:1}},bt={width:1,height:1},ne=(e,t)=>e.color??K[t%K.length],xt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>K.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("LineChart:paletteWrap",`[LineChart] More than ${K.length} line series with default colors \u2014 colors will repeat and series may become visually indistinguishable. Set an explicit \`color\` on each line.`);};function zt({data:e,lines:t,xAxisDataKey:o,variant:r="default",width:n,height:a,showTooltip:i,showLegend:y=false,showGrid:u,showXAxis:d,showYAxis:c,className:b,style:L,dir:v,...N}){xt(t);let m=k(v),h=m==="rtl",p=r==="sparkline",f=n??(p?Y.width:"100%"),s=a??(p?Y.height:300),l=i??!p,w=u??!p,I=d??!p,C=c??!p,g=useRef(null),H=j(g,m),W=V(g,m);return jsx(E,{...N,rootClassName:classNames("BaselineUI-LineChart",xe),className:b,style:L,width:f,height:s,variant:r,dir:m,legend:y?jsx(A,{series:t,resolveColor:ne,paddingInlineStart:H}):null,surfaceRef:g,surfaceStyle:{"--chart-focus-left-overflow":h?"0px":`${W}px`,"--chart-focus-right-overflow":h?`${W}px`:"0px"},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:bt,children:jsxs(LineChart,{accessibilityLayer:!p,data:e,margin:p?Y.margin:void 0,children:[w?jsx(CartesianGrid,{stroke:themeVars.color.border.strong,strokeDasharray:"3 3"}):null,I?jsx(XAxis,{dataKey:o,reversed:h,stroke:themeVars.color.border.inverse,tick:{className:oe}}):null,C?jsx(YAxis,{orientation:h?"right":"left",stroke:themeVars.color.border.inverse,tick:{className:oe}}):null,l?jsx(Tooltip,{content:D,cursor:{stroke:themeVars.color.border.interactive.enabled,strokeDasharray:"3 3"}}):null,t.map((x,_)=>jsx(Line,{activeDot:p?false:{r:4,strokeWidth:2,stroke:themeVars.color.background.positive.subtle,fill:ne(x,_),style:{filter:"drop-shadow(0 0 4px rgba(0,0,0,0.4))"}},dataKey:x.dataKey,dot:x.dot??false,name:x.name??x.dataKey,stroke:ne(x,_),strokeWidth:x.strokeWidth??(p?Y.strokeWidth:2),type:x.type??"monotone"},x.dataKey))]})})})}var ze="_1yep5z69o _1yep5z69p _1yep5z69q",we="_1sy8dya1",Le="_1sy8dya0 _1yep5z6dy";var q=[themeVars.color.support.info.medium,themeVars.color.support.success.medium,themeVars.color.support.error.medium,themeVars.color.support.warning.medium],Ot=90,Bt=-270,Mt=.05,jt={width:1,height:1},Se=(e,t)=>e.color??q[t%q.length],Vt=e=>{if(process.env.NODE_ENV==="production")return;let t=e.length>q.length,o=e.some(r=>r.color==null);t&&o&&devWarnOnce("PieChart:paletteWrap",`[PieChart] More than ${q.length} slices with default colors \u2014 colors will repeat and slices may become visually indistinguishable. Set an explicit \`color\` on each slice.`);},Ft=({cx:e,cy:t,midAngle:o,innerRadius:r=0,outerRadius:n=0,percent:a=0})=>{if(e==null||t==null||o==null||a<Mt)return null;let i=r+(n-r)*.65,y=-o*(Math.PI/180),u=e+i*Math.cos(y),d=t+i*Math.sin(y);return jsx("text",{className:Le,x:u,y:d,textAnchor:"middle",dominantBaseline:"central",children:jsx(NumberFormat,{value:a,style:"percent",maximumFractionDigits:0})})},Wt={style:"percent",maximumFractionDigits:0},$t=3,Ut=({cx:e,cy:t,innerRadius:o,outerRadius:r=0,startAngle:n,endAngle:a,fill:i})=>jsxs("g",{children:[jsx(Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r+$t,startAngle:n,endAngle:a,fill:i}),jsx(Sector,{cx:e,cy:t,innerRadius:o,outerRadius:r,startAngle:n,endAngle:a,fill:i,stroke:themeVars.color.focused.inset,strokeWidth:1})]}),Pe=new WeakSet;function Gt({data:e,width:t="100%",height:o=300,innerRadius:r,outerRadius:n,showTooltip:a=true,showLegend:i=true,showLabels:y=true,className:u,style:d,dir:c,...b}){Vt(e);let L=k(c),v=useRef(null),{sortedData:N,sliceData:m}=useMemo(()=>{let s=e.filter(C=>C.value>=0);process.env.NODE_ENV!=="production"&&s.length!==e.length&&console.warn("[PieChart] Negative slice values were dropped. PieChart expects all `value`s to be >= 0.");let l=s.toSorted((C,g)=>g.value-C.value),w=l.reduce((C,g)=>C+g.value,0);process.env.NODE_ENV!=="production"&&w<=0&&e.length>0&&!Pe.has(e)&&(Pe.add(e),console.warn("[PieChart] Received data with a non-positive total. The chart will render empty."));let I=l.map(C=>({...C,fraction:w>0?C.value/w:0}));return {sortedData:l,sliceData:I}},[e]);useEffect(()=>{let s=v.current;if(!s)return;let l=()=>{let C=s.querySelector(".recharts-active-shape")?.parentElement,g=C?.parentElement;C&&g&&g.lastElementChild!==C&&g.append(C);};l();let w=new MutationObserver(l);return w.observe(s,{subtree:true,attributes:true,attributeFilter:["class"]}),()=>{w.disconnect();}},[]);let h=n??"100%",p=r??0,f=N.map((s,l)=>({dataKey:`${s.name}-${l}`,name:s.name}));return jsx(E,{...b,rootClassName:classNames("BaselineUI-PieChart",ze),className:u,style:d,width:t,height:o,variant:"default",dir:L,legend:i?jsx(A,{series:f,resolveColor:(s,l)=>Se(N[l],l)}):null,surfaceRef:v,children:jsx(ResponsiveContainer,{width:"100%",height:"100%",initialDimension:jt,children:jsxs(PieChart,{accessibilityLayer:true,children:[a?jsx(Tooltip,{content:s=>jsx(D,{...s,formatterProps:Wt})}):null,jsx(Pie,{data:m,dataKey:"fraction",nameKey:"name",innerRadius:p,outerRadius:h,startAngle:Ot,endAngle:Bt,isAnimationActive:false,label:y?Ft:false,labelLine:false,stroke:themeVars.color.focused.inset,strokeWidth:1,activeShape:Ut,rootTabIndex:-1,children:N.map((s,l)=>jsx(Cell,{className:we,fill:Se(s,l)},`${s.name}-${l}`))})]})})})}export{ct as BarChart,zt as LineChart,Gt as PieChart};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baseline-ui/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0",
|
|
4
4
|
"description": "Chart components for Baseline UI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@baseline-ui/core": "0.
|
|
14
|
-
"@baseline-ui/tokens": "0.
|
|
13
|
+
"@baseline-ui/core": "0.60.0",
|
|
14
|
+
"@baseline-ui/tokens": "0.60.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "^18.0.0",
|