Spaces:
Sleeping
Sleeping
Commit
·
47cf216
0
Parent(s):
Déploiement final Startech V1
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +35 -0
- Dockerfile +24 -0
- app/admin/login/page.tsx +45 -0
- app/admin/page.tsx +149 -0
- app/globals.css +174 -0
- app/layout.tsx +47 -0
- app/page.tsx +183 -0
- backend/requirements.txt +9 -0
- backend/server.py +191 -0
- backend/test_face.py +60 -0
- components.json +21 -0
- components/neurolink/comparison-chart.tsx +61 -0
- components/neurolink/emotional-intensity-chart.tsx +79 -0
- components/neurolink/header.tsx +64 -0
- components/neurolink/metric-gauge.tsx +78 -0
- components/neurolink/metrics-panel.tsx +144 -0
- components/neurolink/video-player.tsx +74 -0
- components/theme-provider.tsx +11 -0
- components/ui/accordion.tsx +66 -0
- components/ui/alert-dialog.tsx +157 -0
- components/ui/alert.tsx +66 -0
- components/ui/aspect-ratio.tsx +11 -0
- components/ui/avatar.tsx +53 -0
- components/ui/badge.tsx +46 -0
- components/ui/breadcrumb.tsx +109 -0
- components/ui/button-group.tsx +83 -0
- components/ui/button.tsx +60 -0
- components/ui/calendar.tsx +213 -0
- components/ui/card.tsx +92 -0
- components/ui/carousel.tsx +241 -0
- components/ui/chart.tsx +353 -0
- components/ui/checkbox.tsx +32 -0
- components/ui/collapsible.tsx +33 -0
- components/ui/command.tsx +184 -0
- components/ui/context-menu.tsx +252 -0
- components/ui/dialog.tsx +143 -0
- components/ui/drawer.tsx +135 -0
- components/ui/dropdown-menu.tsx +257 -0
- components/ui/empty.tsx +104 -0
- components/ui/field.tsx +244 -0
- components/ui/form.tsx +167 -0
- components/ui/hover-card.tsx +44 -0
- components/ui/input-group.tsx +169 -0
- components/ui/input-otp.tsx +77 -0
- components/ui/input.tsx +21 -0
- components/ui/item.tsx +193 -0
- components/ui/kbd.tsx +28 -0
- components/ui/label.tsx +24 -0
- components/ui/menubar.tsx +276 -0
- components/ui/navigation-menu.tsx +166 -0
.gitignore
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- FRONTEND (Node/Next.js) ---
|
| 2 |
+
/node_modules
|
| 3 |
+
/.next/
|
| 4 |
+
/out/
|
| 5 |
+
/build
|
| 6 |
+
npm-debug.log*
|
| 7 |
+
yarn-debug.log*
|
| 8 |
+
yarn-error.log*
|
| 9 |
+
.pnpm-debug.log*
|
| 10 |
+
.vercel
|
| 11 |
+
*.tsbuildinfo
|
| 12 |
+
next-env.d.ts
|
| 13 |
+
|
| 14 |
+
# --- BACKEND (Python) ---
|
| 15 |
+
# Ignore le dossier d'environnement virtuel (très lourd)
|
| 16 |
+
venv/
|
| 17 |
+
env/
|
| 18 |
+
.venv/
|
| 19 |
+
|
| 20 |
+
# Ignore les fichiers compilés Python
|
| 21 |
+
__pycache__/
|
| 22 |
+
*.py[cod]
|
| 23 |
+
*$py.class
|
| 24 |
+
|
| 25 |
+
# Ignore la base de données locale (on utilise Supabase maintenant)
|
| 26 |
+
startech.db
|
| 27 |
+
*.sqlite3
|
| 28 |
+
|
| 29 |
+
# --- SÉCURITÉ (Secrets) ---
|
| 30 |
+
.env
|
| 31 |
+
.env.local
|
| 32 |
+
.env.development.local
|
| 33 |
+
.env.test.local
|
| 34 |
+
.env.production.local
|
| 35 |
+
.DS_Store
|
Dockerfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 1. Image Python stable
|
| 2 |
+
FROM python:3.10
|
| 3 |
+
|
| 4 |
+
# 2. Dossier de travail dans le conteneur
|
| 5 |
+
WORKDIR /code
|
| 6 |
+
|
| 7 |
+
# 3. Copie des requirements (On va chercher dans le dossier backend)
|
| 8 |
+
COPY ./backend/requirements.txt /code/requirements.txt
|
| 9 |
+
|
| 10 |
+
# 4. Installation des dépendances (Mise à jour de pip + installation)
|
| 11 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 12 |
+
pip install --no-cache-dir -r /code/requirements.txt
|
| 13 |
+
|
| 14 |
+
# 5. Création du dossier pour les poids DeepFace (évite les erreurs de permission)
|
| 15 |
+
RUN mkdir -p /root/.deepface/weights
|
| 16 |
+
|
| 17 |
+
# 6. Copie du code backend
|
| 18 |
+
COPY ./backend /code
|
| 19 |
+
|
| 20 |
+
# 7. Ouverture du port standard Hugging Face
|
| 21 |
+
EXPOSE 7860
|
| 22 |
+
|
| 23 |
+
# 8. Lancement du serveur (Host 0.0.0.0 est vital pour le cloud)
|
| 24 |
+
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/admin/login/page.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import { useRouter } from "next/navigation"
|
| 5 |
+
import { supabase } from "@/lib/supabase"
|
| 6 |
+
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card"
|
| 7 |
+
import { Button } from "@/components/ui/button"
|
| 8 |
+
import { Input } from "@/components/ui/input"
|
| 9 |
+
import { Label } from "@/components/ui/label"
|
| 10 |
+
import { Shield, Lock, AlertCircle, Mail } from "lucide-react"
|
| 11 |
+
|
| 12 |
+
export default function AdminLogin() {
|
| 13 |
+
const [email, setEmail] = useState("")
|
| 14 |
+
const [password, setPassword] = useState("")
|
| 15 |
+
const [error, setError] = useState("")
|
| 16 |
+
const [loading, setLoading] = useState(false)
|
| 17 |
+
const router = useRouter()
|
| 18 |
+
|
| 19 |
+
const handleLogin = async (e: React.FormEvent) => {
|
| 20 |
+
e.preventDefault(); setLoading(true); setError("")
|
| 21 |
+
const { data, error } = await supabase.auth.signInWithPassword({ email, password })
|
| 22 |
+
if (error) { setError("Erreur : " + error.message); setLoading(false) }
|
| 23 |
+
else { localStorage.setItem("startech_admin_token", "authorized_access_granted"); router.push("/admin") }
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
return (
|
| 27 |
+
<div className="min-h-screen bg-slate-50 flex items-center justify-center p-4 relative overflow-hidden text-slate-900">
|
| 28 |
+
<div className="absolute inset-0 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-blue-100 via-slate-50 to-white opacity-80"></div>
|
| 29 |
+
<Card className="w-full max-w-md border-slate-200 bg-white shadow-2xl relative z-10">
|
| 30 |
+
<CardHeader className="text-center space-y-4">
|
| 31 |
+
<div className="mx-auto w-16 h-16 rounded-full bg-blue-50 flex items-center justify-center border border-blue-100 shadow-sm"><Lock className="w-8 h-8 text-blue-600" /></div>
|
| 32 |
+
<div><CardTitle className="text-2xl font-bold tracking-tight text-slate-900">STARTECH <span className="text-blue-600">ADMIN</span></CardTitle><CardDescription className="text-slate-500">Connexion Cloud Sécurisée</CardDescription></div>
|
| 33 |
+
</CardHeader>
|
| 34 |
+
<form onSubmit={handleLogin}>
|
| 35 |
+
<CardContent className="space-y-4">
|
| 36 |
+
<div className="space-y-2"><Label htmlFor="email" className="text-slate-700">Email Admin</Label><div className="relative"><Mail className="absolute left-3 top-3 h-4 w-4 text-slate-400" /><Input id="email" type="email" placeholder="admin@startech.com" className="pl-10" value={email} onChange={e => setEmail(e.target.value)} required /></div></div>
|
| 37 |
+
<div className="space-y-2"><Label htmlFor="password" className="text-slate-700">Mot de passe</Label><div className="relative"><Shield className="absolute left-3 top-3 h-4 w-4 text-slate-400" /><Input id="password" type="password" placeholder="••••••••" className="pl-10" value={password} onChange={e => setPassword(e.target.value)} required /></div></div>
|
| 38 |
+
{error && <div className="flex items-center gap-2 text-red-600 text-sm bg-red-50 p-3 rounded-md border border-red-100"><AlertCircle className="w-4 h-4" />{error}</div>}
|
| 39 |
+
</CardContent>
|
| 40 |
+
<CardFooter><Button type="submit" className="w-full bg-blue-600 hover:bg-blue-700 text-white" disabled={loading}>{loading ? "Connexion..." : "Se connecter"}</Button></CardFooter>
|
| 41 |
+
</form>
|
| 42 |
+
</Card>
|
| 43 |
+
</div>
|
| 44 |
+
)
|
| 45 |
+
}
|
app/admin/page.tsx
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect } from "react"
|
| 4 |
+
import { useRouter } from "next/navigation"
|
| 5 |
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { Badge } from "@/components/ui/badge"
|
| 8 |
+
import { ScrollArea } from "@/components/ui/scroll-area"
|
| 9 |
+
import { ArrowLeft, Calendar, Database, FileText, Trash2, Clock, Activity, ThumbsUp, LogOut, ArrowRightLeft, Trophy } from "lucide-react"
|
| 10 |
+
import Link from "next/link"
|
| 11 |
+
import ComparisonChart from "@/components/neurolink/comparison-chart"
|
| 12 |
+
|
| 13 |
+
const CircularProgress = ({ value, color, label, icon: Icon }: any) => {
|
| 14 |
+
const radius = 30; const circumference = 2 * Math.PI * radius; const offset = circumference - (value / 100) * circumference
|
| 15 |
+
return (
|
| 16 |
+
<div className="flex flex-col items-center justify-center space-y-2">
|
| 17 |
+
<div className="relative flex items-center justify-center">
|
| 18 |
+
<svg className="transform -rotate-90 w-24 h-24">
|
| 19 |
+
<circle cx="48" cy="48" r={radius} stroke="#e2e8f0" strokeWidth="8" fill="transparent" />
|
| 20 |
+
<circle cx="48" cy="48" r={radius} stroke={color} strokeWidth="8" fill="transparent" strokeDasharray={circumference} strokeDashoffset={offset} strokeLinecap="round" className="transition-all duration-1000 ease-out" />
|
| 21 |
+
</svg>
|
| 22 |
+
<div className="absolute inset-0 flex items-center justify-center flex-col"><span className="text-lg font-bold text-slate-900">{value}%</span></div>
|
| 23 |
+
</div>
|
| 24 |
+
<div className="flex items-center gap-1 text-xs font-medium text-slate-500 uppercase tracking-wide">{Icon && <Icon className="w-3 h-3" />} {label}</div>
|
| 25 |
+
</div>
|
| 26 |
+
)
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export default function AdminPage() {
|
| 30 |
+
const [sessions, setSessions] = useState<any[]>([])
|
| 31 |
+
const [isAuthorized, setIsAuthorized] = useState(false)
|
| 32 |
+
const router = useRouter()
|
| 33 |
+
const [isCompareMode, setIsCompareMode] = useState(false)
|
| 34 |
+
const [sessionA, setSessionA] = useState<any>(null); const [dataA, setDataA] = useState<any[]>([]); const [statsA, setStatsA] = useState<any>(null)
|
| 35 |
+
const [sessionB, setSessionB] = useState<any>(null); const [dataB, setDataB] = useState<any[]>([]); const [statsB, setStatsB] = useState<any>(null)
|
| 36 |
+
|
| 37 |
+
useEffect(() => {
|
| 38 |
+
const token = localStorage.getItem("startech_admin_token")
|
| 39 |
+
if (token !== "authorized_access_granted") { router.push("/admin/login") }
|
| 40 |
+
else { setIsAuthorized(true); fetch('http://localhost:8000/api/sessions').then(res => res.json()).then(data => setSessions(data)) }
|
| 41 |
+
}, [])
|
| 42 |
+
|
| 43 |
+
const handleSelectSession = (sessionId: number) => {
|
| 44 |
+
fetch(`http://localhost:8000/api/sessions/${sessionId}`).then(res => res.json()).then(response => {
|
| 45 |
+
const info = response.info; const data = response.data; const stats = calculateStatsInternal(data)
|
| 46 |
+
if (isCompareMode) {
|
| 47 |
+
if (!sessionA) { setSessionA(info); setDataA(data); setStatsA(stats) }
|
| 48 |
+
else if (!sessionB && sessionId !== sessionA.id) { setSessionB(info); setDataB(data); setStatsB(stats) }
|
| 49 |
+
else if (sessionA && sessionB) { setSessionA(info); setDataA(data); setStatsA(stats); setSessionB(null); setDataB([]); setStatsB(null) }
|
| 50 |
+
} else { setSessionA(info); setDataA(data); setStatsA(stats); setSessionB(null); setDataB([]); setStatsB(null) }
|
| 51 |
+
})
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
const calculateStatsInternal = (data: any[]) => {
|
| 55 |
+
if (data.length === 0) return null
|
| 56 |
+
const avg = (key: string) => Math.round(data.reduce((acc, curr) => acc + curr[key], 0) / data.length)
|
| 57 |
+
return { duration: data.length, avg_engagement: avg('engagement_val'), avg_satisfaction: avg('satisfaction_val'), dominant_label: data[data.length - 1]?.satisfaction_lbl || "N/A" }
|
| 58 |
+
}
|
| 59 |
+
const toggleCompareMode = () => { setIsCompareMode(!isCompareMode); setSessionB(null); setDataB([]); setStatsB(null) }
|
| 60 |
+
const handleDeleteSession = async (e: React.MouseEvent, sessionId: number) => {
|
| 61 |
+
e.stopPropagation(); if (!confirm("Supprimer définitivement ?")) return
|
| 62 |
+
const res = await fetch(`http://localhost:8000/api/sessions/${sessionId}`, { method: 'DELETE' })
|
| 63 |
+
if (res.ok) { setSessions(prev => prev.filter(s => s.id !== sessionId)); if (sessionA?.id === sessionId) { setSessionA(null); setDataA([]); setStatsA(null) }; if (sessionB?.id === sessionId) { setSessionB(null); setDataB([]); setStatsB(null) } }
|
| 64 |
+
}
|
| 65 |
+
const handleExport = (session: any, data: any) => {
|
| 66 |
+
if (!data.length) return
|
| 67 |
+
const headers = ["Temps", "Emotion", "Score IA", "Engagement", "Label Engagement", "Satisfaction", "Label Satisfaction", "Confiance", "Fidelite", "Avis"]
|
| 68 |
+
const rows = data.map((row: any) => [ String(row.session_time).replace('.', ','), row.emotion, row.emotion_score ? String(row.emotion_score.toFixed(2)).replace('.', ',') : "0", String(row.engagement_val), `"${row.engagement_lbl}"`, String(row.satisfaction_val), `"${row.satisfaction_lbl}"`, String(row.trust_val), String(row.loyalty_val), `"${row.opinion_lbl}"` ])
|
| 69 |
+
const csvContent = [headers.join(";"), ...rows.map((e: any) => e.join(";"))].join("\n")
|
| 70 |
+
const blob = new Blob(["\uFEFF" + csvContent], { type: "text/csv;charset=utf-8;" }); const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.setAttribute("download", `Rapport_${session.first_name}.csv`); document.body.appendChild(link); link.click(); document.body.removeChild(link)
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// CORRECTION DE LA DATE ICI : On gère created_at de Supabase
|
| 74 |
+
const formatDate = (dateStr: string) => {
|
| 75 |
+
if (!dateStr) return "Date inconnue";
|
| 76 |
+
try {
|
| 77 |
+
return new Date(dateStr).toLocaleString('fr-FR', { day: 'numeric', month: 'short', hour: '2-digit', minute:'2-digit' })
|
| 78 |
+
} catch (e) { return "Erreur date" }
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if (!isAuthorized) return null
|
| 82 |
+
|
| 83 |
+
return (
|
| 84 |
+
<div className="min-h-screen bg-slate-50 text-slate-900 flex flex-col font-sans">
|
| 85 |
+
<header className="border-b border-slate-200 bg-white p-4 flex items-center justify-between sticky top-0 z-50 shadow-sm">
|
| 86 |
+
<div className="flex items-center gap-4">
|
| 87 |
+
<Link href="/"><Button variant="ghost" size="icon" className="text-slate-500 hover:text-blue-600 hover:bg-blue-50"><ArrowLeft className="w-5 h-5" /></Button></Link>
|
| 88 |
+
<div><h1 className="text-xl font-bold flex items-center gap-2 text-slate-900"><Database className="w-5 h-5 text-blue-600" /> STARTECH <span className="text-slate-400">ADMIN</span></h1></div>
|
| 89 |
+
</div>
|
| 90 |
+
<div className="flex items-center gap-4">
|
| 91 |
+
<Button onClick={toggleCompareMode} className={`gap-2 border transition-colors duration-200 ${isCompareMode ? "bg-purple-600 border-purple-600 text-white hover:bg-purple-700 hover:text-white" : "bg-white border-slate-300 text-slate-700 hover:bg-slate-100 hover:text-slate-900"}`}><ArrowRightLeft className="w-4 h-4" /> {isCompareMode ? "Mode Comparaison Actif" : "Comparer deux sessions"}</Button>
|
| 92 |
+
<Button variant="ghost" onClick={() => {localStorage.removeItem("startech_admin_token"); router.push("/admin/login")}} className="text-slate-500 hover:text-red-600 hover:bg-red-50 gap-2"><LogOut className="w-4 h-4" /></Button>
|
| 93 |
+
</div>
|
| 94 |
+
</header>
|
| 95 |
+
|
| 96 |
+
<main className="flex-1 overflow-hidden grid grid-cols-12 h-[calc(100vh-64px)]">
|
| 97 |
+
<div className="col-span-3 border-r border-slate-200 bg-white flex flex-col h-full">
|
| 98 |
+
<div className="p-4 border-b border-slate-200 bg-slate-50/50"><h2 className="text-xs font-bold uppercase tracking-widest text-slate-500">Historique</h2></div>
|
| 99 |
+
<ScrollArea className="flex-1 bg-white">
|
| 100 |
+
<div className="flex flex-col">
|
| 101 |
+
{sessions.map((session) => {
|
| 102 |
+
const isA = sessionA?.id === session.id; const isB = sessionB?.id === session.id
|
| 103 |
+
let activeClass = "border-l-4 border-l-transparent"
|
| 104 |
+
if (isA) activeClass = "bg-blue-50 border-l-blue-500"; if (isB) activeClass = "bg-orange-50 border-l-orange-500"
|
| 105 |
+
return (
|
| 106 |
+
<div key={session.id} onClick={() => handleSelectSession(session.id)} className={`group flex items-center justify-between p-4 border-b border-slate-100 hover:bg-slate-50 cursor-pointer transition-all ${activeClass}`}>
|
| 107 |
+
<div>
|
| 108 |
+
<div className="font-bold flex items-center gap-2 text-slate-800">{session.first_name} {session.last_name} {isA && <Badge className="bg-blue-500 h-4 px-1 text-[9px]">A</Badge>} {isB && <Badge className="bg-orange-500 h-4 px-1 text-[9px]">B</Badge>}</div>
|
| 109 |
+
{/* CORRECTION ICI : created_at au lieu de start_time */}
|
| 110 |
+
<div className="text-xs text-slate-500 mt-1 flex items-center gap-2"><Calendar className="w-3 h-3" /> {formatDate(session.created_at)}</div>
|
| 111 |
+
</div>
|
| 112 |
+
<Button variant="ghost" size="icon" className="h-8 w-8 text-slate-400 opacity-0 group-hover:opacity-100" onClick={(e) => handleDeleteSession(e, session.id)}><Trash2 className="w-4 h-4 hover:text-red-500" /></Button>
|
| 113 |
+
</div>
|
| 114 |
+
)
|
| 115 |
+
})}
|
| 116 |
+
</div>
|
| 117 |
+
</ScrollArea>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<div className="col-span-9 p-6 overflow-y-auto bg-slate-50">
|
| 121 |
+
{!isCompareMode && sessionA && statsA && (
|
| 122 |
+
<div className="max-w-5xl mx-auto space-y-6 animate-in fade-in slide-in-from-bottom-4">
|
| 123 |
+
<div className="flex justify-between items-start">
|
| 124 |
+
<div><h2 className="text-3xl font-bold text-slate-900">{sessionA.first_name} {sessionA.last_name}</h2><p className="text-slate-500 flex items-center gap-2 mt-1"><Clock className="w-4 h-4" /> Durée: {statsA.duration}s | ID: {sessionA.client_id || "N/A"}</p></div>
|
| 125 |
+
<Button variant="outline" className="bg-white border-slate-200 text-slate-700 hover:bg-slate-50" onClick={() => handleExport(sessionA, dataA)}><FileText className="w-4 h-4 mr-2" /> CSV</Button>
|
| 126 |
+
</div>
|
| 127 |
+
<div className="grid grid-cols-3 gap-6">
|
| 128 |
+
<Card className="bg-white shadow-sm border-slate-200"><CardContent className="pt-6"><CircularProgress value={statsA.avg_engagement} color="#3b82f6" label="Engagement" icon={Activity} /></CardContent></Card>
|
| 129 |
+
<Card className="bg-white shadow-sm border-slate-200"><CardContent className="pt-6"><CircularProgress value={statsA.avg_satisfaction} color="#22c55e" label="Satisfaction" icon={ThumbsUp} /></CardContent></Card>
|
| 130 |
+
<Card className="flex items-center justify-center bg-slate-900 text-white shadow-sm border-slate-900"><div className="text-center"><Badge variant="outline" className="mb-2 text-slate-400 border-slate-700">Verdict</Badge><div className="text-xl font-bold">{statsA.dominant_label}</div></div></Card>
|
| 131 |
+
</div>
|
| 132 |
+
<Card className="bg-white shadow-sm border-slate-200"><CardHeader><CardTitle className="text-slate-900">Analyse Temporelle</CardTitle></CardHeader><CardContent><ComparisonChart dataA={dataA} dataB={[]} nameA={`${sessionA.first_name} (Engagement)`} nameB="" /></CardContent></Card>
|
| 133 |
+
<Card className="bg-white shadow-sm border-slate-200"><CardHeader><CardTitle className="text-slate-900">Données Brutes Complètes</CardTitle></CardHeader><CardContent><div className="rounded-md border border-slate-200 overflow-hidden"><ScrollArea className="h-[400px] w-full"><table className="w-full text-sm text-left text-slate-700"><thead className="bg-slate-100 font-medium sticky top-0 z-10 text-slate-900"><tr><th className="p-3">Temps</th><th className="p-3">Émotion</th><th className="p-3">Score IA</th><th className="p-3 border-l border-slate-200">Engagement</th><th className="p-3 border-l border-slate-200">Satisfaction</th><th className="p-3 border-l border-slate-200">Confiance</th><th className="p-3 border-l border-slate-200">Fidélité</th><th className="p-3 border-l border-slate-200">Avis</th></tr></thead><tbody className="divide-y divide-slate-100">{dataA.map((row, i) => (<tr key={i} className="hover:bg-slate-50 transition-colors"><td className="p-3 font-mono text-xs">{row.session_time}s</td><td className="p-3 capitalize flex items-center gap-2"><Badge variant="secondary" className="text-[10px] bg-slate-100 text-slate-700">{row.emotion}</Badge></td><td className="p-3 font-mono text-xs text-slate-500">{row.emotion_score?.toFixed(1)}%</td><td className="p-3 border-l border-slate-100"><div className="flex flex-col"><span className="font-bold text-xs">{row.engagement_val}%</span><span className="text-[10px] text-slate-400">{row.engagement_lbl}</span></div></td><td className="p-3 border-l border-slate-100"><div className="flex flex-col"><span className={`font-bold text-xs ${row.satisfaction_val > 50 ? "text-green-600" : "text-orange-500"}`}>{row.satisfaction_val}%</span><span className="text-[10px] text-slate-400">{row.satisfaction_lbl}</span></div></td><td className="p-3 border-l border-slate-100"><div className="flex flex-col"><span className="font-bold text-xs">{row.trust_val}%</span><span className="text-[10px] text-slate-400">{row.trust_lbl}</span></div></td><td className="p-3 border-l border-slate-100"><div className="flex flex-col"><span className="font-bold text-xs">{row.loyalty_val}%</span><span className="text-[10px] text-slate-400">{row.loyalty_lbl}</span></div></td><td className="p-3 border-l border-slate-100"><span className="text-xs">{row.opinion_lbl}</span></td></tr>))}</tbody></table></ScrollArea></div></CardContent></Card>
|
| 134 |
+
</div>
|
| 135 |
+
)}
|
| 136 |
+
{isCompareMode && sessionA && sessionB && statsA && statsB && (
|
| 137 |
+
<div className="max-w-6xl mx-auto space-y-6 animate-in fade-in zoom-in-95">
|
| 138 |
+
<div className="grid grid-cols-3 items-center text-center bg-white shadow-sm p-6 rounded-2xl border border-slate-200"><div className="text-blue-600"><div className="text-2xl font-bold">{sessionA.first_name}</div><div className="text-sm opacity-70">Session A</div></div><div className="flex justify-center"><div className="bg-slate-100 rounded-full px-4 py-1 text-xs font-bold text-slate-500 border border-slate-200">VS</div></div><div className="text-orange-500"><div className="text-2xl font-bold">{sessionB.first_name}</div><div className="text-sm opacity-70">Session B</div></div></div>
|
| 139 |
+
<Card className="border-slate-200 bg-white shadow-sm"><CardHeader><CardTitle className="text-slate-900">Duel d'Engagement</CardTitle></CardHeader><CardContent><ComparisonChart dataA={dataA} dataB={dataB} nameA={`Engagement ${sessionA.first_name}`} nameB={`Engagement ${sessionB.first_name}`} /></CardContent></Card>
|
| 140 |
+
<div className="grid grid-cols-2 gap-6"><Card className={`border-t-4 border-t-blue-500 shadow-sm bg-white ${statsA.avg_engagement > statsB.avg_engagement ? "bg-blue-50" : ""}`}><CardHeader><CardTitle className="flex justify-between text-slate-900">{sessionA.first_name}{statsA.avg_engagement > statsB.avg_engagement && <Badge className="bg-yellow-400 text-black gap-1 hover:bg-yellow-500"><Trophy className="w-3 h-3" /> Vainqueur</Badge>}</CardTitle></CardHeader><CardContent className="grid grid-cols-2 gap-4"><CircularProgress value={statsA.avg_engagement} color="#3b82f6" label="Engagement" icon={Activity} /><CircularProgress value={statsA.avg_satisfaction} color="#3b82f6" label="Satisfaction" icon={ThumbsUp} /></CardContent></Card><Card className={`border-t-4 border-t-orange-500 shadow-sm bg-white ${statsB.avg_engagement > statsA.avg_engagement ? "bg-orange-50" : ""}`}><CardHeader><CardTitle className="flex justify-between text-slate-900">{sessionB.first_name}{statsB.avg_engagement > statsA.avg_engagement && <Badge className="bg-yellow-400 text-black gap-1 hover:bg-yellow-500"><Trophy className="w-3 h-3" /> Vainqueur</Badge>}</CardTitle></CardHeader><CardContent className="grid grid-cols-2 gap-4"><CircularProgress value={statsB.avg_engagement} color="#f97316" label="Engagement" icon={Activity} /><CircularProgress value={statsB.avg_satisfaction} color="#f97316" label="Satisfaction" icon={ThumbsUp} /></CardContent></Card></div>
|
| 141 |
+
</div>
|
| 142 |
+
)}
|
| 143 |
+
{(!sessionA) && <div className="h-full flex flex-col items-center justify-center text-slate-400 opacity-50"><ArrowLeft className="w-12 h-12 mb-4 animate-pulse" /><p>Sélectionnez une session à gauche pour commencer.</p></div>}
|
| 144 |
+
{(isCompareMode && sessionA && !sessionB) && <div className="h-full flex flex-col items-center justify-center text-slate-400 opacity-50"><div className="text-blue-600 font-bold mb-2">Session A : {sessionA.first_name} sélectionnée.</div><p>Maintenant, sélectionnez la Session B dans la liste.</p></div>}
|
| 145 |
+
</div>
|
| 146 |
+
</main>
|
| 147 |
+
</div>
|
| 148 |
+
)
|
| 149 |
+
}
|
app/globals.css
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import "tailwindcss";
|
| 2 |
+
@import "tw-animate-css";
|
| 3 |
+
|
| 4 |
+
@custom-variant dark (&:is(.dark *));
|
| 5 |
+
|
| 6 |
+
:root {
|
| 7 |
+
/* Light neuromarketing color scheme */
|
| 8 |
+
--background: oklch(0.98 0.01 0);
|
| 9 |
+
--foreground: oklch(0.15 0.01 0);
|
| 10 |
+
--card: oklch(1 0 0);
|
| 11 |
+
--card-foreground: oklch(0.15 0.01 0);
|
| 12 |
+
--popover: oklch(1 0 0);
|
| 13 |
+
--popover-foreground: oklch(0.15 0.01 0);
|
| 14 |
+
--primary: oklch(0.5 0.15 260);
|
| 15 |
+
--primary-foreground: oklch(1 0 0);
|
| 16 |
+
--secondary: oklch(0.7 0.1 260);
|
| 17 |
+
--secondary-foreground: oklch(0.15 0.01 0);
|
| 18 |
+
--muted: oklch(0.8 0.02 0);
|
| 19 |
+
--muted-foreground: oklch(0.45 0.01 0);
|
| 20 |
+
--accent: oklch(0.6 0.2 280);
|
| 21 |
+
--accent-foreground: oklch(1 0 0);
|
| 22 |
+
--destructive: oklch(0.6 0.22 28);
|
| 23 |
+
--destructive-foreground: oklch(1 0 0);
|
| 24 |
+
--border: oklch(0.9 0.02 0);
|
| 25 |
+
--input: oklch(0.95 0.02 0);
|
| 26 |
+
--ring: oklch(0.5 0.15 260);
|
| 27 |
+
--chart-1: oklch(0.5 0.15 260);
|
| 28 |
+
--chart-2: oklch(0.6 0.2 300);
|
| 29 |
+
--chart-3: oklch(0.6 0.22 28);
|
| 30 |
+
--chart-4: oklch(0.7 0.15 280);
|
| 31 |
+
--chart-5: oklch(0.5 0.18 50);
|
| 32 |
+
--radius: 0.625rem;
|
| 33 |
+
--sidebar: oklch(1 0 0);
|
| 34 |
+
--sidebar-foreground: oklch(0.15 0.01 0);
|
| 35 |
+
--sidebar-primary: oklch(0.5 0.15 260);
|
| 36 |
+
--sidebar-primary-foreground: oklch(1 0 0);
|
| 37 |
+
--sidebar-accent: oklch(0.6 0.2 300);
|
| 38 |
+
--sidebar-accent-foreground: oklch(1 0 0);
|
| 39 |
+
--sidebar-border: oklch(0.9 0.02 0);
|
| 40 |
+
--sidebar-ring: oklch(0.5 0.15 260);
|
| 41 |
+
|
| 42 |
+
/* NeuroLink specific colors */
|
| 43 |
+
--neuro-green: #16a34a;
|
| 44 |
+
--neuro-red: #dc2626;
|
| 45 |
+
--neuro-blue: #2563eb;
|
| 46 |
+
--neuro-orange: #ea580c;
|
| 47 |
+
--neuro-accent: #2563eb;
|
| 48 |
+
--neuro-text: #1f2937;
|
| 49 |
+
--neuro-muted: #6b7280;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.dark {
|
| 53 |
+
--background: oklch(0.08 0 0);
|
| 54 |
+
--foreground: oklch(0.95 0.01 0);
|
| 55 |
+
--card: oklch(0.1 0.01 0);
|
| 56 |
+
--card-foreground: oklch(0.95 0.01 0);
|
| 57 |
+
--popover: oklch(0.1 0.01 0);
|
| 58 |
+
--popover-foreground: oklch(0.95 0.01 0);
|
| 59 |
+
--primary: oklch(0.85 0.15 131);
|
| 60 |
+
--primary-foreground: oklch(0.08 0 0);
|
| 61 |
+
--secondary: oklch(0.3 0.1 0);
|
| 62 |
+
--secondary-foreground: oklch(0.95 0.01 0);
|
| 63 |
+
--muted: oklch(0.25 0.05 0);
|
| 64 |
+
--muted-foreground: oklch(0.65 0.01 0);
|
| 65 |
+
--accent: oklch(0.6 0.2 300);
|
| 66 |
+
--accent-foreground: oklch(0.08 0 0);
|
| 67 |
+
--destructive: oklch(0.6 0.22 28);
|
| 68 |
+
--destructive-foreground: oklch(0.95 0.01 0);
|
| 69 |
+
--border: oklch(0.2 0.02 0);
|
| 70 |
+
--input: oklch(0.15 0.02 0);
|
| 71 |
+
--ring: oklch(0.85 0.15 131);
|
| 72 |
+
--chart-1: oklch(0.85 0.15 131);
|
| 73 |
+
--chart-2: oklch(0.6 0.2 300);
|
| 74 |
+
--chart-3: oklch(0.6 0.22 28);
|
| 75 |
+
--chart-4: oklch(0.7 0.15 280);
|
| 76 |
+
--chart-5: oklch(0.5 0.18 50);
|
| 77 |
+
--sidebar: oklch(0.1 0.01 0);
|
| 78 |
+
--sidebar-foreground: oklch(0.95 0.01 0);
|
| 79 |
+
--sidebar-primary: oklch(0.85 0.15 131);
|
| 80 |
+
--sidebar-primary-foreground: oklch(0.08 0 0);
|
| 81 |
+
--sidebar-accent: oklch(0.6 0.2 300);
|
| 82 |
+
--sidebar-accent-foreground: oklch(0.08 0 0);
|
| 83 |
+
--sidebar-border: oklch(0.2 0.02 0);
|
| 84 |
+
--sidebar-ring: oklch(0.85 0.15 131);
|
| 85 |
+
|
| 86 |
+
--neuro-green: #22c55e;
|
| 87 |
+
--neuro-red: #ef4444;
|
| 88 |
+
--neuro-blue: #3b82f6;
|
| 89 |
+
--neuro-accent: #8b5cf6;
|
| 90 |
+
--neuro-text: #e2e8f0;
|
| 91 |
+
--neuro-muted: #94a3b8;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
@theme inline {
|
| 95 |
+
--font-sans: "Geist", "Geist Fallback";
|
| 96 |
+
--font-mono: "Geist Mono", "Geist Mono Fallback";
|
| 97 |
+
--color-background: var(--background);
|
| 98 |
+
--color-foreground: var(--foreground);
|
| 99 |
+
--color-card: var(--card);
|
| 100 |
+
--color-card-foreground: var(--card-foreground);
|
| 101 |
+
--color-popover: var(--popover);
|
| 102 |
+
--color-popover-foreground: var(--popover-foreground);
|
| 103 |
+
--color-primary: var(--primary);
|
| 104 |
+
--color-primary-foreground: var(--primary-foreground);
|
| 105 |
+
--color-secondary: var(--secondary);
|
| 106 |
+
--color-secondary-foreground: var(--secondary-foreground);
|
| 107 |
+
--color-muted: var(--muted);
|
| 108 |
+
--color-muted-foreground: var(--muted-foreground);
|
| 109 |
+
--color-accent: var(--accent);
|
| 110 |
+
--color-accent-foreground: var(--accent-foreground);
|
| 111 |
+
--color-destructive: var(--destructive);
|
| 112 |
+
--color-destructive-foreground: var(--destructive-foreground);
|
| 113 |
+
--color-border: var(--border);
|
| 114 |
+
--color-input: var(--input);
|
| 115 |
+
--color-ring: var(--ring);
|
| 116 |
+
--color-chart-1: var(--chart-1);
|
| 117 |
+
--color-chart-2: var(--chart-2);
|
| 118 |
+
--color-chart-3: var(--chart-3);
|
| 119 |
+
--color-chart-4: var(--chart-4);
|
| 120 |
+
--color-chart-5: var(--chart-5);
|
| 121 |
+
--radius-sm: calc(var(--radius) - 4px);
|
| 122 |
+
--radius-md: calc(var(--radius) - 2px);
|
| 123 |
+
--radius-lg: var(--radius);
|
| 124 |
+
--radius-xl: calc(var(--radius) + 4px);
|
| 125 |
+
--color-sidebar: var(--sidebar);
|
| 126 |
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
| 127 |
+
--color-sidebar-primary: var(--sidebar-primary);
|
| 128 |
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
| 129 |
+
--color-sidebar-accent: var(--sidebar-accent);
|
| 130 |
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
| 131 |
+
--color-sidebar-border: var(--sidebar-border);
|
| 132 |
+
--color-sidebar-ring: var(--sidebar-ring);
|
| 133 |
+
--color-neuro-green: var(--neuro-green);
|
| 134 |
+
--color-neuro-red: var(--neuro-red);
|
| 135 |
+
--color-neuro-blue: var(--neuro-blue);
|
| 136 |
+
--color-neuro-orange: var(--neuro-orange);
|
| 137 |
+
--color-neuro-accent: var(--neuro-accent);
|
| 138 |
+
--color-neuro-text: var(--neuro-text);
|
| 139 |
+
--color-neuro-muted: var(--neuro-muted);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
@layer base {
|
| 143 |
+
* {
|
| 144 |
+
@apply border-border outline-ring/50;
|
| 145 |
+
}
|
| 146 |
+
body {
|
| 147 |
+
@apply bg-background text-foreground;
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/* Custom utilities for NeuroLink dashboard */
|
| 152 |
+
@layer utilities {
|
| 153 |
+
.neuro-text {
|
| 154 |
+
@apply text-neuro-text;
|
| 155 |
+
}
|
| 156 |
+
.neuro-muted {
|
| 157 |
+
@apply text-neuro-muted;
|
| 158 |
+
}
|
| 159 |
+
.neuro-accent {
|
| 160 |
+
@apply text-neuro-accent;
|
| 161 |
+
}
|
| 162 |
+
.neuro-green {
|
| 163 |
+
@apply text-neuro-green;
|
| 164 |
+
}
|
| 165 |
+
.neuro-red {
|
| 166 |
+
@apply text-neuro-red;
|
| 167 |
+
}
|
| 168 |
+
.neuro-blue {
|
| 169 |
+
@apply text-neuro-blue;
|
| 170 |
+
}
|
| 171 |
+
.neuro-orange {
|
| 172 |
+
@apply text-neuro-orange;
|
| 173 |
+
}
|
| 174 |
+
}
|
app/layout.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type React from "react"
|
| 2 |
+
import type { Metadata } from "next"
|
| 3 |
+
import { Geist, Geist_Mono } from "next/font/google"
|
| 4 |
+
import { Analytics } from "@vercel/analytics/next"
|
| 5 |
+
import "./globals.css"
|
| 6 |
+
|
| 7 |
+
const _geist = Geist({ subsets: ["latin"] })
|
| 8 |
+
const _geistMono = Geist_Mono({ subsets: ["latin"] })
|
| 9 |
+
|
| 10 |
+
export const metadata: Metadata = {
|
| 11 |
+
title: "NeuroLink MVP - Biometric Ad Analysis",
|
| 12 |
+
description: "Real-time neuromarketing dashboard for analyzing biometric reactions to video advertisements",
|
| 13 |
+
generator: "v0.app",
|
| 14 |
+
icons: {
|
| 15 |
+
icon: [
|
| 16 |
+
{
|
| 17 |
+
url: "/icon-light-32x32.png",
|
| 18 |
+
media: "(prefers-color-scheme: light)",
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
url: "/icon-dark-32x32.png",
|
| 22 |
+
media: "(prefers-color-scheme: dark)",
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
url: "/icon.svg",
|
| 26 |
+
type: "image/svg+xml",
|
| 27 |
+
},
|
| 28 |
+
],
|
| 29 |
+
apple: "/apple-icon.png",
|
| 30 |
+
},
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export default function RootLayout({
|
| 34 |
+
children,
|
| 35 |
+
}: Readonly<{
|
| 36 |
+
children: React.ReactNode
|
| 37 |
+
}>) {
|
| 38 |
+
return (
|
| 39 |
+
/* CHANGEMENT ICI : J'ai retiré className="dark" pour revenir au mode clair par défaut */
|
| 40 |
+
<html lang="en">
|
| 41 |
+
<body className={`font-sans antialiased`}>
|
| 42 |
+
{children}
|
| 43 |
+
<Analytics />
|
| 44 |
+
</body>
|
| 45 |
+
</html>
|
| 46 |
+
)
|
| 47 |
+
}
|
app/page.tsx
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect, useRef } from "react"
|
| 4 |
+
import MetricsPanel from "@/components/neurolink/metrics-panel"
|
| 5 |
+
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { Badge } from "@/components/ui/badge"
|
| 8 |
+
import { Input } from "@/components/ui/input"
|
| 9 |
+
import { Label } from "@/components/ui/label"
|
| 10 |
+
import { Play, Square, RotateCcw, Zap, User, Fingerprint, Shield, Target } from "lucide-react"
|
| 11 |
+
import { io, Socket } from "socket.io-client"
|
| 12 |
+
import Link from "next/link"
|
| 13 |
+
|
| 14 |
+
interface MetricData { timestamp: number; value: number; engagement: number; satisfaction: number; trust: number; }
|
| 15 |
+
interface UserInfo { firstName: string; lastName: string; clientId: string }
|
| 16 |
+
|
| 17 |
+
export default function Dashboard() {
|
| 18 |
+
const [userInfo, setUserInfo] = useState<UserInfo | null>(null)
|
| 19 |
+
const [socket, setSocket] = useState<Socket | null>(null)
|
| 20 |
+
const [isConnected, setIsConnected] = useState(false)
|
| 21 |
+
const [isRecording, setIsRecording] = useState(false)
|
| 22 |
+
const [sessionTime, setSessionTime] = useState(0)
|
| 23 |
+
const [formData, setFormData] = useState({ firstName: "", lastName: "", clientId: "" })
|
| 24 |
+
const [currentMetrics, setCurrentMetrics] = useState({ engagement: 0, satisfaction: 50, trust: 50, loyalty: 50, opinion: 50, emotion: "neutral" })
|
| 25 |
+
const [history, setHistory] = useState<MetricData[]>([])
|
| 26 |
+
|
| 27 |
+
const videoRef = useRef<HTMLVideoElement>(null)
|
| 28 |
+
const canvasRef = useRef<HTMLCanvasElement>(null)
|
| 29 |
+
const [faceCoords, setFaceCoords] = useState<any>(null)
|
| 30 |
+
const [cameraActive, setCameraActive] = useState(false)
|
| 31 |
+
|
| 32 |
+
// 1. Démarrer Webcam Locale
|
| 33 |
+
useEffect(() => {
|
| 34 |
+
if (userInfo && !cameraActive) {
|
| 35 |
+
navigator.mediaDevices.getUserMedia({ video: { width: 480, height: 360 } })
|
| 36 |
+
.then(stream => { if (videoRef.current) { videoRef.current.srcObject = stream; setCameraActive(true) } })
|
| 37 |
+
.catch(err => console.error("Erreur Webcam:", err))
|
| 38 |
+
}
|
| 39 |
+
}, [userInfo, cameraActive])
|
| 40 |
+
|
| 41 |
+
// 2. Logique Socket & Envoi d'images
|
| 42 |
+
useEffect(() => {
|
| 43 |
+
if (!userInfo) return;
|
| 44 |
+
const newSocket = io("http://localhost:8000")
|
| 45 |
+
newSocket.on("connect", () => setIsConnected(true))
|
| 46 |
+
newSocket.on("disconnect", () => setIsConnected(false))
|
| 47 |
+
|
| 48 |
+
newSocket.on("metrics_update", (data: any) => {
|
| 49 |
+
setSessionTime(data.session_time); setIsRecording(data.is_recording)
|
| 50 |
+
setFaceCoords(data.face_coords)
|
| 51 |
+
|
| 52 |
+
const newMetrics = {
|
| 53 |
+
emotion: data.emotion,
|
| 54 |
+
engagement: data.metrics.engagement, satisfaction: data.metrics.satisfaction,
|
| 55 |
+
trust: data.metrics.trust, loyalty: data.metrics.loyalty, opinion: data.metrics.opinion
|
| 56 |
+
}
|
| 57 |
+
setCurrentMetrics(newMetrics)
|
| 58 |
+
|
| 59 |
+
if (data.is_recording) {
|
| 60 |
+
setHistory(prev => [...prev.slice(-29), {
|
| 61 |
+
timestamp: data.session_time, value: newMetrics.engagement, engagement: newMetrics.engagement,
|
| 62 |
+
satisfaction: newMetrics.satisfaction, trust: newMetrics.trust
|
| 63 |
+
}])
|
| 64 |
+
}
|
| 65 |
+
})
|
| 66 |
+
|
| 67 |
+
setSocket(newSocket)
|
| 68 |
+
|
| 69 |
+
// Envoi 5 fois par seconde
|
| 70 |
+
const interval = setInterval(() => {
|
| 71 |
+
if (videoRef.current && canvasRef.current && newSocket.connected) {
|
| 72 |
+
const ctx = canvasRef.current.getContext('2d')
|
| 73 |
+
if (ctx) {
|
| 74 |
+
ctx.drawImage(videoRef.current, 0, 0, 480, 360)
|
| 75 |
+
const dataUrl = canvasRef.current.toDataURL('image/jpeg', 0.5)
|
| 76 |
+
newSocket.emit('process_frame', dataUrl)
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}, 200)
|
| 80 |
+
|
| 81 |
+
return () => { clearInterval(interval); newSocket.close() }
|
| 82 |
+
}, [userInfo])
|
| 83 |
+
|
| 84 |
+
const handleLogin = (e: React.FormEvent) => { e.preventDefault(); if (formData.firstName && formData.lastName) setUserInfo(formData) }
|
| 85 |
+
const handleStartStop = () => { if (socket && userInfo) { isRecording ? socket.emit("stop_session") : (sessionTime === 0 && setHistory([]), socket.emit("start_session", userInfo)) } }
|
| 86 |
+
const handleReset = () => { if (socket) socket.emit("stop_session"); setHistory([]); setSessionTime(0); setCurrentMetrics(prev => ({ ...prev, engagement: 0, emotion: "neutral" })) }
|
| 87 |
+
const handleLogout = () => { setUserInfo(null); setHistory([]); setSessionTime(0); setCameraActive(false); if(socket) socket.disconnect() }
|
| 88 |
+
const formatTime = (s: number) => `${Math.floor(s/60).toString().padStart(2,'0')}:${(s%60).toString().padStart(2,'0')}`
|
| 89 |
+
const getEmotionDisplay = (e: string) => { const map: any = { happy: "😄 JOIE", sad: "😢 TRISTESSE", angry: "😠 COLÈRE", surprise: "😲 SURPRISE", fear: "😨 PEUR", neutral: "😐 NEUTRE" }; return map[e] || e.toUpperCase() }
|
| 90 |
+
|
| 91 |
+
if (!userInfo) {
|
| 92 |
+
return (
|
| 93 |
+
<div className="min-h-screen bg-slate-50 flex items-center justify-center p-4 relative overflow-hidden text-slate-900">
|
| 94 |
+
<div className="absolute inset-0 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-green-100 via-slate-50 to-white opacity-80"></div>
|
| 95 |
+
<Card className="w-full max-w-md border-slate-200 bg-white shadow-2xl relative z-10">
|
| 96 |
+
<CardHeader className="text-center space-y-4">
|
| 97 |
+
<div className="mx-auto w-20 h-20 rounded-full bg-green-50 flex items-center justify-center border border-green-100 shadow-sm"><Fingerprint className="w-10 h-10 text-green-600" /></div>
|
| 98 |
+
<div><CardTitle className="text-3xl font-bold tracking-tight text-slate-900">STARTECH <span className="text-green-600">ID</span></CardTitle><CardDescription className="text-slate-500">Identification biométrique du sujet</CardDescription></div>
|
| 99 |
+
</CardHeader>
|
| 100 |
+
<form onSubmit={handleLogin}>
|
| 101 |
+
<CardContent className="space-y-4">
|
| 102 |
+
<div className="space-y-2"><Label htmlFor="firstName" className="text-xs uppercase tracking-widest text-slate-500">Prénom</Label><Input id="firstName" placeholder="Ex: Jean" className="bg-slate-50 border-slate-200 text-slate-900 focus:border-green-500 h-11" value={formData.firstName} onChange={e => setFormData({...formData, firstName: e.target.value})} required /></div>
|
| 103 |
+
<div className="space-y-2"><Label htmlFor="lastName" className="text-xs uppercase tracking-widest text-slate-500">Nom</Label><Input id="lastName" placeholder="Ex: Dupont" className="bg-slate-50 border-slate-200 text-slate-900 focus:border-green-500 h-11" value={formData.lastName} onChange={e => setFormData({...formData, lastName: e.target.value})} required /></div>
|
| 104 |
+
<div className="space-y-2"><Label htmlFor="clientId" className="text-xs uppercase tracking-widest text-slate-500">Code Projet</Label><Input id="clientId" placeholder="Ex: PROJET-A12" className="bg-slate-50 border-slate-200 text-slate-900 focus:border-green-500 h-11" value={formData.clientId} onChange={e => setFormData({...formData, clientId: e.target.value})} /></div>
|
| 105 |
+
</CardContent>
|
| 106 |
+
<CardFooter><Button type="submit" className="w-full bg-green-600 hover:bg-green-700 text-white h-12 text-lg font-bold shadow-lg shadow-green-200">INITIALISER SESSION</Button></CardFooter>
|
| 107 |
+
</form>
|
| 108 |
+
</Card>
|
| 109 |
+
<div className="absolute bottom-6 right-6 z-20"><Link href="/admin"><Button variant="ghost" className="text-slate-500 hover:text-slate-900 hover:bg-slate-200 text-xs gap-2"><Shield className="w-3 h-3" /> Accès Admin</Button></Link></div>
|
| 110 |
+
</div>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
return (
|
| 115 |
+
<div className="min-h-screen bg-slate-50 text-slate-900 flex flex-col font-sans">
|
| 116 |
+
<header className="border-b border-slate-200 bg-white/80 backdrop-blur-md sticky top-0 z-50 shadow-sm">
|
| 117 |
+
<div className="flex h-16 items-center px-6 justify-between">
|
| 118 |
+
<div className="flex items-center gap-3 font-bold text-xl tracking-tight text-slate-900"><div className="w-3 h-3 rounded-full bg-green-500 shadow-[0_0_15px_#22c55e] animate-pulse" />STARTECH <span className="text-slate-400 font-normal">VISION</span></div>
|
| 119 |
+
<div className="flex items-center gap-4">
|
| 120 |
+
<div className="flex items-center gap-3 px-4 py-1.5 bg-slate-100 rounded-full border border-slate-200">
|
| 121 |
+
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-green-500 to-emerald-700 flex items-center justify-center text-xs font-bold text-white">{userInfo.firstName.charAt(0)}{userInfo.lastName.charAt(0)}</div>
|
| 122 |
+
<div className="flex flex-col"><span className="text-sm font-bold text-slate-900 leading-none">{userInfo.firstName} {userInfo.lastName}</span><span className="text-[10px] text-slate-500 leading-none mt-1">{userInfo.clientId || "ID: GUEST"}</span></div>
|
| 123 |
+
</div>
|
| 124 |
+
<Button variant="ghost" size="sm" onClick={handleLogout} className="text-xs text-slate-500 hover:text-red-600 hover:bg-red-50">Sortir</Button>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
</header>
|
| 128 |
+
<main className="flex-1 p-4 md:p-6 lg:p-8 overflow-hidden flex flex-col gap-6">
|
| 129 |
+
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-full min-h-[600px]">
|
| 130 |
+
<div className="lg:col-span-7 flex flex-col h-full">
|
| 131 |
+
<Card className="border-slate-300 bg-white shadow-xl relative overflow-hidden transition-all duration-500 flex-1 flex flex-col group">
|
| 132 |
+
<div className="absolute top-4 left-4 w-16 h-16 border-l-4 border-t-4 border-green-500 z-20 rounded-tl-lg opacity-80" />
|
| 133 |
+
<div className="absolute top-4 right-4 w-16 h-16 border-r-4 border-t-4 border-green-500 z-20 rounded-tr-lg opacity-80" />
|
| 134 |
+
<div className="absolute bottom-4 left-4 w-16 h-16 border-l-4 border-b-4 border-green-500 z-20 rounded-bl-lg opacity-80" />
|
| 135 |
+
<div className="absolute bottom-4 right-4 w-16 h-16 border-r-4 border-b-4 border-green-500 z-20 rounded-br-lg opacity-80" />
|
| 136 |
+
{isRecording && <div className="absolute inset-x-0 h-0.5 bg-green-500 shadow-[0_0_20px_#22c55e] z-10 animate-[scan_3s_ease-in-out_infinite]" style={{ top: '0%' }} />}
|
| 137 |
+
{isRecording && <div className="absolute top-0 w-full h-1 bg-red-500 animate-pulse z-30" />}
|
| 138 |
+
<CardContent className="p-0 flex-1 relative flex flex-col items-center justify-center bg-black overflow-hidden rounded-md m-1">
|
| 139 |
+
<canvas ref={canvasRef} width="480" height="360" className="hidden" />
|
| 140 |
+
<div className="absolute inset-0 w-full h-full relative">
|
| 141 |
+
<video ref={videoRef} autoPlay playsInline muted className="w-full h-full object-cover transform scale-x-[-1]" />
|
| 142 |
+
{faceCoords && (
|
| 143 |
+
<div className="absolute border-2 border-green-500 z-50 transition-all duration-100 ease-linear shadow-[0_0_15px_#22c55e]" style={{ left: `${(faceCoords.x / 480) * 100}%`, top: `${(faceCoords.y / 360) * 100}%`, width: `${(faceCoords.w / 480) * 100}%`, height: `${(faceCoords.h / 360) * 100}%`, transform: 'scaleX(-1)' }}>
|
| 144 |
+
<div className="absolute -top-6 left-0 bg-green-500 text-black text-[10px] font-bold px-1 scale-x-[-1]">TARGET LOCKED</div>
|
| 145 |
+
</div>
|
| 146 |
+
)}
|
| 147 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0)_50%,rgba(0,0,0,0.1)_50%),linear-gradient(90deg,rgba(255,0,0,0.06),rgba(0,255,0,0.02),rgba(0,0,255,0.06))] z-10 bg-[length:100%_4px,6px_100%] pointer-events-none" />
|
| 148 |
+
</div>
|
| 149 |
+
<div className="absolute inset-0 flex items-center justify-center pointer-events-none z-10 opacity-30"><Target className="w-64 h-64 text-white stroke-1" /></div>
|
| 150 |
+
<div className="z-20 w-full px-8 pb-8 mt-auto absolute bottom-0">
|
| 151 |
+
<div className="flex justify-between items-end mb-8">
|
| 152 |
+
<div>
|
| 153 |
+
<div className="flex items-center gap-2 mb-2"><Badge variant="outline" className={`px-3 py-1 border-none backdrop-blur-md ${isRecording ? "bg-red-600 text-white animate-pulse" : "bg-white/20 text-white"}`}><div className={`w-2 h-2 rounded-full mr-2 ${isRecording ? "bg-white" : "bg-slate-300"}`} />{isRecording ? "ENREGISTREMENT" : "PRÊT"}</Badge></div>
|
| 154 |
+
<div className="text-7xl font-mono font-bold text-white tabular-nums tracking-tighter drop-shadow-lg">{formatTime(sessionTime)}</div>
|
| 155 |
+
</div>
|
| 156 |
+
<div className="text-right">
|
| 157 |
+
<div className="bg-white/90 backdrop-blur-xl px-6 py-4 rounded-xl border border-white shadow-2xl">
|
| 158 |
+
<span className="block text-[10px] text-slate-500 uppercase tracking-widest mb-1 font-bold">Emotion Dominante</span>
|
| 159 |
+
<span className="text-3xl font-bold text-slate-900 flex items-center justify-end gap-3">{getEmotionDisplay(currentMetrics.emotion)}</span>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
<div className="flex items-center justify-center gap-8 pt-6 border-t border-white/20">
|
| 164 |
+
<Button size="icon" variant="outline" onClick={handleReset} className="h-14 w-14 rounded-full border border-white/20 bg-white/10 text-white hover:bg-white hover:text-black backdrop-blur-md transition-all"><RotateCcw className="h-5 w-5" /></Button>
|
| 165 |
+
{!isRecording ? (<Button onClick={handleStartStop} className="bg-green-600 hover:bg-green-500 text-white px-10 h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(34,197,94,0.4)] transition-all hover:scale-105"><Play className="mr-2 h-5 w-5 fill-current" /> DÉMARRER</Button>) : (<Button onClick={handleStartStop} variant="destructive" className="px-10 h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(239,68,68,0.4)] transition-all hover:scale-105"><Square className="mr-2 h-5 w-5 fill-current" /> STOP</Button>)}
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
</CardContent>
|
| 169 |
+
</Card>
|
| 170 |
+
</div>
|
| 171 |
+
<div className="lg:col-span-5 flex flex-col h-full gap-4">
|
| 172 |
+
<MetricsPanel metrics={currentMetrics} />
|
| 173 |
+
<div className="p-4 rounded-xl bg-white border border-slate-200 shadow-sm flex justify-between items-center text-xs font-mono text-slate-500 mt-auto">
|
| 174 |
+
<div className="flex items-center gap-2"><Zap className={`w-3 h-3 ${isConnected ? "text-green-500" : "text-red-500"}`} />SERVEUR STARTECH</div>
|
| 175 |
+
<span className={isConnected ? "text-green-600 font-bold bg-green-50 px-2 py-1 rounded" : "text-red-500 bg-red-50 px-2 py-1 rounded"}>{isConnected ? "ONLINE" : "OFFLINE"}</span>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
</main>
|
| 180 |
+
<style jsx global>{` @keyframes scan { 0% { top: 0%; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { top: 100%; opacity: 0; } } @keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .animate-spin-slow { animation: spin-slow 10s linear infinite; } `}</style>
|
| 181 |
+
</div>
|
| 182 |
+
)
|
| 183 |
+
}
|
backend/requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
python-socketio
|
| 4 |
+
deepface
|
| 5 |
+
opencv-python-headless<4.10
|
| 6 |
+
numpy<2
|
| 7 |
+
supabase
|
| 8 |
+
tf-keras
|
| 9 |
+
tensorflow
|
backend/server.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import socketio
|
| 3 |
+
import uvicorn
|
| 4 |
+
from fastapi import FastAPI, HTTPException
|
| 5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
+
import asyncio
|
| 7 |
+
import base64
|
| 8 |
+
import cv2
|
| 9 |
+
import numpy as np
|
| 10 |
+
import random
|
| 11 |
+
from datetime import datetime
|
| 12 |
+
from deepface import DeepFace
|
| 13 |
+
from supabase import create_client, Client
|
| 14 |
+
|
| 15 |
+
# --- CONFIGURATION SUPABASE (BACKEND) ---
|
| 16 |
+
# ⚠️ REMPLACEZ PAR VOS CLÉS (Supabase > Settings > API)
|
| 17 |
+
# ICI IL FAUT LA CLÉ SECRÈTE "SERVICE_ROLE" POUR POUVOIR ECRIRE/SUPPRIMER
|
| 18 |
+
SUPABASE_URL = 'https://gwjrwejdjpctizolfkcz.supabase.co'
|
| 19 |
+
SUPABASE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd3anJ3ZWpkanBjdGl6b2xma2N6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc2OTA5ODEyNCwiZXhwIjoyMDg0Njc0MTI0fQ.EjU1DGTN-jrdkaC6nJWilFtYZgtu-NKjnfiMVMnHal0"
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
|
| 23 |
+
print("☁️ Connecté à Supabase (PerseeTech)")
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"❌ Erreur de connexion Supabase : {e}")
|
| 26 |
+
|
| 27 |
+
# --- CONFIGURATION SERVEUR ---
|
| 28 |
+
sio = socketio.AsyncServer(async_mode='asgi', cors_allowed_origins='*')
|
| 29 |
+
app = FastAPI()
|
| 30 |
+
app.add_middleware(
|
| 31 |
+
CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
| 32 |
+
)
|
| 33 |
+
socket_app = socketio.ASGIApp(sio, app)
|
| 34 |
+
|
| 35 |
+
# --- API REST (Lecture pour l'Admin) ---
|
| 36 |
+
@app.get("/api/sessions")
|
| 37 |
+
def get_sessions():
|
| 38 |
+
response = supabase.table('sessions').select("*").order('id', desc=True).execute()
|
| 39 |
+
return response.data
|
| 40 |
+
|
| 41 |
+
@app.get("/api/sessions/{session_id}")
|
| 42 |
+
def get_session_details(session_id: int):
|
| 43 |
+
sess = supabase.table('sessions').select("*").eq('id', session_id).execute()
|
| 44 |
+
if not sess.data:
|
| 45 |
+
raise HTTPException(status_code=404, detail="Session non trouvée")
|
| 46 |
+
meas = supabase.table('measurements').select("*").eq('session_id', session_id).order('session_time', desc=False).execute()
|
| 47 |
+
return {"info": sess.data[0], "data": meas.data}
|
| 48 |
+
|
| 49 |
+
@app.delete("/api/sessions/{session_id}")
|
| 50 |
+
def delete_session(session_id: int):
|
| 51 |
+
try:
|
| 52 |
+
supabase.table('sessions').delete().eq('id', session_id).execute()
|
| 53 |
+
return {"message": "Session supprimée avec succès"}
|
| 54 |
+
except Exception as e:
|
| 55 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 56 |
+
|
| 57 |
+
# --- LOGIQUE MÉTIER (KPIs - SANS BPM) ---
|
| 58 |
+
def calculate_kpis(emotion):
|
| 59 |
+
valence = 0.0; arousal = 0.0; noise = random.uniform(-0.05, 0.05)
|
| 60 |
+
if emotion == "happy": valence = 0.8 + noise; arousal = 0.6 + noise
|
| 61 |
+
elif emotion == "surprise": valence = 0.2 + noise; arousal = 0.9 + noise
|
| 62 |
+
elif emotion in ["fear", "angry"]: valence = -0.7 + noise; arousal = 0.8 + noise
|
| 63 |
+
elif emotion == "disgust": valence = -0.8 + noise; arousal = 0.5 + noise
|
| 64 |
+
elif emotion == "sad": valence = -0.6 + noise; arousal = 0.2 + noise
|
| 65 |
+
else: valence = 0.0 + noise; arousal = 0.3 + noise
|
| 66 |
+
|
| 67 |
+
def clamp(n): return max(0, min(100, int(n)))
|
| 68 |
+
val_eng = clamp((arousal * 100) + random.uniform(0, 5))
|
| 69 |
+
val_sat = clamp(((valence + 1) / 2) * 100)
|
| 70 |
+
val_tru = clamp(50 + (valence * 40) + random.uniform(0, 5)) if valence > 0 else clamp(50 - (abs(valence) * 40) + random.uniform(0, 5))
|
| 71 |
+
val_loy = clamp((val_sat * 0.7) + (val_tru * 0.3))
|
| 72 |
+
val_opi = val_sat
|
| 73 |
+
|
| 74 |
+
# Labels
|
| 75 |
+
if val_eng >= 75: lbl_eng = "Engagement Fort 🔥"
|
| 76 |
+
elif val_eng >= 40: lbl_eng = "Engagement Moyen"
|
| 77 |
+
else: lbl_eng = "Désengagement 💤"
|
| 78 |
+
|
| 79 |
+
if val_sat >= 70: lbl_sat = "Très Satisfait 😃"
|
| 80 |
+
elif val_sat >= 45: lbl_sat = "Neutre 😐"
|
| 81 |
+
else: lbl_sat = "Insatisfait 😡"
|
| 82 |
+
|
| 83 |
+
if val_tru >= 70: lbl_tru = "Confiance Totale 🤝"
|
| 84 |
+
elif val_tru >= 40: lbl_tru = "Sceptique 🤔"
|
| 85 |
+
else: lbl_tru = "Méfiant 🚩"
|
| 86 |
+
|
| 87 |
+
if val_loy >= 75: lbl_loy = "Fidèle (Ambassadeur) 💎"
|
| 88 |
+
elif val_loy >= 50: lbl_loy = "Client Standard"
|
| 89 |
+
else: lbl_loy = "Infidèle / Volatile 💸"
|
| 90 |
+
|
| 91 |
+
if val_opi >= 60: lbl_opi = "Avis Positif 👍"
|
| 92 |
+
elif val_opi >= 40: lbl_opi = "Indécis"
|
| 93 |
+
else: lbl_opi = "Avis Négatif 👎"
|
| 94 |
+
|
| 95 |
+
return {
|
| 96 |
+
"engagement": val_eng, "satisfaction": val_sat, "trust": val_tru, "loyalty": val_loy, "opinion": val_opi,
|
| 97 |
+
"lbl_eng": lbl_eng, "lbl_sat": lbl_sat, "lbl_tru": lbl_tru, "lbl_loy": lbl_loy, "lbl_opi": lbl_opi
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
# --- ETAT IA ---
|
| 101 |
+
camera_state = { "emotion": "neutral", "emotion_score": 0, "face_coords": None }
|
| 102 |
+
active_sessions = {}
|
| 103 |
+
|
| 104 |
+
# TÂCHE 1 : RECEPTION IMAGE (CLIENT -> SERVER)
|
| 105 |
+
@sio.event
|
| 106 |
+
async def process_frame(sid, data_uri):
|
| 107 |
+
try:
|
| 108 |
+
encoded_data = data_uri.split(',')[1]
|
| 109 |
+
nparr = np.frombuffer(base64.b64decode(encoded_data), np.uint8)
|
| 110 |
+
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
| 111 |
+
|
| 112 |
+
# Analyse DeepFace
|
| 113 |
+
result = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False, silent=True)
|
| 114 |
+
data = result[0] if isinstance(result, list) else result
|
| 115 |
+
|
| 116 |
+
camera_state["emotion"] = data['dominant_emotion']
|
| 117 |
+
camera_state["emotion_score"] = data['emotion'][data['dominant_emotion']]
|
| 118 |
+
|
| 119 |
+
region = data['region']
|
| 120 |
+
if region['w'] > 0:
|
| 121 |
+
camera_state["face_coords"] = {'x': region['x'], 'y': region['y'], 'w': region['w'], 'h': region['h']}
|
| 122 |
+
else:
|
| 123 |
+
camera_state["face_coords"] = None
|
| 124 |
+
except:
|
| 125 |
+
camera_state["face_coords"] = None
|
| 126 |
+
|
| 127 |
+
# TÂCHE 2 : GESTION SESSION (Boucle infinie)
|
| 128 |
+
async def session_manager_loop():
|
| 129 |
+
while True:
|
| 130 |
+
for sid, user_data in list(active_sessions.items()):
|
| 131 |
+
kpis = calculate_kpis(camera_state["emotion"])
|
| 132 |
+
|
| 133 |
+
if user_data["is_recording"]:
|
| 134 |
+
user_data["session_time"] += 1
|
| 135 |
+
t = user_data["session_time"]
|
| 136 |
+
|
| 137 |
+
# ENREGISTREMENT DB SUPABASE
|
| 138 |
+
if user_data["db_id"]:
|
| 139 |
+
try:
|
| 140 |
+
data_to_insert = {
|
| 141 |
+
"session_id": user_data["db_id"],
|
| 142 |
+
"session_time": t,
|
| 143 |
+
"emotion": camera_state["emotion"],
|
| 144 |
+
"emotion_score": camera_state["emotion_score"],
|
| 145 |
+
"engagement_val": kpis["engagement"], "engagement_lbl": kpis["lbl_eng"],
|
| 146 |
+
"satisfaction_val": kpis["satisfaction"], "satisfaction_lbl": kpis["lbl_sat"],
|
| 147 |
+
"trust_val": kpis["trust"], "trust_lbl": kpis["lbl_tru"],
|
| 148 |
+
"loyalty_val": kpis["loyalty"], "loyalty_lbl": kpis["lbl_loy"],
|
| 149 |
+
"opinion_val": kpis["opinion"], "opinion_lbl": kpis["lbl_opi"]
|
| 150 |
+
}
|
| 151 |
+
supabase.table('measurements').insert(data_to_insert).execute()
|
| 152 |
+
except Exception as e: print(f"Supabase Insert Error: {e}")
|
| 153 |
+
|
| 154 |
+
await sio.emit('metrics_update', {
|
| 155 |
+
"emotion": camera_state["emotion"], "metrics": kpis,
|
| 156 |
+
"face_coords": camera_state["face_coords"],
|
| 157 |
+
"session_time": user_data["session_time"],
|
| 158 |
+
"is_recording": user_data["is_recording"]
|
| 159 |
+
}, room=sid)
|
| 160 |
+
await asyncio.sleep(1)
|
| 161 |
+
|
| 162 |
+
@sio.event
|
| 163 |
+
async def connect(sid, environ): active_sessions[sid] = { "is_recording": False, "session_time": 0, "db_id": None }
|
| 164 |
+
@sio.event
|
| 165 |
+
async def disconnect(sid):
|
| 166 |
+
if sid in active_sessions: del active_sessions[sid]
|
| 167 |
+
@sio.event
|
| 168 |
+
async def start_session(sid, data):
|
| 169 |
+
user_session = active_sessions.get(sid)
|
| 170 |
+
if user_session:
|
| 171 |
+
user_session["is_recording"] = True
|
| 172 |
+
user_session["session_time"] = 0
|
| 173 |
+
|
| 174 |
+
new_session = {
|
| 175 |
+
"first_name": data.get('firstName'),
|
| 176 |
+
"last_name": data.get('lastName'),
|
| 177 |
+
"client_id": data.get('clientId')
|
| 178 |
+
}
|
| 179 |
+
res = supabase.table('sessions').insert(new_session).execute()
|
| 180 |
+
user_session["db_id"] = res.data[0]['id']
|
| 181 |
+
|
| 182 |
+
@sio.event
|
| 183 |
+
async def stop_session(sid):
|
| 184 |
+
user_session = active_sessions.get(sid)
|
| 185 |
+
if user_session: user_session["is_recording"] = False
|
| 186 |
+
|
| 187 |
+
if __name__ == "__main__":
|
| 188 |
+
@app.on_event("startup")
|
| 189 |
+
async def startup_event():
|
| 190 |
+
asyncio.create_task(session_manager_loop())
|
| 191 |
+
uvicorn.run(socket_app, host="0.0.0.0", port=8000)
|
backend/test_face.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
from deepface import DeepFace
|
| 3 |
+
import time
|
| 4 |
+
|
| 5 |
+
# Essaie d'ouvrir la caméra (0 par défaut)
|
| 6 |
+
cap = cv2.VideoCapture(0)
|
| 7 |
+
|
| 8 |
+
print("📸 Caméra active. Regarde l'objectif...")
|
| 9 |
+
print("Appuie sur la touche 'q' pour quitter.")
|
| 10 |
+
|
| 11 |
+
last_analysis_time = 0
|
| 12 |
+
current_text = "Recherche..."
|
| 13 |
+
x, y, w, h = 0, 0, 0, 0
|
| 14 |
+
|
| 15 |
+
while True:
|
| 16 |
+
ret, frame = cap.read()
|
| 17 |
+
if not ret:
|
| 18 |
+
print("Erreur: Impossible de lire la caméra")
|
| 19 |
+
break
|
| 20 |
+
|
| 21 |
+
# Analyse toutes les 0.5 secondes
|
| 22 |
+
if time.time() - last_analysis_time > 0.5:
|
| 23 |
+
try:
|
| 24 |
+
# enforce_detection=False évite le crash si pas de visage
|
| 25 |
+
result = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False)
|
| 26 |
+
|
| 27 |
+
# DeepFace renvoie une liste
|
| 28 |
+
if isinstance(result, list):
|
| 29 |
+
data = result[0]
|
| 30 |
+
else:
|
| 31 |
+
data = result
|
| 32 |
+
|
| 33 |
+
emotion = data['dominant_emotion']
|
| 34 |
+
score = data['emotion'][emotion]
|
| 35 |
+
|
| 36 |
+
current_text = f"{emotion.upper()} ({int(score)}%)"
|
| 37 |
+
|
| 38 |
+
region = data['region']
|
| 39 |
+
x, y, w, h = region['x'], region['y'], region['w'], region['h']
|
| 40 |
+
|
| 41 |
+
last_analysis_time = time.time()
|
| 42 |
+
|
| 43 |
+
except Exception as e:
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
# Dessine le carré et le texte si un visage est trouvé
|
| 47 |
+
if w > 0:
|
| 48 |
+
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
| 49 |
+
cv2.putText(frame, current_text, (x, y-10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
|
| 50 |
+
|
| 51 |
+
cv2.imshow('NeuroLink Face Test', frame)
|
| 52 |
+
|
| 53 |
+
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 54 |
+
break
|
| 55 |
+
|
| 56 |
+
cap.release()
|
| 57 |
+
cv2.destroyAllWindows()
|
| 58 |
+
# Force la fermeture des fenêtres sur Mac
|
| 59 |
+
for i in range(5):
|
| 60 |
+
cv2.waitKey(1)
|
components.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "new-york",
|
| 4 |
+
"rsc": true,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "",
|
| 8 |
+
"css": "app/globals.css",
|
| 9 |
+
"baseColor": "neutral",
|
| 10 |
+
"cssVariables": true,
|
| 11 |
+
"prefix": ""
|
| 12 |
+
},
|
| 13 |
+
"aliases": {
|
| 14 |
+
"components": "@/components",
|
| 15 |
+
"utils": "@/lib/utils",
|
| 16 |
+
"ui": "@/components/ui",
|
| 17 |
+
"lib": "@/lib",
|
| 18 |
+
"hooks": "@/hooks"
|
| 19 |
+
},
|
| 20 |
+
"iconLibrary": "lucide"
|
| 21 |
+
}
|
components/neurolink/comparison-chart.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from 'recharts'
|
| 4 |
+
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"
|
| 5 |
+
|
| 6 |
+
export default function ComparisonChart({ dataA, dataB, nameA, nameB }: any) {
|
| 7 |
+
|
| 8 |
+
// Fusion des données pour le graphique
|
| 9 |
+
// On prend la durée la plus longue
|
| 10 |
+
const length = Math.max(dataA.length, dataB.length)
|
| 11 |
+
const chartData = []
|
| 12 |
+
|
| 13 |
+
for (let i = 0; i < length; i++) {
|
| 14 |
+
chartData.push({
|
| 15 |
+
time: i,
|
| 16 |
+
// Session A (Bleu)
|
| 17 |
+
engA: dataA[i] ? dataA[i].engagement_val : null,
|
| 18 |
+
// Session B (Orange)
|
| 19 |
+
engB: dataB[i] ? dataB[i].engagement_val : null,
|
| 20 |
+
})
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
return (
|
| 24 |
+
<div className="w-full h-[350px]">
|
| 25 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 26 |
+
<LineChart data={chartData}>
|
| 27 |
+
<CartesianGrid strokeDasharray="3 3" stroke="#333" vertical={false} />
|
| 28 |
+
<XAxis dataKey="time" stroke="#888" tick={{fontSize: 12}} tickFormatter={(val) => `${val}s`} />
|
| 29 |
+
<YAxis stroke="#888" tick={{fontSize: 12}} domain={[0, 100]} />
|
| 30 |
+
<Tooltip
|
| 31 |
+
contentStyle={{ backgroundColor: '#18181b', borderColor: '#333', color: '#fff' }}
|
| 32 |
+
labelFormatter={(label) => `Temps : ${label}s`}
|
| 33 |
+
/>
|
| 34 |
+
<Legend />
|
| 35 |
+
|
| 36 |
+
{/* Ligne A (Bleu) */}
|
| 37 |
+
<Line
|
| 38 |
+
type="monotone"
|
| 39 |
+
dataKey="engA"
|
| 40 |
+
name={nameA}
|
| 41 |
+
stroke="#3b82f6"
|
| 42 |
+
strokeWidth={3}
|
| 43 |
+
dot={false}
|
| 44 |
+
activeDot={{ r: 6 }}
|
| 45 |
+
/>
|
| 46 |
+
|
| 47 |
+
{/* Ligne B (Orange) */}
|
| 48 |
+
<Line
|
| 49 |
+
type="monotone"
|
| 50 |
+
dataKey="engB"
|
| 51 |
+
name={nameB}
|
| 52 |
+
stroke="#f97316"
|
| 53 |
+
strokeWidth={3}
|
| 54 |
+
dot={false}
|
| 55 |
+
activeDot={{ r: 6 }}
|
| 56 |
+
/>
|
| 57 |
+
</LineChart>
|
| 58 |
+
</ResponsiveContainer>
|
| 59 |
+
</div>
|
| 60 |
+
)
|
| 61 |
+
}
|
components/neurolink/emotional-intensity-chart.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
import { motion } from "framer-motion"
|
| 3 |
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts"
|
| 4 |
+
|
| 5 |
+
interface BiometricData {
|
| 6 |
+
engagement: number
|
| 7 |
+
satisfaction: number
|
| 8 |
+
trust: number
|
| 9 |
+
loyalty: number
|
| 10 |
+
opinion: number
|
| 11 |
+
bpm: number
|
| 12 |
+
timestamp: number
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
interface EmotionalIntensityChartProps {
|
| 16 |
+
data: BiometricData[]
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export default function EmotionalIntensityChart({ data }: EmotionalIntensityChartProps) {
|
| 20 |
+
const chartData = data.map((d, idx) => ({
|
| 21 |
+
time: idx,
|
| 22 |
+
intensity: (d.engagement + d.satisfaction + d.opinion) / 3,
|
| 23 |
+
}))
|
| 24 |
+
|
| 25 |
+
return (
|
| 26 |
+
<motion.div
|
| 27 |
+
className="bg-white rounded-xl border border-gray-200 p-6 shadow-md"
|
| 28 |
+
initial={{ opacity: 0, y: 20 }}
|
| 29 |
+
animate={{ opacity: 1, y: 0 }}
|
| 30 |
+
transition={{ duration: 0.5, delay: 0.1 }}
|
| 31 |
+
>
|
| 32 |
+
<div className="mb-4">
|
| 33 |
+
<h3 className="text-sm font-semibold text-neuro-text tracking-wide">Emotional Intensity</h3>
|
| 34 |
+
<p className="text-xs text-neuro-muted mt-1">Last 30 seconds</p>
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
{chartData.length > 0 ? (
|
| 38 |
+
<ResponsiveContainer width="100%" height={200}>
|
| 39 |
+
<LineChart data={chartData}>
|
| 40 |
+
<CartesianGrid strokeDasharray="3 3" stroke="rgba(0, 0, 0, 0.1)" vertical={false} />
|
| 41 |
+
<XAxis
|
| 42 |
+
dataKey="time"
|
| 43 |
+
stroke="rgba(107, 114, 128, 0.5)"
|
| 44 |
+
tick={{ fontSize: 12 }}
|
| 45 |
+
style={{ fontSize: "12px" }}
|
| 46 |
+
/>
|
| 47 |
+
<YAxis
|
| 48 |
+
domain={[0, 100]}
|
| 49 |
+
stroke="rgba(107, 114, 128, 0.5)"
|
| 50 |
+
tick={{ fontSize: 12 }}
|
| 51 |
+
style={{ fontSize: "12px" }}
|
| 52 |
+
/>
|
| 53 |
+
<Tooltip
|
| 54 |
+
contentStyle={{
|
| 55 |
+
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
| 56 |
+
border: "1px solid rgba(37, 99, 235, 0.3)",
|
| 57 |
+
borderRadius: "8px",
|
| 58 |
+
}}
|
| 59 |
+
labelStyle={{ color: "#2563eb" }}
|
| 60 |
+
formatter={(value: any) => value.toFixed(1)}
|
| 61 |
+
/>
|
| 62 |
+
<Line
|
| 63 |
+
type="monotone"
|
| 64 |
+
dataKey="intensity"
|
| 65 |
+
stroke="#2563eb"
|
| 66 |
+
dot={false}
|
| 67 |
+
strokeWidth={2}
|
| 68 |
+
isAnimationActive={false}
|
| 69 |
+
/>
|
| 70 |
+
</LineChart>
|
| 71 |
+
</ResponsiveContainer>
|
| 72 |
+
) : (
|
| 73 |
+
<div className="h-[200px] flex items-center justify-center">
|
| 74 |
+
<p className="text-neuro-muted font-mono text-sm">Waiting for data...</p>
|
| 75 |
+
</div>
|
| 76 |
+
)}
|
| 77 |
+
</motion.div>
|
| 78 |
+
)
|
| 79 |
+
}
|
components/neurolink/header.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
import { motion } from "framer-motion"
|
| 3 |
+
import { Activity } from "lucide-react"
|
| 4 |
+
|
| 5 |
+
interface HeaderProps {
|
| 6 |
+
onStartSession: () => void
|
| 7 |
+
sessionState: "idle" | "calibrating" | "running" | "finished"
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export default function Header({ onStartSession, sessionState }: HeaderProps) {
|
| 11 |
+
const getButtonText = () => {
|
| 12 |
+
switch (sessionState) {
|
| 13 |
+
case "idle":
|
| 14 |
+
return "Start Calibration"
|
| 15 |
+
case "calibrating":
|
| 16 |
+
return "Calibrating..."
|
| 17 |
+
case "running":
|
| 18 |
+
return "Session Running"
|
| 19 |
+
case "finished":
|
| 20 |
+
return "Restart"
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
return (
|
| 25 |
+
<header className="bg-white border-b border-gray-200 shadow-sm">
|
| 26 |
+
<div className="max-w-7xl mx-auto px-6 py-6 flex items-center justify-between">
|
| 27 |
+
<motion.div className="flex items-center gap-3" initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }}>
|
| 28 |
+
<div className="p-2 bg-neuro-blue/10 rounded-lg border border-neuro-blue/30">
|
| 29 |
+
<Activity className="w-6 h-6 text-neuro-blue" strokeWidth={2.5} />
|
| 30 |
+
</div>
|
| 31 |
+
<div>
|
| 32 |
+
<h1 className="text-2xl font-bold text-neuro-text tracking-tight">NeuroLink Bio-Feedback</h1>
|
| 33 |
+
<p className="text-xs text-neuro-muted">Real-time Biometric Analysis</p>
|
| 34 |
+
</div>
|
| 35 |
+
</motion.div>
|
| 36 |
+
|
| 37 |
+
<div className="flex items-center gap-4">
|
| 38 |
+
<motion.div
|
| 39 |
+
className="flex items-center gap-2"
|
| 40 |
+
animate={{ opacity: sessionState !== "idle" ? 1 : 0.7 }}
|
| 41 |
+
transition={{ duration: 0.3 }}
|
| 42 |
+
>
|
| 43 |
+
<div
|
| 44 |
+
className={`w-2 h-2 rounded-full ${sessionState === "running" ? "bg-neuro-green animate-pulse" : "bg-gray-400"}`}
|
| 45 |
+
/>
|
| 46 |
+
<span className="text-xs font-mono text-neuro-text">
|
| 47 |
+
{sessionState === "running" ? "CONNECTED" : "STANDBY"}
|
| 48 |
+
</span>
|
| 49 |
+
</motion.div>
|
| 50 |
+
|
| 51 |
+
<motion.button
|
| 52 |
+
onClick={onStartSession}
|
| 53 |
+
disabled={sessionState === "calibrating" || sessionState === "running"}
|
| 54 |
+
className="px-6 py-2 bg-gradient-to-r from-neuro-blue to-blue-600 text-white font-semibold rounded-lg hover:shadow-lg hover:shadow-neuro-blue/30 disabled:opacity-60 disabled:cursor-not-allowed transition-all duration-300 text-sm"
|
| 55 |
+
whileHover={{ scale: 1.05 }}
|
| 56 |
+
whileTap={{ scale: 0.95 }}
|
| 57 |
+
>
|
| 58 |
+
{getButtonText()}
|
| 59 |
+
</motion.button>
|
| 60 |
+
</div>
|
| 61 |
+
</div>
|
| 62 |
+
</header>
|
| 63 |
+
)
|
| 64 |
+
}
|
components/neurolink/metric-gauge.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
import { motion } from "framer-motion"
|
| 3 |
+
|
| 4 |
+
interface MetricGaugeProps {
|
| 5 |
+
label: string
|
| 6 |
+
value: number
|
| 7 |
+
minLabel: string
|
| 8 |
+
maxLabel: string
|
| 9 |
+
color: string
|
| 10 |
+
type: "engagement" | "valence" | "trust" | "loyalty" | "opinion"
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export default function MetricGauge({ label, value, minLabel, maxLabel, color, type }: MetricGaugeProps) {
|
| 14 |
+
const displayLabel =
|
| 15 |
+
type === "valence"
|
| 16 |
+
? value < 40
|
| 17 |
+
? minLabel
|
| 18 |
+
: value > 60
|
| 19 |
+
? maxLabel
|
| 20 |
+
: "Neutral"
|
| 21 |
+
: type === "trust" || type === "loyalty" || type === "opinion"
|
| 22 |
+
? value < 50
|
| 23 |
+
? minLabel
|
| 24 |
+
: maxLabel
|
| 25 |
+
: label
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<motion.div
|
| 29 |
+
className="bg-white rounded-xl border border-gray-200 p-4 shadow-md"
|
| 30 |
+
whileHover={{ borderColor: "rgba(37, 99, 235, 0.3)" }}
|
| 31 |
+
transition={{ duration: 0.3 }}
|
| 32 |
+
>
|
| 33 |
+
<div className="mb-3">
|
| 34 |
+
<div className="flex justify-between items-center mb-2">
|
| 35 |
+
<span className="text-xs font-mono text-neuro-muted uppercase tracking-wider">{label}</span>
|
| 36 |
+
<span className="text-sm font-mono font-bold text-neuro-text">{value.toFixed(0)}%</span>
|
| 37 |
+
</div>
|
| 38 |
+
<p className="text-xs text-neuro-blue">{displayLabel}</p>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
{/* Gauge Bar Container */}
|
| 42 |
+
<div className="relative h-8 bg-gray-100 rounded-lg overflow-hidden border border-gray-200">
|
| 43 |
+
{/* Background gradient segments for valence */}
|
| 44 |
+
{type === "valence" && (
|
| 45 |
+
<>
|
| 46 |
+
<div className="absolute inset-y-0 left-0 w-2/5 bg-gradient-to-r from-neuro-red to-transparent" />
|
| 47 |
+
<div className="absolute inset-y-0 left-2/5 w-1/5 bg-gray-300" />
|
| 48 |
+
<div className="absolute inset-y-0 right-0 w-2/5 bg-gradient-to-l from-neuro-green to-transparent" />
|
| 49 |
+
</>
|
| 50 |
+
)}
|
| 51 |
+
|
| 52 |
+
{/* Fill bar with gradient */}
|
| 53 |
+
<motion.div
|
| 54 |
+
className={`absolute inset-y-0 left-0 rounded-lg bg-gradient-to-r ${color} shadow-md`}
|
| 55 |
+
initial={{ width: "0%" }}
|
| 56 |
+
animate={{ width: `${value}%` }}
|
| 57 |
+
transition={{ duration: 0.6, ease: "easeOut" }}
|
| 58 |
+
style={{
|
| 59 |
+
filter: "drop-shadow(0 0 4px rgba(37, 99, 235, 0.3))",
|
| 60 |
+
}}
|
| 61 |
+
/>
|
| 62 |
+
|
| 63 |
+
{/* Animated shimmer effect */}
|
| 64 |
+
<motion.div
|
| 65 |
+
className="absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent"
|
| 66 |
+
animate={{ x: ["-100%", "100%"] }}
|
| 67 |
+
transition={{ duration: 2, repeat: Number.POSITIVE_INFINITY, ease: "linear" }}
|
| 68 |
+
/>
|
| 69 |
+
</div>
|
| 70 |
+
|
| 71 |
+
{/* Label helpers */}
|
| 72 |
+
<div className="flex justify-between mt-2">
|
| 73 |
+
<span className="text-xs text-gray-500 font-mono">{minLabel}</span>
|
| 74 |
+
<span className="text-xs text-gray-500 font-mono">{maxLabel}</span>
|
| 75 |
+
</div>
|
| 76 |
+
</motion.div>
|
| 77 |
+
)
|
| 78 |
+
}
|
components/neurolink/metrics-panel.tsx
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
| 4 |
+
import { Activity, ThumbsUp, Shield, Heart, MessageSquare, Brain } from "lucide-react"
|
| 5 |
+
import { motion } from "framer-motion"
|
| 6 |
+
|
| 7 |
+
interface MetricsPanelProps {
|
| 8 |
+
metrics: {
|
| 9 |
+
// bpm: number <-- SUPPRIMÉ
|
| 10 |
+
emotion: string
|
| 11 |
+
engagement: number
|
| 12 |
+
satisfaction: number
|
| 13 |
+
trust: number
|
| 14 |
+
loyalty: number
|
| 15 |
+
opinion: number
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export default function MetricsPanel({ metrics }: MetricsPanelProps) {
|
| 20 |
+
|
| 21 |
+
// Fonction utilitaire pour la couleur
|
| 22 |
+
const getColor = (val: number) => {
|
| 23 |
+
if (val >= 75) return "text-green-600"
|
| 24 |
+
if (val >= 50) return "text-blue-600"
|
| 25 |
+
return "text-orange-500"
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return (
|
| 29 |
+
<div className="grid grid-cols-2 gap-4 h-full">
|
| 30 |
+
|
| 31 |
+
{/* 1. ENGAGEMENT (Remplace le BPM en première position) */}
|
| 32 |
+
<Card className="bg-white border-slate-200 shadow-sm">
|
| 33 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 34 |
+
<CardTitle className="text-xs font-medium uppercase tracking-wider text-slate-500">
|
| 35 |
+
Engagement
|
| 36 |
+
</CardTitle>
|
| 37 |
+
<Activity className="h-4 w-4 text-slate-400" />
|
| 38 |
+
</CardHeader>
|
| 39 |
+
<CardContent>
|
| 40 |
+
<div className="text-2xl font-bold text-slate-900">
|
| 41 |
+
{metrics.engagement}%
|
| 42 |
+
</div>
|
| 43 |
+
<p className="text-xs text-slate-500 mt-1">
|
| 44 |
+
Intensité émotionnelle
|
| 45 |
+
</p>
|
| 46 |
+
{/* Barre de progression */}
|
| 47 |
+
<div className="w-full bg-slate-100 h-1.5 mt-2 rounded-full overflow-hidden">
|
| 48 |
+
<motion.div
|
| 49 |
+
className="h-full bg-blue-500"
|
| 50 |
+
initial={{ width: 0 }}
|
| 51 |
+
animate={{ width: `${metrics.engagement}%` }}
|
| 52 |
+
transition={{ type: "spring", stiffness: 50 }}
|
| 53 |
+
/>
|
| 54 |
+
</div>
|
| 55 |
+
</CardContent>
|
| 56 |
+
</Card>
|
| 57 |
+
|
| 58 |
+
{/* 2. SATISFACTION */}
|
| 59 |
+
<Card className="bg-white border-slate-200 shadow-sm">
|
| 60 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 61 |
+
<CardTitle className="text-xs font-medium uppercase tracking-wider text-slate-500">
|
| 62 |
+
Satisfaction
|
| 63 |
+
</CardTitle>
|
| 64 |
+
<ThumbsUp className="h-4 w-4 text-slate-400" />
|
| 65 |
+
</CardHeader>
|
| 66 |
+
<CardContent>
|
| 67 |
+
<div className={`text-2xl font-bold ${getColor(metrics.satisfaction)}`}>
|
| 68 |
+
{metrics.satisfaction}%
|
| 69 |
+
</div>
|
| 70 |
+
<p className="text-xs text-slate-500 mt-1">Valence positive</p>
|
| 71 |
+
<div className="w-full bg-slate-100 h-1.5 mt-2 rounded-full overflow-hidden">
|
| 72 |
+
<motion.div
|
| 73 |
+
className="h-full bg-green-500"
|
| 74 |
+
initial={{ width: 0 }}
|
| 75 |
+
animate={{ width: `${metrics.satisfaction}%` }}
|
| 76 |
+
/>
|
| 77 |
+
</div>
|
| 78 |
+
</CardContent>
|
| 79 |
+
</Card>
|
| 80 |
+
|
| 81 |
+
{/* 3. CONFIANCE */}
|
| 82 |
+
<Card className="bg-white border-slate-200 shadow-sm">
|
| 83 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 84 |
+
<CardTitle className="text-xs font-medium uppercase tracking-wider text-slate-500">
|
| 85 |
+
Confiance
|
| 86 |
+
</CardTitle>
|
| 87 |
+
<Shield className="h-4 w-4 text-slate-400" />
|
| 88 |
+
</CardHeader>
|
| 89 |
+
<CardContent>
|
| 90 |
+
<div className="text-2xl font-bold text-slate-900">
|
| 91 |
+
{metrics.trust}%
|
| 92 |
+
</div>
|
| 93 |
+
<p className="text-xs text-slate-500 mt-1">Crédibilité perçue</p>
|
| 94 |
+
<div className="w-full bg-slate-100 h-1.5 mt-2 rounded-full overflow-hidden">
|
| 95 |
+
<motion.div className="h-full bg-purple-500" animate={{ width: `${metrics.trust}%` }} />
|
| 96 |
+
</div>
|
| 97 |
+
</CardContent>
|
| 98 |
+
</Card>
|
| 99 |
+
|
| 100 |
+
{/* 4. FIDÉLITÉ */}
|
| 101 |
+
<Card className="bg-white border-slate-200 shadow-sm">
|
| 102 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 103 |
+
<CardTitle className="text-xs font-medium uppercase tracking-wider text-slate-500">
|
| 104 |
+
Fidélité
|
| 105 |
+
</CardTitle>
|
| 106 |
+
<Heart className="h-4 w-4 text-slate-400" />
|
| 107 |
+
</CardHeader>
|
| 108 |
+
<CardContent>
|
| 109 |
+
<div className="text-2xl font-bold text-slate-900">
|
| 110 |
+
{metrics.loyalty}%
|
| 111 |
+
</div>
|
| 112 |
+
<p className="text-xs text-slate-500 mt-1">Intention de retour</p>
|
| 113 |
+
<div className="w-full bg-slate-100 h-1.5 mt-2 rounded-full overflow-hidden">
|
| 114 |
+
<motion.div className="h-full bg-red-500" animate={{ width: `${metrics.loyalty}%` }} />
|
| 115 |
+
</div>
|
| 116 |
+
</CardContent>
|
| 117 |
+
</Card>
|
| 118 |
+
|
| 119 |
+
{/* 5. SCORE AVIS (Large, prend 2 colonnes) */}
|
| 120 |
+
<Card className="col-span-2 bg-slate-900 text-white border-slate-800 shadow-md">
|
| 121 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 122 |
+
<CardTitle className="text-xs font-medium uppercase tracking-wider text-slate-400">
|
| 123 |
+
Score d'Opinion Global
|
| 124 |
+
</CardTitle>
|
| 125 |
+
<Brain className="h-4 w-4 text-slate-400" />
|
| 126 |
+
</CardHeader>
|
| 127 |
+
<CardContent className="flex items-center justify-between">
|
| 128 |
+
<div>
|
| 129 |
+
<div className="text-3xl font-bold text-white">
|
| 130 |
+
{metrics.opinion}/100
|
| 131 |
+
</div>
|
| 132 |
+
<p className="text-xs text-slate-400 mt-1">Synthèse IA des signaux</p>
|
| 133 |
+
</div>
|
| 134 |
+
<div className="h-12 w-24 bg-white/10 rounded flex items-center justify-center">
|
| 135 |
+
<span className="text-lg font-bold">
|
| 136 |
+
{metrics.opinion > 60 ? "POS" : (metrics.opinion < 40 ? "NEG" : "NEU")}
|
| 137 |
+
</span>
|
| 138 |
+
</div>
|
| 139 |
+
</CardContent>
|
| 140 |
+
</Card>
|
| 141 |
+
|
| 142 |
+
</div>
|
| 143 |
+
)
|
| 144 |
+
}
|
components/neurolink/video-player.tsx
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
import { motion } from "framer-motion"
|
| 3 |
+
import { Play, Loader, Upload } from "lucide-react"
|
| 4 |
+
|
| 5 |
+
interface VideoPlayerProps {
|
| 6 |
+
progress: number
|
| 7 |
+
isRunning: boolean
|
| 8 |
+
isCalibrating: boolean
|
| 9 |
+
videoUrl?: string
|
| 10 |
+
sessionState?: string // Added sessionState prop to fix undeclared variable error
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export default function VideoPlayer({ progress, isRunning, isCalibrating, videoUrl, sessionState }: VideoPlayerProps) {
|
| 14 |
+
return (
|
| 15 |
+
<motion.div
|
| 16 |
+
className="relative bg-white rounded-xl overflow-hidden border border-gray-200 shadow-md"
|
| 17 |
+
initial={{ opacity: 0, y: 20 }}
|
| 18 |
+
animate={{ opacity: 1, y: 0 }}
|
| 19 |
+
transition={{ duration: 0.5 }}
|
| 20 |
+
>
|
| 21 |
+
{/* Video container */}
|
| 22 |
+
<div className="aspect-video bg-black flex items-center justify-center relative overflow-hidden">
|
| 23 |
+
{videoUrl ? (
|
| 24 |
+
<video
|
| 25 |
+
src={videoUrl}
|
| 26 |
+
className="w-full h-full object-contain"
|
| 27 |
+
controls={sessionState !== "running"}
|
| 28 |
+
autoPlay={isRunning}
|
| 29 |
+
/>
|
| 30 |
+
) : (
|
| 31 |
+
<>
|
| 32 |
+
<div className="absolute inset-0 bg-[linear-gradient(45deg,transparent_25%,rgba(37,99,235,.05)_25%,rgba(37,99,235,.05)_50%,transparent_50%,transparent_75%,rgba(37,99,235,.05)_75%,rgba(37,99,235,.05))] bg-[length:40px_40px] animate-pulse" />
|
| 33 |
+
|
| 34 |
+
{isCalibrating ? (
|
| 35 |
+
<motion.div
|
| 36 |
+
className="flex flex-col items-center gap-4 z-10"
|
| 37 |
+
animate={{ scale: [1, 1.1, 1] }}
|
| 38 |
+
transition={{ duration: 1.5, repeat: Number.POSITIVE_INFINITY }}
|
| 39 |
+
>
|
| 40 |
+
<Loader className="w-12 h-12 text-neuro-blue animate-spin" />
|
| 41 |
+
<p className="text-neuro-blue font-mono text-sm">Calibrating Sensors...</p>
|
| 42 |
+
</motion.div>
|
| 43 |
+
) : isRunning ? (
|
| 44 |
+
<div className="z-10">
|
| 45 |
+
<Play className="w-16 h-16 text-neuro-blue/60" fill="currentColor" />
|
| 46 |
+
</div>
|
| 47 |
+
) : (
|
| 48 |
+
<div className="z-10 text-center">
|
| 49 |
+
<Upload className="w-16 h-16 text-gray-400 mx-auto mb-3" />
|
| 50 |
+
<p className="text-gray-400 font-mono text-sm">Select a video to begin</p>
|
| 51 |
+
</div>
|
| 52 |
+
)}
|
| 53 |
+
</>
|
| 54 |
+
)}
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
{/* Progress bar */}
|
| 58 |
+
<div className="h-1 bg-gray-200">
|
| 59 |
+
<motion.div
|
| 60 |
+
className="h-full bg-gradient-to-r from-neuro-blue to-blue-500"
|
| 61 |
+
initial={{ width: "0%" }}
|
| 62 |
+
animate={{ width: `${progress}%` }}
|
| 63 |
+
transition={{ duration: 0.5, ease: "easeOut" }}
|
| 64 |
+
/>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
{/* Progress text */}
|
| 68 |
+
<div className="px-4 py-3 bg-gray-50 border-t border-gray-200 flex justify-between items-center">
|
| 69 |
+
<span className="text-xs font-mono text-neuro-muted">Progress</span>
|
| 70 |
+
<span className="text-sm font-mono text-neuro-blue">{progress.toFixed(1)}%</span>
|
| 71 |
+
</div>
|
| 72 |
+
</motion.div>
|
| 73 |
+
)
|
| 74 |
+
}
|
components/theme-provider.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import {
|
| 5 |
+
ThemeProvider as NextThemesProvider,
|
| 6 |
+
type ThemeProviderProps,
|
| 7 |
+
} from 'next-themes'
|
| 8 |
+
|
| 9 |
+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
| 10 |
+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
| 11 |
+
}
|
components/ui/accordion.tsx
ADDED
|
@@ -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 }
|
components/ui/alert-dialog.tsx
ADDED
|
@@ -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 |
+
}
|
components/ui/alert.tsx
ADDED
|
@@ -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 }
|
components/ui/aspect-ratio.tsx
ADDED
|
@@ -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 }
|
components/ui/avatar.tsx
ADDED
|
@@ -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 }
|
components/ui/badge.tsx
ADDED
|
@@ -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-md 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 }
|
components/ui/breadcrumb.tsx
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 3 |
+
import { ChevronRight, MoreHorizontal } from 'lucide-react'
|
| 4 |
+
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
|
| 7 |
+
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
| 8 |
+
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
| 12 |
+
return (
|
| 13 |
+
<ol
|
| 14 |
+
data-slot="breadcrumb-list"
|
| 15 |
+
className={cn(
|
| 16 |
+
'text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
|
| 25 |
+
return (
|
| 26 |
+
<li
|
| 27 |
+
data-slot="breadcrumb-item"
|
| 28 |
+
className={cn('inline-flex items-center gap-1.5', className)}
|
| 29 |
+
{...props}
|
| 30 |
+
/>
|
| 31 |
+
)
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function BreadcrumbLink({
|
| 35 |
+
asChild,
|
| 36 |
+
className,
|
| 37 |
+
...props
|
| 38 |
+
}: React.ComponentProps<'a'> & {
|
| 39 |
+
asChild?: boolean
|
| 40 |
+
}) {
|
| 41 |
+
const Comp = asChild ? Slot : 'a'
|
| 42 |
+
|
| 43 |
+
return (
|
| 44 |
+
<Comp
|
| 45 |
+
data-slot="breadcrumb-link"
|
| 46 |
+
className={cn('hover:text-foreground transition-colors', className)}
|
| 47 |
+
{...props}
|
| 48 |
+
/>
|
| 49 |
+
)
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
|
| 53 |
+
return (
|
| 54 |
+
<span
|
| 55 |
+
data-slot="breadcrumb-page"
|
| 56 |
+
role="link"
|
| 57 |
+
aria-disabled="true"
|
| 58 |
+
aria-current="page"
|
| 59 |
+
className={cn('text-foreground font-normal', className)}
|
| 60 |
+
{...props}
|
| 61 |
+
/>
|
| 62 |
+
)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function BreadcrumbSeparator({
|
| 66 |
+
children,
|
| 67 |
+
className,
|
| 68 |
+
...props
|
| 69 |
+
}: React.ComponentProps<'li'>) {
|
| 70 |
+
return (
|
| 71 |
+
<li
|
| 72 |
+
data-slot="breadcrumb-separator"
|
| 73 |
+
role="presentation"
|
| 74 |
+
aria-hidden="true"
|
| 75 |
+
className={cn('[&>svg]:size-3.5', className)}
|
| 76 |
+
{...props}
|
| 77 |
+
>
|
| 78 |
+
{children ?? <ChevronRight />}
|
| 79 |
+
</li>
|
| 80 |
+
)
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function BreadcrumbEllipsis({
|
| 84 |
+
className,
|
| 85 |
+
...props
|
| 86 |
+
}: React.ComponentProps<'span'>) {
|
| 87 |
+
return (
|
| 88 |
+
<span
|
| 89 |
+
data-slot="breadcrumb-ellipsis"
|
| 90 |
+
role="presentation"
|
| 91 |
+
aria-hidden="true"
|
| 92 |
+
className={cn('flex size-9 items-center justify-center', className)}
|
| 93 |
+
{...props}
|
| 94 |
+
>
|
| 95 |
+
<MoreHorizontal className="size-4" />
|
| 96 |
+
<span className="sr-only">More</span>
|
| 97 |
+
</span>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
export {
|
| 102 |
+
Breadcrumb,
|
| 103 |
+
BreadcrumbList,
|
| 104 |
+
BreadcrumbItem,
|
| 105 |
+
BreadcrumbLink,
|
| 106 |
+
BreadcrumbPage,
|
| 107 |
+
BreadcrumbSeparator,
|
| 108 |
+
BreadcrumbEllipsis,
|
| 109 |
+
}
|
components/ui/button-group.tsx
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 2 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 3 |
+
|
| 4 |
+
import { cn } from '@/lib/utils'
|
| 5 |
+
import { Separator } from '@/components/ui/separator'
|
| 6 |
+
|
| 7 |
+
const buttonGroupVariants = cva(
|
| 8 |
+
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
orientation: {
|
| 12 |
+
horizontal:
|
| 13 |
+
'[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
|
| 14 |
+
vertical:
|
| 15 |
+
'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',
|
| 16 |
+
},
|
| 17 |
+
},
|
| 18 |
+
defaultVariants: {
|
| 19 |
+
orientation: 'horizontal',
|
| 20 |
+
},
|
| 21 |
+
},
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
function ButtonGroup({
|
| 25 |
+
className,
|
| 26 |
+
orientation,
|
| 27 |
+
...props
|
| 28 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {
|
| 29 |
+
return (
|
| 30 |
+
<div
|
| 31 |
+
role="group"
|
| 32 |
+
data-slot="button-group"
|
| 33 |
+
data-orientation={orientation}
|
| 34 |
+
className={cn(buttonGroupVariants({ orientation }), className)}
|
| 35 |
+
{...props}
|
| 36 |
+
/>
|
| 37 |
+
)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function ButtonGroupText({
|
| 41 |
+
className,
|
| 42 |
+
asChild = false,
|
| 43 |
+
...props
|
| 44 |
+
}: React.ComponentProps<'div'> & {
|
| 45 |
+
asChild?: boolean
|
| 46 |
+
}) {
|
| 47 |
+
const Comp = asChild ? Slot : 'div'
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<Comp
|
| 51 |
+
className={cn(
|
| 52 |
+
"bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
| 53 |
+
className,
|
| 54 |
+
)}
|
| 55 |
+
{...props}
|
| 56 |
+
/>
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function ButtonGroupSeparator({
|
| 61 |
+
className,
|
| 62 |
+
orientation = 'vertical',
|
| 63 |
+
...props
|
| 64 |
+
}: React.ComponentProps<typeof Separator>) {
|
| 65 |
+
return (
|
| 66 |
+
<Separator
|
| 67 |
+
data-slot="button-group-separator"
|
| 68 |
+
orientation={orientation}
|
| 69 |
+
className={cn(
|
| 70 |
+
'bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto',
|
| 71 |
+
className,
|
| 72 |
+
)}
|
| 73 |
+
{...props}
|
| 74 |
+
/>
|
| 75 |
+
)
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
export {
|
| 79 |
+
ButtonGroup,
|
| 80 |
+
ButtonGroupSeparator,
|
| 81 |
+
ButtonGroupText,
|
| 82 |
+
buttonGroupVariants,
|
| 83 |
+
}
|
components/ui/button.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 buttonVariants = cva(
|
| 8 |
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-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",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
| 13 |
+
destructive:
|
| 14 |
+
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
| 15 |
+
outline:
|
| 16 |
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
| 17 |
+
secondary:
|
| 18 |
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
| 19 |
+
ghost:
|
| 20 |
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
| 21 |
+
link: 'text-primary underline-offset-4 hover:underline',
|
| 22 |
+
},
|
| 23 |
+
size: {
|
| 24 |
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
| 25 |
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
| 26 |
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
| 27 |
+
icon: 'size-9',
|
| 28 |
+
'icon-sm': 'size-8',
|
| 29 |
+
'icon-lg': 'size-10',
|
| 30 |
+
},
|
| 31 |
+
},
|
| 32 |
+
defaultVariants: {
|
| 33 |
+
variant: 'default',
|
| 34 |
+
size: 'default',
|
| 35 |
+
},
|
| 36 |
+
},
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
function Button({
|
| 40 |
+
className,
|
| 41 |
+
variant,
|
| 42 |
+
size,
|
| 43 |
+
asChild = false,
|
| 44 |
+
...props
|
| 45 |
+
}: React.ComponentProps<'button'> &
|
| 46 |
+
VariantProps<typeof buttonVariants> & {
|
| 47 |
+
asChild?: boolean
|
| 48 |
+
}) {
|
| 49 |
+
const Comp = asChild ? Slot : 'button'
|
| 50 |
+
|
| 51 |
+
return (
|
| 52 |
+
<Comp
|
| 53 |
+
data-slot="button"
|
| 54 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 55 |
+
{...props}
|
| 56 |
+
/>
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
export { Button, buttonVariants }
|
components/ui/calendar.tsx
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import {
|
| 5 |
+
ChevronDownIcon,
|
| 6 |
+
ChevronLeftIcon,
|
| 7 |
+
ChevronRightIcon,
|
| 8 |
+
} from 'lucide-react'
|
| 9 |
+
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker'
|
| 10 |
+
|
| 11 |
+
import { cn } from '@/lib/utils'
|
| 12 |
+
import { Button, buttonVariants } from '@/components/ui/button'
|
| 13 |
+
|
| 14 |
+
function Calendar({
|
| 15 |
+
className,
|
| 16 |
+
classNames,
|
| 17 |
+
showOutsideDays = true,
|
| 18 |
+
captionLayout = 'label',
|
| 19 |
+
buttonVariant = 'ghost',
|
| 20 |
+
formatters,
|
| 21 |
+
components,
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof DayPicker> & {
|
| 24 |
+
buttonVariant?: React.ComponentProps<typeof Button>['variant']
|
| 25 |
+
}) {
|
| 26 |
+
const defaultClassNames = getDefaultClassNames()
|
| 27 |
+
|
| 28 |
+
return (
|
| 29 |
+
<DayPicker
|
| 30 |
+
showOutsideDays={showOutsideDays}
|
| 31 |
+
className={cn(
|
| 32 |
+
'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
|
| 33 |
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
| 34 |
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
| 35 |
+
className,
|
| 36 |
+
)}
|
| 37 |
+
captionLayout={captionLayout}
|
| 38 |
+
formatters={{
|
| 39 |
+
formatMonthDropdown: (date) =>
|
| 40 |
+
date.toLocaleString('default', { month: 'short' }),
|
| 41 |
+
...formatters,
|
| 42 |
+
}}
|
| 43 |
+
classNames={{
|
| 44 |
+
root: cn('w-fit', defaultClassNames.root),
|
| 45 |
+
months: cn(
|
| 46 |
+
'flex gap-4 flex-col md:flex-row relative',
|
| 47 |
+
defaultClassNames.months,
|
| 48 |
+
),
|
| 49 |
+
month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
|
| 50 |
+
nav: cn(
|
| 51 |
+
'flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between',
|
| 52 |
+
defaultClassNames.nav,
|
| 53 |
+
),
|
| 54 |
+
button_previous: cn(
|
| 55 |
+
buttonVariants({ variant: buttonVariant }),
|
| 56 |
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
| 57 |
+
defaultClassNames.button_previous,
|
| 58 |
+
),
|
| 59 |
+
button_next: cn(
|
| 60 |
+
buttonVariants({ variant: buttonVariant }),
|
| 61 |
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
| 62 |
+
defaultClassNames.button_next,
|
| 63 |
+
),
|
| 64 |
+
month_caption: cn(
|
| 65 |
+
'flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)',
|
| 66 |
+
defaultClassNames.month_caption,
|
| 67 |
+
),
|
| 68 |
+
dropdowns: cn(
|
| 69 |
+
'w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5',
|
| 70 |
+
defaultClassNames.dropdowns,
|
| 71 |
+
),
|
| 72 |
+
dropdown_root: cn(
|
| 73 |
+
'relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md',
|
| 74 |
+
defaultClassNames.dropdown_root,
|
| 75 |
+
),
|
| 76 |
+
dropdown: cn(
|
| 77 |
+
'absolute bg-popover inset-0 opacity-0',
|
| 78 |
+
defaultClassNames.dropdown,
|
| 79 |
+
),
|
| 80 |
+
caption_label: cn(
|
| 81 |
+
'select-none font-medium',
|
| 82 |
+
captionLayout === 'label'
|
| 83 |
+
? 'text-sm'
|
| 84 |
+
: 'rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5',
|
| 85 |
+
defaultClassNames.caption_label,
|
| 86 |
+
),
|
| 87 |
+
table: 'w-full border-collapse',
|
| 88 |
+
weekdays: cn('flex', defaultClassNames.weekdays),
|
| 89 |
+
weekday: cn(
|
| 90 |
+
'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none',
|
| 91 |
+
defaultClassNames.weekday,
|
| 92 |
+
),
|
| 93 |
+
week: cn('flex w-full mt-2', defaultClassNames.week),
|
| 94 |
+
week_number_header: cn(
|
| 95 |
+
'select-none w-(--cell-size)',
|
| 96 |
+
defaultClassNames.week_number_header,
|
| 97 |
+
),
|
| 98 |
+
week_number: cn(
|
| 99 |
+
'text-[0.8rem] select-none text-muted-foreground',
|
| 100 |
+
defaultClassNames.week_number,
|
| 101 |
+
),
|
| 102 |
+
day: cn(
|
| 103 |
+
'relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none',
|
| 104 |
+
defaultClassNames.day,
|
| 105 |
+
),
|
| 106 |
+
range_start: cn(
|
| 107 |
+
'rounded-l-md bg-accent',
|
| 108 |
+
defaultClassNames.range_start,
|
| 109 |
+
),
|
| 110 |
+
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
| 111 |
+
range_end: cn('rounded-r-md bg-accent', defaultClassNames.range_end),
|
| 112 |
+
today: cn(
|
| 113 |
+
'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
|
| 114 |
+
defaultClassNames.today,
|
| 115 |
+
),
|
| 116 |
+
outside: cn(
|
| 117 |
+
'text-muted-foreground aria-selected:text-muted-foreground',
|
| 118 |
+
defaultClassNames.outside,
|
| 119 |
+
),
|
| 120 |
+
disabled: cn(
|
| 121 |
+
'text-muted-foreground opacity-50',
|
| 122 |
+
defaultClassNames.disabled,
|
| 123 |
+
),
|
| 124 |
+
hidden: cn('invisible', defaultClassNames.hidden),
|
| 125 |
+
...classNames,
|
| 126 |
+
}}
|
| 127 |
+
components={{
|
| 128 |
+
Root: ({ className, rootRef, ...props }) => {
|
| 129 |
+
return (
|
| 130 |
+
<div
|
| 131 |
+
data-slot="calendar"
|
| 132 |
+
ref={rootRef}
|
| 133 |
+
className={cn(className)}
|
| 134 |
+
{...props}
|
| 135 |
+
/>
|
| 136 |
+
)
|
| 137 |
+
},
|
| 138 |
+
Chevron: ({ className, orientation, ...props }) => {
|
| 139 |
+
if (orientation === 'left') {
|
| 140 |
+
return (
|
| 141 |
+
<ChevronLeftIcon className={cn('size-4', className)} {...props} />
|
| 142 |
+
)
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
if (orientation === 'right') {
|
| 146 |
+
return (
|
| 147 |
+
<ChevronRightIcon
|
| 148 |
+
className={cn('size-4', className)}
|
| 149 |
+
{...props}
|
| 150 |
+
/>
|
| 151 |
+
)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
return (
|
| 155 |
+
<ChevronDownIcon className={cn('size-4', className)} {...props} />
|
| 156 |
+
)
|
| 157 |
+
},
|
| 158 |
+
DayButton: CalendarDayButton,
|
| 159 |
+
WeekNumber: ({ children, ...props }) => {
|
| 160 |
+
return (
|
| 161 |
+
<td {...props}>
|
| 162 |
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
| 163 |
+
{children}
|
| 164 |
+
</div>
|
| 165 |
+
</td>
|
| 166 |
+
)
|
| 167 |
+
},
|
| 168 |
+
...components,
|
| 169 |
+
}}
|
| 170 |
+
{...props}
|
| 171 |
+
/>
|
| 172 |
+
)
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
function CalendarDayButton({
|
| 176 |
+
className,
|
| 177 |
+
day,
|
| 178 |
+
modifiers,
|
| 179 |
+
...props
|
| 180 |
+
}: React.ComponentProps<typeof DayButton>) {
|
| 181 |
+
const defaultClassNames = getDefaultClassNames()
|
| 182 |
+
|
| 183 |
+
const ref = React.useRef<HTMLButtonElement>(null)
|
| 184 |
+
React.useEffect(() => {
|
| 185 |
+
if (modifiers.focused) ref.current?.focus()
|
| 186 |
+
}, [modifiers.focused])
|
| 187 |
+
|
| 188 |
+
return (
|
| 189 |
+
<Button
|
| 190 |
+
ref={ref}
|
| 191 |
+
variant="ghost"
|
| 192 |
+
size="icon"
|
| 193 |
+
data-day={day.date.toLocaleDateString()}
|
| 194 |
+
data-selected-single={
|
| 195 |
+
modifiers.selected &&
|
| 196 |
+
!modifiers.range_start &&
|
| 197 |
+
!modifiers.range_end &&
|
| 198 |
+
!modifiers.range_middle
|
| 199 |
+
}
|
| 200 |
+
data-range-start={modifiers.range_start}
|
| 201 |
+
data-range-end={modifiers.range_end}
|
| 202 |
+
data-range-middle={modifiers.range_middle}
|
| 203 |
+
className={cn(
|
| 204 |
+
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70',
|
| 205 |
+
defaultClassNames.day,
|
| 206 |
+
className,
|
| 207 |
+
)}
|
| 208 |
+
{...props}
|
| 209 |
+
/>
|
| 210 |
+
)
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
export { Calendar, CalendarDayButton }
|
components/ui/card.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
|
| 3 |
+
import { cn } from '@/lib/utils'
|
| 4 |
+
|
| 5 |
+
function Card({ className, ...props }: React.ComponentProps<'div'>) {
|
| 6 |
+
return (
|
| 7 |
+
<div
|
| 8 |
+
data-slot="card"
|
| 9 |
+
className={cn(
|
| 10 |
+
'bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
|
| 11 |
+
className,
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 19 |
+
return (
|
| 20 |
+
<div
|
| 21 |
+
data-slot="card-header"
|
| 22 |
+
className={cn(
|
| 23 |
+
'@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
|
| 24 |
+
className,
|
| 25 |
+
)}
|
| 26 |
+
{...props}
|
| 27 |
+
/>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 32 |
+
return (
|
| 33 |
+
<div
|
| 34 |
+
data-slot="card-title"
|
| 35 |
+
className={cn('leading-none font-semibold', className)}
|
| 36 |
+
{...props}
|
| 37 |
+
/>
|
| 38 |
+
)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
|
| 42 |
+
return (
|
| 43 |
+
<div
|
| 44 |
+
data-slot="card-description"
|
| 45 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 46 |
+
{...props}
|
| 47 |
+
/>
|
| 48 |
+
)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
|
| 52 |
+
return (
|
| 53 |
+
<div
|
| 54 |
+
data-slot="card-action"
|
| 55 |
+
className={cn(
|
| 56 |
+
'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
|
| 57 |
+
className,
|
| 58 |
+
)}
|
| 59 |
+
{...props}
|
| 60 |
+
/>
|
| 61 |
+
)
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 65 |
+
return (
|
| 66 |
+
<div
|
| 67 |
+
data-slot="card-content"
|
| 68 |
+
className={cn('px-6', className)}
|
| 69 |
+
{...props}
|
| 70 |
+
/>
|
| 71 |
+
)
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 75 |
+
return (
|
| 76 |
+
<div
|
| 77 |
+
data-slot="card-footer"
|
| 78 |
+
className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
|
| 79 |
+
{...props}
|
| 80 |
+
/>
|
| 81 |
+
)
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
export {
|
| 85 |
+
Card,
|
| 86 |
+
CardHeader,
|
| 87 |
+
CardFooter,
|
| 88 |
+
CardTitle,
|
| 89 |
+
CardAction,
|
| 90 |
+
CardDescription,
|
| 91 |
+
CardContent,
|
| 92 |
+
}
|
components/ui/carousel.tsx
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
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',
|
| 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 size-8 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 |
+
<ArrowLeft />
|
| 199 |
+
<span className="sr-only">Previous slide</span>
|
| 200 |
+
</Button>
|
| 201 |
+
)
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function CarouselNext({
|
| 205 |
+
className,
|
| 206 |
+
variant = 'outline',
|
| 207 |
+
size = 'icon',
|
| 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 size-8 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 |
+
<ArrowRight />
|
| 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 |
+
}
|
components/ui/chart.tsx
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as RechartsPrimitive from 'recharts'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
| 9 |
+
const THEMES = { light: '', dark: '.dark' } as const
|
| 10 |
+
|
| 11 |
+
export type ChartConfig = {
|
| 12 |
+
[k in string]: {
|
| 13 |
+
label?: React.ReactNode
|
| 14 |
+
icon?: React.ComponentType
|
| 15 |
+
} & (
|
| 16 |
+
| { color?: string; theme?: never }
|
| 17 |
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
type ChartContextProps = {
|
| 22 |
+
config: ChartConfig
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
| 26 |
+
|
| 27 |
+
function useChart() {
|
| 28 |
+
const context = React.useContext(ChartContext)
|
| 29 |
+
|
| 30 |
+
if (!context) {
|
| 31 |
+
throw new Error('useChart must be used within a <ChartContainer />')
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return context
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function ChartContainer({
|
| 38 |
+
id,
|
| 39 |
+
className,
|
| 40 |
+
children,
|
| 41 |
+
config,
|
| 42 |
+
...props
|
| 43 |
+
}: React.ComponentProps<'div'> & {
|
| 44 |
+
config: ChartConfig
|
| 45 |
+
children: React.ComponentProps<
|
| 46 |
+
typeof RechartsPrimitive.ResponsiveContainer
|
| 47 |
+
>['children']
|
| 48 |
+
}) {
|
| 49 |
+
const uniqueId = React.useId()
|
| 50 |
+
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`
|
| 51 |
+
|
| 52 |
+
return (
|
| 53 |
+
<ChartContext.Provider value={{ config }}>
|
| 54 |
+
<div
|
| 55 |
+
data-slot="chart"
|
| 56 |
+
data-chart={chartId}
|
| 57 |
+
className={cn(
|
| 58 |
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
| 59 |
+
className,
|
| 60 |
+
)}
|
| 61 |
+
{...props}
|
| 62 |
+
>
|
| 63 |
+
<ChartStyle id={chartId} config={config} />
|
| 64 |
+
<RechartsPrimitive.ResponsiveContainer>
|
| 65 |
+
{children}
|
| 66 |
+
</RechartsPrimitive.ResponsiveContainer>
|
| 67 |
+
</div>
|
| 68 |
+
</ChartContext.Provider>
|
| 69 |
+
)
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
| 73 |
+
const colorConfig = Object.entries(config).filter(
|
| 74 |
+
([, config]) => config.theme || config.color,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
if (!colorConfig.length) {
|
| 78 |
+
return null
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
return (
|
| 82 |
+
<style
|
| 83 |
+
dangerouslySetInnerHTML={{
|
| 84 |
+
__html: Object.entries(THEMES)
|
| 85 |
+
.map(
|
| 86 |
+
([theme, prefix]) => `
|
| 87 |
+
${prefix} [data-chart=${id}] {
|
| 88 |
+
${colorConfig
|
| 89 |
+
.map(([key, itemConfig]) => {
|
| 90 |
+
const color =
|
| 91 |
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
| 92 |
+
itemConfig.color
|
| 93 |
+
return color ? ` --color-${key}: ${color};` : null
|
| 94 |
+
})
|
| 95 |
+
.join('\n')}
|
| 96 |
+
}
|
| 97 |
+
`,
|
| 98 |
+
)
|
| 99 |
+
.join('\n'),
|
| 100 |
+
}}
|
| 101 |
+
/>
|
| 102 |
+
)
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
| 106 |
+
|
| 107 |
+
function ChartTooltipContent({
|
| 108 |
+
active,
|
| 109 |
+
payload,
|
| 110 |
+
className,
|
| 111 |
+
indicator = 'dot',
|
| 112 |
+
hideLabel = false,
|
| 113 |
+
hideIndicator = false,
|
| 114 |
+
label,
|
| 115 |
+
labelFormatter,
|
| 116 |
+
labelClassName,
|
| 117 |
+
formatter,
|
| 118 |
+
color,
|
| 119 |
+
nameKey,
|
| 120 |
+
labelKey,
|
| 121 |
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
| 122 |
+
React.ComponentProps<'div'> & {
|
| 123 |
+
hideLabel?: boolean
|
| 124 |
+
hideIndicator?: boolean
|
| 125 |
+
indicator?: 'line' | 'dot' | 'dashed'
|
| 126 |
+
nameKey?: string
|
| 127 |
+
labelKey?: string
|
| 128 |
+
}) {
|
| 129 |
+
const { config } = useChart()
|
| 130 |
+
|
| 131 |
+
const tooltipLabel = React.useMemo(() => {
|
| 132 |
+
if (hideLabel || !payload?.length) {
|
| 133 |
+
return null
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
const [item] = payload
|
| 137 |
+
const key = `${labelKey || item?.dataKey || item?.name || 'value'}`
|
| 138 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 139 |
+
const value =
|
| 140 |
+
!labelKey && typeof label === 'string'
|
| 141 |
+
? config[label as keyof typeof config]?.label || label
|
| 142 |
+
: itemConfig?.label
|
| 143 |
+
|
| 144 |
+
if (labelFormatter) {
|
| 145 |
+
return (
|
| 146 |
+
<div className={cn('font-medium', labelClassName)}>
|
| 147 |
+
{labelFormatter(value, payload)}
|
| 148 |
+
</div>
|
| 149 |
+
)
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
if (!value) {
|
| 153 |
+
return null
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
return <div className={cn('font-medium', labelClassName)}>{value}</div>
|
| 157 |
+
}, [
|
| 158 |
+
label,
|
| 159 |
+
labelFormatter,
|
| 160 |
+
payload,
|
| 161 |
+
hideLabel,
|
| 162 |
+
labelClassName,
|
| 163 |
+
config,
|
| 164 |
+
labelKey,
|
| 165 |
+
])
|
| 166 |
+
|
| 167 |
+
if (!active || !payload?.length) {
|
| 168 |
+
return null
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
const nestLabel = payload.length === 1 && indicator !== 'dot'
|
| 172 |
+
|
| 173 |
+
return (
|
| 174 |
+
<div
|
| 175 |
+
className={cn(
|
| 176 |
+
'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
| 177 |
+
className,
|
| 178 |
+
)}
|
| 179 |
+
>
|
| 180 |
+
{!nestLabel ? tooltipLabel : null}
|
| 181 |
+
<div className="grid gap-1.5">
|
| 182 |
+
{payload.map((item, index) => {
|
| 183 |
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`
|
| 184 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 185 |
+
const indicatorColor = color || item.payload.fill || item.color
|
| 186 |
+
|
| 187 |
+
return (
|
| 188 |
+
<div
|
| 189 |
+
key={item.dataKey}
|
| 190 |
+
className={cn(
|
| 191 |
+
'[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
|
| 192 |
+
indicator === 'dot' && 'items-center',
|
| 193 |
+
)}
|
| 194 |
+
>
|
| 195 |
+
{formatter && item?.value !== undefined && item.name ? (
|
| 196 |
+
formatter(item.value, item.name, item, index, item.payload)
|
| 197 |
+
) : (
|
| 198 |
+
<>
|
| 199 |
+
{itemConfig?.icon ? (
|
| 200 |
+
<itemConfig.icon />
|
| 201 |
+
) : (
|
| 202 |
+
!hideIndicator && (
|
| 203 |
+
<div
|
| 204 |
+
className={cn(
|
| 205 |
+
'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
|
| 206 |
+
{
|
| 207 |
+
'h-2.5 w-2.5': indicator === 'dot',
|
| 208 |
+
'w-1': indicator === 'line',
|
| 209 |
+
'w-0 border-[1.5px] border-dashed bg-transparent':
|
| 210 |
+
indicator === 'dashed',
|
| 211 |
+
'my-0.5': nestLabel && indicator === 'dashed',
|
| 212 |
+
},
|
| 213 |
+
)}
|
| 214 |
+
style={
|
| 215 |
+
{
|
| 216 |
+
'--color-bg': indicatorColor,
|
| 217 |
+
'--color-border': indicatorColor,
|
| 218 |
+
} as React.CSSProperties
|
| 219 |
+
}
|
| 220 |
+
/>
|
| 221 |
+
)
|
| 222 |
+
)}
|
| 223 |
+
<div
|
| 224 |
+
className={cn(
|
| 225 |
+
'flex flex-1 justify-between leading-none',
|
| 226 |
+
nestLabel ? 'items-end' : 'items-center',
|
| 227 |
+
)}
|
| 228 |
+
>
|
| 229 |
+
<div className="grid gap-1.5">
|
| 230 |
+
{nestLabel ? tooltipLabel : null}
|
| 231 |
+
<span className="text-muted-foreground">
|
| 232 |
+
{itemConfig?.label || item.name}
|
| 233 |
+
</span>
|
| 234 |
+
</div>
|
| 235 |
+
{item.value && (
|
| 236 |
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
| 237 |
+
{item.value.toLocaleString()}
|
| 238 |
+
</span>
|
| 239 |
+
)}
|
| 240 |
+
</div>
|
| 241 |
+
</>
|
| 242 |
+
)}
|
| 243 |
+
</div>
|
| 244 |
+
)
|
| 245 |
+
})}
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
)
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
const ChartLegend = RechartsPrimitive.Legend
|
| 252 |
+
|
| 253 |
+
function ChartLegendContent({
|
| 254 |
+
className,
|
| 255 |
+
hideIcon = false,
|
| 256 |
+
payload,
|
| 257 |
+
verticalAlign = 'bottom',
|
| 258 |
+
nameKey,
|
| 259 |
+
}: React.ComponentProps<'div'> &
|
| 260 |
+
Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
|
| 261 |
+
hideIcon?: boolean
|
| 262 |
+
nameKey?: string
|
| 263 |
+
}) {
|
| 264 |
+
const { config } = useChart()
|
| 265 |
+
|
| 266 |
+
if (!payload?.length) {
|
| 267 |
+
return null
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
return (
|
| 271 |
+
<div
|
| 272 |
+
className={cn(
|
| 273 |
+
'flex items-center justify-center gap-4',
|
| 274 |
+
verticalAlign === 'top' ? 'pb-3' : 'pt-3',
|
| 275 |
+
className,
|
| 276 |
+
)}
|
| 277 |
+
>
|
| 278 |
+
{payload.map((item) => {
|
| 279 |
+
const key = `${nameKey || item.dataKey || 'value'}`
|
| 280 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 281 |
+
|
| 282 |
+
return (
|
| 283 |
+
<div
|
| 284 |
+
key={item.value}
|
| 285 |
+
className={
|
| 286 |
+
'[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3'
|
| 287 |
+
}
|
| 288 |
+
>
|
| 289 |
+
{itemConfig?.icon && !hideIcon ? (
|
| 290 |
+
<itemConfig.icon />
|
| 291 |
+
) : (
|
| 292 |
+
<div
|
| 293 |
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
| 294 |
+
style={{
|
| 295 |
+
backgroundColor: item.color,
|
| 296 |
+
}}
|
| 297 |
+
/>
|
| 298 |
+
)}
|
| 299 |
+
{itemConfig?.label}
|
| 300 |
+
</div>
|
| 301 |
+
)
|
| 302 |
+
})}
|
| 303 |
+
</div>
|
| 304 |
+
)
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
// Helper to extract item config from a payload.
|
| 308 |
+
function getPayloadConfigFromPayload(
|
| 309 |
+
config: ChartConfig,
|
| 310 |
+
payload: unknown,
|
| 311 |
+
key: string,
|
| 312 |
+
) {
|
| 313 |
+
if (typeof payload !== 'object' || payload === null) {
|
| 314 |
+
return undefined
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
const payloadPayload =
|
| 318 |
+
'payload' in payload &&
|
| 319 |
+
typeof payload.payload === 'object' &&
|
| 320 |
+
payload.payload !== null
|
| 321 |
+
? payload.payload
|
| 322 |
+
: undefined
|
| 323 |
+
|
| 324 |
+
let configLabelKey: string = key
|
| 325 |
+
|
| 326 |
+
if (
|
| 327 |
+
key in payload &&
|
| 328 |
+
typeof payload[key as keyof typeof payload] === 'string'
|
| 329 |
+
) {
|
| 330 |
+
configLabelKey = payload[key as keyof typeof payload] as string
|
| 331 |
+
} else if (
|
| 332 |
+
payloadPayload &&
|
| 333 |
+
key in payloadPayload &&
|
| 334 |
+
typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
|
| 335 |
+
) {
|
| 336 |
+
configLabelKey = payloadPayload[
|
| 337 |
+
key as keyof typeof payloadPayload
|
| 338 |
+
] as string
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
return configLabelKey in config
|
| 342 |
+
? config[configLabelKey]
|
| 343 |
+
: config[key as keyof typeof config]
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
export {
|
| 347 |
+
ChartContainer,
|
| 348 |
+
ChartTooltip,
|
| 349 |
+
ChartTooltipContent,
|
| 350 |
+
ChartLegend,
|
| 351 |
+
ChartLegendContent,
|
| 352 |
+
ChartStyle,
|
| 353 |
+
}
|
components/ui/checkbox.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
|
| 5 |
+
import { CheckIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Checkbox({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<CheckboxPrimitive.Root
|
| 15 |
+
data-slot="checkbox"
|
| 16 |
+
className={cn(
|
| 17 |
+
'peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
>
|
| 22 |
+
<CheckboxPrimitive.Indicator
|
| 23 |
+
data-slot="checkbox-indicator"
|
| 24 |
+
className="flex items-center justify-center text-current transition-none"
|
| 25 |
+
>
|
| 26 |
+
<CheckIcon className="size-3.5" />
|
| 27 |
+
</CheckboxPrimitive.Indicator>
|
| 28 |
+
</CheckboxPrimitive.Root>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
export { Checkbox }
|
components/ui/collapsible.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible'
|
| 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 }
|
components/ui/command.tsx
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { Command as CommandPrimitive } from 'cmdk'
|
| 5 |
+
import { SearchIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
import {
|
| 9 |
+
Dialog,
|
| 10 |
+
DialogContent,
|
| 11 |
+
DialogDescription,
|
| 12 |
+
DialogHeader,
|
| 13 |
+
DialogTitle,
|
| 14 |
+
} from '@/components/ui/dialog'
|
| 15 |
+
|
| 16 |
+
function Command({
|
| 17 |
+
className,
|
| 18 |
+
...props
|
| 19 |
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
| 20 |
+
return (
|
| 21 |
+
<CommandPrimitive
|
| 22 |
+
data-slot="command"
|
| 23 |
+
className={cn(
|
| 24 |
+
'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
|
| 25 |
+
className,
|
| 26 |
+
)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function CommandDialog({
|
| 33 |
+
title = 'Command Palette',
|
| 34 |
+
description = 'Search for a command to run...',
|
| 35 |
+
children,
|
| 36 |
+
className,
|
| 37 |
+
showCloseButton = true,
|
| 38 |
+
...props
|
| 39 |
+
}: React.ComponentProps<typeof Dialog> & {
|
| 40 |
+
title?: string
|
| 41 |
+
description?: string
|
| 42 |
+
className?: string
|
| 43 |
+
showCloseButton?: boolean
|
| 44 |
+
}) {
|
| 45 |
+
return (
|
| 46 |
+
<Dialog {...props}>
|
| 47 |
+
<DialogHeader className="sr-only">
|
| 48 |
+
<DialogTitle>{title}</DialogTitle>
|
| 49 |
+
<DialogDescription>{description}</DialogDescription>
|
| 50 |
+
</DialogHeader>
|
| 51 |
+
<DialogContent
|
| 52 |
+
className={cn('overflow-hidden p-0', className)}
|
| 53 |
+
showCloseButton={showCloseButton}
|
| 54 |
+
>
|
| 55 |
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[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">
|
| 56 |
+
{children}
|
| 57 |
+
</Command>
|
| 58 |
+
</DialogContent>
|
| 59 |
+
</Dialog>
|
| 60 |
+
)
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
function CommandInput({
|
| 64 |
+
className,
|
| 65 |
+
...props
|
| 66 |
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
| 67 |
+
return (
|
| 68 |
+
<div
|
| 69 |
+
data-slot="command-input-wrapper"
|
| 70 |
+
className="flex h-9 items-center gap-2 border-b px-3"
|
| 71 |
+
>
|
| 72 |
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
| 73 |
+
<CommandPrimitive.Input
|
| 74 |
+
data-slot="command-input"
|
| 75 |
+
className={cn(
|
| 76 |
+
'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
|
| 77 |
+
className,
|
| 78 |
+
)}
|
| 79 |
+
{...props}
|
| 80 |
+
/>
|
| 81 |
+
</div>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function CommandList({
|
| 86 |
+
className,
|
| 87 |
+
...props
|
| 88 |
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
| 89 |
+
return (
|
| 90 |
+
<CommandPrimitive.List
|
| 91 |
+
data-slot="command-list"
|
| 92 |
+
className={cn(
|
| 93 |
+
'max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto',
|
| 94 |
+
className,
|
| 95 |
+
)}
|
| 96 |
+
{...props}
|
| 97 |
+
/>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function CommandEmpty({
|
| 102 |
+
...props
|
| 103 |
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
| 104 |
+
return (
|
| 105 |
+
<CommandPrimitive.Empty
|
| 106 |
+
data-slot="command-empty"
|
| 107 |
+
className="py-6 text-center text-sm"
|
| 108 |
+
{...props}
|
| 109 |
+
/>
|
| 110 |
+
)
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function CommandGroup({
|
| 114 |
+
className,
|
| 115 |
+
...props
|
| 116 |
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
| 117 |
+
return (
|
| 118 |
+
<CommandPrimitive.Group
|
| 119 |
+
data-slot="command-group"
|
| 120 |
+
className={cn(
|
| 121 |
+
'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
|
| 122 |
+
className,
|
| 123 |
+
)}
|
| 124 |
+
{...props}
|
| 125 |
+
/>
|
| 126 |
+
)
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
function CommandSeparator({
|
| 130 |
+
className,
|
| 131 |
+
...props
|
| 132 |
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
| 133 |
+
return (
|
| 134 |
+
<CommandPrimitive.Separator
|
| 135 |
+
data-slot="command-separator"
|
| 136 |
+
className={cn('bg-border -mx-1 h-px', className)}
|
| 137 |
+
{...props}
|
| 138 |
+
/>
|
| 139 |
+
)
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
function CommandItem({
|
| 143 |
+
className,
|
| 144 |
+
...props
|
| 145 |
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
| 146 |
+
return (
|
| 147 |
+
<CommandPrimitive.Item
|
| 148 |
+
data-slot="command-item"
|
| 149 |
+
className={cn(
|
| 150 |
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 151 |
+
className,
|
| 152 |
+
)}
|
| 153 |
+
{...props}
|
| 154 |
+
/>
|
| 155 |
+
)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
function CommandShortcut({
|
| 159 |
+
className,
|
| 160 |
+
...props
|
| 161 |
+
}: React.ComponentProps<'span'>) {
|
| 162 |
+
return (
|
| 163 |
+
<span
|
| 164 |
+
data-slot="command-shortcut"
|
| 165 |
+
className={cn(
|
| 166 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 167 |
+
className,
|
| 168 |
+
)}
|
| 169 |
+
{...props}
|
| 170 |
+
/>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
export {
|
| 175 |
+
Command,
|
| 176 |
+
CommandDialog,
|
| 177 |
+
CommandInput,
|
| 178 |
+
CommandList,
|
| 179 |
+
CommandEmpty,
|
| 180 |
+
CommandGroup,
|
| 181 |
+
CommandItem,
|
| 182 |
+
CommandShortcut,
|
| 183 |
+
CommandSeparator,
|
| 184 |
+
}
|
components/ui/context-menu.tsx
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function ContextMenu({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
| 12 |
+
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function ContextMenuTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>) {
|
| 18 |
+
return (
|
| 19 |
+
<ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function ContextMenuGroup({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Group>) {
|
| 26 |
+
return (
|
| 27 |
+
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function ContextMenuPortal({
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Portal>) {
|
| 34 |
+
return (
|
| 35 |
+
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
| 36 |
+
)
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function ContextMenuSub({
|
| 40 |
+
...props
|
| 41 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Sub>) {
|
| 42 |
+
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function ContextMenuRadioGroup({
|
| 46 |
+
...props
|
| 47 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>) {
|
| 48 |
+
return (
|
| 49 |
+
<ContextMenuPrimitive.RadioGroup
|
| 50 |
+
data-slot="context-menu-radio-group"
|
| 51 |
+
{...props}
|
| 52 |
+
/>
|
| 53 |
+
)
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function ContextMenuSubTrigger({
|
| 57 |
+
className,
|
| 58 |
+
inset,
|
| 59 |
+
children,
|
| 60 |
+
...props
|
| 61 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
| 62 |
+
inset?: boolean
|
| 63 |
+
}) {
|
| 64 |
+
return (
|
| 65 |
+
<ContextMenuPrimitive.SubTrigger
|
| 66 |
+
data-slot="context-menu-sub-trigger"
|
| 67 |
+
data-inset={inset}
|
| 68 |
+
className={cn(
|
| 69 |
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 70 |
+
className,
|
| 71 |
+
)}
|
| 72 |
+
{...props}
|
| 73 |
+
>
|
| 74 |
+
{children}
|
| 75 |
+
<ChevronRightIcon className="ml-auto" />
|
| 76 |
+
</ContextMenuPrimitive.SubTrigger>
|
| 77 |
+
)
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function ContextMenuSubContent({
|
| 81 |
+
className,
|
| 82 |
+
...props
|
| 83 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
| 84 |
+
return (
|
| 85 |
+
<ContextMenuPrimitive.SubContent
|
| 86 |
+
data-slot="context-menu-sub-content"
|
| 87 |
+
className={cn(
|
| 88 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 89 |
+
className,
|
| 90 |
+
)}
|
| 91 |
+
{...props}
|
| 92 |
+
/>
|
| 93 |
+
)
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
function ContextMenuContent({
|
| 97 |
+
className,
|
| 98 |
+
...props
|
| 99 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
| 100 |
+
return (
|
| 101 |
+
<ContextMenuPrimitive.Portal>
|
| 102 |
+
<ContextMenuPrimitive.Content
|
| 103 |
+
data-slot="context-menu-content"
|
| 104 |
+
className={cn(
|
| 105 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md',
|
| 106 |
+
className,
|
| 107 |
+
)}
|
| 108 |
+
{...props}
|
| 109 |
+
/>
|
| 110 |
+
</ContextMenuPrimitive.Portal>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
function ContextMenuItem({
|
| 115 |
+
className,
|
| 116 |
+
inset,
|
| 117 |
+
variant = 'default',
|
| 118 |
+
...props
|
| 119 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
| 120 |
+
inset?: boolean
|
| 121 |
+
variant?: 'default' | 'destructive'
|
| 122 |
+
}) {
|
| 123 |
+
return (
|
| 124 |
+
<ContextMenuPrimitive.Item
|
| 125 |
+
data-slot="context-menu-item"
|
| 126 |
+
data-inset={inset}
|
| 127 |
+
data-variant={variant}
|
| 128 |
+
className={cn(
|
| 129 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 130 |
+
className,
|
| 131 |
+
)}
|
| 132 |
+
{...props}
|
| 133 |
+
/>
|
| 134 |
+
)
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
function ContextMenuCheckboxItem({
|
| 138 |
+
className,
|
| 139 |
+
children,
|
| 140 |
+
checked,
|
| 141 |
+
...props
|
| 142 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>) {
|
| 143 |
+
return (
|
| 144 |
+
<ContextMenuPrimitive.CheckboxItem
|
| 145 |
+
data-slot="context-menu-checkbox-item"
|
| 146 |
+
className={cn(
|
| 147 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 148 |
+
className,
|
| 149 |
+
)}
|
| 150 |
+
checked={checked}
|
| 151 |
+
{...props}
|
| 152 |
+
>
|
| 153 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 154 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 155 |
+
<CheckIcon className="size-4" />
|
| 156 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 157 |
+
</span>
|
| 158 |
+
{children}
|
| 159 |
+
</ContextMenuPrimitive.CheckboxItem>
|
| 160 |
+
)
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
function ContextMenuRadioItem({
|
| 164 |
+
className,
|
| 165 |
+
children,
|
| 166 |
+
...props
|
| 167 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>) {
|
| 168 |
+
return (
|
| 169 |
+
<ContextMenuPrimitive.RadioItem
|
| 170 |
+
data-slot="context-menu-radio-item"
|
| 171 |
+
className={cn(
|
| 172 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 173 |
+
className,
|
| 174 |
+
)}
|
| 175 |
+
{...props}
|
| 176 |
+
>
|
| 177 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 178 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 179 |
+
<CircleIcon className="size-2 fill-current" />
|
| 180 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 181 |
+
</span>
|
| 182 |
+
{children}
|
| 183 |
+
</ContextMenuPrimitive.RadioItem>
|
| 184 |
+
)
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function ContextMenuLabel({
|
| 188 |
+
className,
|
| 189 |
+
inset,
|
| 190 |
+
...props
|
| 191 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
| 192 |
+
inset?: boolean
|
| 193 |
+
}) {
|
| 194 |
+
return (
|
| 195 |
+
<ContextMenuPrimitive.Label
|
| 196 |
+
data-slot="context-menu-label"
|
| 197 |
+
data-inset={inset}
|
| 198 |
+
className={cn(
|
| 199 |
+
'text-foreground px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 200 |
+
className,
|
| 201 |
+
)}
|
| 202 |
+
{...props}
|
| 203 |
+
/>
|
| 204 |
+
)
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function ContextMenuSeparator({
|
| 208 |
+
className,
|
| 209 |
+
...props
|
| 210 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
| 211 |
+
return (
|
| 212 |
+
<ContextMenuPrimitive.Separator
|
| 213 |
+
data-slot="context-menu-separator"
|
| 214 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 215 |
+
{...props}
|
| 216 |
+
/>
|
| 217 |
+
)
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
function ContextMenuShortcut({
|
| 221 |
+
className,
|
| 222 |
+
...props
|
| 223 |
+
}: React.ComponentProps<'span'>) {
|
| 224 |
+
return (
|
| 225 |
+
<span
|
| 226 |
+
data-slot="context-menu-shortcut"
|
| 227 |
+
className={cn(
|
| 228 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 229 |
+
className,
|
| 230 |
+
)}
|
| 231 |
+
{...props}
|
| 232 |
+
/>
|
| 233 |
+
)
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
export {
|
| 237 |
+
ContextMenu,
|
| 238 |
+
ContextMenuTrigger,
|
| 239 |
+
ContextMenuContent,
|
| 240 |
+
ContextMenuItem,
|
| 241 |
+
ContextMenuCheckboxItem,
|
| 242 |
+
ContextMenuRadioItem,
|
| 243 |
+
ContextMenuLabel,
|
| 244 |
+
ContextMenuSeparator,
|
| 245 |
+
ContextMenuShortcut,
|
| 246 |
+
ContextMenuGroup,
|
| 247 |
+
ContextMenuPortal,
|
| 248 |
+
ContextMenuSub,
|
| 249 |
+
ContextMenuSubContent,
|
| 250 |
+
ContextMenuSubTrigger,
|
| 251 |
+
ContextMenuRadioGroup,
|
| 252 |
+
}
|
components/ui/dialog.tsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
| 5 |
+
import { XIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Dialog({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
| 12 |
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DialogTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
| 18 |
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function DialogPortal({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
| 24 |
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function DialogClose({
|
| 28 |
+
...props
|
| 29 |
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
| 30 |
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function DialogOverlay({
|
| 34 |
+
className,
|
| 35 |
+
...props
|
| 36 |
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
| 37 |
+
return (
|
| 38 |
+
<DialogPrimitive.Overlay
|
| 39 |
+
data-slot="dialog-overlay"
|
| 40 |
+
className={cn(
|
| 41 |
+
'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',
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function DialogContent({
|
| 50 |
+
className,
|
| 51 |
+
children,
|
| 52 |
+
showCloseButton = true,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
| 55 |
+
showCloseButton?: boolean
|
| 56 |
+
}) {
|
| 57 |
+
return (
|
| 58 |
+
<DialogPortal data-slot="dialog-portal">
|
| 59 |
+
<DialogOverlay />
|
| 60 |
+
<DialogPrimitive.Content
|
| 61 |
+
data-slot="dialog-content"
|
| 62 |
+
className={cn(
|
| 63 |
+
'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',
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
{children}
|
| 69 |
+
{showCloseButton && (
|
| 70 |
+
<DialogPrimitive.Close
|
| 71 |
+
data-slot="dialog-close"
|
| 72 |
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
| 73 |
+
>
|
| 74 |
+
<XIcon />
|
| 75 |
+
<span className="sr-only">Close</span>
|
| 76 |
+
</DialogPrimitive.Close>
|
| 77 |
+
)}
|
| 78 |
+
</DialogPrimitive.Content>
|
| 79 |
+
</DialogPortal>
|
| 80 |
+
)
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 84 |
+
return (
|
| 85 |
+
<div
|
| 86 |
+
data-slot="dialog-header"
|
| 87 |
+
className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
|
| 88 |
+
{...props}
|
| 89 |
+
/>
|
| 90 |
+
)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 94 |
+
return (
|
| 95 |
+
<div
|
| 96 |
+
data-slot="dialog-footer"
|
| 97 |
+
className={cn(
|
| 98 |
+
'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
|
| 99 |
+
className,
|
| 100 |
+
)}
|
| 101 |
+
{...props}
|
| 102 |
+
/>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function DialogTitle({
|
| 107 |
+
className,
|
| 108 |
+
...props
|
| 109 |
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
| 110 |
+
return (
|
| 111 |
+
<DialogPrimitive.Title
|
| 112 |
+
data-slot="dialog-title"
|
| 113 |
+
className={cn('text-lg leading-none font-semibold', className)}
|
| 114 |
+
{...props}
|
| 115 |
+
/>
|
| 116 |
+
)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function DialogDescription({
|
| 120 |
+
className,
|
| 121 |
+
...props
|
| 122 |
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
| 123 |
+
return (
|
| 124 |
+
<DialogPrimitive.Description
|
| 125 |
+
data-slot="dialog-description"
|
| 126 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 127 |
+
{...props}
|
| 128 |
+
/>
|
| 129 |
+
)
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
export {
|
| 133 |
+
Dialog,
|
| 134 |
+
DialogClose,
|
| 135 |
+
DialogContent,
|
| 136 |
+
DialogDescription,
|
| 137 |
+
DialogFooter,
|
| 138 |
+
DialogHeader,
|
| 139 |
+
DialogOverlay,
|
| 140 |
+
DialogPortal,
|
| 141 |
+
DialogTitle,
|
| 142 |
+
DialogTrigger,
|
| 143 |
+
}
|
components/ui/drawer.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { Drawer as DrawerPrimitive } from 'vaul'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Drawer({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
| 11 |
+
return <DrawerPrimitive.Root data-slot="drawer" {...props} />
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function DrawerTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
| 17 |
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function DrawerPortal({
|
| 21 |
+
...props
|
| 22 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
| 23 |
+
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function DrawerClose({
|
| 27 |
+
...props
|
| 28 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
| 29 |
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function DrawerOverlay({
|
| 33 |
+
className,
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {
|
| 36 |
+
return (
|
| 37 |
+
<DrawerPrimitive.Overlay
|
| 38 |
+
data-slot="drawer-overlay"
|
| 39 |
+
className={cn(
|
| 40 |
+
'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',
|
| 41 |
+
className,
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function DrawerContent({
|
| 49 |
+
className,
|
| 50 |
+
children,
|
| 51 |
+
...props
|
| 52 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Content>) {
|
| 53 |
+
return (
|
| 54 |
+
<DrawerPortal data-slot="drawer-portal">
|
| 55 |
+
<DrawerOverlay />
|
| 56 |
+
<DrawerPrimitive.Content
|
| 57 |
+
data-slot="drawer-content"
|
| 58 |
+
className={cn(
|
| 59 |
+
'group/drawer-content bg-background fixed z-50 flex h-auto flex-col',
|
| 60 |
+
'data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b',
|
| 61 |
+
'data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t',
|
| 62 |
+
'data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm',
|
| 63 |
+
'data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm',
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
<div className="bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />
|
| 69 |
+
{children}
|
| 70 |
+
</DrawerPrimitive.Content>
|
| 71 |
+
</DrawerPortal>
|
| 72 |
+
)
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 76 |
+
return (
|
| 77 |
+
<div
|
| 78 |
+
data-slot="drawer-header"
|
| 79 |
+
className={cn(
|
| 80 |
+
'flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left',
|
| 81 |
+
className,
|
| 82 |
+
)}
|
| 83 |
+
{...props}
|
| 84 |
+
/>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 89 |
+
return (
|
| 90 |
+
<div
|
| 91 |
+
data-slot="drawer-footer"
|
| 92 |
+
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
|
| 93 |
+
{...props}
|
| 94 |
+
/>
|
| 95 |
+
)
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function DrawerTitle({
|
| 99 |
+
className,
|
| 100 |
+
...props
|
| 101 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
| 102 |
+
return (
|
| 103 |
+
<DrawerPrimitive.Title
|
| 104 |
+
data-slot="drawer-title"
|
| 105 |
+
className={cn('text-foreground font-semibold', className)}
|
| 106 |
+
{...props}
|
| 107 |
+
/>
|
| 108 |
+
)
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function DrawerDescription({
|
| 112 |
+
className,
|
| 113 |
+
...props
|
| 114 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Description>) {
|
| 115 |
+
return (
|
| 116 |
+
<DrawerPrimitive.Description
|
| 117 |
+
data-slot="drawer-description"
|
| 118 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 119 |
+
{...props}
|
| 120 |
+
/>
|
| 121 |
+
)
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
export {
|
| 125 |
+
Drawer,
|
| 126 |
+
DrawerPortal,
|
| 127 |
+
DrawerOverlay,
|
| 128 |
+
DrawerTrigger,
|
| 129 |
+
DrawerClose,
|
| 130 |
+
DrawerContent,
|
| 131 |
+
DrawerHeader,
|
| 132 |
+
DrawerFooter,
|
| 133 |
+
DrawerTitle,
|
| 134 |
+
DrawerDescription,
|
| 135 |
+
}
|
components/ui/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function DropdownMenu({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
| 12 |
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DropdownMenuPortal({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
| 18 |
+
return (
|
| 19 |
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function DropdownMenuTrigger({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
| 26 |
+
return (
|
| 27 |
+
<DropdownMenuPrimitive.Trigger
|
| 28 |
+
data-slot="dropdown-menu-trigger"
|
| 29 |
+
{...props}
|
| 30 |
+
/>
|
| 31 |
+
)
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function DropdownMenuContent({
|
| 35 |
+
className,
|
| 36 |
+
sideOffset = 4,
|
| 37 |
+
...props
|
| 38 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
| 39 |
+
return (
|
| 40 |
+
<DropdownMenuPrimitive.Portal>
|
| 41 |
+
<DropdownMenuPrimitive.Content
|
| 42 |
+
data-slot="dropdown-menu-content"
|
| 43 |
+
sideOffset={sideOffset}
|
| 44 |
+
className={cn(
|
| 45 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md',
|
| 46 |
+
className,
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
</DropdownMenuPrimitive.Portal>
|
| 51 |
+
)
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function DropdownMenuGroup({
|
| 55 |
+
...props
|
| 56 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
| 57 |
+
return (
|
| 58 |
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
| 59 |
+
)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function DropdownMenuItem({
|
| 63 |
+
className,
|
| 64 |
+
inset,
|
| 65 |
+
variant = 'default',
|
| 66 |
+
...props
|
| 67 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
| 68 |
+
inset?: boolean
|
| 69 |
+
variant?: 'default' | 'destructive'
|
| 70 |
+
}) {
|
| 71 |
+
return (
|
| 72 |
+
<DropdownMenuPrimitive.Item
|
| 73 |
+
data-slot="dropdown-menu-item"
|
| 74 |
+
data-inset={inset}
|
| 75 |
+
data-variant={variant}
|
| 76 |
+
className={cn(
|
| 77 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 78 |
+
className,
|
| 79 |
+
)}
|
| 80 |
+
{...props}
|
| 81 |
+
/>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function DropdownMenuCheckboxItem({
|
| 86 |
+
className,
|
| 87 |
+
children,
|
| 88 |
+
checked,
|
| 89 |
+
...props
|
| 90 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
| 91 |
+
return (
|
| 92 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 93 |
+
data-slot="dropdown-menu-checkbox-item"
|
| 94 |
+
className={cn(
|
| 95 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 96 |
+
className,
|
| 97 |
+
)}
|
| 98 |
+
checked={checked}
|
| 99 |
+
{...props}
|
| 100 |
+
>
|
| 101 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 102 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 103 |
+
<CheckIcon className="size-4" />
|
| 104 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 105 |
+
</span>
|
| 106 |
+
{children}
|
| 107 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 108 |
+
)
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function DropdownMenuRadioGroup({
|
| 112 |
+
...props
|
| 113 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
| 114 |
+
return (
|
| 115 |
+
<DropdownMenuPrimitive.RadioGroup
|
| 116 |
+
data-slot="dropdown-menu-radio-group"
|
| 117 |
+
{...props}
|
| 118 |
+
/>
|
| 119 |
+
)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function DropdownMenuRadioItem({
|
| 123 |
+
className,
|
| 124 |
+
children,
|
| 125 |
+
...props
|
| 126 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
| 127 |
+
return (
|
| 128 |
+
<DropdownMenuPrimitive.RadioItem
|
| 129 |
+
data-slot="dropdown-menu-radio-item"
|
| 130 |
+
className={cn(
|
| 131 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 132 |
+
className,
|
| 133 |
+
)}
|
| 134 |
+
{...props}
|
| 135 |
+
>
|
| 136 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 137 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 138 |
+
<CircleIcon className="size-2 fill-current" />
|
| 139 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 140 |
+
</span>
|
| 141 |
+
{children}
|
| 142 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 143 |
+
)
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function DropdownMenuLabel({
|
| 147 |
+
className,
|
| 148 |
+
inset,
|
| 149 |
+
...props
|
| 150 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
| 151 |
+
inset?: boolean
|
| 152 |
+
}) {
|
| 153 |
+
return (
|
| 154 |
+
<DropdownMenuPrimitive.Label
|
| 155 |
+
data-slot="dropdown-menu-label"
|
| 156 |
+
data-inset={inset}
|
| 157 |
+
className={cn(
|
| 158 |
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 159 |
+
className,
|
| 160 |
+
)}
|
| 161 |
+
{...props}
|
| 162 |
+
/>
|
| 163 |
+
)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function DropdownMenuSeparator({
|
| 167 |
+
className,
|
| 168 |
+
...props
|
| 169 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
| 170 |
+
return (
|
| 171 |
+
<DropdownMenuPrimitive.Separator
|
| 172 |
+
data-slot="dropdown-menu-separator"
|
| 173 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 174 |
+
{...props}
|
| 175 |
+
/>
|
| 176 |
+
)
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
function DropdownMenuShortcut({
|
| 180 |
+
className,
|
| 181 |
+
...props
|
| 182 |
+
}: React.ComponentProps<'span'>) {
|
| 183 |
+
return (
|
| 184 |
+
<span
|
| 185 |
+
data-slot="dropdown-menu-shortcut"
|
| 186 |
+
className={cn(
|
| 187 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 188 |
+
className,
|
| 189 |
+
)}
|
| 190 |
+
{...props}
|
| 191 |
+
/>
|
| 192 |
+
)
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function DropdownMenuSub({
|
| 196 |
+
...props
|
| 197 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
| 198 |
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function DropdownMenuSubTrigger({
|
| 202 |
+
className,
|
| 203 |
+
inset,
|
| 204 |
+
children,
|
| 205 |
+
...props
|
| 206 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 207 |
+
inset?: boolean
|
| 208 |
+
}) {
|
| 209 |
+
return (
|
| 210 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 211 |
+
data-slot="dropdown-menu-sub-trigger"
|
| 212 |
+
data-inset={inset}
|
| 213 |
+
className={cn(
|
| 214 |
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 215 |
+
className,
|
| 216 |
+
)}
|
| 217 |
+
{...props}
|
| 218 |
+
>
|
| 219 |
+
{children}
|
| 220 |
+
<ChevronRightIcon className="ml-auto size-4" />
|
| 221 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 222 |
+
)
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function DropdownMenuSubContent({
|
| 226 |
+
className,
|
| 227 |
+
...props
|
| 228 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
| 229 |
+
return (
|
| 230 |
+
<DropdownMenuPrimitive.SubContent
|
| 231 |
+
data-slot="dropdown-menu-sub-content"
|
| 232 |
+
className={cn(
|
| 233 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 234 |
+
className,
|
| 235 |
+
)}
|
| 236 |
+
{...props}
|
| 237 |
+
/>
|
| 238 |
+
)
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
export {
|
| 242 |
+
DropdownMenu,
|
| 243 |
+
DropdownMenuPortal,
|
| 244 |
+
DropdownMenuTrigger,
|
| 245 |
+
DropdownMenuContent,
|
| 246 |
+
DropdownMenuGroup,
|
| 247 |
+
DropdownMenuLabel,
|
| 248 |
+
DropdownMenuItem,
|
| 249 |
+
DropdownMenuCheckboxItem,
|
| 250 |
+
DropdownMenuRadioGroup,
|
| 251 |
+
DropdownMenuRadioItem,
|
| 252 |
+
DropdownMenuSeparator,
|
| 253 |
+
DropdownMenuShortcut,
|
| 254 |
+
DropdownMenuSub,
|
| 255 |
+
DropdownMenuSubTrigger,
|
| 256 |
+
DropdownMenuSubContent,
|
| 257 |
+
}
|
components/ui/empty.tsx
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 2 |
+
|
| 3 |
+
import { cn } from '@/lib/utils'
|
| 4 |
+
|
| 5 |
+
function Empty({ className, ...props }: React.ComponentProps<'div'>) {
|
| 6 |
+
return (
|
| 7 |
+
<div
|
| 8 |
+
data-slot="empty"
|
| 9 |
+
className={cn(
|
| 10 |
+
'flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12',
|
| 11 |
+
className,
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 19 |
+
return (
|
| 20 |
+
<div
|
| 21 |
+
data-slot="empty-header"
|
| 22 |
+
className={cn(
|
| 23 |
+
'flex max-w-sm flex-col items-center gap-2 text-center',
|
| 24 |
+
className,
|
| 25 |
+
)}
|
| 26 |
+
{...props}
|
| 27 |
+
/>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const emptyMediaVariants = cva(
|
| 32 |
+
'flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
| 33 |
+
{
|
| 34 |
+
variants: {
|
| 35 |
+
variant: {
|
| 36 |
+
default: 'bg-transparent',
|
| 37 |
+
icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6",
|
| 38 |
+
},
|
| 39 |
+
},
|
| 40 |
+
defaultVariants: {
|
| 41 |
+
variant: 'default',
|
| 42 |
+
},
|
| 43 |
+
},
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
function EmptyMedia({
|
| 47 |
+
className,
|
| 48 |
+
variant = 'default',
|
| 49 |
+
...props
|
| 50 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>) {
|
| 51 |
+
return (
|
| 52 |
+
<div
|
| 53 |
+
data-slot="empty-icon"
|
| 54 |
+
data-variant={variant}
|
| 55 |
+
className={cn(emptyMediaVariants({ variant, className }))}
|
| 56 |
+
{...props}
|
| 57 |
+
/>
|
| 58 |
+
)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function EmptyTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 62 |
+
return (
|
| 63 |
+
<div
|
| 64 |
+
data-slot="empty-title"
|
| 65 |
+
className={cn('text-lg font-medium tracking-tight', className)}
|
| 66 |
+
{...props}
|
| 67 |
+
/>
|
| 68 |
+
)
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
function EmptyDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
| 72 |
+
return (
|
| 73 |
+
<div
|
| 74 |
+
data-slot="empty-description"
|
| 75 |
+
className={cn(
|
| 76 |
+
'text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4',
|
| 77 |
+
className,
|
| 78 |
+
)}
|
| 79 |
+
{...props}
|
| 80 |
+
/>
|
| 81 |
+
)
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
function EmptyContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 85 |
+
return (
|
| 86 |
+
<div
|
| 87 |
+
data-slot="empty-content"
|
| 88 |
+
className={cn(
|
| 89 |
+
'flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance',
|
| 90 |
+
className,
|
| 91 |
+
)}
|
| 92 |
+
{...props}
|
| 93 |
+
/>
|
| 94 |
+
)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
export {
|
| 98 |
+
Empty,
|
| 99 |
+
EmptyHeader,
|
| 100 |
+
EmptyTitle,
|
| 101 |
+
EmptyDescription,
|
| 102 |
+
EmptyContent,
|
| 103 |
+
EmptyMedia,
|
| 104 |
+
}
|
components/ui/field.tsx
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useMemo } from 'react'
|
| 4 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
import { Label } from '@/components/ui/label'
|
| 8 |
+
import { Separator } from '@/components/ui/separator'
|
| 9 |
+
|
| 10 |
+
function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
|
| 11 |
+
return (
|
| 12 |
+
<fieldset
|
| 13 |
+
data-slot="field-set"
|
| 14 |
+
className={cn(
|
| 15 |
+
'flex flex-col gap-6',
|
| 16 |
+
'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function FieldLegend({
|
| 25 |
+
className,
|
| 26 |
+
variant = 'legend',
|
| 27 |
+
...props
|
| 28 |
+
}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
|
| 29 |
+
return (
|
| 30 |
+
<legend
|
| 31 |
+
data-slot="field-legend"
|
| 32 |
+
data-variant={variant}
|
| 33 |
+
className={cn(
|
| 34 |
+
'mb-3 font-medium',
|
| 35 |
+
'data-[variant=legend]:text-base',
|
| 36 |
+
'data-[variant=label]:text-sm',
|
| 37 |
+
className,
|
| 38 |
+
)}
|
| 39 |
+
{...props}
|
| 40 |
+
/>
|
| 41 |
+
)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 45 |
+
return (
|
| 46 |
+
<div
|
| 47 |
+
data-slot="field-group"
|
| 48 |
+
className={cn(
|
| 49 |
+
'group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4',
|
| 50 |
+
className,
|
| 51 |
+
)}
|
| 52 |
+
{...props}
|
| 53 |
+
/>
|
| 54 |
+
)
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
const fieldVariants = cva(
|
| 58 |
+
'group/field flex w-full gap-3 data-[invalid=true]:text-destructive',
|
| 59 |
+
{
|
| 60 |
+
variants: {
|
| 61 |
+
orientation: {
|
| 62 |
+
vertical: ['flex-col [&>*]:w-full [&>.sr-only]:w-auto'],
|
| 63 |
+
horizontal: [
|
| 64 |
+
'flex-row items-center',
|
| 65 |
+
'[&>[data-slot=field-label]]:flex-auto',
|
| 66 |
+
'has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
| 67 |
+
],
|
| 68 |
+
responsive: [
|
| 69 |
+
'flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto',
|
| 70 |
+
'@md/field-group:[&>[data-slot=field-label]]:flex-auto',
|
| 71 |
+
'@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
| 72 |
+
],
|
| 73 |
+
},
|
| 74 |
+
},
|
| 75 |
+
defaultVariants: {
|
| 76 |
+
orientation: 'vertical',
|
| 77 |
+
},
|
| 78 |
+
},
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
function Field({
|
| 82 |
+
className,
|
| 83 |
+
orientation = 'vertical',
|
| 84 |
+
...props
|
| 85 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
|
| 86 |
+
return (
|
| 87 |
+
<div
|
| 88 |
+
role="group"
|
| 89 |
+
data-slot="field"
|
| 90 |
+
data-orientation={orientation}
|
| 91 |
+
className={cn(fieldVariants({ orientation }), className)}
|
| 92 |
+
{...props}
|
| 93 |
+
/>
|
| 94 |
+
)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 98 |
+
return (
|
| 99 |
+
<div
|
| 100 |
+
data-slot="field-content"
|
| 101 |
+
className={cn(
|
| 102 |
+
'group/field-content flex flex-1 flex-col gap-1.5 leading-snug',
|
| 103 |
+
className,
|
| 104 |
+
)}
|
| 105 |
+
{...props}
|
| 106 |
+
/>
|
| 107 |
+
)
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
function FieldLabel({
|
| 111 |
+
className,
|
| 112 |
+
...props
|
| 113 |
+
}: React.ComponentProps<typeof Label>) {
|
| 114 |
+
return (
|
| 115 |
+
<Label
|
| 116 |
+
data-slot="field-label"
|
| 117 |
+
className={cn(
|
| 118 |
+
'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50',
|
| 119 |
+
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4',
|
| 120 |
+
'has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10',
|
| 121 |
+
className,
|
| 122 |
+
)}
|
| 123 |
+
{...props}
|
| 124 |
+
/>
|
| 125 |
+
)
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 129 |
+
return (
|
| 130 |
+
<div
|
| 131 |
+
data-slot="field-label"
|
| 132 |
+
className={cn(
|
| 133 |
+
'flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
|
| 134 |
+
className,
|
| 135 |
+
)}
|
| 136 |
+
{...props}
|
| 137 |
+
/>
|
| 138 |
+
)
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
| 142 |
+
return (
|
| 143 |
+
<p
|
| 144 |
+
data-slot="field-description"
|
| 145 |
+
className={cn(
|
| 146 |
+
'text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance',
|
| 147 |
+
'last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5',
|
| 148 |
+
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
| 149 |
+
className,
|
| 150 |
+
)}
|
| 151 |
+
{...props}
|
| 152 |
+
/>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function FieldSeparator({
|
| 157 |
+
children,
|
| 158 |
+
className,
|
| 159 |
+
...props
|
| 160 |
+
}: React.ComponentProps<'div'> & {
|
| 161 |
+
children?: React.ReactNode
|
| 162 |
+
}) {
|
| 163 |
+
return (
|
| 164 |
+
<div
|
| 165 |
+
data-slot="field-separator"
|
| 166 |
+
data-content={!!children}
|
| 167 |
+
className={cn(
|
| 168 |
+
'relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2',
|
| 169 |
+
className,
|
| 170 |
+
)}
|
| 171 |
+
{...props}
|
| 172 |
+
>
|
| 173 |
+
<Separator className="absolute inset-0 top-1/2" />
|
| 174 |
+
{children && (
|
| 175 |
+
<span
|
| 176 |
+
className="bg-background text-muted-foreground relative mx-auto block w-fit px-2"
|
| 177 |
+
data-slot="field-separator-content"
|
| 178 |
+
>
|
| 179 |
+
{children}
|
| 180 |
+
</span>
|
| 181 |
+
)}
|
| 182 |
+
</div>
|
| 183 |
+
)
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
function FieldError({
|
| 187 |
+
className,
|
| 188 |
+
children,
|
| 189 |
+
errors,
|
| 190 |
+
...props
|
| 191 |
+
}: React.ComponentProps<'div'> & {
|
| 192 |
+
errors?: Array<{ message?: string } | undefined>
|
| 193 |
+
}) {
|
| 194 |
+
const content = useMemo(() => {
|
| 195 |
+
if (children) {
|
| 196 |
+
return children
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
if (!errors) {
|
| 200 |
+
return null
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
if (errors.length === 1 && errors[0]?.message) {
|
| 204 |
+
return errors[0].message
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
return (
|
| 208 |
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
| 209 |
+
{errors.map(
|
| 210 |
+
(error, index) =>
|
| 211 |
+
error?.message && <li key={index}>{error.message}</li>,
|
| 212 |
+
)}
|
| 213 |
+
</ul>
|
| 214 |
+
)
|
| 215 |
+
}, [children, errors])
|
| 216 |
+
|
| 217 |
+
if (!content) {
|
| 218 |
+
return null
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
return (
|
| 222 |
+
<div
|
| 223 |
+
role="alert"
|
| 224 |
+
data-slot="field-error"
|
| 225 |
+
className={cn('text-destructive text-sm font-normal', className)}
|
| 226 |
+
{...props}
|
| 227 |
+
>
|
| 228 |
+
{content}
|
| 229 |
+
</div>
|
| 230 |
+
)
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
export {
|
| 234 |
+
Field,
|
| 235 |
+
FieldLabel,
|
| 236 |
+
FieldDescription,
|
| 237 |
+
FieldError,
|
| 238 |
+
FieldGroup,
|
| 239 |
+
FieldLegend,
|
| 240 |
+
FieldSeparator,
|
| 241 |
+
FieldSet,
|
| 242 |
+
FieldContent,
|
| 243 |
+
FieldTitle,
|
| 244 |
+
}
|
components/ui/form.tsx
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
| 5 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 6 |
+
import {
|
| 7 |
+
Controller,
|
| 8 |
+
FormProvider,
|
| 9 |
+
useFormContext,
|
| 10 |
+
useFormState,
|
| 11 |
+
type ControllerProps,
|
| 12 |
+
type FieldPath,
|
| 13 |
+
type FieldValues,
|
| 14 |
+
} from 'react-hook-form'
|
| 15 |
+
|
| 16 |
+
import { cn } from '@/lib/utils'
|
| 17 |
+
import { Label } from '@/components/ui/label'
|
| 18 |
+
|
| 19 |
+
const Form = FormProvider
|
| 20 |
+
|
| 21 |
+
type FormFieldContextValue<
|
| 22 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 23 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 24 |
+
> = {
|
| 25 |
+
name: TName
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
| 29 |
+
{} as FormFieldContextValue,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
const FormField = <
|
| 33 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 34 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 35 |
+
>({
|
| 36 |
+
...props
|
| 37 |
+
}: ControllerProps<TFieldValues, TName>) => {
|
| 38 |
+
return (
|
| 39 |
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
| 40 |
+
<Controller {...props} />
|
| 41 |
+
</FormFieldContext.Provider>
|
| 42 |
+
)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
const useFormField = () => {
|
| 46 |
+
const fieldContext = React.useContext(FormFieldContext)
|
| 47 |
+
const itemContext = React.useContext(FormItemContext)
|
| 48 |
+
const { getFieldState } = useFormContext()
|
| 49 |
+
const formState = useFormState({ name: fieldContext.name })
|
| 50 |
+
const fieldState = getFieldState(fieldContext.name, formState)
|
| 51 |
+
|
| 52 |
+
if (!fieldContext) {
|
| 53 |
+
throw new Error('useFormField should be used within <FormField>')
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
const { id } = itemContext
|
| 57 |
+
|
| 58 |
+
return {
|
| 59 |
+
id,
|
| 60 |
+
name: fieldContext.name,
|
| 61 |
+
formItemId: `${id}-form-item`,
|
| 62 |
+
formDescriptionId: `${id}-form-item-description`,
|
| 63 |
+
formMessageId: `${id}-form-item-message`,
|
| 64 |
+
...fieldState,
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
type FormItemContextValue = {
|
| 69 |
+
id: string
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
| 73 |
+
{} as FormItemContextValue,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
|
| 77 |
+
const id = React.useId()
|
| 78 |
+
|
| 79 |
+
return (
|
| 80 |
+
<FormItemContext.Provider value={{ id }}>
|
| 81 |
+
<div
|
| 82 |
+
data-slot="form-item"
|
| 83 |
+
className={cn('grid gap-2', className)}
|
| 84 |
+
{...props}
|
| 85 |
+
/>
|
| 86 |
+
</FormItemContext.Provider>
|
| 87 |
+
)
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
function FormLabel({
|
| 91 |
+
className,
|
| 92 |
+
...props
|
| 93 |
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
| 94 |
+
const { error, formItemId } = useFormField()
|
| 95 |
+
|
| 96 |
+
return (
|
| 97 |
+
<Label
|
| 98 |
+
data-slot="form-label"
|
| 99 |
+
data-error={!!error}
|
| 100 |
+
className={cn('data-[error=true]:text-destructive', className)}
|
| 101 |
+
htmlFor={formItemId}
|
| 102 |
+
{...props}
|
| 103 |
+
/>
|
| 104 |
+
)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
| 108 |
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
| 109 |
+
|
| 110 |
+
return (
|
| 111 |
+
<Slot
|
| 112 |
+
data-slot="form-control"
|
| 113 |
+
id={formItemId}
|
| 114 |
+
aria-describedby={
|
| 115 |
+
!error
|
| 116 |
+
? `${formDescriptionId}`
|
| 117 |
+
: `${formDescriptionId} ${formMessageId}`
|
| 118 |
+
}
|
| 119 |
+
aria-invalid={!!error}
|
| 120 |
+
{...props}
|
| 121 |
+
/>
|
| 122 |
+
)
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function FormDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
| 126 |
+
const { formDescriptionId } = useFormField()
|
| 127 |
+
|
| 128 |
+
return (
|
| 129 |
+
<p
|
| 130 |
+
data-slot="form-description"
|
| 131 |
+
id={formDescriptionId}
|
| 132 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
|
| 139 |
+
const { error, formMessageId } = useFormField()
|
| 140 |
+
const body = error ? String(error?.message ?? '') : props.children
|
| 141 |
+
|
| 142 |
+
if (!body) {
|
| 143 |
+
return null
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
return (
|
| 147 |
+
<p
|
| 148 |
+
data-slot="form-message"
|
| 149 |
+
id={formMessageId}
|
| 150 |
+
className={cn('text-destructive text-sm', className)}
|
| 151 |
+
{...props}
|
| 152 |
+
>
|
| 153 |
+
{body}
|
| 154 |
+
</p>
|
| 155 |
+
)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
export {
|
| 159 |
+
useFormField,
|
| 160 |
+
Form,
|
| 161 |
+
FormItem,
|
| 162 |
+
FormLabel,
|
| 163 |
+
FormControl,
|
| 164 |
+
FormDescription,
|
| 165 |
+
FormMessage,
|
| 166 |
+
FormField,
|
| 167 |
+
}
|
components/ui/hover-card.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as HoverCardPrimitive from '@radix-ui/react-hover-card'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function HoverCard({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
| 11 |
+
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function HoverCardTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
| 17 |
+
return (
|
| 18 |
+
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function HoverCardContent({
|
| 23 |
+
className,
|
| 24 |
+
align = 'center',
|
| 25 |
+
sideOffset = 4,
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
| 28 |
+
return (
|
| 29 |
+
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
| 30 |
+
<HoverCardPrimitive.Content
|
| 31 |
+
data-slot="hover-card-content"
|
| 32 |
+
align={align}
|
| 33 |
+
sideOffset={sideOffset}
|
| 34 |
+
className={cn(
|
| 35 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
|
| 36 |
+
className,
|
| 37 |
+
)}
|
| 38 |
+
{...props}
|
| 39 |
+
/>
|
| 40 |
+
</HoverCardPrimitive.Portal>
|
| 41 |
+
)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
components/ui/input-group.tsx
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 4 |
+
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
import { Button } from '@/components/ui/button'
|
| 7 |
+
import { Input } from '@/components/ui/input'
|
| 8 |
+
import { Textarea } from '@/components/ui/textarea'
|
| 9 |
+
|
| 10 |
+
function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 11 |
+
return (
|
| 12 |
+
<div
|
| 13 |
+
data-slot="input-group"
|
| 14 |
+
role="group"
|
| 15 |
+
className={cn(
|
| 16 |
+
'group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none',
|
| 17 |
+
'h-9 has-[>textarea]:h-auto',
|
| 18 |
+
|
| 19 |
+
// Variants based on alignment.
|
| 20 |
+
'has-[>[data-align=inline-start]]:[&>input]:pl-2',
|
| 21 |
+
'has-[>[data-align=inline-end]]:[&>input]:pr-2',
|
| 22 |
+
'has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3',
|
| 23 |
+
'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3',
|
| 24 |
+
|
| 25 |
+
// Focus state.
|
| 26 |
+
'has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]',
|
| 27 |
+
|
| 28 |
+
// Error state.
|
| 29 |
+
'has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40',
|
| 30 |
+
|
| 31 |
+
className,
|
| 32 |
+
)}
|
| 33 |
+
{...props}
|
| 34 |
+
/>
|
| 35 |
+
)
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const inputGroupAddonVariants = cva(
|
| 39 |
+
"text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",
|
| 40 |
+
{
|
| 41 |
+
variants: {
|
| 42 |
+
align: {
|
| 43 |
+
'inline-start':
|
| 44 |
+
'order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]',
|
| 45 |
+
'inline-end':
|
| 46 |
+
'order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]',
|
| 47 |
+
'block-start':
|
| 48 |
+
'order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5',
|
| 49 |
+
'block-end':
|
| 50 |
+
'order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5',
|
| 51 |
+
},
|
| 52 |
+
},
|
| 53 |
+
defaultVariants: {
|
| 54 |
+
align: 'inline-start',
|
| 55 |
+
},
|
| 56 |
+
},
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
function InputGroupAddon({
|
| 60 |
+
className,
|
| 61 |
+
align = 'inline-start',
|
| 62 |
+
...props
|
| 63 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
|
| 64 |
+
return (
|
| 65 |
+
<div
|
| 66 |
+
role="group"
|
| 67 |
+
data-slot="input-group-addon"
|
| 68 |
+
data-align={align}
|
| 69 |
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
| 70 |
+
onClick={(e) => {
|
| 71 |
+
if ((e.target as HTMLElement).closest('button')) {
|
| 72 |
+
return
|
| 73 |
+
}
|
| 74 |
+
e.currentTarget.parentElement?.querySelector('input')?.focus()
|
| 75 |
+
}}
|
| 76 |
+
{...props}
|
| 77 |
+
/>
|
| 78 |
+
)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
const inputGroupButtonVariants = cva(
|
| 82 |
+
'text-sm shadow-none flex gap-2 items-center',
|
| 83 |
+
{
|
| 84 |
+
variants: {
|
| 85 |
+
size: {
|
| 86 |
+
xs: "h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",
|
| 87 |
+
sm: 'h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5',
|
| 88 |
+
'icon-xs':
|
| 89 |
+
'size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0',
|
| 90 |
+
'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
|
| 91 |
+
},
|
| 92 |
+
},
|
| 93 |
+
defaultVariants: {
|
| 94 |
+
size: 'xs',
|
| 95 |
+
},
|
| 96 |
+
},
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
function InputGroupButton({
|
| 100 |
+
className,
|
| 101 |
+
type = 'button',
|
| 102 |
+
variant = 'ghost',
|
| 103 |
+
size = 'xs',
|
| 104 |
+
...props
|
| 105 |
+
}: Omit<React.ComponentProps<typeof Button>, 'size'> &
|
| 106 |
+
VariantProps<typeof inputGroupButtonVariants>) {
|
| 107 |
+
return (
|
| 108 |
+
<Button
|
| 109 |
+
type={type}
|
| 110 |
+
data-size={size}
|
| 111 |
+
variant={variant}
|
| 112 |
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
| 113 |
+
{...props}
|
| 114 |
+
/>
|
| 115 |
+
)
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
|
| 119 |
+
return (
|
| 120 |
+
<span
|
| 121 |
+
className={cn(
|
| 122 |
+
"text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
| 123 |
+
className,
|
| 124 |
+
)}
|
| 125 |
+
{...props}
|
| 126 |
+
/>
|
| 127 |
+
)
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
function InputGroupInput({
|
| 131 |
+
className,
|
| 132 |
+
...props
|
| 133 |
+
}: React.ComponentProps<'input'>) {
|
| 134 |
+
return (
|
| 135 |
+
<Input
|
| 136 |
+
data-slot="input-group-control"
|
| 137 |
+
className={cn(
|
| 138 |
+
'flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent',
|
| 139 |
+
className,
|
| 140 |
+
)}
|
| 141 |
+
{...props}
|
| 142 |
+
/>
|
| 143 |
+
)
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function InputGroupTextarea({
|
| 147 |
+
className,
|
| 148 |
+
...props
|
| 149 |
+
}: React.ComponentProps<'textarea'>) {
|
| 150 |
+
return (
|
| 151 |
+
<Textarea
|
| 152 |
+
data-slot="input-group-control"
|
| 153 |
+
className={cn(
|
| 154 |
+
'flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent',
|
| 155 |
+
className,
|
| 156 |
+
)}
|
| 157 |
+
{...props}
|
| 158 |
+
/>
|
| 159 |
+
)
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
export {
|
| 163 |
+
InputGroup,
|
| 164 |
+
InputGroupAddon,
|
| 165 |
+
InputGroupButton,
|
| 166 |
+
InputGroupText,
|
| 167 |
+
InputGroupInput,
|
| 168 |
+
InputGroupTextarea,
|
| 169 |
+
}
|
components/ui/input-otp.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { OTPInput, OTPInputContext } from 'input-otp'
|
| 5 |
+
import { MinusIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function InputOTP({
|
| 10 |
+
className,
|
| 11 |
+
containerClassName,
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof OTPInput> & {
|
| 14 |
+
containerClassName?: string
|
| 15 |
+
}) {
|
| 16 |
+
return (
|
| 17 |
+
<OTPInput
|
| 18 |
+
data-slot="input-otp"
|
| 19 |
+
containerClassName={cn(
|
| 20 |
+
'flex items-center gap-2 has-disabled:opacity-50',
|
| 21 |
+
containerClassName,
|
| 22 |
+
)}
|
| 23 |
+
className={cn('disabled:cursor-not-allowed', className)}
|
| 24 |
+
{...props}
|
| 25 |
+
/>
|
| 26 |
+
)
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 30 |
+
return (
|
| 31 |
+
<div
|
| 32 |
+
data-slot="input-otp-group"
|
| 33 |
+
className={cn('flex items-center', className)}
|
| 34 |
+
{...props}
|
| 35 |
+
/>
|
| 36 |
+
)
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function InputOTPSlot({
|
| 40 |
+
index,
|
| 41 |
+
className,
|
| 42 |
+
...props
|
| 43 |
+
}: React.ComponentProps<'div'> & {
|
| 44 |
+
index: number
|
| 45 |
+
}) {
|
| 46 |
+
const inputOTPContext = React.useContext(OTPInputContext)
|
| 47 |
+
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<div
|
| 51 |
+
data-slot="input-otp-slot"
|
| 52 |
+
data-active={isActive}
|
| 53 |
+
className={cn(
|
| 54 |
+
'data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]',
|
| 55 |
+
className,
|
| 56 |
+
)}
|
| 57 |
+
{...props}
|
| 58 |
+
>
|
| 59 |
+
{char}
|
| 60 |
+
{hasFakeCaret && (
|
| 61 |
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 62 |
+
<div className="animate-caret-blink bg-foreground h-4 w-px duration-1000" />
|
| 63 |
+
</div>
|
| 64 |
+
)}
|
| 65 |
+
</div>
|
| 66 |
+
)
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {
|
| 70 |
+
return (
|
| 71 |
+
<div data-slot="input-otp-separator" role="separator" {...props}>
|
| 72 |
+
<MinusIcon />
|
| 73 |
+
</div>
|
| 74 |
+
)
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
components/ui/input.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
|
| 3 |
+
import { cn } from '@/lib/utils'
|
| 4 |
+
|
| 5 |
+
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
| 6 |
+
return (
|
| 7 |
+
<input
|
| 8 |
+
type={type}
|
| 9 |
+
data-slot="input"
|
| 10 |
+
className={cn(
|
| 11 |
+
'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
| 12 |
+
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
| 13 |
+
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
| 14 |
+
className,
|
| 15 |
+
)}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export { Input }
|
components/ui/item.tsx
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
import { Separator } from '@/components/ui/separator'
|
| 7 |
+
|
| 8 |
+
function ItemGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 9 |
+
return (
|
| 10 |
+
<div
|
| 11 |
+
role="list"
|
| 12 |
+
data-slot="item-group"
|
| 13 |
+
className={cn('group/item-group flex flex-col', className)}
|
| 14 |
+
{...props}
|
| 15 |
+
/>
|
| 16 |
+
)
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function ItemSeparator({
|
| 20 |
+
className,
|
| 21 |
+
...props
|
| 22 |
+
}: React.ComponentProps<typeof Separator>) {
|
| 23 |
+
return (
|
| 24 |
+
<Separator
|
| 25 |
+
data-slot="item-separator"
|
| 26 |
+
orientation="horizontal"
|
| 27 |
+
className={cn('my-0', className)}
|
| 28 |
+
{...props}
|
| 29 |
+
/>
|
| 30 |
+
)
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
const itemVariants = cva(
|
| 34 |
+
'group/item flex items-center border border-transparent text-sm rounded-md transition-colors [a&]:hover:bg-accent/50 [a&]:transition-colors duration-100 flex-wrap outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
| 35 |
+
{
|
| 36 |
+
variants: {
|
| 37 |
+
variant: {
|
| 38 |
+
default: 'bg-transparent',
|
| 39 |
+
outline: 'border-border',
|
| 40 |
+
muted: 'bg-muted/50',
|
| 41 |
+
},
|
| 42 |
+
size: {
|
| 43 |
+
default: 'p-4 gap-4 ',
|
| 44 |
+
sm: 'py-3 px-4 gap-2.5',
|
| 45 |
+
},
|
| 46 |
+
},
|
| 47 |
+
defaultVariants: {
|
| 48 |
+
variant: 'default',
|
| 49 |
+
size: 'default',
|
| 50 |
+
},
|
| 51 |
+
},
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
function Item({
|
| 55 |
+
className,
|
| 56 |
+
variant = 'default',
|
| 57 |
+
size = 'default',
|
| 58 |
+
asChild = false,
|
| 59 |
+
...props
|
| 60 |
+
}: React.ComponentProps<'div'> &
|
| 61 |
+
VariantProps<typeof itemVariants> & { asChild?: boolean }) {
|
| 62 |
+
const Comp = asChild ? Slot : 'div'
|
| 63 |
+
return (
|
| 64 |
+
<Comp
|
| 65 |
+
data-slot="item"
|
| 66 |
+
data-variant={variant}
|
| 67 |
+
data-size={size}
|
| 68 |
+
className={cn(itemVariants({ variant, size, className }))}
|
| 69 |
+
{...props}
|
| 70 |
+
/>
|
| 71 |
+
)
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
const itemMediaVariants = cva(
|
| 75 |
+
'flex shrink-0 items-center justify-center gap-2 group-has-[[data-slot=item-description]]/item:self-start [&_svg]:pointer-events-none group-has-[[data-slot=item-description]]/item:translate-y-0.5',
|
| 76 |
+
{
|
| 77 |
+
variants: {
|
| 78 |
+
variant: {
|
| 79 |
+
default: 'bg-transparent',
|
| 80 |
+
icon: "size-8 border rounded-sm bg-muted [&_svg:not([class*='size-'])]:size-4",
|
| 81 |
+
image:
|
| 82 |
+
'size-10 rounded-sm overflow-hidden [&_img]:size-full [&_img]:object-cover',
|
| 83 |
+
},
|
| 84 |
+
},
|
| 85 |
+
defaultVariants: {
|
| 86 |
+
variant: 'default',
|
| 87 |
+
},
|
| 88 |
+
},
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
function ItemMedia({
|
| 92 |
+
className,
|
| 93 |
+
variant = 'default',
|
| 94 |
+
...props
|
| 95 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof itemMediaVariants>) {
|
| 96 |
+
return (
|
| 97 |
+
<div
|
| 98 |
+
data-slot="item-media"
|
| 99 |
+
data-variant={variant}
|
| 100 |
+
className={cn(itemMediaVariants({ variant, className }))}
|
| 101 |
+
{...props}
|
| 102 |
+
/>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function ItemContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 107 |
+
return (
|
| 108 |
+
<div
|
| 109 |
+
data-slot="item-content"
|
| 110 |
+
className={cn(
|
| 111 |
+
'flex flex-1 flex-col gap-1 [&+[data-slot=item-content]]:flex-none',
|
| 112 |
+
className,
|
| 113 |
+
)}
|
| 114 |
+
{...props}
|
| 115 |
+
/>
|
| 116 |
+
)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function ItemTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 120 |
+
return (
|
| 121 |
+
<div
|
| 122 |
+
data-slot="item-title"
|
| 123 |
+
className={cn(
|
| 124 |
+
'flex w-fit items-center gap-2 text-sm leading-snug font-medium',
|
| 125 |
+
className,
|
| 126 |
+
)}
|
| 127 |
+
{...props}
|
| 128 |
+
/>
|
| 129 |
+
)
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
function ItemDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
| 133 |
+
return (
|
| 134 |
+
<p
|
| 135 |
+
data-slot="item-description"
|
| 136 |
+
className={cn(
|
| 137 |
+
'text-muted-foreground line-clamp-2 text-sm leading-normal font-normal text-balance',
|
| 138 |
+
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
| 139 |
+
className,
|
| 140 |
+
)}
|
| 141 |
+
{...props}
|
| 142 |
+
/>
|
| 143 |
+
)
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function ItemActions({ className, ...props }: React.ComponentProps<'div'>) {
|
| 147 |
+
return (
|
| 148 |
+
<div
|
| 149 |
+
data-slot="item-actions"
|
| 150 |
+
className={cn('flex items-center gap-2', className)}
|
| 151 |
+
{...props}
|
| 152 |
+
/>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function ItemHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 157 |
+
return (
|
| 158 |
+
<div
|
| 159 |
+
data-slot="item-header"
|
| 160 |
+
className={cn(
|
| 161 |
+
'flex basis-full items-center justify-between gap-2',
|
| 162 |
+
className,
|
| 163 |
+
)}
|
| 164 |
+
{...props}
|
| 165 |
+
/>
|
| 166 |
+
)
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function ItemFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 170 |
+
return (
|
| 171 |
+
<div
|
| 172 |
+
data-slot="item-footer"
|
| 173 |
+
className={cn(
|
| 174 |
+
'flex basis-full items-center justify-between gap-2',
|
| 175 |
+
className,
|
| 176 |
+
)}
|
| 177 |
+
{...props}
|
| 178 |
+
/>
|
| 179 |
+
)
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
export {
|
| 183 |
+
Item,
|
| 184 |
+
ItemMedia,
|
| 185 |
+
ItemContent,
|
| 186 |
+
ItemActions,
|
| 187 |
+
ItemGroup,
|
| 188 |
+
ItemSeparator,
|
| 189 |
+
ItemTitle,
|
| 190 |
+
ItemDescription,
|
| 191 |
+
ItemHeader,
|
| 192 |
+
ItemFooter,
|
| 193 |
+
}
|
components/ui/kbd.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { cn } from '@/lib/utils'
|
| 2 |
+
|
| 3 |
+
function Kbd({ className, ...props }: React.ComponentProps<'kbd'>) {
|
| 4 |
+
return (
|
| 5 |
+
<kbd
|
| 6 |
+
data-slot="kbd"
|
| 7 |
+
className={cn(
|
| 8 |
+
'bg-muted w-fit text-muted-foreground pointer-events-none inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none',
|
| 9 |
+
"[&_svg:not([class*='size-'])]:size-3",
|
| 10 |
+
'[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10',
|
| 11 |
+
className,
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function KbdGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 19 |
+
return (
|
| 20 |
+
<kbd
|
| 21 |
+
data-slot="kbd-group"
|
| 22 |
+
className={cn('inline-flex items-center gap-1', className)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
export { Kbd, KbdGroup }
|
components/ui/label.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Label({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<LabelPrimitive.Root
|
| 14 |
+
data-slot="label"
|
| 15 |
+
className={cn(
|
| 16 |
+
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export { Label }
|
components/ui/menubar.tsx
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as MenubarPrimitive from '@radix-ui/react-menubar'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Menubar({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<MenubarPrimitive.Root
|
| 15 |
+
data-slot="menubar"
|
| 16 |
+
className={cn(
|
| 17 |
+
'bg-background flex h-9 items-center gap-1 rounded-md border p-1 shadow-xs',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
)
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function MenubarMenu({
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
|
| 28 |
+
return <MenubarPrimitive.Menu data-slot="menubar-menu" {...props} />
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function MenubarGroup({
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Group>) {
|
| 34 |
+
return <MenubarPrimitive.Group data-slot="menubar-group" {...props} />
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function MenubarPortal({
|
| 38 |
+
...props
|
| 39 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
|
| 40 |
+
return <MenubarPrimitive.Portal data-slot="menubar-portal" {...props} />
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function MenubarRadioGroup({
|
| 44 |
+
...props
|
| 45 |
+
}: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
|
| 46 |
+
return (
|
| 47 |
+
<MenubarPrimitive.RadioGroup data-slot="menubar-radio-group" {...props} />
|
| 48 |
+
)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function MenubarTrigger({
|
| 52 |
+
className,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Trigger>) {
|
| 55 |
+
return (
|
| 56 |
+
<MenubarPrimitive.Trigger
|
| 57 |
+
data-slot="menubar-trigger"
|
| 58 |
+
className={cn(
|
| 59 |
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none',
|
| 60 |
+
className,
|
| 61 |
+
)}
|
| 62 |
+
{...props}
|
| 63 |
+
/>
|
| 64 |
+
)
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
function MenubarContent({
|
| 68 |
+
className,
|
| 69 |
+
align = 'start',
|
| 70 |
+
alignOffset = -4,
|
| 71 |
+
sideOffset = 8,
|
| 72 |
+
...props
|
| 73 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Content>) {
|
| 74 |
+
return (
|
| 75 |
+
<MenubarPortal>
|
| 76 |
+
<MenubarPrimitive.Content
|
| 77 |
+
data-slot="menubar-content"
|
| 78 |
+
align={align}
|
| 79 |
+
alignOffset={alignOffset}
|
| 80 |
+
sideOffset={sideOffset}
|
| 81 |
+
className={cn(
|
| 82 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[12rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-md',
|
| 83 |
+
className,
|
| 84 |
+
)}
|
| 85 |
+
{...props}
|
| 86 |
+
/>
|
| 87 |
+
</MenubarPortal>
|
| 88 |
+
)
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function MenubarItem({
|
| 92 |
+
className,
|
| 93 |
+
inset,
|
| 94 |
+
variant = 'default',
|
| 95 |
+
...props
|
| 96 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Item> & {
|
| 97 |
+
inset?: boolean
|
| 98 |
+
variant?: 'default' | 'destructive'
|
| 99 |
+
}) {
|
| 100 |
+
return (
|
| 101 |
+
<MenubarPrimitive.Item
|
| 102 |
+
data-slot="menubar-item"
|
| 103 |
+
data-inset={inset}
|
| 104 |
+
data-variant={variant}
|
| 105 |
+
className={cn(
|
| 106 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 107 |
+
className,
|
| 108 |
+
)}
|
| 109 |
+
{...props}
|
| 110 |
+
/>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
function MenubarCheckboxItem({
|
| 115 |
+
className,
|
| 116 |
+
children,
|
| 117 |
+
checked,
|
| 118 |
+
...props
|
| 119 |
+
}: React.ComponentProps<typeof MenubarPrimitive.CheckboxItem>) {
|
| 120 |
+
return (
|
| 121 |
+
<MenubarPrimitive.CheckboxItem
|
| 122 |
+
data-slot="menubar-checkbox-item"
|
| 123 |
+
className={cn(
|
| 124 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 125 |
+
className,
|
| 126 |
+
)}
|
| 127 |
+
checked={checked}
|
| 128 |
+
{...props}
|
| 129 |
+
>
|
| 130 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 131 |
+
<MenubarPrimitive.ItemIndicator>
|
| 132 |
+
<CheckIcon className="size-4" />
|
| 133 |
+
</MenubarPrimitive.ItemIndicator>
|
| 134 |
+
</span>
|
| 135 |
+
{children}
|
| 136 |
+
</MenubarPrimitive.CheckboxItem>
|
| 137 |
+
)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function MenubarRadioItem({
|
| 141 |
+
className,
|
| 142 |
+
children,
|
| 143 |
+
...props
|
| 144 |
+
}: React.ComponentProps<typeof MenubarPrimitive.RadioItem>) {
|
| 145 |
+
return (
|
| 146 |
+
<MenubarPrimitive.RadioItem
|
| 147 |
+
data-slot="menubar-radio-item"
|
| 148 |
+
className={cn(
|
| 149 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 150 |
+
className,
|
| 151 |
+
)}
|
| 152 |
+
{...props}
|
| 153 |
+
>
|
| 154 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 155 |
+
<MenubarPrimitive.ItemIndicator>
|
| 156 |
+
<CircleIcon className="size-2 fill-current" />
|
| 157 |
+
</MenubarPrimitive.ItemIndicator>
|
| 158 |
+
</span>
|
| 159 |
+
{children}
|
| 160 |
+
</MenubarPrimitive.RadioItem>
|
| 161 |
+
)
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
function MenubarLabel({
|
| 165 |
+
className,
|
| 166 |
+
inset,
|
| 167 |
+
...props
|
| 168 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Label> & {
|
| 169 |
+
inset?: boolean
|
| 170 |
+
}) {
|
| 171 |
+
return (
|
| 172 |
+
<MenubarPrimitive.Label
|
| 173 |
+
data-slot="menubar-label"
|
| 174 |
+
data-inset={inset}
|
| 175 |
+
className={cn(
|
| 176 |
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 177 |
+
className,
|
| 178 |
+
)}
|
| 179 |
+
{...props}
|
| 180 |
+
/>
|
| 181 |
+
)
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
function MenubarSeparator({
|
| 185 |
+
className,
|
| 186 |
+
...props
|
| 187 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Separator>) {
|
| 188 |
+
return (
|
| 189 |
+
<MenubarPrimitive.Separator
|
| 190 |
+
data-slot="menubar-separator"
|
| 191 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 192 |
+
{...props}
|
| 193 |
+
/>
|
| 194 |
+
)
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
function MenubarShortcut({
|
| 198 |
+
className,
|
| 199 |
+
...props
|
| 200 |
+
}: React.ComponentProps<'span'>) {
|
| 201 |
+
return (
|
| 202 |
+
<span
|
| 203 |
+
data-slot="menubar-shortcut"
|
| 204 |
+
className={cn(
|
| 205 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 206 |
+
className,
|
| 207 |
+
)}
|
| 208 |
+
{...props}
|
| 209 |
+
/>
|
| 210 |
+
)
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function MenubarSub({
|
| 214 |
+
...props
|
| 215 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
|
| 216 |
+
return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
function MenubarSubTrigger({
|
| 220 |
+
className,
|
| 221 |
+
inset,
|
| 222 |
+
children,
|
| 223 |
+
...props
|
| 224 |
+
}: React.ComponentProps<typeof MenubarPrimitive.SubTrigger> & {
|
| 225 |
+
inset?: boolean
|
| 226 |
+
}) {
|
| 227 |
+
return (
|
| 228 |
+
<MenubarPrimitive.SubTrigger
|
| 229 |
+
data-slot="menubar-sub-trigger"
|
| 230 |
+
data-inset={inset}
|
| 231 |
+
className={cn(
|
| 232 |
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[inset]:pl-8',
|
| 233 |
+
className,
|
| 234 |
+
)}
|
| 235 |
+
{...props}
|
| 236 |
+
>
|
| 237 |
+
{children}
|
| 238 |
+
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
| 239 |
+
</MenubarPrimitive.SubTrigger>
|
| 240 |
+
)
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function MenubarSubContent({
|
| 244 |
+
className,
|
| 245 |
+
...props
|
| 246 |
+
}: React.ComponentProps<typeof MenubarPrimitive.SubContent>) {
|
| 247 |
+
return (
|
| 248 |
+
<MenubarPrimitive.SubContent
|
| 249 |
+
data-slot="menubar-sub-content"
|
| 250 |
+
className={cn(
|
| 251 |
+
'bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 252 |
+
className,
|
| 253 |
+
)}
|
| 254 |
+
{...props}
|
| 255 |
+
/>
|
| 256 |
+
)
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
export {
|
| 260 |
+
Menubar,
|
| 261 |
+
MenubarPortal,
|
| 262 |
+
MenubarMenu,
|
| 263 |
+
MenubarTrigger,
|
| 264 |
+
MenubarContent,
|
| 265 |
+
MenubarGroup,
|
| 266 |
+
MenubarSeparator,
|
| 267 |
+
MenubarLabel,
|
| 268 |
+
MenubarItem,
|
| 269 |
+
MenubarShortcut,
|
| 270 |
+
MenubarCheckboxItem,
|
| 271 |
+
MenubarRadioGroup,
|
| 272 |
+
MenubarRadioItem,
|
| 273 |
+
MenubarSub,
|
| 274 |
+
MenubarSubTrigger,
|
| 275 |
+
MenubarSubContent,
|
| 276 |
+
}
|
components/ui/navigation-menu.tsx
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'
|
| 3 |
+
import { cva } from 'class-variance-authority'
|
| 4 |
+
import { ChevronDownIcon } from 'lucide-react'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function NavigationMenu({
|
| 9 |
+
className,
|
| 10 |
+
children,
|
| 11 |
+
viewport = true,
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
|
| 14 |
+
viewport?: boolean
|
| 15 |
+
}) {
|
| 16 |
+
return (
|
| 17 |
+
<NavigationMenuPrimitive.Root
|
| 18 |
+
data-slot="navigation-menu"
|
| 19 |
+
data-viewport={viewport}
|
| 20 |
+
className={cn(
|
| 21 |
+
'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',
|
| 22 |
+
className,
|
| 23 |
+
)}
|
| 24 |
+
{...props}
|
| 25 |
+
>
|
| 26 |
+
{children}
|
| 27 |
+
{viewport && <NavigationMenuViewport />}
|
| 28 |
+
</NavigationMenuPrimitive.Root>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function NavigationMenuList({
|
| 33 |
+
className,
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
|
| 36 |
+
return (
|
| 37 |
+
<NavigationMenuPrimitive.List
|
| 38 |
+
data-slot="navigation-menu-list"
|
| 39 |
+
className={cn(
|
| 40 |
+
'group flex flex-1 list-none items-center justify-center gap-1',
|
| 41 |
+
className,
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function NavigationMenuItem({
|
| 49 |
+
className,
|
| 50 |
+
...props
|
| 51 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
|
| 52 |
+
return (
|
| 53 |
+
<NavigationMenuPrimitive.Item
|
| 54 |
+
data-slot="navigation-menu-item"
|
| 55 |
+
className={cn('relative', className)}
|
| 56 |
+
{...props}
|
| 57 |
+
/>
|
| 58 |
+
)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const navigationMenuTriggerStyle = cva(
|
| 62 |
+
'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1',
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
function NavigationMenuTrigger({
|
| 66 |
+
className,
|
| 67 |
+
children,
|
| 68 |
+
...props
|
| 69 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
|
| 70 |
+
return (
|
| 71 |
+
<NavigationMenuPrimitive.Trigger
|
| 72 |
+
data-slot="navigation-menu-trigger"
|
| 73 |
+
className={cn(navigationMenuTriggerStyle(), 'group', className)}
|
| 74 |
+
{...props}
|
| 75 |
+
>
|
| 76 |
+
{children}{' '}
|
| 77 |
+
<ChevronDownIcon
|
| 78 |
+
className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
|
| 79 |
+
aria-hidden="true"
|
| 80 |
+
/>
|
| 81 |
+
</NavigationMenuPrimitive.Trigger>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function NavigationMenuContent({
|
| 86 |
+
className,
|
| 87 |
+
...props
|
| 88 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
|
| 89 |
+
return (
|
| 90 |
+
<NavigationMenuPrimitive.Content
|
| 91 |
+
data-slot="navigation-menu-content"
|
| 92 |
+
className={cn(
|
| 93 |
+
'data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto',
|
| 94 |
+
'group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none',
|
| 95 |
+
className,
|
| 96 |
+
)}
|
| 97 |
+
{...props}
|
| 98 |
+
/>
|
| 99 |
+
)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function NavigationMenuViewport({
|
| 103 |
+
className,
|
| 104 |
+
...props
|
| 105 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) {
|
| 106 |
+
return (
|
| 107 |
+
<div
|
| 108 |
+
className={'absolute top-full left-0 isolate z-50 flex justify-center'}
|
| 109 |
+
>
|
| 110 |
+
<NavigationMenuPrimitive.Viewport
|
| 111 |
+
data-slot="navigation-menu-viewport"
|
| 112 |
+
className={cn(
|
| 113 |
+
'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]',
|
| 114 |
+
className,
|
| 115 |
+
)}
|
| 116 |
+
{...props}
|
| 117 |
+
/>
|
| 118 |
+
</div>
|
| 119 |
+
)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function NavigationMenuLink({
|
| 123 |
+
className,
|
| 124 |
+
...props
|
| 125 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
|
| 126 |
+
return (
|
| 127 |
+
<NavigationMenuPrimitive.Link
|
| 128 |
+
data-slot="navigation-menu-link"
|
| 129 |
+
className={cn(
|
| 130 |
+
"data-[active=true]:focus:bg-accent data-[active=true]:hover:bg-accent data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-ring/50 [&_svg:not([class*='text-'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4",
|
| 131 |
+
className,
|
| 132 |
+
)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function NavigationMenuIndicator({
|
| 139 |
+
className,
|
| 140 |
+
...props
|
| 141 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
|
| 142 |
+
return (
|
| 143 |
+
<NavigationMenuPrimitive.Indicator
|
| 144 |
+
data-slot="navigation-menu-indicator"
|
| 145 |
+
className={cn(
|
| 146 |
+
'data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
| 147 |
+
className,
|
| 148 |
+
)}
|
| 149 |
+
{...props}
|
| 150 |
+
>
|
| 151 |
+
<div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
|
| 152 |
+
</NavigationMenuPrimitive.Indicator>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
export {
|
| 157 |
+
NavigationMenu,
|
| 158 |
+
NavigationMenuList,
|
| 159 |
+
NavigationMenuItem,
|
| 160 |
+
NavigationMenuContent,
|
| 161 |
+
NavigationMenuTrigger,
|
| 162 |
+
NavigationMenuLink,
|
| 163 |
+
NavigationMenuIndicator,
|
| 164 |
+
NavigationMenuViewport,
|
| 165 |
+
navigationMenuTriggerStyle,
|
| 166 |
+
}
|