create-surf-app 0.1.4 → 0.1.6
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/chunk-AMAMASIV.js +1016 -0
- package/dist/cli.js +51 -0
- package/dist/index.js +5 -379
- package/dist/templates/default/CLAUDE.md +46 -0
- package/dist/templates/default/backend/db/index.js +23 -0
- package/dist/templates/default/backend/db/schema.js +20 -0
- package/dist/templates/{backend → default/backend}/eslint.config.mjs +1 -1
- package/dist/templates/default/backend/lib/db.js +67 -0
- package/dist/templates/default/backend/package.json +25 -0
- package/dist/templates/default/backend/routes/proxy.js +66 -0
- package/dist/templates/default/backend/server.js +444 -0
- package/dist/templates/default/frontend/components.json +21 -0
- package/{templates → dist/templates/default}/frontend/eslint.config.js +1 -1
- package/dist/templates/default/frontend/package.json +82 -0
- package/dist/templates/default/frontend/src/App.tsx +23 -0
- package/dist/templates/default/frontend/src/ErrorBoundary.tsx +106 -0
- package/dist/templates/default/frontend/src/components/ui/accordion.tsx +55 -0
- package/dist/templates/default/frontend/src/components/ui/alert.tsx +59 -0
- package/dist/templates/default/frontend/src/components/ui/aspect-ratio.tsx +5 -0
- package/dist/templates/default/frontend/src/components/ui/avatar.tsx +48 -0
- package/dist/templates/default/frontend/src/components/ui/badge.tsx +36 -0
- package/dist/templates/default/frontend/src/components/ui/breadcrumb.tsx +115 -0
- package/dist/templates/default/frontend/src/components/ui/button.tsx +57 -0
- package/dist/templates/default/frontend/src/components/ui/calendar.tsx +211 -0
- package/dist/templates/default/frontend/src/components/ui/card.tsx +76 -0
- package/dist/templates/default/frontend/src/components/ui/carousel.tsx +262 -0
- package/dist/templates/default/frontend/src/components/ui/checkbox.tsx +30 -0
- package/dist/templates/default/frontend/src/components/ui/collapsible.tsx +9 -0
- package/dist/templates/default/frontend/src/components/ui/command.tsx +153 -0
- package/dist/templates/default/frontend/src/components/ui/context-menu.tsx +200 -0
- package/dist/templates/default/frontend/src/components/ui/dialog.tsx +120 -0
- package/dist/templates/default/frontend/src/components/ui/drawer.tsx +118 -0
- package/dist/templates/default/frontend/src/components/ui/dropdown-menu.tsx +201 -0
- package/dist/templates/default/frontend/src/components/ui/form.tsx +176 -0
- package/dist/templates/default/frontend/src/components/ui/hover-card.tsx +29 -0
- package/dist/templates/default/frontend/src/components/ui/input.tsx +22 -0
- package/dist/templates/default/frontend/src/components/ui/label.tsx +26 -0
- package/dist/templates/default/frontend/src/components/ui/menubar.tsx +256 -0
- package/dist/templates/default/frontend/src/components/ui/navigation-menu.tsx +128 -0
- package/dist/templates/default/frontend/src/components/ui/popover.tsx +33 -0
- package/dist/templates/default/frontend/src/components/ui/progress.tsx +26 -0
- package/dist/templates/default/frontend/src/components/ui/radio-group.tsx +42 -0
- package/dist/templates/default/frontend/src/components/ui/resizable.tsx +43 -0
- package/dist/templates/default/frontend/src/components/ui/scroll-area.tsx +46 -0
- package/dist/templates/default/frontend/src/components/ui/select.tsx +157 -0
- package/dist/templates/default/frontend/src/components/ui/separator.tsx +31 -0
- package/dist/templates/default/frontend/src/components/ui/sheet.tsx +140 -0
- package/dist/templates/default/frontend/src/components/ui/skeleton.tsx +15 -0
- package/dist/templates/default/frontend/src/components/ui/slider.tsx +26 -0
- package/dist/templates/default/frontend/src/components/ui/sonner.tsx +29 -0
- package/dist/templates/default/frontend/src/components/ui/switch.tsx +29 -0
- package/dist/templates/default/frontend/src/components/ui/table.tsx +120 -0
- package/dist/templates/default/frontend/src/components/ui/tabs.tsx +53 -0
- package/dist/templates/default/frontend/src/components/ui/textarea.tsx +22 -0
- package/dist/templates/default/frontend/src/components/ui/toast.tsx +129 -0
- package/dist/templates/default/frontend/src/components/ui/toaster.tsx +35 -0
- package/dist/templates/default/frontend/src/components/ui/toggle-group.tsx +59 -0
- package/dist/templates/default/frontend/src/components/ui/toggle.tsx +43 -0
- package/dist/templates/default/frontend/src/components/ui/tooltip.tsx +30 -0
- package/dist/templates/default/frontend/src/db/schema.ts +16 -0
- package/{templates → dist/templates/default}/frontend/src/entry-client.tsx +11 -8
- package/dist/templates/default/frontend/src/hooks/use-toast.ts +95 -0
- package/dist/templates/default/frontend/src/index.css +314 -0
- package/dist/templates/default/frontend/src/lib/api.ts +31 -0
- package/dist/templates/default/frontend/src/lib/fetch.ts +38 -0
- package/dist/templates/default/frontend/src/lib/utils.ts +6 -0
- package/dist/templates/default/frontend/src/vite-env.d.ts +11 -0
- package/dist/templates/default/frontend/tsconfig.json +22 -0
- package/dist/templates/default/frontend/vite.config.ts +162 -0
- package/package.json +7 -7
- package/dist/templates/frontend/eslint.config.js +0 -42
- package/dist/templates/frontend/src/entry-client.tsx +0 -109
- package/templates/backend/eslint.config.mjs +0 -21
- package/templates/frontend/index.html +0 -43
- package/templates/frontend/src/entry-server.tsx +0 -13
- /package/dist/templates/{frontend → default/frontend}/index.html +0 -0
- /package/dist/templates/{frontend → default/frontend}/src/entry-server.tsx +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"rounded-xl border bg-card text-card-foreground shadow",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
))
|
|
18
|
+
Card.displayName = "Card"
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<
|
|
21
|
+
HTMLDivElement,
|
|
22
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
CardHeader.displayName = "CardHeader"
|
|
31
|
+
|
|
32
|
+
const CardTitle = React.forwardRef<
|
|
33
|
+
HTMLDivElement,
|
|
34
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<div
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn("font-semibold leading-none tracking-tight", className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
))
|
|
42
|
+
CardTitle.displayName = "CardTitle"
|
|
43
|
+
|
|
44
|
+
const CardDescription = React.forwardRef<
|
|
45
|
+
HTMLDivElement,
|
|
46
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
47
|
+
>(({ className, ...props }, ref) => (
|
|
48
|
+
<div
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
))
|
|
54
|
+
CardDescription.displayName = "CardDescription"
|
|
55
|
+
|
|
56
|
+
const CardContent = React.forwardRef<
|
|
57
|
+
HTMLDivElement,
|
|
58
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
59
|
+
>(({ className, ...props }, ref) => (
|
|
60
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
61
|
+
))
|
|
62
|
+
CardContent.displayName = "CardContent"
|
|
63
|
+
|
|
64
|
+
const CardFooter = React.forwardRef<
|
|
65
|
+
HTMLDivElement,
|
|
66
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
67
|
+
>(({ className, ...props }, ref) => (
|
|
68
|
+
<div
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
))
|
|
74
|
+
CardFooter.displayName = "CardFooter"
|
|
75
|
+
|
|
76
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import useEmblaCarousel, {
|
|
5
|
+
type UseEmblaCarouselType,
|
|
6
|
+
} from "embla-carousel-react"
|
|
7
|
+
import { ArrowLeft, ArrowRight } from "lucide-react"
|
|
8
|
+
|
|
9
|
+
import { cn } from "@/lib/utils"
|
|
10
|
+
import { Button } from "@/components/ui/button"
|
|
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
|
+
const Carousel = React.forwardRef<
|
|
46
|
+
HTMLDivElement,
|
|
47
|
+
React.HTMLAttributes<HTMLDivElement> & CarouselProps
|
|
48
|
+
>(
|
|
49
|
+
(
|
|
50
|
+
{
|
|
51
|
+
orientation = "horizontal",
|
|
52
|
+
opts,
|
|
53
|
+
setApi,
|
|
54
|
+
plugins,
|
|
55
|
+
className,
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
},
|
|
59
|
+
ref
|
|
60
|
+
) => {
|
|
61
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
62
|
+
{
|
|
63
|
+
...opts,
|
|
64
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
65
|
+
},
|
|
66
|
+
plugins
|
|
67
|
+
)
|
|
68
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
69
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
70
|
+
|
|
71
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
72
|
+
if (!api) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
77
|
+
setCanScrollNext(api.canScrollNext())
|
|
78
|
+
}, [])
|
|
79
|
+
|
|
80
|
+
const scrollPrev = React.useCallback(() => {
|
|
81
|
+
api?.scrollPrev()
|
|
82
|
+
}, [api])
|
|
83
|
+
|
|
84
|
+
const scrollNext = React.useCallback(() => {
|
|
85
|
+
api?.scrollNext()
|
|
86
|
+
}, [api])
|
|
87
|
+
|
|
88
|
+
const handleKeyDown = React.useCallback(
|
|
89
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
90
|
+
if (event.key === "ArrowLeft") {
|
|
91
|
+
event.preventDefault()
|
|
92
|
+
scrollPrev()
|
|
93
|
+
} else if (event.key === "ArrowRight") {
|
|
94
|
+
event.preventDefault()
|
|
95
|
+
scrollNext()
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
[scrollPrev, scrollNext]
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
if (!api || !setApi) {
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setApi(api)
|
|
107
|
+
}, [api, setApi])
|
|
108
|
+
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
if (!api) {
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
onSelect(api)
|
|
115
|
+
api.on("reInit", onSelect)
|
|
116
|
+
api.on("select", onSelect)
|
|
117
|
+
|
|
118
|
+
return () => {
|
|
119
|
+
api?.off("select", onSelect)
|
|
120
|
+
}
|
|
121
|
+
}, [api, onSelect])
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<CarouselContext.Provider
|
|
125
|
+
value={{
|
|
126
|
+
carouselRef,
|
|
127
|
+
api: api,
|
|
128
|
+
opts,
|
|
129
|
+
orientation:
|
|
130
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
131
|
+
scrollPrev,
|
|
132
|
+
scrollNext,
|
|
133
|
+
canScrollPrev,
|
|
134
|
+
canScrollNext,
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
<div
|
|
138
|
+
ref={ref}
|
|
139
|
+
onKeyDownCapture={handleKeyDown}
|
|
140
|
+
className={cn("relative", className)}
|
|
141
|
+
role="region"
|
|
142
|
+
aria-roledescription="carousel"
|
|
143
|
+
{...props}
|
|
144
|
+
>
|
|
145
|
+
{children}
|
|
146
|
+
</div>
|
|
147
|
+
</CarouselContext.Provider>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
Carousel.displayName = "Carousel"
|
|
152
|
+
|
|
153
|
+
const CarouselContent = React.forwardRef<
|
|
154
|
+
HTMLDivElement,
|
|
155
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
156
|
+
>(({ className, ...props }, ref) => {
|
|
157
|
+
const { carouselRef, orientation } = useCarousel()
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div ref={carouselRef} className="overflow-hidden">
|
|
161
|
+
<div
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn(
|
|
164
|
+
"flex",
|
|
165
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
166
|
+
className
|
|
167
|
+
)}
|
|
168
|
+
{...props}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
)
|
|
172
|
+
})
|
|
173
|
+
CarouselContent.displayName = "CarouselContent"
|
|
174
|
+
|
|
175
|
+
const CarouselItem = React.forwardRef<
|
|
176
|
+
HTMLDivElement,
|
|
177
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
178
|
+
>(({ className, ...props }, ref) => {
|
|
179
|
+
const { orientation } = useCarousel()
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div
|
|
183
|
+
ref={ref}
|
|
184
|
+
role="group"
|
|
185
|
+
aria-roledescription="slide"
|
|
186
|
+
className={cn(
|
|
187
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
188
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
189
|
+
className
|
|
190
|
+
)}
|
|
191
|
+
{...props}
|
|
192
|
+
/>
|
|
193
|
+
)
|
|
194
|
+
})
|
|
195
|
+
CarouselItem.displayName = "CarouselItem"
|
|
196
|
+
|
|
197
|
+
const CarouselPrevious = React.forwardRef<
|
|
198
|
+
HTMLButtonElement,
|
|
199
|
+
React.ComponentProps<typeof Button>
|
|
200
|
+
>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
201
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Button
|
|
205
|
+
ref={ref}
|
|
206
|
+
variant={variant}
|
|
207
|
+
size={size}
|
|
208
|
+
className={cn(
|
|
209
|
+
"absolute h-8 w-8 rounded-full",
|
|
210
|
+
orientation === "horizontal"
|
|
211
|
+
? "-left-12 top-1/2 -translate-y-1/2"
|
|
212
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
213
|
+
className
|
|
214
|
+
)}
|
|
215
|
+
disabled={!canScrollPrev}
|
|
216
|
+
onClick={scrollPrev}
|
|
217
|
+
{...props}
|
|
218
|
+
>
|
|
219
|
+
<ArrowLeft className="h-4 w-4" />
|
|
220
|
+
<span className="sr-only">Previous slide</span>
|
|
221
|
+
</Button>
|
|
222
|
+
)
|
|
223
|
+
})
|
|
224
|
+
CarouselPrevious.displayName = "CarouselPrevious"
|
|
225
|
+
|
|
226
|
+
const CarouselNext = React.forwardRef<
|
|
227
|
+
HTMLButtonElement,
|
|
228
|
+
React.ComponentProps<typeof Button>
|
|
229
|
+
>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
230
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<Button
|
|
234
|
+
ref={ref}
|
|
235
|
+
variant={variant}
|
|
236
|
+
size={size}
|
|
237
|
+
className={cn(
|
|
238
|
+
"absolute h-8 w-8 rounded-full",
|
|
239
|
+
orientation === "horizontal"
|
|
240
|
+
? "-right-12 top-1/2 -translate-y-1/2"
|
|
241
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
242
|
+
className
|
|
243
|
+
)}
|
|
244
|
+
disabled={!canScrollNext}
|
|
245
|
+
onClick={scrollNext}
|
|
246
|
+
{...props}
|
|
247
|
+
>
|
|
248
|
+
<ArrowRight className="h-4 w-4" />
|
|
249
|
+
<span className="sr-only">Next slide</span>
|
|
250
|
+
</Button>
|
|
251
|
+
)
|
|
252
|
+
})
|
|
253
|
+
CarouselNext.displayName = "CarouselNext"
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
type CarouselApi,
|
|
257
|
+
Carousel,
|
|
258
|
+
CarouselContent,
|
|
259
|
+
CarouselItem,
|
|
260
|
+
CarouselPrevious,
|
|
261
|
+
CarouselNext,
|
|
262
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
|
5
|
+
import { Check } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
const Checkbox = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
12
|
+
>(({ className, ...props }, ref) => (
|
|
13
|
+
<CheckboxPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
className={cn(
|
|
16
|
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow 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",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<CheckboxPrimitive.Indicator
|
|
22
|
+
className={cn("flex items-center justify-center text-current")}
|
|
23
|
+
>
|
|
24
|
+
<Check className="h-4 w-4" />
|
|
25
|
+
</CheckboxPrimitive.Indicator>
|
|
26
|
+
</CheckboxPrimitive.Root>
|
|
27
|
+
))
|
|
28
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
|
29
|
+
|
|
30
|
+
export { Checkbox }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
|
75
|
+
ref={ref}
|
|
76
|
+
className="py-6 text-center text-sm"
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
))
|
|
80
|
+
|
|
81
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName
|
|
82
|
+
|
|
83
|
+
const CommandGroup = React.forwardRef<
|
|
84
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
85
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
86
|
+
>(({ className, ...props }, ref) => (
|
|
87
|
+
<CommandPrimitive.Group
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={cn(
|
|
90
|
+
"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",
|
|
91
|
+
className
|
|
92
|
+
)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
))
|
|
96
|
+
|
|
97
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName
|
|
98
|
+
|
|
99
|
+
const CommandSeparator = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<CommandPrimitive.Separator
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
|
|
110
|
+
|
|
111
|
+
const CommandItem = React.forwardRef<
|
|
112
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
113
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
114
|
+
>(({ className, ...props }, ref) => (
|
|
115
|
+
<CommandPrimitive.Item
|
|
116
|
+
ref={ref}
|
|
117
|
+
className={cn(
|
|
118
|
+
"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",
|
|
119
|
+
className
|
|
120
|
+
)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
))
|
|
124
|
+
|
|
125
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName
|
|
126
|
+
|
|
127
|
+
const CommandShortcut = ({
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
131
|
+
return (
|
|
132
|
+
<span
|
|
133
|
+
className={cn(
|
|
134
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
135
|
+
className
|
|
136
|
+
)}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
CommandShortcut.displayName = "CommandShortcut"
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
Command,
|
|
145
|
+
CommandDialog,
|
|
146
|
+
CommandInput,
|
|
147
|
+
CommandList,
|
|
148
|
+
CommandEmpty,
|
|
149
|
+
CommandGroup,
|
|
150
|
+
CommandItem,
|
|
151
|
+
CommandShortcut,
|
|
152
|
+
CommandSeparator,
|
|
153
|
+
}
|