framepexls-ui-lib 0.3.23 → 0.3.25
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/dist/Checkbox.d.mts +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/RechartsDonutCard.js +49 -20
- package/dist/RechartsDonutCard.mjs +50 -21
- package/package.json +1 -1
package/dist/Checkbox.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ type CheckboxProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
11
11
|
className?: string;
|
|
12
12
|
inputClassName?: string;
|
|
13
13
|
};
|
|
14
|
-
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "
|
|
14
|
+
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
|
15
15
|
label?: React__default.ReactNode;
|
|
16
16
|
description?: React__default.ReactNode;
|
|
17
17
|
error?: boolean;
|
package/dist/Checkbox.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type CheckboxProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
11
11
|
className?: string;
|
|
12
12
|
inputClassName?: string;
|
|
13
13
|
};
|
|
14
|
-
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "
|
|
14
|
+
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
|
15
15
|
label?: React__default.ReactNode;
|
|
16
16
|
description?: React__default.ReactNode;
|
|
17
17
|
error?: boolean;
|
|
@@ -55,8 +55,36 @@ function RechartsDonutCard({
|
|
|
55
55
|
valueFormatter
|
|
56
56
|
}) {
|
|
57
57
|
const safeData = Array.isArray(data) ? data : [];
|
|
58
|
+
const totalValue = safeData.reduce((acc, item) => {
|
|
59
|
+
var _a;
|
|
60
|
+
const raw = Number((_a = item == null ? void 0 : item[valueKey]) != null ? _a : 0);
|
|
61
|
+
return acc + (Number.isFinite(raw) ? raw : 0);
|
|
62
|
+
}, 0);
|
|
63
|
+
const formattedTotal = typeof totalValue === "number" ? valueFormatter ? valueFormatter(totalValue) : totalValue.toLocaleString("es-MX", { maximumFractionDigits: 2 }) : "";
|
|
64
|
+
const renderTooltip = (props) => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const { active, payload } = props || {};
|
|
67
|
+
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
68
|
+
const p = payload[0];
|
|
69
|
+
const rawValue = p.value;
|
|
70
|
+
const value = typeof rawValue === "number" ? valueFormatter ? valueFormatter(rawValue) : rawValue.toLocaleString("es-MX", { maximumFractionDigits: 2 }) : rawValue;
|
|
71
|
+
const label = (_b = (_a = p.payload && p.payload[nameKey]) != null ? _a : p.name) != null ? _b : "";
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rounded-xl border border-slate-200 bg-white/95 px-3 py-2 text-xs shadow-xl dark:border-white/10 dark:bg-slate-900/95 dark:text-slate-50", children: [
|
|
73
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-1 font-medium text-slate-800 dark:text-slate-50", children: label }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
"span",
|
|
77
|
+
{
|
|
78
|
+
className: "inline-block h-2 w-2 rounded-full",
|
|
79
|
+
style: { backgroundColor: p.color }
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-semibold text-slate-800 dark:text-slate-50", children: value })
|
|
83
|
+
] })
|
|
84
|
+
] });
|
|
85
|
+
};
|
|
58
86
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChartCard.default, { title, subtitle, children: !safeData.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex h-[220px] items-center justify-center text-xs text-slate-500 dark:text-slate-400", children: "Sin datos para los filtros seleccionados." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex h-[240px] w-full items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_recharts.PieChart, { width: 260, height: 220, children: [
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
60
88
|
import_recharts.Pie,
|
|
61
89
|
{
|
|
62
90
|
data: safeData,
|
|
@@ -65,26 +93,27 @@ function RechartsDonutCard({
|
|
|
65
93
|
innerRadius: 50,
|
|
66
94
|
outerRadius: 80,
|
|
67
95
|
paddingAngle: 2,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
labelLine: false,
|
|
97
|
+
label: ({ percent }) => percent && percent > 0.05 ? `${(percent * 100).toFixed(0)}%` : "",
|
|
98
|
+
children: [
|
|
99
|
+
safeData.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
100
|
+
import_recharts.Cell,
|
|
101
|
+
{
|
|
102
|
+
fill: colors[index % colors.length]
|
|
103
|
+
},
|
|
104
|
+
`slice-${index}`
|
|
105
|
+
)),
|
|
106
|
+
formattedTotal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
import_recharts.Label,
|
|
108
|
+
{
|
|
109
|
+
position: "center",
|
|
110
|
+
value: formattedTotal,
|
|
111
|
+
style: { fontSize: 12, fontWeight: 600 }
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
]
|
|
75
115
|
}
|
|
76
116
|
),
|
|
77
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
-
import_recharts.Tooltip,
|
|
79
|
-
{
|
|
80
|
-
formatter: (value, name, props) => {
|
|
81
|
-
const v = typeof value === "number" ? valueFormatter ? valueFormatter(value) : value.toLocaleString("es-MX", {
|
|
82
|
-
maximumFractionDigits: 2
|
|
83
|
-
}) : value;
|
|
84
|
-
const label = (props == null ? void 0 : props.payload) && props.payload[nameKey] || name;
|
|
85
|
-
return [v, label];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
)
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.Tooltip, { content: renderTooltip })
|
|
89
118
|
] }) }) });
|
|
90
119
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import ChartCard from "./ChartCard";
|
|
4
|
-
import { PieChart, Pie, Cell, Tooltip } from "recharts";
|
|
4
|
+
import { PieChart, Pie, Cell, Tooltip, Label } from "recharts";
|
|
5
5
|
const DEFAULT_COLORS = [
|
|
6
6
|
"#0ea5e9",
|
|
7
7
|
"#6366f1",
|
|
@@ -22,8 +22,36 @@ function RechartsDonutCard({
|
|
|
22
22
|
valueFormatter
|
|
23
23
|
}) {
|
|
24
24
|
const safeData = Array.isArray(data) ? data : [];
|
|
25
|
+
const totalValue = safeData.reduce((acc, item) => {
|
|
26
|
+
var _a;
|
|
27
|
+
const raw = Number((_a = item == null ? void 0 : item[valueKey]) != null ? _a : 0);
|
|
28
|
+
return acc + (Number.isFinite(raw) ? raw : 0);
|
|
29
|
+
}, 0);
|
|
30
|
+
const formattedTotal = typeof totalValue === "number" ? valueFormatter ? valueFormatter(totalValue) : totalValue.toLocaleString("es-MX", { maximumFractionDigits: 2 }) : "";
|
|
31
|
+
const renderTooltip = (props) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const { active, payload } = props || {};
|
|
34
|
+
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
35
|
+
const p = payload[0];
|
|
36
|
+
const rawValue = p.value;
|
|
37
|
+
const value = typeof rawValue === "number" ? valueFormatter ? valueFormatter(rawValue) : rawValue.toLocaleString("es-MX", { maximumFractionDigits: 2 }) : rawValue;
|
|
38
|
+
const label = (_b = (_a = p.payload && p.payload[nameKey]) != null ? _a : p.name) != null ? _b : "";
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-slate-200 bg-white/95 px-3 py-2 text-xs shadow-xl dark:border-white/10 dark:bg-slate-900/95 dark:text-slate-50", children: [
|
|
40
|
+
label && /* @__PURE__ */ jsx("div", { className: "mb-1 font-medium text-slate-800 dark:text-slate-50", children: label }),
|
|
41
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
className: "inline-block h-2 w-2 rounded-full",
|
|
46
|
+
style: { backgroundColor: p.color }
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-800 dark:text-slate-50", children: value })
|
|
50
|
+
] })
|
|
51
|
+
] });
|
|
52
|
+
};
|
|
25
53
|
return /* @__PURE__ */ jsx(ChartCard, { title, subtitle, children: !safeData.length ? /* @__PURE__ */ jsx("div", { className: "flex h-[220px] items-center justify-center text-xs text-slate-500 dark:text-slate-400", children: "Sin datos para los filtros seleccionados." }) : /* @__PURE__ */ jsx("div", { className: "flex h-[240px] w-full items-center justify-center", children: /* @__PURE__ */ jsxs(PieChart, { width: 260, height: 220, children: [
|
|
26
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ jsxs(
|
|
27
55
|
Pie,
|
|
28
56
|
{
|
|
29
57
|
data: safeData,
|
|
@@ -32,27 +60,28 @@ function RechartsDonutCard({
|
|
|
32
60
|
innerRadius: 50,
|
|
33
61
|
outerRadius: 80,
|
|
34
62
|
paddingAngle: 2,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
labelLine: false,
|
|
64
|
+
label: ({ percent }) => percent && percent > 0.05 ? `${(percent * 100).toFixed(0)}%` : "",
|
|
65
|
+
children: [
|
|
66
|
+
safeData.map((entry, index) => /* @__PURE__ */ jsx(
|
|
67
|
+
Cell,
|
|
68
|
+
{
|
|
69
|
+
fill: colors[index % colors.length]
|
|
70
|
+
},
|
|
71
|
+
`slice-${index}`
|
|
72
|
+
)),
|
|
73
|
+
formattedTotal && /* @__PURE__ */ jsx(
|
|
74
|
+
Label,
|
|
75
|
+
{
|
|
76
|
+
position: "center",
|
|
77
|
+
value: formattedTotal,
|
|
78
|
+
style: { fontSize: 12, fontWeight: 600 }
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
]
|
|
42
82
|
}
|
|
43
83
|
),
|
|
44
|
-
/* @__PURE__ */ jsx(
|
|
45
|
-
Tooltip,
|
|
46
|
-
{
|
|
47
|
-
formatter: (value, name, props) => {
|
|
48
|
-
const v = typeof value === "number" ? valueFormatter ? valueFormatter(value) : value.toLocaleString("es-MX", {
|
|
49
|
-
maximumFractionDigits: 2
|
|
50
|
-
}) : value;
|
|
51
|
-
const label = (props == null ? void 0 : props.payload) && props.payload[nameKey] || name;
|
|
52
|
-
return [v, label];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
)
|
|
84
|
+
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip })
|
|
56
85
|
] }) }) });
|
|
57
86
|
}
|
|
58
87
|
export {
|