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/ui/chart/Pie.js CHANGED
@@ -11,53 +11,329 @@ 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))));
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")));
46
148
  }
47
- return null;
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), "%")));
48
160
  };
49
161
  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));
162
+ var _b;
163
+ var data = _a.data, id = _a.id, _c = _a.variant, variant = _c === void 0 ? '' : _c,
164
+ // Chart Type & Layout
165
+ _d = _a.donut,
166
+ // Chart Type & Layout
167
+ donut = _d === void 0 ? false : _d, _e = _a.width, width = _e === void 0 ? '100%' : _e, _f = _a.height, height = _f === void 0 ? 300 : _f, _g = _a.outerRadius, outerRadius = _g === void 0 ? 80 : _g, innerRadius = _a.innerRadius, _h = _a.paddingAngle, paddingAngle = _h === void 0 ? 0 : _h, _j = _a.cornerRadius, cornerRadius = _j === void 0 ? 0 : _j, _k = _a.startAngle, startAngle = _k === void 0 ? 0 : _k, _l = _a.endAngle, endAngle = _l === void 0 ? 360 : _l, _m = _a.minAngle, minAngle = _m === void 0 ? 0 : _m,
168
+ // Display Controls
169
+ _o = _a.showLegend,
170
+ // Display Controls
171
+ showLegend = _o === void 0 ? true : _o, _p = _a.showTooltip, showTooltip = _p === void 0 ? true : _p, _q = _a.showLabels, showLabels = _q === void 0 ? false : _q, _r = _a.showLabelLine, showLabelLine = _r === void 0 ? false : _r, _s = _a.labelPosition, labelPosition = _s === void 0 ? 'inside' : _s, _t = _a.legendPosition, legendPosition = _t === void 0 ? 'bottom' : _t,
172
+ // Appearance
173
+ funcss = _a.funcss, legendCss = _a.legendCss, chartBackground = _a.chartBackground, borderRadius = _a.borderRadius, padding = _a.padding, _u = _a.shadow, shadow = _u === void 0 ? false : _u,
174
+ // Styling
175
+ _v = _a.strokeWidth,
176
+ // Styling
177
+ strokeWidth = _v === void 0 ? 1 : _v, _w = _a.strokeColor, strokeColor = _w === void 0 ? '#ffffff' : _w, _x = _a.activeShape, activeShape = _x === void 0 ? true : _x, _y = _a.inactiveShape, inactiveShape = _y === void 0 ? true : _y,
178
+ // Tooltip / Legend
179
+ tooltipFormatter = _a.tooltipFormatter, labelFormatter = _a.labelFormatter, _z = _a.legendProps, legendProps = _z === void 0 ? {} : _z, _0 = _a.tooltipProps, tooltipProps = _0 === void 0 ? {} : _0, customTooltip = _a.customTooltip, customLabel = _a.customLabel,
180
+ // Animation & Interaction
181
+ _1 = _a.animation,
182
+ // Animation & Interaction
183
+ animation = _1 === void 0 ? true : _1, _2 = _a.animationDuration, animationDuration = _2 === void 0 ? 500 : _2, _3 = _a.isAnimationActive, isAnimationActive = _3 === void 0 ? true : _3, onPieClick = _a.onPieClick, onPieEnter = _a.onPieEnter, onPieLeave = _a.onPieLeave,
184
+ // Responsive
185
+ aspect = _a.aspect, minHeight = _a.minHeight, maxHeight = _a.maxHeight, minWidth = _a.minWidth, maxWidth = _a.maxWidth;
186
+ // Use component configuration with variant support and error handling
187
+ var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('PieChart', variant).mergeWithLocal;
188
+ // Create local props object with null checks
189
+ var localProps = {
190
+ data: data !== null && data !== void 0 ? data : [],
191
+ id: id !== null && id !== void 0 ? id : '',
192
+ variant: variant !== null && variant !== void 0 ? variant : '',
193
+ donut: donut !== null && donut !== void 0 ? donut : false,
194
+ width: width !== null && width !== void 0 ? width : '100%',
195
+ height: height !== null && height !== void 0 ? height : 300,
196
+ outerRadius: outerRadius !== null && outerRadius !== void 0 ? outerRadius : 80,
197
+ innerRadius: innerRadius !== null && innerRadius !== void 0 ? innerRadius : undefined,
198
+ paddingAngle: paddingAngle !== null && paddingAngle !== void 0 ? paddingAngle : 0,
199
+ cornerRadius: cornerRadius !== null && cornerRadius !== void 0 ? cornerRadius : 0,
200
+ startAngle: startAngle !== null && startAngle !== void 0 ? startAngle : 0,
201
+ endAngle: endAngle !== null && endAngle !== void 0 ? endAngle : 360,
202
+ minAngle: minAngle !== null && minAngle !== void 0 ? minAngle : 0,
203
+ showLegend: showLegend !== null && showLegend !== void 0 ? showLegend : true,
204
+ showTooltip: showTooltip !== null && showTooltip !== void 0 ? showTooltip : true,
205
+ showLabels: showLabels !== null && showLabels !== void 0 ? showLabels : false,
206
+ showLabelLine: showLabelLine !== null && showLabelLine !== void 0 ? showLabelLine : false,
207
+ labelPosition: labelPosition !== null && labelPosition !== void 0 ? labelPosition : 'inside',
208
+ legendPosition: legendPosition !== null && legendPosition !== void 0 ? legendPosition : 'bottom',
209
+ funcss: funcss !== null && funcss !== void 0 ? funcss : '',
210
+ legendCss: legendCss !== null && legendCss !== void 0 ? legendCss : '',
211
+ chartBackground: chartBackground !== null && chartBackground !== void 0 ? chartBackground : '',
212
+ borderRadius: borderRadius !== null && borderRadius !== void 0 ? borderRadius : '',
213
+ padding: padding !== null && padding !== void 0 ? padding : '',
214
+ shadow: shadow !== null && shadow !== void 0 ? shadow : false,
215
+ strokeWidth: strokeWidth !== null && strokeWidth !== void 0 ? strokeWidth : 1,
216
+ strokeColor: strokeColor !== null && strokeColor !== void 0 ? strokeColor : '#ffffff',
217
+ activeShape: activeShape !== null && activeShape !== void 0 ? activeShape : true,
218
+ inactiveShape: inactiveShape !== null && inactiveShape !== void 0 ? inactiveShape : true,
219
+ tooltipFormatter: tooltipFormatter !== null && tooltipFormatter !== void 0 ? tooltipFormatter : undefined,
220
+ labelFormatter: labelFormatter !== null && labelFormatter !== void 0 ? labelFormatter : undefined,
221
+ legendProps: legendProps !== null && legendProps !== void 0 ? legendProps : {},
222
+ tooltipProps: tooltipProps !== null && tooltipProps !== void 0 ? tooltipProps : {},
223
+ customTooltip: customTooltip !== null && customTooltip !== void 0 ? customTooltip : undefined,
224
+ customLabel: customLabel !== null && customLabel !== void 0 ? customLabel : undefined,
225
+ animation: animation !== null && animation !== void 0 ? animation : true,
226
+ animationDuration: animationDuration !== null && animationDuration !== void 0 ? animationDuration : 500,
227
+ isAnimationActive: isAnimationActive !== null && isAnimationActive !== void 0 ? isAnimationActive : true,
228
+ onPieClick: onPieClick !== null && onPieClick !== void 0 ? onPieClick : undefined,
229
+ onPieEnter: onPieEnter !== null && onPieEnter !== void 0 ? onPieEnter : undefined,
230
+ onPieLeave: onPieLeave !== null && onPieLeave !== void 0 ? onPieLeave : undefined,
231
+ aspect: aspect !== null && aspect !== void 0 ? aspect : undefined,
232
+ minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : undefined,
233
+ maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
234
+ minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : undefined,
235
+ maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : undefined
236
+ };
237
+ // Merge with config
238
+ var mergedProps;
239
+ try {
240
+ var result = mergeWithLocal(localProps);
241
+ mergedProps = (_b = result === null || result === void 0 ? void 0 : result.props) !== null && _b !== void 0 ? _b : localProps;
242
+ }
243
+ catch (error) {
244
+ console.error('Error merging component configuration:', error);
245
+ mergedProps = localProps;
246
+ }
247
+ // Parse data if it's a string with enhanced validation
248
+ var parsedData = (0, react_1.useMemo)(function () {
249
+ var parsed = parseIfString(mergedProps.data, []);
250
+ var safeData = getSafeArray(parsed);
251
+ // Calculate percentages for tooltip
252
+ var total = safeData.reduce(function (sum, item) { return sum + (item.value || 0); }, 0);
253
+ return safeData.map(function (item) { return (__assign(__assign({}, item), { percentage: total > 0 ? ((item.value / total) * 100).toFixed(1) : '0' })); });
254
+ }, [mergedProps.data]);
255
+ // Check if we have valid data to display
256
+ var hasValidData = parsedData.length > 0;
257
+ // Extract final values with fallbacks
258
+ var final = (0, react_1.useMemo)(function () { return ({
259
+ data: parsedData,
260
+ id: mergedProps.id || 'pie-chart',
261
+ variant: mergedProps.variant,
262
+ donut: mergedProps.donut,
263
+ width: mergedProps.width,
264
+ height: mergedProps.height,
265
+ outerRadius: mergedProps.outerRadius,
266
+ innerRadius: mergedProps.donut ? (mergedProps.innerRadius || typeof mergedProps.outerRadius === 'number' ? mergedProps.outerRadius * 0.6 : '60%') : 0,
267
+ paddingAngle: mergedProps.paddingAngle,
268
+ cornerRadius: mergedProps.cornerRadius,
269
+ startAngle: mergedProps.startAngle,
270
+ endAngle: mergedProps.endAngle,
271
+ minAngle: mergedProps.minAngle,
272
+ showLegend: mergedProps.showLegend,
273
+ showTooltip: mergedProps.showTooltip,
274
+ showLabels: mergedProps.showLabels,
275
+ showLabelLine: mergedProps.showLabelLine,
276
+ labelPosition: mergedProps.labelPosition,
277
+ legendPosition: mergedProps.legendPosition,
278
+ funcss: mergedProps.funcss,
279
+ legendCss: mergedProps.legendCss,
280
+ chartBackground: mergedProps.chartBackground,
281
+ borderRadius: mergedProps.borderRadius,
282
+ padding: mergedProps.padding,
283
+ shadow: mergedProps.shadow,
284
+ strokeWidth: mergedProps.strokeWidth,
285
+ strokeColor: mergedProps.strokeColor,
286
+ activeShape: mergedProps.activeShape,
287
+ inactiveShape: mergedProps.inactiveShape,
288
+ tooltipFormatter: mergedProps.tooltipFormatter,
289
+ labelFormatter: mergedProps.labelFormatter,
290
+ legendProps: mergedProps.legendProps,
291
+ tooltipProps: mergedProps.tooltipProps,
292
+ customTooltip: mergedProps.customTooltip,
293
+ customLabel: mergedProps.customLabel,
294
+ animation: mergedProps.animation,
295
+ animationDuration: mergedProps.animationDuration,
296
+ isAnimationActive: mergedProps.isAnimationActive,
297
+ onPieClick: mergedProps.onPieClick,
298
+ onPieEnter: mergedProps.onPieEnter,
299
+ onPieLeave: mergedProps.onPieLeave,
300
+ aspect: mergedProps.aspect,
301
+ minHeight: mergedProps.minHeight,
302
+ maxHeight: mergedProps.maxHeight,
303
+ minWidth: mergedProps.minWidth,
304
+ maxWidth: mergedProps.maxWidth
305
+ }); }, [parsedData, mergedProps, hasValidData]);
306
+ // Configure legend based on position
307
+ var legendConfig = (0, react_1.useMemo)(function () {
308
+ 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' }, final.legendProps.wrapperStyle) }, final.legendProps);
309
+ return baseProps;
310
+ }, [final.legendPosition, final.legendProps]);
311
+ var TooltipComponent = final.customTooltip || CustomTooltip;
312
+ var LabelComponent = final.customLabel || (final.showLabels ? CustomLabel : undefined);
313
+ var containerStyle = (0, react_1.useMemo)(function () { return ({
314
+ width: final.width,
315
+ height: final.height,
316
+ minHeight: final.minHeight,
317
+ maxHeight: final.maxHeight,
318
+ minWidth: final.minWidth,
319
+ maxWidth: final.maxWidth,
320
+ background: final.chartBackground,
321
+ borderRadius: final.borderRadius,
322
+ padding: final.padding,
323
+ boxShadow: final.shadow ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : undefined,
324
+ }); }, [final]);
325
+ // Show empty state if no data
326
+ if (!hasValidData) {
327
+ return (react_1.default.createElement("div", { className: "flex items-center justify-center ".concat(final.funcss), style: containerStyle },
328
+ react_1.default.createElement("div", { className: "text-center text-muted" },
329
+ react_1.default.createElement("div", { className: "text-lg mb-2" }, "\uD83E\uDD67"),
330
+ react_1.default.createElement("div", null, "No chart data available"))));
331
+ }
332
+ var chartContent = (react_1.default.createElement(recharts_1.PieChart, null,
333
+ final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
334
+ final.showLegend && (react_1.default.createElement(recharts_1.Legend, __assign({}, legendConfig, { className: final.legendCss }))),
335
+ react_1.default.createElement(recharts_1.Pie, { data: final.data, dataKey: "value", nameKey: "label", cx: "50%", cy: "50%", outerRadius: final.outerRadius, innerRadius: final.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 }, final.data.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 })); }))));
336
+ // Use ResponsiveContainer for automatic sizing
337
+ return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: final.height, aspect: final.aspect, className: final.funcss, style: containerStyle }, chartContent));
62
338
  };
63
339
  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;