@getjack/jack 0.1.32 → 0.1.33
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 +1 -1
- package/src/commands/deploys.ts +95 -0
- package/src/commands/link.ts +8 -0
- package/src/commands/mcp.ts +179 -4
- package/src/commands/rollback.ts +53 -0
- package/src/commands/services.ts +11 -1
- package/src/commands/ship.ts +3 -1
- package/src/commands/tokens.ts +16 -1
- package/src/commands/whoami.ts +43 -8
- package/src/index.ts +16 -0
- package/src/lib/agent-files.ts +54 -4
- package/src/lib/agent-integration.ts +4 -166
- package/src/lib/claude-hooks-installer.ts +55 -0
- package/src/lib/control-plane.ts +78 -40
- package/src/lib/debug.ts +2 -1
- package/src/lib/deploy-upload.ts +6 -0
- package/src/lib/hooks.ts +3 -1
- package/src/lib/managed-deploy.ts +12 -9
- package/src/lib/project-link.ts +6 -0
- package/src/lib/project-operations.ts +68 -22
- package/src/lib/telemetry.ts +2 -0
- package/src/mcp/README.md +1 -1
- package/src/mcp/resources/index.ts +1 -16
- package/src/mcp/server.ts +23 -0
- package/src/mcp/tools/index.ts +133 -17
- package/src/mcp/types.ts +1 -0
- package/src/mcp/utils.ts +2 -1
- package/src/templates/index.ts +25 -73
- package/templates/CLAUDE.md +41 -0
- package/templates/ai-chat/.jack.json +10 -5
- package/templates/ai-chat/bun.lock +50 -1
- package/templates/ai-chat/package.json +5 -0
- package/templates/ai-chat/public/app.js +73 -0
- package/templates/ai-chat/public/index.html +14 -197
- package/templates/ai-chat/schema.sql +14 -0
- package/templates/ai-chat/src/index.ts +86 -102
- package/templates/ai-chat/wrangler.jsonc +8 -1
- package/templates/cron/.jack.json +66 -0
- package/templates/cron/bun.lock +23 -0
- package/templates/cron/package.json +16 -0
- package/templates/cron/schema.sql +24 -0
- package/templates/cron/src/index.ts +117 -0
- package/templates/cron/src/jobs.ts +139 -0
- package/templates/cron/src/webhooks.ts +95 -0
- package/templates/cron/tsconfig.json +17 -0
- package/templates/cron/wrangler.jsonc +11 -0
- package/templates/miniapp/.jack.json +1 -1
- package/templates/nextjs/.jack.json +1 -1
- package/templates/nextjs-auth/.jack.json +44 -0
- package/templates/nextjs-auth/app/api/auth/[...all]/route.ts +11 -0
- package/templates/nextjs-auth/app/dashboard/loading.tsx +53 -0
- package/templates/nextjs-auth/app/dashboard/page.tsx +73 -0
- package/templates/nextjs-auth/app/error.tsx +44 -0
- package/templates/nextjs-auth/app/globals.css +1 -0
- package/templates/nextjs-auth/app/health/route.ts +3 -0
- package/templates/nextjs-auth/app/layout.tsx +24 -0
- package/templates/nextjs-auth/app/login/page.tsx +10 -0
- package/templates/nextjs-auth/app/page.tsx +86 -0
- package/templates/nextjs-auth/app/signup/page.tsx +10 -0
- package/templates/nextjs-auth/bun.lock +1065 -0
- package/templates/nextjs-auth/cloudflare-env.d.ts +8 -0
- package/templates/nextjs-auth/components/auth-form.tsx +191 -0
- package/templates/nextjs-auth/components/header.tsx +50 -0
- package/templates/nextjs-auth/components/user-menu.tsx +23 -0
- package/templates/nextjs-auth/lib/auth-client.ts +3 -0
- package/templates/nextjs-auth/lib/auth.ts +43 -0
- package/templates/nextjs-auth/lib/utils.ts +6 -0
- package/templates/nextjs-auth/middleware.ts +33 -0
- package/templates/nextjs-auth/next.config.ts +8 -0
- package/templates/nextjs-auth/open-next.config.ts +6 -0
- package/templates/nextjs-auth/package.json +33 -0
- package/templates/nextjs-auth/postcss.config.mjs +8 -0
- package/templates/nextjs-auth/schema.sql +49 -0
- package/templates/nextjs-auth/tsconfig.json +28 -0
- package/templates/nextjs-auth/wrangler.jsonc +23 -0
- package/templates/nextjs-clerk/.jack.json +54 -0
- package/templates/nextjs-clerk/app/dashboard/page.tsx +69 -0
- package/templates/nextjs-clerk/app/globals.css +1 -0
- package/templates/nextjs-clerk/app/health/route.ts +3 -0
- package/templates/nextjs-clerk/app/layout.tsx +26 -0
- package/templates/nextjs-clerk/app/page.tsx +86 -0
- package/templates/nextjs-clerk/app/sign-in/[[...sign-in]]/page.tsx +9 -0
- package/templates/nextjs-clerk/app/sign-up/[[...sign-up]]/page.tsx +9 -0
- package/templates/nextjs-clerk/bun.lock +1055 -0
- package/templates/nextjs-clerk/cloudflare-env.d.ts +3 -0
- package/templates/nextjs-clerk/components/header.tsx +40 -0
- package/templates/nextjs-clerk/lib/utils.ts +6 -0
- package/templates/nextjs-clerk/middleware.ts +18 -0
- package/templates/nextjs-clerk/next.config.ts +8 -0
- package/templates/nextjs-clerk/open-next.config.ts +6 -0
- package/templates/nextjs-clerk/package.json +31 -0
- package/templates/nextjs-clerk/postcss.config.mjs +8 -0
- package/templates/nextjs-clerk/tsconfig.json +28 -0
- package/templates/nextjs-clerk/wrangler.jsonc +17 -0
- package/templates/nextjs-shadcn/.jack.json +34 -0
- package/templates/nextjs-shadcn/app/dashboard/data.json +614 -0
- package/templates/nextjs-shadcn/app/dashboard/page.tsx +55 -0
- package/templates/nextjs-shadcn/app/globals.css +126 -0
- package/templates/nextjs-shadcn/app/health/route.ts +3 -0
- package/templates/nextjs-shadcn/app/layout.tsx +24 -0
- package/templates/nextjs-shadcn/app/login/page.tsx +19 -0
- package/templates/nextjs-shadcn/app/page.tsx +180 -0
- package/templates/nextjs-shadcn/app/showcase.tsx +1262 -0
- package/templates/nextjs-shadcn/bun.lock +1789 -0
- package/templates/nextjs-shadcn/cloudflare-env.d.ts +4 -0
- package/templates/nextjs-shadcn/components/app-sidebar.tsx +175 -0
- package/templates/nextjs-shadcn/components/chart-area-interactive.tsx +291 -0
- package/templates/nextjs-shadcn/components/data-table.tsx +807 -0
- package/templates/nextjs-shadcn/components/login-form.tsx +95 -0
- package/templates/nextjs-shadcn/components/nav-documents.tsx +92 -0
- package/templates/nextjs-shadcn/components/nav-main.tsx +73 -0
- package/templates/nextjs-shadcn/components/nav-projects.tsx +89 -0
- package/templates/nextjs-shadcn/components/nav-secondary.tsx +42 -0
- package/templates/nextjs-shadcn/components/nav-user.tsx +114 -0
- package/templates/nextjs-shadcn/components/section-cards.tsx +102 -0
- package/templates/nextjs-shadcn/components/site-header.tsx +30 -0
- package/templates/nextjs-shadcn/components/team-switcher.tsx +91 -0
- package/templates/nextjs-shadcn/components/ui/accordion.tsx +66 -0
- package/templates/nextjs-shadcn/components/ui/alert-dialog.tsx +196 -0
- package/templates/nextjs-shadcn/components/ui/alert.tsx +66 -0
- package/templates/nextjs-shadcn/components/ui/aspect-ratio.tsx +11 -0
- package/templates/nextjs-shadcn/components/ui/avatar.tsx +109 -0
- package/templates/nextjs-shadcn/components/ui/badge.tsx +48 -0
- package/templates/nextjs-shadcn/components/ui/breadcrumb.tsx +109 -0
- package/templates/nextjs-shadcn/components/ui/button-group.tsx +83 -0
- package/templates/nextjs-shadcn/components/ui/button.tsx +64 -0
- package/templates/nextjs-shadcn/components/ui/calendar.tsx +220 -0
- package/templates/nextjs-shadcn/components/ui/card.tsx +92 -0
- package/templates/nextjs-shadcn/components/ui/carousel.tsx +241 -0
- package/templates/nextjs-shadcn/components/ui/chart.tsx +357 -0
- package/templates/nextjs-shadcn/components/ui/checkbox.tsx +32 -0
- package/templates/nextjs-shadcn/components/ui/collapsible.tsx +33 -0
- package/templates/nextjs-shadcn/components/ui/combobox.tsx +310 -0
- package/templates/nextjs-shadcn/components/ui/command.tsx +184 -0
- package/templates/nextjs-shadcn/components/ui/context-menu.tsx +252 -0
- package/templates/nextjs-shadcn/components/ui/dialog.tsx +158 -0
- package/templates/nextjs-shadcn/components/ui/direction.tsx +22 -0
- package/templates/nextjs-shadcn/components/ui/drawer.tsx +135 -0
- package/templates/nextjs-shadcn/components/ui/dropdown-menu.tsx +257 -0
- package/templates/nextjs-shadcn/components/ui/empty.tsx +104 -0
- package/templates/nextjs-shadcn/components/ui/field.tsx +248 -0
- package/templates/nextjs-shadcn/components/ui/form.tsx +167 -0
- package/templates/nextjs-shadcn/components/ui/hover-card.tsx +44 -0
- package/templates/nextjs-shadcn/components/ui/input-group.tsx +170 -0
- package/templates/nextjs-shadcn/components/ui/input-otp.tsx +77 -0
- package/templates/nextjs-shadcn/components/ui/input.tsx +21 -0
- package/templates/nextjs-shadcn/components/ui/item.tsx +193 -0
- package/templates/nextjs-shadcn/components/ui/kbd.tsx +28 -0
- package/templates/nextjs-shadcn/components/ui/label.tsx +24 -0
- package/templates/nextjs-shadcn/components/ui/menubar.tsx +276 -0
- package/templates/nextjs-shadcn/components/ui/native-select.tsx +53 -0
- package/templates/nextjs-shadcn/components/ui/navigation-menu.tsx +168 -0
- package/templates/nextjs-shadcn/components/ui/pagination.tsx +127 -0
- package/templates/nextjs-shadcn/components/ui/popover.tsx +89 -0
- package/templates/nextjs-shadcn/components/ui/progress.tsx +31 -0
- package/templates/nextjs-shadcn/components/ui/radio-group.tsx +45 -0
- package/templates/nextjs-shadcn/components/ui/resizable.tsx +53 -0
- package/templates/nextjs-shadcn/components/ui/scroll-area.tsx +58 -0
- package/templates/nextjs-shadcn/components/ui/select.tsx +190 -0
- package/templates/nextjs-shadcn/components/ui/separator.tsx +28 -0
- package/templates/nextjs-shadcn/components/ui/sheet.tsx +143 -0
- package/templates/nextjs-shadcn/components/ui/sidebar.tsx +726 -0
- package/templates/nextjs-shadcn/components/ui/skeleton.tsx +13 -0
- package/templates/nextjs-shadcn/components/ui/slider.tsx +63 -0
- package/templates/nextjs-shadcn/components/ui/sonner.tsx +40 -0
- package/templates/nextjs-shadcn/components/ui/spinner.tsx +16 -0
- package/templates/nextjs-shadcn/components/ui/switch.tsx +35 -0
- package/templates/nextjs-shadcn/components/ui/table.tsx +116 -0
- package/templates/nextjs-shadcn/components/ui/tabs.tsx +91 -0
- package/templates/nextjs-shadcn/components/ui/textarea.tsx +18 -0
- package/templates/nextjs-shadcn/components/ui/toggle-group.tsx +83 -0
- package/templates/nextjs-shadcn/components/ui/toggle.tsx +47 -0
- package/templates/nextjs-shadcn/components/ui/tooltip.tsx +57 -0
- package/templates/nextjs-shadcn/components.json +23 -0
- package/templates/nextjs-shadcn/hooks/use-mobile.ts +19 -0
- package/templates/nextjs-shadcn/lib/utils.ts +6 -0
- package/templates/nextjs-shadcn/next-env.d.ts +6 -0
- package/templates/nextjs-shadcn/next.config.ts +8 -0
- package/templates/nextjs-shadcn/open-next.config.ts +6 -0
- package/templates/nextjs-shadcn/package.json +55 -0
- package/templates/nextjs-shadcn/postcss.config.mjs +8 -0
- package/templates/nextjs-shadcn/tsconfig.json +28 -0
- package/templates/nextjs-shadcn/wrangler.jsonc +23 -0
- package/templates/resend/.jack.json +64 -0
- package/templates/resend/bun.lock +23 -0
- package/templates/resend/package.json +16 -0
- package/templates/resend/schema.sql +13 -0
- package/templates/resend/src/email.ts +165 -0
- package/templates/resend/src/index.ts +108 -0
- package/templates/resend/tsconfig.json +17 -0
- package/templates/resend/wrangler.jsonc +11 -0
- package/templates/saas/.jack.json +1 -1
- package/templates/ai-chat/public/chat.js +0 -149
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as RechartsPrimitive from "recharts"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
9
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
10
|
+
|
|
11
|
+
export type ChartConfig = {
|
|
12
|
+
[k in string]: {
|
|
13
|
+
label?: React.ReactNode
|
|
14
|
+
icon?: React.ComponentType
|
|
15
|
+
} & (
|
|
16
|
+
| { color?: string; theme?: never }
|
|
17
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ChartContextProps = {
|
|
22
|
+
config: ChartConfig
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
26
|
+
|
|
27
|
+
function useChart() {
|
|
28
|
+
const context = React.useContext(ChartContext)
|
|
29
|
+
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return context
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function ChartContainer({
|
|
38
|
+
id,
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
config,
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<"div"> & {
|
|
44
|
+
config: ChartConfig
|
|
45
|
+
children: React.ComponentProps<
|
|
46
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
47
|
+
>["children"]
|
|
48
|
+
}) {
|
|
49
|
+
const uniqueId = React.useId()
|
|
50
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<ChartContext.Provider value={{ config }}>
|
|
54
|
+
<div
|
|
55
|
+
data-slot="chart"
|
|
56
|
+
data-chart={chartId}
|
|
57
|
+
className={cn(
|
|
58
|
+
"[&_.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-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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
<ChartStyle id={chartId} config={config} />
|
|
64
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
65
|
+
{children}
|
|
66
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
67
|
+
</div>
|
|
68
|
+
</ChartContext.Provider>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
73
|
+
const colorConfig = Object.entries(config).filter(
|
|
74
|
+
([, config]) => config.theme || config.color
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if (!colorConfig.length) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<style
|
|
83
|
+
dangerouslySetInnerHTML={{
|
|
84
|
+
__html: Object.entries(THEMES)
|
|
85
|
+
.map(
|
|
86
|
+
([theme, prefix]) => `
|
|
87
|
+
${prefix} [data-chart=${id}] {
|
|
88
|
+
${colorConfig
|
|
89
|
+
.map(([key, itemConfig]) => {
|
|
90
|
+
const color =
|
|
91
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
92
|
+
itemConfig.color
|
|
93
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
94
|
+
})
|
|
95
|
+
.join("\n")}
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
)
|
|
99
|
+
.join("\n"),
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
106
|
+
|
|
107
|
+
function ChartTooltipContent({
|
|
108
|
+
active,
|
|
109
|
+
payload,
|
|
110
|
+
className,
|
|
111
|
+
indicator = "dot",
|
|
112
|
+
hideLabel = false,
|
|
113
|
+
hideIndicator = false,
|
|
114
|
+
label,
|
|
115
|
+
labelFormatter,
|
|
116
|
+
labelClassName,
|
|
117
|
+
formatter,
|
|
118
|
+
color,
|
|
119
|
+
nameKey,
|
|
120
|
+
labelKey,
|
|
121
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
122
|
+
React.ComponentProps<"div"> & {
|
|
123
|
+
hideLabel?: boolean
|
|
124
|
+
hideIndicator?: boolean
|
|
125
|
+
indicator?: "line" | "dot" | "dashed"
|
|
126
|
+
nameKey?: string
|
|
127
|
+
labelKey?: string
|
|
128
|
+
}) {
|
|
129
|
+
const { config } = useChart()
|
|
130
|
+
|
|
131
|
+
const tooltipLabel = React.useMemo(() => {
|
|
132
|
+
if (hideLabel || !payload?.length) {
|
|
133
|
+
return null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const [item] = payload
|
|
137
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
|
138
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
139
|
+
const value =
|
|
140
|
+
!labelKey && typeof label === "string"
|
|
141
|
+
? config[label as keyof typeof config]?.label || label
|
|
142
|
+
: itemConfig?.label
|
|
143
|
+
|
|
144
|
+
if (labelFormatter) {
|
|
145
|
+
return (
|
|
146
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
147
|
+
{labelFormatter(value, payload)}
|
|
148
|
+
</div>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!value) {
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
157
|
+
}, [
|
|
158
|
+
label,
|
|
159
|
+
labelFormatter,
|
|
160
|
+
payload,
|
|
161
|
+
hideLabel,
|
|
162
|
+
labelClassName,
|
|
163
|
+
config,
|
|
164
|
+
labelKey,
|
|
165
|
+
])
|
|
166
|
+
|
|
167
|
+
if (!active || !payload?.length) {
|
|
168
|
+
return null
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div
|
|
175
|
+
className={cn(
|
|
176
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
177
|
+
className
|
|
178
|
+
)}
|
|
179
|
+
>
|
|
180
|
+
{!nestLabel ? tooltipLabel : null}
|
|
181
|
+
<div className="grid gap-1.5">
|
|
182
|
+
{payload
|
|
183
|
+
.filter((item) => item.type !== "none")
|
|
184
|
+
.map((item, index) => {
|
|
185
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`
|
|
186
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
187
|
+
const indicatorColor = color || item.payload.fill || item.color
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div
|
|
191
|
+
key={item.dataKey}
|
|
192
|
+
className={cn(
|
|
193
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
194
|
+
indicator === "dot" && "items-center"
|
|
195
|
+
)}
|
|
196
|
+
>
|
|
197
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
198
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
199
|
+
) : (
|
|
200
|
+
<>
|
|
201
|
+
{itemConfig?.icon ? (
|
|
202
|
+
<itemConfig.icon />
|
|
203
|
+
) : (
|
|
204
|
+
!hideIndicator && (
|
|
205
|
+
<div
|
|
206
|
+
className={cn(
|
|
207
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
208
|
+
{
|
|
209
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
210
|
+
"w-1": indicator === "line",
|
|
211
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
212
|
+
indicator === "dashed",
|
|
213
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
214
|
+
}
|
|
215
|
+
)}
|
|
216
|
+
style={
|
|
217
|
+
{
|
|
218
|
+
"--color-bg": indicatorColor,
|
|
219
|
+
"--color-border": indicatorColor,
|
|
220
|
+
} as React.CSSProperties
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
)
|
|
224
|
+
)}
|
|
225
|
+
<div
|
|
226
|
+
className={cn(
|
|
227
|
+
"flex flex-1 justify-between leading-none",
|
|
228
|
+
nestLabel ? "items-end" : "items-center"
|
|
229
|
+
)}
|
|
230
|
+
>
|
|
231
|
+
<div className="grid gap-1.5">
|
|
232
|
+
{nestLabel ? tooltipLabel : null}
|
|
233
|
+
<span className="text-muted-foreground">
|
|
234
|
+
{itemConfig?.label || item.name}
|
|
235
|
+
</span>
|
|
236
|
+
</div>
|
|
237
|
+
{item.value && (
|
|
238
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
239
|
+
{item.value.toLocaleString()}
|
|
240
|
+
</span>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
</>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
})}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
254
|
+
|
|
255
|
+
function ChartLegendContent({
|
|
256
|
+
className,
|
|
257
|
+
hideIcon = false,
|
|
258
|
+
payload,
|
|
259
|
+
verticalAlign = "bottom",
|
|
260
|
+
nameKey,
|
|
261
|
+
}: React.ComponentProps<"div"> &
|
|
262
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
263
|
+
hideIcon?: boolean
|
|
264
|
+
nameKey?: string
|
|
265
|
+
}) {
|
|
266
|
+
const { config } = useChart()
|
|
267
|
+
|
|
268
|
+
if (!payload?.length) {
|
|
269
|
+
return null
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<div
|
|
274
|
+
className={cn(
|
|
275
|
+
"flex items-center justify-center gap-4",
|
|
276
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
277
|
+
className
|
|
278
|
+
)}
|
|
279
|
+
>
|
|
280
|
+
{payload
|
|
281
|
+
.filter((item) => item.type !== "none")
|
|
282
|
+
.map((item) => {
|
|
283
|
+
const key = `${nameKey || item.dataKey || "value"}`
|
|
284
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<div
|
|
288
|
+
key={item.value}
|
|
289
|
+
className={cn(
|
|
290
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
291
|
+
)}
|
|
292
|
+
>
|
|
293
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
294
|
+
<itemConfig.icon />
|
|
295
|
+
) : (
|
|
296
|
+
<div
|
|
297
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
298
|
+
style={{
|
|
299
|
+
backgroundColor: item.color,
|
|
300
|
+
}}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
303
|
+
{itemConfig?.label}
|
|
304
|
+
</div>
|
|
305
|
+
)
|
|
306
|
+
})}
|
|
307
|
+
</div>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Helper to extract item config from a payload.
|
|
312
|
+
function getPayloadConfigFromPayload(
|
|
313
|
+
config: ChartConfig,
|
|
314
|
+
payload: unknown,
|
|
315
|
+
key: string
|
|
316
|
+
) {
|
|
317
|
+
if (typeof payload !== "object" || payload === null) {
|
|
318
|
+
return undefined
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const payloadPayload =
|
|
322
|
+
"payload" in payload &&
|
|
323
|
+
typeof payload.payload === "object" &&
|
|
324
|
+
payload.payload !== null
|
|
325
|
+
? payload.payload
|
|
326
|
+
: undefined
|
|
327
|
+
|
|
328
|
+
let configLabelKey: string = key
|
|
329
|
+
|
|
330
|
+
if (
|
|
331
|
+
key in payload &&
|
|
332
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
333
|
+
) {
|
|
334
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
335
|
+
} else if (
|
|
336
|
+
payloadPayload &&
|
|
337
|
+
key in payloadPayload &&
|
|
338
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
339
|
+
) {
|
|
340
|
+
configLabelKey = payloadPayload[
|
|
341
|
+
key as keyof typeof payloadPayload
|
|
342
|
+
] as string
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return configLabelKey in config
|
|
346
|
+
? config[configLabelKey]
|
|
347
|
+
: config[key as keyof typeof config]
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export {
|
|
351
|
+
ChartContainer,
|
|
352
|
+
ChartTooltip,
|
|
353
|
+
ChartTooltipContent,
|
|
354
|
+
ChartLegend,
|
|
355
|
+
ChartLegendContent,
|
|
356
|
+
ChartStyle,
|
|
357
|
+
}
|
|
@@ -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 border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
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 }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "radix-ui"
|
|
4
|
+
|
|
5
|
+
function Collapsible({
|
|
6
|
+
...props
|
|
7
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
8
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function CollapsibleTrigger({
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
14
|
+
return (
|
|
15
|
+
<CollapsiblePrimitive.CollapsibleTrigger
|
|
16
|
+
data-slot="collapsible-trigger"
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function CollapsibleContent({
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
25
|
+
return (
|
|
26
|
+
<CollapsiblePrimitive.CollapsibleContent
|
|
27
|
+
data-slot="collapsible-content"
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|