@hobenakicoffee/libraries 1.28.0 → 1.29.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/package.json +5 -39
- package/src/nuqs/common.ts +12 -0
- package/src/nuqs/index.ts +2 -0
- package/src/nuqs/transactions.ts +31 -0
- package/src/components/ui/alert-dialog.tsx +0 -196
- package/src/components/ui/alert.tsx +0 -76
- package/src/components/ui/avatar.tsx +0 -110
- package/src/components/ui/badge.tsx +0 -49
- package/src/components/ui/breadcrumb.tsx +0 -122
- package/src/components/ui/button-group.tsx +0 -82
- package/src/components/ui/card.tsx +0 -100
- package/src/components/ui/chart.tsx +0 -364
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/dialog.tsx +0 -162
- package/src/components/ui/drawer.tsx +0 -126
- package/src/components/ui/dropdown-menu.tsx +0 -267
- package/src/components/ui/empty-minimal.tsx +0 -20
- package/src/components/ui/empty.tsx +0 -101
- package/src/components/ui/field.tsx +0 -235
- package/src/components/ui/input-group.tsx +0 -170
- package/src/components/ui/input-otp.tsx +0 -84
- package/src/components/ui/input.tsx +0 -37
- package/src/components/ui/item.tsx +0 -196
- package/src/components/ui/label.tsx +0 -19
- package/src/components/ui/popover.tsx +0 -87
- package/src/components/ui/radio-group.tsx +0 -47
- package/src/components/ui/select.tsx +0 -205
- package/src/components/ui/separator.tsx +0 -26
- package/src/components/ui/sheet.tsx +0 -141
- package/src/components/ui/sidebar.tsx +0 -699
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/sonner.tsx +0 -74
- package/src/components/ui/table.tsx +0 -114
- package/src/components/ui/tabs.tsx +0 -88
- package/src/components/ui/textarea.tsx +0 -35
- package/src/components/ui/toggle-group.tsx +0 -91
- package/src/components/ui/toggle.tsx +0 -44
- package/src/components/ui/tooltip.tsx +0 -59
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
-
import { Slot } from "radix-ui";
|
|
3
|
-
import { Separator } from "@/components/ui/separator";
|
|
4
|
-
import { cn } from "@/lib/utils";
|
|
5
|
-
|
|
6
|
-
const buttonGroupVariants = cva(
|
|
7
|
-
"flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-xl [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
|
|
8
|
-
{
|
|
9
|
-
variants: {
|
|
10
|
-
orientation: {
|
|
11
|
-
horizontal:
|
|
12
|
-
"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-xl!",
|
|
13
|
-
vertical:
|
|
14
|
-
"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-xl!",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
defaultVariants: {
|
|
18
|
-
orientation: "horizontal",
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
function ButtonGroup({
|
|
24
|
-
className,
|
|
25
|
-
orientation,
|
|
26
|
-
...props
|
|
27
|
-
}: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={cn(buttonGroupVariants({ orientation }), className)}
|
|
31
|
-
data-orientation={orientation}
|
|
32
|
-
data-slot="button-group"
|
|
33
|
-
role="group"
|
|
34
|
-
{...props}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function ButtonGroupText({
|
|
40
|
-
className,
|
|
41
|
-
asChild = false,
|
|
42
|
-
...props
|
|
43
|
-
}: React.ComponentProps<"div"> & {
|
|
44
|
-
asChild?: boolean;
|
|
45
|
-
}) {
|
|
46
|
-
const Comp = asChild ? Slot.Root : "div";
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Comp
|
|
50
|
-
className={cn(
|
|
51
|
-
"flex items-center gap-2 rounded-xl border bg-muted px-2.5 font-medium text-sm shadow-xs [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
52
|
-
className
|
|
53
|
-
)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function ButtonGroupSeparator({
|
|
60
|
-
className,
|
|
61
|
-
orientation = "vertical",
|
|
62
|
-
...props
|
|
63
|
-
}: React.ComponentProps<typeof Separator>) {
|
|
64
|
-
return (
|
|
65
|
-
<Separator
|
|
66
|
-
className={cn(
|
|
67
|
-
"relative self-stretch bg-input data-[orientation=horizontal]:mx-px data-[orientation=vertical]:my-px data-[orientation=vertical]:h-auto data-[orientation=horizontal]:w-auto",
|
|
68
|
-
className
|
|
69
|
-
)}
|
|
70
|
-
data-slot="button-group-separator"
|
|
71
|
-
orientation={orientation}
|
|
72
|
-
{...props}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
ButtonGroup,
|
|
79
|
-
ButtonGroupSeparator,
|
|
80
|
-
ButtonGroupText,
|
|
81
|
-
buttonGroupVariants,
|
|
82
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@/lib/utils";
|
|
4
|
-
|
|
5
|
-
function Card({
|
|
6
|
-
className,
|
|
7
|
-
size = "default",
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
10
|
-
return (
|
|
11
|
-
<div
|
|
12
|
-
className={cn(
|
|
13
|
-
"group/card flex flex-col gap-6 overflow-hidden rounded-2xl bg-card py-6 text-card-foreground text-sm ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
14
|
-
className
|
|
15
|
-
)}
|
|
16
|
-
data-size={size}
|
|
17
|
-
data-slot="card"
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
className={cn(
|
|
27
|
-
"group/card-header @container/card-header grid auto-rows-min items-start gap-2 rounded-t-xl px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] group-data-[size=sm]/card:px-4 sm:px-6 [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4",
|
|
28
|
-
className
|
|
29
|
-
)}
|
|
30
|
-
data-slot="card-header"
|
|
31
|
-
{...props}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
-
return (
|
|
38
|
-
<div
|
|
39
|
-
className={cn("font-medium text-base", className)}
|
|
40
|
-
data-slot="card-title"
|
|
41
|
-
{...props}
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
47
|
-
return (
|
|
48
|
-
<div
|
|
49
|
-
className={cn("text-muted-foreground text-sm", className)}
|
|
50
|
-
data-slot="card-description"
|
|
51
|
-
{...props}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
className={cn(
|
|
60
|
-
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
61
|
-
className
|
|
62
|
-
)}
|
|
63
|
-
data-slot="card-action"
|
|
64
|
-
{...props}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
70
|
-
return (
|
|
71
|
-
<div
|
|
72
|
-
className={cn("px-4 group-data-[size=sm]/card:px-4 sm:px-6", className)}
|
|
73
|
-
data-slot="card-content"
|
|
74
|
-
{...props}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
80
|
-
return (
|
|
81
|
-
<div
|
|
82
|
-
className={cn(
|
|
83
|
-
"flex items-center rounded-b-xl px-6 group-data-[size=sm]/card:px-4 [.border-t]:pt-6 group-data-[size=sm]/card:[.border-t]:pt-4",
|
|
84
|
-
className
|
|
85
|
-
)}
|
|
86
|
-
data-slot="card-footer"
|
|
87
|
-
{...props}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export {
|
|
93
|
-
Card,
|
|
94
|
-
CardHeader,
|
|
95
|
-
CardFooter,
|
|
96
|
-
CardTitle,
|
|
97
|
-
CardAction,
|
|
98
|
-
CardDescription,
|
|
99
|
-
CardContent,
|
|
100
|
-
};
|
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ComponentProps,
|
|
3
|
-
type ComponentType,
|
|
4
|
-
type CSSProperties,
|
|
5
|
-
createContext,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
useContext,
|
|
8
|
-
useId,
|
|
9
|
-
useMemo,
|
|
10
|
-
} from "react";
|
|
11
|
-
import {
|
|
12
|
-
Legend,
|
|
13
|
-
type LegendProps,
|
|
14
|
-
ResponsiveContainer,
|
|
15
|
-
Tooltip,
|
|
16
|
-
} from "recharts";
|
|
17
|
-
import { cn } from "@/lib/utils";
|
|
18
|
-
|
|
19
|
-
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
20
|
-
const THEMES = { light: "", dark: ".dark" } as const;
|
|
21
|
-
|
|
22
|
-
export type ChartConfig = {
|
|
23
|
-
[k in string]: {
|
|
24
|
-
label?: ReactNode;
|
|
25
|
-
icon?: ComponentType;
|
|
26
|
-
} & (
|
|
27
|
-
| { color?: string; theme?: never }
|
|
28
|
-
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type ChartContextProps = {
|
|
33
|
-
config: ChartConfig;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const ChartContext = createContext<ChartContextProps | null>(null);
|
|
37
|
-
|
|
38
|
-
function useChart() {
|
|
39
|
-
const context = useContext(ChartContext);
|
|
40
|
-
|
|
41
|
-
if (!context) {
|
|
42
|
-
throw new Error("useChart must be used within a <ChartContainer />");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return context;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function ChartContainer({
|
|
49
|
-
id,
|
|
50
|
-
className,
|
|
51
|
-
children,
|
|
52
|
-
config,
|
|
53
|
-
...props
|
|
54
|
-
}: ComponentProps<"div"> & {
|
|
55
|
-
config: ChartConfig;
|
|
56
|
-
children: ComponentProps<typeof ResponsiveContainer>["children"];
|
|
57
|
-
}) {
|
|
58
|
-
const uniqueId = useId();
|
|
59
|
-
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<ChartContext.Provider value={{ config }}>
|
|
63
|
-
<div
|
|
64
|
-
className={cn(
|
|
65
|
-
"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[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-hidden [&_.recharts-surface]:outline-hidden",
|
|
66
|
-
className
|
|
67
|
-
)}
|
|
68
|
-
data-chart={chartId}
|
|
69
|
-
data-slot="chart"
|
|
70
|
-
{...props}
|
|
71
|
-
>
|
|
72
|
-
<ChartStyle config={config} id={chartId} />
|
|
73
|
-
<ResponsiveContainer>{children}</ResponsiveContainer>
|
|
74
|
-
</div>
|
|
75
|
-
</ChartContext.Provider>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
80
|
-
const colorConfig = Object.entries(config).filter(
|
|
81
|
-
([, config]) => config.theme || config.color
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
if (!colorConfig.length) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<style
|
|
90
|
-
// biome-ignore lint/security/noDangerouslySetInnerHtml: <properly sanitized />
|
|
91
|
-
dangerouslySetInnerHTML={{
|
|
92
|
-
__html: Object.entries(THEMES)
|
|
93
|
-
.map(
|
|
94
|
-
([theme, prefix]) => `
|
|
95
|
-
${prefix} [data-chart=${id}] {
|
|
96
|
-
${colorConfig
|
|
97
|
-
.map(([key, itemConfig]) => {
|
|
98
|
-
const color =
|
|
99
|
-
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
100
|
-
itemConfig.color;
|
|
101
|
-
return color ? ` --color-${key}: ${color};` : null;
|
|
102
|
-
})
|
|
103
|
-
.join("\n")}
|
|
104
|
-
}
|
|
105
|
-
`
|
|
106
|
-
)
|
|
107
|
-
.join("\n"),
|
|
108
|
-
}}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const ChartTooltip = Tooltip;
|
|
114
|
-
|
|
115
|
-
function ChartTooltipContent({
|
|
116
|
-
active,
|
|
117
|
-
payload,
|
|
118
|
-
className,
|
|
119
|
-
indicator = "dot",
|
|
120
|
-
hideLabel = false,
|
|
121
|
-
hideIndicator = false,
|
|
122
|
-
label,
|
|
123
|
-
labelFormatter,
|
|
124
|
-
labelClassName,
|
|
125
|
-
formatter,
|
|
126
|
-
color,
|
|
127
|
-
nameKey,
|
|
128
|
-
labelKey,
|
|
129
|
-
}: ComponentProps<typeof Tooltip> &
|
|
130
|
-
ComponentProps<"div"> & {
|
|
131
|
-
hideLabel?: boolean;
|
|
132
|
-
hideIndicator?: boolean;
|
|
133
|
-
indicator?: "line" | "dot" | "dashed";
|
|
134
|
-
nameKey?: string;
|
|
135
|
-
labelKey?: string;
|
|
136
|
-
}) {
|
|
137
|
-
const { config } = useChart();
|
|
138
|
-
|
|
139
|
-
const tooltipLabel = useMemo(() => {
|
|
140
|
-
if (hideLabel || !payload?.length) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const [item] = payload;
|
|
145
|
-
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
146
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
147
|
-
const value =
|
|
148
|
-
!labelKey && typeof label === "string"
|
|
149
|
-
? config[label as keyof typeof config]?.label || label
|
|
150
|
-
: itemConfig?.label;
|
|
151
|
-
|
|
152
|
-
if (labelFormatter) {
|
|
153
|
-
return (
|
|
154
|
-
<div className={cn("font-medium", labelClassName)}>
|
|
155
|
-
{labelFormatter(value, payload)}
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (!value) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
|
165
|
-
}, [
|
|
166
|
-
label,
|
|
167
|
-
labelFormatter,
|
|
168
|
-
payload,
|
|
169
|
-
hideLabel,
|
|
170
|
-
labelClassName,
|
|
171
|
-
config,
|
|
172
|
-
labelKey,
|
|
173
|
-
]);
|
|
174
|
-
|
|
175
|
-
if (!(active && payload?.length)) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<div
|
|
183
|
-
className={cn(
|
|
184
|
-
"grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
185
|
-
className
|
|
186
|
-
)}
|
|
187
|
-
>
|
|
188
|
-
{nestLabel ? null : tooltipLabel}
|
|
189
|
-
<div className="grid gap-1.5">
|
|
190
|
-
{payload
|
|
191
|
-
.filter((item) => item.type !== "none")
|
|
192
|
-
.map((item, index) => {
|
|
193
|
-
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
194
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
195
|
-
const indicatorColor = color || item.payload.fill || item.color;
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div
|
|
199
|
-
className={cn(
|
|
200
|
-
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
201
|
-
indicator === "dot" && "items-center"
|
|
202
|
-
)}
|
|
203
|
-
key={item.dataKey}
|
|
204
|
-
>
|
|
205
|
-
{formatter && item?.value !== undefined && item.name ? (
|
|
206
|
-
formatter(item.value, item.name, item, index, item.payload)
|
|
207
|
-
) : (
|
|
208
|
-
<>
|
|
209
|
-
{itemConfig?.icon ? (
|
|
210
|
-
<itemConfig.icon />
|
|
211
|
-
) : (
|
|
212
|
-
!hideIndicator && (
|
|
213
|
-
<div
|
|
214
|
-
className={cn(
|
|
215
|
-
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
216
|
-
{
|
|
217
|
-
"h-2.5 w-2.5": indicator === "dot",
|
|
218
|
-
"w-1": indicator === "line",
|
|
219
|
-
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
220
|
-
indicator === "dashed",
|
|
221
|
-
"my-0.5": nestLabel && indicator === "dashed",
|
|
222
|
-
}
|
|
223
|
-
)}
|
|
224
|
-
style={
|
|
225
|
-
{
|
|
226
|
-
"--color-bg": indicatorColor,
|
|
227
|
-
"--color-border": indicatorColor,
|
|
228
|
-
} as CSSProperties
|
|
229
|
-
}
|
|
230
|
-
/>
|
|
231
|
-
)
|
|
232
|
-
)}
|
|
233
|
-
<div
|
|
234
|
-
className={cn(
|
|
235
|
-
"flex flex-1 justify-between leading-none",
|
|
236
|
-
nestLabel ? "items-end" : "items-center"
|
|
237
|
-
)}
|
|
238
|
-
>
|
|
239
|
-
<div className="grid gap-1.5">
|
|
240
|
-
{nestLabel ? tooltipLabel : null}
|
|
241
|
-
<span className="text-muted-foreground">
|
|
242
|
-
{itemConfig?.label || item.name}
|
|
243
|
-
</span>
|
|
244
|
-
</div>
|
|
245
|
-
{item.value && (
|
|
246
|
-
<span className="font-medium font-mono text-foreground tabular-nums">
|
|
247
|
-
{item.value.toLocaleString()}
|
|
248
|
-
</span>
|
|
249
|
-
)}
|
|
250
|
-
</div>
|
|
251
|
-
</>
|
|
252
|
-
)}
|
|
253
|
-
</div>
|
|
254
|
-
);
|
|
255
|
-
})}
|
|
256
|
-
</div>
|
|
257
|
-
</div>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const ChartLegend = Legend;
|
|
262
|
-
|
|
263
|
-
function ChartLegendContent({
|
|
264
|
-
className,
|
|
265
|
-
hideIcon = false,
|
|
266
|
-
payload,
|
|
267
|
-
verticalAlign = "bottom",
|
|
268
|
-
nameKey,
|
|
269
|
-
}: ComponentProps<"div"> &
|
|
270
|
-
Pick<LegendProps, "payload" | "verticalAlign"> & {
|
|
271
|
-
hideIcon?: boolean;
|
|
272
|
-
nameKey?: string;
|
|
273
|
-
}) {
|
|
274
|
-
const { config } = useChart();
|
|
275
|
-
|
|
276
|
-
if (!payload?.length) {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
<div
|
|
282
|
-
className={cn(
|
|
283
|
-
"flex items-center justify-center gap-4",
|
|
284
|
-
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
285
|
-
className
|
|
286
|
-
)}
|
|
287
|
-
>
|
|
288
|
-
{payload
|
|
289
|
-
.filter((item) => item.type !== "none")
|
|
290
|
-
.map((item) => {
|
|
291
|
-
const key = `${nameKey || item.dataKey || "value"}`;
|
|
292
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
293
|
-
|
|
294
|
-
return (
|
|
295
|
-
<div
|
|
296
|
-
className={cn(
|
|
297
|
-
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
298
|
-
)}
|
|
299
|
-
key={item.value}
|
|
300
|
-
>
|
|
301
|
-
{itemConfig?.icon && !hideIcon ? (
|
|
302
|
-
<itemConfig.icon />
|
|
303
|
-
) : (
|
|
304
|
-
<div
|
|
305
|
-
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
306
|
-
style={{
|
|
307
|
-
backgroundColor: item.color,
|
|
308
|
-
}}
|
|
309
|
-
/>
|
|
310
|
-
)}
|
|
311
|
-
{itemConfig?.label}
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
})}
|
|
315
|
-
</div>
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function getPayloadConfigFromPayload(
|
|
320
|
-
config: ChartConfig,
|
|
321
|
-
payload: unknown,
|
|
322
|
-
key: string
|
|
323
|
-
) {
|
|
324
|
-
if (typeof payload !== "object" || payload === null) {
|
|
325
|
-
return undefined;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const payloadPayload =
|
|
329
|
-
"payload" in payload &&
|
|
330
|
-
typeof payload.payload === "object" &&
|
|
331
|
-
payload.payload !== null
|
|
332
|
-
? payload.payload
|
|
333
|
-
: undefined;
|
|
334
|
-
|
|
335
|
-
let configLabelKey: string = key;
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
key in payload &&
|
|
339
|
-
typeof payload[key as keyof typeof payload] === "string"
|
|
340
|
-
) {
|
|
341
|
-
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
342
|
-
} else if (
|
|
343
|
-
payloadPayload &&
|
|
344
|
-
key in payloadPayload &&
|
|
345
|
-
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
346
|
-
) {
|
|
347
|
-
configLabelKey = payloadPayload[
|
|
348
|
-
key as keyof typeof payloadPayload
|
|
349
|
-
] as string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return configLabelKey in config
|
|
353
|
-
? config[configLabelKey]
|
|
354
|
-
: config[key as keyof typeof config];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export {
|
|
358
|
-
ChartContainer,
|
|
359
|
-
ChartTooltip,
|
|
360
|
-
ChartTooltipContent,
|
|
361
|
-
ChartLegend,
|
|
362
|
-
ChartLegendContent,
|
|
363
|
-
ChartStyle,
|
|
364
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Tick02Icon } from "@hugeicons/core-free-icons";
|
|
2
|
-
import { HugeiconsIcon } from "@hugeicons/react";
|
|
3
|
-
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
|
4
|
-
import type * as React from "react";
|
|
5
|
-
import { cn } from "@/lib/utils";
|
|
6
|
-
|
|
7
|
-
function Checkbox({
|
|
8
|
-
className,
|
|
9
|
-
...props
|
|
10
|
-
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
11
|
-
return (
|
|
12
|
-
<CheckboxPrimitive.Root
|
|
13
|
-
className={cn(
|
|
14
|
-
"peer relative flex size-5.5 shrink-0 items-center justify-center rounded-md border border-input shadow-xs outline-none transition-shadow after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 group-has-disabled/field:opacity-50 aria-invalid:border-destructive aria-invalid:ring aria-invalid:ring-destructive aria-invalid:aria-checked:border-primary data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:bg-input/30 dark:data-checked:bg-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
15
|
-
className
|
|
16
|
-
)}
|
|
17
|
-
data-slot="checkbox"
|
|
18
|
-
{...props}
|
|
19
|
-
>
|
|
20
|
-
<CheckboxPrimitive.Indicator
|
|
21
|
-
className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
|
|
22
|
-
data-slot="checkbox-indicator"
|
|
23
|
-
>
|
|
24
|
-
<HugeiconsIcon icon={Tick02Icon} strokeWidth={2} />
|
|
25
|
-
</CheckboxPrimitive.Indicator>
|
|
26
|
-
</CheckboxPrimitive.Root>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Checkbox };
|