@wealthx/shadcn 1.0.1 → 1.1.0
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 +154 -135
- package/CHANGELOG.md +12 -0
- package/README.md +82 -0
- package/dist/chunk-3EQP72AW.mjs +58 -0
- package/dist/{chunk-2WZVSBAY.mjs → chunk-3NQGYJEZ.mjs} +1 -1
- package/dist/{chunk-ZN2QKLF6.mjs → chunk-46OFHMQA.mjs} +1 -1
- package/dist/{chunk-IAOOZCUY.mjs → chunk-4AJ5HWHD.mjs} +4 -1
- package/dist/chunk-5JGQAAQV.mjs +212 -0
- package/dist/{chunk-MKFL5MNH.mjs → chunk-CJ46PDXE.mjs} +6 -6
- package/dist/{chunk-7LDIMXGM.mjs → chunk-DKZRJOMF.mjs} +1 -1
- package/dist/{chunk-AMJ23O53.mjs → chunk-FHNT55I5.mjs} +2 -2
- package/dist/chunk-GLW2UO6O.mjs +212 -0
- package/dist/{chunk-NGYG2EA6.mjs → chunk-I64K754C.mjs} +1 -1
- package/dist/chunk-K74JRTJR.mjs +105 -0
- package/dist/{chunk-NWZ46DJL.mjs → chunk-KQDD5MU3.mjs} +1 -1
- package/dist/chunk-RN67642N.mjs +171 -0
- package/dist/chunk-UEL4RD5P.mjs +272 -0
- package/dist/chunk-YBXCIF5Q.mjs +198 -0
- package/dist/components/ui/alert-dialog.js +4 -1
- package/dist/components/ui/alert-dialog.mjs +2 -2
- package/dist/components/ui/button.js +4 -1
- package/dist/components/ui/button.mjs +1 -1
- package/dist/components/ui/calendar.js +4 -1
- package/dist/components/ui/calendar.mjs +2 -2
- package/dist/components/ui/cashflow-bar-chart.js +596 -0
- package/dist/components/ui/cashflow-bar-chart.mjs +16 -0
- package/dist/components/ui/combobox.js +261 -0
- package/dist/components/ui/combobox.mjs +28 -0
- package/dist/components/ui/data-table.js +4 -1
- package/dist/components/ui/data-table.mjs +4 -4
- package/dist/components/ui/date-picker.js +4 -1
- package/dist/components/ui/date-picker.mjs +3 -3
- package/dist/components/ui/dialog.js +4 -1
- package/dist/components/ui/dialog.mjs +2 -2
- package/dist/components/ui/expense-bar-chart.js +543 -0
- package/dist/components/ui/expense-bar-chart.mjs +16 -0
- package/dist/components/ui/field.mjs +2 -2
- package/dist/components/ui/income-bar-chart.js +543 -0
- package/dist/components/ui/income-bar-chart.mjs +16 -0
- package/dist/components/ui/input-group.js +4 -1
- package/dist/components/ui/input-group.mjs +2 -2
- package/dist/components/ui/pagination.js +4 -1
- package/dist/components/ui/pagination.mjs +2 -2
- package/dist/components/ui/slider.js +166 -0
- package/dist/components/ui/slider.mjs +8 -0
- package/dist/components/ui/transactions-income-expense-bar-chart.js +478 -0
- package/dist/components/ui/transactions-income-expense-bar-chart.mjs +16 -0
- package/dist/index.js +1757 -698
- package/dist/index.mjs +160 -115
- package/dist/styles.css +1 -1
- package/package.json +35 -2
- package/src/components/index.tsx +59 -0
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/cashflow-bar-chart.tsx +336 -0
- package/src/components/ui/chart-shared.tsx +100 -0
- package/src/components/ui/combobox.tsx +217 -0
- package/src/components/ui/expense-bar-chart.tsx +278 -0
- package/src/components/ui/income-bar-chart.tsx +278 -0
- package/src/components/ui/slider.tsx +107 -0
- package/src/components/ui/transactions-income-expense-bar-chart.tsx +198 -0
- package/src/styles/styles-css.ts +1 -1
- package/tsup.config.ts +6 -0
- package/dist/{chunk-HUVTPUV2.mjs → chunk-NLLKTU4B.mjs} +3 -3
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHART_PERIODS,
|
|
3
|
+
CHART_SLICE_COUNT,
|
|
4
|
+
ChartLegendItem,
|
|
5
|
+
ChartPeriodButton,
|
|
6
|
+
DATASET_ALPHAS,
|
|
7
|
+
FALLBACK_TICK,
|
|
8
|
+
formatTooltipDate,
|
|
9
|
+
hexToRgba
|
|
10
|
+
} from "./chunk-3EQP72AW.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Skeleton
|
|
13
|
+
} from "./chunk-HS7TFG7V.mjs";
|
|
14
|
+
import {
|
|
15
|
+
Empty,
|
|
16
|
+
EmptyDescription
|
|
17
|
+
} from "./chunk-YN5SYTOO.mjs";
|
|
18
|
+
import {
|
|
19
|
+
Card,
|
|
20
|
+
CardAction,
|
|
21
|
+
CardContent,
|
|
22
|
+
CardHeader,
|
|
23
|
+
CardTitle
|
|
24
|
+
} from "./chunk-SLWCCURD.mjs";
|
|
25
|
+
import {
|
|
26
|
+
useThemeVars
|
|
27
|
+
} from "./chunk-OXQQNQZI.mjs";
|
|
28
|
+
import {
|
|
29
|
+
cn
|
|
30
|
+
} from "./chunk-V7CNWJT3.mjs";
|
|
31
|
+
import {
|
|
32
|
+
__spreadProps,
|
|
33
|
+
__spreadValues
|
|
34
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
35
|
+
|
|
36
|
+
// src/components/ui/expense-bar-chart.tsx
|
|
37
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
38
|
+
import {
|
|
39
|
+
Chart as ChartJS,
|
|
40
|
+
CategoryScale,
|
|
41
|
+
LinearScale,
|
|
42
|
+
BarElement,
|
|
43
|
+
Tooltip,
|
|
44
|
+
Legend
|
|
45
|
+
} from "chart.js";
|
|
46
|
+
import { Chart } from "react-chartjs-2";
|
|
47
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
48
|
+
ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
|
|
49
|
+
var FALLBACK_SECONDARY = "#162029";
|
|
50
|
+
function ExpenseBarChart({
|
|
51
|
+
expenseData,
|
|
52
|
+
title = "Expenses",
|
|
53
|
+
showLegend = true,
|
|
54
|
+
showXAxis = true,
|
|
55
|
+
showYAxis = true,
|
|
56
|
+
legendPosition = "top",
|
|
57
|
+
defaultPeriod = 6,
|
|
58
|
+
granularity = "monthly",
|
|
59
|
+
height = 280,
|
|
60
|
+
width = "100%",
|
|
61
|
+
className,
|
|
62
|
+
isLoading = false
|
|
63
|
+
}) {
|
|
64
|
+
const periods = CHART_PERIODS[granularity];
|
|
65
|
+
const [period, setPeriod] = useState(defaultPeriod);
|
|
66
|
+
const isFirstRender = useRef(true);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (isFirstRender.current) {
|
|
69
|
+
isFirstRender.current = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setPeriod(CHART_PERIODS[granularity][0]);
|
|
73
|
+
}, [granularity]);
|
|
74
|
+
const themeVars = useThemeVars();
|
|
75
|
+
const brandSecondary = themeVars["--theme-secondary"] || FALLBACK_SECONDARY;
|
|
76
|
+
const sliced = useMemo(() => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
if (!((_a = expenseData == null ? void 0 : expenseData.months) == null ? void 0 : _a.length) || !expenseData.datasets.length) return null;
|
|
79
|
+
const count = Math.min(CHART_SLICE_COUNT[granularity][period], expenseData.months.length);
|
|
80
|
+
const start = expenseData.months.length - count;
|
|
81
|
+
return {
|
|
82
|
+
months: expenseData.months.slice(start),
|
|
83
|
+
dates: (_b = expenseData.dates) == null ? void 0 : _b.slice(start),
|
|
84
|
+
datasets: expenseData.datasets.map((ds) => __spreadProps(__spreadValues({}, ds), {
|
|
85
|
+
data: ds.data.slice(start)
|
|
86
|
+
}))
|
|
87
|
+
};
|
|
88
|
+
}, [expenseData, period, granularity]);
|
|
89
|
+
const datasetColors = useMemo(
|
|
90
|
+
() => {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = sliced == null ? void 0 : sliced.datasets.map(
|
|
93
|
+
(_, i) => hexToRgba(brandSecondary, DATASET_ALPHAS[i % DATASET_ALPHAS.length])
|
|
94
|
+
)) != null ? _a : [];
|
|
95
|
+
},
|
|
96
|
+
[sliced, brandSecondary]
|
|
97
|
+
);
|
|
98
|
+
const chartData = useMemo(() => {
|
|
99
|
+
if (!sliced) return { labels: [], datasets: [] };
|
|
100
|
+
return {
|
|
101
|
+
labels: sliced.months,
|
|
102
|
+
datasets: sliced.datasets.map((ds, i) => ({
|
|
103
|
+
label: ds.label,
|
|
104
|
+
data: ds.data,
|
|
105
|
+
backgroundColor: datasetColors[i],
|
|
106
|
+
hoverBackgroundColor: hexToRgba(
|
|
107
|
+
brandSecondary,
|
|
108
|
+
Math.min(DATASET_ALPHAS[i % DATASET_ALPHAS.length] + 0.15, 1)
|
|
109
|
+
),
|
|
110
|
+
borderWidth: 0,
|
|
111
|
+
borderRadius: 0,
|
|
112
|
+
borderSkipped: false,
|
|
113
|
+
barPercentage: 0.75,
|
|
114
|
+
categoryPercentage: 0.7,
|
|
115
|
+
stack: "expense"
|
|
116
|
+
}))
|
|
117
|
+
};
|
|
118
|
+
}, [sliced, datasetColors, brandSecondary]);
|
|
119
|
+
const options = useMemo(() => ({
|
|
120
|
+
responsive: true,
|
|
121
|
+
maintainAspectRatio: false,
|
|
122
|
+
animation: { duration: 800, easing: "easeOutQuart" },
|
|
123
|
+
layout: { padding: 0 },
|
|
124
|
+
plugins: {
|
|
125
|
+
legend: { display: false },
|
|
126
|
+
tooltip: {
|
|
127
|
+
mode: "index",
|
|
128
|
+
intersect: false,
|
|
129
|
+
padding: 12,
|
|
130
|
+
cornerRadius: 0,
|
|
131
|
+
titleFont: { size: 11, weight: "600" },
|
|
132
|
+
bodyFont: { size: 12, weight: "500" },
|
|
133
|
+
callbacks: {
|
|
134
|
+
title: (tooltipItems) => {
|
|
135
|
+
var _a, _b, _c, _d;
|
|
136
|
+
const idx = (_a = tooltipItems[0]) == null ? void 0 : _a.dataIndex;
|
|
137
|
+
if (idx != null && ((_b = sliced == null ? void 0 : sliced.dates) == null ? void 0 : _b[idx])) {
|
|
138
|
+
return formatTooltipDate(sliced.dates[idx], granularity);
|
|
139
|
+
}
|
|
140
|
+
return (_d = (_c = tooltipItems[0]) == null ? void 0 : _c.label) != null ? _d : "";
|
|
141
|
+
},
|
|
142
|
+
label: (ctx) => {
|
|
143
|
+
const val = ctx.raw;
|
|
144
|
+
if (val === 0) return null;
|
|
145
|
+
return ` ${ctx.dataset.label}: $${val.toLocaleString()}`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
scales: {
|
|
151
|
+
x: {
|
|
152
|
+
display: showXAxis,
|
|
153
|
+
stacked: true,
|
|
154
|
+
grid: { display: false },
|
|
155
|
+
border: { display: false },
|
|
156
|
+
ticks: { font: { size: 10 }, color: FALLBACK_TICK }
|
|
157
|
+
},
|
|
158
|
+
y: {
|
|
159
|
+
display: showYAxis,
|
|
160
|
+
stacked: true,
|
|
161
|
+
grid: { display: false },
|
|
162
|
+
border: { display: false },
|
|
163
|
+
ticks: {
|
|
164
|
+
font: { size: 10 },
|
|
165
|
+
color: FALLBACK_TICK,
|
|
166
|
+
maxTicksLimit: 5,
|
|
167
|
+
padding: 8,
|
|
168
|
+
callback: (v) => `$${Number(v).toLocaleString()}`
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}), [showXAxis, showYAxis, sliced, granularity]);
|
|
173
|
+
return /* @__PURE__ */ jsxs(
|
|
174
|
+
Card,
|
|
175
|
+
{
|
|
176
|
+
className: cn("w-full py-4 sm:py-6 gap-2", className),
|
|
177
|
+
style: { maxWidth: width },
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsxs(CardHeader, { className: "px-3 sm:px-6", children: [
|
|
180
|
+
/* @__PURE__ */ jsx(CardTitle, { className: "text-sm sm:text-base", children: title }),
|
|
181
|
+
/* @__PURE__ */ jsx(CardAction, { children: /* @__PURE__ */ jsx("div", { className: "flex gap-0.5 sm:gap-1", children: periods.map((p) => /* @__PURE__ */ jsx(
|
|
182
|
+
ChartPeriodButton,
|
|
183
|
+
{
|
|
184
|
+
period: p,
|
|
185
|
+
active: period === p,
|
|
186
|
+
onClick: () => setPeriod(p)
|
|
187
|
+
},
|
|
188
|
+
p
|
|
189
|
+
)) }) })
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ jsx(CardContent, { className: "px-3 sm:px-6", children: isLoading ? /* @__PURE__ */ jsx(Skeleton, { style: { height, width: "100%" } }) : !sliced ? /* @__PURE__ */ jsx(Empty, { className: "flex-none p-4", style: { height }, children: /* @__PURE__ */ jsx(EmptyDescription, { children: "No data available" }) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
192
|
+
showLegend && legendPosition === "top" && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1.5 pb-2", children: sliced.datasets.map((ds, i) => /* @__PURE__ */ jsx(ChartLegendItem, { label: ds.label, color: datasetColors[i] }, ds.label)) }),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { style: { height, width: "100%", position: "relative" }, children: /* @__PURE__ */ jsx(
|
|
194
|
+
Chart,
|
|
195
|
+
{
|
|
196
|
+
type: "bar",
|
|
197
|
+
data: chartData,
|
|
198
|
+
options,
|
|
199
|
+
"aria-label": title
|
|
200
|
+
},
|
|
201
|
+
brandSecondary
|
|
202
|
+
) }),
|
|
203
|
+
showLegend && legendPosition === "bottom" && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1.5 pt-2", children: sliced.datasets.map((ds, i) => /* @__PURE__ */ jsx(ChartLegendItem, { label: ds.label, color: datasetColors[i] }, ds.label)) })
|
|
204
|
+
] }) })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
ExpenseBarChart
|
|
212
|
+
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Skeleton
|
|
3
|
-
} from "./chunk-HS7TFG7V.mjs";
|
|
4
1
|
import {
|
|
5
2
|
Table,
|
|
6
3
|
TableBody,
|
|
@@ -16,6 +13,9 @@ import {
|
|
|
16
13
|
SelectTrigger,
|
|
17
14
|
SelectValue
|
|
18
15
|
} from "./chunk-VZ2NR7L3.mjs";
|
|
16
|
+
import {
|
|
17
|
+
Input
|
|
18
|
+
} from "./chunk-DS2AMHN2.mjs";
|
|
19
19
|
import {
|
|
20
20
|
DropdownMenu,
|
|
21
21
|
DropdownMenuCheckboxItem,
|
|
@@ -26,14 +26,14 @@ import {
|
|
|
26
26
|
DropdownMenuTrigger
|
|
27
27
|
} from "./chunk-MJIEMGRD.mjs";
|
|
28
28
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
29
|
+
Skeleton
|
|
30
|
+
} from "./chunk-HS7TFG7V.mjs";
|
|
31
31
|
import {
|
|
32
32
|
Checkbox
|
|
33
33
|
} from "./chunk-JF4PHPD5.mjs";
|
|
34
34
|
import {
|
|
35
35
|
Button
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-4AJ5HWHD.mjs";
|
|
37
37
|
import {
|
|
38
38
|
cn
|
|
39
39
|
} from "./chunk-V7CNWJT3.mjs";
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
} from "./chunk-MQ72DIBH.mjs";
|
|
6
6
|
import {
|
|
7
7
|
Calendar
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3NQGYJEZ.mjs";
|
|
9
9
|
import {
|
|
10
10
|
Button
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4AJ5HWHD.mjs";
|
|
12
12
|
import {
|
|
13
13
|
cn
|
|
14
14
|
} from "./chunk-V7CNWJT3.mjs";
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHART_PERIODS,
|
|
3
|
+
CHART_SLICE_COUNT,
|
|
4
|
+
ChartLegendItem,
|
|
5
|
+
ChartPeriodButton,
|
|
6
|
+
DATASET_ALPHAS,
|
|
7
|
+
FALLBACK_TICK,
|
|
8
|
+
formatTooltipDate,
|
|
9
|
+
hexToRgba
|
|
10
|
+
} from "./chunk-3EQP72AW.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Skeleton
|
|
13
|
+
} from "./chunk-HS7TFG7V.mjs";
|
|
14
|
+
import {
|
|
15
|
+
Empty,
|
|
16
|
+
EmptyDescription
|
|
17
|
+
} from "./chunk-YN5SYTOO.mjs";
|
|
18
|
+
import {
|
|
19
|
+
Card,
|
|
20
|
+
CardAction,
|
|
21
|
+
CardContent,
|
|
22
|
+
CardHeader,
|
|
23
|
+
CardTitle
|
|
24
|
+
} from "./chunk-SLWCCURD.mjs";
|
|
25
|
+
import {
|
|
26
|
+
useThemeVars
|
|
27
|
+
} from "./chunk-OXQQNQZI.mjs";
|
|
28
|
+
import {
|
|
29
|
+
cn
|
|
30
|
+
} from "./chunk-V7CNWJT3.mjs";
|
|
31
|
+
import {
|
|
32
|
+
__spreadProps,
|
|
33
|
+
__spreadValues
|
|
34
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
35
|
+
|
|
36
|
+
// src/components/ui/income-bar-chart.tsx
|
|
37
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
38
|
+
import {
|
|
39
|
+
Chart as ChartJS,
|
|
40
|
+
CategoryScale,
|
|
41
|
+
LinearScale,
|
|
42
|
+
BarElement,
|
|
43
|
+
Tooltip,
|
|
44
|
+
Legend
|
|
45
|
+
} from "chart.js";
|
|
46
|
+
import { Chart } from "react-chartjs-2";
|
|
47
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
48
|
+
ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
|
|
49
|
+
var FALLBACK_PRIMARY = "#33FF99";
|
|
50
|
+
function IncomeBarChart({
|
|
51
|
+
incomeData,
|
|
52
|
+
title = "Income",
|
|
53
|
+
showLegend = true,
|
|
54
|
+
showXAxis = true,
|
|
55
|
+
showYAxis = true,
|
|
56
|
+
legendPosition = "top",
|
|
57
|
+
defaultPeriod = 6,
|
|
58
|
+
granularity = "monthly",
|
|
59
|
+
height = 280,
|
|
60
|
+
width = "100%",
|
|
61
|
+
className,
|
|
62
|
+
isLoading = false
|
|
63
|
+
}) {
|
|
64
|
+
const periods = CHART_PERIODS[granularity];
|
|
65
|
+
const [period, setPeriod] = useState(defaultPeriod);
|
|
66
|
+
const isFirstRender = useRef(true);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (isFirstRender.current) {
|
|
69
|
+
isFirstRender.current = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setPeriod(CHART_PERIODS[granularity][0]);
|
|
73
|
+
}, [granularity]);
|
|
74
|
+
const themeVars = useThemeVars();
|
|
75
|
+
const brandPrimary = themeVars["--theme-primary"] || FALLBACK_PRIMARY;
|
|
76
|
+
const sliced = useMemo(() => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
if (!((_a = incomeData == null ? void 0 : incomeData.months) == null ? void 0 : _a.length) || !incomeData.datasets.length) return null;
|
|
79
|
+
const count = Math.min(CHART_SLICE_COUNT[granularity][period], incomeData.months.length);
|
|
80
|
+
const start = incomeData.months.length - count;
|
|
81
|
+
return {
|
|
82
|
+
months: incomeData.months.slice(start),
|
|
83
|
+
dates: (_b = incomeData.dates) == null ? void 0 : _b.slice(start),
|
|
84
|
+
datasets: incomeData.datasets.map((ds) => __spreadProps(__spreadValues({}, ds), {
|
|
85
|
+
data: ds.data.slice(start)
|
|
86
|
+
}))
|
|
87
|
+
};
|
|
88
|
+
}, [incomeData, period, granularity]);
|
|
89
|
+
const datasetColors = useMemo(
|
|
90
|
+
() => {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = sliced == null ? void 0 : sliced.datasets.map(
|
|
93
|
+
(_, i) => hexToRgba(brandPrimary, DATASET_ALPHAS[i % DATASET_ALPHAS.length])
|
|
94
|
+
)) != null ? _a : [];
|
|
95
|
+
},
|
|
96
|
+
[sliced, brandPrimary]
|
|
97
|
+
);
|
|
98
|
+
const chartData = useMemo(() => {
|
|
99
|
+
if (!sliced) return { labels: [], datasets: [] };
|
|
100
|
+
return {
|
|
101
|
+
labels: sliced.months,
|
|
102
|
+
datasets: sliced.datasets.map((ds, i) => ({
|
|
103
|
+
label: ds.label,
|
|
104
|
+
data: ds.data,
|
|
105
|
+
backgroundColor: datasetColors[i],
|
|
106
|
+
hoverBackgroundColor: hexToRgba(
|
|
107
|
+
brandPrimary,
|
|
108
|
+
Math.min(DATASET_ALPHAS[i % DATASET_ALPHAS.length] + 0.15, 1)
|
|
109
|
+
),
|
|
110
|
+
borderWidth: 0,
|
|
111
|
+
borderRadius: 0,
|
|
112
|
+
borderSkipped: false,
|
|
113
|
+
barPercentage: 0.75,
|
|
114
|
+
categoryPercentage: 0.7,
|
|
115
|
+
stack: "income"
|
|
116
|
+
}))
|
|
117
|
+
};
|
|
118
|
+
}, [sliced, datasetColors, brandPrimary]);
|
|
119
|
+
const options = useMemo(() => ({
|
|
120
|
+
responsive: true,
|
|
121
|
+
maintainAspectRatio: false,
|
|
122
|
+
animation: { duration: 800, easing: "easeOutQuart" },
|
|
123
|
+
layout: { padding: 0 },
|
|
124
|
+
plugins: {
|
|
125
|
+
legend: { display: false },
|
|
126
|
+
tooltip: {
|
|
127
|
+
mode: "index",
|
|
128
|
+
intersect: false,
|
|
129
|
+
padding: 12,
|
|
130
|
+
cornerRadius: 0,
|
|
131
|
+
titleFont: { size: 11, weight: "600" },
|
|
132
|
+
bodyFont: { size: 12, weight: "500" },
|
|
133
|
+
callbacks: {
|
|
134
|
+
title: (tooltipItems) => {
|
|
135
|
+
var _a, _b, _c, _d;
|
|
136
|
+
const idx = (_a = tooltipItems[0]) == null ? void 0 : _a.dataIndex;
|
|
137
|
+
if (idx != null && ((_b = sliced == null ? void 0 : sliced.dates) == null ? void 0 : _b[idx])) {
|
|
138
|
+
return formatTooltipDate(sliced.dates[idx], granularity);
|
|
139
|
+
}
|
|
140
|
+
return (_d = (_c = tooltipItems[0]) == null ? void 0 : _c.label) != null ? _d : "";
|
|
141
|
+
},
|
|
142
|
+
label: (ctx) => {
|
|
143
|
+
const val = ctx.raw;
|
|
144
|
+
if (val === 0) return null;
|
|
145
|
+
return ` ${ctx.dataset.label}: $${val.toLocaleString()}`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
scales: {
|
|
151
|
+
x: {
|
|
152
|
+
display: showXAxis,
|
|
153
|
+
stacked: true,
|
|
154
|
+
grid: { display: false },
|
|
155
|
+
border: { display: false },
|
|
156
|
+
ticks: { font: { size: 10 }, color: FALLBACK_TICK }
|
|
157
|
+
},
|
|
158
|
+
y: {
|
|
159
|
+
display: showYAxis,
|
|
160
|
+
stacked: true,
|
|
161
|
+
grid: { display: false },
|
|
162
|
+
border: { display: false },
|
|
163
|
+
ticks: {
|
|
164
|
+
font: { size: 10 },
|
|
165
|
+
color: FALLBACK_TICK,
|
|
166
|
+
maxTicksLimit: 5,
|
|
167
|
+
padding: 8,
|
|
168
|
+
callback: (v) => `$${Number(v).toLocaleString()}`
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}), [showXAxis, showYAxis, sliced, granularity]);
|
|
173
|
+
return /* @__PURE__ */ jsxs(
|
|
174
|
+
Card,
|
|
175
|
+
{
|
|
176
|
+
className: cn("w-full py-4 sm:py-6 gap-2", className),
|
|
177
|
+
style: { maxWidth: width },
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsxs(CardHeader, { className: "px-3 sm:px-6", children: [
|
|
180
|
+
/* @__PURE__ */ jsx(CardTitle, { className: "text-sm sm:text-base", children: title }),
|
|
181
|
+
/* @__PURE__ */ jsx(CardAction, { children: /* @__PURE__ */ jsx("div", { className: "flex gap-0.5 sm:gap-1", children: periods.map((p) => /* @__PURE__ */ jsx(
|
|
182
|
+
ChartPeriodButton,
|
|
183
|
+
{
|
|
184
|
+
period: p,
|
|
185
|
+
active: period === p,
|
|
186
|
+
onClick: () => setPeriod(p)
|
|
187
|
+
},
|
|
188
|
+
p
|
|
189
|
+
)) }) })
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ jsx(CardContent, { className: "px-3 sm:px-6", children: isLoading ? /* @__PURE__ */ jsx(Skeleton, { style: { height, width: "100%" } }) : !sliced ? /* @__PURE__ */ jsx(Empty, { className: "flex-none p-4", style: { height }, children: /* @__PURE__ */ jsx(EmptyDescription, { children: "No data available" }) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
192
|
+
showLegend && legendPosition === "top" && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1.5 pb-2", children: sliced.datasets.map((ds, i) => /* @__PURE__ */ jsx(ChartLegendItem, { label: ds.label, color: datasetColors[i] }, ds.label)) }),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { style: { height, width: "100%", position: "relative" }, children: /* @__PURE__ */ jsx(
|
|
194
|
+
Chart,
|
|
195
|
+
{
|
|
196
|
+
type: "bar",
|
|
197
|
+
data: chartData,
|
|
198
|
+
options,
|
|
199
|
+
"aria-label": title
|
|
200
|
+
},
|
|
201
|
+
brandPrimary
|
|
202
|
+
) }),
|
|
203
|
+
showLegend && legendPosition === "bottom" && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1.5 pt-2", children: sliced.datasets.map((ds, i) => /* @__PURE__ */ jsx(ChartLegendItem, { label: ds.label, color: datasetColors[i] }, ds.label)) })
|
|
204
|
+
] }) })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
IncomeBarChart
|
|
212
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-V7CNWJT3.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/ui/slider.tsx
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var Slider = React.forwardRef(
|
|
13
|
+
(_a, ref) => {
|
|
14
|
+
var _b = _a, {
|
|
15
|
+
className,
|
|
16
|
+
value,
|
|
17
|
+
defaultValue = 0,
|
|
18
|
+
min = 0,
|
|
19
|
+
max = 100,
|
|
20
|
+
step = 1,
|
|
21
|
+
disabled = false,
|
|
22
|
+
onValueChange
|
|
23
|
+
} = _b, props = __objRest(_b, [
|
|
24
|
+
"className",
|
|
25
|
+
"value",
|
|
26
|
+
"defaultValue",
|
|
27
|
+
"min",
|
|
28
|
+
"max",
|
|
29
|
+
"step",
|
|
30
|
+
"disabled",
|
|
31
|
+
"onValueChange"
|
|
32
|
+
]);
|
|
33
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
34
|
+
const currentValue = value !== void 0 ? value : internalValue;
|
|
35
|
+
const percentage = (currentValue - min) / (max - min) * 100;
|
|
36
|
+
const handleChange = (e) => {
|
|
37
|
+
const newValue = Number(e.target.value);
|
|
38
|
+
if (value === void 0) {
|
|
39
|
+
setInternalValue(newValue);
|
|
40
|
+
}
|
|
41
|
+
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
"data-slot": "slider",
|
|
47
|
+
className: cn(
|
|
48
|
+
"relative flex w-full touch-none items-center select-none",
|
|
49
|
+
disabled && "opacity-50",
|
|
50
|
+
className
|
|
51
|
+
),
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
"data-slot": "slider-track",
|
|
57
|
+
className: "relative h-2 w-full overflow-hidden rounded-full bg-muted",
|
|
58
|
+
children: /* @__PURE__ */ jsx(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
"data-slot": "slider-range",
|
|
62
|
+
className: "absolute h-full rounded-full bg-primary",
|
|
63
|
+
style: { width: `${percentage}%` }
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"input",
|
|
70
|
+
__spreadValues({
|
|
71
|
+
ref,
|
|
72
|
+
type: "range",
|
|
73
|
+
min,
|
|
74
|
+
max,
|
|
75
|
+
step,
|
|
76
|
+
value: currentValue,
|
|
77
|
+
disabled,
|
|
78
|
+
onChange: handleChange,
|
|
79
|
+
className: cn(
|
|
80
|
+
"absolute inset-0 h-full w-full cursor-pointer opacity-0",
|
|
81
|
+
disabled && "cursor-not-allowed"
|
|
82
|
+
)
|
|
83
|
+
}, props)
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
"data-slot": "slider-thumb",
|
|
89
|
+
className: cn(
|
|
90
|
+
"pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
91
|
+
"block size-5 rounded-full border-2 border-primary bg-background shadow-sm"
|
|
92
|
+
),
|
|
93
|
+
style: { left: `${percentage}%` }
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
Slider.displayName = "Slider";
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
Slider
|
|
105
|
+
};
|