howone 0.0.3 → 0.0.5
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/templates/nextjs/.prettierignore +7 -0
- package/templates/nextjs/.prettierrc +11 -0
- package/templates/nextjs/README.md +12 -27
- package/templates/nextjs/app/globals.css +123 -40
- package/templates/nextjs/app/layout.tsx +19 -19
- package/templates/nextjs/app/page.tsx +13 -60
- package/templates/nextjs/bun.lock +925 -53
- package/templates/nextjs/components/.gitkeep +0 -0
- package/templates/nextjs/components/theme-provider.tsx +71 -0
- package/templates/nextjs/components/ui/accordion.tsx +81 -0
- package/templates/nextjs/components/ui/alert-dialog.tsx +199 -0
- package/templates/nextjs/components/ui/alert.tsx +76 -0
- package/templates/nextjs/components/ui/aspect-ratio.tsx +11 -0
- package/templates/nextjs/components/ui/avatar.tsx +112 -0
- package/templates/nextjs/components/ui/badge.tsx +49 -0
- package/templates/nextjs/components/ui/breadcrumb.tsx +122 -0
- package/templates/nextjs/components/ui/button-group.tsx +83 -0
- package/templates/nextjs/components/ui/button.tsx +67 -0
- package/templates/nextjs/components/ui/calendar.tsx +222 -0
- package/templates/nextjs/components/ui/card.tsx +103 -0
- package/templates/nextjs/components/ui/carousel.tsx +242 -0
- package/templates/nextjs/components/ui/chart.tsx +373 -0
- package/templates/nextjs/components/ui/checkbox.tsx +33 -0
- package/templates/nextjs/components/ui/collapsible.tsx +33 -0
- package/templates/nextjs/components/ui/combobox.tsx +299 -0
- package/templates/nextjs/components/ui/command.tsx +195 -0
- package/templates/nextjs/components/ui/context-menu.tsx +263 -0
- package/templates/nextjs/components/ui/dialog.tsx +168 -0
- package/templates/nextjs/components/ui/direction.tsx +22 -0
- package/templates/nextjs/components/ui/drawer.tsx +134 -0
- package/templates/nextjs/components/ui/dropdown-menu.tsx +269 -0
- package/templates/nextjs/components/ui/empty.tsx +104 -0
- package/templates/nextjs/components/ui/field.tsx +238 -0
- package/templates/nextjs/components/ui/hover-card.tsx +44 -0
- package/templates/nextjs/components/ui/input-group.tsx +156 -0
- package/templates/nextjs/components/ui/input-otp.tsx +87 -0
- package/templates/nextjs/components/ui/input.tsx +19 -0
- package/templates/nextjs/components/ui/item.tsx +196 -0
- package/templates/nextjs/components/ui/kbd.tsx +26 -0
- package/templates/nextjs/components/ui/label.tsx +24 -0
- package/templates/nextjs/components/ui/menubar.tsx +280 -0
- package/templates/nextjs/components/ui/native-select.tsx +61 -0
- package/templates/nextjs/components/ui/navigation-menu.tsx +164 -0
- package/templates/nextjs/components/ui/pagination.tsx +129 -0
- package/templates/nextjs/components/ui/popover.tsx +89 -0
- package/templates/nextjs/components/ui/progress.tsx +31 -0
- package/templates/nextjs/components/ui/radio-group.tsx +44 -0
- package/templates/nextjs/components/ui/resizable.tsx +50 -0
- package/templates/nextjs/components/ui/scroll-area.tsx +55 -0
- package/templates/nextjs/components/ui/select.tsx +192 -0
- package/templates/nextjs/components/ui/separator.tsx +28 -0
- package/templates/nextjs/components/ui/sheet.tsx +147 -0
- package/templates/nextjs/components/ui/sidebar.tsx +702 -0
- package/templates/nextjs/components/ui/skeleton.tsx +13 -0
- package/templates/nextjs/components/ui/slider.tsx +59 -0
- package/templates/nextjs/components/ui/sonner.tsx +49 -0
- package/templates/nextjs/components/ui/spinner.tsx +10 -0
- package/templates/nextjs/components/ui/switch.tsx +33 -0
- package/templates/nextjs/components/ui/table.tsx +116 -0
- package/templates/nextjs/components/ui/tabs.tsx +90 -0
- package/templates/nextjs/components/ui/textarea.tsx +18 -0
- package/templates/nextjs/components/ui/toggle-group.tsx +89 -0
- package/templates/nextjs/components/ui/toggle.tsx +47 -0
- package/templates/nextjs/components/ui/tooltip.tsx +57 -0
- package/templates/nextjs/components.json +25 -0
- package/templates/nextjs/hooks/.gitkeep +0 -0
- package/templates/nextjs/hooks/use-mobile.ts +19 -0
- package/templates/nextjs/lib/.gitkeep +0 -0
- package/templates/nextjs/lib/sdk.ts +7 -0
- package/templates/nextjs/lib/utils.ts +6 -0
- package/templates/nextjs/next.config.mjs +4 -0
- package/templates/vite/.prettierignore +7 -0
- package/templates/vite/.prettierrc +11 -0
- package/templates/vite/AGENTS.md +0 -0
- package/templates/vite/README.md +12 -64
- package/templates/vite/bun.lock +1478 -0
- package/templates/vite/components.json +25 -0
- package/templates/vite/eslint.config.js +1 -0
- package/templates/vite/index.html +2 -2
- package/templates/vite/package.json +39 -13
- package/templates/vite/public/vite.svg +1 -0
- package/templates/vite/src/App.tsx +6 -115
- package/templates/vite/src/components/theme-provider.tsx +230 -0
- package/templates/vite/src/components/ui/accordion.tsx +79 -0
- package/templates/vite/src/components/ui/alert-dialog.tsx +197 -0
- package/templates/vite/src/components/ui/alert.tsx +76 -0
- package/templates/vite/src/components/ui/aspect-ratio.tsx +11 -0
- package/templates/vite/src/components/ui/avatar.tsx +110 -0
- package/templates/vite/src/components/ui/badge.tsx +49 -0
- package/templates/vite/src/components/ui/breadcrumb.tsx +122 -0
- package/templates/vite/src/components/ui/button-group.tsx +83 -0
- package/templates/vite/src/components/ui/button.tsx +67 -0
- package/templates/vite/src/components/ui/calendar.tsx +222 -0
- package/templates/vite/src/components/ui/card.tsx +103 -0
- package/templates/vite/src/components/ui/carousel.tsx +240 -0
- package/templates/vite/src/components/ui/chart.tsx +373 -0
- package/templates/vite/src/components/ui/checkbox.tsx +31 -0
- package/templates/vite/src/components/ui/collapsible.tsx +33 -0
- package/templates/vite/src/components/ui/combobox.tsx +299 -0
- package/templates/vite/src/components/ui/command.tsx +193 -0
- package/templates/vite/src/components/ui/context-menu.tsx +261 -0
- package/templates/vite/src/components/ui/dialog.tsx +168 -0
- package/templates/vite/src/components/ui/direction.tsx +22 -0
- package/templates/vite/src/components/ui/drawer.tsx +132 -0
- package/templates/vite/src/components/ui/dropdown-menu.tsx +269 -0
- package/templates/vite/src/components/ui/empty.tsx +104 -0
- package/templates/vite/src/components/ui/field.tsx +238 -0
- package/templates/vite/src/components/ui/hover-card.tsx +42 -0
- package/templates/vite/src/components/ui/input-group.tsx +154 -0
- package/templates/vite/src/components/ui/input-otp.tsx +87 -0
- package/templates/vite/src/components/ui/input.tsx +19 -0
- package/templates/vite/src/components/ui/item.tsx +196 -0
- package/templates/vite/src/components/ui/kbd.tsx +26 -0
- package/templates/vite/src/components/ui/label.tsx +22 -0
- package/templates/vite/src/components/ui/menubar.tsx +280 -0
- package/templates/vite/src/components/ui/native-select.tsx +61 -0
- package/templates/vite/src/components/ui/navigation-menu.tsx +164 -0
- package/templates/vite/src/components/ui/pagination.tsx +129 -0
- package/templates/vite/src/components/ui/popover.tsx +87 -0
- package/templates/vite/src/components/ui/progress.tsx +31 -0
- package/templates/vite/src/components/ui/radio-group.tsx +42 -0
- package/templates/vite/src/components/ui/resizable.tsx +50 -0
- package/templates/vite/src/components/ui/scroll-area.tsx +53 -0
- package/templates/vite/src/components/ui/select.tsx +192 -0
- package/templates/vite/src/components/ui/separator.tsx +26 -0
- package/templates/vite/src/components/ui/sheet.tsx +145 -0
- package/templates/vite/src/components/ui/sidebar.tsx +700 -0
- package/templates/vite/src/components/ui/skeleton.tsx +13 -0
- package/templates/vite/src/components/ui/slider.tsx +59 -0
- package/templates/vite/src/components/ui/sonner.tsx +47 -0
- package/templates/vite/src/components/ui/spinner.tsx +10 -0
- package/templates/vite/src/components/ui/switch.tsx +33 -0
- package/templates/vite/src/components/ui/table.tsx +114 -0
- package/templates/vite/src/components/ui/tabs.tsx +90 -0
- package/templates/vite/src/components/ui/textarea.tsx +18 -0
- package/templates/vite/src/components/ui/toggle-group.tsx +89 -0
- package/templates/vite/src/components/ui/toggle.tsx +45 -0
- package/templates/vite/src/components/ui/tooltip.tsx +57 -0
- package/templates/vite/src/hooks/use-mobile.ts +19 -0
- package/templates/vite/src/index.css +125 -103
- package/templates/vite/src/lib/sdk.ts +7 -0
- package/templates/vite/src/lib/utils.ts +6 -0
- package/templates/vite/src/main.tsx +11 -7
- package/templates/vite/tsconfig.app.json +11 -4
- package/templates/vite/tsconfig.json +7 -1
- package/templates/vite/tsconfig.node.json +5 -3
- package/templates/vite/vite.config.ts +10 -3
- package/templates/nextjs/AGENTS.md +0 -5
- package/templates/nextjs/CLAUDE.md +0 -1
- package/templates/nextjs/app/page.module.css +0 -142
- package/templates/nextjs/gitignore +0 -41
- package/templates/nextjs/next-env.d.ts +0 -6
- package/templates/nextjs/next.config.ts +0 -7
- package/templates/nextjs/package.json +0 -32
- package/templates/nextjs/public/file.svg +0 -1
- package/templates/nextjs/public/globe.svg +0 -1
- package/templates/nextjs/public/next.svg +0 -1
- package/templates/nextjs/public/vercel.svg +0 -1
- package/templates/nextjs/public/window.svg +0 -1
- package/templates/nextjs/tsconfig.json +0 -34
- package/templates/vite/gitignore +0 -24
- package/templates/vite/public/favicon.svg +0 -1
- package/templates/vite/public/icons.svg +0 -24
- package/templates/vite/src/App.css +0 -184
- package/templates/vite/src/assets/hero.png +0 -0
- package/templates/vite/src/assets/vite.svg +0 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import useEmblaCarousel, {
|
|
5
|
+
type UseEmblaCarouselType,
|
|
6
|
+
} from "embla-carousel-react"
|
|
7
|
+
|
|
8
|
+
import { cn } from "@/lib/utils"
|
|
9
|
+
import { Button } from "@/components/ui/button"
|
|
10
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
|
|
11
|
+
|
|
12
|
+
type CarouselApi = UseEmblaCarouselType[1]
|
|
13
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
14
|
+
type CarouselOptions = UseCarouselParameters[0]
|
|
15
|
+
type CarouselPlugin = UseCarouselParameters[1]
|
|
16
|
+
|
|
17
|
+
type CarouselProps = {
|
|
18
|
+
opts?: CarouselOptions
|
|
19
|
+
plugins?: CarouselPlugin
|
|
20
|
+
orientation?: "horizontal" | "vertical"
|
|
21
|
+
setApi?: (api: CarouselApi) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type CarouselContextProps = {
|
|
25
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
26
|
+
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
27
|
+
scrollPrev: () => void
|
|
28
|
+
scrollNext: () => void
|
|
29
|
+
canScrollPrev: boolean
|
|
30
|
+
canScrollNext: boolean
|
|
31
|
+
} & CarouselProps
|
|
32
|
+
|
|
33
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
34
|
+
|
|
35
|
+
function useCarousel() {
|
|
36
|
+
const context = React.useContext(CarouselContext)
|
|
37
|
+
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("useCarousel must be used within a <Carousel />")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return context
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Carousel({
|
|
46
|
+
orientation = "horizontal",
|
|
47
|
+
opts,
|
|
48
|
+
setApi,
|
|
49
|
+
plugins,
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
54
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
55
|
+
{
|
|
56
|
+
...opts,
|
|
57
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
58
|
+
},
|
|
59
|
+
plugins
|
|
60
|
+
)
|
|
61
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
62
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
63
|
+
|
|
64
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
65
|
+
if (!api) return
|
|
66
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
67
|
+
setCanScrollNext(api.canScrollNext())
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
const scrollPrev = React.useCallback(() => {
|
|
71
|
+
api?.scrollPrev()
|
|
72
|
+
}, [api])
|
|
73
|
+
|
|
74
|
+
const scrollNext = React.useCallback(() => {
|
|
75
|
+
api?.scrollNext()
|
|
76
|
+
}, [api])
|
|
77
|
+
|
|
78
|
+
const handleKeyDown = React.useCallback(
|
|
79
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
80
|
+
if (event.key === "ArrowLeft") {
|
|
81
|
+
event.preventDefault()
|
|
82
|
+
scrollPrev()
|
|
83
|
+
} else if (event.key === "ArrowRight") {
|
|
84
|
+
event.preventDefault()
|
|
85
|
+
scrollNext()
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[scrollPrev, scrollNext]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (!api || !setApi) return
|
|
93
|
+
setApi(api)
|
|
94
|
+
}, [api, setApi])
|
|
95
|
+
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (!api) return
|
|
98
|
+
onSelect(api)
|
|
99
|
+
api.on("reInit", onSelect)
|
|
100
|
+
api.on("select", onSelect)
|
|
101
|
+
|
|
102
|
+
return () => {
|
|
103
|
+
api?.off("select", onSelect)
|
|
104
|
+
}
|
|
105
|
+
}, [api, onSelect])
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<CarouselContext.Provider
|
|
109
|
+
value={{
|
|
110
|
+
carouselRef,
|
|
111
|
+
api: api,
|
|
112
|
+
opts,
|
|
113
|
+
orientation:
|
|
114
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
115
|
+
scrollPrev,
|
|
116
|
+
scrollNext,
|
|
117
|
+
canScrollPrev,
|
|
118
|
+
canScrollNext,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
<div
|
|
122
|
+
onKeyDownCapture={handleKeyDown}
|
|
123
|
+
className={cn("relative", className)}
|
|
124
|
+
role="region"
|
|
125
|
+
aria-roledescription="carousel"
|
|
126
|
+
data-slot="carousel"
|
|
127
|
+
{...props}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
</CarouselContext.Provider>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
136
|
+
const { carouselRef, orientation } = useCarousel()
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div
|
|
140
|
+
ref={carouselRef}
|
|
141
|
+
className="overflow-hidden"
|
|
142
|
+
data-slot="carousel-content"
|
|
143
|
+
>
|
|
144
|
+
<div
|
|
145
|
+
className={cn(
|
|
146
|
+
"flex",
|
|
147
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
148
|
+
className
|
|
149
|
+
)}
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
157
|
+
const { orientation } = useCarousel()
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div
|
|
161
|
+
role="group"
|
|
162
|
+
aria-roledescription="slide"
|
|
163
|
+
data-slot="carousel-item"
|
|
164
|
+
className={cn(
|
|
165
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
166
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
167
|
+
className
|
|
168
|
+
)}
|
|
169
|
+
{...props}
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function CarouselPrevious({
|
|
175
|
+
className,
|
|
176
|
+
variant = "outline",
|
|
177
|
+
size = "icon-sm",
|
|
178
|
+
...props
|
|
179
|
+
}: React.ComponentProps<typeof Button>) {
|
|
180
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<Button
|
|
184
|
+
data-slot="carousel-previous"
|
|
185
|
+
variant={variant}
|
|
186
|
+
size={size}
|
|
187
|
+
className={cn(
|
|
188
|
+
"absolute touch-manipulation rounded-full",
|
|
189
|
+
orientation === "horizontal"
|
|
190
|
+
? "top-1/2 -left-12 -translate-y-1/2"
|
|
191
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
192
|
+
className
|
|
193
|
+
)}
|
|
194
|
+
disabled={!canScrollPrev}
|
|
195
|
+
onClick={scrollPrev}
|
|
196
|
+
{...props}
|
|
197
|
+
>
|
|
198
|
+
<ChevronLeftIcon />
|
|
199
|
+
<span className="sr-only">Previous slide</span>
|
|
200
|
+
</Button>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function CarouselNext({
|
|
205
|
+
className,
|
|
206
|
+
variant = "outline",
|
|
207
|
+
size = "icon-sm",
|
|
208
|
+
...props
|
|
209
|
+
}: React.ComponentProps<typeof Button>) {
|
|
210
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<Button
|
|
214
|
+
data-slot="carousel-next"
|
|
215
|
+
variant={variant}
|
|
216
|
+
size={size}
|
|
217
|
+
className={cn(
|
|
218
|
+
"absolute touch-manipulation rounded-full",
|
|
219
|
+
orientation === "horizontal"
|
|
220
|
+
? "top-1/2 -right-12 -translate-y-1/2"
|
|
221
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
222
|
+
className
|
|
223
|
+
)}
|
|
224
|
+
disabled={!canScrollNext}
|
|
225
|
+
onClick={scrollNext}
|
|
226
|
+
{...props}
|
|
227
|
+
>
|
|
228
|
+
<ChevronRightIcon />
|
|
229
|
+
<span className="sr-only">Next slide</span>
|
|
230
|
+
</Button>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export {
|
|
235
|
+
type CarouselApi,
|
|
236
|
+
Carousel,
|
|
237
|
+
CarouselContent,
|
|
238
|
+
CarouselItem,
|
|
239
|
+
CarouselPrevious,
|
|
240
|
+
CarouselNext,
|
|
241
|
+
useCarousel,
|
|
242
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
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-32 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
|
+
function getPayloadConfigFromPayload(
|
|
331
|
+
config: ChartConfig,
|
|
332
|
+
payload: unknown,
|
|
333
|
+
key: string
|
|
334
|
+
) {
|
|
335
|
+
if (typeof payload !== "object" || payload === null) {
|
|
336
|
+
return undefined
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const payloadPayload =
|
|
340
|
+
"payload" in payload &&
|
|
341
|
+
typeof payload.payload === "object" &&
|
|
342
|
+
payload.payload !== null
|
|
343
|
+
? payload.payload
|
|
344
|
+
: undefined
|
|
345
|
+
|
|
346
|
+
let configLabelKey: string = key
|
|
347
|
+
|
|
348
|
+
if (
|
|
349
|
+
key in payload &&
|
|
350
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
351
|
+
) {
|
|
352
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
353
|
+
} else if (
|
|
354
|
+
payloadPayload &&
|
|
355
|
+
key in payloadPayload &&
|
|
356
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
357
|
+
) {
|
|
358
|
+
configLabelKey = payloadPayload[
|
|
359
|
+
key as keyof typeof payloadPayload
|
|
360
|
+
] as string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return configLabelKey in config ? config[configLabelKey] : config[key]
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export {
|
|
367
|
+
ChartContainer,
|
|
368
|
+
ChartTooltip,
|
|
369
|
+
ChartTooltipContent,
|
|
370
|
+
ChartLegend,
|
|
371
|
+
ChartLegendContent,
|
|
372
|
+
ChartStyle,
|
|
373
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
import { CheckIcon } from "lucide-react"
|
|
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 relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-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 [&>svg]:size-3.5"
|
|
25
|
+
>
|
|
26
|
+
<CheckIcon
|
|
27
|
+
/>
|
|
28
|
+
</CheckboxPrimitive.Indicator>
|
|
29
|
+
</CheckboxPrimitive.Root>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
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 }
|