funuicss 3.7.1 → 3.7.3

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/ui/chart/Line.js CHANGED
@@ -152,71 +152,17 @@ var CustomTooltip = function (_a) {
152
152
  react_1.default.createElement("div", { className: "text-error" }, "Error displaying tooltip")));
153
153
  }
154
154
  };
155
- var Lines = function (_a) {
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
159
- var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('AreaChart', variant).mergeWithLocal;
160
- // Create local props object with null checks
161
- var localProps = {
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
209
- };
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
- }
155
+ var Lines = function (localProps) {
156
+ var _a;
157
+ // Use component configuration with variant support
158
+ var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Lines', localProps.variant).mergeWithLocal;
159
+ // Merge with config - LOCAL PROPS OVERRIDE CONFIG
160
+ var mergedProps = mergeWithLocal(localProps).props;
161
+ // Debug: Log what props are actually coming through
162
+ react_1.default.useEffect(function () {
163
+ console.log('Lines merged props:', mergedProps);
164
+ console.log('Lines config available:', Object.keys(mergedProps).length > 0);
165
+ }, [mergedProps]);
220
166
  // Parse data and series if they're strings with enhanced validation
221
167
  var parsedData = (0, react_1.useMemo)(function () {
222
168
  var parsed = parseIfString(mergedProps.data, []);
@@ -230,66 +176,15 @@ var Lines = function (_a) {
230
176
  }, [mergedProps.series]);
231
177
  // Check if we have valid data to display
232
178
  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]);
179
+ // Use mergedProps directly - no need for complex fallback logic
180
+ var final = mergedProps;
286
181
  var baseGradientId = final.id || 'areaChartGradient';
287
182
  var TooltipComponent = final.customTooltip || CustomTooltip;
288
183
  // Generate per-series gradients with error handling
289
184
  var gradients = (0, react_1.useMemo)(function () {
290
- if (!final.series || !Array.isArray(final.series))
185
+ if (!parsedSeries || !Array.isArray(parsedSeries))
291
186
  return [];
292
- return final.series.map(function (s, index) {
187
+ return parsedSeries.map(function (s, index) {
293
188
  if (!s || typeof s !== 'object')
294
189
  return null;
295
190
  try {
@@ -307,7 +202,7 @@ var Lines = function (_a) {
307
202
  return null;
308
203
  }
309
204
  }).filter(Boolean);
310
- }, [final.series, baseGradientId, final.fromColor, final.toColor]);
205
+ }, [parsedSeries, baseGradientId, final.fromColor, final.toColor]);
311
206
  // Default gradient for series without custom gradients
312
207
  var defaultGradient = (0, react_1.useMemo)(function () { return (react_1.default.createElement("linearGradient", { id: baseGradientId, x1: "0", y1: "0", x2: "0", y2: "1" },
313
208
  react_1.default.createElement("stop", { offset: "5%", stopColor: getCssVar(final.fromColor || 'primary') || '#8884d8', stopOpacity: 0.8 }),
@@ -332,17 +227,17 @@ var Lines = function (_a) {
332
227
  react_1.default.createElement("div", null, "No chart data available"))));
333
228
  }
334
229
  return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: final.height, aspect: final.aspect, className: final.funcss, style: containerStyle },
335
- react_1.default.createElement(recharts_1.AreaChart, { data: final.data, margin: final.margin, syncId: final.syncId },
230
+ react_1.default.createElement(recharts_1.AreaChart, { data: parsedData, margin: final.margin, syncId: final.syncId },
336
231
  react_1.default.createElement("defs", null,
337
232
  defaultGradient,
338
233
  gradients),
339
234
  final.showGrid && (react_1.default.createElement(recharts_1.CartesianGrid, { strokeDasharray: final.gridStrokeDasharray, stroke: final.gridStroke || getCssVar('border-color') || '#e2e8f0' })),
340
235
  !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' })),
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))),
236
+ 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: (_a = final.dy) !== null && _a !== void 0 ? _a : 10, tickLine: final.tickLine, axisLine: final.axisLine, label: final.xAxisLabel ? { value: final.xAxisLabel, position: 'insideBottom', offset: -10 } : undefined }, final.xAxisProps))),
342
237
  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))),
343
238
  final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
344
239
  final.showLegend && react_1.default.createElement(recharts_1.Legend, __assign({}, final.legendProps)),
345
- final.series.map(function (s, index) {
240
+ parsedSeries.map(function (s, index) {
346
241
  if (!s || !s.dataKey) {
347
242
  console.warn('Invalid series configuration at index:', index);
348
243
  return null;
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
- legendProps?: any;
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;
package/ui/chart/Pie.js CHANGED
@@ -11,53 +11,216 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  return __assign.apply(this, arguments);
13
13
  };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
17
47
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var react_1 = __importDefault(require("react"));
48
+ var react_1 = __importStar(require("react"));
19
49
  var recharts_1 = require("recharts");
20
- // Get CSS variable value from :root
50
+ var componentUtils_1 = require("../../utils/componentUtils");
51
+ // Parse string to object utility with enhanced error handling
52
+ var parseIfString = function (value, fallback) {
53
+ if (typeof value === 'string') {
54
+ try {
55
+ var parsed = JSON.parse(value);
56
+ if (Array.isArray(fallback) && !Array.isArray(parsed)) {
57
+ console.warn('Parsed value is not an array, using fallback');
58
+ return fallback;
59
+ }
60
+ return parsed;
61
+ }
62
+ catch (error) {
63
+ console.error('Failed to parse JSON string:', error);
64
+ return fallback;
65
+ }
66
+ }
67
+ if (value == null) {
68
+ return fallback;
69
+ }
70
+ return value;
71
+ };
72
+ // Safe array access utility
73
+ var getSafeArray = function (value, fallback) {
74
+ if (fallback === void 0) { fallback = []; }
75
+ if (!value || !Array.isArray(value))
76
+ return fallback;
77
+ return value;
78
+ };
79
+ // CSS var resolver with error handling
21
80
  var getCssVar = function (varName) {
22
81
  var _a;
23
82
  if (typeof window === 'undefined')
24
83
  return '';
25
- return (((_a = getComputedStyle(document.documentElement)
26
- .getPropertyValue("--".concat(varName))) === null || _a === void 0 ? void 0 : _a.trim()) || '');
27
- };
28
- // Resolve color from CSS var or fallback
29
- var resolveColor = function (input, fallback) {
30
- if (fallback === void 0) { fallback = '#8884d8'; }
31
- if (!input)
32
- return getCssVar('primary') || fallback;
33
- if (input.startsWith('#'))
34
- return input;
35
- return getCssVar(input) || input;
36
- };
37
- // Custom Tooltip
84
+ try {
85
+ return ((_a = getComputedStyle(document.documentElement).getPropertyValue("--".concat(varName))) === null || _a === void 0 ? void 0 : _a.trim()) || '';
86
+ }
87
+ catch (error) {
88
+ console.warn("Failed to get CSS variable --".concat(varName, ":"), error);
89
+ return '';
90
+ }
91
+ };
92
+ // Color resolver with fallbacks
93
+ var resolveColor = function (color) {
94
+ if (!color)
95
+ return getCssVar('primary') || '#8884d8';
96
+ if (color.startsWith('#'))
97
+ return color;
98
+ var cssColor = getCssVar(color);
99
+ if (cssColor)
100
+ return cssColor;
101
+ var colorMap = {
102
+ primary: '#8884d8',
103
+ secondary: '#82ca9d',
104
+ error: '#ff4d4f',
105
+ warning: '#faad14',
106
+ success: '#52c41a',
107
+ info: '#1890ff'
108
+ };
109
+ return colorMap[color] || color || '#8884d8';
110
+ };
111
+ // Default color palette for pie charts
112
+ var defaultColors = [
113
+ '#8884d8', '#82ca9d', '#ffc658', '#ff7300', '#8dd1e1',
114
+ '#d084d0', '#ff8042', '#a4de6c', '#d0ed57', '#ffbb28'
115
+ ];
116
+ // Default Tooltip with error handling
38
117
  var CustomTooltip = function (_a) {
39
- var active = _a.active, payload = _a.payload, label = _a.label;
40
- if (active && payload && payload.length) {
41
- return (react_1.default.createElement("div", { className: "dark raised round-edge p-2 text-sm" },
42
- react_1.default.createElement("div", { className: "text-bold" }, payload[0].name),
43
- react_1.default.createElement("div", { style: { lineHeight: 1 } },
44
- "Count: ",
45
- react_1.default.createElement("span", { className: "font-semibold" }, payload[0].value))));
46
- }
47
- return null;
48
- };
49
- var ChartPie = function (_a) {
50
- var data = _a.data, _b = _a.donut, donut = _b === void 0 ? false : _b, _c = _a.showLegend, showLegend = _c === void 0 ? true : _c, _d = _a.funcss, funcss = _d === void 0 ? '' : _d, width = _a.width, height = _a.height, _e = _a.outerRadius, outerRadius = _e === void 0 ? 100 : _e, innerRadius = _a.innerRadius, tooltipFormatter = _a.tooltipFormatter, legendCss = _a.legendCss, _f = _a.legendProps, legendProps = _f === void 0 ? {} : _f;
51
- var chart = (react_1.default.createElement(recharts_1.PieChart, { width: typeof width === 'number' ? width : undefined, height: typeof height === 'number' ? height : undefined },
52
- react_1.default.createElement(recharts_1.Tooltip, { content: react_1.default.createElement(CustomTooltip, null), formatter: tooltipFormatter }),
53
- showLegend && react_1.default.createElement(recharts_1.Legend, __assign({}, legendProps, { className: legendCss || "" })),
54
- react_1.default.createElement(recharts_1.Pie, { data: data, dataKey: "value", nameKey: "label", cx: "50%", cy: "50%", outerRadius: outerRadius, innerRadius: donut ? innerRadius !== null && innerRadius !== void 0 ? innerRadius : outerRadius * 0.6 : 0, label: false, labelLine: false }, data.map(function (entry, index) { return (react_1.default.createElement(recharts_1.Cell, { key: "cell-".concat(index), fill: resolveColor(entry.color), stroke: "#ffffff", strokeWidth: 1 })); }))));
55
- if (!width && !height) {
56
- return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: 300, className: funcss }, chart));
57
- }
58
- return (react_1.default.createElement("div", { className: funcss, style: {
59
- width: typeof width === 'number' ? "".concat(width, "px") : width || '100%',
60
- height: typeof height === 'number' ? "".concat(height, "px") : height || '300px',
61
- } }, chart));
118
+ var _b;
119
+ var active = _a.active, payload = _a.payload, label = _a.label, formatter = _a.formatter;
120
+ if (!active || !payload || !Array.isArray(payload) || payload.length === 0) {
121
+ return null;
122
+ }
123
+ try {
124
+ var data = payload[0];
125
+ return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm", style: {
126
+ maxWidth: '300px',
127
+ backgroundColor: 'var(--background, #fff)',
128
+ border: '1px solid var(--border-color, #e2e8f0)'
129
+ } },
130
+ react_1.default.createElement("div", { className: "text-bold mb-1", style: { color: 'var(--text-color, #1a202c)' } }, data.name || 'N/A'),
131
+ react_1.default.createElement("div", { style: { lineHeight: 1.4, display: 'flex', alignItems: 'center', gap: '8px' } },
132
+ react_1.default.createElement("div", { style: {
133
+ width: '12px',
134
+ height: '12px',
135
+ backgroundColor: data.color || ((_b = data.payload) === null || _b === void 0 ? void 0 : _b.fill) || '#8884d8',
136
+ borderRadius: '2px'
137
+ } }),
138
+ react_1.default.createElement("span", { style: { fontWeight: 500, color: 'var(--text-color, #1a202c)' } }, "Value:"),
139
+ react_1.default.createElement("span", { style: { fontWeight: 600, color: 'var(--text-color, #1a202c)' } }, formatter ? formatter(data.value, data.name, data) : data.value)),
140
+ data.payload && data.payload.percentage && (react_1.default.createElement("div", { style: { marginTop: '4px', fontSize: '0.75rem', color: 'var(--text-muted, #6b7280)' } },
141
+ data.payload.percentage,
142
+ "%"))));
143
+ }
144
+ catch (error) {
145
+ console.error('Error rendering tooltip:', error);
146
+ return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm" },
147
+ react_1.default.createElement("div", { className: "text-error" }, "Error displaying tooltip")));
148
+ }
149
+ };
150
+ // Default Label component
151
+ var CustomLabel = function (_a) {
152
+ var cx = _a.cx, cy = _a.cy, midAngle = _a.midAngle, innerRadius = _a.innerRadius, outerRadius = _a.outerRadius, percent = _a.percent, value = _a.value, name = _a.name;
153
+ if (!percent || percent < 0.05)
154
+ return null; // Hide labels for very small slices
155
+ var RADIAN = Math.PI / 180;
156
+ var radius = innerRadius + (outerRadius - innerRadius) * 0.5;
157
+ var x = cx + radius * Math.cos(-midAngle * RADIAN);
158
+ var y = cy + radius * Math.sin(-midAngle * RADIAN);
159
+ return (react_1.default.createElement("text", { x: x, y: y, fill: "white", textAnchor: x > cx ? 'start' : 'end', dominantBaseline: "central", fontSize: "12", fontWeight: "600" }, "".concat((percent * 100).toFixed(0), "%")));
160
+ };
161
+ var ChartPie = function (localProps) {
162
+ // Use component configuration with variant support
163
+ var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('ChartPie', localProps.variant).mergeWithLocal;
164
+ // Merge with config - LOCAL PROPS OVERRIDE CONFIG
165
+ var mergedProps = mergeWithLocal(localProps).props;
166
+ // Debug: Log what props are actually coming through
167
+ react_1.default.useEffect(function () {
168
+ console.log('ChartPie merged props:', mergedProps);
169
+ console.log('ChartPie config available:', Object.keys(mergedProps).length > 0);
170
+ }, [mergedProps]);
171
+ // Parse data if it's a string with enhanced validation
172
+ var parsedData = (0, react_1.useMemo)(function () {
173
+ var parsed = parseIfString(mergedProps.data, []);
174
+ var safeData = getSafeArray(parsed);
175
+ // Calculate percentages for tooltip
176
+ var total = safeData.reduce(function (sum, item) { return sum + (item.value || 0); }, 0);
177
+ return safeData.map(function (item) { return (__assign(__assign({}, item), { percentage: total > 0 ? ((item.value / total) * 100).toFixed(1) : '0' })); });
178
+ }, [mergedProps.data]);
179
+ // Check if we have valid data to display
180
+ var hasValidData = parsedData.length > 0;
181
+ // Use mergedProps directly - no need for complex fallback logic
182
+ var final = mergedProps;
183
+ // Configure legend based on position - WITH SAFE ACCESS
184
+ var legendConfig = (0, react_1.useMemo)(function () {
185
+ // Safely access legendProps with defaults
186
+ var safeLegendProps = final.legendProps || {};
187
+ var safeWrapperStyle = safeLegendProps.wrapperStyle || {};
188
+ var baseProps = __assign({ align: 'center', layout: final.legendPosition === 'left' || final.legendPosition === 'right' ? 'vertical' : 'horizontal', verticalAlign: final.legendPosition === 'top' ? 'top' : final.legendPosition === 'bottom' ? 'bottom' : 'middle', wrapperStyle: __assign({ paddingTop: final.legendPosition === 'top' ? '0' : '10px' }, safeWrapperStyle) }, safeLegendProps);
189
+ return baseProps;
190
+ }, [final.legendPosition, final.legendProps]);
191
+ var TooltipComponent = final.customTooltip || CustomTooltip;
192
+ var LabelComponent = final.customLabel || (final.showLabels ? CustomLabel : undefined);
193
+ var containerStyle = (0, react_1.useMemo)(function () { return ({
194
+ width: final.width,
195
+ height: final.height,
196
+ minHeight: final.minHeight,
197
+ maxHeight: final.maxHeight,
198
+ minWidth: final.minWidth,
199
+ maxWidth: final.maxWidth,
200
+ background: final.chartBackground,
201
+ borderRadius: final.borderRadius,
202
+ padding: final.padding,
203
+ boxShadow: final.shadow ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : undefined,
204
+ }); }, [final]);
205
+ // Calculate inner radius for donut chart
206
+ var innerRadius = (0, react_1.useMemo)(function () {
207
+ if (final.donut) {
208
+ return final.innerRadius || (typeof final.outerRadius === 'number' ? final.outerRadius * 0.6 : '60%');
209
+ }
210
+ return 0;
211
+ }, [final.donut, final.innerRadius, final.outerRadius]);
212
+ // Show empty state if no data
213
+ if (!hasValidData) {
214
+ return (react_1.default.createElement("div", { className: "flex items-center justify-center ".concat(final.funcss), style: containerStyle },
215
+ react_1.default.createElement("div", { className: "text-center text-muted" },
216
+ react_1.default.createElement("div", { className: "text-lg mb-2" }, "\uD83E\uDD67"),
217
+ react_1.default.createElement("div", null, "No chart data available"))));
218
+ }
219
+ var chartContent = (react_1.default.createElement(recharts_1.PieChart, null,
220
+ final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
221
+ final.showLegend && (react_1.default.createElement(recharts_1.Legend, __assign({}, legendConfig, { className: final.legendCss }))),
222
+ react_1.default.createElement(recharts_1.Pie, { data: parsedData, dataKey: "value", nameKey: "label", cx: "50%", cy: "50%", outerRadius: final.outerRadius, innerRadius: innerRadius, paddingAngle: final.paddingAngle, cornerRadius: final.cornerRadius, startAngle: final.startAngle, endAngle: final.endAngle, minAngle: final.minAngle, label: LabelComponent ? react_1.default.createElement(LabelComponent, null) : final.showLabels, labelLine: final.showLabelLine, isAnimationActive: final.isAnimationActive, animationDuration: final.animationDuration, onClick: final.onPieClick, onMouseEnter: final.onPieEnter, onMouseLeave: final.onPieLeave, activeShape: final.activeShape, inactiveShape: final.inactiveShape }, parsedData.map(function (entry, index) { return (react_1.default.createElement(recharts_1.Cell, { key: "cell-".concat(index), fill: resolveColor(entry.color) || defaultColors[index % defaultColors.length], stroke: resolveColor(final.strokeColor), strokeWidth: final.strokeWidth })); }))));
223
+ // Use ResponsiveContainer for automatic sizing
224
+ return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: final.height, aspect: final.aspect, className: final.funcss, style: containerStyle }, chartContent));
62
225
  };
63
226
  exports.default = ChartPie;
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- type Position = 'left' | 'right';
3
- type Direction = 'dropdown' | 'dropup';
2
+ type Position = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
4
3
  interface DropdownItem {
5
4
  label: React.ReactNode;
6
5
  onClick?: () => void;
7
6
  startIcon?: React.ReactNode;
8
7
  endIcon?: React.ReactNode;
8
+ disabled?: boolean;
9
+ divider?: boolean;
9
10
  }
10
11
  interface DropdownProps {
11
- direction?: Direction;
12
12
  position?: Position;
13
13
  button: React.ReactNode;
14
14
  items: DropdownItem[];
@@ -16,6 +16,7 @@ interface DropdownProps {
16
16
  openOnHover?: boolean;
17
17
  closableOnlyOutside?: boolean;
18
18
  className?: string;
19
+ menuClassName?: string;
19
20
  width?: string;
20
21
  minWidth?: string;
21
22
  maxWidth?: string;
@@ -33,18 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  return result;
34
34
  };
35
35
  })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
36
  Object.defineProperty(exports, "__esModule", { value: true });
40
37
  var react_1 = __importStar(require("react"));
41
- var Flex_1 = __importDefault(require("../flex/Flex"));
42
38
  var Dropdown = function (_a) {
43
- var _b = _a.direction, direction = _b === void 0 ? 'dropdown' : _b, _c = _a.position, position = _c === void 0 ? 'left' : _c, button = _a.button, items = _a.items, _d = _a.hoverable, hoverable = _d === void 0 ? true : _d, _e = _a.openOnHover, openOnHover = _e === void 0 ? true : _e, _f = _a.closableOnlyOutside, closableOnlyOutside = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g, width = _a.width, minWidth = _a.minWidth, maxWidth = _a.maxWidth, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight;
39
+ var _b = _a.position, position = _b === void 0 ? 'bottom' : _b, button = _a.button, items = _a.items, _c = _a.hoverable, hoverable = _c === void 0 ? true : _c, _d = _a.openOnHover, openOnHover = _d === void 0 ? true : _d, _e = _a.closableOnlyOutside, closableOnlyOutside = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f, _g = _a.menuClassName, menuClassName = _g === void 0 ? '' : _g, width = _a.width, minWidth = _a.minWidth, maxWidth = _a.maxWidth, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight;
44
40
  var containerRef = (0, react_1.useRef)(null);
45
41
  var _h = (0, react_1.useState)(false), open = _h[0], setOpen = _h[1];
46
- var containerClass = "".concat(direction, " ").concat(position, " ").concat(className).trim();
47
- var menuClass = "drop-menu ".concat(hoverable ? ' item-hoverable' : '');
48
42
  (0, react_1.useEffect)(function () {
49
43
  if (openOnHover)
50
44
  return;
@@ -57,27 +51,28 @@ var Dropdown = function (_a) {
57
51
  return function () { return document.removeEventListener('mousedown', handleClickOutside); };
58
52
  }, [openOnHover]);
59
53
  var showMenu = openOnHover || open;
60
- return (react_1.default.createElement("div", { ref: containerRef, className: containerClass, onMouseEnter: function () { return openOnHover && setOpen(true); }, onMouseLeave: function () { return openOnHover && setOpen(false); } },
61
- react_1.default.createElement("div", { className: "drop-button", onClick: function () { return !openOnHover && setOpen(!open); }, style: { cursor: !openOnHover ? 'pointer' : undefined } }, button),
62
- showMenu &&
63
- react_1.default.createElement("div", { className: menuClass, style: {
64
- width: width,
65
- minWidth: minWidth,
66
- maxWidth: maxWidth,
67
- height: height,
68
- minHeight: minHeight,
69
- maxHeight: maxHeight,
70
- } }, items.map(function (item, index) { return (react_1.default.createElement("div", { key: index, className: "drop-item hoverable", onClick: function () {
71
- var _a;
72
- if (!closableOnlyOutside) {
73
- (_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item);
74
- if (!openOnHover)
75
- setOpen(false);
76
- }
77
- } },
78
- react_1.default.createElement(Flex_1.default, { wrap: 'nowrap', gap: 0.2, alignItems: 'center', justify: 'flex-start' },
79
- react_1.default.createElement("span", { style: { lineHeight: 0 } }, (item === null || item === void 0 ? void 0 : item.startIcon) || ''),
80
- item.label,
81
- react_1.default.createElement("span", { style: { lineHeight: 0 } }, (item === null || item === void 0 ? void 0 : item.endIcon) || '')))); }))));
54
+ var menuStyle = {
55
+ width: width,
56
+ minWidth: minWidth,
57
+ maxWidth: maxWidth,
58
+ height: height,
59
+ minHeight: minHeight,
60
+ maxHeight: maxHeight,
61
+ };
62
+ return (react_1.default.createElement("div", { ref: containerRef, className: "dropdown-container ".concat(className), onMouseEnter: function () { return openOnHover && setOpen(true); }, onMouseLeave: function () { return openOnHover && setOpen(false); } },
63
+ react_1.default.createElement("div", { onClick: function () { return !openOnHover && setOpen(!open); }, style: { cursor: !openOnHover ? 'pointer' : undefined } }, button),
64
+ showMenu && (react_1.default.createElement("div", { className: "dropdown-menu ".concat(position, " ").concat(menuClassName), style: menuStyle }, items.map(function (item, index) { return (react_1.default.createElement(react_1.default.Fragment, { key: index }, item.divider ? (react_1.default.createElement("div", { className: "dropdown-divider" })) : (react_1.default.createElement("div", { className: "dropdown-item ".concat(item.disabled ? 'disabled' : '', " ").concat(!hoverable ? 'no-hover' : ''), onClick: function () {
65
+ var _a;
66
+ if (item.disabled)
67
+ return;
68
+ if (!closableOnlyOutside) {
69
+ (_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item);
70
+ if (!openOnHover)
71
+ setOpen(false);
72
+ }
73
+ } },
74
+ item.startIcon && (react_1.default.createElement("span", { className: "dropdown-item-icon" }, item.startIcon)),
75
+ react_1.default.createElement("span", { className: "dropdown-item-label" }, item.label),
76
+ item.endIcon && (react_1.default.createElement("span", { className: "dropdown-item-icon" }, item.endIcon)))))); })))));
82
77
  };
83
78
  exports.default = Dropdown;