open-mcp-app-ui 0.0.4 → 0.0.7
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 +165 -0
- package/dist/charts/index.js +460 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/editor/index.d.ts +17 -4
- package/dist/editor/index.js +161 -53
- package/dist/editor/index.js.map +1 -1
- package/dist/index.d.ts +37 -16
- package/dist/index.js +35 -27
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table/index.d.ts +8 -1
- package/dist/table/index.js +7 -12
- package/dist/table/index.js.map +1 -1
- package/package.json +10 -4
- package/dist/styles/display-modes.css +0 -14
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
export { Area, Bar, CartesianGrid, Cell, Legend, Line, Pie, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, Tooltip as RechartsTooltip, ReferenceArea, ReferenceLine, ResponsiveContainer, Scatter, XAxis, YAxis } from 'recharts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Border variant type shared across chart sub-components.
|
|
7
|
+
* - "default" uses --color-border-primary (stronger)
|
|
8
|
+
* - "secondary" uses --color-border-secondary (subtler)
|
|
9
|
+
*/
|
|
10
|
+
type ChartBorderVariant = "default" | "secondary";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Shared chart types.
|
|
14
|
+
* Defines the theme interface and common props used across all chart wrappers.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Color palette for multi-series charts.
|
|
19
|
+
* Each series gets the next color in the palette.
|
|
20
|
+
* Uses CSS variables from the MCP Apps spec where possible,
|
|
21
|
+
* with opacity variations for additional series.
|
|
22
|
+
*/
|
|
23
|
+
declare const DEFAULT_PALETTE: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Base props shared by all chart container wrappers.
|
|
26
|
+
*/
|
|
27
|
+
interface ChartContainerProps {
|
|
28
|
+
/** Chart height in pixels. Width is always 100% of parent. */
|
|
29
|
+
height?: number;
|
|
30
|
+
/** Custom color palette for series data. Overrides the default palette. */
|
|
31
|
+
colorPalette?: string[];
|
|
32
|
+
/** Additional CSS class on the outermost wrapper. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Inline styles on the outermost wrapper. */
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ThemedLineChartProps extends ChartContainerProps {
|
|
39
|
+
/** Chart data array. Each entry is one data point. */
|
|
40
|
+
data: Record<string, unknown>[];
|
|
41
|
+
/** Child elements (Line, XAxis, YAxis, Tooltip, Legend, etc.) */
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
/** Show background grid lines. */
|
|
44
|
+
grid?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Border variant for axis lines and tick marks.
|
|
47
|
+
* - "default" — uses --color-border-primary (stronger)
|
|
48
|
+
* - "secondary" — uses --color-border-secondary (subtler)
|
|
49
|
+
*/
|
|
50
|
+
borderVariant?: ChartBorderVariant;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Themed LineChart.
|
|
54
|
+
* Automatically assigns palette colors to Line children and
|
|
55
|
+
* applies themed axis styles to XAxis/YAxis children.
|
|
56
|
+
*/
|
|
57
|
+
declare const LineChart: ({ data, height, colorPalette, className, style, grid, borderVariant, children, }: ThemedLineChartProps) => react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
interface ThemedBarChartProps extends ChartContainerProps {
|
|
60
|
+
/** Chart data array. */
|
|
61
|
+
data: Record<string, unknown>[];
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
grid?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Border variant for axis lines and tick marks.
|
|
66
|
+
* - "default" — uses --color-border-primary (stronger)
|
|
67
|
+
* - "secondary" — uses --color-border-secondary (subtler)
|
|
68
|
+
*/
|
|
69
|
+
borderVariant?: ChartBorderVariant;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Themed BarChart.
|
|
73
|
+
* Automatically assigns palette colors to Bar children and
|
|
74
|
+
* applies themed axis styles to XAxis/YAxis children.
|
|
75
|
+
*/
|
|
76
|
+
declare const BarChart: ({ data, height, colorPalette, className, style, grid, borderVariant, children, }: ThemedBarChartProps) => react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
interface ThemedAreaChartProps extends ChartContainerProps {
|
|
79
|
+
data: Record<string, unknown>[];
|
|
80
|
+
children: ReactNode;
|
|
81
|
+
grid?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Border variant for axis lines and tick marks.
|
|
84
|
+
* - "default" — uses --color-border-primary (stronger)
|
|
85
|
+
* - "secondary" — uses --color-border-secondary (subtler)
|
|
86
|
+
*/
|
|
87
|
+
borderVariant?: ChartBorderVariant;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Themed AreaChart.
|
|
91
|
+
* Auto-assigns palette colors with gradient fill to Area children and
|
|
92
|
+
* applies themed axis styles to XAxis/YAxis children.
|
|
93
|
+
*/
|
|
94
|
+
declare const AreaChart: ({ data, height, colorPalette, className, style, grid, borderVariant, children, }: ThemedAreaChartProps) => react_jsx_runtime.JSX.Element;
|
|
95
|
+
|
|
96
|
+
interface ThemedPieChartProps extends Omit<ChartContainerProps, "height"> {
|
|
97
|
+
/** Chart height (also used for approximate width in responsive container). */
|
|
98
|
+
height?: number;
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Themed PieChart.
|
|
103
|
+
* Auto-assigns palette colors to Pie data via Cell children when no
|
|
104
|
+
* explicit fill is provided on individual data entries.
|
|
105
|
+
*/
|
|
106
|
+
declare const PieChart: ({ height, colorPalette, className, style, children, }: ThemedPieChartProps) => react_jsx_runtime.JSX.Element;
|
|
107
|
+
|
|
108
|
+
interface ThemedScatterChartProps extends ChartContainerProps {
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
grid?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Border variant for axis lines and tick marks.
|
|
113
|
+
* - "default" — uses --color-border-primary (stronger)
|
|
114
|
+
* - "secondary" — uses --color-border-secondary (subtler)
|
|
115
|
+
*/
|
|
116
|
+
borderVariant?: ChartBorderVariant;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Themed ScatterChart.
|
|
120
|
+
* Auto-assigns palette fill colors to Scatter children and
|
|
121
|
+
* applies themed axis styles to XAxis/YAxis children.
|
|
122
|
+
*/
|
|
123
|
+
declare const ScatterChart: ({ height, colorPalette, className, style, grid, borderVariant, children, }: ThemedScatterChartProps) => react_jsx_runtime.JSX.Element;
|
|
124
|
+
|
|
125
|
+
interface ThemedRadarChartProps extends ChartContainerProps {
|
|
126
|
+
data: Record<string, unknown>[];
|
|
127
|
+
children: ReactNode;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Themed RadarChart.
|
|
131
|
+
* Auto-assigns palette colors to Radar children.
|
|
132
|
+
*/
|
|
133
|
+
declare const RadarChart: ({ data, height, colorPalette, className, style, children, }: ThemedRadarChartProps) => react_jsx_runtime.JSX.Element;
|
|
134
|
+
|
|
135
|
+
interface ThemedComposedChartProps extends ChartContainerProps {
|
|
136
|
+
data: Record<string, unknown>[];
|
|
137
|
+
children: ReactNode;
|
|
138
|
+
grid?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Border variant for axis lines and tick marks.
|
|
141
|
+
* - "default" — uses --color-border-primary (stronger)
|
|
142
|
+
* - "secondary" — uses --color-border-secondary (subtler)
|
|
143
|
+
*/
|
|
144
|
+
borderVariant?: ChartBorderVariant;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Themed ComposedChart.
|
|
148
|
+
* Auto-assigns palette colors to Line, Bar, and Area children and
|
|
149
|
+
* applies themed axis styles to XAxis/YAxis children.
|
|
150
|
+
*/
|
|
151
|
+
declare const ComposedChart: ({ data, height, colorPalette, className, style, grid, borderVariant, children, }: ThemedComposedChartProps) => react_jsx_runtime.JSX.Element;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* ThemedTooltip — Pre-themed tooltip using MCP Apps spec CSS variables.
|
|
155
|
+
*
|
|
156
|
+
* Drop-in replacement for Recharts' Tooltip that automatically
|
|
157
|
+
* applies the host's theme colors for background, text, border.
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* A themed Tooltip that reads CSS variables at render time.
|
|
161
|
+
* Forwards all standard Recharts Tooltip props.
|
|
162
|
+
*/
|
|
163
|
+
declare const ThemedTooltip: (props: any) => react_jsx_runtime.JSX.Element;
|
|
164
|
+
|
|
165
|
+
export { AreaChart, BarChart, type ChartBorderVariant, type ChartContainerProps, ComposedChart, DEFAULT_PALETTE, LineChart, PieChart, RadarChart, ScatterChart, ThemedTooltip as Tooltip };
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
// src/charts/LineChart.tsx
|
|
2
|
+
import { Children, cloneElement, isValidElement } from "react";
|
|
3
|
+
import {
|
|
4
|
+
LineChart as RechartsLineChart,
|
|
5
|
+
Line as RechartsLine,
|
|
6
|
+
XAxis as RechartsXAxis,
|
|
7
|
+
YAxis as RechartsYAxis,
|
|
8
|
+
CartesianGrid
|
|
9
|
+
} from "recharts";
|
|
10
|
+
|
|
11
|
+
// src/charts/ChartContainer.tsx
|
|
12
|
+
import { ResponsiveContainer } from "recharts";
|
|
13
|
+
|
|
14
|
+
// src/charts/types.ts
|
|
15
|
+
var DEFAULT_PALETTE = [
|
|
16
|
+
"var(--color-accent, #6366f1)",
|
|
17
|
+
"var(--color-text-secondary, #6b7280)",
|
|
18
|
+
"var(--color-ring-primary, #a78bfa)",
|
|
19
|
+
"var(--color-text-tertiary, #9ca3af)",
|
|
20
|
+
"var(--color-border-primary, #d1d5db)",
|
|
21
|
+
"color-mix(in srgb, var(--color-accent, #6366f1) 60%, transparent)",
|
|
22
|
+
"color-mix(in srgb, var(--color-accent, #6366f1) 35%, transparent)"
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
// src/charts/ChartContainer.tsx
|
|
26
|
+
import { jsx } from "react/jsx-runtime";
|
|
27
|
+
var ChartContainer = ({
|
|
28
|
+
height = 300,
|
|
29
|
+
className = "",
|
|
30
|
+
style,
|
|
31
|
+
children
|
|
32
|
+
}) => /* @__PURE__ */ jsx(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className: `omu-chart w-full ${className}`,
|
|
36
|
+
style: { height: `${height}px`, ...style },
|
|
37
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children })
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
var getSeriesColor = ({
|
|
41
|
+
index,
|
|
42
|
+
palette
|
|
43
|
+
}) => {
|
|
44
|
+
const colors = palette ?? DEFAULT_PALETTE;
|
|
45
|
+
return colors[index % colors.length];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/charts/theme.ts
|
|
49
|
+
import React from "react";
|
|
50
|
+
var getCSSVar = ({ name, fallback }) => {
|
|
51
|
+
if (typeof window === "undefined") return fallback;
|
|
52
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
53
|
+
return value || fallback;
|
|
54
|
+
};
|
|
55
|
+
var getTooltipStyle = () => ({
|
|
56
|
+
contentStyle: {
|
|
57
|
+
backgroundColor: getCSSVar({ name: "--color-background-secondary", fallback: "#f9fafb" }),
|
|
58
|
+
border: `1px solid ${getCSSVar({ name: "--color-border-secondary", fallback: "#e5e7eb" })}`,
|
|
59
|
+
borderRadius: getCSSVar({ name: "--border-radius-md", fallback: "8px" }),
|
|
60
|
+
color: getCSSVar({ name: "--color-text-primary", fallback: "#111827" }),
|
|
61
|
+
fontSize: getCSSVar({ name: "--font-text-sm-size", fallback: "13px" }),
|
|
62
|
+
fontFamily: getCSSVar({ name: "--font-sans", fallback: "ui-sans-serif, system-ui, sans-serif" }),
|
|
63
|
+
padding: "8px 12px",
|
|
64
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.08)"
|
|
65
|
+
},
|
|
66
|
+
labelStyle: {
|
|
67
|
+
color: getCSSVar({ name: "--color-text-primary", fallback: "#111827" }),
|
|
68
|
+
fontWeight: 500,
|
|
69
|
+
marginBottom: "4px"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var getBorderColor = ({ variant = "default" } = {}) => variant === "secondary" ? getCSSVar({ name: "--color-border-secondary", fallback: "#e5e7eb" }) : getCSSVar({ name: "--color-border-primary", fallback: "#d1d5db" });
|
|
73
|
+
var getGridColor = ({ variant = "secondary" } = {}) => getBorderColor({ variant });
|
|
74
|
+
var getAxisStyle = ({ variant = "default" } = {}) => ({
|
|
75
|
+
tick: {
|
|
76
|
+
fill: getCSSVar({ name: "--color-text-secondary", fallback: "#6b7280" }),
|
|
77
|
+
fontSize: getCSSVar({ name: "--font-text-xs-size", fallback: "11px" }),
|
|
78
|
+
fontFamily: getCSSVar({ name: "--font-sans", fallback: "ui-sans-serif, system-ui, sans-serif" })
|
|
79
|
+
},
|
|
80
|
+
axisLine: {
|
|
81
|
+
stroke: getBorderColor({ variant })
|
|
82
|
+
},
|
|
83
|
+
tickLine: {
|
|
84
|
+
stroke: getBorderColor({ variant })
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
var themeAxisChild = ({
|
|
88
|
+
child,
|
|
89
|
+
variant = "default",
|
|
90
|
+
XAxis: XAxis2,
|
|
91
|
+
YAxis: YAxis2
|
|
92
|
+
}) => {
|
|
93
|
+
const t = child.type;
|
|
94
|
+
const dn = t?.displayName;
|
|
95
|
+
if (t === XAxis2 || t === YAxis2 || dn === "XAxis" || dn === "YAxis") {
|
|
96
|
+
const style = getAxisStyle({ variant });
|
|
97
|
+
const props = child.props;
|
|
98
|
+
return React.cloneElement(child, {
|
|
99
|
+
tick: props.tick === false ? false : { ...style.tick, ...typeof props.tick === "object" && props.tick ? props.tick : {} },
|
|
100
|
+
axisLine: props.axisLine === false ? false : { ...style.axisLine, ...typeof props.axisLine === "object" && props.axisLine ? props.axisLine : {} },
|
|
101
|
+
tickLine: props.tickLine === false ? false : { ...style.tickLine, ...typeof props.tickLine === "object" && props.tickLine ? props.tickLine : {} }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/charts/LineChart.tsx
|
|
108
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
109
|
+
var LineChart = ({
|
|
110
|
+
data,
|
|
111
|
+
height,
|
|
112
|
+
colorPalette,
|
|
113
|
+
className,
|
|
114
|
+
style,
|
|
115
|
+
grid = true,
|
|
116
|
+
borderVariant = "default",
|
|
117
|
+
children
|
|
118
|
+
}) => {
|
|
119
|
+
let seriesIndex = 0;
|
|
120
|
+
const themedChildren = Children.map(children, (child) => {
|
|
121
|
+
if (!isValidElement(child)) return child;
|
|
122
|
+
const themedAxis = themeAxisChild({ child, variant: borderVariant, XAxis: RechartsXAxis, YAxis: RechartsYAxis });
|
|
123
|
+
if (themedAxis) return themedAxis;
|
|
124
|
+
if (child.type === RechartsLine || child.type?.displayName === "Line") {
|
|
125
|
+
const idx = seriesIndex++;
|
|
126
|
+
const existing = child.props.stroke;
|
|
127
|
+
return cloneElement(child, {
|
|
128
|
+
stroke: existing || getSeriesColor({ index: idx, palette: colorPalette }),
|
|
129
|
+
strokeWidth: child.props.strokeWidth ?? 2,
|
|
130
|
+
dot: child.props.dot ?? false,
|
|
131
|
+
activeDot: child.props.activeDot ?? { r: 4 }
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return child;
|
|
135
|
+
});
|
|
136
|
+
return /* @__PURE__ */ jsx2(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsxs(RechartsLineChart, { data, margin: { top: 5, right: 20, bottom: 5, left: 0 }, children: [
|
|
137
|
+
grid && /* @__PURE__ */ jsx2(CartesianGrid, { strokeDasharray: "3 3", stroke: getGridColor(), opacity: 0.5 }),
|
|
138
|
+
themedChildren
|
|
139
|
+
] }) });
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// src/charts/BarChart.tsx
|
|
143
|
+
import { Children as Children2, cloneElement as cloneElement2, isValidElement as isValidElement2 } from "react";
|
|
144
|
+
import {
|
|
145
|
+
BarChart as RechartsBarChart,
|
|
146
|
+
Bar as RechartsBar,
|
|
147
|
+
XAxis as RechartsXAxis2,
|
|
148
|
+
YAxis as RechartsYAxis2,
|
|
149
|
+
CartesianGrid as CartesianGrid2
|
|
150
|
+
} from "recharts";
|
|
151
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
152
|
+
var BarChart = ({
|
|
153
|
+
data,
|
|
154
|
+
height,
|
|
155
|
+
colorPalette,
|
|
156
|
+
className,
|
|
157
|
+
style,
|
|
158
|
+
grid = true,
|
|
159
|
+
borderVariant = "default",
|
|
160
|
+
children
|
|
161
|
+
}) => {
|
|
162
|
+
let seriesIndex = 0;
|
|
163
|
+
const themedChildren = Children2.map(children, (child) => {
|
|
164
|
+
if (!isValidElement2(child)) return child;
|
|
165
|
+
const themedAxis = themeAxisChild({ child, variant: borderVariant, XAxis: RechartsXAxis2, YAxis: RechartsYAxis2 });
|
|
166
|
+
if (themedAxis) return themedAxis;
|
|
167
|
+
if (child.type === RechartsBar || child.type?.displayName === "Bar") {
|
|
168
|
+
const idx = seriesIndex++;
|
|
169
|
+
const existing = child.props.fill;
|
|
170
|
+
return cloneElement2(child, {
|
|
171
|
+
fill: existing || getSeriesColor({ index: idx, palette: colorPalette }),
|
|
172
|
+
radius: child.props.radius ?? [4, 4, 0, 0]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return child;
|
|
176
|
+
});
|
|
177
|
+
return /* @__PURE__ */ jsx3(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsxs2(RechartsBarChart, { data, margin: { top: 5, right: 20, bottom: 5, left: 0 }, children: [
|
|
178
|
+
grid && /* @__PURE__ */ jsx3(CartesianGrid2, { strokeDasharray: "3 3", stroke: getGridColor(), opacity: 0.5, vertical: false }),
|
|
179
|
+
themedChildren
|
|
180
|
+
] }) });
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/charts/AreaChart.tsx
|
|
184
|
+
import { Children as Children3, cloneElement as cloneElement3, isValidElement as isValidElement3 } from "react";
|
|
185
|
+
import {
|
|
186
|
+
AreaChart as RechartsAreaChart,
|
|
187
|
+
Area as RechartsArea,
|
|
188
|
+
XAxis as RechartsXAxis3,
|
|
189
|
+
YAxis as RechartsYAxis3,
|
|
190
|
+
CartesianGrid as CartesianGrid3
|
|
191
|
+
} from "recharts";
|
|
192
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
193
|
+
var AreaChart = ({
|
|
194
|
+
data,
|
|
195
|
+
height,
|
|
196
|
+
colorPalette,
|
|
197
|
+
className,
|
|
198
|
+
style,
|
|
199
|
+
grid = true,
|
|
200
|
+
borderVariant = "default",
|
|
201
|
+
children
|
|
202
|
+
}) => {
|
|
203
|
+
let seriesIndex = 0;
|
|
204
|
+
const themedChildren = Children3.map(children, (child) => {
|
|
205
|
+
if (!isValidElement3(child)) return child;
|
|
206
|
+
const themedAxis = themeAxisChild({ child, variant: borderVariant, XAxis: RechartsXAxis3, YAxis: RechartsYAxis3 });
|
|
207
|
+
if (themedAxis) return themedAxis;
|
|
208
|
+
if (child.type === RechartsArea || child.type?.displayName === "Area") {
|
|
209
|
+
const idx = seriesIndex++;
|
|
210
|
+
const color = child.props.stroke || getSeriesColor({ index: idx, palette: colorPalette });
|
|
211
|
+
return cloneElement3(child, {
|
|
212
|
+
stroke: color,
|
|
213
|
+
fill: child.props.fill || color,
|
|
214
|
+
fillOpacity: child.props.fillOpacity ?? 0.15,
|
|
215
|
+
strokeWidth: child.props.strokeWidth ?? 2
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return child;
|
|
219
|
+
});
|
|
220
|
+
return /* @__PURE__ */ jsx4(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsxs3(RechartsAreaChart, { data, margin: { top: 5, right: 20, bottom: 5, left: 0 }, children: [
|
|
221
|
+
grid && /* @__PURE__ */ jsx4(CartesianGrid3, { strokeDasharray: "3 3", stroke: getGridColor(), opacity: 0.5 }),
|
|
222
|
+
themedChildren
|
|
223
|
+
] }) });
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/charts/PieChart.tsx
|
|
227
|
+
import { Children as Children4, cloneElement as cloneElement4, isValidElement as isValidElement4 } from "react";
|
|
228
|
+
import {
|
|
229
|
+
PieChart as RechartsPieChart,
|
|
230
|
+
Pie as RechartsPie,
|
|
231
|
+
Cell
|
|
232
|
+
} from "recharts";
|
|
233
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
234
|
+
var PieChart = ({
|
|
235
|
+
height,
|
|
236
|
+
colorPalette,
|
|
237
|
+
className,
|
|
238
|
+
style,
|
|
239
|
+
children
|
|
240
|
+
}) => {
|
|
241
|
+
const themedChildren = Children4.map(children, (child) => {
|
|
242
|
+
if (!isValidElement4(child)) return child;
|
|
243
|
+
if (child.type === RechartsPie || child.type?.displayName === "Pie") {
|
|
244
|
+
const props = child.props;
|
|
245
|
+
const data = props.data ?? [];
|
|
246
|
+
const hasExplicitCells = Children4.toArray(props.children).some(
|
|
247
|
+
(c) => isValidElement4(c) && (c.type === Cell || c.type?.displayName === "Cell")
|
|
248
|
+
);
|
|
249
|
+
if (!hasExplicitCells && data.length > 0) {
|
|
250
|
+
return cloneElement4(child, {
|
|
251
|
+
children: data.map((_, i) => /* @__PURE__ */ jsx5(Cell, { fill: getSeriesColor({ index: i, palette: colorPalette }) }, `cell-${i}`))
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return child;
|
|
256
|
+
});
|
|
257
|
+
return /* @__PURE__ */ jsx5(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsx5(RechartsPieChart, { children: themedChildren }) });
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/charts/ScatterChart.tsx
|
|
261
|
+
import { Children as Children5, cloneElement as cloneElement5, isValidElement as isValidElement5 } from "react";
|
|
262
|
+
import {
|
|
263
|
+
ScatterChart as RechartsScatterChart,
|
|
264
|
+
Scatter as RechartsScatter,
|
|
265
|
+
XAxis as RechartsXAxis4,
|
|
266
|
+
YAxis as RechartsYAxis4,
|
|
267
|
+
CartesianGrid as CartesianGrid4
|
|
268
|
+
} from "recharts";
|
|
269
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
270
|
+
var ScatterChart = ({
|
|
271
|
+
height,
|
|
272
|
+
colorPalette,
|
|
273
|
+
className,
|
|
274
|
+
style,
|
|
275
|
+
grid = true,
|
|
276
|
+
borderVariant = "default",
|
|
277
|
+
children
|
|
278
|
+
}) => {
|
|
279
|
+
let seriesIndex = 0;
|
|
280
|
+
const themedChildren = Children5.map(children, (child) => {
|
|
281
|
+
if (!isValidElement5(child)) return child;
|
|
282
|
+
const themedAxis = themeAxisChild({ child, variant: borderVariant, XAxis: RechartsXAxis4, YAxis: RechartsYAxis4 });
|
|
283
|
+
if (themedAxis) return themedAxis;
|
|
284
|
+
if (child.type === RechartsScatter || child.type?.displayName === "Scatter") {
|
|
285
|
+
const idx = seriesIndex++;
|
|
286
|
+
const existing = child.props.fill;
|
|
287
|
+
return cloneElement5(child, {
|
|
288
|
+
fill: existing || getSeriesColor({ index: idx, palette: colorPalette })
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return child;
|
|
292
|
+
});
|
|
293
|
+
return /* @__PURE__ */ jsx6(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsxs4(RechartsScatterChart, { margin: { top: 5, right: 20, bottom: 5, left: 0 }, children: [
|
|
294
|
+
grid && /* @__PURE__ */ jsx6(CartesianGrid4, { strokeDasharray: "3 3", stroke: getGridColor(), opacity: 0.5 }),
|
|
295
|
+
themedChildren
|
|
296
|
+
] }) });
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/charts/RadarChart.tsx
|
|
300
|
+
import { Children as Children6, cloneElement as cloneElement6, isValidElement as isValidElement6 } from "react";
|
|
301
|
+
import {
|
|
302
|
+
RadarChart as RechartsRadarChart,
|
|
303
|
+
Radar as RechartsRadar
|
|
304
|
+
} from "recharts";
|
|
305
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
306
|
+
var RadarChart = ({
|
|
307
|
+
data,
|
|
308
|
+
height,
|
|
309
|
+
colorPalette,
|
|
310
|
+
className,
|
|
311
|
+
style,
|
|
312
|
+
children
|
|
313
|
+
}) => {
|
|
314
|
+
let seriesIndex = 0;
|
|
315
|
+
const themedChildren = Children6.map(children, (child) => {
|
|
316
|
+
if (!isValidElement6(child)) return child;
|
|
317
|
+
if (child.type === RechartsRadar || child.type?.displayName === "Radar") {
|
|
318
|
+
const idx = seriesIndex++;
|
|
319
|
+
const color = child.props.stroke || getSeriesColor({ index: idx, palette: colorPalette });
|
|
320
|
+
return cloneElement6(child, {
|
|
321
|
+
stroke: color,
|
|
322
|
+
fill: child.props.fill || color,
|
|
323
|
+
fillOpacity: child.props.fillOpacity ?? 0.2
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
return child;
|
|
327
|
+
});
|
|
328
|
+
return /* @__PURE__ */ jsx7(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsx7(RechartsRadarChart, { data, cx: "50%", cy: "50%", outerRadius: "70%", children: themedChildren }) });
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/charts/ComposedChart.tsx
|
|
332
|
+
import { Children as Children7, cloneElement as cloneElement7, isValidElement as isValidElement7 } from "react";
|
|
333
|
+
import {
|
|
334
|
+
ComposedChart as RechartsComposedChart,
|
|
335
|
+
Line as RechartsLine2,
|
|
336
|
+
Bar as RechartsBar2,
|
|
337
|
+
Area as RechartsArea2,
|
|
338
|
+
XAxis as RechartsXAxis5,
|
|
339
|
+
YAxis as RechartsYAxis5,
|
|
340
|
+
CartesianGrid as CartesianGrid5
|
|
341
|
+
} from "recharts";
|
|
342
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
343
|
+
var ComposedChart = ({
|
|
344
|
+
data,
|
|
345
|
+
height,
|
|
346
|
+
colorPalette,
|
|
347
|
+
className,
|
|
348
|
+
style,
|
|
349
|
+
grid = true,
|
|
350
|
+
borderVariant = "default",
|
|
351
|
+
children
|
|
352
|
+
}) => {
|
|
353
|
+
let seriesIndex = 0;
|
|
354
|
+
const themedChildren = Children7.map(children, (child) => {
|
|
355
|
+
if (!isValidElement7(child)) return child;
|
|
356
|
+
const themedAxis = themeAxisChild({ child, variant: borderVariant, XAxis: RechartsXAxis5, YAxis: RechartsYAxis5 });
|
|
357
|
+
if (themedAxis) return themedAxis;
|
|
358
|
+
const t = child.type;
|
|
359
|
+
const dn = t?.displayName;
|
|
360
|
+
if (t === RechartsLine2 || dn === "Line") {
|
|
361
|
+
const idx = seriesIndex++;
|
|
362
|
+
return cloneElement7(child, {
|
|
363
|
+
stroke: child.props.stroke || getSeriesColor({ index: idx, palette: colorPalette }),
|
|
364
|
+
strokeWidth: child.props.strokeWidth ?? 2,
|
|
365
|
+
dot: child.props.dot ?? false
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (t === RechartsBar2 || dn === "Bar") {
|
|
369
|
+
const idx = seriesIndex++;
|
|
370
|
+
return cloneElement7(child, {
|
|
371
|
+
fill: child.props.fill || getSeriesColor({ index: idx, palette: colorPalette }),
|
|
372
|
+
radius: child.props.radius ?? [4, 4, 0, 0]
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (t === RechartsArea2 || dn === "Area") {
|
|
376
|
+
const idx = seriesIndex++;
|
|
377
|
+
const color = child.props.stroke || getSeriesColor({ index: idx, palette: colorPalette });
|
|
378
|
+
return cloneElement7(child, {
|
|
379
|
+
stroke: color,
|
|
380
|
+
fill: child.props.fill || color,
|
|
381
|
+
fillOpacity: child.props.fillOpacity ?? 0.15,
|
|
382
|
+
strokeWidth: child.props.strokeWidth ?? 2
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return child;
|
|
386
|
+
});
|
|
387
|
+
return /* @__PURE__ */ jsx8(ChartContainer, { height, className, style, children: /* @__PURE__ */ jsxs5(RechartsComposedChart, { data, margin: { top: 5, right: 20, bottom: 5, left: 0 }, children: [
|
|
388
|
+
grid && /* @__PURE__ */ jsx8(CartesianGrid5, { strokeDasharray: "3 3", stroke: getGridColor(), opacity: 0.5 }),
|
|
389
|
+
themedChildren
|
|
390
|
+
] }) });
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/charts/ThemedTooltip.tsx
|
|
394
|
+
import { useMemo } from "react";
|
|
395
|
+
import { Tooltip as RechartsTooltip } from "recharts";
|
|
396
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
397
|
+
var ThemedTooltip = (props) => {
|
|
398
|
+
const style = useMemo(() => getTooltipStyle(), []);
|
|
399
|
+
return /* @__PURE__ */ jsx9(
|
|
400
|
+
RechartsTooltip,
|
|
401
|
+
{
|
|
402
|
+
contentStyle: style.contentStyle,
|
|
403
|
+
labelStyle: style.labelStyle,
|
|
404
|
+
cursor: { stroke: "var(--color-border-secondary, #e5e7eb)", strokeWidth: 1 },
|
|
405
|
+
...props
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// src/charts/index.ts
|
|
411
|
+
import {
|
|
412
|
+
Line,
|
|
413
|
+
Bar,
|
|
414
|
+
Area,
|
|
415
|
+
Pie,
|
|
416
|
+
Scatter,
|
|
417
|
+
Radar,
|
|
418
|
+
Cell as Cell2,
|
|
419
|
+
XAxis,
|
|
420
|
+
YAxis,
|
|
421
|
+
CartesianGrid as CartesianGrid6,
|
|
422
|
+
Legend,
|
|
423
|
+
PolarGrid,
|
|
424
|
+
PolarAngleAxis,
|
|
425
|
+
PolarRadiusAxis,
|
|
426
|
+
Tooltip,
|
|
427
|
+
ReferenceLine,
|
|
428
|
+
ReferenceArea,
|
|
429
|
+
ResponsiveContainer as ResponsiveContainer2
|
|
430
|
+
} from "recharts";
|
|
431
|
+
export {
|
|
432
|
+
Area,
|
|
433
|
+
AreaChart,
|
|
434
|
+
Bar,
|
|
435
|
+
BarChart,
|
|
436
|
+
CartesianGrid6 as CartesianGrid,
|
|
437
|
+
Cell2 as Cell,
|
|
438
|
+
ComposedChart,
|
|
439
|
+
DEFAULT_PALETTE,
|
|
440
|
+
Legend,
|
|
441
|
+
Line,
|
|
442
|
+
LineChart,
|
|
443
|
+
Pie,
|
|
444
|
+
PieChart,
|
|
445
|
+
PolarAngleAxis,
|
|
446
|
+
PolarGrid,
|
|
447
|
+
PolarRadiusAxis,
|
|
448
|
+
Radar,
|
|
449
|
+
RadarChart,
|
|
450
|
+
Tooltip as RechartsTooltip,
|
|
451
|
+
ReferenceArea,
|
|
452
|
+
ReferenceLine,
|
|
453
|
+
ResponsiveContainer2 as ResponsiveContainer,
|
|
454
|
+
Scatter,
|
|
455
|
+
ScatterChart,
|
|
456
|
+
ThemedTooltip as Tooltip,
|
|
457
|
+
XAxis,
|
|
458
|
+
YAxis
|
|
459
|
+
};
|
|
460
|
+
//# sourceMappingURL=index.js.map
|