@cogito.ai/cli 0.3.4 → 0.4.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/dist/index.js +77 -6
- package/dist/templates/web-nextjs/apps/docs/.source/browser.ts +1 -1
- package/dist/templates/web-nextjs/apps/docs/.source/server.ts +3 -2
- package/dist/templates/web-nextjs/apps/docs/content/docs/decisions/meta.json +1 -1
- package/dist/templates/web-nextjs/apps/docs/content/docs/decisions/turbo-package-manager.mdx +70 -0
- package/dist/templates/web-nextjs/apps/docs/package.json +1 -1
- package/dist/templates/web-nextjs/apps/web/middleware.ts +6 -13
- package/dist/templates/web-nextjs/apps/web/package.json +26 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(auth)/login/page.tsx +87 -93
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(auth)/signup/page.tsx +116 -98
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(protected)/dashboard/page.tsx +38 -29
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/(protected)/layout.tsx +2 -5
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/layout.tsx +11 -8
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/privacy/page.tsx +23 -0
- package/dist/templates/web-nextjs/apps/web/src/app/[locale]/terms/page.tsx +23 -0
- package/dist/templates/web-nextjs/apps/web/src/app/route.ts +13 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/app-sidebar.tsx +188 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/chart-area-interactive.tsx +291 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/data-table.tsx +807 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/data.json +614 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/nav-documents.tsx +92 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/nav-main.tsx +58 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/nav-secondary.tsx +42 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/nav-user.tsx +118 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/page.tsx +40 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/section-cards.tsx +102 -0
- package/dist/templates/web-nextjs/apps/web/src/components/dashboard/site-header.tsx +30 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/alert-dialog.tsx +196 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/avatar.tsx +109 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/badge.tsx +48 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/breadcrumb.tsx +109 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/button.tsx +14 -2
- package/dist/templates/web-nextjs/apps/web/src/components/ui/card.tsx +92 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/chart.tsx +374 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/checkbox.tsx +32 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/collapsible.tsx +33 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/command.tsx +184 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/dialog.tsx +158 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/drawer.tsx +135 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/dropdown-menu.tsx +257 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/field.tsx +248 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/input-otp.tsx +77 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/pagination.tsx +127 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/popover.tsx +89 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/progress.tsx +31 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/radio-group.tsx +45 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/scroll-area.tsx +58 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/select.tsx +190 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/separator.tsx +29 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/sheet.tsx +143 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/sidebar.tsx +726 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/skeleton.tsx +13 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/slider.tsx +63 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/sonner.tsx +11 -25
- package/dist/templates/web-nextjs/apps/web/src/components/ui/switch.tsx +35 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/table.tsx +116 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/tabs.tsx +91 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/textarea.tsx +18 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/toggle-group.tsx +83 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/toggle.tsx +47 -0
- package/dist/templates/web-nextjs/apps/web/src/components/ui/tooltip.tsx +57 -0
- package/dist/templates/web-nextjs/apps/web/src/features/auth/server.ts +15 -0
- package/dist/templates/web-nextjs/apps/web/src/hooks/use-mobile.ts +21 -0
- package/dist/templates/web-nextjs/package.json +10 -1
- package/dist/templates/web-nextjs/packages/openspec-docs-sync/package.json +1 -3
- package/dist/templates/web-nextjs/pnpm-lock.yaml +1562 -100
- package/dist/templates/web-nextjs/pnpm-workspace.yaml +15 -0
- package/dist/templates/web-nextjs/turbo.json +1 -0
- package/package.json +2 -2
- /package/dist/templates/web-nextjs/{.env.example → apps/web/.env.example} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { Slot } from "radix-ui"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
13
|
+
secondary:
|
|
14
|
+
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
15
|
+
destructive:
|
|
16
|
+
"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
|
|
17
|
+
outline:
|
|
18
|
+
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
19
|
+
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
20
|
+
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default",
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
function Badge({
|
|
30
|
+
className,
|
|
31
|
+
variant = "default",
|
|
32
|
+
asChild = false,
|
|
33
|
+
...props
|
|
34
|
+
}: React.ComponentProps<"span"> &
|
|
35
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
36
|
+
const Comp = asChild ? Slot.Root : "span"
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Comp
|
|
40
|
+
data-slot="badge"
|
|
41
|
+
data-variant={variant}
|
|
42
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { Badge, badgeVariants }
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react"
|
|
3
|
+
import { Slot } from "radix-ui"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
|
|
8
|
+
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
|
|
12
|
+
return (
|
|
13
|
+
<ol
|
|
14
|
+
data-slot="breadcrumb-list"
|
|
15
|
+
className={cn(
|
|
16
|
+
"flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
25
|
+
return (
|
|
26
|
+
<li
|
|
27
|
+
data-slot="breadcrumb-item"
|
|
28
|
+
className={cn("inline-flex items-center gap-1.5", className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function BreadcrumbLink({
|
|
35
|
+
asChild,
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<"a"> & {
|
|
39
|
+
asChild?: boolean
|
|
40
|
+
}) {
|
|
41
|
+
const Comp = asChild ? Slot.Root : "a"
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
data-slot="breadcrumb-link"
|
|
46
|
+
className={cn("transition-colors hover:text-foreground", className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
data-slot="breadcrumb-page"
|
|
56
|
+
role="link"
|
|
57
|
+
aria-disabled="true"
|
|
58
|
+
aria-current="page"
|
|
59
|
+
className={cn("font-normal text-foreground", className)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function BreadcrumbSeparator({
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<"li">) {
|
|
70
|
+
return (
|
|
71
|
+
<li
|
|
72
|
+
data-slot="breadcrumb-separator"
|
|
73
|
+
role="presentation"
|
|
74
|
+
aria-hidden="true"
|
|
75
|
+
className={cn("[&>svg]:size-3.5", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children ?? <ChevronRight />}
|
|
79
|
+
</li>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function BreadcrumbEllipsis({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<"span">) {
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
data-slot="breadcrumb-ellipsis"
|
|
90
|
+
role="presentation"
|
|
91
|
+
aria-hidden="true"
|
|
92
|
+
className={cn("flex size-9 items-center justify-center", className)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<MoreHorizontal className="size-4" />
|
|
96
|
+
<span className="sr-only">More</span>
|
|
97
|
+
</span>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
Breadcrumb,
|
|
103
|
+
BreadcrumbList,
|
|
104
|
+
BreadcrumbItem,
|
|
105
|
+
BreadcrumbLink,
|
|
106
|
+
BreadcrumbPage,
|
|
107
|
+
BreadcrumbSeparator,
|
|
108
|
+
BreadcrumbEllipsis,
|
|
109
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Button as ButtonPrimitive } from "@base-ui/react/button"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
2
3
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
4
|
|
|
4
5
|
import { cn } from "@/lib/utils"
|
|
@@ -44,13 +45,24 @@ function Button({
|
|
|
44
45
|
className,
|
|
45
46
|
variant = "default",
|
|
46
47
|
size = "default",
|
|
48
|
+
asChild = false,
|
|
47
49
|
...props
|
|
48
|
-
}:
|
|
50
|
+
}: React.ComponentProps<"button"> &
|
|
51
|
+
VariantProps<typeof buttonVariants> & { asChild?: boolean }) {
|
|
52
|
+
if (asChild) {
|
|
53
|
+
return (
|
|
54
|
+
<Slot
|
|
55
|
+
data-slot="button"
|
|
56
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
49
61
|
return (
|
|
50
62
|
<ButtonPrimitive
|
|
51
63
|
data-slot="button"
|
|
52
64
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
53
|
-
{...props}
|
|
65
|
+
{...(props as ButtonPrimitive.Props)}
|
|
54
66
|
/>
|
|
55
67
|
)
|
|
56
68
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot="card-title"
|
|
35
|
+
className={cn("leading-none font-semibold", className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-slot="card-description"
|
|
45
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="card-action"
|
|
55
|
+
className={cn(
|
|
56
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
data-slot="card-content"
|
|
68
|
+
className={cn("px-6", className)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
data-slot="card-footer"
|
|
78
|
+
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Card,
|
|
86
|
+
CardHeader,
|
|
87
|
+
CardFooter,
|
|
88
|
+
CardTitle,
|
|
89
|
+
CardAction,
|
|
90
|
+
CardDescription,
|
|
91
|
+
CardContent,
|
|
92
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as RechartsPrimitive from "recharts"
|
|
5
|
+
import type { TooltipValueType } from "recharts"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
10
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
11
|
+
|
|
12
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const
|
|
13
|
+
type TooltipNameType = number | string
|
|
14
|
+
|
|
15
|
+
export type ChartConfig = Record<
|
|
16
|
+
string,
|
|
17
|
+
{
|
|
18
|
+
label?: React.ReactNode
|
|
19
|
+
icon?: React.ComponentType
|
|
20
|
+
} & (
|
|
21
|
+
| { color?: string; theme?: never }
|
|
22
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
23
|
+
)
|
|
24
|
+
>
|
|
25
|
+
|
|
26
|
+
type ChartContextProps = {
|
|
27
|
+
config: ChartConfig
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
31
|
+
|
|
32
|
+
function useChart() {
|
|
33
|
+
const context = React.useContext(ChartContext)
|
|
34
|
+
|
|
35
|
+
if (!context) {
|
|
36
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return context
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function ChartContainer({
|
|
43
|
+
id,
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
config,
|
|
47
|
+
initialDimension = INITIAL_DIMENSION,
|
|
48
|
+
...props
|
|
49
|
+
}: React.ComponentProps<"div"> & {
|
|
50
|
+
config: ChartConfig
|
|
51
|
+
children: React.ComponentProps<
|
|
52
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
53
|
+
>["children"]
|
|
54
|
+
initialDimension?: {
|
|
55
|
+
width: number
|
|
56
|
+
height: number
|
|
57
|
+
}
|
|
58
|
+
}) {
|
|
59
|
+
const uniqueId = React.useId()
|
|
60
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<ChartContext.Provider value={{ config }}>
|
|
64
|
+
<div
|
|
65
|
+
data-slot="chart"
|
|
66
|
+
data-chart={chartId}
|
|
67
|
+
className={cn(
|
|
68
|
+
"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",
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
<ChartStyle id={chartId} config={config} />
|
|
74
|
+
<RechartsPrimitive.ResponsiveContainer
|
|
75
|
+
initialDimension={initialDimension}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
79
|
+
</div>
|
|
80
|
+
</ChartContext.Provider>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
85
|
+
const colorConfig = Object.entries(config).filter(
|
|
86
|
+
([, config]) => config.theme ?? config.color
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if (!colorConfig.length) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<style
|
|
95
|
+
dangerouslySetInnerHTML={{
|
|
96
|
+
__html: Object.entries(THEMES)
|
|
97
|
+
.map(
|
|
98
|
+
([theme, prefix]) => `
|
|
99
|
+
${prefix} [data-chart=${id}] {
|
|
100
|
+
${colorConfig
|
|
101
|
+
.map(([key, itemConfig]) => {
|
|
102
|
+
const color =
|
|
103
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
|
104
|
+
itemConfig.color
|
|
105
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
106
|
+
})
|
|
107
|
+
.join("\n")}
|
|
108
|
+
}
|
|
109
|
+
`
|
|
110
|
+
)
|
|
111
|
+
.join("\n"),
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
118
|
+
|
|
119
|
+
function ChartTooltipContent({
|
|
120
|
+
active,
|
|
121
|
+
payload,
|
|
122
|
+
className,
|
|
123
|
+
indicator = "dot",
|
|
124
|
+
hideLabel = false,
|
|
125
|
+
hideIndicator = false,
|
|
126
|
+
label,
|
|
127
|
+
labelFormatter,
|
|
128
|
+
labelClassName,
|
|
129
|
+
formatter,
|
|
130
|
+
color,
|
|
131
|
+
nameKey,
|
|
132
|
+
labelKey,
|
|
133
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
134
|
+
React.ComponentProps<"div"> & {
|
|
135
|
+
hideLabel?: boolean
|
|
136
|
+
hideIndicator?: boolean
|
|
137
|
+
indicator?: "line" | "dot" | "dashed"
|
|
138
|
+
nameKey?: string
|
|
139
|
+
labelKey?: string
|
|
140
|
+
} & Omit<
|
|
141
|
+
RechartsPrimitive.DefaultTooltipContentProps<
|
|
142
|
+
TooltipValueType,
|
|
143
|
+
TooltipNameType
|
|
144
|
+
>,
|
|
145
|
+
"accessibilityLayer"
|
|
146
|
+
>) {
|
|
147
|
+
const { config } = useChart()
|
|
148
|
+
|
|
149
|
+
const tooltipLabel = React.useMemo(() => {
|
|
150
|
+
if (hideLabel || !payload?.length) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const [item] = payload
|
|
155
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`
|
|
156
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
157
|
+
const value =
|
|
158
|
+
!labelKey && typeof label === "string"
|
|
159
|
+
? (config[label]?.label ?? label)
|
|
160
|
+
: itemConfig?.label
|
|
161
|
+
|
|
162
|
+
if (labelFormatter) {
|
|
163
|
+
return (
|
|
164
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
165
|
+
{labelFormatter(value, payload)}
|
|
166
|
+
</div>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!value) {
|
|
171
|
+
return null
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
175
|
+
}, [
|
|
176
|
+
label,
|
|
177
|
+
labelFormatter,
|
|
178
|
+
payload,
|
|
179
|
+
hideLabel,
|
|
180
|
+
labelClassName,
|
|
181
|
+
config,
|
|
182
|
+
labelKey,
|
|
183
|
+
])
|
|
184
|
+
|
|
185
|
+
if (!active || !payload?.length) {
|
|
186
|
+
return null
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<div
|
|
193
|
+
className={cn(
|
|
194
|
+
"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",
|
|
195
|
+
className
|
|
196
|
+
)}
|
|
197
|
+
>
|
|
198
|
+
{!nestLabel ? tooltipLabel : null}
|
|
199
|
+
<div className="grid gap-1.5">
|
|
200
|
+
{payload
|
|
201
|
+
.filter((item) => item.type !== "none")
|
|
202
|
+
.map((item, index) => {
|
|
203
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`
|
|
204
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
205
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<div
|
|
209
|
+
key={index}
|
|
210
|
+
className={cn(
|
|
211
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
212
|
+
indicator === "dot" && "items-center"
|
|
213
|
+
)}
|
|
214
|
+
>
|
|
215
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
216
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
217
|
+
) : (
|
|
218
|
+
<>
|
|
219
|
+
{itemConfig?.icon ? (
|
|
220
|
+
<itemConfig.icon />
|
|
221
|
+
) : (
|
|
222
|
+
!hideIndicator && (
|
|
223
|
+
<div
|
|
224
|
+
className={cn(
|
|
225
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
226
|
+
{
|
|
227
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
228
|
+
"w-1": indicator === "line",
|
|
229
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
230
|
+
indicator === "dashed",
|
|
231
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
232
|
+
}
|
|
233
|
+
)}
|
|
234
|
+
style={
|
|
235
|
+
{
|
|
236
|
+
"--color-bg": indicatorColor,
|
|
237
|
+
"--color-border": indicatorColor,
|
|
238
|
+
} as React.CSSProperties
|
|
239
|
+
}
|
|
240
|
+
/>
|
|
241
|
+
)
|
|
242
|
+
)}
|
|
243
|
+
<div
|
|
244
|
+
className={cn(
|
|
245
|
+
"flex flex-1 justify-between leading-none",
|
|
246
|
+
nestLabel ? "items-end" : "items-center"
|
|
247
|
+
)}
|
|
248
|
+
>
|
|
249
|
+
<div className="grid gap-1.5">
|
|
250
|
+
{nestLabel ? tooltipLabel : null}
|
|
251
|
+
<span className="text-muted-foreground">
|
|
252
|
+
{itemConfig?.label ?? item.name}
|
|
253
|
+
</span>
|
|
254
|
+
</div>
|
|
255
|
+
{item.value != null && (
|
|
256
|
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
257
|
+
{typeof item.value === "number"
|
|
258
|
+
? item.value.toLocaleString()
|
|
259
|
+
: String(item.value)}
|
|
260
|
+
</span>
|
|
261
|
+
)}
|
|
262
|
+
</div>
|
|
263
|
+
</>
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
)
|
|
267
|
+
})}
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
274
|
+
|
|
275
|
+
function ChartLegendContent({
|
|
276
|
+
className,
|
|
277
|
+
hideIcon = false,
|
|
278
|
+
payload,
|
|
279
|
+
verticalAlign = "bottom",
|
|
280
|
+
nameKey,
|
|
281
|
+
}: React.ComponentProps<"div"> & {
|
|
282
|
+
hideIcon?: boolean
|
|
283
|
+
nameKey?: string
|
|
284
|
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
285
|
+
const { config } = useChart()
|
|
286
|
+
|
|
287
|
+
if (!payload?.length) {
|
|
288
|
+
return null
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return (
|
|
292
|
+
<div
|
|
293
|
+
className={cn(
|
|
294
|
+
"flex items-center justify-center gap-4",
|
|
295
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
296
|
+
className
|
|
297
|
+
)}
|
|
298
|
+
>
|
|
299
|
+
{payload
|
|
300
|
+
.filter((item) => item.type !== "none")
|
|
301
|
+
.map((item, index) => {
|
|
302
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`
|
|
303
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<div
|
|
307
|
+
key={index}
|
|
308
|
+
className={cn(
|
|
309
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
310
|
+
)}
|
|
311
|
+
>
|
|
312
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
313
|
+
<itemConfig.icon />
|
|
314
|
+
) : (
|
|
315
|
+
<div
|
|
316
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
317
|
+
style={{
|
|
318
|
+
backgroundColor: item.color,
|
|
319
|
+
}}
|
|
320
|
+
/>
|
|
321
|
+
)}
|
|
322
|
+
{itemConfig?.label}
|
|
323
|
+
</div>
|
|
324
|
+
)
|
|
325
|
+
})}
|
|
326
|
+
</div>
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Helper to extract item config from a payload.
|
|
331
|
+
function getPayloadConfigFromPayload(
|
|
332
|
+
config: ChartConfig,
|
|
333
|
+
payload: unknown,
|
|
334
|
+
key: string
|
|
335
|
+
) {
|
|
336
|
+
if (typeof payload !== "object" || payload === null) {
|
|
337
|
+
return undefined
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const payloadPayload =
|
|
341
|
+
"payload" in payload &&
|
|
342
|
+
typeof payload.payload === "object" &&
|
|
343
|
+
payload.payload !== null
|
|
344
|
+
? payload.payload
|
|
345
|
+
: undefined
|
|
346
|
+
|
|
347
|
+
let configLabelKey: string = key
|
|
348
|
+
|
|
349
|
+
if (
|
|
350
|
+
key in payload &&
|
|
351
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
352
|
+
) {
|
|
353
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
354
|
+
} else if (
|
|
355
|
+
payloadPayload &&
|
|
356
|
+
key in payloadPayload &&
|
|
357
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
358
|
+
) {
|
|
359
|
+
configLabelKey = payloadPayload[
|
|
360
|
+
key as keyof typeof payloadPayload
|
|
361
|
+
] as string
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return configLabelKey in config ? config[configLabelKey] : config[key]
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export {
|
|
368
|
+
ChartContainer,
|
|
369
|
+
ChartTooltip,
|
|
370
|
+
ChartTooltipContent,
|
|
371
|
+
ChartLegend,
|
|
372
|
+
ChartLegendContent,
|
|
373
|
+
ChartStyle,
|
|
374
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { CheckIcon } from "lucide-react"
|
|
5
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
function Checkbox({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<CheckboxPrimitive.Root
|
|
15
|
+
data-slot="checkbox"
|
|
16
|
+
className={cn(
|
|
17
|
+
"peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<CheckboxPrimitive.Indicator
|
|
23
|
+
data-slot="checkbox-indicator"
|
|
24
|
+
className="grid place-content-center text-current transition-none"
|
|
25
|
+
>
|
|
26
|
+
<CheckIcon className="size-3.5" />
|
|
27
|
+
</CheckboxPrimitive.Indicator>
|
|
28
|
+
</CheckboxPrimitive.Root>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Checkbox }
|