@deepnoid/ui 0.1.167 → 0.1.169
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/.turbo/turbo-build.log +165 -160
- package/dist/chunk-B4UNRT7U.mjs +192 -0
- package/dist/{chunk-BRVQTI2T.mjs → chunk-JOK735WN.mjs} +9 -3
- package/dist/{chunk-ARNMOGRH.mjs → chunk-LH6Z7SDZ.mjs} +1 -1
- package/dist/components/charts/areaChart.js +1 -1
- package/dist/components/charts/areaChart.mjs +1 -1
- package/dist/components/charts/barChart.d.mts +4 -2
- package/dist/components/charts/barChart.d.ts +4 -2
- package/dist/components/charts/barChart.js +9 -3
- package/dist/components/charts/barChart.mjs +1 -1
- package/dist/components/charts/index.d.mts +1 -0
- package/dist/components/charts/index.d.ts +1 -0
- package/dist/components/charts/index.js +195 -6
- package/dist/components/charts/index.mjs +8 -4
- package/dist/components/charts/simpleBarChart.d.mts +40 -0
- package/dist/components/charts/simpleBarChart.d.ts +40 -0
- package/dist/components/charts/simpleBarChart.js +555 -0
- package/dist/components/charts/simpleBarChart.mjs +10 -0
- package/dist/components/picker/datePicker.mjs +2 -2
- package/dist/components/picker/index.mjs +2 -2
- package/dist/components/table/index.mjs +1 -1
- package/dist/components/table/table-body.mjs +1 -1
- package/dist/components/table/table-head.mjs +1 -1
- package/dist/components/table/table.mjs +1 -1
- package/dist/components/toast/index.mjs +2 -2
- package/dist/components/toast/use-toast.mjs +2 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +208 -19
- package/dist/index.mjs +26 -22
- package/package.json +1 -1
- package/dist/{chunk-VYNBJBXD.mjs → chunk-3OCNT22V.mjs} +0 -0
- package/dist/{chunk-EQLBG32V.mjs → chunk-4OOHXMJH.mjs} +3 -3
- package/dist/{chunk-NJFJJIWK.mjs → chunk-W66K4FK5.mjs} +3 -3
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
mapPropsVariants
|
|
4
|
+
} from "./chunk-E3G5QXSH.mjs";
|
|
5
|
+
import {
|
|
6
|
+
tv
|
|
7
|
+
} from "./chunk-U4DJHAM5.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/charts/simpleBarChart.tsx
|
|
10
|
+
import { forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { XAxis, YAxis, ResponsiveContainer, CartesianGrid, BarChart, Bar } from "recharts";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var SimpleBarChartComponent = forwardRef((originalProps, ref) => {
|
|
14
|
+
const [props, variantProps] = mapPropsVariants(originalProps, simpleBarChartStyle.variantKeys);
|
|
15
|
+
const {
|
|
16
|
+
data = [],
|
|
17
|
+
label,
|
|
18
|
+
classNames,
|
|
19
|
+
yAxisTicks = [0, 20, 40, 60, 80, 100],
|
|
20
|
+
yAxisDomain = [0, 100],
|
|
21
|
+
barGap = 20,
|
|
22
|
+
tooltipFormatter
|
|
23
|
+
} = { ...props, ...variantProps };
|
|
24
|
+
const slots = useMemo(() => simpleBarChartStyle({ ...variantProps }), [variantProps]);
|
|
25
|
+
const chartRef = useRef(null);
|
|
26
|
+
const tooltipRef = useRef(null);
|
|
27
|
+
const [tooltipLeft, setTooltipLeft] = useState(0);
|
|
28
|
+
const [tickPositions, setTickPositions] = useState([]);
|
|
29
|
+
const tickRef = useRef([]);
|
|
30
|
+
const [tooltipState, setTooltipState] = useState(null);
|
|
31
|
+
const handleMouseEnter = (e) => {
|
|
32
|
+
if (!tooltipFormatter || !chartRef.current) return;
|
|
33
|
+
const { payload, x, y } = e;
|
|
34
|
+
if (!payload) return;
|
|
35
|
+
setTooltipState({
|
|
36
|
+
x,
|
|
37
|
+
y,
|
|
38
|
+
value: payload.value,
|
|
39
|
+
label: payload.title
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const handleMouseLeave = () => {
|
|
43
|
+
setTooltipState(null);
|
|
44
|
+
};
|
|
45
|
+
const CustomBarShape = ({ x, y, width, height, fill }) => {
|
|
46
|
+
const radius = 4;
|
|
47
|
+
const extraHeight = 10;
|
|
48
|
+
const adjustedHeight = height + extraHeight;
|
|
49
|
+
const adjustedY = y - extraHeight;
|
|
50
|
+
const bottomY = adjustedY + adjustedHeight;
|
|
51
|
+
return height > 0 ? /* @__PURE__ */ jsx(
|
|
52
|
+
"path",
|
|
53
|
+
{
|
|
54
|
+
d: `M${x},${bottomY} L${x},${adjustedY + radius} Q${x},${adjustedY} ${x + radius},${adjustedY} L${x + width - radius},${adjustedY} Q${x + width},${adjustedY} ${x + width},${adjustedY + radius} L${x + width},${bottomY} Z`,
|
|
55
|
+
fill
|
|
56
|
+
}
|
|
57
|
+
) : /* @__PURE__ */ jsx("rect", { x, y, width, height: 0, fill });
|
|
58
|
+
};
|
|
59
|
+
const CustomTick = ({ x, y, payload }) => {
|
|
60
|
+
if (x !== void 0) tickRef.current.push(x);
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"text",
|
|
63
|
+
{
|
|
64
|
+
x,
|
|
65
|
+
y: y + 14,
|
|
66
|
+
textAnchor: "middle",
|
|
67
|
+
fontSize: 12,
|
|
68
|
+
fontWeight: 700,
|
|
69
|
+
fill: "currentColor",
|
|
70
|
+
className: "text-body-foreground",
|
|
71
|
+
children: payload.value
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const raf = requestAnimationFrame(() => {
|
|
77
|
+
const unique = [...new Set(tickRef.current)].sort((a, b) => a - b);
|
|
78
|
+
const mids = [];
|
|
79
|
+
for (let i = 0; i < unique.length - 1; i++) {
|
|
80
|
+
mids.push((unique[i] + unique[i + 1]) / 2);
|
|
81
|
+
}
|
|
82
|
+
setTickPositions(mids);
|
|
83
|
+
tickRef.current = [];
|
|
84
|
+
});
|
|
85
|
+
return () => cancelAnimationFrame(raf);
|
|
86
|
+
}, [data]);
|
|
87
|
+
useLayoutEffect(() => {
|
|
88
|
+
if (!tooltipState || !chartRef.current || !tooltipRef.current) return;
|
|
89
|
+
const chartRect = chartRef.current.getBoundingClientRect();
|
|
90
|
+
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
91
|
+
const chartWidth = chartRect.width;
|
|
92
|
+
const tooltipWidth = tooltipRect.width;
|
|
93
|
+
let left = tooltipState.x - tooltipWidth / 2;
|
|
94
|
+
const padding = 8;
|
|
95
|
+
if (left < padding) {
|
|
96
|
+
left = padding;
|
|
97
|
+
} else if (left + tooltipWidth > chartWidth - padding) {
|
|
98
|
+
left = chartWidth - tooltipWidth - padding;
|
|
99
|
+
}
|
|
100
|
+
setTooltipLeft(left);
|
|
101
|
+
}, [tooltipState]);
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", { ref: chartRef, className: slots.base({ class: classNames == null ? void 0 : classNames.base }), onMouseLeave: handleMouseLeave, children: [
|
|
103
|
+
label && /* @__PURE__ */ jsx("p", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label }),
|
|
104
|
+
/* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 140, children: /* @__PURE__ */ jsxs(
|
|
105
|
+
BarChart,
|
|
106
|
+
{
|
|
107
|
+
data,
|
|
108
|
+
margin: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
109
|
+
barSize: 10,
|
|
110
|
+
barGap,
|
|
111
|
+
className: "[&_.recharts-surface]:outline-none [&_.recharts-surface]:focus:outline-none",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
CartesianGrid,
|
|
115
|
+
{
|
|
116
|
+
vertical: true,
|
|
117
|
+
horizontal: false,
|
|
118
|
+
strokeDasharray: "4 4",
|
|
119
|
+
className: "stroke-neutral-light",
|
|
120
|
+
verticalPoints: tickPositions
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
CartesianGrid,
|
|
125
|
+
{
|
|
126
|
+
vertical: true,
|
|
127
|
+
horizontal: false,
|
|
128
|
+
strokeDasharray: "0",
|
|
129
|
+
strokeWidth: 2,
|
|
130
|
+
className: "stroke-neutral-light",
|
|
131
|
+
verticalPoints: [0]
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
XAxis,
|
|
136
|
+
{
|
|
137
|
+
dataKey: "title",
|
|
138
|
+
axisLine: { stroke: "#DFE2E7", strokeWidth: 1 },
|
|
139
|
+
tickLine: false,
|
|
140
|
+
tick: CustomTick,
|
|
141
|
+
padding: { left: 0, right: 0 }
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ jsx(YAxis, { hide: true, ticks: yAxisTicks, domain: yAxisDomain }),
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
Bar,
|
|
147
|
+
{
|
|
148
|
+
dataKey: "value",
|
|
149
|
+
fill: "#C7E5FA",
|
|
150
|
+
shape: CustomBarShape,
|
|
151
|
+
onMouseEnter: handleMouseEnter,
|
|
152
|
+
onMouseLeave: handleMouseLeave
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
) }),
|
|
158
|
+
tooltipFormatter && /* @__PURE__ */ jsx(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
ref: tooltipRef,
|
|
162
|
+
style: {
|
|
163
|
+
position: "absolute",
|
|
164
|
+
left: tooltipLeft + 5,
|
|
165
|
+
top: (tooltipState == null ? void 0 : tooltipState.y) ? tooltipState.y - 20 : 0,
|
|
166
|
+
pointerEvents: "none",
|
|
167
|
+
zIndex: 10,
|
|
168
|
+
opacity: tooltipState ? 1 : 0,
|
|
169
|
+
transition: "opacity 0.1s ease-out",
|
|
170
|
+
visibility: tooltipState ? "visible" : "hidden",
|
|
171
|
+
width: "fit-content",
|
|
172
|
+
whiteSpace: "nowrap"
|
|
173
|
+
},
|
|
174
|
+
children: tooltipState && tooltipFormatter(tooltipState)
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
] });
|
|
178
|
+
});
|
|
179
|
+
SimpleBarChartComponent.displayName = "simpleBarChart";
|
|
180
|
+
var simpleBarChart_default = SimpleBarChartComponent;
|
|
181
|
+
var simpleBarChartStyle = tv({
|
|
182
|
+
slots: {
|
|
183
|
+
base: ["flex", "flex-col", "gap-[10px]", "select-none", "relative", "w-full"],
|
|
184
|
+
label: ["text-md", "font-bold", "text-common-black"]
|
|
185
|
+
},
|
|
186
|
+
variants: {},
|
|
187
|
+
defaultVariants: {}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
simpleBarChart_default
|
|
192
|
+
};
|
|
@@ -145,7 +145,7 @@ var BarChartComponent = forwardRef((originalProps, ref) => {
|
|
|
145
145
|
{
|
|
146
146
|
vertical: true,
|
|
147
147
|
horizontal: false,
|
|
148
|
-
strokeDasharray: "
|
|
148
|
+
strokeDasharray: "4 4",
|
|
149
149
|
className: "stroke-neutral-light",
|
|
150
150
|
verticalPoints: tickPositions
|
|
151
151
|
}
|
|
@@ -234,8 +234,14 @@ var barChartStyle = tv({
|
|
|
234
234
|
variants: {},
|
|
235
235
|
defaultVariants: {}
|
|
236
236
|
});
|
|
237
|
-
function BarChartTooltip({ children }) {
|
|
238
|
-
return /* @__PURE__ */ jsx(
|
|
237
|
+
function BarChartTooltip({ className = "", children }) {
|
|
238
|
+
return /* @__PURE__ */ jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
className: `text-md text-common-white bg-common-black flex max-w-[160px] whitespace-nowrap rounded-[5px] px-[10px] py-[6px] text-center font-bold ${className}`,
|
|
242
|
+
children
|
|
243
|
+
}
|
|
244
|
+
);
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
export {
|
|
@@ -558,7 +558,7 @@ var AreaChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
|
|
|
558
558
|
{
|
|
559
559
|
vertical: true,
|
|
560
560
|
horizontal: false,
|
|
561
|
-
strokeDasharray: "
|
|
561
|
+
strokeDasharray: "4 4",
|
|
562
562
|
className: "stroke-neutral-light",
|
|
563
563
|
verticalPoints: tickPositions
|
|
564
564
|
}
|
|
@@ -41,8 +41,10 @@ declare const barChartStyle: tailwind_variants.TVReturnType<{}, {
|
|
|
41
41
|
}, undefined, unknown, unknown, undefined>>;
|
|
42
42
|
type barChartVariantProps = VariantProps<typeof barChartStyle>;
|
|
43
43
|
type barChartSlots = keyof ReturnType<typeof barChartStyle>;
|
|
44
|
-
|
|
44
|
+
type BarChartTooltipProps = {
|
|
45
|
+
className?: string;
|
|
45
46
|
children: ReactNode;
|
|
46
|
-
}
|
|
47
|
+
};
|
|
48
|
+
declare function BarChartTooltip({ className, children }: BarChartTooltipProps): react_jsx_runtime.JSX.Element;
|
|
47
49
|
|
|
48
50
|
export { BarChartTooltip, type barChartProps, BarChartComponent as default };
|
|
@@ -41,8 +41,10 @@ declare const barChartStyle: tailwind_variants.TVReturnType<{}, {
|
|
|
41
41
|
}, undefined, unknown, unknown, undefined>>;
|
|
42
42
|
type barChartVariantProps = VariantProps<typeof barChartStyle>;
|
|
43
43
|
type barChartSlots = keyof ReturnType<typeof barChartStyle>;
|
|
44
|
-
|
|
44
|
+
type BarChartTooltipProps = {
|
|
45
|
+
className?: string;
|
|
45
46
|
children: ReactNode;
|
|
46
|
-
}
|
|
47
|
+
};
|
|
48
|
+
declare function BarChartTooltip({ className, children }: BarChartTooltipProps): react_jsx_runtime.JSX.Element;
|
|
47
49
|
|
|
48
50
|
export { BarChartTooltip, type barChartProps, BarChartComponent as default };
|
|
@@ -513,7 +513,7 @@ var BarChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
|
|
|
513
513
|
{
|
|
514
514
|
vertical: true,
|
|
515
515
|
horizontal: false,
|
|
516
|
-
strokeDasharray: "
|
|
516
|
+
strokeDasharray: "4 4",
|
|
517
517
|
className: "stroke-neutral-light",
|
|
518
518
|
verticalPoints: tickPositions
|
|
519
519
|
}
|
|
@@ -602,8 +602,14 @@ var barChartStyle = tv({
|
|
|
602
602
|
variants: {},
|
|
603
603
|
defaultVariants: {}
|
|
604
604
|
});
|
|
605
|
-
function BarChartTooltip({ children }) {
|
|
606
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
605
|
+
function BarChartTooltip({ className = "", children }) {
|
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
607
|
+
"div",
|
|
608
|
+
{
|
|
609
|
+
className: `text-md text-common-white bg-common-black flex max-w-[160px] whitespace-nowrap rounded-[5px] px-[10px] py-[6px] text-center font-bold ${className}`,
|
|
610
|
+
children
|
|
611
|
+
}
|
|
612
|
+
);
|
|
607
613
|
}
|
|
608
614
|
// Annotate the CommonJS export names for ESM import in node:
|
|
609
615
|
0 && (module.exports = {
|
|
@@ -2,6 +2,7 @@ export { default as CircularProgress } from './circularProgress.mjs';
|
|
|
2
2
|
export { default as AreaChart } from './areaChart.mjs';
|
|
3
3
|
export { default as BarChart, BarChartTooltip } from './barChart.mjs';
|
|
4
4
|
export { default as RadarChart } from './radarChart.mjs';
|
|
5
|
+
export { default as SimpleBarChart } from './simpleBarChart.mjs';
|
|
5
6
|
import 'tailwind-variants';
|
|
6
7
|
import 'react';
|
|
7
8
|
import '../../utils/types.mjs';
|
|
@@ -2,6 +2,7 @@ export { default as CircularProgress } from './circularProgress.js';
|
|
|
2
2
|
export { default as AreaChart } from './areaChart.js';
|
|
3
3
|
export { default as BarChart, BarChartTooltip } from './barChart.js';
|
|
4
4
|
export { default as RadarChart } from './radarChart.js';
|
|
5
|
+
export { default as SimpleBarChart } from './simpleBarChart.js';
|
|
5
6
|
import 'tailwind-variants';
|
|
6
7
|
import 'react';
|
|
7
8
|
import '../../utils/types.js';
|
|
@@ -106,7 +106,8 @@ __export(charts_exports, {
|
|
|
106
106
|
BarChart: () => barChart_default,
|
|
107
107
|
BarChartTooltip: () => BarChartTooltip,
|
|
108
108
|
CircularProgress: () => circularProgress_default,
|
|
109
|
-
RadarChart: () => radarChart_default
|
|
109
|
+
RadarChart: () => radarChart_default,
|
|
110
|
+
SimpleBarChart: () => simpleBarChart_default
|
|
110
111
|
});
|
|
111
112
|
module.exports = __toCommonJS(charts_exports);
|
|
112
113
|
|
|
@@ -715,7 +716,7 @@ var AreaChartComponent = (0, import_react2.forwardRef)((originalProps, ref) => {
|
|
|
715
716
|
{
|
|
716
717
|
vertical: true,
|
|
717
718
|
horizontal: false,
|
|
718
|
-
strokeDasharray: "
|
|
719
|
+
strokeDasharray: "4 4",
|
|
719
720
|
className: "stroke-neutral-light",
|
|
720
721
|
verticalPoints: tickPositions
|
|
721
722
|
}
|
|
@@ -932,7 +933,7 @@ var BarChartComponent = (0, import_react3.forwardRef)((originalProps, ref) => {
|
|
|
932
933
|
{
|
|
933
934
|
vertical: true,
|
|
934
935
|
horizontal: false,
|
|
935
|
-
strokeDasharray: "
|
|
936
|
+
strokeDasharray: "4 4",
|
|
936
937
|
className: "stroke-neutral-light",
|
|
937
938
|
verticalPoints: tickPositions
|
|
938
939
|
}
|
|
@@ -1021,8 +1022,14 @@ var barChartStyle = tv({
|
|
|
1021
1022
|
variants: {},
|
|
1022
1023
|
defaultVariants: {}
|
|
1023
1024
|
});
|
|
1024
|
-
function BarChartTooltip({ children }) {
|
|
1025
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1025
|
+
function BarChartTooltip({ className = "", children }) {
|
|
1026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1027
|
+
"div",
|
|
1028
|
+
{
|
|
1029
|
+
className: `text-md text-common-white bg-common-black flex max-w-[160px] whitespace-nowrap rounded-[5px] px-[10px] py-[6px] text-center font-bold ${className}`,
|
|
1030
|
+
children
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1026
1033
|
}
|
|
1027
1034
|
|
|
1028
1035
|
// src/components/charts/radarChart.tsx
|
|
@@ -1128,11 +1135,193 @@ var radarChartStyle = tv({
|
|
|
1128
1135
|
color: "primary"
|
|
1129
1136
|
}
|
|
1130
1137
|
});
|
|
1138
|
+
|
|
1139
|
+
// src/components/charts/simpleBarChart.tsx
|
|
1140
|
+
var import_react5 = require("react");
|
|
1141
|
+
var import_recharts5 = require("recharts");
|
|
1142
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1143
|
+
var SimpleBarChartComponent = (0, import_react5.forwardRef)((originalProps, ref) => {
|
|
1144
|
+
const [props, variantProps] = mapPropsVariants(originalProps, simpleBarChartStyle.variantKeys);
|
|
1145
|
+
const {
|
|
1146
|
+
data = [],
|
|
1147
|
+
label,
|
|
1148
|
+
classNames,
|
|
1149
|
+
yAxisTicks = [0, 20, 40, 60, 80, 100],
|
|
1150
|
+
yAxisDomain = [0, 100],
|
|
1151
|
+
barGap = 20,
|
|
1152
|
+
tooltipFormatter
|
|
1153
|
+
} = { ...props, ...variantProps };
|
|
1154
|
+
const slots = (0, import_react5.useMemo)(() => simpleBarChartStyle({ ...variantProps }), [variantProps]);
|
|
1155
|
+
const chartRef = (0, import_react5.useRef)(null);
|
|
1156
|
+
const tooltipRef = (0, import_react5.useRef)(null);
|
|
1157
|
+
const [tooltipLeft, setTooltipLeft] = (0, import_react5.useState)(0);
|
|
1158
|
+
const [tickPositions, setTickPositions] = (0, import_react5.useState)([]);
|
|
1159
|
+
const tickRef = (0, import_react5.useRef)([]);
|
|
1160
|
+
const [tooltipState, setTooltipState] = (0, import_react5.useState)(null);
|
|
1161
|
+
const handleMouseEnter = (e) => {
|
|
1162
|
+
if (!tooltipFormatter || !chartRef.current) return;
|
|
1163
|
+
const { payload, x, y } = e;
|
|
1164
|
+
if (!payload) return;
|
|
1165
|
+
setTooltipState({
|
|
1166
|
+
x,
|
|
1167
|
+
y,
|
|
1168
|
+
value: payload.value,
|
|
1169
|
+
label: payload.title
|
|
1170
|
+
});
|
|
1171
|
+
};
|
|
1172
|
+
const handleMouseLeave = () => {
|
|
1173
|
+
setTooltipState(null);
|
|
1174
|
+
};
|
|
1175
|
+
const CustomBarShape = ({ x, y, width, height, fill }) => {
|
|
1176
|
+
const radius = 4;
|
|
1177
|
+
const extraHeight = 10;
|
|
1178
|
+
const adjustedHeight = height + extraHeight;
|
|
1179
|
+
const adjustedY = y - extraHeight;
|
|
1180
|
+
const bottomY = adjustedY + adjustedHeight;
|
|
1181
|
+
return height > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1182
|
+
"path",
|
|
1183
|
+
{
|
|
1184
|
+
d: `M${x},${bottomY} L${x},${adjustedY + radius} Q${x},${adjustedY} ${x + radius},${adjustedY} L${x + width - radius},${adjustedY} Q${x + width},${adjustedY} ${x + width},${adjustedY + radius} L${x + width},${bottomY} Z`,
|
|
1185
|
+
fill
|
|
1186
|
+
}
|
|
1187
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("rect", { x, y, width, height: 0, fill });
|
|
1188
|
+
};
|
|
1189
|
+
const CustomTick = ({ x, y, payload }) => {
|
|
1190
|
+
if (x !== void 0) tickRef.current.push(x);
|
|
1191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1192
|
+
"text",
|
|
1193
|
+
{
|
|
1194
|
+
x,
|
|
1195
|
+
y: y + 14,
|
|
1196
|
+
textAnchor: "middle",
|
|
1197
|
+
fontSize: 12,
|
|
1198
|
+
fontWeight: 700,
|
|
1199
|
+
fill: "currentColor",
|
|
1200
|
+
className: "text-body-foreground",
|
|
1201
|
+
children: payload.value
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
};
|
|
1205
|
+
(0, import_react5.useEffect)(() => {
|
|
1206
|
+
const raf = requestAnimationFrame(() => {
|
|
1207
|
+
const unique = [...new Set(tickRef.current)].sort((a, b) => a - b);
|
|
1208
|
+
const mids = [];
|
|
1209
|
+
for (let i = 0; i < unique.length - 1; i++) {
|
|
1210
|
+
mids.push((unique[i] + unique[i + 1]) / 2);
|
|
1211
|
+
}
|
|
1212
|
+
setTickPositions(mids);
|
|
1213
|
+
tickRef.current = [];
|
|
1214
|
+
});
|
|
1215
|
+
return () => cancelAnimationFrame(raf);
|
|
1216
|
+
}, [data]);
|
|
1217
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
1218
|
+
if (!tooltipState || !chartRef.current || !tooltipRef.current) return;
|
|
1219
|
+
const chartRect = chartRef.current.getBoundingClientRect();
|
|
1220
|
+
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
1221
|
+
const chartWidth = chartRect.width;
|
|
1222
|
+
const tooltipWidth = tooltipRect.width;
|
|
1223
|
+
let left = tooltipState.x - tooltipWidth / 2;
|
|
1224
|
+
const padding2 = 8;
|
|
1225
|
+
if (left < padding2) {
|
|
1226
|
+
left = padding2;
|
|
1227
|
+
} else if (left + tooltipWidth > chartWidth - padding2) {
|
|
1228
|
+
left = chartWidth - tooltipWidth - padding2;
|
|
1229
|
+
}
|
|
1230
|
+
setTooltipLeft(left);
|
|
1231
|
+
}, [tooltipState]);
|
|
1232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: chartRef, className: slots.base({ class: classNames == null ? void 0 : classNames.base }), onMouseLeave: handleMouseLeave, children: [
|
|
1233
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label }),
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_recharts5.ResponsiveContainer, { width: "100%", height: 140, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1235
|
+
import_recharts5.BarChart,
|
|
1236
|
+
{
|
|
1237
|
+
data,
|
|
1238
|
+
margin: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
1239
|
+
barSize: 10,
|
|
1240
|
+
barGap,
|
|
1241
|
+
className: "[&_.recharts-surface]:outline-none [&_.recharts-surface]:focus:outline-none",
|
|
1242
|
+
children: [
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1244
|
+
import_recharts5.CartesianGrid,
|
|
1245
|
+
{
|
|
1246
|
+
vertical: true,
|
|
1247
|
+
horizontal: false,
|
|
1248
|
+
strokeDasharray: "4 4",
|
|
1249
|
+
className: "stroke-neutral-light",
|
|
1250
|
+
verticalPoints: tickPositions
|
|
1251
|
+
}
|
|
1252
|
+
),
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1254
|
+
import_recharts5.CartesianGrid,
|
|
1255
|
+
{
|
|
1256
|
+
vertical: true,
|
|
1257
|
+
horizontal: false,
|
|
1258
|
+
strokeDasharray: "0",
|
|
1259
|
+
strokeWidth: 2,
|
|
1260
|
+
className: "stroke-neutral-light",
|
|
1261
|
+
verticalPoints: [0]
|
|
1262
|
+
}
|
|
1263
|
+
),
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1265
|
+
import_recharts5.XAxis,
|
|
1266
|
+
{
|
|
1267
|
+
dataKey: "title",
|
|
1268
|
+
axisLine: { stroke: "#DFE2E7", strokeWidth: 1 },
|
|
1269
|
+
tickLine: false,
|
|
1270
|
+
tick: CustomTick,
|
|
1271
|
+
padding: { left: 0, right: 0 }
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_recharts5.YAxis, { hide: true, ticks: yAxisTicks, domain: yAxisDomain }),
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1276
|
+
import_recharts5.Bar,
|
|
1277
|
+
{
|
|
1278
|
+
dataKey: "value",
|
|
1279
|
+
fill: "#C7E5FA",
|
|
1280
|
+
shape: CustomBarShape,
|
|
1281
|
+
onMouseEnter: handleMouseEnter,
|
|
1282
|
+
onMouseLeave: handleMouseLeave
|
|
1283
|
+
}
|
|
1284
|
+
)
|
|
1285
|
+
]
|
|
1286
|
+
}
|
|
1287
|
+
) }),
|
|
1288
|
+
tooltipFormatter && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1289
|
+
"div",
|
|
1290
|
+
{
|
|
1291
|
+
ref: tooltipRef,
|
|
1292
|
+
style: {
|
|
1293
|
+
position: "absolute",
|
|
1294
|
+
left: tooltipLeft + 5,
|
|
1295
|
+
top: (tooltipState == null ? void 0 : tooltipState.y) ? tooltipState.y - 20 : 0,
|
|
1296
|
+
pointerEvents: "none",
|
|
1297
|
+
zIndex: 10,
|
|
1298
|
+
opacity: tooltipState ? 1 : 0,
|
|
1299
|
+
transition: "opacity 0.1s ease-out",
|
|
1300
|
+
visibility: tooltipState ? "visible" : "hidden",
|
|
1301
|
+
width: "fit-content",
|
|
1302
|
+
whiteSpace: "nowrap"
|
|
1303
|
+
},
|
|
1304
|
+
children: tooltipState && tooltipFormatter(tooltipState)
|
|
1305
|
+
}
|
|
1306
|
+
)
|
|
1307
|
+
] });
|
|
1308
|
+
});
|
|
1309
|
+
SimpleBarChartComponent.displayName = "simpleBarChart";
|
|
1310
|
+
var simpleBarChart_default = SimpleBarChartComponent;
|
|
1311
|
+
var simpleBarChartStyle = tv({
|
|
1312
|
+
slots: {
|
|
1313
|
+
base: ["flex", "flex-col", "gap-[10px]", "select-none", "relative", "w-full"],
|
|
1314
|
+
label: ["text-md", "font-bold", "text-common-black"]
|
|
1315
|
+
},
|
|
1316
|
+
variants: {},
|
|
1317
|
+
defaultVariants: {}
|
|
1318
|
+
});
|
|
1131
1319
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1132
1320
|
0 && (module.exports = {
|
|
1133
1321
|
AreaChart,
|
|
1134
1322
|
BarChart,
|
|
1135
1323
|
BarChartTooltip,
|
|
1136
1324
|
CircularProgress,
|
|
1137
|
-
RadarChart
|
|
1325
|
+
RadarChart,
|
|
1326
|
+
SimpleBarChart
|
|
1138
1327
|
});
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "../../chunk-
|
|
2
|
+
import "../../chunk-3OCNT22V.mjs";
|
|
3
3
|
import {
|
|
4
4
|
areaChart_default
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-LH6Z7SDZ.mjs";
|
|
6
6
|
import "../../chunk-DQRAFUDA.mjs";
|
|
7
7
|
import "../../chunk-EWS3FESG.mjs";
|
|
8
8
|
import {
|
|
9
9
|
BarChartTooltip,
|
|
10
10
|
barChart_default
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-JOK735WN.mjs";
|
|
12
12
|
import {
|
|
13
13
|
circularProgress_default
|
|
14
14
|
} from "../../chunk-WA7CSZQ3.mjs";
|
|
15
15
|
import {
|
|
16
16
|
radarChart_default
|
|
17
17
|
} from "../../chunk-U7SYKG2C.mjs";
|
|
18
|
+
import {
|
|
19
|
+
simpleBarChart_default
|
|
20
|
+
} from "../../chunk-B4UNRT7U.mjs";
|
|
18
21
|
import "../../chunk-E3G5QXSH.mjs";
|
|
19
22
|
import "../../chunk-U4DJHAM5.mjs";
|
|
20
23
|
import "../../chunk-27Y6K5NK.mjs";
|
|
@@ -24,5 +27,6 @@ export {
|
|
|
24
27
|
barChart_default as BarChart,
|
|
25
28
|
BarChartTooltip,
|
|
26
29
|
circularProgress_default as CircularProgress,
|
|
27
|
-
radarChart_default as RadarChart
|
|
30
|
+
radarChart_default as RadarChart,
|
|
31
|
+
simpleBarChart_default as SimpleBarChart
|
|
28
32
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { SlotsToClasses } from '../../utils/types.mjs';
|
|
6
|
+
|
|
7
|
+
type SimpleBarData = {
|
|
8
|
+
title: string;
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
type TooltipFormatterParams = {
|
|
12
|
+
value: number;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
type Props = {
|
|
16
|
+
data?: SimpleBarData[];
|
|
17
|
+
label?: string;
|
|
18
|
+
classNames?: SlotsToClasses<simpleBarChartSlots>;
|
|
19
|
+
yAxisTicks?: number[];
|
|
20
|
+
yAxisDomain?: [number, number];
|
|
21
|
+
barGap?: number;
|
|
22
|
+
tooltipFormatter?: (params: TooltipFormatterParams) => ReactNode;
|
|
23
|
+
};
|
|
24
|
+
type simpleBarChartProps = Props & simpleBarChartVariantProps;
|
|
25
|
+
declare const SimpleBarChartComponent: react.ForwardRefExoticComponent<Props & simpleBarChartVariantProps & react.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
|
|
27
|
+
declare const simpleBarChartStyle: tailwind_variants.TVReturnType<{}, {
|
|
28
|
+
base: string[];
|
|
29
|
+
label: string[];
|
|
30
|
+
}, undefined, {}, {
|
|
31
|
+
base: string[];
|
|
32
|
+
label: string[];
|
|
33
|
+
}, tailwind_variants.TVReturnType<{}, {
|
|
34
|
+
base: string[];
|
|
35
|
+
label: string[];
|
|
36
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
37
|
+
type simpleBarChartVariantProps = VariantProps<typeof simpleBarChartStyle>;
|
|
38
|
+
type simpleBarChartSlots = keyof ReturnType<typeof simpleBarChartStyle>;
|
|
39
|
+
|
|
40
|
+
export { SimpleBarChartComponent as default, type simpleBarChartProps };
|