funuicss 3.7.0 → 3.7.2
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/css/fun.css +552 -71
- package/index.d.ts +1 -1
- package/index.js +6 -1
- package/package.json +1 -1
- package/ui/calendar/Calendar.js +1 -1
- package/ui/chart/Bar.d.ts +98 -12
- package/ui/chart/Bar.js +387 -40
- package/ui/chart/Line.js +246 -149
- package/ui/chart/Pie.d.ts +61 -7
- package/ui/chart/Pie.js +314 -38
- package/ui/drop/Dropdown.d.ts +4 -3
- package/ui/drop/Dropdown.js +24 -29
- package/ui/input/Input.js +46 -21
- package/ui/richtext/RichText.js +1 -1
- package/ui/specials/Circle.d.ts +2 -1
- package/ui/specials/Circle.js +2 -5
- package/ui/table/Table.d.ts +2 -1
- package/ui/table/Table.js +66 -63
- package/ui/text/Text.d.ts +1 -1
- package/ui/text/Text.js +50 -49
- package/ui/theme/theme.d.ts +34 -0
- package/ui/theme/theme.js +198 -18
- package/ui/vista/Vista.js +135 -49
- package/utils/componentUtils.js +27 -4
package/ui/chart/Line.js
CHANGED
|
@@ -48,190 +48,270 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
var react_1 = __importStar(require("react"));
|
|
49
49
|
var recharts_1 = require("recharts");
|
|
50
50
|
var componentUtils_1 = require("../../utils/componentUtils");
|
|
51
|
-
// Parse string to object utility
|
|
51
|
+
// Parse string to object utility with enhanced error handling
|
|
52
52
|
var parseIfString = function (value, fallback) {
|
|
53
53
|
if (typeof value === 'string') {
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
var parsed = JSON.parse(value);
|
|
56
|
+
// Additional validation for arrays
|
|
57
|
+
if (Array.isArray(fallback) && !Array.isArray(parsed)) {
|
|
58
|
+
console.warn('Parsed value is not an array, using fallback');
|
|
59
|
+
return fallback;
|
|
60
|
+
}
|
|
61
|
+
return parsed;
|
|
56
62
|
}
|
|
57
63
|
catch (error) {
|
|
58
64
|
console.error('Failed to parse JSON string:', error);
|
|
59
65
|
return fallback;
|
|
60
66
|
}
|
|
61
67
|
}
|
|
68
|
+
// Handle null/undefined values
|
|
69
|
+
if (value == null) {
|
|
70
|
+
return fallback;
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
// Safe array access utility
|
|
75
|
+
var getSafeArray = function (value, fallback) {
|
|
76
|
+
if (fallback === void 0) { fallback = []; }
|
|
77
|
+
if (!value || !Array.isArray(value))
|
|
78
|
+
return fallback;
|
|
62
79
|
return value;
|
|
63
80
|
};
|
|
64
|
-
// CSS var resolver
|
|
81
|
+
// CSS var resolver with error handling
|
|
65
82
|
var getCssVar = function (varName) {
|
|
66
83
|
var _a;
|
|
67
84
|
if (typeof window === 'undefined')
|
|
68
85
|
return '';
|
|
69
|
-
|
|
86
|
+
try {
|
|
87
|
+
return ((_a = getComputedStyle(document.documentElement).getPropertyValue("--".concat(varName))) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.warn("Failed to get CSS variable --".concat(varName, ":"), error);
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
70
93
|
};
|
|
71
|
-
// Color resolver
|
|
94
|
+
// Color resolver with fallbacks
|
|
72
95
|
var resolveStrokeColor = function (color) {
|
|
73
96
|
if (!color)
|
|
74
97
|
return getCssVar('primary') || '#8884d8';
|
|
75
98
|
if (color.startsWith('#'))
|
|
76
99
|
return color;
|
|
77
|
-
|
|
100
|
+
var cssColor = getCssVar(color);
|
|
101
|
+
if (cssColor)
|
|
102
|
+
return cssColor;
|
|
103
|
+
// Fallback to common color names if CSS var not found
|
|
104
|
+
var colorMap = {
|
|
105
|
+
primary: '#8884d8',
|
|
106
|
+
secondary: '#82ca9d',
|
|
107
|
+
error: '#ff4d4f',
|
|
108
|
+
warning: '#faad14',
|
|
109
|
+
success: '#52c41a'
|
|
110
|
+
};
|
|
111
|
+
return colorMap[color] || color || '#8884d8';
|
|
78
112
|
};
|
|
79
|
-
// Default Tooltip
|
|
113
|
+
// Default Tooltip with error handling
|
|
80
114
|
var CustomTooltip = function (_a) {
|
|
81
115
|
var active = _a.active, payload = _a.payload, label = _a.label, formatter = _a.formatter;
|
|
82
|
-
if (active
|
|
116
|
+
if (!active || !payload || !Array.isArray(payload) || payload.length === 0) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
83
120
|
return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm", style: {
|
|
84
121
|
maxWidth: '300px'
|
|
85
122
|
} },
|
|
86
|
-
react_1.default.createElement("div", { className: "text-bold mb-1" }, label),
|
|
87
|
-
payload.map(function (entry, index) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
react_1.default.createElement("div", { className: "text-bold mb-1" }, label || 'N/A'),
|
|
124
|
+
payload.map(function (entry, index) {
|
|
125
|
+
if (!entry)
|
|
126
|
+
return null;
|
|
127
|
+
var value = formatter ? formatter(entry.value, entry.name, entry) : entry.value;
|
|
128
|
+
var displayValue = value != null ? value : 'N/A';
|
|
129
|
+
var displayName = entry.name || 'Unknown';
|
|
130
|
+
var displayColor = entry.color || '#8884d8';
|
|
131
|
+
return (react_1.default.createElement("div", { key: index, style: {
|
|
132
|
+
lineHeight: 1.4,
|
|
133
|
+
display: 'flex',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
gap: '8px'
|
|
136
|
+
} },
|
|
137
|
+
react_1.default.createElement("div", { style: {
|
|
138
|
+
width: '12px',
|
|
139
|
+
height: '12px',
|
|
140
|
+
backgroundColor: displayColor,
|
|
141
|
+
borderRadius: '2px'
|
|
142
|
+
} }),
|
|
143
|
+
react_1.default.createElement("span", { style: { fontWeight: 500 } },
|
|
144
|
+
displayName,
|
|
145
|
+
":"),
|
|
146
|
+
react_1.default.createElement("span", { style: { fontWeight: 600, color: 'var(--text-color, #1a202c)' } }, displayValue)));
|
|
147
|
+
})));
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error('Error rendering tooltip:', error);
|
|
151
|
+
return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm" },
|
|
152
|
+
react_1.default.createElement("div", { className: "text-error" }, "Error displaying tooltip")));
|
|
103
153
|
}
|
|
104
|
-
return null;
|
|
105
154
|
};
|
|
106
155
|
var Lines = function (_a) {
|
|
107
|
-
var _b;
|
|
108
|
-
var data = _a.data, id = _a.id, series = _a.series, fromColor = _a.fromColor, toColor = _a.toColor, dy = _a.dy,
|
|
109
|
-
// Use component configuration with variant support
|
|
156
|
+
var _b, _c;
|
|
157
|
+
var data = _a.data, id = _a.id, series = _a.series, fromColor = _a.fromColor, toColor = _a.toColor, dy = _a.dy, _d = _a.showGrid, showGrid = _d === void 0 ? true : _d, _e = _a.horizontalLines, horizontalLines = _e === void 0 ? false : _e, _f = _a.showLegend, showLegend = _f === void 0 ? true : _f, _g = _a.showXAxis, showXAxis = _g === void 0 ? true : _g, _h = _a.showYAxis, showYAxis = _h === void 0 ? false : _h, _j = _a.showTooltip, showTooltip = _j === void 0 ? true : _j, funcss = _a.funcss, _k = _a.curveType, curveType = _k === void 0 ? 'monotone' : _k, _l = _a.height, height = _l === void 0 ? "100%" : _l, _m = _a.width, width = _m === void 0 ? '100%' : _m, _o = _a.margin, margin = _o === void 0 ? { top: 10, right: 30, left: 0, bottom: 20 } : _o, _p = _a.xAxisProps, xAxisProps = _p === void 0 ? {} : _p, _q = _a.yAxisProps, yAxisProps = _q === void 0 ? {} : _q, tooltipFormatter = _a.tooltipFormatter, _r = _a.legendProps, legendProps = _r === void 0 ? {} : _r, _s = _a.tooltipProps, tooltipProps = _s === void 0 ? {} : _s, rotateLabel = _a.rotateLabel, xLabelSize = _a.xLabelSize, yLabelSize = _a.yLabelSize, xInterval = _a.xInterval, yInterval = _a.yInterval, _t = _a.variant, variant = _t === void 0 ? '' : _t, xAxisLabel = _a.xAxisLabel, yAxisLabel = _a.yAxisLabel, _u = _a.tickLine, tickLine = _u === void 0 ? true : _u, _v = _a.axisLine, axisLine = _v === void 0 ? true : _v, gridStroke = _a.gridStroke, _w = _a.gridStrokeDasharray, gridStrokeDasharray = _w === void 0 ? "3 3" : _w, customTooltip = _a.customTooltip, _x = _a.animation, animation = _x === void 0 ? true : _x, _y = _a.animationDuration, animationDuration = _y === void 0 ? 500 : _y, _z = _a.isAnimationActive, isAnimationActive = _z === void 0 ? true : _z, syncId = _a.syncId, chartBackground = _a.chartBackground, borderRadius = _a.borderRadius, padding = _a.padding, _0 = _a.shadow, shadow = _0 === void 0 ? false : _0, aspect = _a.aspect, minHeight = _a.minHeight, maxHeight = _a.maxHeight, minWidth = _a.minWidth, maxWidth = _a.maxWidth;
|
|
158
|
+
// Use component configuration with variant support and error handling
|
|
110
159
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('AreaChart', variant).mergeWithLocal;
|
|
111
|
-
// Create local props object
|
|
160
|
+
// Create local props object with null checks
|
|
112
161
|
var localProps = {
|
|
113
|
-
data: data,
|
|
114
|
-
id: id,
|
|
115
|
-
series: series,
|
|
116
|
-
fromColor: fromColor,
|
|
117
|
-
toColor: toColor,
|
|
118
|
-
dy: dy,
|
|
119
|
-
showGrid: showGrid,
|
|
120
|
-
horizontalLines: horizontalLines,
|
|
121
|
-
showLegend: showLegend,
|
|
122
|
-
showXAxis: showXAxis,
|
|
123
|
-
showYAxis: showYAxis,
|
|
124
|
-
showTooltip: showTooltip,
|
|
125
|
-
funcss: funcss,
|
|
126
|
-
curveType: curveType,
|
|
127
|
-
height: height,
|
|
128
|
-
width: width,
|
|
129
|
-
margin: margin,
|
|
130
|
-
xAxisProps: xAxisProps,
|
|
131
|
-
yAxisProps: yAxisProps,
|
|
132
|
-
tooltipFormatter: tooltipFormatter,
|
|
133
|
-
legendProps: legendProps,
|
|
134
|
-
tooltipProps: tooltipProps,
|
|
135
|
-
rotateLabel: rotateLabel,
|
|
136
|
-
xLabelSize: xLabelSize,
|
|
137
|
-
yLabelSize: yLabelSize,
|
|
138
|
-
xInterval: xInterval,
|
|
139
|
-
yInterval: yInterval,
|
|
140
|
-
xAxisLabel: xAxisLabel,
|
|
141
|
-
yAxisLabel: yAxisLabel,
|
|
142
|
-
tickLine: tickLine,
|
|
143
|
-
axisLine: axisLine,
|
|
144
|
-
gridStroke: gridStroke,
|
|
145
|
-
gridStrokeDasharray: gridStrokeDasharray,
|
|
146
|
-
customTooltip: customTooltip,
|
|
147
|
-
animation: animation,
|
|
148
|
-
animationDuration: animationDuration,
|
|
149
|
-
isAnimationActive: isAnimationActive,
|
|
150
|
-
syncId: syncId,
|
|
151
|
-
chartBackground: chartBackground,
|
|
152
|
-
borderRadius: borderRadius,
|
|
153
|
-
padding: padding,
|
|
154
|
-
shadow: shadow,
|
|
155
|
-
aspect: aspect,
|
|
156
|
-
minHeight: minHeight,
|
|
157
|
-
maxHeight: maxHeight,
|
|
158
|
-
minWidth: minWidth,
|
|
159
|
-
maxWidth: maxWidth
|
|
162
|
+
data: data !== null && data !== void 0 ? data : [],
|
|
163
|
+
id: id !== null && id !== void 0 ? id : '',
|
|
164
|
+
series: series !== null && series !== void 0 ? series : [],
|
|
165
|
+
fromColor: fromColor !== null && fromColor !== void 0 ? fromColor : '',
|
|
166
|
+
toColor: toColor !== null && toColor !== void 0 ? toColor : '',
|
|
167
|
+
dy: dy !== null && dy !== void 0 ? dy : 0,
|
|
168
|
+
showGrid: showGrid !== null && showGrid !== void 0 ? showGrid : true,
|
|
169
|
+
horizontalLines: horizontalLines !== null && horizontalLines !== void 0 ? horizontalLines : false,
|
|
170
|
+
showLegend: showLegend !== null && showLegend !== void 0 ? showLegend : true,
|
|
171
|
+
showXAxis: showXAxis !== null && showXAxis !== void 0 ? showXAxis : true,
|
|
172
|
+
showYAxis: showYAxis !== null && showYAxis !== void 0 ? showYAxis : false,
|
|
173
|
+
showTooltip: showTooltip !== null && showTooltip !== void 0 ? showTooltip : true,
|
|
174
|
+
funcss: funcss !== null && funcss !== void 0 ? funcss : '',
|
|
175
|
+
curveType: curveType !== null && curveType !== void 0 ? curveType : 'monotone',
|
|
176
|
+
height: height !== null && height !== void 0 ? height : "100%",
|
|
177
|
+
width: width !== null && width !== void 0 ? width : '100%',
|
|
178
|
+
margin: margin !== null && margin !== void 0 ? margin : { top: 10, right: 30, left: 0, bottom: 20 },
|
|
179
|
+
xAxisProps: xAxisProps !== null && xAxisProps !== void 0 ? xAxisProps : {},
|
|
180
|
+
yAxisProps: yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {},
|
|
181
|
+
tooltipFormatter: tooltipFormatter !== null && tooltipFormatter !== void 0 ? tooltipFormatter : undefined,
|
|
182
|
+
legendProps: legendProps !== null && legendProps !== void 0 ? legendProps : {},
|
|
183
|
+
tooltipProps: tooltipProps !== null && tooltipProps !== void 0 ? tooltipProps : {},
|
|
184
|
+
rotateLabel: rotateLabel !== null && rotateLabel !== void 0 ? rotateLabel : 0,
|
|
185
|
+
xLabelSize: xLabelSize !== null && xLabelSize !== void 0 ? xLabelSize : "0.8rem",
|
|
186
|
+
yLabelSize: yLabelSize !== null && yLabelSize !== void 0 ? yLabelSize : "0.8rem",
|
|
187
|
+
xInterval: xInterval !== null && xInterval !== void 0 ? xInterval : undefined,
|
|
188
|
+
yInterval: yInterval !== null && yInterval !== void 0 ? yInterval : undefined,
|
|
189
|
+
xAxisLabel: xAxisLabel !== null && xAxisLabel !== void 0 ? xAxisLabel : '',
|
|
190
|
+
yAxisLabel: yAxisLabel !== null && yAxisLabel !== void 0 ? yAxisLabel : '',
|
|
191
|
+
tickLine: tickLine !== null && tickLine !== void 0 ? tickLine : true,
|
|
192
|
+
axisLine: axisLine !== null && axisLine !== void 0 ? axisLine : true,
|
|
193
|
+
gridStroke: gridStroke !== null && gridStroke !== void 0 ? gridStroke : '',
|
|
194
|
+
gridStrokeDasharray: gridStrokeDasharray !== null && gridStrokeDasharray !== void 0 ? gridStrokeDasharray : "3 3",
|
|
195
|
+
customTooltip: customTooltip !== null && customTooltip !== void 0 ? customTooltip : undefined,
|
|
196
|
+
animation: animation !== null && animation !== void 0 ? animation : true,
|
|
197
|
+
animationDuration: animationDuration !== null && animationDuration !== void 0 ? animationDuration : 500,
|
|
198
|
+
isAnimationActive: isAnimationActive !== null && isAnimationActive !== void 0 ? isAnimationActive : true,
|
|
199
|
+
syncId: syncId !== null && syncId !== void 0 ? syncId : '',
|
|
200
|
+
chartBackground: chartBackground !== null && chartBackground !== void 0 ? chartBackground : '',
|
|
201
|
+
borderRadius: borderRadius !== null && borderRadius !== void 0 ? borderRadius : '',
|
|
202
|
+
padding: padding !== null && padding !== void 0 ? padding : '',
|
|
203
|
+
shadow: shadow !== null && shadow !== void 0 ? shadow : false,
|
|
204
|
+
aspect: aspect !== null && aspect !== void 0 ? aspect : undefined,
|
|
205
|
+
minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : undefined,
|
|
206
|
+
maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
|
|
207
|
+
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : undefined,
|
|
208
|
+
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : undefined
|
|
160
209
|
};
|
|
161
|
-
// Merge with config - LOCAL PROPS OVERRIDE CONFIG
|
|
162
|
-
var mergedProps
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
// Merge with config - LOCAL PROPS OVERRIDE CONFIG with error handling
|
|
211
|
+
var mergedProps;
|
|
212
|
+
try {
|
|
213
|
+
var result = mergeWithLocal(localProps);
|
|
214
|
+
mergedProps = (_b = result === null || result === void 0 ? void 0 : result.props) !== null && _b !== void 0 ? _b : localProps;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
console.error('Error merging component configuration:', error);
|
|
218
|
+
mergedProps = localProps;
|
|
219
|
+
}
|
|
220
|
+
// Parse data and series if they're strings with enhanced validation
|
|
221
|
+
var parsedData = (0, react_1.useMemo)(function () {
|
|
222
|
+
var parsed = parseIfString(mergedProps.data, []);
|
|
223
|
+
return getSafeArray(parsed);
|
|
224
|
+
}, [mergedProps.data]);
|
|
225
|
+
var parsedSeries = (0, react_1.useMemo)(function () {
|
|
226
|
+
var parsed = parseIfString(mergedProps.series, []);
|
|
227
|
+
return getSafeArray(parsed).filter(function (series) {
|
|
228
|
+
return series && typeof series === 'object' && series.dataKey;
|
|
229
|
+
});
|
|
230
|
+
}, [mergedProps.series]);
|
|
231
|
+
// Check if we have valid data to display
|
|
232
|
+
var hasValidData = parsedData.length > 0 && parsedSeries.length > 0;
|
|
233
|
+
// Extract final values with fallbacks
|
|
234
|
+
var final = (0, react_1.useMemo)(function () {
|
|
235
|
+
var _a, _b, _c, _d, _e, _f;
|
|
236
|
+
return ({
|
|
237
|
+
data: parsedData,
|
|
238
|
+
id: mergedProps.id || 'area-chart',
|
|
239
|
+
series: parsedSeries,
|
|
240
|
+
fromColor: mergedProps.fromColor || '',
|
|
241
|
+
toColor: mergedProps.toColor || '',
|
|
242
|
+
dy: mergedProps.dy || 0,
|
|
243
|
+
showGrid: (_a = mergedProps.showGrid) !== null && _a !== void 0 ? _a : true,
|
|
244
|
+
horizontalLines: (_b = mergedProps.horizontalLines) !== null && _b !== void 0 ? _b : false,
|
|
245
|
+
showLegend: mergedProps.showLegend,
|
|
246
|
+
showXAxis: mergedProps.showXAxis,
|
|
247
|
+
showYAxis: mergedProps.showYAxis,
|
|
248
|
+
showTooltip: mergedProps.showTooltip,
|
|
249
|
+
funcss: mergedProps.funcss || '',
|
|
250
|
+
curveType: mergedProps.curveType || 'monotone',
|
|
251
|
+
height: mergedProps.height || "100%",
|
|
252
|
+
width: mergedProps.width || '100%',
|
|
253
|
+
margin: mergedProps.margin || { top: 10, right: 30, left: 0, bottom: 20 },
|
|
254
|
+
xAxisProps: mergedProps.xAxisProps || {},
|
|
255
|
+
yAxisProps: mergedProps.yAxisProps || {},
|
|
256
|
+
tooltipFormatter: mergedProps.tooltipFormatter,
|
|
257
|
+
legendProps: mergedProps.legendProps || {},
|
|
258
|
+
tooltipProps: mergedProps.tooltipProps || {},
|
|
259
|
+
rotateLabel: mergedProps.rotateLabel || 0,
|
|
260
|
+
xLabelSize: mergedProps.xLabelSize || "0.8rem",
|
|
261
|
+
yLabelSize: mergedProps.yLabelSize || "0.8rem",
|
|
262
|
+
xInterval: mergedProps.xInterval,
|
|
263
|
+
yInterval: mergedProps.yInterval,
|
|
264
|
+
xAxisLabel: mergedProps.xAxisLabel || '',
|
|
265
|
+
yAxisLabel: mergedProps.yAxisLabel || '',
|
|
266
|
+
tickLine: (_c = mergedProps.tickLine) !== null && _c !== void 0 ? _c : true,
|
|
267
|
+
axisLine: (_d = mergedProps.axisLine) !== null && _d !== void 0 ? _d : true,
|
|
268
|
+
gridStroke: mergedProps.gridStroke || '',
|
|
269
|
+
gridStrokeDasharray: mergedProps.gridStrokeDasharray || "3 3",
|
|
270
|
+
customTooltip: mergedProps.customTooltip,
|
|
271
|
+
animation: (_e = mergedProps.animation) !== null && _e !== void 0 ? _e : true,
|
|
272
|
+
animationDuration: mergedProps.animationDuration || 500,
|
|
273
|
+
isAnimationActive: mergedProps.isAnimationActive,
|
|
274
|
+
syncId: mergedProps.syncId || '',
|
|
275
|
+
chartBackground: mergedProps.chartBackground || '',
|
|
276
|
+
borderRadius: mergedProps.borderRadius || '',
|
|
277
|
+
padding: mergedProps.padding || '',
|
|
278
|
+
shadow: (_f = mergedProps.shadow) !== null && _f !== void 0 ? _f : false,
|
|
279
|
+
aspect: mergedProps.aspect,
|
|
280
|
+
minHeight: mergedProps.minHeight,
|
|
281
|
+
maxHeight: mergedProps.maxHeight,
|
|
282
|
+
minWidth: mergedProps.minWidth,
|
|
283
|
+
maxWidth: mergedProps.maxWidth
|
|
284
|
+
});
|
|
285
|
+
}, [parsedData, parsedSeries, mergedProps, hasValidData]);
|
|
216
286
|
var baseGradientId = final.id || 'areaChartGradient';
|
|
217
287
|
var TooltipComponent = final.customTooltip || CustomTooltip;
|
|
218
|
-
// Generate per-series gradients
|
|
288
|
+
// Generate per-series gradients with error handling
|
|
219
289
|
var gradients = (0, react_1.useMemo)(function () {
|
|
290
|
+
if (!final.series || !Array.isArray(final.series))
|
|
291
|
+
return [];
|
|
220
292
|
return final.series.map(function (s, index) {
|
|
221
|
-
if (!s
|
|
293
|
+
if (!s || typeof s !== 'object')
|
|
222
294
|
return null;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
295
|
+
try {
|
|
296
|
+
if (!s.fromColor && !s.toColor)
|
|
297
|
+
return null;
|
|
298
|
+
var gradientId = "".concat(baseGradientId, "-").concat(index);
|
|
299
|
+
var startColor = resolveStrokeColor(s.fromColor || s.color || final.fromColor);
|
|
300
|
+
var endColor = resolveStrokeColor(s.toColor || final.toColor);
|
|
301
|
+
return (react_1.default.createElement("linearGradient", { key: gradientId, id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1" },
|
|
302
|
+
react_1.default.createElement("stop", { offset: "5%", stopColor: startColor, stopOpacity: 0.8 }),
|
|
303
|
+
react_1.default.createElement("stop", { offset: "95%", stopColor: endColor, stopOpacity: 0 })));
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
console.error('Error generating gradient for series:', error);
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
}).filter(Boolean);
|
|
230
310
|
}, [final.series, baseGradientId, final.fromColor, final.toColor]);
|
|
231
311
|
// Default gradient for series without custom gradients
|
|
232
312
|
var defaultGradient = (0, react_1.useMemo)(function () { return (react_1.default.createElement("linearGradient", { id: baseGradientId, x1: "0", y1: "0", x2: "0", y2: "1" },
|
|
233
|
-
react_1.default.createElement("stop", { offset: "5%", stopColor: getCssVar(final.fromColor || 'primary'), stopOpacity: 0.8 }),
|
|
234
|
-
react_1.default.createElement("stop", { offset: "95%", stopColor: getCssVar(final.toColor || 'primary200'), stopOpacity: 0 }))); }, [baseGradientId, final.fromColor, final.toColor]);
|
|
313
|
+
react_1.default.createElement("stop", { offset: "5%", stopColor: getCssVar(final.fromColor || 'primary') || '#8884d8', stopOpacity: 0.8 }),
|
|
314
|
+
react_1.default.createElement("stop", { offset: "95%", stopColor: getCssVar(final.toColor || 'primary200') || '#8884d8', stopOpacity: 0 }))); }, [baseGradientId, final.fromColor, final.toColor]);
|
|
235
315
|
var containerStyle = (0, react_1.useMemo)(function () { return ({
|
|
236
316
|
height: final.height,
|
|
237
317
|
width: final.width,
|
|
@@ -244,6 +324,13 @@ var Lines = function (_a) {
|
|
|
244
324
|
padding: final.padding,
|
|
245
325
|
boxShadow: final.shadow ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : undefined,
|
|
246
326
|
}); }, [final]);
|
|
327
|
+
// Show empty state if no data
|
|
328
|
+
if (!hasValidData) {
|
|
329
|
+
return (react_1.default.createElement("div", { className: "flex items-center justify-center ".concat(final.funcss), style: containerStyle },
|
|
330
|
+
react_1.default.createElement("div", { className: "text-center text-muted" },
|
|
331
|
+
react_1.default.createElement("div", { className: "text-lg mb-2" }, "\uD83D\uDCCA"),
|
|
332
|
+
react_1.default.createElement("div", null, "No chart data available"))));
|
|
333
|
+
}
|
|
247
334
|
return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: final.height, aspect: final.aspect, className: final.funcss, style: containerStyle },
|
|
248
335
|
react_1.default.createElement(recharts_1.AreaChart, { data: final.data, margin: final.margin, syncId: final.syncId },
|
|
249
336
|
react_1.default.createElement("defs", null,
|
|
@@ -251,16 +338,26 @@ var Lines = function (_a) {
|
|
|
251
338
|
gradients),
|
|
252
339
|
final.showGrid && (react_1.default.createElement(recharts_1.CartesianGrid, { strokeDasharray: final.gridStrokeDasharray, stroke: final.gridStroke || getCssVar('border-color') || '#e2e8f0' })),
|
|
253
340
|
!final.showGrid && final.horizontalLines && (react_1.default.createElement(recharts_1.CartesianGrid, { strokeDasharray: final.gridStrokeDasharray, horizontal: true, vertical: false, stroke: final.gridStroke || getCssVar('border-color') || '#e2e8f0' })),
|
|
254
|
-
final.showXAxis && (react_1.default.createElement(recharts_1.XAxis, __assign({ interval: final.xInterval, padding: { left: 10, right: 10 }, fontSize: final.xLabelSize || "0.8rem", strokeWidth: final.horizontalLines ? 0 : 0.2, dataKey: "label", angle: final.rotateLabel || -35, dy: (
|
|
341
|
+
final.showXAxis && (react_1.default.createElement(recharts_1.XAxis, __assign({ interval: final.xInterval, padding: { left: 10, right: 10 }, fontSize: final.xLabelSize || "0.8rem", strokeWidth: final.horizontalLines ? 0 : 0.2, dataKey: "label", angle: final.rotateLabel || -35, dy: (_c = final.dy) !== null && _c !== void 0 ? _c : 10, tickLine: final.tickLine, axisLine: final.axisLine, label: final.xAxisLabel ? { value: final.xAxisLabel, position: 'insideBottom', offset: -10 } : undefined }, final.xAxisProps))),
|
|
255
342
|
final.showYAxis && (react_1.default.createElement(recharts_1.YAxis, __assign({ interval: final.yInterval, strokeWidth: final.horizontalLines ? 0 : 0.2, fontSize: final.yLabelSize || "0.8rem", tickLine: final.tickLine, axisLine: final.axisLine, label: final.yAxisLabel ? { value: final.yAxisLabel, angle: -90, position: 'insideLeft' } : undefined }, final.yAxisProps))),
|
|
256
343
|
final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
|
|
257
344
|
final.showLegend && react_1.default.createElement(recharts_1.Legend, __assign({}, final.legendProps)),
|
|
258
345
|
final.series.map(function (s, index) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
346
|
+
if (!s || !s.dataKey) {
|
|
347
|
+
console.warn('Invalid series configuration at index:', index);
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
var hasCustomGradient = s.fromColor || s.toColor;
|
|
352
|
+
var gradientId = hasCustomGradient
|
|
353
|
+
? "".concat(baseGradientId, "-").concat(index)
|
|
354
|
+
: baseGradientId;
|
|
355
|
+
return (react_1.default.createElement(recharts_1.Area, { key: s.dataKey || "series-".concat(index), type: final.curveType, dataKey: s.dataKey, name: s.label || s.dataKey, stroke: resolveStrokeColor(s.color), fill: hasCustomGradient || final.fromColor ? "url(#".concat(gradientId, ")") : resolveStrokeColor(s.color), fillOpacity: s.fillOpacity !== undefined ? s.fillOpacity : 0.6, strokeWidth: s.strokeWidth || 2, strokeDasharray: s.strokeDasharray, dot: s.dot !== false ? { r: 4 } : false, activeDot: s.activeDot !== false ? (typeof s.activeDot === 'object' ? s.activeDot : { r: 6, strokeWidth: 2 }) : false, isAnimationActive: final.isAnimationActive, animationDuration: final.animationDuration }));
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
console.error('Error rendering area series:', error);
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
264
361
|
}))));
|
|
265
362
|
};
|
|
266
363
|
exports.default = Lines;
|
package/ui/chart/Pie.d.ts
CHANGED
|
@@ -3,19 +3,73 @@ type PieDataItem = {
|
|
|
3
3
|
label: string;
|
|
4
4
|
value: number;
|
|
5
5
|
color?: string;
|
|
6
|
+
[key: string]: any;
|
|
6
7
|
};
|
|
8
|
+
interface LegendProps {
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
11
|
+
layout?: 'horizontal' | 'vertical';
|
|
12
|
+
iconType?: 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye';
|
|
13
|
+
wrapperStyle?: Record<string, any>;
|
|
14
|
+
formatter?: (value: any, entry: any, index: number) => React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
interface TooltipProps {
|
|
17
|
+
cursor?: boolean | Record<string, any>;
|
|
18
|
+
separator?: string;
|
|
19
|
+
offset?: number;
|
|
20
|
+
allowEscapeViewBox?: {
|
|
21
|
+
x?: boolean;
|
|
22
|
+
y?: boolean;
|
|
23
|
+
};
|
|
24
|
+
wrapperStyle?: Record<string, any>;
|
|
25
|
+
}
|
|
7
26
|
interface PieChartProps {
|
|
8
|
-
data: PieDataItem[];
|
|
27
|
+
data: PieDataItem[] | string;
|
|
28
|
+
id?: string;
|
|
29
|
+
variant?: string;
|
|
9
30
|
donut?: boolean;
|
|
10
|
-
showLegend?: boolean;
|
|
11
|
-
funcss?: string;
|
|
12
31
|
width?: number | string;
|
|
13
|
-
legendCss: string;
|
|
14
32
|
height?: number | string;
|
|
15
|
-
outerRadius?: number;
|
|
16
|
-
innerRadius?: number;
|
|
33
|
+
outerRadius?: number | string;
|
|
34
|
+
innerRadius?: number | string;
|
|
35
|
+
paddingAngle?: number;
|
|
36
|
+
cornerRadius?: number;
|
|
37
|
+
startAngle?: number;
|
|
38
|
+
endAngle?: number;
|
|
39
|
+
minAngle?: number;
|
|
40
|
+
showLegend?: boolean;
|
|
41
|
+
showTooltip?: boolean;
|
|
42
|
+
showLabels?: boolean;
|
|
43
|
+
showLabelLine?: boolean;
|
|
44
|
+
labelPosition?: 'inside' | 'outside' | 'center' | 'radial';
|
|
45
|
+
legendPosition?: 'top' | 'bottom' | 'left' | 'right';
|
|
46
|
+
funcss?: string;
|
|
47
|
+
legendCss?: string;
|
|
48
|
+
chartBackground?: string;
|
|
49
|
+
borderRadius?: string;
|
|
50
|
+
padding?: string;
|
|
51
|
+
shadow?: boolean;
|
|
52
|
+
strokeWidth?: number;
|
|
53
|
+
strokeColor?: string;
|
|
54
|
+
activeShape?: boolean | Record<string, any>;
|
|
55
|
+
inactiveShape?: boolean | Record<string, any>;
|
|
17
56
|
tooltipFormatter?: (value: any, name: string, props: any) => React.ReactNode;
|
|
18
|
-
|
|
57
|
+
labelFormatter?: (value: any, name: string, props: any) => React.ReactNode;
|
|
58
|
+
legendProps?: LegendProps;
|
|
59
|
+
tooltipProps?: TooltipProps;
|
|
60
|
+
customTooltip?: React.ComponentType<any>;
|
|
61
|
+
customLabel?: React.ComponentType<any>;
|
|
62
|
+
animation?: boolean;
|
|
63
|
+
animationDuration?: number;
|
|
64
|
+
isAnimationActive?: boolean;
|
|
65
|
+
onPieClick?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
66
|
+
onPieEnter?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
67
|
+
onPieLeave?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
68
|
+
aspect?: number;
|
|
69
|
+
minHeight?: number | string;
|
|
70
|
+
maxHeight?: number | string;
|
|
71
|
+
minWidth?: number | string;
|
|
72
|
+
maxWidth?: number | string;
|
|
19
73
|
}
|
|
20
74
|
declare const ChartPie: React.FC<PieChartProps>;
|
|
21
75
|
export default ChartPie;
|