@pibit.ai/cure-design-system 0.6.43 → 0.6.44
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.
|
@@ -7,7 +7,8 @@ export interface DonutChartProps {
|
|
|
7
7
|
colors: string[];
|
|
8
8
|
innerRadius?: number;
|
|
9
9
|
outerRadius?: number;
|
|
10
|
-
|
|
10
|
+
/** Appends % to slice values in the legend. Default true. */
|
|
11
|
+
isPercentage?: boolean;
|
|
11
12
|
/** When true, renders a color swatch + label + value to the right of the chart. */
|
|
12
13
|
showLegend?: boolean;
|
|
13
14
|
/** When true, shows the numeric total in the donut hole. */
|
|
@@ -26,7 +27,9 @@ export interface DonutChartProps {
|
|
|
26
27
|
* Intended for tiny progress indicators.
|
|
27
28
|
*/
|
|
28
29
|
compact?: boolean;
|
|
30
|
+
/** Accessible name for the chart. Defaults to the data, e.g. "Open 60%, Closed 40%". */
|
|
31
|
+
"aria-label"?: string;
|
|
29
32
|
}
|
|
30
|
-
export declare function DonutChart({ data, colors, innerRadius, outerRadius, isPercentage, showLegend, showCenterLabel, centerSubLabel, title, size, compact, }: DonutChartProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function DonutChart({ data, colors, innerRadius, outerRadius, isPercentage, showLegend, showCenterLabel, centerSubLabel, title, size, compact, "aria-label": ariaLabel, }: DonutChartProps): import("react/jsx-runtime").JSX.Element;
|
|
31
34
|
export default DonutChart;
|
|
32
35
|
//# sourceMappingURL=donut-chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donut-chart.d.ts","sourceRoot":"","sources":["../../../src/primitives/donut-chart/donut-chart.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"donut-chart.d.ts","sourceRoot":"","sources":["../../../src/primitives/donut-chart/donut-chart.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mFAAmF;IACnF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAqBD,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,WAAgB,EAChB,WAAiB,EACjB,YAAmB,EACnB,UAAkB,EAClB,eAAuB,EACvB,cAAc,EACd,KAAK,EACL,IAAU,EACV,OAAe,EACf,YAAY,EAAE,SAAS,GAC1B,EAAE,eAAe,2CAyHjB;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,111 +1,121 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as p } from "react";
|
|
3
|
-
import { ResponsiveContainer as
|
|
4
|
-
import { PieChart as
|
|
5
|
-
import { Pie as
|
|
6
|
-
import { Cell as
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
10
|
-
const o = [...
|
|
11
|
-
for (let
|
|
12
|
-
const
|
|
13
|
-
o.push(`hsl(${
|
|
3
|
+
import { ResponsiveContainer as $ } from "../../node_modules/recharts/es6/component/ResponsiveContainer.js";
|
|
4
|
+
import { PieChart as j } from "../../node_modules/recharts/es6/chart/PieChart.js";
|
|
5
|
+
import { Pie as C } from "../../node_modules/recharts/es6/polar/Pie.js";
|
|
6
|
+
import { Cell as k } from "../../node_modules/recharts/es6/component/Cell.js";
|
|
7
|
+
const A = (a, r) => {
|
|
8
|
+
if (a <= r.length)
|
|
9
|
+
return r.slice(0, a);
|
|
10
|
+
const o = [...r], m = a - r.length;
|
|
11
|
+
for (let i = 0; i < m; i++) {
|
|
12
|
+
const d = i * 360 / m, h = 65 + i % 3 * 10, c = 50 + i % 2 * 10;
|
|
13
|
+
o.push(`hsl(${d}, ${h}%, ${c}%)`);
|
|
14
14
|
}
|
|
15
15
|
return o;
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
data:
|
|
19
|
-
colors:
|
|
17
|
+
function B({
|
|
18
|
+
data: a,
|
|
19
|
+
colors: r,
|
|
20
20
|
innerRadius: o = 72,
|
|
21
|
-
outerRadius:
|
|
22
|
-
isPercentage:
|
|
23
|
-
showLegend:
|
|
24
|
-
showCenterLabel:
|
|
25
|
-
centerSubLabel:
|
|
21
|
+
outerRadius: m = 120,
|
|
22
|
+
isPercentage: i = !0,
|
|
23
|
+
showLegend: d = !1,
|
|
24
|
+
showCenterLabel: h = !1,
|
|
25
|
+
centerSubLabel: c,
|
|
26
26
|
title: g,
|
|
27
|
-
size:
|
|
28
|
-
compact: f = !1
|
|
27
|
+
size: u = 240,
|
|
28
|
+
compact: f = !1,
|
|
29
|
+
"aria-label": v
|
|
29
30
|
}) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
const l = p(() => [...a], [a]), y = p(() => A(l.length, r), [l, r]), N = p(() => l.reduce((t, n) => t + (Number.isFinite(n.value) ? n.value : 0), 0), [l]), w = (t) => `${Number.isFinite(t) ? t : 0}${i ? "%" : ""}`, b = v ?? l.map((t) => `${String(t.name)} ${w(t.value)}`).join(", "), x = /* @__PURE__ */ s(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: "pointer-events-none relative",
|
|
35
|
+
style: { width: u, height: u },
|
|
36
|
+
role: "img",
|
|
37
|
+
"aria-label": b,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ e($, { width: "100%", height: "100%", children: /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e(
|
|
40
|
+
C,
|
|
41
|
+
{
|
|
42
|
+
data: l,
|
|
43
|
+
dataKey: "value",
|
|
44
|
+
nameKey: "name",
|
|
45
|
+
cx: "50%",
|
|
46
|
+
cy: "50%",
|
|
47
|
+
innerRadius: o,
|
|
48
|
+
outerRadius: m,
|
|
49
|
+
startAngle: 90,
|
|
50
|
+
endAngle: -270,
|
|
51
|
+
paddingAngle: f ? 0 : 2,
|
|
52
|
+
strokeWidth: 0,
|
|
53
|
+
cornerRadius: f ? 0 : 4,
|
|
54
|
+
style: { outline: "none" },
|
|
55
|
+
isAnimationActive: !1,
|
|
56
|
+
children: l.map((t, n) => /* @__PURE__ */ e(
|
|
57
|
+
k,
|
|
58
|
+
{
|
|
59
|
+
fill: y[n],
|
|
60
|
+
stroke: "none",
|
|
61
|
+
style: { outline: "none", cursor: "default" }
|
|
62
|
+
},
|
|
63
|
+
`cell-${n}`
|
|
64
|
+
))
|
|
65
|
+
}
|
|
66
|
+
) }) }),
|
|
67
|
+
h && /* @__PURE__ */ s(
|
|
68
|
+
"div",
|
|
50
69
|
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"aria-hidden": !0,
|
|
64
|
-
children: [
|
|
65
|
-
/* @__PURE__ */ e("span", { className: "text-2xl font-semibold tabular-nums text-primary", children: Number.isFinite(y) ? y : 0 }),
|
|
66
|
-
m ? /* @__PURE__ */ e("span", { className: "mt-1 max-w-[7.5rem] text-sm font-normal leading-snug text-secondary text-center", children: m }) : null
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
)
|
|
70
|
-
] });
|
|
71
|
-
return u ? /* @__PURE__ */ a("div", { className: "flex w-full min-w-0 max-w-[1100px] flex-col gap-3 bg-white", style: { outline: "none" }, children: [
|
|
70
|
+
className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center px-4 text-center",
|
|
71
|
+
"aria-hidden": !0,
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ e("span", { className: "text-2xl font-semibold tabular-nums text-primary", children: Number.isFinite(N) ? N : 0 }),
|
|
74
|
+
c ? /* @__PURE__ */ e("span", { className: "mt-1 max-w-[7.5rem] text-sm font-normal leading-snug text-secondary text-center", children: c }) : null
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
return d ? /* @__PURE__ */ s("div", { className: "flex w-full min-w-0 max-w-[1100px] flex-col gap-3 bg-primary", style: { outline: "none" }, children: [
|
|
72
82
|
g ? /* @__PURE__ */ e("h4", { className: "text-sm font-normal text-primary", children: g }) : null,
|
|
73
|
-
/* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ s("div", { className: "flex w-full min-w-0 flex-row flex-wrap items-center gap-[60px]", children: [
|
|
74
84
|
x,
|
|
75
|
-
|
|
85
|
+
l.length > 0 ? /* @__PURE__ */ e("ul", { className: "flex min-h-[2.75rem] min-w-0 flex-1 flex-row flex-wrap content-center items-stretch gap-x-[60px] gap-y-4", children: l.map((t, n) => /* @__PURE__ */ s("li", { className: "flex w-[132px] items-stretch gap-2.5", children: [
|
|
76
86
|
/* @__PURE__ */ e(
|
|
77
87
|
"div",
|
|
78
88
|
{
|
|
79
89
|
className: "w-1.5 shrink-0 rounded-sm",
|
|
80
90
|
style: {
|
|
81
|
-
backgroundColor:
|
|
91
|
+
backgroundColor: y[n],
|
|
82
92
|
minHeight: "2.75rem"
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
),
|
|
86
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 flex-col justify-center", children: [
|
|
87
97
|
/* @__PURE__ */ e("span", { className: "text-xs text-secondary", children: t.name }),
|
|
88
|
-
/* @__PURE__ */ e("span", { className: "text-xl font-semibold tabular-nums text-primary", children:
|
|
98
|
+
/* @__PURE__ */ e("span", { className: "text-xl font-semibold tabular-nums text-primary", children: w(t.value) })
|
|
89
99
|
] })
|
|
90
|
-
] }, `${String(t.name)}-${
|
|
100
|
+
] }, `${String(t.name)}-${n}`)) }) : null
|
|
91
101
|
] })
|
|
92
102
|
] }) : f ? /* @__PURE__ */ e(
|
|
93
103
|
"div",
|
|
94
104
|
{
|
|
95
105
|
className: "flex items-center justify-center",
|
|
96
|
-
style: { outline: "none", width:
|
|
106
|
+
style: { outline: "none", width: u, height: u },
|
|
97
107
|
children: x
|
|
98
108
|
}
|
|
99
109
|
) : /* @__PURE__ */ e(
|
|
100
110
|
"div",
|
|
101
111
|
{
|
|
102
|
-
className: "flex h-full min-h-[150px] w-full items-center justify-center bg-
|
|
112
|
+
className: "flex h-full min-h-[150px] w-full items-center justify-center bg-primary",
|
|
103
113
|
style: { outline: "none" },
|
|
104
114
|
children: x
|
|
105
115
|
}
|
|
106
116
|
);
|
|
107
117
|
}
|
|
108
118
|
export {
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
B as DonutChart,
|
|
120
|
+
B as default
|
|
111
121
|
};
|