@papercraneai/cli 1.5.6 → 1.6.0-beta.1

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.
Files changed (74) hide show
  1. package/bin/papercrane.js +170 -251
  2. package/components/command-listener.tsx +52 -0
  3. package/components/dashboard-grid.tsx +61 -0
  4. package/components/error-reporter.tsx +112 -0
  5. package/components/theme-provider.tsx +10 -0
  6. package/components/theme-switcher.tsx +54 -0
  7. package/components/theme-toggle.tsx +21 -0
  8. package/components/ui/accordion.tsx +66 -0
  9. package/components/ui/alert-dialog.tsx +157 -0
  10. package/components/ui/alert.tsx +66 -0
  11. package/components/ui/aspect-ratio.tsx +11 -0
  12. package/components/ui/avatar.tsx +53 -0
  13. package/components/ui/badge.tsx +46 -0
  14. package/components/ui/breadcrumb.tsx +109 -0
  15. package/components/ui/button-group.tsx +83 -0
  16. package/components/ui/button.tsx +60 -0
  17. package/components/ui/calendar.tsx +216 -0
  18. package/components/ui/card.tsx +92 -0
  19. package/components/ui/carousel.tsx +241 -0
  20. package/components/ui/chart.tsx +357 -0
  21. package/components/ui/checkbox.tsx +32 -0
  22. package/components/ui/collapsible.tsx +33 -0
  23. package/components/ui/command.tsx +184 -0
  24. package/components/ui/context-menu.tsx +252 -0
  25. package/components/ui/dialog.tsx +143 -0
  26. package/components/ui/drawer.tsx +135 -0
  27. package/components/ui/dropdown-menu.tsx +257 -0
  28. package/components/ui/empty.tsx +104 -0
  29. package/components/ui/field.tsx +248 -0
  30. package/components/ui/form.tsx +167 -0
  31. package/components/ui/hover-card.tsx +44 -0
  32. package/components/ui/input-group.tsx +170 -0
  33. package/components/ui/input-otp.tsx +77 -0
  34. package/components/ui/input.tsx +21 -0
  35. package/components/ui/item.tsx +193 -0
  36. package/components/ui/kbd.tsx +28 -0
  37. package/components/ui/label.tsx +24 -0
  38. package/components/ui/menubar.tsx +276 -0
  39. package/components/ui/navigation-menu.tsx +168 -0
  40. package/components/ui/pagination.tsx +127 -0
  41. package/components/ui/popover.tsx +48 -0
  42. package/components/ui/progress.tsx +31 -0
  43. package/components/ui/radio-group.tsx +45 -0
  44. package/components/ui/resizable.tsx +56 -0
  45. package/components/ui/scroll-area.tsx +58 -0
  46. package/components/ui/select.tsx +187 -0
  47. package/components/ui/separator.tsx +28 -0
  48. package/components/ui/sheet.tsx +139 -0
  49. package/components/ui/sidebar.tsx +726 -0
  50. package/components/ui/skeleton.tsx +13 -0
  51. package/components/ui/slider.tsx +63 -0
  52. package/components/ui/sonner.tsx +40 -0
  53. package/components/ui/spinner.tsx +16 -0
  54. package/components/ui/switch.tsx +31 -0
  55. package/components/ui/table.tsx +116 -0
  56. package/components/ui/tabs.tsx +66 -0
  57. package/components/ui/textarea.tsx +18 -0
  58. package/components/ui/toggle-group.tsx +83 -0
  59. package/components/ui/toggle.tsx +47 -0
  60. package/components/ui/tooltip.tsx +61 -0
  61. package/lib/dev-server.js +395 -0
  62. package/lib/environment-client.js +50 -12
  63. package/package.json +65 -4
  64. package/public/themes/blue.css +69 -0
  65. package/public/themes/default.css +70 -0
  66. package/public/themes/green.css +69 -0
  67. package/public/themes/orange.css +69 -0
  68. package/public/themes/red.css +69 -0
  69. package/public/themes/rose.css +69 -0
  70. package/public/themes/violet.css +69 -0
  71. package/public/themes/yellow.css +69 -0
  72. package/runtime-hooks/use-mobile.ts +19 -0
  73. package/runtime-lib/papercrane.ts +49 -0
  74. package/runtime-lib/utils.ts +6 -0
@@ -0,0 +1,61 @@
1
+ "use client"
2
+
3
+ import { useState, useEffect, type ReactNode, type CSSProperties } from "react"
4
+
5
+ interface DashboardGridProps {
6
+ children: ReactNode
7
+ cols?: number
8
+ rowHeight?: number
9
+ gap?: number
10
+ className?: string
11
+ }
12
+
13
+ // Try to load the enterprise DashboardGrid from the plugin
14
+ let pluginGrid: React.ComponentType<DashboardGridProps> | null = null
15
+ let pluginLoaded = false
16
+
17
+ export function DashboardGrid(props: DashboardGridProps) {
18
+ const { children, cols = 4, rowHeight = 140, gap = 16, className = "" } = props
19
+ const [, forceUpdate] = useState(0)
20
+
21
+ useEffect(() => {
22
+ if (pluginLoaded) return
23
+
24
+ async function loadPlugin() {
25
+ try {
26
+ const pkg = "@papercrane/" + "dashboard-grid/plugin"
27
+ const mod = await import(pkg)
28
+ if (mod.createPlugin) {
29
+ const plugin = mod.createPlugin()
30
+ pluginGrid = plugin.DashboardGrid
31
+ }
32
+ } catch {
33
+ // Plugin not installed — use fallback grid
34
+ }
35
+ pluginLoaded = true
36
+ forceUpdate((n) => n + 1)
37
+ }
38
+
39
+ loadPlugin()
40
+ }, [])
41
+
42
+ // If plugin loaded, use its grid
43
+ if (pluginGrid) {
44
+ const PluginGrid = pluginGrid
45
+ return <PluginGrid {...props} />
46
+ }
47
+
48
+ // Fallback: plain CSS grid (no drag, no edit mode)
49
+ const gridStyle: CSSProperties = {
50
+ display: "grid",
51
+ gridTemplateColumns: `repeat(${cols}, 1fr)`,
52
+ gridAutoRows: `minmax(${rowHeight}px, auto)`,
53
+ gap: `${gap}px`,
54
+ }
55
+
56
+ return (
57
+ <div style={gridStyle} className={className}>
58
+ {children}
59
+ </div>
60
+ )
61
+ }
@@ -0,0 +1,112 @@
1
+ "use client"
2
+
3
+ import { useEffect } from "react"
4
+
5
+ interface ErrorInfo {
6
+ message: string
7
+ stack?: string
8
+ source?: string
9
+ line?: number
10
+ column?: number
11
+ timestamp: number
12
+ }
13
+
14
+ export function ErrorReporter() {
15
+ useEffect(() => {
16
+ // Only run in browser and when embedded in an iframe
17
+ if (typeof window === "undefined" || window === window.parent) {
18
+ return
19
+ }
20
+
21
+ const sendError = (error: ErrorInfo) => {
22
+ try {
23
+ window.parent.postMessage(
24
+ { type: "preview-error", error },
25
+ "*"
26
+ )
27
+ } catch {
28
+ // Ignore postMessage errors
29
+ }
30
+ }
31
+
32
+ const sendLoaded = () => {
33
+ try {
34
+ window.parent.postMessage({ type: "preview-loaded" }, "*")
35
+ } catch {
36
+ // Ignore postMessage errors
37
+ }
38
+ }
39
+
40
+ // Handle uncaught errors
41
+ const handleError = (event: ErrorEvent) => {
42
+ sendError({
43
+ message: event.message || "Unknown error",
44
+ stack: event.error?.stack,
45
+ source: event.filename,
46
+ line: event.lineno,
47
+ column: event.colno,
48
+ timestamp: Date.now()
49
+ })
50
+ }
51
+
52
+ // Handle unhandled promise rejections
53
+ const handleRejection = (event: PromiseRejectionEvent) => {
54
+ const reason = event.reason
55
+ sendError({
56
+ message: reason?.message || String(reason) || "Unhandled promise rejection",
57
+ stack: reason?.stack,
58
+ timestamp: Date.now()
59
+ })
60
+ }
61
+
62
+ // Patch console.error to catch React errors and other console errors
63
+ const originalConsoleError = console.error
64
+ console.error = (...args: unknown[]) => {
65
+ // Call original first
66
+ originalConsoleError.apply(console, args)
67
+
68
+ // Extract error message
69
+ const message = args
70
+ .map((arg) => {
71
+ if (arg instanceof Error) {
72
+ return arg.message
73
+ }
74
+ if (typeof arg === "string") {
75
+ return arg
76
+ }
77
+ try {
78
+ return JSON.stringify(arg)
79
+ } catch {
80
+ return String(arg)
81
+ }
82
+ })
83
+ .join(" ")
84
+
85
+ // Get stack trace if available
86
+ const errorArg = args.find((arg) => arg instanceof Error) as Error | undefined
87
+
88
+ sendError({
89
+ message,
90
+ stack: errorArg?.stack,
91
+ timestamp: Date.now()
92
+ })
93
+ }
94
+
95
+ // Add event listeners
96
+ window.addEventListener("error", handleError)
97
+ window.addEventListener("unhandledrejection", handleRejection)
98
+
99
+ // Notify parent that the page has loaded
100
+ sendLoaded()
101
+
102
+ // Cleanup
103
+ return () => {
104
+ window.removeEventListener("error", handleError)
105
+ window.removeEventListener("unhandledrejection", handleRejection)
106
+ console.error = originalConsoleError
107
+ }
108
+ }, [])
109
+
110
+ // This component doesn't render anything
111
+ return null
112
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+
3
+ import { ThemeProvider as NextThemesProvider } from 'next-themes'
4
+
5
+ export function ThemeProvider({
6
+ children,
7
+ ...props
8
+ }: React.ComponentProps<typeof NextThemesProvider>) {
9
+ return <NextThemesProvider {...props}>{children}</NextThemesProvider>
10
+ }
@@ -0,0 +1,54 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState } from 'react'
4
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
5
+
6
+ const themes = [
7
+ { value: 'default', label: 'Default' },
8
+ { value: 'blue', label: 'Blue' },
9
+ { value: 'green', label: 'Green' },
10
+ { value: 'orange', label: 'Orange' },
11
+ { value: 'red', label: 'Red' },
12
+ { value: 'rose', label: 'Rose' },
13
+ { value: 'violet', label: 'Violet' },
14
+ { value: 'yellow', label: 'Yellow' },
15
+ ]
16
+
17
+ export function ThemeSwitcher() {
18
+ const [theme, setTheme] = useState('default')
19
+
20
+ useEffect(() => {
21
+ const saved = localStorage.getItem('color-theme')
22
+ if (saved) setTheme(saved)
23
+ }, [])
24
+
25
+ useEffect(() => {
26
+ const id = 'color-theme-stylesheet'
27
+ let link = document.getElementById(id) as HTMLLinkElement | null
28
+
29
+ if (!link) {
30
+ link = document.createElement('link')
31
+ link.id = id
32
+ link.rel = 'stylesheet'
33
+ document.head.appendChild(link)
34
+ }
35
+
36
+ link.href = `/themes/${theme}.css`
37
+ localStorage.setItem('color-theme', theme)
38
+ }, [theme])
39
+
40
+ return (
41
+ <Select value={theme} onValueChange={setTheme}>
42
+ <SelectTrigger className="w-[120px]">
43
+ <SelectValue placeholder="Theme" />
44
+ </SelectTrigger>
45
+ <SelectContent>
46
+ {themes.map((t) => (
47
+ <SelectItem key={t.value} value={t.value}>
48
+ {t.label}
49
+ </SelectItem>
50
+ ))}
51
+ </SelectContent>
52
+ </Select>
53
+ )
54
+ }
@@ -0,0 +1,21 @@
1
+ 'use client'
2
+
3
+ import { Moon, Sun } from 'lucide-react'
4
+ import { useTheme } from 'next-themes'
5
+ import { Button } from '@/components/ui/button'
6
+
7
+ export function ThemeToggle() {
8
+ const { theme, setTheme } = useTheme()
9
+
10
+ return (
11
+ <Button
12
+ variant="outline"
13
+ size="icon"
14
+ onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
15
+ >
16
+ <Sun className="h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
17
+ <Moon className="absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
18
+ <span className="sr-only">Toggle theme</span>
19
+ </Button>
20
+ )
21
+ }
@@ -0,0 +1,66 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as AccordionPrimitive from "@radix-ui/react-accordion"
5
+ import { ChevronDownIcon } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ function Accordion({
10
+ ...props
11
+ }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
12
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />
13
+ }
14
+
15
+ function AccordionItem({
16
+ className,
17
+ ...props
18
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
19
+ return (
20
+ <AccordionPrimitive.Item
21
+ data-slot="accordion-item"
22
+ className={cn("border-b last:border-b-0", className)}
23
+ {...props}
24
+ />
25
+ )
26
+ }
27
+
28
+ function AccordionTrigger({
29
+ className,
30
+ children,
31
+ ...props
32
+ }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
33
+ return (
34
+ <AccordionPrimitive.Header className="flex">
35
+ <AccordionPrimitive.Trigger
36
+ data-slot="accordion-trigger"
37
+ className={cn(
38
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
39
+ className
40
+ )}
41
+ {...props}
42
+ >
43
+ {children}
44
+ <ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
45
+ </AccordionPrimitive.Trigger>
46
+ </AccordionPrimitive.Header>
47
+ )
48
+ }
49
+
50
+ function AccordionContent({
51
+ className,
52
+ children,
53
+ ...props
54
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
55
+ return (
56
+ <AccordionPrimitive.Content
57
+ data-slot="accordion-content"
58
+ className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
59
+ {...props}
60
+ >
61
+ <div className={cn("pt-0 pb-4", className)}>{children}</div>
62
+ </AccordionPrimitive.Content>
63
+ )
64
+ }
65
+
66
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
@@ -0,0 +1,157 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { buttonVariants } from "@/components/ui/button"
8
+
9
+ function AlertDialog({
10
+ ...props
11
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
12
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
13
+ }
14
+
15
+ function AlertDialogTrigger({
16
+ ...props
17
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
18
+ return (
19
+ <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
20
+ )
21
+ }
22
+
23
+ function AlertDialogPortal({
24
+ ...props
25
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
26
+ return (
27
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
28
+ )
29
+ }
30
+
31
+ function AlertDialogOverlay({
32
+ className,
33
+ ...props
34
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
35
+ return (
36
+ <AlertDialogPrimitive.Overlay
37
+ data-slot="alert-dialog-overlay"
38
+ className={cn(
39
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ function AlertDialogContent({
48
+ className,
49
+ ...props
50
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
51
+ return (
52
+ <AlertDialogPortal>
53
+ <AlertDialogOverlay />
54
+ <AlertDialogPrimitive.Content
55
+ data-slot="alert-dialog-content"
56
+ className={cn(
57
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
58
+ className
59
+ )}
60
+ {...props}
61
+ />
62
+ </AlertDialogPortal>
63
+ )
64
+ }
65
+
66
+ function AlertDialogHeader({
67
+ className,
68
+ ...props
69
+ }: React.ComponentProps<"div">) {
70
+ return (
71
+ <div
72
+ data-slot="alert-dialog-header"
73
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
74
+ {...props}
75
+ />
76
+ )
77
+ }
78
+
79
+ function AlertDialogFooter({
80
+ className,
81
+ ...props
82
+ }: React.ComponentProps<"div">) {
83
+ return (
84
+ <div
85
+ data-slot="alert-dialog-footer"
86
+ className={cn(
87
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
88
+ className
89
+ )}
90
+ {...props}
91
+ />
92
+ )
93
+ }
94
+
95
+ function AlertDialogTitle({
96
+ className,
97
+ ...props
98
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
99
+ return (
100
+ <AlertDialogPrimitive.Title
101
+ data-slot="alert-dialog-title"
102
+ className={cn("text-lg font-semibold", className)}
103
+ {...props}
104
+ />
105
+ )
106
+ }
107
+
108
+ function AlertDialogDescription({
109
+ className,
110
+ ...props
111
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
112
+ return (
113
+ <AlertDialogPrimitive.Description
114
+ data-slot="alert-dialog-description"
115
+ className={cn("text-muted-foreground text-sm", className)}
116
+ {...props}
117
+ />
118
+ )
119
+ }
120
+
121
+ function AlertDialogAction({
122
+ className,
123
+ ...props
124
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
125
+ return (
126
+ <AlertDialogPrimitive.Action
127
+ className={cn(buttonVariants(), className)}
128
+ {...props}
129
+ />
130
+ )
131
+ }
132
+
133
+ function AlertDialogCancel({
134
+ className,
135
+ ...props
136
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
137
+ return (
138
+ <AlertDialogPrimitive.Cancel
139
+ className={cn(buttonVariants({ variant: "outline" }), className)}
140
+ {...props}
141
+ />
142
+ )
143
+ }
144
+
145
+ export {
146
+ AlertDialog,
147
+ AlertDialogPortal,
148
+ AlertDialogOverlay,
149
+ AlertDialogTrigger,
150
+ AlertDialogContent,
151
+ AlertDialogHeader,
152
+ AlertDialogFooter,
153
+ AlertDialogTitle,
154
+ AlertDialogDescription,
155
+ AlertDialogAction,
156
+ AlertDialogCancel,
157
+ }
@@ -0,0 +1,66 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const alertVariants = cva(
7
+ "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-card text-card-foreground",
12
+ destructive:
13
+ "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: "default",
18
+ },
19
+ }
20
+ )
21
+
22
+ function Alert({
23
+ className,
24
+ variant,
25
+ ...props
26
+ }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
27
+ return (
28
+ <div
29
+ data-slot="alert"
30
+ role="alert"
31
+ className={cn(alertVariants({ variant }), className)}
32
+ {...props}
33
+ />
34
+ )
35
+ }
36
+
37
+ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
38
+ return (
39
+ <div
40
+ data-slot="alert-title"
41
+ className={cn(
42
+ "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
43
+ className
44
+ )}
45
+ {...props}
46
+ />
47
+ )
48
+ }
49
+
50
+ function AlertDescription({
51
+ className,
52
+ ...props
53
+ }: React.ComponentProps<"div">) {
54
+ return (
55
+ <div
56
+ data-slot="alert-description"
57
+ className={cn(
58
+ "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
59
+ className
60
+ )}
61
+ {...props}
62
+ />
63
+ )
64
+ }
65
+
66
+ export { Alert, AlertTitle, AlertDescription }
@@ -0,0 +1,11 @@
1
+ "use client"
2
+
3
+ import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"
4
+
5
+ function AspectRatio({
6
+ ...props
7
+ }: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {
8
+ return <AspectRatioPrimitive.Root data-slot="aspect-ratio" {...props} />
9
+ }
10
+
11
+ export { AspectRatio }
@@ -0,0 +1,53 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as AvatarPrimitive from "@radix-ui/react-avatar"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ function Avatar({
9
+ className,
10
+ ...props
11
+ }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
12
+ return (
13
+ <AvatarPrimitive.Root
14
+ data-slot="avatar"
15
+ className={cn(
16
+ "relative flex size-8 shrink-0 overflow-hidden rounded-full",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ function AvatarImage({
25
+ className,
26
+ ...props
27
+ }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
28
+ return (
29
+ <AvatarPrimitive.Image
30
+ data-slot="avatar-image"
31
+ className={cn("aspect-square size-full", className)}
32
+ {...props}
33
+ />
34
+ )
35
+ }
36
+
37
+ function AvatarFallback({
38
+ className,
39
+ ...props
40
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
41
+ return (
42
+ <AvatarPrimitive.Fallback
43
+ data-slot="avatar-fallback"
44
+ className={cn(
45
+ "bg-muted flex size-full items-center justify-center rounded-full",
46
+ className
47
+ )}
48
+ {...props}
49
+ />
50
+ )
51
+ }
52
+
53
+ export { Avatar, AvatarImage, AvatarFallback }
@@ -0,0 +1,46 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ const badgeVariants = cva(
8
+ "inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default:
13
+ "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
14
+ secondary:
15
+ "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
16
+ destructive:
17
+ "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
18
+ outline:
19
+ "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ variant: "default",
24
+ },
25
+ }
26
+ )
27
+
28
+ function Badge({
29
+ className,
30
+ variant,
31
+ asChild = false,
32
+ ...props
33
+ }: React.ComponentProps<"span"> &
34
+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
35
+ const Comp = asChild ? Slot : "span"
36
+
37
+ return (
38
+ <Comp
39
+ data-slot="badge"
40
+ className={cn(badgeVariants({ variant }), className)}
41
+ {...props}
42
+ />
43
+ )
44
+ }
45
+
46
+ export { Badge, badgeVariants }