funuicss 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/fun.css +619 -75
- package/index.d.ts +2 -1
- package/index.js +8 -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 +235 -42
- package/ui/chart/Line.js +19 -124
- package/ui/chart/Pie.d.ts +61 -7
- package/ui/chart/Pie.js +204 -41
- package/ui/drop/Dropdown.d.ts +4 -3
- package/ui/drop/Dropdown.js +24 -29
- package/ui/input/FileUpload.d.ts +21 -0
- package/ui/input/FileUpload.js +235 -0
- package/ui/input/Input.d.ts +0 -7
- package/ui/input/Input.js +16 -136
- 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.js +55 -49
- package/ui/text/Text.d.ts +2 -1
- package/ui/text/Text.js +51 -50
- package/ui/theme/theme.d.ts +34 -0
- package/ui/theme/theme.js +198 -18
- package/ui/vista/Vista.js +58 -141
- package/utils/componentUtils.js +27 -4
package/index.d.ts
CHANGED
|
@@ -55,7 +55,8 @@ export { default as Slider } from "./ui/slider/Slider";
|
|
|
55
55
|
export { default as FlexItem } from "./ui/flex/FlexItem";
|
|
56
56
|
export { default as ScrollToTop } from "./ui/scrolltotop/ScrollToTop";
|
|
57
57
|
export { default as Select } from "./ui/select/Select";
|
|
58
|
+
export { default as FileUpload } from "./ui/input/FileUpload";
|
|
58
59
|
export { default as Cookie } from "./js/Cookie";
|
|
59
|
-
export { useVariable } from "./ui/theme/theme";
|
|
60
|
+
export { useVariable, useAsset, useAssetType, useAssetValue, useAssets, useVariables, } from "./ui/theme/theme";
|
|
60
61
|
export { FunGet } from "./js/Fun";
|
|
61
62
|
export { default as GoogleAnalytics } from "./js/google/analytics";
|
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.FileUpload = 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");
|
|
@@ -119,11 +119,18 @@ var ScrollToTop_1 = require("./ui/scrolltotop/ScrollToTop");
|
|
|
119
119
|
Object.defineProperty(exports, "ScrollToTop", { enumerable: true, get: function () { return __importDefault(ScrollToTop_1).default; } });
|
|
120
120
|
var Select_1 = require("./ui/select/Select");
|
|
121
121
|
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
|
|
122
|
+
var FileUpload_1 = require("./ui/input/FileUpload");
|
|
123
|
+
Object.defineProperty(exports, "FileUpload", { enumerable: true, get: function () { return __importDefault(FileUpload_1).default; } });
|
|
122
124
|
// js
|
|
123
125
|
var Cookie_1 = require("./js/Cookie");
|
|
124
126
|
Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return __importDefault(Cookie_1).default; } });
|
|
125
127
|
var theme_2 = require("./ui/theme/theme");
|
|
126
128
|
Object.defineProperty(exports, "useVariable", { enumerable: true, get: function () { return theme_2.useVariable; } });
|
|
129
|
+
Object.defineProperty(exports, "useAsset", { enumerable: true, get: function () { return theme_2.useAsset; } });
|
|
130
|
+
Object.defineProperty(exports, "useAssetType", { enumerable: true, get: function () { return theme_2.useAssetType; } });
|
|
131
|
+
Object.defineProperty(exports, "useAssetValue", { enumerable: true, get: function () { return theme_2.useAssetValue; } });
|
|
132
|
+
Object.defineProperty(exports, "useAssets", { enumerable: true, get: function () { return theme_2.useAssets; } });
|
|
133
|
+
Object.defineProperty(exports, "useVariables", { enumerable: true, get: function () { return theme_2.useVariables; } });
|
|
127
134
|
var Fun_1 = require("./js/Fun");
|
|
128
135
|
Object.defineProperty(exports, "FunGet", { enumerable: true, get: function () { return Fun_1.FunGet; } });
|
|
129
136
|
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.3",
|
|
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,256 @@ 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
|
-
var Bars = function (
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
158
|
+
var Bars = function (localProps) {
|
|
159
|
+
var _a;
|
|
160
|
+
// Use component configuration with variant support
|
|
161
|
+
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Bar', localProps.variant).mergeWithLocal;
|
|
162
|
+
// Merge with config - LOCAL PROPS OVERRIDE CONFIG
|
|
163
|
+
var mergedProps = mergeWithLocal(localProps).props;
|
|
164
|
+
// Debug: Log what props are actually coming through
|
|
165
|
+
react_1.default.useEffect(function () {
|
|
166
|
+
console.log('Bars merged props:', mergedProps);
|
|
167
|
+
console.log('Bars config available:', Object.keys(mergedProps).length > 0);
|
|
168
|
+
}, [mergedProps]);
|
|
169
|
+
// Parse data and series if they're strings with enhanced validation
|
|
170
|
+
var parsedData = (0, react_1.useMemo)(function () {
|
|
171
|
+
var parsed = parseIfString(mergedProps.data, []);
|
|
172
|
+
return getSafeArray(parsed);
|
|
173
|
+
}, [mergedProps.data]);
|
|
174
|
+
var parsedSeries = (0, react_1.useMemo)(function () {
|
|
175
|
+
var parsed = parseIfString(mergedProps.series, []);
|
|
176
|
+
return getSafeArray(parsed).filter(function (series) {
|
|
177
|
+
return series && typeof series === 'object' && series.dataKey;
|
|
178
|
+
});
|
|
179
|
+
}, [mergedProps.series]);
|
|
180
|
+
// Check if we have valid data to display
|
|
181
|
+
var hasValidData = parsedData.length > 0 && parsedSeries.length > 0;
|
|
182
|
+
var isVertical = mergedProps.layout === 'vertical';
|
|
183
|
+
// Use mergedProps directly - no need for complex fallback logic
|
|
184
|
+
var final = mergedProps;
|
|
185
|
+
// Smart default margins based on layout
|
|
186
|
+
var smartMargin = (0, react_1.useMemo)(function () {
|
|
187
|
+
var baseMargin = { top: 10, right: 30, left: 0, bottom: 20 };
|
|
188
|
+
if (isVertical) {
|
|
189
|
+
return __assign(__assign(__assign({}, baseMargin), { left: 60, bottom: final.xAxisLabel ? 40 : 20 }), final.margin);
|
|
190
|
+
}
|
|
191
|
+
return __assign(__assign(__assign({}, baseMargin), { bottom: final.xAxisLabel ? 50 : 20 }), final.margin);
|
|
192
|
+
}, [isVertical, final.margin, final.xAxisLabel]);
|
|
56
193
|
// 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
|
-
|
|
194
|
+
var smartHeight = (0, react_1.useMemo)(function () {
|
|
195
|
+
if (final.height !== 300)
|
|
196
|
+
return final.height;
|
|
197
|
+
if (isVertical) {
|
|
198
|
+
return Math.max(300, parsedData.length * 45);
|
|
199
|
+
}
|
|
200
|
+
return final.height;
|
|
201
|
+
}, [final.height, isVertical, parsedData.length]);
|
|
202
|
+
var TooltipComponent = final.customTooltip || CustomTooltip;
|
|
203
|
+
var containerStyle = (0, react_1.useMemo)(function () { return ({
|
|
204
|
+
height: smartHeight,
|
|
205
|
+
width: final.width,
|
|
206
|
+
minHeight: final.minHeight,
|
|
207
|
+
maxHeight: final.maxHeight,
|
|
208
|
+
minWidth: final.minWidth,
|
|
209
|
+
maxWidth: final.maxWidth,
|
|
210
|
+
background: final.chartBackground,
|
|
211
|
+
borderRadius: final.borderRadius,
|
|
212
|
+
padding: final.padding,
|
|
213
|
+
boxShadow: final.shadow ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : undefined,
|
|
214
|
+
}); }, [smartHeight, final]);
|
|
215
|
+
// Handle bar radius based on layout
|
|
216
|
+
var getBarRadius = function (seriesRadius) {
|
|
217
|
+
if (seriesRadius !== undefined) {
|
|
218
|
+
return Array.isArray(seriesRadius) ? seriesRadius : [seriesRadius, seriesRadius, seriesRadius, seriesRadius];
|
|
219
|
+
}
|
|
220
|
+
if (isVertical) {
|
|
221
|
+
return [0, final.barRadius, final.barRadius, 0];
|
|
222
|
+
}
|
|
223
|
+
return [final.barRadius, final.barRadius, 0, 0];
|
|
224
|
+
};
|
|
225
|
+
// Show empty state if no data
|
|
226
|
+
if (!hasValidData) {
|
|
227
|
+
return (react_1.default.createElement("div", { className: "flex items-center justify-center ".concat(final.funcss), style: containerStyle },
|
|
228
|
+
react_1.default.createElement("div", { className: "text-center text-muted" },
|
|
229
|
+
react_1.default.createElement("div", { className: "text-lg mb-2" }, "\uD83D\uDCCA"),
|
|
230
|
+
react_1.default.createElement("div", null, "No chart data available"))));
|
|
231
|
+
}
|
|
232
|
+
return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: final.width, height: smartHeight, aspect: final.aspect, className: final.funcss, style: containerStyle },
|
|
233
|
+
react_1.default.createElement(recharts_1.BarChart, { data: parsedData, layout: final.layout, margin: smartMargin, barGap: final.barGap, barCategoryGap: final.barCategoryGap, stackOffset: final.stackOffset, syncId: final.syncId },
|
|
234
|
+
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 })),
|
|
235
|
+
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: (_a = final.dy) !== null && _a !== void 0 ? _a : (isVertical ? 0 : 10), tickLine: final.tickLine, axisLine: final.axisLine, label: final.xAxisLabel ? {
|
|
236
|
+
value: final.xAxisLabel,
|
|
237
|
+
position: isVertical ? 'insideBottom' : 'insideBottom',
|
|
238
|
+
offset: isVertical ? -10 : -30
|
|
239
|
+
} : undefined }, final.xAxisProps))),
|
|
240
|
+
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 ? {
|
|
241
|
+
value: final.yAxisLabel,
|
|
242
|
+
angle: isVertical ? 0 : -90,
|
|
243
|
+
position: isVertical ? 'insideLeft' : 'insideLeft'
|
|
244
|
+
} : undefined }, final.yAxisProps))),
|
|
245
|
+
final.showTooltip && (react_1.default.createElement(recharts_1.Tooltip, __assign({ content: react_1.default.createElement(TooltipComponent, { formatter: final.tooltipFormatter }), formatter: final.tooltipFormatter }, final.tooltipProps))),
|
|
246
|
+
final.showLegend && react_1.default.createElement(recharts_1.Legend, __assign({}, final.legendProps)),
|
|
247
|
+
parsedSeries.map(function (s, index) {
|
|
248
|
+
if (!s || !s.dataKey) {
|
|
249
|
+
console.warn('Invalid series configuration at index:', index);
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
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 : {
|
|
254
|
+
fill: resolveColor(s.color),
|
|
255
|
+
stroke: resolveColor(s.stroke),
|
|
256
|
+
strokeWidth: 2,
|
|
257
|
+
fillOpacity: 1
|
|
258
|
+
}) : false }));
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.error('Error rendering bar series:', error);
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}))));
|
|
72
265
|
};
|
|
73
266
|
exports.default = Bars;
|