@helloleo/plugins 0.2.12 → 0.2.13
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 +2 -2
- package/dist/templates/tanstack-start-2026-07-30/components.json +22 -0
- package/dist/templates/tanstack-start-2026-07-30/drizzle/0000_tidy_kang.sql +5 -0
- package/dist/templates/tanstack-start-2026-07-30/drizzle/meta/0000_snapshot.json +50 -0
- package/dist/templates/tanstack-start-2026-07-30/drizzle/meta/_journal.json +13 -0
- package/dist/templates/tanstack-start-2026-07-30/drizzle.config.ts +18 -0
- package/dist/templates/tanstack-start-2026-07-30/package.json +103 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/error-component.tsx +47 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/accordion.tsx +51 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/alert-dialog.tsx +115 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/alert.tsx +49 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/aspect-ratio.tsx +5 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/avatar.tsx +47 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/badge.tsx +32 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/breadcrumb.tsx +101 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/button.tsx +49 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/calendar.tsx +177 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/card.tsx +55 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/carousel.tsx +240 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/chart.tsx +371 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/checkbox.tsx +26 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/collapsible.tsx +11 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/command.tsx +143 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/context-menu.tsx +187 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/dialog.tsx +104 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/drawer.tsx +98 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/dropdown-menu.tsx +188 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/form.tsx +171 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/hover-card.tsx +27 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/input-otp.tsx +69 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/input.tsx +22 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/label.tsx +21 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/menubar.tsx +229 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/navigation-menu.tsx +120 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/pagination.tsx +98 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/popover.tsx +31 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/progress.tsx +25 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/radio-group.tsx +36 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/resizable.tsx +37 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/scroll-area.tsx +44 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/select.tsx +152 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/separator.tsx +24 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/sheet.tsx +122 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/sidebar.tsx +744 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/skeleton.tsx +7 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/slider.tsx +23 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/sonner.tsx +23 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/switch.tsx +27 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/table.tsx +94 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/tabs.tsx +53 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/textarea.tsx +21 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/toggle-group.tsx +57 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/toggle.tsx +42 -0
- package/dist/templates/tanstack-start-2026-07-30/src/components/ui/tooltip.tsx +32 -0
- package/dist/templates/tanstack-start-2026-07-30/src/db/index.ts +9 -0
- package/dist/templates/tanstack-start-2026-07-30/src/db/schema.ts +18 -0
- package/dist/templates/tanstack-start-2026-07-30/src/global.d.ts +3 -0
- package/dist/templates/tanstack-start-2026-07-30/src/hooks/use-mobile.tsx +19 -0
- package/dist/templates/tanstack-start-2026-07-30/src/lib/proxy.ts +82 -0
- package/dist/templates/tanstack-start-2026-07-30/src/lib/utils.ts +6 -0
- package/dist/templates/tanstack-start-2026-07-30/src/routeTree.gen.ts +86 -0
- package/dist/templates/tanstack-start-2026-07-30/src/router.tsx +37 -0
- package/dist/templates/tanstack-start-2026-07-30/src/routes/README.md +94 -0
- package/dist/templates/tanstack-start-2026-07-30/src/routes/__root.tsx +65 -0
- package/dist/templates/tanstack-start-2026-07-30/src/routes/api/health.ts +81 -0
- package/dist/templates/tanstack-start-2026-07-30/src/routes/index.tsx +33 -0
- package/dist/templates/tanstack-start-2026-07-30/src/server.ts +32 -0
- package/dist/templates/tanstack-start-2026-07-30/src/styles.css +214 -0
- package/dist/templates/tanstack-start-2026-07-30/tsconfig.json +27 -0
- package/dist/templates/tanstack-start-2026-07-30/vite.config.ts +17 -0
- package/package.json +1 -1
- package/src/templates/tanstack-start-2026-07-30/components.json +22 -0
- package/src/templates/tanstack-start-2026-07-30/drizzle/0000_tidy_kang.sql +5 -0
- package/src/templates/tanstack-start-2026-07-30/drizzle/meta/0000_snapshot.json +50 -0
- package/src/templates/tanstack-start-2026-07-30/drizzle/meta/_journal.json +13 -0
- package/src/templates/tanstack-start-2026-07-30/drizzle.config.ts +18 -0
- package/src/templates/tanstack-start-2026-07-30/package.json +103 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/error-component.tsx +47 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/accordion.tsx +51 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/alert-dialog.tsx +115 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/alert.tsx +49 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/avatar.tsx +47 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/badge.tsx +32 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/breadcrumb.tsx +101 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/button.tsx +49 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/calendar.tsx +177 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/card.tsx +55 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/carousel.tsx +240 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/chart.tsx +371 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/checkbox.tsx +26 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/collapsible.tsx +11 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/command.tsx +143 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/context-menu.tsx +187 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/dialog.tsx +104 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/drawer.tsx +98 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/dropdown-menu.tsx +188 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/form.tsx +171 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/hover-card.tsx +27 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/input-otp.tsx +69 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/input.tsx +22 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/label.tsx +21 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/menubar.tsx +229 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/navigation-menu.tsx +120 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/pagination.tsx +98 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/popover.tsx +31 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/progress.tsx +25 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/radio-group.tsx +36 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/resizable.tsx +37 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/scroll-area.tsx +44 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/select.tsx +152 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/separator.tsx +24 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/sheet.tsx +122 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/sidebar.tsx +744 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/skeleton.tsx +7 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/slider.tsx +23 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/sonner.tsx +23 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/switch.tsx +27 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/table.tsx +94 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/tabs.tsx +53 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/textarea.tsx +21 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/toggle-group.tsx +57 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/toggle.tsx +42 -0
- package/src/templates/tanstack-start-2026-07-30/src/components/ui/tooltip.tsx +32 -0
- package/src/templates/tanstack-start-2026-07-30/src/db/index.ts +9 -0
- package/src/templates/tanstack-start-2026-07-30/src/db/schema.ts +18 -0
- package/src/templates/tanstack-start-2026-07-30/src/global.d.ts +3 -0
- package/src/templates/tanstack-start-2026-07-30/src/hooks/use-mobile.tsx +19 -0
- package/src/templates/tanstack-start-2026-07-30/src/lib/proxy.ts +82 -0
- package/src/templates/tanstack-start-2026-07-30/src/lib/utils.ts +6 -0
- package/src/templates/tanstack-start-2026-07-30/src/routeTree.gen.ts +86 -0
- package/src/templates/tanstack-start-2026-07-30/src/router.tsx +37 -0
- package/src/templates/tanstack-start-2026-07-30/src/routes/README.md +94 -0
- package/src/templates/tanstack-start-2026-07-30/src/routes/__root.tsx +65 -0
- package/src/templates/tanstack-start-2026-07-30/src/routes/api/health.ts +81 -0
- package/src/templates/tanstack-start-2026-07-30/src/routes/index.tsx +33 -0
- package/src/templates/tanstack-start-2026-07-30/src/server.ts +32 -0
- package/src/templates/tanstack-start-2026-07-30/src/styles.css +214 -0
- package/src/templates/tanstack-start-2026-07-30/tsconfig.json +27 -0
- package/src/templates/tanstack-start-2026-07-30/vite.config.ts +17 -0
- package/src/tools/scaffold.ts +2 -2
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RechartsPrimitive from "recharts"
|
|
3
|
+
import type { TooltipValueType } from "recharts"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
8
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
9
|
+
|
|
10
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const
|
|
11
|
+
type TooltipNameType = number | string
|
|
12
|
+
|
|
13
|
+
export type ChartConfig = Record<
|
|
14
|
+
string,
|
|
15
|
+
{
|
|
16
|
+
label?: React.ReactNode
|
|
17
|
+
icon?: React.ComponentType
|
|
18
|
+
} & (
|
|
19
|
+
| { color?: string; theme?: never }
|
|
20
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
21
|
+
)
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
type ChartContextProps = {
|
|
25
|
+
config: ChartConfig
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
29
|
+
|
|
30
|
+
function useChart() {
|
|
31
|
+
const context = React.useContext(ChartContext)
|
|
32
|
+
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return context
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ChartContainer({
|
|
41
|
+
id,
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
config,
|
|
45
|
+
initialDimension = INITIAL_DIMENSION,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<"div"> & {
|
|
48
|
+
config: ChartConfig
|
|
49
|
+
children: React.ComponentProps<
|
|
50
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
51
|
+
>["children"]
|
|
52
|
+
initialDimension?: {
|
|
53
|
+
width: number
|
|
54
|
+
height: number
|
|
55
|
+
}
|
|
56
|
+
}) {
|
|
57
|
+
const uniqueId = React.useId()
|
|
58
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ChartContext.Provider value={{ config }}>
|
|
62
|
+
<div
|
|
63
|
+
data-slot="chart"
|
|
64
|
+
data-chart={chartId}
|
|
65
|
+
className={cn(
|
|
66
|
+
"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",
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<ChartStyle id={chartId} config={config} />
|
|
72
|
+
<RechartsPrimitive.ResponsiveContainer
|
|
73
|
+
initialDimension={initialDimension}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
77
|
+
</div>
|
|
78
|
+
</ChartContext.Provider>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
83
|
+
const colorConfig = Object.entries(config).filter(
|
|
84
|
+
([, config]) => config.theme ?? config.color
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if (!colorConfig.length) {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<style
|
|
93
|
+
dangerouslySetInnerHTML={{
|
|
94
|
+
__html: Object.entries(THEMES)
|
|
95
|
+
.map(
|
|
96
|
+
([theme, prefix]) => `
|
|
97
|
+
${prefix} [data-chart=${id}] {
|
|
98
|
+
${colorConfig
|
|
99
|
+
.map(([key, itemConfig]) => {
|
|
100
|
+
const color =
|
|
101
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
|
102
|
+
itemConfig.color
|
|
103
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
104
|
+
})
|
|
105
|
+
.join("\n")}
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
)
|
|
109
|
+
.join("\n"),
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
116
|
+
|
|
117
|
+
function ChartTooltipContent({
|
|
118
|
+
active,
|
|
119
|
+
payload,
|
|
120
|
+
className,
|
|
121
|
+
indicator = "dot",
|
|
122
|
+
hideLabel = false,
|
|
123
|
+
hideIndicator = false,
|
|
124
|
+
label,
|
|
125
|
+
labelFormatter,
|
|
126
|
+
labelClassName,
|
|
127
|
+
formatter,
|
|
128
|
+
color,
|
|
129
|
+
nameKey,
|
|
130
|
+
labelKey,
|
|
131
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
132
|
+
React.ComponentProps<"div"> & {
|
|
133
|
+
hideLabel?: boolean
|
|
134
|
+
hideIndicator?: boolean
|
|
135
|
+
indicator?: "line" | "dot" | "dashed"
|
|
136
|
+
nameKey?: string
|
|
137
|
+
labelKey?: string
|
|
138
|
+
} & Omit<
|
|
139
|
+
RechartsPrimitive.DefaultTooltipContentProps<
|
|
140
|
+
TooltipValueType,
|
|
141
|
+
TooltipNameType
|
|
142
|
+
>,
|
|
143
|
+
"accessibilityLayer"
|
|
144
|
+
>) {
|
|
145
|
+
const { config } = useChart()
|
|
146
|
+
|
|
147
|
+
const tooltipLabel = React.useMemo(() => {
|
|
148
|
+
if (hideLabel || !payload?.length) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const [item] = payload
|
|
153
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`
|
|
154
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
155
|
+
const value =
|
|
156
|
+
!labelKey && typeof label === "string"
|
|
157
|
+
? (config[label]?.label ?? label)
|
|
158
|
+
: itemConfig?.label
|
|
159
|
+
|
|
160
|
+
if (labelFormatter) {
|
|
161
|
+
return (
|
|
162
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
163
|
+
{labelFormatter(value, payload)}
|
|
164
|
+
</div>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!value) {
|
|
169
|
+
return null
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
173
|
+
}, [
|
|
174
|
+
label,
|
|
175
|
+
labelFormatter,
|
|
176
|
+
payload,
|
|
177
|
+
hideLabel,
|
|
178
|
+
labelClassName,
|
|
179
|
+
config,
|
|
180
|
+
labelKey,
|
|
181
|
+
])
|
|
182
|
+
|
|
183
|
+
if (!active || !payload?.length) {
|
|
184
|
+
return null
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div
|
|
191
|
+
className={cn(
|
|
192
|
+
"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",
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
{!nestLabel ? tooltipLabel : null}
|
|
197
|
+
<div className="grid gap-1.5">
|
|
198
|
+
{payload
|
|
199
|
+
.filter((item) => item.type !== "none")
|
|
200
|
+
.map((item, index) => {
|
|
201
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`
|
|
202
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
203
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div
|
|
207
|
+
key={index}
|
|
208
|
+
className={cn(
|
|
209
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
210
|
+
indicator === "dot" && "items-center"
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
214
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
215
|
+
) : (
|
|
216
|
+
<>
|
|
217
|
+
{itemConfig?.icon ? (
|
|
218
|
+
<itemConfig.icon />
|
|
219
|
+
) : (
|
|
220
|
+
!hideIndicator && (
|
|
221
|
+
<div
|
|
222
|
+
className={cn(
|
|
223
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
224
|
+
{
|
|
225
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
226
|
+
"w-1": indicator === "line",
|
|
227
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
228
|
+
indicator === "dashed",
|
|
229
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
230
|
+
}
|
|
231
|
+
)}
|
|
232
|
+
style={
|
|
233
|
+
{
|
|
234
|
+
"--color-bg": indicatorColor,
|
|
235
|
+
"--color-border": indicatorColor,
|
|
236
|
+
} as React.CSSProperties
|
|
237
|
+
}
|
|
238
|
+
/>
|
|
239
|
+
)
|
|
240
|
+
)}
|
|
241
|
+
<div
|
|
242
|
+
className={cn(
|
|
243
|
+
"flex flex-1 justify-between leading-none",
|
|
244
|
+
nestLabel ? "items-end" : "items-center"
|
|
245
|
+
)}
|
|
246
|
+
>
|
|
247
|
+
<div className="grid gap-1.5">
|
|
248
|
+
{nestLabel ? tooltipLabel : null}
|
|
249
|
+
<span className="text-muted-foreground">
|
|
250
|
+
{itemConfig?.label ?? item.name}
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
{item.value != null && (
|
|
254
|
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
255
|
+
{typeof item.value === "number"
|
|
256
|
+
? item.value.toLocaleString()
|
|
257
|
+
: String(item.value)}
|
|
258
|
+
</span>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
</>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
)
|
|
265
|
+
})}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
272
|
+
|
|
273
|
+
function ChartLegendContent({
|
|
274
|
+
className,
|
|
275
|
+
hideIcon = false,
|
|
276
|
+
payload,
|
|
277
|
+
verticalAlign = "bottom",
|
|
278
|
+
nameKey,
|
|
279
|
+
}: React.ComponentProps<"div"> & {
|
|
280
|
+
hideIcon?: boolean
|
|
281
|
+
nameKey?: string
|
|
282
|
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
283
|
+
const { config } = useChart()
|
|
284
|
+
|
|
285
|
+
if (!payload?.length) {
|
|
286
|
+
return null
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<div
|
|
291
|
+
className={cn(
|
|
292
|
+
"flex items-center justify-center gap-4",
|
|
293
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
294
|
+
className
|
|
295
|
+
)}
|
|
296
|
+
>
|
|
297
|
+
{payload
|
|
298
|
+
.filter((item) => item.type !== "none")
|
|
299
|
+
.map((item, index) => {
|
|
300
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`
|
|
301
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<div
|
|
305
|
+
key={index}
|
|
306
|
+
className={cn(
|
|
307
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
308
|
+
)}
|
|
309
|
+
>
|
|
310
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
311
|
+
<itemConfig.icon />
|
|
312
|
+
) : (
|
|
313
|
+
<div
|
|
314
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
315
|
+
style={{
|
|
316
|
+
backgroundColor: item.color,
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
)}
|
|
320
|
+
{itemConfig?.label}
|
|
321
|
+
</div>
|
|
322
|
+
)
|
|
323
|
+
})}
|
|
324
|
+
</div>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getPayloadConfigFromPayload(
|
|
329
|
+
config: ChartConfig,
|
|
330
|
+
payload: unknown,
|
|
331
|
+
key: string
|
|
332
|
+
) {
|
|
333
|
+
if (typeof payload !== "object" || payload === null) {
|
|
334
|
+
return undefined
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const payloadPayload =
|
|
338
|
+
"payload" in payload &&
|
|
339
|
+
typeof payload.payload === "object" &&
|
|
340
|
+
payload.payload !== null
|
|
341
|
+
? payload.payload
|
|
342
|
+
: undefined
|
|
343
|
+
|
|
344
|
+
let configLabelKey: string = key
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
key in payload &&
|
|
348
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
349
|
+
) {
|
|
350
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
351
|
+
} else if (
|
|
352
|
+
payloadPayload &&
|
|
353
|
+
key in payloadPayload &&
|
|
354
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
355
|
+
) {
|
|
356
|
+
configLabelKey = payloadPayload[
|
|
357
|
+
key as keyof typeof payloadPayload
|
|
358
|
+
] as string
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return configLabelKey in config ? config[configLabelKey] : config[key]
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
ChartContainer,
|
|
366
|
+
ChartTooltip,
|
|
367
|
+
ChartTooltipContent,
|
|
368
|
+
ChartLegend,
|
|
369
|
+
ChartLegendContent,
|
|
370
|
+
ChartStyle,
|
|
371
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
const Checkbox = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<CheckboxPrimitive.Root
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
"grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<CheckboxPrimitive.Indicator className={cn("grid place-content-center text-current")}>
|
|
20
|
+
<Check className="h-4 w-4" />
|
|
21
|
+
</CheckboxPrimitive.Indicator>
|
|
22
|
+
</CheckboxPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Checkbox };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
4
|
+
|
|
5
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
8
|
+
|
|
9
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
10
|
+
|
|
11
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { type DialogProps } from "@radix-ui/react-dialog";
|
|
5
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
6
|
+
import { Search } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
|
10
|
+
|
|
11
|
+
const Command = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<CommandPrimitive
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
25
|
+
|
|
26
|
+
const CommandDialog = ({ children, ...props }: DialogProps) => {
|
|
27
|
+
return (
|
|
28
|
+
<Dialog {...props}>
|
|
29
|
+
<DialogContent className="overflow-hidden p-0">
|
|
30
|
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
31
|
+
{children}
|
|
32
|
+
</Command>
|
|
33
|
+
</DialogContent>
|
|
34
|
+
</Dialog>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const CommandInput = React.forwardRef<
|
|
39
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
40
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
41
|
+
>(({ className, ...props }, ref) => (
|
|
42
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
43
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
44
|
+
<CommandPrimitive.Input
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
));
|
|
54
|
+
|
|
55
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
56
|
+
|
|
57
|
+
const CommandList = React.forwardRef<
|
|
58
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
59
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
60
|
+
>(({ className, ...props }, ref) => (
|
|
61
|
+
<CommandPrimitive.List
|
|
62
|
+
ref={ref}
|
|
63
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
));
|
|
67
|
+
|
|
68
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
69
|
+
|
|
70
|
+
const CommandEmpty = React.forwardRef<
|
|
71
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
72
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
73
|
+
>((props, ref) => (
|
|
74
|
+
<CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
|
|
75
|
+
));
|
|
76
|
+
|
|
77
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
78
|
+
|
|
79
|
+
const CommandGroup = React.forwardRef<
|
|
80
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
81
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
82
|
+
>(({ className, ...props }, ref) => (
|
|
83
|
+
<CommandPrimitive.Group
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(
|
|
86
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
));
|
|
92
|
+
|
|
93
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
94
|
+
|
|
95
|
+
const CommandSeparator = React.forwardRef<
|
|
96
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
98
|
+
>(({ className, ...props }, ref) => (
|
|
99
|
+
<CommandPrimitive.Separator
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
));
|
|
105
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
106
|
+
|
|
107
|
+
const CommandItem = React.forwardRef<
|
|
108
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
109
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
110
|
+
>(({ className, ...props }, ref) => (
|
|
111
|
+
<CommandPrimitive.Item
|
|
112
|
+
ref={ref}
|
|
113
|
+
className={cn(
|
|
114
|
+
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
));
|
|
120
|
+
|
|
121
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
122
|
+
|
|
123
|
+
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
124
|
+
return (
|
|
125
|
+
<span
|
|
126
|
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
Command,
|
|
135
|
+
CommandDialog,
|
|
136
|
+
CommandInput,
|
|
137
|
+
CommandList,
|
|
138
|
+
CommandEmpty,
|
|
139
|
+
CommandGroup,
|
|
140
|
+
CommandItem,
|
|
141
|
+
CommandShortcut,
|
|
142
|
+
CommandSeparator,
|
|
143
|
+
};
|