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/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
|
|
15
|
-
|
|
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 =
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
19
49
|
var recharts_1 = require("recharts");
|
|
20
|
-
|
|
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
|
-
|
|
26
|
-
.getPropertyValue("--".concat(varName))) === null || _a === void 0 ? void 0 : _a.trim()) || ''
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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;
|
package/ui/drop/Dropdown.d.ts
CHANGED
|
@@ -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;
|
package/ui/drop/Dropdown.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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;
|