@saasflare/ui 1.0.0 → 1.0.1
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/README.md +258 -0
- package/dist/button-B2DR7obe.d.mts +316 -0
- package/dist/button-B2DR7obe.d.ts +316 -0
- package/dist/chunk-7UB3R5JU.js +590 -0
- package/dist/chunk-JOVJRQO3.js +13 -0
- package/dist/chunk-P2JF7JDY.mjs +550 -0
- package/dist/chunk-S26666D6.mjs +11 -0
- package/dist/entries/carousel.d.mts +24 -0
- package/dist/entries/carousel.d.ts +24 -0
- package/dist/entries/carousel.js +223 -0
- package/dist/entries/carousel.mjs +194 -0
- package/dist/entries/chart.d.mts +69 -0
- package/dist/entries/chart.d.ts +69 -0
- package/dist/entries/chart.js +265 -0
- package/dist/entries/chart.mjs +237 -0
- package/dist/index.d.mts +173 -545
- package/dist/index.d.ts +173 -545
- package/dist/index.js +1094 -2018
- package/dist/index.mjs +650 -1638
- package/package.json +82 -18
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJOVJRQO3_js = require('../chunk-JOVJRQO3.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var RechartsPrimitive = require('recharts');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
var RechartsPrimitive__namespace = /*#__PURE__*/_interopNamespace(RechartsPrimitive);
|
|
28
|
+
|
|
29
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
30
|
+
var ChartContext = React__namespace.createContext(null);
|
|
31
|
+
function useChart() {
|
|
32
|
+
const context = React__namespace.useContext(ChartContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
38
|
+
function ChartContainer({
|
|
39
|
+
id,
|
|
40
|
+
className,
|
|
41
|
+
children,
|
|
42
|
+
config,
|
|
43
|
+
...props
|
|
44
|
+
}) {
|
|
45
|
+
const uniqueId = React__namespace.useId();
|
|
46
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
"data-slot": "chart",
|
|
51
|
+
"data-chart": chartId,
|
|
52
|
+
className: chunkJOVJRQO3_js.cn(
|
|
53
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChartStyle, { id: chartId, config }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx(RechartsPrimitive__namespace.ResponsiveContainer, { children })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
}
|
|
64
|
+
var ChartStyle = ({ id, config }) => {
|
|
65
|
+
const colorConfig = Object.entries(config).filter(
|
|
66
|
+
([, config2]) => config2.theme || config2.color
|
|
67
|
+
);
|
|
68
|
+
if (!colorConfig.length) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
|
+
"style",
|
|
73
|
+
{
|
|
74
|
+
dangerouslySetInnerHTML: {
|
|
75
|
+
__html: Object.entries(THEMES).map(
|
|
76
|
+
([theme, prefix]) => `
|
|
77
|
+
${prefix} [data-chart=${id}] {
|
|
78
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
79
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
80
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
81
|
+
}).join("\n")}
|
|
82
|
+
}
|
|
83
|
+
`
|
|
84
|
+
).join("\n")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
var ChartTooltip = RechartsPrimitive__namespace.Tooltip;
|
|
90
|
+
function ChartTooltipContent({
|
|
91
|
+
active,
|
|
92
|
+
payload,
|
|
93
|
+
className,
|
|
94
|
+
indicator = "dot",
|
|
95
|
+
hideLabel = false,
|
|
96
|
+
hideIndicator = false,
|
|
97
|
+
label,
|
|
98
|
+
labelFormatter,
|
|
99
|
+
labelClassName,
|
|
100
|
+
formatter,
|
|
101
|
+
color,
|
|
102
|
+
nameKey,
|
|
103
|
+
labelKey
|
|
104
|
+
}) {
|
|
105
|
+
const { config } = useChart();
|
|
106
|
+
const tooltipLabel = React__namespace.useMemo(() => {
|
|
107
|
+
if (hideLabel || !payload?.length) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const [item] = payload;
|
|
111
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
112
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
113
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
114
|
+
if (labelFormatter) {
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkJOVJRQO3_js.cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
116
|
+
}
|
|
117
|
+
if (!value) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkJOVJRQO3_js.cn("font-medium", labelClassName), children: value });
|
|
121
|
+
}, [
|
|
122
|
+
label,
|
|
123
|
+
labelFormatter,
|
|
124
|
+
payload,
|
|
125
|
+
hideLabel,
|
|
126
|
+
labelClassName,
|
|
127
|
+
config,
|
|
128
|
+
labelKey
|
|
129
|
+
]);
|
|
130
|
+
if (!active || !payload?.length) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
134
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: chunkJOVJRQO3_js.cn(
|
|
138
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
139
|
+
className
|
|
140
|
+
),
|
|
141
|
+
children: [
|
|
142
|
+
!nestLabel ? tooltipLabel : null,
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
144
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
145
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
146
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: chunkJOVJRQO3_js.cn(
|
|
151
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
152
|
+
indicator === "dot" && "items-center"
|
|
153
|
+
),
|
|
154
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
155
|
+
itemConfig?.icon ? /* @__PURE__ */ jsxRuntime.jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: chunkJOVJRQO3_js.cn(
|
|
159
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
160
|
+
{
|
|
161
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
162
|
+
"w-1": indicator === "line",
|
|
163
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
164
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
style: {
|
|
168
|
+
"--color-bg": indicatorColor,
|
|
169
|
+
"--color-border": indicatorColor
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: chunkJOVJRQO3_js.cn(
|
|
177
|
+
"flex flex-1 justify-between leading-none",
|
|
178
|
+
nestLabel ? "items-end" : "items-center"
|
|
179
|
+
),
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-1.5", children: [
|
|
182
|
+
nestLabel ? tooltipLabel : null,
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
184
|
+
] }),
|
|
185
|
+
item.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono font-medium text-foreground tabular-nums", children: item.value.toLocaleString() })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
] })
|
|
190
|
+
},
|
|
191
|
+
item.dataKey
|
|
192
|
+
);
|
|
193
|
+
}) })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
var ChartLegend = RechartsPrimitive__namespace.Legend;
|
|
199
|
+
function ChartLegendContent({
|
|
200
|
+
className,
|
|
201
|
+
hideIcon = false,
|
|
202
|
+
payload,
|
|
203
|
+
verticalAlign = "bottom",
|
|
204
|
+
nameKey
|
|
205
|
+
}) {
|
|
206
|
+
const { config } = useChart();
|
|
207
|
+
if (!payload?.length) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
className: chunkJOVJRQO3_js.cn(
|
|
214
|
+
"flex items-center justify-center gap-4",
|
|
215
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
216
|
+
className
|
|
217
|
+
),
|
|
218
|
+
children: payload.filter((item) => item.type !== "none").map((item) => {
|
|
219
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
220
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
221
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
222
|
+
"div",
|
|
223
|
+
{
|
|
224
|
+
className: chunkJOVJRQO3_js.cn(
|
|
225
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
226
|
+
),
|
|
227
|
+
children: [
|
|
228
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsxRuntime.jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
232
|
+
style: {
|
|
233
|
+
backgroundColor: item.color
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
itemConfig?.label
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
item.value
|
|
241
|
+
);
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
247
|
+
if (typeof payload !== "object" || payload === null) {
|
|
248
|
+
return void 0;
|
|
249
|
+
}
|
|
250
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
251
|
+
let configLabelKey = key;
|
|
252
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
253
|
+
configLabelKey = payload[key];
|
|
254
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
255
|
+
configLabelKey = payloadPayload[key];
|
|
256
|
+
}
|
|
257
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
exports.ChartContainer = ChartContainer;
|
|
261
|
+
exports.ChartLegend = ChartLegend;
|
|
262
|
+
exports.ChartLegendContent = ChartLegendContent;
|
|
263
|
+
exports.ChartStyle = ChartStyle;
|
|
264
|
+
exports.ChartTooltip = ChartTooltip;
|
|
265
|
+
exports.ChartTooltipContent = ChartTooltipContent;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { cn } from '../chunk-S26666D6.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as RechartsPrimitive from 'recharts';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
7
|
+
var ChartContext = React.createContext(null);
|
|
8
|
+
function useChart() {
|
|
9
|
+
const context = React.useContext(ChartContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
function ChartContainer({
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
config,
|
|
20
|
+
...props
|
|
21
|
+
}) {
|
|
22
|
+
const uniqueId = React.useId();
|
|
23
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
24
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
"data-slot": "chart",
|
|
28
|
+
"data-chart": chartId,
|
|
29
|
+
className: cn(
|
|
30
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
31
|
+
className
|
|
32
|
+
),
|
|
33
|
+
...props,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
|
|
36
|
+
/* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
) });
|
|
40
|
+
}
|
|
41
|
+
var ChartStyle = ({ id, config }) => {
|
|
42
|
+
const colorConfig = Object.entries(config).filter(
|
|
43
|
+
([, config2]) => config2.theme || config2.color
|
|
44
|
+
);
|
|
45
|
+
if (!colorConfig.length) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
"style",
|
|
50
|
+
{
|
|
51
|
+
dangerouslySetInnerHTML: {
|
|
52
|
+
__html: Object.entries(THEMES).map(
|
|
53
|
+
([theme, prefix]) => `
|
|
54
|
+
${prefix} [data-chart=${id}] {
|
|
55
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
56
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
57
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
58
|
+
}).join("\n")}
|
|
59
|
+
}
|
|
60
|
+
`
|
|
61
|
+
).join("\n")
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
67
|
+
function ChartTooltipContent({
|
|
68
|
+
active,
|
|
69
|
+
payload,
|
|
70
|
+
className,
|
|
71
|
+
indicator = "dot",
|
|
72
|
+
hideLabel = false,
|
|
73
|
+
hideIndicator = false,
|
|
74
|
+
label,
|
|
75
|
+
labelFormatter,
|
|
76
|
+
labelClassName,
|
|
77
|
+
formatter,
|
|
78
|
+
color,
|
|
79
|
+
nameKey,
|
|
80
|
+
labelKey
|
|
81
|
+
}) {
|
|
82
|
+
const { config } = useChart();
|
|
83
|
+
const tooltipLabel = React.useMemo(() => {
|
|
84
|
+
if (hideLabel || !payload?.length) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const [item] = payload;
|
|
88
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
89
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
90
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
91
|
+
if (labelFormatter) {
|
|
92
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
93
|
+
}
|
|
94
|
+
if (!value) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
|
|
98
|
+
}, [
|
|
99
|
+
label,
|
|
100
|
+
labelFormatter,
|
|
101
|
+
payload,
|
|
102
|
+
hideLabel,
|
|
103
|
+
labelClassName,
|
|
104
|
+
config,
|
|
105
|
+
labelKey
|
|
106
|
+
]);
|
|
107
|
+
if (!active || !payload?.length) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
111
|
+
return /* @__PURE__ */ jsxs(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: cn(
|
|
115
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
116
|
+
className
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
!nestLabel ? tooltipLabel : null,
|
|
120
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
121
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
122
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
123
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
124
|
+
return /* @__PURE__ */ jsx(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: cn(
|
|
128
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
129
|
+
indicator === "dot" && "items-center"
|
|
130
|
+
),
|
|
131
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
132
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
className: cn(
|
|
136
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
137
|
+
{
|
|
138
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
139
|
+
"w-1": indicator === "line",
|
|
140
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
141
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
style: {
|
|
145
|
+
"--color-bg": indicatorColor,
|
|
146
|
+
"--color-border": indicatorColor
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsxs(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: cn(
|
|
154
|
+
"flex flex-1 justify-between leading-none",
|
|
155
|
+
nestLabel ? "items-end" : "items-center"
|
|
156
|
+
),
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
|
|
159
|
+
nestLabel ? tooltipLabel : null,
|
|
160
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
161
|
+
] }),
|
|
162
|
+
item.value && /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-foreground tabular-nums", children: item.value.toLocaleString() })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
},
|
|
168
|
+
item.dataKey
|
|
169
|
+
);
|
|
170
|
+
}) })
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
176
|
+
function ChartLegendContent({
|
|
177
|
+
className,
|
|
178
|
+
hideIcon = false,
|
|
179
|
+
payload,
|
|
180
|
+
verticalAlign = "bottom",
|
|
181
|
+
nameKey
|
|
182
|
+
}) {
|
|
183
|
+
const { config } = useChart();
|
|
184
|
+
if (!payload?.length) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return /* @__PURE__ */ jsx(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
className: cn(
|
|
191
|
+
"flex items-center justify-center gap-4",
|
|
192
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
193
|
+
className
|
|
194
|
+
),
|
|
195
|
+
children: payload.filter((item) => item.type !== "none").map((item) => {
|
|
196
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
197
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
198
|
+
return /* @__PURE__ */ jsxs(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
className: cn(
|
|
202
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
203
|
+
),
|
|
204
|
+
children: [
|
|
205
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
209
|
+
style: {
|
|
210
|
+
backgroundColor: item.color
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
itemConfig?.label
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
item.value
|
|
218
|
+
);
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
224
|
+
if (typeof payload !== "object" || payload === null) {
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
228
|
+
let configLabelKey = key;
|
|
229
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
230
|
+
configLabelKey = payload[key];
|
|
231
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
232
|
+
configLabelKey = payloadPayload[key];
|
|
233
|
+
}
|
|
234
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
|