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/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.View = exports.ScrollInView = exports.Accordion = exports.Flex = exports.RichText = exports.Carousel = exports.Video = exports.SideBar = exports.ChartPie = exports.Lines = exports.Bars = exports.FullCenteredPage = exports.CircleGroup = exports.Circle = exports.Hr = exports.Section = exports.RowFlex = exports.Tip = exports.AppBar = exports.ToolTip = exports.Notification = exports.FunLoader = exports.ProgressBar = exports.DropMenu = exports.DropItem = exports.Dropdown = exports.DropDown = exports.DropUp = exports.UnAuthorized = exports.NotFound = exports.StepLine = exports.StepHeader = exports.Step = exports.StepContainer = exports.Div = exports.Text = exports.List = exports.Table = exports.Modal = exports.Loader = exports.SearchableInput = exports.Input = exports.Col = exports.Grid = exports.Container = exports.BreadCrumb = exports.Card = exports.Button = exports.ThemeProvider = exports.Alert = void 0;
|
|
7
|
-
exports.GoogleAnalytics = exports.FunGet = exports.useVariable = exports.Cookie = exports.Select = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = exports.DatePicker = void 0;
|
|
7
|
+
exports.GoogleAnalytics = exports.FunGet = exports.useVariables = exports.useAssets = exports.useAssetValue = exports.useAssetType = exports.useAsset = exports.useVariable = exports.Cookie = exports.Select = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = exports.DatePicker = void 0;
|
|
8
8
|
var Alert_1 = require("./ui/alert/Alert");
|
|
9
9
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
|
|
10
10
|
var theme_1 = require("./ui/theme/theme");
|
|
@@ -124,6 +124,11 @@ var Cookie_1 = require("./js/Cookie");
|
|
|
124
124
|
Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return __importDefault(Cookie_1).default; } });
|
|
125
125
|
var theme_2 = require("./ui/theme/theme");
|
|
126
126
|
Object.defineProperty(exports, "useVariable", { enumerable: true, get: function () { return theme_2.useVariable; } });
|
|
127
|
+
Object.defineProperty(exports, "useAsset", { enumerable: true, get: function () { return theme_2.useAsset; } });
|
|
128
|
+
Object.defineProperty(exports, "useAssetType", { enumerable: true, get: function () { return theme_2.useAssetType; } });
|
|
129
|
+
Object.defineProperty(exports, "useAssetValue", { enumerable: true, get: function () { return theme_2.useAssetValue; } });
|
|
130
|
+
Object.defineProperty(exports, "useAssets", { enumerable: true, get: function () { return theme_2.useAssets; } });
|
|
131
|
+
Object.defineProperty(exports, "useVariables", { enumerable: true, get: function () { return theme_2.useVariables; } });
|
|
127
132
|
var Fun_1 = require("./js/Fun");
|
|
128
133
|
Object.defineProperty(exports, "FunGet", { enumerable: true, get: function () { return Fun_1.FunGet; } });
|
|
129
134
|
var analytics_1 = require("./js/google/analytics");
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.7.
|
|
2
|
+
"version": "3.7.2",
|
|
3
3
|
"name": "funuicss",
|
|
4
4
|
"description": "React and Next.js component UI Library for creating Easy and good looking websites with fewer lines of code. Elevate your web development experience with our cutting-edge React/Next.js component UI Library. Craft stunning websites effortlessly, boasting both seamless functionality and aesthetic appeal—all achieved with minimal lines of code. Unleash the power of simplicity and style in your projects!",
|
|
5
5
|
"main": "index.js",
|
package/ui/calendar/Calendar.js
CHANGED
|
@@ -175,7 +175,7 @@ var Calendar = function (_a) {
|
|
|
175
175
|
var year = (0, dayjs_1.default)().year() - 10 + i;
|
|
176
176
|
return { value: year.toString(), text: year.toString() };
|
|
177
177
|
}), borderless: true, funcss: "round-edge" })),
|
|
178
|
-
react_1.default.createElement(Dropdown_1.default, {
|
|
178
|
+
react_1.default.createElement(Dropdown_1.default, { position: "bottom", openOnHover: false, button: react_1.default.createElement(Avatar_1.default, null,
|
|
179
179
|
react_1.default.createElement(hi_1.HiOutlineDotsVertical, null)), items: [
|
|
180
180
|
{
|
|
181
181
|
label: react_1.default.createElement("span", { className: "text-sm" }, "Today"),
|
package/ui/chart/Bar.d.ts
CHANGED
|
@@ -7,37 +7,123 @@ type ChartSeries = {
|
|
|
7
7
|
dataKey: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
color?: string;
|
|
10
|
+
strokeWidth?: number;
|
|
11
|
+
stroke?: string;
|
|
12
|
+
fillOpacity?: number;
|
|
13
|
+
radius?: number | [number, number, number, number];
|
|
14
|
+
barSize?: number;
|
|
15
|
+
activeBar?: boolean | Record<string, any>;
|
|
16
|
+
stackId?: string;
|
|
17
|
+
background?: boolean | Record<string, any>;
|
|
18
|
+
minPointSize?: number;
|
|
19
|
+
maxBarSize?: number;
|
|
10
20
|
};
|
|
21
|
+
interface XAxisProps {
|
|
22
|
+
interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
|
|
23
|
+
tick?: boolean | Record<string, any>;
|
|
24
|
+
tickFormatter?: (value: any) => string;
|
|
25
|
+
domain?: [number | string | 'auto' | 'dataMin' | 'dataMax', number | string | 'auto' | 'dataMin' | 'dataMax'];
|
|
26
|
+
type?: 'number' | 'category';
|
|
27
|
+
allowDataOverflow?: boolean;
|
|
28
|
+
scale?: 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold';
|
|
29
|
+
padding?: {
|
|
30
|
+
left?: number;
|
|
31
|
+
right?: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
interface YAxisProps {
|
|
35
|
+
interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
|
|
36
|
+
tick?: boolean | Record<string, any>;
|
|
37
|
+
tickFormatter?: (value: any) => string;
|
|
38
|
+
domain?: [number | string | 'auto' | 'dataMin' | 'dataMax', number | string | 'auto' | 'dataMin' | 'dataMax'];
|
|
39
|
+
type?: 'number' | 'category';
|
|
40
|
+
allowDataOverflow?: boolean;
|
|
41
|
+
scale?: 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold';
|
|
42
|
+
padding?: {
|
|
43
|
+
top?: number;
|
|
44
|
+
bottom?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface LegendProps {
|
|
48
|
+
align?: 'left' | 'center' | 'right';
|
|
49
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
50
|
+
layout?: 'horizontal' | 'vertical';
|
|
51
|
+
iconType?: 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye';
|
|
52
|
+
wrapperStyle?: Record<string, any>;
|
|
53
|
+
}
|
|
54
|
+
interface TooltipProps {
|
|
55
|
+
cursor?: boolean | Record<string, any>;
|
|
56
|
+
separator?: string;
|
|
57
|
+
offset?: number;
|
|
58
|
+
allowEscapeViewBox?: {
|
|
59
|
+
x?: boolean;
|
|
60
|
+
y?: boolean;
|
|
61
|
+
};
|
|
62
|
+
wrapperStyle?: Record<string, any>;
|
|
63
|
+
}
|
|
11
64
|
interface BarsProps {
|
|
12
|
-
data: DataItem[];
|
|
13
|
-
series: ChartSeries[];
|
|
65
|
+
data: DataItem[] | string;
|
|
66
|
+
series: ChartSeries[] | string;
|
|
67
|
+
id?: string;
|
|
68
|
+
variant?: string;
|
|
14
69
|
width?: number | string;
|
|
15
70
|
height?: number | string;
|
|
16
71
|
layout?: 'horizontal' | 'vertical';
|
|
17
72
|
margin?: {
|
|
18
73
|
top?: number;
|
|
19
74
|
right?: number;
|
|
20
|
-
bottom?: number;
|
|
21
75
|
left?: number;
|
|
76
|
+
bottom?: number;
|
|
22
77
|
};
|
|
23
|
-
barRadius?: number;
|
|
78
|
+
barRadius?: number | [number, number, number, number];
|
|
24
79
|
barSize?: number;
|
|
25
80
|
barGap?: number | string;
|
|
26
81
|
barCategoryGap?: number | string;
|
|
82
|
+
maxBarSize?: number;
|
|
83
|
+
showGrid?: boolean;
|
|
84
|
+
horizontalLines?: boolean;
|
|
85
|
+
verticalLines?: boolean;
|
|
86
|
+
showLegend?: boolean;
|
|
27
87
|
showXAxis?: boolean;
|
|
28
88
|
showYAxis?: boolean;
|
|
29
|
-
|
|
30
|
-
|
|
89
|
+
showTooltip?: boolean;
|
|
90
|
+
funcss?: string;
|
|
91
|
+
rotateLabel?: number;
|
|
92
|
+
xLabelSize?: string | number;
|
|
93
|
+
yLabelSize?: string | number;
|
|
31
94
|
xInterval?: number;
|
|
32
95
|
yInterval?: number;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
96
|
+
gridStroke?: string;
|
|
97
|
+
gridStrokeDasharray?: string;
|
|
98
|
+
dy?: number;
|
|
99
|
+
xAxisProps?: XAxisProps;
|
|
100
|
+
yAxisProps?: YAxisProps;
|
|
101
|
+
xAxisLabel?: string;
|
|
102
|
+
yAxisLabel?: string;
|
|
103
|
+
tickLine?: boolean;
|
|
104
|
+
axisLine?: boolean;
|
|
36
105
|
tooltipFormatter?: (value: any, name: string, props: any) => React.ReactNode;
|
|
37
|
-
|
|
38
|
-
|
|
106
|
+
legendProps?: LegendProps;
|
|
107
|
+
tooltipProps?: TooltipProps;
|
|
108
|
+
customTooltip?: React.ComponentType<any>;
|
|
109
|
+
animation?: boolean;
|
|
110
|
+
animationDuration?: number;
|
|
39
111
|
isAnimationActive?: boolean;
|
|
40
|
-
|
|
112
|
+
syncId?: string;
|
|
113
|
+
stackOffset?: 'expand' | 'none' | 'wiggle' | 'silhouette' | 'sign';
|
|
114
|
+
barCategoryGapPercentage?: number;
|
|
115
|
+
chartBackground?: string;
|
|
116
|
+
borderRadius?: string;
|
|
117
|
+
padding?: string;
|
|
118
|
+
shadow?: boolean;
|
|
119
|
+
aspect?: number;
|
|
120
|
+
minHeight?: number | string;
|
|
121
|
+
maxHeight?: number | string;
|
|
122
|
+
minWidth?: number | string;
|
|
123
|
+
maxWidth?: number | string;
|
|
124
|
+
onBarClick?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
125
|
+
onBarMouseEnter?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
126
|
+
onBarMouseLeave?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
41
127
|
}
|
|
42
128
|
declare const Bars: React.FC<BarsProps>;
|
|
43
129
|
export default Bars;
|
package/ui/chart/Bar.js
CHANGED
|
@@ -11,63 +11,410 @@ 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");
|
|
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
|
+
// Additional validation for arrays
|
|
57
|
+
if (Array.isArray(fallback) && !Array.isArray(parsed)) {
|
|
58
|
+
console.warn('Parsed value is not an array, using fallback');
|
|
59
|
+
return fallback;
|
|
60
|
+
}
|
|
61
|
+
return parsed;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('Failed to parse JSON string:', error);
|
|
65
|
+
return fallback;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Handle null/undefined values
|
|
69
|
+
if (value == null) {
|
|
70
|
+
return fallback;
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
// Safe array access utility
|
|
75
|
+
var getSafeArray = function (value, fallback) {
|
|
76
|
+
if (fallback === void 0) { fallback = []; }
|
|
77
|
+
if (!value || !Array.isArray(value))
|
|
78
|
+
return fallback;
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
// CSS var resolver with error handling
|
|
20
82
|
var getCssVar = function (varName) {
|
|
21
83
|
var _a;
|
|
22
84
|
if (typeof window === 'undefined')
|
|
23
85
|
return '';
|
|
24
|
-
|
|
86
|
+
try {
|
|
87
|
+
return ((_a = getComputedStyle(document.documentElement).getPropertyValue("--".concat(varName))) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.warn("Failed to get CSS variable --".concat(varName, ":"), error);
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
25
93
|
};
|
|
94
|
+
// Color resolver with fallbacks
|
|
26
95
|
var resolveColor = function (color) {
|
|
27
96
|
if (!color)
|
|
28
|
-
return getCssVar('
|
|
97
|
+
return getCssVar('primary') || '#8884d8';
|
|
29
98
|
if (color.startsWith('#'))
|
|
30
99
|
return color;
|
|
31
|
-
|
|
100
|
+
var cssColor = getCssVar(color);
|
|
101
|
+
if (cssColor)
|
|
102
|
+
return cssColor;
|
|
103
|
+
// Fallback to common color names if CSS var not found
|
|
104
|
+
var colorMap = {
|
|
105
|
+
primary: '#8884d8',
|
|
106
|
+
secondary: '#82ca9d',
|
|
107
|
+
error: '#ff4d4f',
|
|
108
|
+
warning: '#faad14',
|
|
109
|
+
success: '#52c41a',
|
|
110
|
+
info: '#1890ff'
|
|
111
|
+
};
|
|
112
|
+
return colorMap[color] || color || '#8884d8';
|
|
32
113
|
};
|
|
114
|
+
// Default Tooltip with error handling
|
|
33
115
|
var CustomTooltip = function (_a) {
|
|
34
|
-
var active = _a.active, payload = _a.payload, label = _a.label;
|
|
35
|
-
if (active
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
116
|
+
var active = _a.active, payload = _a.payload, label = _a.label, formatter = _a.formatter;
|
|
117
|
+
if (!active || !payload || !Array.isArray(payload) || payload.length === 0) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm", style: {
|
|
122
|
+
maxWidth: '300px',
|
|
123
|
+
backgroundColor: 'var(--background, #fff)',
|
|
124
|
+
border: '1px solid var(--border-color, #e2e8f0)'
|
|
125
|
+
} },
|
|
126
|
+
react_1.default.createElement("div", { className: "text-bold mb-1", style: { color: 'var(--text-color, #1a202c)' } }, label || 'N/A'),
|
|
127
|
+
payload.map(function (entry, index) {
|
|
128
|
+
if (!entry)
|
|
129
|
+
return null;
|
|
130
|
+
var value = formatter ? formatter(entry.value, entry.name, entry) : entry.value;
|
|
131
|
+
var displayValue = value != null ? value : 'N/A';
|
|
132
|
+
var displayName = entry.name || 'Unknown';
|
|
133
|
+
var displayColor = entry.color || entry.fill || '#8884d8';
|
|
134
|
+
return (react_1.default.createElement("div", { key: index, style: {
|
|
135
|
+
lineHeight: 1.4,
|
|
136
|
+
display: 'flex',
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
gap: '8px'
|
|
139
|
+
} },
|
|
140
|
+
react_1.default.createElement("div", { style: {
|
|
141
|
+
width: '12px',
|
|
142
|
+
height: '12px',
|
|
143
|
+
backgroundColor: displayColor,
|
|
144
|
+
borderRadius: '2px'
|
|
145
|
+
} }),
|
|
146
|
+
react_1.default.createElement("span", { style: { fontWeight: 500, color: 'var(--text-color, #1a202c)' } },
|
|
147
|
+
displayName,
|
|
148
|
+
":"),
|
|
149
|
+
react_1.default.createElement("span", { style: { fontWeight: 600, color: 'var(--text-color, #1a202c)' } }, displayValue)));
|
|
150
|
+
})));
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
console.error('Error rendering tooltip:', error);
|
|
154
|
+
return (react_1.default.createElement("div", { className: "card raised round-edge p-2 text-sm" },
|
|
155
|
+
react_1.default.createElement("div", { className: "text-error" }, "Error displaying tooltip")));
|
|
42
156
|
}
|
|
43
|
-
return null;
|
|
44
157
|
};
|
|
45
158
|
var Bars = function (_a) {
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
159
|
+
var _b, _c;
|
|
160
|
+
var data = _a.data, series = _a.series, id = _a.id, _d = _a.variant, variant = _d === void 0 ? '' : _d,
|
|
161
|
+
// Layout & Dimensions
|
|
162
|
+
_e = _a.width,
|
|
163
|
+
// Layout & Dimensions
|
|
164
|
+
width = _e === void 0 ? '100%' : _e, _f = _a.height, height = _f === void 0 ? 300 : _f, _g = _a.layout, layout = _g === void 0 ? 'horizontal' : _g, _h = _a.margin, margin = _h === void 0 ? { top: 10, right: 30, left: 0, bottom: 20 } : _h,
|
|
165
|
+
// Bar styling
|
|
166
|
+
_j = _a.barRadius,
|
|
167
|
+
// Bar styling
|
|
168
|
+
barRadius = _j === void 0 ? 6 : _j, _k = _a.barSize, barSize = _k === void 0 ? 30 : _k, _l = _a.barGap, barGap = _l === void 0 ? 4 : _l, _m = _a.barCategoryGap, barCategoryGap = _m === void 0 ? '10%' : _m, _o = _a.maxBarSize, maxBarSize = _o === void 0 ? 100 : _o,
|
|
169
|
+
// Display controls
|
|
170
|
+
_p = _a.showGrid,
|
|
171
|
+
// Display controls
|
|
172
|
+
showGrid = _p === void 0 ? true : _p, _q = _a.horizontalLines, horizontalLines = _q === void 0 ? false : _q, _r = _a.verticalLines, verticalLines = _r === void 0 ? true : _r, _s = _a.showLegend, showLegend = _s === void 0 ? true : _s, _t = _a.showXAxis, showXAxis = _t === void 0 ? true : _t, _u = _a.showYAxis, showYAxis = _u === void 0 ? false : _u, _v = _a.showTooltip, showTooltip = _v === void 0 ? true : _v,
|
|
173
|
+
// Appearance controls
|
|
174
|
+
funcss = _a.funcss, rotateLabel = _a.rotateLabel, xLabelSize = _a.xLabelSize, yLabelSize = _a.yLabelSize, xInterval = _a.xInterval, yInterval = _a.yInterval, gridStroke = _a.gridStroke, _w = _a.gridStrokeDasharray, gridStrokeDasharray = _w === void 0 ? "3 3" : _w,
|
|
175
|
+
// Axis controls
|
|
176
|
+
dy = _a.dy, _x = _a.xAxisProps, xAxisProps = _x === void 0 ? {} : _x, _y = _a.yAxisProps, yAxisProps = _y === void 0 ? {} : _y, xAxisLabel = _a.xAxisLabel, yAxisLabel = _a.yAxisLabel, _z = _a.tickLine, tickLine = _z === void 0 ? true : _z, _0 = _a.axisLine, axisLine = _0 === void 0 ? true : _0,
|
|
177
|
+
// Tooltip / Legend
|
|
178
|
+
tooltipFormatter = _a.tooltipFormatter, _1 = _a.legendProps, legendProps = _1 === void 0 ? {} : _1, _2 = _a.tooltipProps, tooltipProps = _2 === void 0 ? {} : _2, customTooltip = _a.customTooltip,
|
|
179
|
+
// Animation & Interaction
|
|
180
|
+
_3 = _a.animation,
|
|
181
|
+
// Animation & Interaction
|
|
182
|
+
animation = _3 === void 0 ? true : _3, _4 = _a.animationDuration, animationDuration = _4 === void 0 ? 500 : _4, _5 = _a.isAnimationActive, isAnimationActive = _5 === void 0 ? true : _5, syncId = _a.syncId,
|
|
183
|
+
// Stacking & Grouping
|
|
184
|
+
_6 = _a.stackOffset,
|
|
185
|
+
// Stacking & Grouping
|
|
186
|
+
stackOffset = _6 === void 0 ? 'none' : _6, barCategoryGapPercentage = _a.barCategoryGapPercentage,
|
|
187
|
+
// Styling
|
|
188
|
+
chartBackground = _a.chartBackground, borderRadius = _a.borderRadius, padding = _a.padding, _7 = _a.shadow, shadow = _7 === void 0 ? false : _7,
|
|
189
|
+
// Responsive
|
|
190
|
+
aspect = _a.aspect, minHeight = _a.minHeight, maxHeight = _a.maxHeight, minWidth = _a.minWidth, maxWidth = _a.maxWidth,
|
|
191
|
+
// Advanced
|
|
192
|
+
onBarClick = _a.onBarClick, onBarMouseEnter = _a.onBarMouseEnter, onBarMouseLeave = _a.onBarMouseLeave;
|
|
193
|
+
// Use component configuration with variant support and error handling
|
|
194
|
+
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('BarChart', variant).mergeWithLocal;
|
|
195
|
+
// Create local props object with null checks
|
|
196
|
+
var localProps = {
|
|
197
|
+
data: data !== null && data !== void 0 ? data : [],
|
|
198
|
+
series: series !== null && series !== void 0 ? series : [],
|
|
199
|
+
id: id !== null && id !== void 0 ? id : '',
|
|
200
|
+
variant: variant !== null && variant !== void 0 ? variant : '',
|
|
201
|
+
width: width !== null && width !== void 0 ? width : '100%',
|
|
202
|
+
height: height !== null && height !== void 0 ? height : 300,
|
|
203
|
+
layout: layout !== null && layout !== void 0 ? layout : 'horizontal',
|
|
204
|
+
margin: margin !== null && margin !== void 0 ? margin : { top: 10, right: 30, left: 0, bottom: 20 },
|
|
205
|
+
barRadius: barRadius !== null && barRadius !== void 0 ? barRadius : 6,
|
|
206
|
+
barSize: barSize !== null && barSize !== void 0 ? barSize : 30,
|
|
207
|
+
barGap: barGap !== null && barGap !== void 0 ? barGap : 4,
|
|
208
|
+
barCategoryGap: barCategoryGap !== null && barCategoryGap !== void 0 ? barCategoryGap : '10%',
|
|
209
|
+
maxBarSize: maxBarSize !== null && maxBarSize !== void 0 ? maxBarSize : 100,
|
|
210
|
+
showGrid: showGrid !== null && showGrid !== void 0 ? showGrid : true,
|
|
211
|
+
horizontalLines: horizontalLines !== null && horizontalLines !== void 0 ? horizontalLines : false,
|
|
212
|
+
verticalLines: verticalLines !== null && verticalLines !== void 0 ? verticalLines : true,
|
|
213
|
+
showLegend: showLegend !== null && showLegend !== void 0 ? showLegend : true,
|
|
214
|
+
showXAxis: showXAxis !== null && showXAxis !== void 0 ? showXAxis : true,
|
|
215
|
+
showYAxis: showYAxis !== null && showYAxis !== void 0 ? showYAxis : false,
|
|
216
|
+
showTooltip: showTooltip !== null && showTooltip !== void 0 ? showTooltip : true,
|
|
217
|
+
funcss: funcss !== null && funcss !== void 0 ? funcss : '',
|
|
218
|
+
rotateLabel: rotateLabel !== null && rotateLabel !== void 0 ? rotateLabel : 0,
|
|
219
|
+
xLabelSize: xLabelSize !== null && xLabelSize !== void 0 ? xLabelSize : "0.8rem",
|
|
220
|
+
yLabelSize: yLabelSize !== null && yLabelSize !== void 0 ? yLabelSize : "0.8rem",
|
|
221
|
+
xInterval: xInterval !== null && xInterval !== void 0 ? xInterval : undefined,
|
|
222
|
+
yInterval: yInterval !== null && yInterval !== void 0 ? yInterval : undefined,
|
|
223
|
+
gridStroke: gridStroke !== null && gridStroke !== void 0 ? gridStroke : '',
|
|
224
|
+
gridStrokeDasharray: gridStrokeDasharray !== null && gridStrokeDasharray !== void 0 ? gridStrokeDasharray : "3 3",
|
|
225
|
+
dy: dy !== null && dy !== void 0 ? dy : 0,
|
|
226
|
+
xAxisProps: xAxisProps !== null && xAxisProps !== void 0 ? xAxisProps : {},
|
|
227
|
+
yAxisProps: yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {},
|
|
228
|
+
xAxisLabel: xAxisLabel !== null && xAxisLabel !== void 0 ? xAxisLabel : '',
|
|
229
|
+
yAxisLabel: yAxisLabel !== null && yAxisLabel !== void 0 ? yAxisLabel : '',
|
|
230
|
+
tickLine: tickLine !== null && tickLine !== void 0 ? tickLine : true,
|
|
231
|
+
axisLine: axisLine !== null && axisLine !== void 0 ? axisLine : true,
|
|
232
|
+
tooltipFormatter: tooltipFormatter !== null && tooltipFormatter !== void 0 ? tooltipFormatter : undefined,
|
|
233
|
+
legendProps: legendProps !== null && legendProps !== void 0 ? legendProps : {},
|
|
234
|
+
tooltipProps: tooltipProps !== null && tooltipProps !== void 0 ? tooltipProps : {},
|
|
235
|
+
customTooltip: customTooltip !== null && customTooltip !== void 0 ? customTooltip : undefined,
|
|
236
|
+
animation: animation !== null && animation !== void 0 ? animation : true,
|
|
237
|
+
animationDuration: animationDuration !== null && animationDuration !== void 0 ? animationDuration : 500,
|
|
238
|
+
isAnimationActive: isAnimationActive !== null && isAnimationActive !== void 0 ? isAnimationActive : true,
|
|
239
|
+
syncId: syncId !== null && syncId !== void 0 ? syncId : '',
|
|
240
|
+
stackOffset: stackOffset !== null && stackOffset !== void 0 ? stackOffset : 'none',
|
|
241
|
+
barCategoryGapPercentage: barCategoryGapPercentage !== null && barCategoryGapPercentage !== void 0 ? barCategoryGapPercentage : undefined,
|
|
242
|
+
chartBackground: chartBackground !== null && chartBackground !== void 0 ? chartBackground : '',
|
|
243
|
+
borderRadius: borderRadius !== null && borderRadius !== void 0 ? borderRadius : '',
|
|
244
|
+
padding: padding !== null && padding !== void 0 ? padding : '',
|
|
245
|
+
shadow: shadow !== null && shadow !== void 0 ? shadow : false,
|
|
246
|
+
aspect: aspect !== null && aspect !== void 0 ? aspect : undefined,
|
|
247
|
+
minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : undefined,
|
|
248
|
+
maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
|
|
249
|
+
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : undefined,
|
|
250
|
+
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : undefined,
|
|
251
|
+
onBarClick: onBarClick !== null && onBarClick !== void 0 ? onBarClick : undefined,
|
|
252
|
+
onBarMouseEnter: onBarMouseEnter !== null && onBarMouseEnter !== void 0 ? onBarMouseEnter : undefined,
|
|
253
|
+
onBarMouseLeave: onBarMouseLeave !== null && onBarMouseLeave !== void 0 ? onBarMouseLeave : undefined
|
|
54
254
|
};
|
|
55
|
-
|
|
255
|
+
// Merge with config - LOCAL PROPS OVERRIDE CONFIG with error handling
|
|
256
|
+
var mergedProps;
|
|
257
|
+
try {
|
|
258
|
+
var result = mergeWithLocal(localProps);
|
|
259
|
+
mergedProps = (_b = result === null || result === void 0 ? void 0 : result.props) !== null && _b !== void 0 ? _b : localProps;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
console.error('Error merging component configuration:', error);
|
|
263
|
+
mergedProps = localProps;
|
|
264
|
+
}
|
|
265
|
+
// Parse data and series if they're strings with enhanced validation
|
|
266
|
+
var parsedData = (0, react_1.useMemo)(function () {
|
|
267
|
+
var parsed = parseIfString(mergedProps.data, []);
|
|
268
|
+
return getSafeArray(parsed);
|
|
269
|
+
}, [mergedProps.data]);
|
|
270
|
+
var parsedSeries = (0, react_1.useMemo)(function () {
|
|
271
|
+
var parsed = parseIfString(mergedProps.series, []);
|
|
272
|
+
return getSafeArray(parsed).filter(function (series) {
|
|
273
|
+
return series && typeof series === 'object' && series.dataKey;
|
|
274
|
+
});
|
|
275
|
+
}, [mergedProps.series]);
|
|
276
|
+
// Check if we have valid data to display
|
|
277
|
+
var hasValidData = parsedData.length > 0 && parsedSeries.length > 0;
|
|
278
|
+
var isVertical = mergedProps.layout === 'vertical';
|
|
279
|
+
// Extract final values with fallbacks
|
|
280
|
+
var final = (0, react_1.useMemo)(function () { return ({
|
|
281
|
+
data: parsedData,
|
|
282
|
+
series: parsedSeries,
|
|
283
|
+
id: mergedProps.id || 'bar-chart',
|
|
284
|
+
variant: mergedProps.variant,
|
|
285
|
+
width: mergedProps.width,
|
|
286
|
+
height: mergedProps.height,
|
|
287
|
+
layout: mergedProps.layout,
|
|
288
|
+
margin: mergedProps.margin,
|
|
289
|
+
barRadius: mergedProps.barRadius,
|
|
290
|
+
barSize: mergedProps.barSize,
|
|
291
|
+
barGap: mergedProps.barGap,
|
|
292
|
+
barCategoryGap: mergedProps.barCategoryGap,
|
|
293
|
+
maxBarSize: mergedProps.maxBarSize,
|
|
294
|
+
showGrid: mergedProps.showGrid,
|
|
295
|
+
horizontalLines: mergedProps.horizontalLines,
|
|
296
|
+
verticalLines: mergedProps.verticalLines,
|
|
297
|
+
showLegend: mergedProps.showLegend,
|
|
298
|
+
showXAxis: mergedProps.showXAxis,
|
|
299
|
+
showYAxis: mergedProps.showYAxis,
|
|
300
|
+
showTooltip: mergedProps.showTooltip,
|
|
301
|
+
funcss: mergedProps.funcss,
|
|
302
|
+
rotateLabel: mergedProps.rotateLabel,
|
|
303
|
+
xLabelSize: mergedProps.xLabelSize,
|
|
304
|
+
yLabelSize: mergedProps.yLabelSize,
|
|
305
|
+
xInterval: mergedProps.xInterval,
|
|
306
|
+
yInterval: mergedProps.yInterval,
|
|
307
|
+
gridStroke: mergedProps.gridStroke,
|
|
308
|
+
gridStrokeDasharray: mergedProps.gridStrokeDasharray,
|
|
309
|
+
dy: mergedProps.dy,
|
|
310
|
+
xAxisProps: mergedProps.xAxisProps,
|
|
311
|
+
yAxisProps: mergedProps.yAxisProps,
|
|
312
|
+
xAxisLabel: mergedProps.xAxisLabel,
|
|
313
|
+
yAxisLabel: mergedProps.yAxisLabel,
|
|
314
|
+
tickLine: mergedProps.tickLine,
|
|
315
|
+
axisLine: mergedProps.axisLine,
|
|
316
|
+
tooltipFormatter: mergedProps.tooltipFormatter,
|
|
317
|
+
legendProps: mergedProps.legendProps,
|
|
318
|
+
tooltipProps: mergedProps.tooltipProps,
|
|
319
|
+
customTooltip: mergedProps.customTooltip,
|
|
320
|
+
animation: mergedProps.animation,
|
|
321
|
+
animationDuration: mergedProps.animationDuration,
|
|
322
|
+
isAnimationActive: mergedProps.isAnimationActive,
|
|
323
|
+
syncId: mergedProps.syncId,
|
|
324
|
+
stackOffset: mergedProps.stackOffset,
|
|
325
|
+
barCategoryGapPercentage: mergedProps.barCategoryGapPercentage,
|
|
326
|
+
chartBackground: mergedProps.chartBackground,
|
|
327
|
+
borderRadius: mergedProps.borderRadius,
|
|
328
|
+
padding: mergedProps.padding,
|
|
329
|
+
shadow: mergedProps.shadow,
|
|
330
|
+
aspect: mergedProps.aspect,
|
|
331
|
+
minHeight: mergedProps.minHeight,
|
|
332
|
+
maxHeight: mergedProps.maxHeight,
|
|
333
|
+
minWidth: mergedProps.minWidth,
|
|
334
|
+
maxWidth: mergedProps.maxWidth,
|
|
335
|
+
onBarClick: mergedProps.onBarClick,
|
|
336
|
+
onBarMouseEnter: mergedProps.onBarMouseEnter,
|
|
337
|
+
onBarMouseLeave: mergedProps.onBarMouseLeave
|
|
338
|
+
}); }, [parsedData, parsedSeries, mergedProps, hasValidData]);
|
|
339
|
+
// Smart default margins based on layout
|
|
340
|
+
var smartMargin = (0, react_1.useMemo)(function () {
|
|
341
|
+
var baseMargin = { top: 10, right: 30, left: 0, bottom: 20 };
|
|
342
|
+
if (isVertical) {
|
|
343
|
+
return __assign(__assign(__assign({}, baseMargin), { left: 60, bottom: final.xAxisLabel ? 40 : 20 }), final.margin);
|
|
344
|
+
}
|
|
345
|
+
return __assign(__assign(__assign({}, baseMargin), { bottom: final.xAxisLabel ? 50 : 20 }), final.margin);
|
|
346
|
+
}, [isVertical, final.margin, final.xAxisLabel]);
|
|
56
347
|
// Smart height for vertical layout based on data length
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
348
|
+
var smartHeight = (0, react_1.useMemo)(function () {
|
|
349
|
+
if (final.height !== 300)
|
|
350
|
+
return final.height;
|
|
351
|
+
if (isVertical) {
|
|
352
|
+
return Math.max(300, parsedData.length * 45);
|
|
353
|
+
}
|
|
354
|
+
return final.height;
|
|
355
|
+
}, [final.height, isVertical, parsedData.length]);
|
|
356
|
+
var TooltipComponent = final.customTooltip || CustomTooltip;
|
|
357
|
+
var containerStyle = (0, react_1.useMemo)(function () { return ({
|
|
358
|
+
height: smartHeight,
|
|
359
|
+
width: final.width,
|
|
360
|
+
minHeight: final.minHeight,
|
|
361
|
+
maxHeight: final.maxHeight,
|
|
362
|
+
minWidth: final.minWidth,
|
|
363
|
+
maxWidth: final.maxWidth,
|
|
364
|
+
background: final.chartBackground,
|
|
365
|
+
borderRadius: final.borderRadius,
|
|
366
|
+
padding: final.padding,
|
|
367
|
+
boxShadow: final.shadow ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : undefined,
|
|
368
|
+
}); }, [smartHeight, final]);
|
|
369
|
+
// Handle bar radius based on layout
|
|
370
|
+
var getBarRadius = function (seriesRadius) {
|
|
371
|
+
if (seriesRadius !== undefined) {
|
|
372
|
+
return Array.isArray(seriesRadius) ? seriesRadius : [seriesRadius, seriesRadius, seriesRadius, seriesRadius];
|
|
373
|
+
}
|
|
374
|
+
if (isVertical) {
|
|
375
|
+
return [0, final.barRadius, final.barRadius, 0];
|
|
376
|
+
}
|
|
377
|
+
return [final.barRadius, final.barRadius, 0, 0];
|
|
378
|
+
};
|
|
379
|
+
// Show empty state if no data
|
|
380
|
+
if (!hasValidData) {
|
|
381
|
+
return (react_1.default.createElement("div", { className: "flex items-center justify-center ".concat(final.funcss), style: containerStyle },
|
|
382
|
+
react_1.default.createElement("div", { className: "text-center text-muted" },
|
|
383
|
+
react_1.default.createElement("div", { className: "text-lg mb-2" }, "\uD83D\uDCCA"),
|
|
384
|
+
react_1.default.createElement("div", null, "No chart data available"))));
|
|
385
|
+
}
|
|
386
|
+
return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: smartHeight, aspect: final.aspect, className: final.funcss, style: containerStyle },
|
|
387
|
+
react_1.default.createElement(recharts_1.BarChart, { data: final.data, layout: final.layout, margin: smartMargin, barGap: final.barGap, barCategoryGap: final.barCategoryGap, stackOffset: final.stackOffset, syncId: final.syncId },
|
|
388
|
+
final.showGrid && (react_1.default.createElement(recharts_1.CartesianGrid, { strokeDasharray: final.gridStrokeDasharray, stroke: final.gridStroke || getCssVar('border-color') || '#e2e8f0', horizontal: final.horizontalLines !== false, vertical: final.verticalLines !== false })),
|
|
389
|
+
final.showXAxis && (react_1.default.createElement(recharts_1.XAxis, __assign({ type: isVertical ? 'number' : 'category', dataKey: isVertical ? undefined : 'label', interval: final.xInterval, padding: { left: 10, right: 10 }, fontSize: final.xLabelSize, strokeWidth: 0.2, angle: final.rotateLabel || (isVertical ? 0 : -35), dy: (_c = final.dy) !== null && _c !== void 0 ? _c : (isVertical ? 0 : 10), tickLine: final.tickLine, axisLine: final.axisLine, label: final.xAxisLabel ? {
|
|
390
|
+
value: final.xAxisLabel,
|
|
391
|
+
position: isVertical ? 'insideBottom' : 'insideBottom',
|
|
392
|
+
offset: isVertical ? -10 : -30
|
|
393
|
+
} : undefined }, final.xAxisProps))),
|
|
394
|
+
final.showYAxis && (react_1.default.createElement(recharts_1.YAxis, __assign({ type: isVertical ? 'category' : 'number', dataKey: isVertical ? 'label' : undefined, interval: final.yInterval, strokeWidth: 0.2, fontSize: final.yLabelSize, tickLine: final.tickLine, axisLine: final.axisLine, label: final.yAxisLabel ? {
|
|
395
|
+
value: final.yAxisLabel,
|
|
396
|
+
angle: isVertical ? 0 : -90,
|
|
397
|
+
position: isVertical ? 'insideLeft' : 'insideLeft'
|
|
398
|
+
} : undefined }, final.yAxisProps))),
|
|
399
|
+
final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
|
|
400
|
+
final.showLegend && react_1.default.createElement(recharts_1.Legend, __assign({}, final.legendProps)),
|
|
401
|
+
final.series.map(function (s, index) {
|
|
402
|
+
if (!s || !s.dataKey) {
|
|
403
|
+
console.warn('Invalid series configuration at index:', index);
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
return (react_1.default.createElement(recharts_1.Bar, { key: s.dataKey || "series-".concat(index), dataKey: s.dataKey, name: s.label || s.dataKey, fill: resolveColor(s.color), stroke: s.stroke ? resolveColor(s.stroke) : undefined, strokeWidth: s.strokeWidth || 0, fillOpacity: s.fillOpacity !== undefined ? s.fillOpacity : 0.8, barSize: s.barSize || final.barSize, maxBarSize: s.maxBarSize || final.maxBarSize, stackId: s.stackId, background: s.background || false, minPointSize: s.minPointSize, isAnimationActive: final.isAnimationActive, animationDuration: final.animationDuration, onClick: final.onBarClick, onMouseEnter: final.onBarMouseEnter, onMouseLeave: final.onBarMouseLeave, activeBar: s.activeBar !== false ? (typeof s.activeBar === 'object' ? s.activeBar : {
|
|
408
|
+
fill: resolveColor(s.color),
|
|
409
|
+
stroke: resolveColor(s.stroke),
|
|
410
|
+
strokeWidth: 2,
|
|
411
|
+
fillOpacity: 1
|
|
412
|
+
}) : false }));
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
console.error('Error rendering bar series:', error);
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
}))));
|
|
72
419
|
};
|
|
73
420
|
exports.default = Bars;
|