Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +6 -0
- .gitattributes +1 -0
- Dockerfile +23 -0
- README.md +12 -4
- bun.lockb +3 -0
- components.json +20 -0
- eslint.config.js +26 -0
- index.html +24 -0
- nginx.conf +11 -0
- package-lock.json +0 -0
- package.json +83 -0
- postcss.config.js +6 -0
- public/favicon.ico +0 -0
- public/placeholder.svg +1 -0
- public/robots.txt +14 -0
- src/App.tsx +27 -0
- src/components/FileUploader.tsx +248 -0
- src/components/ResponseDisplay.tsx +213 -0
- src/components/ResponseHistory.tsx +141 -0
- src/components/ui/accordion.tsx +52 -0
- src/components/ui/alert-dialog.tsx +104 -0
- src/components/ui/alert.tsx +43 -0
- src/components/ui/aspect-ratio.tsx +5 -0
- src/components/ui/avatar.tsx +38 -0
- src/components/ui/badge.tsx +29 -0
- src/components/ui/breadcrumb.tsx +90 -0
- src/components/ui/button.tsx +48 -0
- src/components/ui/calendar.tsx +54 -0
- src/components/ui/card.tsx +43 -0
- src/components/ui/carousel.tsx +224 -0
- src/components/ui/chart.tsx +303 -0
- src/components/ui/checkbox.tsx +26 -0
- src/components/ui/collapsible.tsx +9 -0
- src/components/ui/command.tsx +132 -0
- src/components/ui/context-menu.tsx +178 -0
- src/components/ui/dialog.tsx +95 -0
- src/components/ui/drawer.tsx +87 -0
- src/components/ui/dropdown-menu.tsx +179 -0
- src/components/ui/form.tsx +129 -0
- src/components/ui/hover-card.tsx +27 -0
- src/components/ui/input-otp.tsx +61 -0
- src/components/ui/input.tsx +22 -0
- src/components/ui/label.tsx +17 -0
- src/components/ui/menubar.tsx +207 -0
- src/components/ui/navigation-menu.tsx +120 -0
- src/components/ui/pagination.tsx +81 -0
- src/components/ui/popover.tsx +29 -0
- src/components/ui/progress.tsx +23 -0
- src/components/ui/radio-group.tsx +36 -0
- src/components/ui/resizable.tsx +37 -0
.dockerignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
dist
|
| 3 |
+
.git
|
| 4 |
+
.gitignore
|
| 5 |
+
.DS_Store
|
| 6 |
+
README.md
|
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
bun.lockb filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:20-alpine AS build
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
ARG VITE_API_URL=https://jayvatliq-car-view-classifier.hf.space/api
|
| 6 |
+
ARG VITE_FILE_STORAGE_URL=https://jayvatliq-car-view-classifier.hf.space/files
|
| 7 |
+
ENV VITE_API_URL=$VITE_API_URL
|
| 8 |
+
ENV VITE_FILE_STORAGE_URL=$VITE_FILE_STORAGE_URL
|
| 9 |
+
|
| 10 |
+
COPY package.json package-lock.json ./
|
| 11 |
+
RUN npm ci
|
| 12 |
+
|
| 13 |
+
COPY . .
|
| 14 |
+
RUN npm run build
|
| 15 |
+
|
| 16 |
+
FROM nginx:alpine
|
| 17 |
+
|
| 18 |
+
COPY --from=build /app/dist /usr/share/nginx/html
|
| 19 |
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 20 |
+
|
| 21 |
+
EXPOSE 7860
|
| 22 |
+
|
| 23 |
+
CMD ["nginx", "-g", "daemon off;"]
|
README.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
---
|
| 2 |
title: Car View Classifier Frontend
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Car View Classifier Frontend
|
| 3 |
+
emoji: 🖼️
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Car View Classifier — Frontend
|
| 12 |
+
|
| 13 |
+
Vite + React upload UI for the
|
| 14 |
+
[car-view-classifier backend Space](https://huggingface.co/spaces/jayvatliq/car-view-classifier).
|
| 15 |
+
|
| 16 |
+
Built with `npm run build`, served by nginx on port 80. Backend URL is
|
| 17 |
+
baked in at build time via `VITE_API_URL` / `VITE_FILE_STORAGE_URL`
|
| 18 |
+
Docker build args (defaults point at the backend Space).
|
bun.lockb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:570b2bffe5052345e4a55eddc0077d6cef9b44f618123e9d746f4230bab0f298
|
| 3 |
+
size 197327
|
components.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "default",
|
| 4 |
+
"rsc": false,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "tailwind.config.ts",
|
| 8 |
+
"css": "src/index.css",
|
| 9 |
+
"baseColor": "slate",
|
| 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 |
+
}
|
eslint.config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import js from "@eslint/js";
|
| 2 |
+
import globals from "globals";
|
| 3 |
+
import reactHooks from "eslint-plugin-react-hooks";
|
| 4 |
+
import reactRefresh from "eslint-plugin-react-refresh";
|
| 5 |
+
import tseslint from "typescript-eslint";
|
| 6 |
+
|
| 7 |
+
export default tseslint.config(
|
| 8 |
+
{ ignores: ["dist"] },
|
| 9 |
+
{
|
| 10 |
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
| 11 |
+
files: ["**/*.{ts,tsx}"],
|
| 12 |
+
languageOptions: {
|
| 13 |
+
ecmaVersion: 2020,
|
| 14 |
+
globals: globals.browser,
|
| 15 |
+
},
|
| 16 |
+
plugins: {
|
| 17 |
+
"react-hooks": reactHooks,
|
| 18 |
+
"react-refresh": reactRefresh,
|
| 19 |
+
},
|
| 20 |
+
rules: {
|
| 21 |
+
...reactHooks.configs.recommended.rules,
|
| 22 |
+
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
| 23 |
+
"@typescript-eslint/no-unused-vars": "off",
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
);
|
index.html
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>AutoView Analyzer - Car View Classification</title>
|
| 7 |
+
<meta name="description" content="Advanced AI-powered car view classification with real-time detection and perspective analysis" />
|
| 8 |
+
<meta name="author" content="Lovable" />
|
| 9 |
+
|
| 10 |
+
<meta property="og:title" content="AutoView Analyzer - Car View Classification" />
|
| 11 |
+
<meta property="og:description" content="AI-powered car image analysis and view classification system" />
|
| 12 |
+
<meta property="og:type" content="website" />
|
| 13 |
+
<meta property="og:image" content="https://lovable.dev/opengraph-image-p98pqg.png" />
|
| 14 |
+
|
| 15 |
+
<meta name="twitter:card" content="summary_large_image" />
|
| 16 |
+
<meta name="twitter:site" content="@lovable_dev" />
|
| 17 |
+
<meta name="twitter:image" content="https://lovable.dev/opengraph-image-p98pqg.png" />
|
| 18 |
+
</head>
|
| 19 |
+
|
| 20 |
+
<body>
|
| 21 |
+
<div id="root"></div>
|
| 22 |
+
<script type="module" src="/src/main.tsx"></script>
|
| 23 |
+
</body>
|
| 24 |
+
</html>
|
nginx.conf
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 7860;
|
| 3 |
+
server_name _;
|
| 4 |
+
|
| 5 |
+
root /usr/share/nginx/html;
|
| 6 |
+
index index.html;
|
| 7 |
+
|
| 8 |
+
location / {
|
| 9 |
+
try_files $uri $uri/ /index.html;
|
| 10 |
+
}
|
| 11 |
+
}
|
package-lock.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "vite_react_shadcn_ts",
|
| 3 |
+
"private": true,
|
| 4 |
+
"version": "0.0.0",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite",
|
| 8 |
+
"build": "vite build",
|
| 9 |
+
"build:dev": "vite build --mode development",
|
| 10 |
+
"lint": "eslint .",
|
| 11 |
+
"preview": "vite preview"
|
| 12 |
+
},
|
| 13 |
+
"dependencies": {
|
| 14 |
+
"@hookform/resolvers": "^3.10.0",
|
| 15 |
+
"@radix-ui/react-accordion": "^1.2.11",
|
| 16 |
+
"@radix-ui/react-alert-dialog": "^1.1.14",
|
| 17 |
+
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
| 18 |
+
"@radix-ui/react-avatar": "^1.1.10",
|
| 19 |
+
"@radix-ui/react-checkbox": "^1.3.2",
|
| 20 |
+
"@radix-ui/react-collapsible": "^1.1.11",
|
| 21 |
+
"@radix-ui/react-context-menu": "^2.2.15",
|
| 22 |
+
"@radix-ui/react-dialog": "^1.1.14",
|
| 23 |
+
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
| 24 |
+
"@radix-ui/react-hover-card": "^1.1.14",
|
| 25 |
+
"@radix-ui/react-label": "^2.1.7",
|
| 26 |
+
"@radix-ui/react-menubar": "^1.1.15",
|
| 27 |
+
"@radix-ui/react-navigation-menu": "^1.2.13",
|
| 28 |
+
"@radix-ui/react-popover": "^1.1.14",
|
| 29 |
+
"@radix-ui/react-progress": "^1.1.7",
|
| 30 |
+
"@radix-ui/react-radio-group": "^1.3.7",
|
| 31 |
+
"@radix-ui/react-scroll-area": "^1.2.9",
|
| 32 |
+
"@radix-ui/react-select": "^2.2.5",
|
| 33 |
+
"@radix-ui/react-separator": "^1.1.7",
|
| 34 |
+
"@radix-ui/react-slider": "^1.3.5",
|
| 35 |
+
"@radix-ui/react-slot": "^1.2.3",
|
| 36 |
+
"@radix-ui/react-switch": "^1.2.5",
|
| 37 |
+
"@radix-ui/react-tabs": "^1.1.12",
|
| 38 |
+
"@radix-ui/react-toast": "^1.2.14",
|
| 39 |
+
"@radix-ui/react-toggle": "^1.1.9",
|
| 40 |
+
"@radix-ui/react-toggle-group": "^1.1.10",
|
| 41 |
+
"@radix-ui/react-tooltip": "^1.2.7",
|
| 42 |
+
"@tanstack/react-query": "^5.83.0",
|
| 43 |
+
"class-variance-authority": "^0.7.1",
|
| 44 |
+
"clsx": "^2.1.1",
|
| 45 |
+
"cmdk": "^1.1.1",
|
| 46 |
+
"date-fns": "^3.6.0",
|
| 47 |
+
"embla-carousel-react": "^8.6.0",
|
| 48 |
+
"input-otp": "^1.4.2",
|
| 49 |
+
"lucide-react": "^0.462.0",
|
| 50 |
+
"next-themes": "^0.3.0",
|
| 51 |
+
"react": "^18.3.1",
|
| 52 |
+
"react-day-picker": "^8.10.1",
|
| 53 |
+
"react-dom": "^18.3.1",
|
| 54 |
+
"react-hook-form": "^7.61.1",
|
| 55 |
+
"react-resizable-panels": "^2.1.9",
|
| 56 |
+
"react-router-dom": "^6.30.1",
|
| 57 |
+
"recharts": "^2.15.4",
|
| 58 |
+
"sonner": "^1.7.4",
|
| 59 |
+
"tailwind-merge": "^2.6.0",
|
| 60 |
+
"tailwindcss-animate": "^1.0.7",
|
| 61 |
+
"vaul": "^0.9.9",
|
| 62 |
+
"zod": "^3.25.76"
|
| 63 |
+
},
|
| 64 |
+
"devDependencies": {
|
| 65 |
+
"@eslint/js": "^9.32.0",
|
| 66 |
+
"@tailwindcss/typography": "^0.5.16",
|
| 67 |
+
"@types/node": "^22.16.5",
|
| 68 |
+
"@types/react": "^18.3.23",
|
| 69 |
+
"@types/react-dom": "^18.3.7",
|
| 70 |
+
"@vitejs/plugin-react-swc": "^3.11.0",
|
| 71 |
+
"autoprefixer": "^10.4.21",
|
| 72 |
+
"eslint": "^9.32.0",
|
| 73 |
+
"eslint-plugin-react-hooks": "^5.2.0",
|
| 74 |
+
"eslint-plugin-react-refresh": "^0.4.20",
|
| 75 |
+
"globals": "^15.15.0",
|
| 76 |
+
"lovable-tagger": "^1.1.9",
|
| 77 |
+
"postcss": "^8.5.6",
|
| 78 |
+
"tailwindcss": "^3.4.17",
|
| 79 |
+
"typescript": "^5.8.3",
|
| 80 |
+
"typescript-eslint": "^8.38.0",
|
| 81 |
+
"vite": "^5.4.19"
|
| 82 |
+
}
|
| 83 |
+
}
|
postcss.config.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default {
|
| 2 |
+
plugins: {
|
| 3 |
+
tailwindcss: {},
|
| 4 |
+
autoprefixer: {},
|
| 5 |
+
},
|
| 6 |
+
};
|
public/favicon.ico
ADDED
|
|
public/placeholder.svg
ADDED
|
|
public/robots.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
User-agent: Googlebot
|
| 2 |
+
Allow: /
|
| 3 |
+
|
| 4 |
+
User-agent: Bingbot
|
| 5 |
+
Allow: /
|
| 6 |
+
|
| 7 |
+
User-agent: Twitterbot
|
| 8 |
+
Allow: /
|
| 9 |
+
|
| 10 |
+
User-agent: facebookexternalhit
|
| 11 |
+
Allow: /
|
| 12 |
+
|
| 13 |
+
User-agent: *
|
| 14 |
+
Allow: /
|
src/App.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Toaster } from "@/components/ui/toaster";
|
| 2 |
+
import { Toaster as Sonner } from "@/components/ui/sonner";
|
| 3 |
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
| 4 |
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
| 5 |
+
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
| 6 |
+
import Index from "./pages/Index";
|
| 7 |
+
import NotFound from "./pages/NotFound";
|
| 8 |
+
|
| 9 |
+
const queryClient = new QueryClient();
|
| 10 |
+
|
| 11 |
+
const App = () => (
|
| 12 |
+
<QueryClientProvider client={queryClient}>
|
| 13 |
+
<TooltipProvider>
|
| 14 |
+
<Toaster />
|
| 15 |
+
<Sonner />
|
| 16 |
+
<BrowserRouter>
|
| 17 |
+
<Routes>
|
| 18 |
+
<Route path="/" element={<Index />} />
|
| 19 |
+
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
| 20 |
+
<Route path="*" element={<NotFound />} />
|
| 21 |
+
</Routes>
|
| 22 |
+
</BrowserRouter>
|
| 23 |
+
</TooltipProvider>
|
| 24 |
+
</QueryClientProvider>
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
export default App;
|
src/components/FileUploader.tsx
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useCallback, useRef } from 'react';
|
| 2 |
+
import { Upload, X, Loader2, Image, FileImage, Car } from 'lucide-react';
|
| 3 |
+
import { Button } from '@/components/ui/button';
|
| 4 |
+
import { Card } from '@/components/ui/card';
|
| 5 |
+
import { UploadedFile } from '@/types';
|
| 6 |
+
import { cn } from '@/lib/utils';
|
| 7 |
+
import { uuid } from '@/utils/uuid';
|
| 8 |
+
|
| 9 |
+
interface FileUploaderProps {
|
| 10 |
+
onUpload: (files: File[]) => Promise<void>;
|
| 11 |
+
isUploading: boolean;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export const FileUploader = ({ onUpload, isUploading }: FileUploaderProps) => {
|
| 15 |
+
const [files, setFiles] = useState<UploadedFile[]>([]);
|
| 16 |
+
const [dragActive, setDragActive] = useState(false);
|
| 17 |
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
| 18 |
+
|
| 19 |
+
const handleFiles = useCallback((fileList: FileList) => {
|
| 20 |
+
const validFiles = Array.from(fileList).filter(file =>
|
| 21 |
+
file.type.startsWith('image/')
|
| 22 |
+
);
|
| 23 |
+
|
| 24 |
+
const newFiles: UploadedFile[] = validFiles.map(file => ({
|
| 25 |
+
file,
|
| 26 |
+
id: uuid(),
|
| 27 |
+
preview: URL.createObjectURL(file),
|
| 28 |
+
}));
|
| 29 |
+
|
| 30 |
+
setFiles(prev => [...prev, ...newFiles]);
|
| 31 |
+
}, []);
|
| 32 |
+
|
| 33 |
+
const removeFile = useCallback((id: string) => {
|
| 34 |
+
setFiles(prev => {
|
| 35 |
+
const updated = prev.filter(f => f.id !== id);
|
| 36 |
+
// Clean up object URLs
|
| 37 |
+
const removed = prev.find(f => f.id === id);
|
| 38 |
+
if (removed?.preview) {
|
| 39 |
+
URL.revokeObjectURL(removed.preview);
|
| 40 |
+
}
|
| 41 |
+
return updated;
|
| 42 |
+
});
|
| 43 |
+
}, []);
|
| 44 |
+
|
| 45 |
+
const handleDrag = useCallback((e: React.DragEvent) => {
|
| 46 |
+
e.preventDefault();
|
| 47 |
+
e.stopPropagation();
|
| 48 |
+
}, []);
|
| 49 |
+
|
| 50 |
+
const handleDragIn = useCallback((e: React.DragEvent) => {
|
| 51 |
+
e.preventDefault();
|
| 52 |
+
e.stopPropagation();
|
| 53 |
+
if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
|
| 54 |
+
setDragActive(true);
|
| 55 |
+
}
|
| 56 |
+
}, []);
|
| 57 |
+
|
| 58 |
+
const handleDragOut = useCallback((e: React.DragEvent) => {
|
| 59 |
+
e.preventDefault();
|
| 60 |
+
e.stopPropagation();
|
| 61 |
+
setDragActive(false);
|
| 62 |
+
}, []);
|
| 63 |
+
|
| 64 |
+
const handleDrop = useCallback((e: React.DragEvent) => {
|
| 65 |
+
e.preventDefault();
|
| 66 |
+
e.stopPropagation();
|
| 67 |
+
setDragActive(false);
|
| 68 |
+
|
| 69 |
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
| 70 |
+
handleFiles(e.dataTransfer.files);
|
| 71 |
+
}
|
| 72 |
+
}, [handleFiles]);
|
| 73 |
+
|
| 74 |
+
const handleFileSelect = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
| 75 |
+
if (e.target.files && e.target.files.length > 0) {
|
| 76 |
+
handleFiles(e.target.files);
|
| 77 |
+
}
|
| 78 |
+
}, [handleFiles]);
|
| 79 |
+
|
| 80 |
+
const handleUpload = async () => {
|
| 81 |
+
if (files.length > 0) {
|
| 82 |
+
await onUpload(files.map(f => f.file));
|
| 83 |
+
// Clear files after successful upload
|
| 84 |
+
files.forEach(f => {
|
| 85 |
+
if (f.preview) URL.revokeObjectURL(f.preview);
|
| 86 |
+
});
|
| 87 |
+
setFiles([]);
|
| 88 |
+
}
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
return (
|
| 92 |
+
<Card className="p-8 shadow-lg border-border/50 bg-gradient-to-br from-card to-card/50">
|
| 93 |
+
<div className="space-y-8">
|
| 94 |
+
{/* Drop Zone */}
|
| 95 |
+
<div
|
| 96 |
+
className={cn(
|
| 97 |
+
"border-2 border-dashed rounded-xl p-16 transition-all duration-300 cursor-pointer",
|
| 98 |
+
"bg-gradient-accent hover:bg-secondary/30 backdrop-blur-sm",
|
| 99 |
+
"relative overflow-hidden group",
|
| 100 |
+
dragActive
|
| 101 |
+
? "border-primary/60 bg-primary/5 shadow-glow scale-[1.02]"
|
| 102 |
+
: "border-border/40 hover:border-primary/30 hover:shadow-md"
|
| 103 |
+
)}
|
| 104 |
+
onDragEnter={handleDragIn}
|
| 105 |
+
onDragLeave={handleDragOut}
|
| 106 |
+
onDragOver={handleDrag}
|
| 107 |
+
onDrop={handleDrop}
|
| 108 |
+
onClick={() => fileInputRef.current?.click()}
|
| 109 |
+
>
|
| 110 |
+
{/* Background Pattern */}
|
| 111 |
+
<div className="absolute inset-0 bg-gradient-to-br from-primary/5 via-transparent to-accent/5 opacity-50" />
|
| 112 |
+
|
| 113 |
+
<div className="flex flex-col items-center justify-center space-y-6 text-center relative z-10">
|
| 114 |
+
<div className={cn(
|
| 115 |
+
"w-20 h-20 rounded-full bg-gradient-primary/20 flex items-center justify-center",
|
| 116 |
+
"transition-all duration-300 group-hover:scale-110 group-hover:shadow-glow",
|
| 117 |
+
dragActive && "scale-125 shadow-glow-strong"
|
| 118 |
+
)}>
|
| 119 |
+
<Upload className={cn(
|
| 120 |
+
"w-10 h-10 text-primary transition-all duration-300",
|
| 121 |
+
dragActive && "scale-125 text-accent-foreground animate-bounce"
|
| 122 |
+
)} />
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
<div className="space-y-3">
|
| 126 |
+
<h3 className="text-2xl font-bold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
| 127 |
+
{dragActive ? "Drop Car Images Here" : "Upload Your Car Images"}
|
| 128 |
+
</h3>
|
| 129 |
+
<p className="text-muted-foreground text-lg">
|
| 130 |
+
Drag & drop car images here, or{" "}
|
| 131 |
+
<span className="text-primary font-medium">click to browse</span>
|
| 132 |
+
</p>
|
| 133 |
+
<div className="flex items-center justify-center space-x-4 text-sm text-muted-foreground">
|
| 134 |
+
<div className="flex items-center space-x-1">
|
| 135 |
+
<FileImage className="w-4 h-4" />
|
| 136 |
+
<span>JPG, PNG, GIF, WEBP</span>
|
| 137 |
+
</div>
|
| 138 |
+
<div className="w-1 h-1 bg-muted-foreground rounded-full" />
|
| 139 |
+
<span>Multiple files supported</span>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
|
| 144 |
+
<input
|
| 145 |
+
ref={fileInputRef}
|
| 146 |
+
type="file"
|
| 147 |
+
multiple
|
| 148 |
+
accept="image/*"
|
| 149 |
+
onChange={handleFileSelect}
|
| 150 |
+
className="hidden"
|
| 151 |
+
/>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
{/* Selected Files Grid */}
|
| 155 |
+
{files.length > 0 && (
|
| 156 |
+
<div className="space-y-6 animate-in slide-in-from-bottom-4 duration-300">
|
| 157 |
+
<div className="flex items-center justify-between">
|
| 158 |
+
<h4 className="text-lg font-semibold text-foreground">
|
| 159 |
+
Selected Car Images
|
| 160 |
+
</h4>
|
| 161 |
+
<div className="px-3 py-1 bg-primary/20 text-primary text-sm font-medium rounded-full">
|
| 162 |
+
{files.length} car {files.length === 1 ? 'image' : 'images'}
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4">
|
| 167 |
+
{files.map((file, index) => (
|
| 168 |
+
<div
|
| 169 |
+
key={file.id}
|
| 170 |
+
className="relative group animate-in fade-in-0 zoom-in-95 duration-300"
|
| 171 |
+
style={{ animationDelay: `${index * 50}ms` }}
|
| 172 |
+
>
|
| 173 |
+
<Card className="aspect-square overflow-hidden bg-secondary/50 border-border/50 transition-all duration-300 hover:shadow-lg hover:scale-[1.02] hover:border-primary/30">
|
| 174 |
+
{file.preview && (
|
| 175 |
+
<img
|
| 176 |
+
src={file.preview}
|
| 177 |
+
alt={file.file.name}
|
| 178 |
+
className="w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"
|
| 179 |
+
/>
|
| 180 |
+
)}
|
| 181 |
+
|
| 182 |
+
{/* Overlay */}
|
| 183 |
+
<div className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-all duration-300">
|
| 184 |
+
<div className="absolute bottom-2 left-2 right-2">
|
| 185 |
+
<p className="text-white text-xs font-medium truncate">
|
| 186 |
+
{file.file.name}
|
| 187 |
+
</p>
|
| 188 |
+
<p className="text-white/70 text-xs">
|
| 189 |
+
{(file.file.size / 1024 / 1024).toFixed(1)} MB
|
| 190 |
+
</p>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
+
</Card>
|
| 194 |
+
|
| 195 |
+
{/* Remove Button */}
|
| 196 |
+
<Button
|
| 197 |
+
onClick={() => removeFile(file.id)}
|
| 198 |
+
size="icon"
|
| 199 |
+
variant="destructive"
|
| 200 |
+
className={cn(
|
| 201 |
+
"absolute -top-2 -right-2 w-7 h-7 rounded-full shadow-lg",
|
| 202 |
+
"opacity-0 group-hover:opacity-100 transition-all duration-200",
|
| 203 |
+
"hover:scale-110 active:scale-95"
|
| 204 |
+
)}
|
| 205 |
+
>
|
| 206 |
+
<X className="w-3 h-3" />
|
| 207 |
+
</Button>
|
| 208 |
+
</div>
|
| 209 |
+
))}
|
| 210 |
+
</div>
|
| 211 |
+
</div>
|
| 212 |
+
)}
|
| 213 |
+
|
| 214 |
+
{/* Upload Button */}
|
| 215 |
+
<Button
|
| 216 |
+
onClick={handleUpload}
|
| 217 |
+
disabled={files.length === 0 || isUploading}
|
| 218 |
+
size="lg"
|
| 219 |
+
className={cn(
|
| 220 |
+
"w-full relative overflow-hidden",
|
| 221 |
+
isUploading && "animate-pulse"
|
| 222 |
+
)}
|
| 223 |
+
>
|
| 224 |
+
<div className="flex items-center justify-center space-x-2">
|
| 225 |
+
{isUploading ? (
|
| 226 |
+
<>
|
| 227 |
+
<Loader2 className="w-5 h-5 animate-spin" />
|
| 228 |
+
<span>Classifying {files.length} car {files.length === 1 ? 'image' : 'images'}...</span>
|
| 229 |
+
</>
|
| 230 |
+
) : (
|
| 231 |
+
<>
|
| 232 |
+
<Car className="w-5 h-5" />
|
| 233 |
+
<span>
|
| 234 |
+
Analyze Car Views {files.length > 0 ? `(${files.length} image${files.length !== 1 ? 's' : ''})` : ''}
|
| 235 |
+
</span>
|
| 236 |
+
</>
|
| 237 |
+
)}
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
+
{/* Button shine effect */}
|
| 241 |
+
{!isUploading && files.length > 0 && (
|
| 242 |
+
<div className="absolute inset-0 -top-[1px] bg-gradient-to-r from-transparent via-white/20 to-transparent opacity-0 group-hover:opacity-100 transform -skew-x-12 transition-all duration-1000 translate-x-[-100%] group-hover:translate-x-[100%]" />
|
| 243 |
+
)}
|
| 244 |
+
</Button>
|
| 245 |
+
</div>
|
| 246 |
+
</Card>
|
| 247 |
+
);
|
| 248 |
+
};
|
src/components/ResponseDisplay.tsx
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
| 2 |
+
import { ExternalLink, Calendar, Image as ImageIcon, Eye, Database, CheckCircle2 } from "lucide-react";
|
| 3 |
+
import { Card } from "@/components/ui/card";
|
| 4 |
+
import { Badge } from "@/components/ui/badge";
|
| 5 |
+
import { Button } from "@/components/ui/button";
|
| 6 |
+
import { ApiResponse } from "@/types";
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
import { getUrl } from "@/utils/constants";
|
| 9 |
+
|
| 10 |
+
interface ResponseDisplayProps {
|
| 11 |
+
response: ApiResponse;
|
| 12 |
+
className?: string;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export const ResponseDisplay = ({
|
| 16 |
+
response,
|
| 17 |
+
className,
|
| 18 |
+
}: ResponseDisplayProps) => {
|
| 19 |
+
const imgUrls =
|
| 20 |
+
(!response.error && [
|
| 21 |
+
{ img: response.file_details.main_img_name, type: "Original Upload", icon: ImageIcon },
|
| 22 |
+
{ img: response.file_details.car_detection, type: "Car Detection", icon: Eye },
|
| 23 |
+
{ img: response.file_details.part_detection, type: "Part Detection", icon: Database },
|
| 24 |
+
]) ||
|
| 25 |
+
[];
|
| 26 |
+
|
| 27 |
+
const data =
|
| 28 |
+
(!response.error &&
|
| 29 |
+
response.rule_based_view_type.map((item, i) => ({
|
| 30 |
+
view: item,
|
| 31 |
+
score: response.final_scores[i],
|
| 32 |
+
}))) ||
|
| 33 |
+
[];
|
| 34 |
+
|
| 35 |
+
const formatTimestamp = (timestamp: number) => {
|
| 36 |
+
return new Date(timestamp).toLocaleString('en-US', {
|
| 37 |
+
month: 'short',
|
| 38 |
+
day: 'numeric',
|
| 39 |
+
year: 'numeric',
|
| 40 |
+
hour: '2-digit',
|
| 41 |
+
minute: '2-digit',
|
| 42 |
+
});
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
const renderDetectedViews = (
|
| 46 |
+
data: {
|
| 47 |
+
view: any;
|
| 48 |
+
score: any;
|
| 49 |
+
}[]
|
| 50 |
+
) => {
|
| 51 |
+
if (!data || Object.keys(data).length === 0) {
|
| 52 |
+
return (
|
| 53 |
+
<div className="flex items-center justify-center py-8">
|
| 54 |
+
<div className="text-center space-y-2">
|
| 55 |
+
<Database className="w-8 h-8 text-muted-foreground mx-auto" />
|
| 56 |
+
<p className="text-muted-foreground text-sm">No car view classification data available</p>
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return (
|
| 63 |
+
<div className="grid gap-3">
|
| 64 |
+
{data.map((each, key) => {
|
| 65 |
+
return (
|
| 66 |
+
<Card key={key} className="p-4 bg-secondary/50 border-border hover:bg-secondary hover:shadow-md transition-all duration-200">
|
| 67 |
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
| 68 |
+
<div className="flex items-center space-x-3">
|
| 69 |
+
<div className="w-2 h-2 bg-primary rounded-full animate-pulse" />
|
| 70 |
+
<span className="font-medium text-foreground">
|
| 71 |
+
{each.view}
|
| 72 |
+
</span>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div className="flex items-center space-x-2">
|
| 76 |
+
<Badge variant="outline" className="font-mono text-xs">
|
| 77 |
+
Score: {each.score}
|
| 78 |
+
</Badge>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
</Card>
|
| 82 |
+
);
|
| 83 |
+
})}
|
| 84 |
+
</div>
|
| 85 |
+
);
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
return (
|
| 89 |
+
<Card
|
| 90 |
+
className={cn(
|
| 91 |
+
"p-6 space-y-6 bg-gradient-to-br from-card to-secondary/30 border-border",
|
| 92 |
+
"hover:shadow-xl hover:border-primary/30 transition-all duration-300",
|
| 93 |
+
"animate-in fade-in-0 slide-in-from-bottom-4",
|
| 94 |
+
className
|
| 95 |
+
)}
|
| 96 |
+
>
|
| 97 |
+
{/* Header */}
|
| 98 |
+
<div className="flex items-start justify-between">
|
| 99 |
+
<div className="flex items-center space-x-3">
|
| 100 |
+
<div className={cn(
|
| 101 |
+
"w-3 h-3 rounded-full animate-pulse",
|
| 102 |
+
!response.error ? "bg-emerald-500" : "bg-red-500"
|
| 103 |
+
)} />
|
| 104 |
+
<Badge
|
| 105 |
+
variant={!response.error ? "default" : "destructive"}
|
| 106 |
+
className={cn(
|
| 107 |
+
"text-xs font-medium px-3 py-1",
|
| 108 |
+
!response.error && "bg-gradient-success"
|
| 109 |
+
)}
|
| 110 |
+
>
|
| 111 |
+
<CheckCircle2 className="w-3 h-3 mr-1" />
|
| 112 |
+
{!response.error ? "View Classification Complete" : "Classification Failed"}
|
| 113 |
+
</Badge>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<div className="flex items-center text-xs text-muted-foreground space-x-2">
|
| 117 |
+
<Calendar className="w-3 h-3" />
|
| 118 |
+
<span>{formatTimestamp(response.timestamp)}</span>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
{/* Images Section */}
|
| 123 |
+
{(imgUrls && imgUrls.length > 0 && !response.error && (
|
| 124 |
+
<div className="space-y-4">
|
| 125 |
+
<div className="flex items-center space-x-2">
|
| 126 |
+
<ImageIcon className="w-4 h-4 text-primary" />
|
| 127 |
+
<h4 className="font-semibold text-foreground">Car View Analysis Results</h4>
|
| 128 |
+
</div>
|
| 129 |
+
|
| 130 |
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 131 |
+
{imgUrls.map((url, index) => {
|
| 132 |
+
const IconComponent = url.icon;
|
| 133 |
+
return (
|
| 134 |
+
<div key={index} className="group space-y-3">
|
| 135 |
+
<div className="flex items-center space-x-2 text-sm text-muted-foreground">
|
| 136 |
+
<IconComponent className="w-4 h-4" />
|
| 137 |
+
<span className="font-medium">{url.type}</span>
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<Card className="relative overflow-hidden bg-card border-border hover:shadow-lg transition-all duration-300 group-hover:scale-105 cursor-pointer">
|
| 141 |
+
<a
|
| 142 |
+
href={getUrl(url.img)}
|
| 143 |
+
target="_blank"
|
| 144 |
+
rel="noopener noreferrer"
|
| 145 |
+
className="block aspect-square"
|
| 146 |
+
>
|
| 147 |
+
<img
|
| 148 |
+
src={getUrl(url.img)}
|
| 149 |
+
alt={`${url.type} result`}
|
| 150 |
+
className="w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"
|
| 151 |
+
onError={(e) => {
|
| 152 |
+
e.currentTarget.src = "/placeholder.svg";
|
| 153 |
+
}}
|
| 154 |
+
/>
|
| 155 |
+
</a>
|
| 156 |
+
|
| 157 |
+
{/* Visual Cue - Magnifying Glass */}
|
| 158 |
+
{/* <div className="absolute top-3 right-3 w-8 h-8 bg-white/90 rounded-full flex items-center justify-center shadow-md opacity-0 group-hover:opacity-100 transition-all duration-300 pointer-events-none">
|
| 159 |
+
<Eye className="w-4 h-4 text-primary" />
|
| 160 |
+
</div> */}
|
| 161 |
+
|
| 162 |
+
{/* Overlay with External Link Button */}
|
| 163 |
+
<div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-all duration-300">
|
| 164 |
+
<Button
|
| 165 |
+
asChild
|
| 166 |
+
size="sm"
|
| 167 |
+
variant="secondary"
|
| 168 |
+
className="absolute bottom-3 right-3 opacity-0 group-hover:opacity-100 transition-all duration-300 bg-white/90 hover:bg-white text-primary border-0"
|
| 169 |
+
>
|
| 170 |
+
<a
|
| 171 |
+
href={getUrl(url.img)}
|
| 172 |
+
target="_blank"
|
| 173 |
+
rel="noopener noreferrer"
|
| 174 |
+
onClick={(e) => e.stopPropagation()}
|
| 175 |
+
>
|
| 176 |
+
<ExternalLink className="w-4 h-4" />
|
| 177 |
+
</a>
|
| 178 |
+
</Button>
|
| 179 |
+
</div>
|
| 180 |
+
</Card>
|
| 181 |
+
</div>
|
| 182 |
+
);
|
| 183 |
+
})}
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
)) || (
|
| 187 |
+
<div className="flex items-center justify-center py-12">
|
| 188 |
+
<div className="text-center space-y-3">
|
| 189 |
+
<div className="w-16 h-16 rounded-full bg-muted/20 flex items-center justify-center mx-auto">
|
| 190 |
+
<ImageIcon className="w-8 h-8 text-muted-foreground" />
|
| 191 |
+
</div>
|
| 192 |
+
<div>
|
| 193 |
+
<h4 className="font-medium text-foreground mb-1">No Analysis Images Available</h4>
|
| 194 |
+
<p className="text-muted-foreground text-sm">
|
| 195 |
+
Car view classification failed or no detection images were generated
|
| 196 |
+
</p>
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
)}
|
| 201 |
+
|
| 202 |
+
{/* Detection Results */}
|
| 203 |
+
<div className="space-y-4">
|
| 204 |
+
<div className="flex items-center space-x-2">
|
| 205 |
+
<Database className="w-4 h-4 text-primary" />
|
| 206 |
+
<h4 className="font-semibold text-foreground">Car View Classification</h4>
|
| 207 |
+
</div>
|
| 208 |
+
|
| 209 |
+
{renderDetectedViews(data)}
|
| 210 |
+
</div>
|
| 211 |
+
</Card>
|
| 212 |
+
);
|
| 213 |
+
};
|
src/components/ResponseHistory.tsx
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Trash2, History, Database, RotateCcw } from 'lucide-react';
|
| 2 |
+
import { Button } from '@/components/ui/button';
|
| 3 |
+
import { Card } from '@/components/ui/card';
|
| 4 |
+
import { ResponseDisplay } from './ResponseDisplay';
|
| 5 |
+
import { ApiResponse } from '@/types';
|
| 6 |
+
import { clearStoredResponses } from '@/utils/storage';
|
| 7 |
+
import { useToast } from '@/hooks/use-toast';
|
| 8 |
+
import { cn } from '@/lib/utils';
|
| 9 |
+
|
| 10 |
+
interface ResponseHistoryProps {
|
| 11 |
+
responses: ApiResponse[];
|
| 12 |
+
onClear: () => void;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export const ResponseHistory = ({ responses, onClear }: ResponseHistoryProps) => {
|
| 16 |
+
const { toast } = useToast();
|
| 17 |
+
|
| 18 |
+
const handleClear = () => {
|
| 19 |
+
try {
|
| 20 |
+
clearStoredResponses();
|
| 21 |
+
onClear();
|
| 22 |
+
toast({
|
| 23 |
+
title: "Classification history cleared",
|
| 24 |
+
description: "All car view analysis history has been removed from storage.",
|
| 25 |
+
});
|
| 26 |
+
} catch (error) {
|
| 27 |
+
toast({
|
| 28 |
+
title: "Error clearing history",
|
| 29 |
+
description: "Failed to clear history. Please try again.",
|
| 30 |
+
variant: "destructive",
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
if (responses.length === 0) {
|
| 36 |
+
return (
|
| 37 |
+
<Card className="relative overflow-hidden bg-gradient-to-br from-card to-secondary/30 border-border shadow-sm">
|
| 38 |
+
{/* Background Pattern */}
|
| 39 |
+
<div className="absolute inset-0 bg-gradient-accent opacity-20" />
|
| 40 |
+
|
| 41 |
+
<div className="relative p-12 text-center">
|
| 42 |
+
<div className="flex flex-col items-center space-y-6">
|
| 43 |
+
<div className="relative">
|
| 44 |
+
<div className="w-20 h-20 rounded-full bg-gradient-accent flex items-center justify-center shadow-lg">
|
| 45 |
+
<Database className="w-10 h-10 text-primary" />
|
| 46 |
+
</div>
|
| 47 |
+
<div className="absolute -top-1 -right-1 w-6 h-6 bg-primary/20 rounded-full animate-pulse" />
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<div className="space-y-3">
|
| 51 |
+
<h3 className="text-2xl font-bold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
| 52 |
+
No Classification History Yet
|
| 53 |
+
</h3>
|
| 54 |
+
<p className="text-muted-foreground text-lg max-w-md">
|
| 55 |
+
Upload some car images to start building your view classification history.
|
| 56 |
+
All analysis results will appear here for easy access.
|
| 57 |
+
</p>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<div className="flex items-center space-x-2 text-sm text-muted-foreground">
|
| 61 |
+
<div className="w-2 h-2 bg-primary rounded-full animate-pulse" />
|
| 62 |
+
<span>Waiting for your first car image classification...</span>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
</Card>
|
| 67 |
+
);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
return (
|
| 71 |
+
<div className="space-y-8">
|
| 72 |
+
{/* Header Card */}
|
| 73 |
+
<Card className="p-6 bg-gradient-to-r from-card to-secondary/30 border-border shadow-md">
|
| 74 |
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-6">
|
| 75 |
+
<div className="flex items-center space-x-4">
|
| 76 |
+
<div className="relative">
|
| 77 |
+
<div className="w-12 h-12 rounded-full bg-gradient-accent/30 flex items-center justify-center shadow-sm">
|
| 78 |
+
<History className="w-6 h-6 text-primary" />
|
| 79 |
+
</div>
|
| 80 |
+
<div className="absolute -top-1 -right-1 w-4 h-4 bg-primary rounded-full flex items-center justify-center shadow-sm">
|
| 81 |
+
<span className="text-xs font-bold text-primary-foreground">
|
| 82 |
+
{responses.length > 99 ? '99+' : responses.length}
|
| 83 |
+
</span>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<div>
|
| 88 |
+
<h2 className="text-2xl font-bold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
| 89 |
+
Classification History
|
| 90 |
+
</h2>
|
| 91 |
+
<p className="text-muted-foreground">
|
| 92 |
+
{responses.length} car view analysis{responses.length !== 1 ? ' results' : ' result'} stored locally
|
| 93 |
+
</p>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<Button
|
| 98 |
+
onClick={handleClear}
|
| 99 |
+
variant="outline"
|
| 100 |
+
size="sm"
|
| 101 |
+
className={cn(
|
| 102 |
+
"group border-destructive/50 text-destructive hover:bg-destructive hover:text-destructive-foreground",
|
| 103 |
+
"transition-all duration-300 hover:shadow-lg hover:scale-105"
|
| 104 |
+
)}
|
| 105 |
+
>
|
| 106 |
+
<RotateCcw className="w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-300" />
|
| 107 |
+
Clear All History
|
| 108 |
+
</Button>
|
| 109 |
+
</div>
|
| 110 |
+
</Card>
|
| 111 |
+
|
| 112 |
+
{/* Floating Clear Button for Mobile */}
|
| 113 |
+
<div className="fixed bottom-6 right-6 z-50 sm:hidden">
|
| 114 |
+
<Button
|
| 115 |
+
onClick={handleClear}
|
| 116 |
+
size="icon"
|
| 117 |
+
variant="destructive"
|
| 118 |
+
className="w-14 h-14 rounded-full shadow-xl hover:shadow-2xl transition-all duration-300 hover:scale-110"
|
| 119 |
+
>
|
| 120 |
+
<Trash2 className="w-6 h-6" />
|
| 121 |
+
</Button>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
{/* Results Grid */}
|
| 125 |
+
<div className="space-y-6">
|
| 126 |
+
{responses.map((response, index) => (
|
| 127 |
+
<div
|
| 128 |
+
key={response.id}
|
| 129 |
+
className="animate-in fade-in-0 slide-in-from-bottom-4"
|
| 130 |
+
style={{ animationDelay: `${index * 100}ms` }}
|
| 131 |
+
>
|
| 132 |
+
<ResponseDisplay response={response} />
|
| 133 |
+
</div>
|
| 134 |
+
))}
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
{/* Bottom Spacer for Mobile FAB */}
|
| 138 |
+
<div className="h-20 sm:hidden" />
|
| 139 |
+
</div>
|
| 140 |
+
);
|
| 141 |
+
};
|
src/components/ui/accordion.tsx
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
| 3 |
+
import { ChevronDown } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Accordion = AccordionPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const AccordionItem = React.forwardRef<
|
| 10 |
+
React.ElementRef<typeof AccordionPrimitive.Item>,
|
| 11 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
| 12 |
+
>(({ className, ...props }, ref) => (
|
| 13 |
+
<AccordionPrimitive.Item ref={ref} className={cn("border-b", className)} {...props} />
|
| 14 |
+
));
|
| 15 |
+
AccordionItem.displayName = "AccordionItem";
|
| 16 |
+
|
| 17 |
+
const AccordionTrigger = React.forwardRef<
|
| 18 |
+
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
| 19 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
| 20 |
+
>(({ className, children, ...props }, ref) => (
|
| 21 |
+
<AccordionPrimitive.Header className="flex">
|
| 22 |
+
<AccordionPrimitive.Trigger
|
| 23 |
+
ref={ref}
|
| 24 |
+
className={cn(
|
| 25 |
+
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
|
| 26 |
+
className,
|
| 27 |
+
)}
|
| 28 |
+
{...props}
|
| 29 |
+
>
|
| 30 |
+
{children}
|
| 31 |
+
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
| 32 |
+
</AccordionPrimitive.Trigger>
|
| 33 |
+
</AccordionPrimitive.Header>
|
| 34 |
+
));
|
| 35 |
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
| 36 |
+
|
| 37 |
+
const AccordionContent = React.forwardRef<
|
| 38 |
+
React.ElementRef<typeof AccordionPrimitive.Content>,
|
| 39 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
| 40 |
+
>(({ className, children, ...props }, ref) => (
|
| 41 |
+
<AccordionPrimitive.Content
|
| 42 |
+
ref={ref}
|
| 43 |
+
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
| 44 |
+
{...props}
|
| 45 |
+
>
|
| 46 |
+
<div className={cn("pb-4 pt-0", className)}>{children}</div>
|
| 47 |
+
</AccordionPrimitive.Content>
|
| 48 |
+
));
|
| 49 |
+
|
| 50 |
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
| 51 |
+
|
| 52 |
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
src/components/ui/alert-dialog.tsx
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
import { buttonVariants } from "@/components/ui/button";
|
| 6 |
+
|
| 7 |
+
const AlertDialog = AlertDialogPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
| 12 |
+
|
| 13 |
+
const AlertDialogOverlay = React.forwardRef<
|
| 14 |
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
| 15 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
| 16 |
+
>(({ className, ...props }, ref) => (
|
| 17 |
+
<AlertDialogPrimitive.Overlay
|
| 18 |
+
className={cn(
|
| 19 |
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
| 20 |
+
className,
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
ref={ref}
|
| 24 |
+
/>
|
| 25 |
+
));
|
| 26 |
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
| 27 |
+
|
| 28 |
+
const AlertDialogContent = React.forwardRef<
|
| 29 |
+
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
| 30 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
| 31 |
+
>(({ className, ...props }, ref) => (
|
| 32 |
+
<AlertDialogPortal>
|
| 33 |
+
<AlertDialogOverlay />
|
| 34 |
+
<AlertDialogPrimitive.Content
|
| 35 |
+
ref={ref}
|
| 36 |
+
className={cn(
|
| 37 |
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
| 38 |
+
className,
|
| 39 |
+
)}
|
| 40 |
+
{...props}
|
| 41 |
+
/>
|
| 42 |
+
</AlertDialogPortal>
|
| 43 |
+
));
|
| 44 |
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
| 45 |
+
|
| 46 |
+
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 47 |
+
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
| 48 |
+
);
|
| 49 |
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
| 50 |
+
|
| 51 |
+
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 52 |
+
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
| 53 |
+
);
|
| 54 |
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
| 55 |
+
|
| 56 |
+
const AlertDialogTitle = React.forwardRef<
|
| 57 |
+
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
| 58 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
| 59 |
+
>(({ className, ...props }, ref) => (
|
| 60 |
+
<AlertDialogPrimitive.Title ref={ref} className={cn("text-lg font-semibold", className)} {...props} />
|
| 61 |
+
));
|
| 62 |
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
| 63 |
+
|
| 64 |
+
const AlertDialogDescription = React.forwardRef<
|
| 65 |
+
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
| 66 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
| 67 |
+
>(({ className, ...props }, ref) => (
|
| 68 |
+
<AlertDialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
| 69 |
+
));
|
| 70 |
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
| 71 |
+
|
| 72 |
+
const AlertDialogAction = React.forwardRef<
|
| 73 |
+
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
| 74 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
| 75 |
+
>(({ className, ...props }, ref) => (
|
| 76 |
+
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
| 77 |
+
));
|
| 78 |
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
| 79 |
+
|
| 80 |
+
const AlertDialogCancel = React.forwardRef<
|
| 81 |
+
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
| 82 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
| 83 |
+
>(({ className, ...props }, ref) => (
|
| 84 |
+
<AlertDialogPrimitive.Cancel
|
| 85 |
+
ref={ref}
|
| 86 |
+
className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
|
| 87 |
+
{...props}
|
| 88 |
+
/>
|
| 89 |
+
));
|
| 90 |
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
| 91 |
+
|
| 92 |
+
export {
|
| 93 |
+
AlertDialog,
|
| 94 |
+
AlertDialogPortal,
|
| 95 |
+
AlertDialogOverlay,
|
| 96 |
+
AlertDialogTrigger,
|
| 97 |
+
AlertDialogContent,
|
| 98 |
+
AlertDialogHeader,
|
| 99 |
+
AlertDialogFooter,
|
| 100 |
+
AlertDialogTitle,
|
| 101 |
+
AlertDialogDescription,
|
| 102 |
+
AlertDialogAction,
|
| 103 |
+
AlertDialogCancel,
|
| 104 |
+
};
|
src/components/ui/alert.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "bg-background text-foreground",
|
| 12 |
+
destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
| 13 |
+
},
|
| 14 |
+
},
|
| 15 |
+
defaultVariants: {
|
| 16 |
+
variant: "default",
|
| 17 |
+
},
|
| 18 |
+
},
|
| 19 |
+
);
|
| 20 |
+
|
| 21 |
+
const Alert = React.forwardRef<
|
| 22 |
+
HTMLDivElement,
|
| 23 |
+
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
| 24 |
+
>(({ className, variant, ...props }, ref) => (
|
| 25 |
+
<div ref={ref} role="alert" className={cn(alertVariants({ variant }), className)} {...props} />
|
| 26 |
+
));
|
| 27 |
+
Alert.displayName = "Alert";
|
| 28 |
+
|
| 29 |
+
const AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
| 30 |
+
({ className, ...props }, ref) => (
|
| 31 |
+
<h5 ref={ref} className={cn("mb-1 font-medium leading-none tracking-tight", className)} {...props} />
|
| 32 |
+
),
|
| 33 |
+
);
|
| 34 |
+
AlertTitle.displayName = "AlertTitle";
|
| 35 |
+
|
| 36 |
+
const AlertDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
| 37 |
+
({ className, ...props }, ref) => (
|
| 38 |
+
<div ref={ref} className={cn("text-sm [&_p]:leading-relaxed", className)} {...props} />
|
| 39 |
+
),
|
| 40 |
+
);
|
| 41 |
+
AlertDescription.displayName = "AlertDescription";
|
| 42 |
+
|
| 43 |
+
export { Alert, AlertTitle, AlertDescription };
|
src/components/ui/aspect-ratio.tsx
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio";
|
| 2 |
+
|
| 3 |
+
const AspectRatio = AspectRatioPrimitive.Root;
|
| 4 |
+
|
| 5 |
+
export { AspectRatio };
|
src/components/ui/avatar.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const Avatar = React.forwardRef<
|
| 7 |
+
React.ElementRef<typeof AvatarPrimitive.Root>,
|
| 8 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
| 9 |
+
>(({ className, ...props }, ref) => (
|
| 10 |
+
<AvatarPrimitive.Root
|
| 11 |
+
ref={ref}
|
| 12 |
+
className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
));
|
| 16 |
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
| 17 |
+
|
| 18 |
+
const AvatarImage = React.forwardRef<
|
| 19 |
+
React.ElementRef<typeof AvatarPrimitive.Image>,
|
| 20 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
| 21 |
+
>(({ className, ...props }, ref) => (
|
| 22 |
+
<AvatarPrimitive.Image ref={ref} className={cn("aspect-square h-full w-full", className)} {...props} />
|
| 23 |
+
));
|
| 24 |
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
| 25 |
+
|
| 26 |
+
const AvatarFallback = React.forwardRef<
|
| 27 |
+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
| 28 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
| 29 |
+
>(({ className, ...props }, ref) => (
|
| 30 |
+
<AvatarPrimitive.Fallback
|
| 31 |
+
ref={ref}
|
| 32 |
+
className={cn("flex h-full w-full items-center justify-center rounded-full bg-muted", className)}
|
| 33 |
+
{...props}
|
| 34 |
+
/>
|
| 35 |
+
));
|
| 36 |
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
| 37 |
+
|
| 38 |
+
export { Avatar, AvatarImage, AvatarFallback };
|
src/components/ui/badge.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 badgeVariants = cva(
|
| 7 |
+
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
| 12 |
+
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
| 13 |
+
destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
| 14 |
+
outline: "text-foreground",
|
| 15 |
+
},
|
| 16 |
+
},
|
| 17 |
+
defaultVariants: {
|
| 18 |
+
variant: "default",
|
| 19 |
+
},
|
| 20 |
+
},
|
| 21 |
+
);
|
| 22 |
+
|
| 23 |
+
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
| 24 |
+
|
| 25 |
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
| 26 |
+
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export { Badge, badgeVariants };
|
src/components/ui/breadcrumb.tsx
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
const Breadcrumb = React.forwardRef<
|
| 8 |
+
HTMLElement,
|
| 9 |
+
React.ComponentPropsWithoutRef<"nav"> & {
|
| 10 |
+
separator?: React.ReactNode;
|
| 11 |
+
}
|
| 12 |
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
| 13 |
+
Breadcrumb.displayName = "Breadcrumb";
|
| 14 |
+
|
| 15 |
+
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<"ol">>(
|
| 16 |
+
({ className, ...props }, ref) => (
|
| 17 |
+
<ol
|
| 18 |
+
ref={ref}
|
| 19 |
+
className={cn(
|
| 20 |
+
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
| 21 |
+
className,
|
| 22 |
+
)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
),
|
| 26 |
+
);
|
| 27 |
+
BreadcrumbList.displayName = "BreadcrumbList";
|
| 28 |
+
|
| 29 |
+
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<"li">>(
|
| 30 |
+
({ className, ...props }, ref) => (
|
| 31 |
+
<li ref={ref} className={cn("inline-flex items-center gap-1.5", className)} {...props} />
|
| 32 |
+
),
|
| 33 |
+
);
|
| 34 |
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
| 35 |
+
|
| 36 |
+
const BreadcrumbLink = React.forwardRef<
|
| 37 |
+
HTMLAnchorElement,
|
| 38 |
+
React.ComponentPropsWithoutRef<"a"> & {
|
| 39 |
+
asChild?: boolean;
|
| 40 |
+
}
|
| 41 |
+
>(({ asChild, className, ...props }, ref) => {
|
| 42 |
+
const Comp = asChild ? Slot : "a";
|
| 43 |
+
|
| 44 |
+
return <Comp ref={ref} className={cn("transition-colors hover:text-foreground", className)} {...props} />;
|
| 45 |
+
});
|
| 46 |
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
| 47 |
+
|
| 48 |
+
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<"span">>(
|
| 49 |
+
({ className, ...props }, ref) => (
|
| 50 |
+
<span
|
| 51 |
+
ref={ref}
|
| 52 |
+
role="link"
|
| 53 |
+
aria-disabled="true"
|
| 54 |
+
aria-current="page"
|
| 55 |
+
className={cn("font-normal text-foreground", className)}
|
| 56 |
+
{...props}
|
| 57 |
+
/>
|
| 58 |
+
),
|
| 59 |
+
);
|
| 60 |
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
| 61 |
+
|
| 62 |
+
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<"li">) => (
|
| 63 |
+
<li role="presentation" aria-hidden="true" className={cn("[&>svg]:size-3.5", className)} {...props}>
|
| 64 |
+
{children ?? <ChevronRight />}
|
| 65 |
+
</li>
|
| 66 |
+
);
|
| 67 |
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
| 68 |
+
|
| 69 |
+
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
| 70 |
+
<span
|
| 71 |
+
role="presentation"
|
| 72 |
+
aria-hidden="true"
|
| 73 |
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
| 74 |
+
{...props}
|
| 75 |
+
>
|
| 76 |
+
<MoreHorizontal className="h-4 w-4" />
|
| 77 |
+
<span className="sr-only">More</span>
|
| 78 |
+
</span>
|
| 79 |
+
);
|
| 80 |
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
| 81 |
+
|
| 82 |
+
export {
|
| 83 |
+
Breadcrumb,
|
| 84 |
+
BreadcrumbList,
|
| 85 |
+
BreadcrumbItem,
|
| 86 |
+
BreadcrumbLink,
|
| 87 |
+
BreadcrumbPage,
|
| 88 |
+
BreadcrumbSeparator,
|
| 89 |
+
BreadcrumbEllipsis,
|
| 90 |
+
};
|
src/components/ui/button.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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-lg text-sm font-medium transition-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 relative overflow-hidden",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default: "bg-gradient-primary text-primary-foreground hover:opacity-90 hover:shadow-glow hover:scale-[1.02] active:scale-[0.98]",
|
| 13 |
+
destructive: "bg-gradient-danger text-destructive-foreground hover:opacity-90 hover:shadow-lg active:scale-[0.98]",
|
| 14 |
+
outline: "border border-border bg-card/50 hover:bg-secondary/80 hover:text-secondary-foreground hover:border-primary/30 hover:shadow-md active:scale-[0.98]",
|
| 15 |
+
secondary: "bg-gradient-secondary text-secondary-foreground hover:bg-secondary/80 hover:shadow-md active:scale-[0.98]",
|
| 16 |
+
ghost: "hover:bg-accent/50 hover:text-accent-foreground hover:shadow-sm active:scale-[0.98]",
|
| 17 |
+
link: "text-primary underline-offset-4 hover:underline hover:text-primary/80",
|
| 18 |
+
success: "bg-gradient-success text-primary-foreground hover:opacity-90 hover:shadow-glow active:scale-[0.98]",
|
| 19 |
+
},
|
| 20 |
+
size: {
|
| 21 |
+
default: "h-11 px-6 py-3",
|
| 22 |
+
sm: "h-9 rounded-md px-4 text-xs",
|
| 23 |
+
lg: "h-12 rounded-lg px-8 text-base font-semibold",
|
| 24 |
+
icon: "h-10 w-10",
|
| 25 |
+
},
|
| 26 |
+
},
|
| 27 |
+
defaultVariants: {
|
| 28 |
+
variant: "default",
|
| 29 |
+
size: "default",
|
| 30 |
+
},
|
| 31 |
+
},
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
export interface ButtonProps
|
| 35 |
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
| 36 |
+
VariantProps<typeof buttonVariants> {
|
| 37 |
+
asChild?: boolean;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
| 41 |
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
| 42 |
+
const Comp = asChild ? Slot : "button";
|
| 43 |
+
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
|
| 44 |
+
},
|
| 45 |
+
);
|
| 46 |
+
Button.displayName = "Button";
|
| 47 |
+
|
| 48 |
+
export { Button, buttonVariants };
|
src/components/ui/calendar.tsx
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
| 3 |
+
import { DayPicker } from "react-day-picker";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
import { buttonVariants } from "@/components/ui/button";
|
| 7 |
+
|
| 8 |
+
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
| 9 |
+
|
| 10 |
+
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
|
| 11 |
+
return (
|
| 12 |
+
<DayPicker
|
| 13 |
+
showOutsideDays={showOutsideDays}
|
| 14 |
+
className={cn("p-3", className)}
|
| 15 |
+
classNames={{
|
| 16 |
+
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
| 17 |
+
month: "space-y-4",
|
| 18 |
+
caption: "flex justify-center pt-1 relative items-center",
|
| 19 |
+
caption_label: "text-sm font-medium",
|
| 20 |
+
nav: "space-x-1 flex items-center",
|
| 21 |
+
nav_button: cn(
|
| 22 |
+
buttonVariants({ variant: "outline" }),
|
| 23 |
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
| 24 |
+
),
|
| 25 |
+
nav_button_previous: "absolute left-1",
|
| 26 |
+
nav_button_next: "absolute right-1",
|
| 27 |
+
table: "w-full border-collapse space-y-1",
|
| 28 |
+
head_row: "flex",
|
| 29 |
+
head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
| 30 |
+
row: "flex w-full mt-2",
|
| 31 |
+
cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
|
| 32 |
+
day: cn(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100"),
|
| 33 |
+
day_range_end: "day-range-end",
|
| 34 |
+
day_selected:
|
| 35 |
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
| 36 |
+
day_today: "bg-accent text-accent-foreground",
|
| 37 |
+
day_outside:
|
| 38 |
+
"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
| 39 |
+
day_disabled: "text-muted-foreground opacity-50",
|
| 40 |
+
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
| 41 |
+
day_hidden: "invisible",
|
| 42 |
+
...classNames,
|
| 43 |
+
}}
|
| 44 |
+
components={{
|
| 45 |
+
IconLeft: ({ ..._props }) => <ChevronLeft className="h-4 w-4" />,
|
| 46 |
+
IconRight: ({ ..._props }) => <ChevronRight className="h-4 w-4" />,
|
| 47 |
+
}}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
Calendar.displayName = "Calendar";
|
| 53 |
+
|
| 54 |
+
export { Calendar };
|
src/components/ui/card.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils";
|
| 4 |
+
|
| 5 |
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
| 6 |
+
<div ref={ref} className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} {...props} />
|
| 7 |
+
));
|
| 8 |
+
Card.displayName = "Card";
|
| 9 |
+
|
| 10 |
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 11 |
+
({ className, ...props }, ref) => (
|
| 12 |
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
| 13 |
+
),
|
| 14 |
+
);
|
| 15 |
+
CardHeader.displayName = "CardHeader";
|
| 16 |
+
|
| 17 |
+
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
| 18 |
+
({ className, ...props }, ref) => (
|
| 19 |
+
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-tight", className)} {...props} />
|
| 20 |
+
),
|
| 21 |
+
);
|
| 22 |
+
CardTitle.displayName = "CardTitle";
|
| 23 |
+
|
| 24 |
+
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
| 25 |
+
({ className, ...props }, ref) => (
|
| 26 |
+
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
| 27 |
+
),
|
| 28 |
+
);
|
| 29 |
+
CardDescription.displayName = "CardDescription";
|
| 30 |
+
|
| 31 |
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 32 |
+
({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
|
| 33 |
+
);
|
| 34 |
+
CardContent.displayName = "CardContent";
|
| 35 |
+
|
| 36 |
+
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 37 |
+
({ className, ...props }, ref) => (
|
| 38 |
+
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
| 39 |
+
),
|
| 40 |
+
);
|
| 41 |
+
CardFooter.displayName = "CardFooter";
|
| 42 |
+
|
| 43 |
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
src/components/ui/carousel.tsx
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
| 3 |
+
import { ArrowLeft, ArrowRight } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
import { Button } from "@/components/ui/button";
|
| 7 |
+
|
| 8 |
+
type CarouselApi = UseEmblaCarouselType[1];
|
| 9 |
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
| 10 |
+
type CarouselOptions = UseCarouselParameters[0];
|
| 11 |
+
type CarouselPlugin = UseCarouselParameters[1];
|
| 12 |
+
|
| 13 |
+
type CarouselProps = {
|
| 14 |
+
opts?: CarouselOptions;
|
| 15 |
+
plugins?: CarouselPlugin;
|
| 16 |
+
orientation?: "horizontal" | "vertical";
|
| 17 |
+
setApi?: (api: CarouselApi) => void;
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
type CarouselContextProps = {
|
| 21 |
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
| 22 |
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
| 23 |
+
scrollPrev: () => void;
|
| 24 |
+
scrollNext: () => void;
|
| 25 |
+
canScrollPrev: boolean;
|
| 26 |
+
canScrollNext: boolean;
|
| 27 |
+
} & CarouselProps;
|
| 28 |
+
|
| 29 |
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
| 30 |
+
|
| 31 |
+
function useCarousel() {
|
| 32 |
+
const context = React.useContext(CarouselContext);
|
| 33 |
+
|
| 34 |
+
if (!context) {
|
| 35 |
+
throw new Error("useCarousel must be used within a <Carousel />");
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return context;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & CarouselProps>(
|
| 42 |
+
({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => {
|
| 43 |
+
const [carouselRef, api] = useEmblaCarousel(
|
| 44 |
+
{
|
| 45 |
+
...opts,
|
| 46 |
+
axis: orientation === "horizontal" ? "x" : "y",
|
| 47 |
+
},
|
| 48 |
+
plugins,
|
| 49 |
+
);
|
| 50 |
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
| 51 |
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
| 52 |
+
|
| 53 |
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
| 54 |
+
if (!api) {
|
| 55 |
+
return;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
setCanScrollPrev(api.canScrollPrev());
|
| 59 |
+
setCanScrollNext(api.canScrollNext());
|
| 60 |
+
}, []);
|
| 61 |
+
|
| 62 |
+
const scrollPrev = React.useCallback(() => {
|
| 63 |
+
api?.scrollPrev();
|
| 64 |
+
}, [api]);
|
| 65 |
+
|
| 66 |
+
const scrollNext = React.useCallback(() => {
|
| 67 |
+
api?.scrollNext();
|
| 68 |
+
}, [api]);
|
| 69 |
+
|
| 70 |
+
const handleKeyDown = React.useCallback(
|
| 71 |
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
| 72 |
+
if (event.key === "ArrowLeft") {
|
| 73 |
+
event.preventDefault();
|
| 74 |
+
scrollPrev();
|
| 75 |
+
} else if (event.key === "ArrowRight") {
|
| 76 |
+
event.preventDefault();
|
| 77 |
+
scrollNext();
|
| 78 |
+
}
|
| 79 |
+
},
|
| 80 |
+
[scrollPrev, scrollNext],
|
| 81 |
+
);
|
| 82 |
+
|
| 83 |
+
React.useEffect(() => {
|
| 84 |
+
if (!api || !setApi) {
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
setApi(api);
|
| 89 |
+
}, [api, setApi]);
|
| 90 |
+
|
| 91 |
+
React.useEffect(() => {
|
| 92 |
+
if (!api) {
|
| 93 |
+
return;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
onSelect(api);
|
| 97 |
+
api.on("reInit", onSelect);
|
| 98 |
+
api.on("select", onSelect);
|
| 99 |
+
|
| 100 |
+
return () => {
|
| 101 |
+
api?.off("select", onSelect);
|
| 102 |
+
};
|
| 103 |
+
}, [api, onSelect]);
|
| 104 |
+
|
| 105 |
+
return (
|
| 106 |
+
<CarouselContext.Provider
|
| 107 |
+
value={{
|
| 108 |
+
carouselRef,
|
| 109 |
+
api: api,
|
| 110 |
+
opts,
|
| 111 |
+
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
| 112 |
+
scrollPrev,
|
| 113 |
+
scrollNext,
|
| 114 |
+
canScrollPrev,
|
| 115 |
+
canScrollNext,
|
| 116 |
+
}}
|
| 117 |
+
>
|
| 118 |
+
<div
|
| 119 |
+
ref={ref}
|
| 120 |
+
onKeyDownCapture={handleKeyDown}
|
| 121 |
+
className={cn("relative", className)}
|
| 122 |
+
role="region"
|
| 123 |
+
aria-roledescription="carousel"
|
| 124 |
+
{...props}
|
| 125 |
+
>
|
| 126 |
+
{children}
|
| 127 |
+
</div>
|
| 128 |
+
</CarouselContext.Provider>
|
| 129 |
+
);
|
| 130 |
+
},
|
| 131 |
+
);
|
| 132 |
+
Carousel.displayName = "Carousel";
|
| 133 |
+
|
| 134 |
+
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 135 |
+
({ className, ...props }, ref) => {
|
| 136 |
+
const { carouselRef, orientation } = useCarousel();
|
| 137 |
+
|
| 138 |
+
return (
|
| 139 |
+
<div ref={carouselRef} className="overflow-hidden">
|
| 140 |
+
<div
|
| 141 |
+
ref={ref}
|
| 142 |
+
className={cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className)}
|
| 143 |
+
{...props}
|
| 144 |
+
/>
|
| 145 |
+
</div>
|
| 146 |
+
);
|
| 147 |
+
},
|
| 148 |
+
);
|
| 149 |
+
CarouselContent.displayName = "CarouselContent";
|
| 150 |
+
|
| 151 |
+
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 152 |
+
({ className, ...props }, ref) => {
|
| 153 |
+
const { orientation } = useCarousel();
|
| 154 |
+
|
| 155 |
+
return (
|
| 156 |
+
<div
|
| 157 |
+
ref={ref}
|
| 158 |
+
role="group"
|
| 159 |
+
aria-roledescription="slide"
|
| 160 |
+
className={cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className)}
|
| 161 |
+
{...props}
|
| 162 |
+
/>
|
| 163 |
+
);
|
| 164 |
+
},
|
| 165 |
+
);
|
| 166 |
+
CarouselItem.displayName = "CarouselItem";
|
| 167 |
+
|
| 168 |
+
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
| 169 |
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
| 170 |
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
| 171 |
+
|
| 172 |
+
return (
|
| 173 |
+
<Button
|
| 174 |
+
ref={ref}
|
| 175 |
+
variant={variant}
|
| 176 |
+
size={size}
|
| 177 |
+
className={cn(
|
| 178 |
+
"absolute h-8 w-8 rounded-full",
|
| 179 |
+
orientation === "horizontal"
|
| 180 |
+
? "-left-12 top-1/2 -translate-y-1/2"
|
| 181 |
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
| 182 |
+
className,
|
| 183 |
+
)}
|
| 184 |
+
disabled={!canScrollPrev}
|
| 185 |
+
onClick={scrollPrev}
|
| 186 |
+
{...props}
|
| 187 |
+
>
|
| 188 |
+
<ArrowLeft className="h-4 w-4" />
|
| 189 |
+
<span className="sr-only">Previous slide</span>
|
| 190 |
+
</Button>
|
| 191 |
+
);
|
| 192 |
+
},
|
| 193 |
+
);
|
| 194 |
+
CarouselPrevious.displayName = "CarouselPrevious";
|
| 195 |
+
|
| 196 |
+
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
| 197 |
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
| 198 |
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
| 199 |
+
|
| 200 |
+
return (
|
| 201 |
+
<Button
|
| 202 |
+
ref={ref}
|
| 203 |
+
variant={variant}
|
| 204 |
+
size={size}
|
| 205 |
+
className={cn(
|
| 206 |
+
"absolute h-8 w-8 rounded-full",
|
| 207 |
+
orientation === "horizontal"
|
| 208 |
+
? "-right-12 top-1/2 -translate-y-1/2"
|
| 209 |
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
| 210 |
+
className,
|
| 211 |
+
)}
|
| 212 |
+
disabled={!canScrollNext}
|
| 213 |
+
onClick={scrollNext}
|
| 214 |
+
{...props}
|
| 215 |
+
>
|
| 216 |
+
<ArrowRight className="h-4 w-4" />
|
| 217 |
+
<span className="sr-only">Next slide</span>
|
| 218 |
+
</Button>
|
| 219 |
+
);
|
| 220 |
+
},
|
| 221 |
+
);
|
| 222 |
+
CarouselNext.displayName = "CarouselNext";
|
| 223 |
+
|
| 224 |
+
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };
|
src/components/ui/chart.tsx
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as RechartsPrimitive from "recharts";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
| 7 |
+
const THEMES = { light: "", dark: ".dark" } as const;
|
| 8 |
+
|
| 9 |
+
export type ChartConfig = {
|
| 10 |
+
[k in string]: {
|
| 11 |
+
label?: React.ReactNode;
|
| 12 |
+
icon?: React.ComponentType;
|
| 13 |
+
} & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
type ChartContextProps = {
|
| 17 |
+
config: ChartConfig;
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
| 21 |
+
|
| 22 |
+
function useChart() {
|
| 23 |
+
const context = React.useContext(ChartContext);
|
| 24 |
+
|
| 25 |
+
if (!context) {
|
| 26 |
+
throw new Error("useChart must be used within a <ChartContainer />");
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
return context;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
const ChartContainer = React.forwardRef<
|
| 33 |
+
HTMLDivElement,
|
| 34 |
+
React.ComponentProps<"div"> & {
|
| 35 |
+
config: ChartConfig;
|
| 36 |
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
| 37 |
+
}
|
| 38 |
+
>(({ id, className, children, config, ...props }, ref) => {
|
| 39 |
+
const uniqueId = React.useId();
|
| 40 |
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
| 41 |
+
|
| 42 |
+
return (
|
| 43 |
+
<ChartContext.Provider value={{ config }}>
|
| 44 |
+
<div
|
| 45 |
+
data-chart={chartId}
|
| 46 |
+
ref={ref}
|
| 47 |
+
className={cn(
|
| 48 |
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
| 49 |
+
className,
|
| 50 |
+
)}
|
| 51 |
+
{...props}
|
| 52 |
+
>
|
| 53 |
+
<ChartStyle id={chartId} config={config} />
|
| 54 |
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
| 55 |
+
</div>
|
| 56 |
+
</ChartContext.Provider>
|
| 57 |
+
);
|
| 58 |
+
});
|
| 59 |
+
ChartContainer.displayName = "Chart";
|
| 60 |
+
|
| 61 |
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
| 62 |
+
const colorConfig = Object.entries(config).filter(([_, config]) => config.theme || config.color);
|
| 63 |
+
|
| 64 |
+
if (!colorConfig.length) {
|
| 65 |
+
return null;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
return (
|
| 69 |
+
<style
|
| 70 |
+
dangerouslySetInnerHTML={{
|
| 71 |
+
__html: Object.entries(THEMES)
|
| 72 |
+
.map(
|
| 73 |
+
([theme, prefix]) => `
|
| 74 |
+
${prefix} [data-chart=${id}] {
|
| 75 |
+
${colorConfig
|
| 76 |
+
.map(([key, itemConfig]) => {
|
| 77 |
+
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
| 78 |
+
return color ? ` --color-${key}: ${color};` : null;
|
| 79 |
+
})
|
| 80 |
+
.join("\n")}
|
| 81 |
+
}
|
| 82 |
+
`,
|
| 83 |
+
)
|
| 84 |
+
.join("\n"),
|
| 85 |
+
}}
|
| 86 |
+
/>
|
| 87 |
+
);
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
| 91 |
+
|
| 92 |
+
const ChartTooltipContent = React.forwardRef<
|
| 93 |
+
HTMLDivElement,
|
| 94 |
+
React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
| 95 |
+
React.ComponentProps<"div"> & {
|
| 96 |
+
hideLabel?: boolean;
|
| 97 |
+
hideIndicator?: boolean;
|
| 98 |
+
indicator?: "line" | "dot" | "dashed";
|
| 99 |
+
nameKey?: string;
|
| 100 |
+
labelKey?: string;
|
| 101 |
+
}
|
| 102 |
+
>(
|
| 103 |
+
(
|
| 104 |
+
{
|
| 105 |
+
active,
|
| 106 |
+
payload,
|
| 107 |
+
className,
|
| 108 |
+
indicator = "dot",
|
| 109 |
+
hideLabel = false,
|
| 110 |
+
hideIndicator = false,
|
| 111 |
+
label,
|
| 112 |
+
labelFormatter,
|
| 113 |
+
labelClassName,
|
| 114 |
+
formatter,
|
| 115 |
+
color,
|
| 116 |
+
nameKey,
|
| 117 |
+
labelKey,
|
| 118 |
+
},
|
| 119 |
+
ref,
|
| 120 |
+
) => {
|
| 121 |
+
const { config } = useChart();
|
| 122 |
+
|
| 123 |
+
const tooltipLabel = React.useMemo(() => {
|
| 124 |
+
if (hideLabel || !payload?.length) {
|
| 125 |
+
return null;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
const [item] = payload;
|
| 129 |
+
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
| 130 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 131 |
+
const value =
|
| 132 |
+
!labelKey && typeof label === "string"
|
| 133 |
+
? config[label as keyof typeof config]?.label || label
|
| 134 |
+
: itemConfig?.label;
|
| 135 |
+
|
| 136 |
+
if (labelFormatter) {
|
| 137 |
+
return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
if (!value) {
|
| 141 |
+
return null;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
| 145 |
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
| 146 |
+
|
| 147 |
+
if (!active || !payload?.length) {
|
| 148 |
+
return null;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
| 152 |
+
|
| 153 |
+
return (
|
| 154 |
+
<div
|
| 155 |
+
ref={ref}
|
| 156 |
+
className={cn(
|
| 157 |
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
| 158 |
+
className,
|
| 159 |
+
)}
|
| 160 |
+
>
|
| 161 |
+
{!nestLabel ? tooltipLabel : null}
|
| 162 |
+
<div className="grid gap-1.5">
|
| 163 |
+
{payload.map((item, index) => {
|
| 164 |
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
| 165 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 166 |
+
const indicatorColor = color || item.payload.fill || item.color;
|
| 167 |
+
|
| 168 |
+
return (
|
| 169 |
+
<div
|
| 170 |
+
key={item.dataKey}
|
| 171 |
+
className={cn(
|
| 172 |
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
| 173 |
+
indicator === "dot" && "items-center",
|
| 174 |
+
)}
|
| 175 |
+
>
|
| 176 |
+
{formatter && item?.value !== undefined && item.name ? (
|
| 177 |
+
formatter(item.value, item.name, item, index, item.payload)
|
| 178 |
+
) : (
|
| 179 |
+
<>
|
| 180 |
+
{itemConfig?.icon ? (
|
| 181 |
+
<itemConfig.icon />
|
| 182 |
+
) : (
|
| 183 |
+
!hideIndicator && (
|
| 184 |
+
<div
|
| 185 |
+
className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
| 186 |
+
"h-2.5 w-2.5": indicator === "dot",
|
| 187 |
+
"w-1": indicator === "line",
|
| 188 |
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
| 189 |
+
"my-0.5": nestLabel && indicator === "dashed",
|
| 190 |
+
})}
|
| 191 |
+
style={
|
| 192 |
+
{
|
| 193 |
+
"--color-bg": indicatorColor,
|
| 194 |
+
"--color-border": indicatorColor,
|
| 195 |
+
} as React.CSSProperties
|
| 196 |
+
}
|
| 197 |
+
/>
|
| 198 |
+
)
|
| 199 |
+
)}
|
| 200 |
+
<div
|
| 201 |
+
className={cn(
|
| 202 |
+
"flex flex-1 justify-between leading-none",
|
| 203 |
+
nestLabel ? "items-end" : "items-center",
|
| 204 |
+
)}
|
| 205 |
+
>
|
| 206 |
+
<div className="grid gap-1.5">
|
| 207 |
+
{nestLabel ? tooltipLabel : null}
|
| 208 |
+
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
| 209 |
+
</div>
|
| 210 |
+
{item.value && (
|
| 211 |
+
<span className="font-mono font-medium tabular-nums text-foreground">
|
| 212 |
+
{item.value.toLocaleString()}
|
| 213 |
+
</span>
|
| 214 |
+
)}
|
| 215 |
+
</div>
|
| 216 |
+
</>
|
| 217 |
+
)}
|
| 218 |
+
</div>
|
| 219 |
+
);
|
| 220 |
+
})}
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
);
|
| 224 |
+
},
|
| 225 |
+
);
|
| 226 |
+
ChartTooltipContent.displayName = "ChartTooltip";
|
| 227 |
+
|
| 228 |
+
const ChartLegend = RechartsPrimitive.Legend;
|
| 229 |
+
|
| 230 |
+
const ChartLegendContent = React.forwardRef<
|
| 231 |
+
HTMLDivElement,
|
| 232 |
+
React.ComponentProps<"div"> &
|
| 233 |
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
| 234 |
+
hideIcon?: boolean;
|
| 235 |
+
nameKey?: string;
|
| 236 |
+
}
|
| 237 |
+
>(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
| 238 |
+
const { config } = useChart();
|
| 239 |
+
|
| 240 |
+
if (!payload?.length) {
|
| 241 |
+
return null;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
return (
|
| 245 |
+
<div
|
| 246 |
+
ref={ref}
|
| 247 |
+
className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}
|
| 248 |
+
>
|
| 249 |
+
{payload.map((item) => {
|
| 250 |
+
const key = `${nameKey || item.dataKey || "value"}`;
|
| 251 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 252 |
+
|
| 253 |
+
return (
|
| 254 |
+
<div
|
| 255 |
+
key={item.value}
|
| 256 |
+
className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
|
| 257 |
+
>
|
| 258 |
+
{itemConfig?.icon && !hideIcon ? (
|
| 259 |
+
<itemConfig.icon />
|
| 260 |
+
) : (
|
| 261 |
+
<div
|
| 262 |
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
| 263 |
+
style={{
|
| 264 |
+
backgroundColor: item.color,
|
| 265 |
+
}}
|
| 266 |
+
/>
|
| 267 |
+
)}
|
| 268 |
+
{itemConfig?.label}
|
| 269 |
+
</div>
|
| 270 |
+
);
|
| 271 |
+
})}
|
| 272 |
+
</div>
|
| 273 |
+
);
|
| 274 |
+
});
|
| 275 |
+
ChartLegendContent.displayName = "ChartLegend";
|
| 276 |
+
|
| 277 |
+
// Helper to extract item config from a payload.
|
| 278 |
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
| 279 |
+
if (typeof payload !== "object" || payload === null) {
|
| 280 |
+
return undefined;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
const payloadPayload =
|
| 284 |
+
"payload" in payload && typeof payload.payload === "object" && payload.payload !== null
|
| 285 |
+
? payload.payload
|
| 286 |
+
: undefined;
|
| 287 |
+
|
| 288 |
+
let configLabelKey: string = key;
|
| 289 |
+
|
| 290 |
+
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
|
| 291 |
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
| 292 |
+
} else if (
|
| 293 |
+
payloadPayload &&
|
| 294 |
+
key in payloadPayload &&
|
| 295 |
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
| 296 |
+
) {
|
| 297 |
+
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
|
src/components/ui/checkbox.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
| 3 |
+
import { Check } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Checkbox = React.forwardRef<
|
| 8 |
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
| 9 |
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
| 10 |
+
>(({ className, ...props }, ref) => (
|
| 11 |
+
<CheckboxPrimitive.Root
|
| 12 |
+
ref={ref}
|
| 13 |
+
className={cn(
|
| 14 |
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
| 15 |
+
className,
|
| 16 |
+
)}
|
| 17 |
+
{...props}
|
| 18 |
+
>
|
| 19 |
+
<CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
|
| 20 |
+
<Check className="h-4 w-4" />
|
| 21 |
+
</CheckboxPrimitive.Indicator>
|
| 22 |
+
</CheckboxPrimitive.Root>
|
| 23 |
+
));
|
| 24 |
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
| 25 |
+
|
| 26 |
+
export { Checkbox };
|
src/components/ui/collapsible.tsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
| 2 |
+
|
| 3 |
+
const Collapsible = CollapsiblePrimitive.Root;
|
| 4 |
+
|
| 5 |
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
| 6 |
+
|
| 7 |
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
| 8 |
+
|
| 9 |
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
src/components/ui/command.tsx
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { type DialogProps } from "@radix-ui/react-dialog";
|
| 3 |
+
import { Command as CommandPrimitive } from "cmdk";
|
| 4 |
+
import { Search } from "lucide-react";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
| 8 |
+
|
| 9 |
+
const Command = React.forwardRef<
|
| 10 |
+
React.ElementRef<typeof CommandPrimitive>,
|
| 11 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
| 12 |
+
>(({ className, ...props }, ref) => (
|
| 13 |
+
<CommandPrimitive
|
| 14 |
+
ref={ref}
|
| 15 |
+
className={cn(
|
| 16 |
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
));
|
| 22 |
+
Command.displayName = CommandPrimitive.displayName;
|
| 23 |
+
|
| 24 |
+
interface CommandDialogProps extends DialogProps {}
|
| 25 |
+
|
| 26 |
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
| 27 |
+
return (
|
| 28 |
+
<Dialog {...props}>
|
| 29 |
+
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
| 30 |
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
| 31 |
+
{children}
|
| 32 |
+
</Command>
|
| 33 |
+
</DialogContent>
|
| 34 |
+
</Dialog>
|
| 35 |
+
);
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
const CommandInput = React.forwardRef<
|
| 39 |
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
| 40 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
| 41 |
+
>(({ className, ...props }, ref) => (
|
| 42 |
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
| 43 |
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
| 44 |
+
<CommandPrimitive.Input
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
| 48 |
+
className,
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
</div>
|
| 53 |
+
));
|
| 54 |
+
|
| 55 |
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
| 56 |
+
|
| 57 |
+
const CommandList = React.forwardRef<
|
| 58 |
+
React.ElementRef<typeof CommandPrimitive.List>,
|
| 59 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
| 60 |
+
>(({ className, ...props }, ref) => (
|
| 61 |
+
<CommandPrimitive.List
|
| 62 |
+
ref={ref}
|
| 63 |
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
| 64 |
+
{...props}
|
| 65 |
+
/>
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
| 69 |
+
|
| 70 |
+
const CommandEmpty = React.forwardRef<
|
| 71 |
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
| 72 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
| 73 |
+
>((props, ref) => <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />);
|
| 74 |
+
|
| 75 |
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
| 76 |
+
|
| 77 |
+
const CommandGroup = React.forwardRef<
|
| 78 |
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
| 79 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
| 80 |
+
>(({ className, ...props }, ref) => (
|
| 81 |
+
<CommandPrimitive.Group
|
| 82 |
+
ref={ref}
|
| 83 |
+
className={cn(
|
| 84 |
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
| 85 |
+
className,
|
| 86 |
+
)}
|
| 87 |
+
{...props}
|
| 88 |
+
/>
|
| 89 |
+
));
|
| 90 |
+
|
| 91 |
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
| 92 |
+
|
| 93 |
+
const CommandSeparator = React.forwardRef<
|
| 94 |
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
| 95 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
| 96 |
+
>(({ className, ...props }, ref) => (
|
| 97 |
+
<CommandPrimitive.Separator ref={ref} className={cn("-mx-1 h-px bg-border", className)} {...props} />
|
| 98 |
+
));
|
| 99 |
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
| 100 |
+
|
| 101 |
+
const CommandItem = React.forwardRef<
|
| 102 |
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
| 103 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
| 104 |
+
>(({ className, ...props }, ref) => (
|
| 105 |
+
<CommandPrimitive.Item
|
| 106 |
+
ref={ref}
|
| 107 |
+
className={cn(
|
| 108 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
|
| 109 |
+
className,
|
| 110 |
+
)}
|
| 111 |
+
{...props}
|
| 112 |
+
/>
|
| 113 |
+
));
|
| 114 |
+
|
| 115 |
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
| 116 |
+
|
| 117 |
+
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 118 |
+
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
| 119 |
+
};
|
| 120 |
+
CommandShortcut.displayName = "CommandShortcut";
|
| 121 |
+
|
| 122 |
+
export {
|
| 123 |
+
Command,
|
| 124 |
+
CommandDialog,
|
| 125 |
+
CommandInput,
|
| 126 |
+
CommandList,
|
| 127 |
+
CommandEmpty,
|
| 128 |
+
CommandGroup,
|
| 129 |
+
CommandItem,
|
| 130 |
+
CommandShortcut,
|
| 131 |
+
CommandSeparator,
|
| 132 |
+
};
|
src/components/ui/context-menu.tsx
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
| 3 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const ContextMenu = ContextMenuPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
| 12 |
+
|
| 13 |
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
| 14 |
+
|
| 15 |
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
| 16 |
+
|
| 17 |
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
| 18 |
+
|
| 19 |
+
const ContextMenuSubTrigger = React.forwardRef<
|
| 20 |
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
| 21 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
| 22 |
+
inset?: boolean;
|
| 23 |
+
}
|
| 24 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 25 |
+
<ContextMenuPrimitive.SubTrigger
|
| 26 |
+
ref={ref}
|
| 27 |
+
className={cn(
|
| 28 |
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
| 29 |
+
inset && "pl-8",
|
| 30 |
+
className,
|
| 31 |
+
)}
|
| 32 |
+
{...props}
|
| 33 |
+
>
|
| 34 |
+
{children}
|
| 35 |
+
<ChevronRight className="ml-auto h-4 w-4" />
|
| 36 |
+
</ContextMenuPrimitive.SubTrigger>
|
| 37 |
+
));
|
| 38 |
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
| 39 |
+
|
| 40 |
+
const ContextMenuSubContent = React.forwardRef<
|
| 41 |
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
| 42 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
| 43 |
+
>(({ className, ...props }, ref) => (
|
| 44 |
+
<ContextMenuPrimitive.SubContent
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
|
| 48 |
+
className,
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
));
|
| 53 |
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
| 54 |
+
|
| 55 |
+
const ContextMenuContent = React.forwardRef<
|
| 56 |
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
| 57 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
| 58 |
+
>(({ className, ...props }, ref) => (
|
| 59 |
+
<ContextMenuPrimitive.Portal>
|
| 60 |
+
<ContextMenuPrimitive.Content
|
| 61 |
+
ref={ref}
|
| 62 |
+
className={cn(
|
| 63 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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",
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
/>
|
| 68 |
+
</ContextMenuPrimitive.Portal>
|
| 69 |
+
));
|
| 70 |
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
| 71 |
+
|
| 72 |
+
const ContextMenuItem = React.forwardRef<
|
| 73 |
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
| 74 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
| 75 |
+
inset?: boolean;
|
| 76 |
+
}
|
| 77 |
+
>(({ className, inset, ...props }, ref) => (
|
| 78 |
+
<ContextMenuPrimitive.Item
|
| 79 |
+
ref={ref}
|
| 80 |
+
className={cn(
|
| 81 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 82 |
+
inset && "pl-8",
|
| 83 |
+
className,
|
| 84 |
+
)}
|
| 85 |
+
{...props}
|
| 86 |
+
/>
|
| 87 |
+
));
|
| 88 |
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
| 89 |
+
|
| 90 |
+
const ContextMenuCheckboxItem = React.forwardRef<
|
| 91 |
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
| 92 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
| 93 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 94 |
+
<ContextMenuPrimitive.CheckboxItem
|
| 95 |
+
ref={ref}
|
| 96 |
+
className={cn(
|
| 97 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 98 |
+
className,
|
| 99 |
+
)}
|
| 100 |
+
checked={checked}
|
| 101 |
+
{...props}
|
| 102 |
+
>
|
| 103 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 104 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 105 |
+
<Check className="h-4 w-4" />
|
| 106 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 107 |
+
</span>
|
| 108 |
+
{children}
|
| 109 |
+
</ContextMenuPrimitive.CheckboxItem>
|
| 110 |
+
));
|
| 111 |
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
| 112 |
+
|
| 113 |
+
const ContextMenuRadioItem = React.forwardRef<
|
| 114 |
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
| 115 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
| 116 |
+
>(({ className, children, ...props }, ref) => (
|
| 117 |
+
<ContextMenuPrimitive.RadioItem
|
| 118 |
+
ref={ref}
|
| 119 |
+
className={cn(
|
| 120 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 121 |
+
className,
|
| 122 |
+
)}
|
| 123 |
+
{...props}
|
| 124 |
+
>
|
| 125 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 126 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 127 |
+
<Circle className="h-2 w-2 fill-current" />
|
| 128 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 129 |
+
</span>
|
| 130 |
+
{children}
|
| 131 |
+
</ContextMenuPrimitive.RadioItem>
|
| 132 |
+
));
|
| 133 |
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
| 134 |
+
|
| 135 |
+
const ContextMenuLabel = React.forwardRef<
|
| 136 |
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
| 137 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
| 138 |
+
inset?: boolean;
|
| 139 |
+
}
|
| 140 |
+
>(({ className, inset, ...props }, ref) => (
|
| 141 |
+
<ContextMenuPrimitive.Label
|
| 142 |
+
ref={ref}
|
| 143 |
+
className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
|
| 144 |
+
{...props}
|
| 145 |
+
/>
|
| 146 |
+
));
|
| 147 |
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
| 148 |
+
|
| 149 |
+
const ContextMenuSeparator = React.forwardRef<
|
| 150 |
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
| 151 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
| 152 |
+
>(({ className, ...props }, ref) => (
|
| 153 |
+
<ContextMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
|
| 154 |
+
));
|
| 155 |
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
| 156 |
+
|
| 157 |
+
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 158 |
+
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
| 159 |
+
};
|
| 160 |
+
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
| 161 |
+
|
| 162 |
+
export {
|
| 163 |
+
ContextMenu,
|
| 164 |
+
ContextMenuTrigger,
|
| 165 |
+
ContextMenuContent,
|
| 166 |
+
ContextMenuItem,
|
| 167 |
+
ContextMenuCheckboxItem,
|
| 168 |
+
ContextMenuRadioItem,
|
| 169 |
+
ContextMenuLabel,
|
| 170 |
+
ContextMenuSeparator,
|
| 171 |
+
ContextMenuShortcut,
|
| 172 |
+
ContextMenuGroup,
|
| 173 |
+
ContextMenuPortal,
|
| 174 |
+
ContextMenuSub,
|
| 175 |
+
ContextMenuSubContent,
|
| 176 |
+
ContextMenuSubTrigger,
|
| 177 |
+
ContextMenuRadioGroup,
|
| 178 |
+
};
|
src/components/ui/dialog.tsx
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
| 3 |
+
import { X } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Dialog = DialogPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const DialogTrigger = DialogPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const DialogPortal = DialogPrimitive.Portal;
|
| 12 |
+
|
| 13 |
+
const DialogClose = DialogPrimitive.Close;
|
| 14 |
+
|
| 15 |
+
const DialogOverlay = React.forwardRef<
|
| 16 |
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
| 17 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
| 18 |
+
>(({ className, ...props }, ref) => (
|
| 19 |
+
<DialogPrimitive.Overlay
|
| 20 |
+
ref={ref}
|
| 21 |
+
className={cn(
|
| 22 |
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
| 23 |
+
className,
|
| 24 |
+
)}
|
| 25 |
+
{...props}
|
| 26 |
+
/>
|
| 27 |
+
));
|
| 28 |
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
| 29 |
+
|
| 30 |
+
const DialogContent = React.forwardRef<
|
| 31 |
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
| 32 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
| 33 |
+
>(({ className, children, ...props }, ref) => (
|
| 34 |
+
<DialogPortal>
|
| 35 |
+
<DialogOverlay />
|
| 36 |
+
<DialogPrimitive.Content
|
| 37 |
+
ref={ref}
|
| 38 |
+
className={cn(
|
| 39 |
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
| 40 |
+
className,
|
| 41 |
+
)}
|
| 42 |
+
{...props}
|
| 43 |
+
>
|
| 44 |
+
{children}
|
| 45 |
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
| 46 |
+
<X className="h-4 w-4" />
|
| 47 |
+
<span className="sr-only">Close</span>
|
| 48 |
+
</DialogPrimitive.Close>
|
| 49 |
+
</DialogPrimitive.Content>
|
| 50 |
+
</DialogPortal>
|
| 51 |
+
));
|
| 52 |
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
| 53 |
+
|
| 54 |
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 55 |
+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
| 56 |
+
);
|
| 57 |
+
DialogHeader.displayName = "DialogHeader";
|
| 58 |
+
|
| 59 |
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 60 |
+
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
| 61 |
+
);
|
| 62 |
+
DialogFooter.displayName = "DialogFooter";
|
| 63 |
+
|
| 64 |
+
const DialogTitle = React.forwardRef<
|
| 65 |
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
| 66 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
| 67 |
+
>(({ className, ...props }, ref) => (
|
| 68 |
+
<DialogPrimitive.Title
|
| 69 |
+
ref={ref}
|
| 70 |
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
| 71 |
+
{...props}
|
| 72 |
+
/>
|
| 73 |
+
));
|
| 74 |
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
| 75 |
+
|
| 76 |
+
const DialogDescription = React.forwardRef<
|
| 77 |
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
| 78 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
| 79 |
+
>(({ className, ...props }, ref) => (
|
| 80 |
+
<DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
| 81 |
+
));
|
| 82 |
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
| 83 |
+
|
| 84 |
+
export {
|
| 85 |
+
Dialog,
|
| 86 |
+
DialogPortal,
|
| 87 |
+
DialogOverlay,
|
| 88 |
+
DialogClose,
|
| 89 |
+
DialogTrigger,
|
| 90 |
+
DialogContent,
|
| 91 |
+
DialogHeader,
|
| 92 |
+
DialogFooter,
|
| 93 |
+
DialogTitle,
|
| 94 |
+
DialogDescription,
|
| 95 |
+
};
|
src/components/ui/drawer.tsx
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { Drawer as DrawerPrimitive } from "vaul";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
| 7 |
+
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
| 8 |
+
);
|
| 9 |
+
Drawer.displayName = "Drawer";
|
| 10 |
+
|
| 11 |
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
| 12 |
+
|
| 13 |
+
const DrawerPortal = DrawerPrimitive.Portal;
|
| 14 |
+
|
| 15 |
+
const DrawerClose = DrawerPrimitive.Close;
|
| 16 |
+
|
| 17 |
+
const DrawerOverlay = React.forwardRef<
|
| 18 |
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
| 19 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
| 20 |
+
>(({ className, ...props }, ref) => (
|
| 21 |
+
<DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
|
| 22 |
+
));
|
| 23 |
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
| 24 |
+
|
| 25 |
+
const DrawerContent = React.forwardRef<
|
| 26 |
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
| 27 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
| 28 |
+
>(({ className, children, ...props }, ref) => (
|
| 29 |
+
<DrawerPortal>
|
| 30 |
+
<DrawerOverlay />
|
| 31 |
+
<DrawerPrimitive.Content
|
| 32 |
+
ref={ref}
|
| 33 |
+
className={cn(
|
| 34 |
+
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
|
| 35 |
+
className,
|
| 36 |
+
)}
|
| 37 |
+
{...props}
|
| 38 |
+
>
|
| 39 |
+
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
| 40 |
+
{children}
|
| 41 |
+
</DrawerPrimitive.Content>
|
| 42 |
+
</DrawerPortal>
|
| 43 |
+
));
|
| 44 |
+
DrawerContent.displayName = "DrawerContent";
|
| 45 |
+
|
| 46 |
+
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 47 |
+
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
| 48 |
+
);
|
| 49 |
+
DrawerHeader.displayName = "DrawerHeader";
|
| 50 |
+
|
| 51 |
+
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 52 |
+
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
| 53 |
+
);
|
| 54 |
+
DrawerFooter.displayName = "DrawerFooter";
|
| 55 |
+
|
| 56 |
+
const DrawerTitle = React.forwardRef<
|
| 57 |
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
| 58 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
| 59 |
+
>(({ className, ...props }, ref) => (
|
| 60 |
+
<DrawerPrimitive.Title
|
| 61 |
+
ref={ref}
|
| 62 |
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
| 63 |
+
{...props}
|
| 64 |
+
/>
|
| 65 |
+
));
|
| 66 |
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
| 67 |
+
|
| 68 |
+
const DrawerDescription = React.forwardRef<
|
| 69 |
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
| 70 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
| 71 |
+
>(({ className, ...props }, ref) => (
|
| 72 |
+
<DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
| 73 |
+
));
|
| 74 |
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
| 75 |
+
|
| 76 |
+
export {
|
| 77 |
+
Drawer,
|
| 78 |
+
DrawerPortal,
|
| 79 |
+
DrawerOverlay,
|
| 80 |
+
DrawerTrigger,
|
| 81 |
+
DrawerClose,
|
| 82 |
+
DrawerContent,
|
| 83 |
+
DrawerHeader,
|
| 84 |
+
DrawerFooter,
|
| 85 |
+
DrawerTitle,
|
| 86 |
+
DrawerDescription,
|
| 87 |
+
};
|
src/components/ui/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
| 3 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
| 12 |
+
|
| 13 |
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
| 14 |
+
|
| 15 |
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
| 16 |
+
|
| 17 |
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
| 18 |
+
|
| 19 |
+
const DropdownMenuSubTrigger = React.forwardRef<
|
| 20 |
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
| 21 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 22 |
+
inset?: boolean;
|
| 23 |
+
}
|
| 24 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 25 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 26 |
+
ref={ref}
|
| 27 |
+
className={cn(
|
| 28 |
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",
|
| 29 |
+
inset && "pl-8",
|
| 30 |
+
className,
|
| 31 |
+
)}
|
| 32 |
+
{...props}
|
| 33 |
+
>
|
| 34 |
+
{children}
|
| 35 |
+
<ChevronRight className="ml-auto h-4 w-4" />
|
| 36 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 37 |
+
));
|
| 38 |
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
| 39 |
+
|
| 40 |
+
const DropdownMenuSubContent = React.forwardRef<
|
| 41 |
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
| 42 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
| 43 |
+
>(({ className, ...props }, ref) => (
|
| 44 |
+
<DropdownMenuPrimitive.SubContent
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
|
| 48 |
+
className,
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
));
|
| 53 |
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
| 54 |
+
|
| 55 |
+
const DropdownMenuContent = React.forwardRef<
|
| 56 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
| 57 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
| 58 |
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
| 59 |
+
<DropdownMenuPrimitive.Portal>
|
| 60 |
+
<DropdownMenuPrimitive.Content
|
| 61 |
+
ref={ref}
|
| 62 |
+
sideOffset={sideOffset}
|
| 63 |
+
className={cn(
|
| 64 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
|
| 65 |
+
className,
|
| 66 |
+
)}
|
| 67 |
+
{...props}
|
| 68 |
+
/>
|
| 69 |
+
</DropdownMenuPrimitive.Portal>
|
| 70 |
+
));
|
| 71 |
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
| 72 |
+
|
| 73 |
+
const DropdownMenuItem = React.forwardRef<
|
| 74 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
| 75 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
| 76 |
+
inset?: boolean;
|
| 77 |
+
}
|
| 78 |
+
>(({ className, inset, ...props }, ref) => (
|
| 79 |
+
<DropdownMenuPrimitive.Item
|
| 80 |
+
ref={ref}
|
| 81 |
+
className={cn(
|
| 82 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 83 |
+
inset && "pl-8",
|
| 84 |
+
className,
|
| 85 |
+
)}
|
| 86 |
+
{...props}
|
| 87 |
+
/>
|
| 88 |
+
));
|
| 89 |
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
| 90 |
+
|
| 91 |
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
| 92 |
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
| 93 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
| 94 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 95 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 96 |
+
ref={ref}
|
| 97 |
+
className={cn(
|
| 98 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 99 |
+
className,
|
| 100 |
+
)}
|
| 101 |
+
checked={checked}
|
| 102 |
+
{...props}
|
| 103 |
+
>
|
| 104 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 105 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 106 |
+
<Check className="h-4 w-4" />
|
| 107 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 108 |
+
</span>
|
| 109 |
+
{children}
|
| 110 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 111 |
+
));
|
| 112 |
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
| 113 |
+
|
| 114 |
+
const DropdownMenuRadioItem = React.forwardRef<
|
| 115 |
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
| 116 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
| 117 |
+
>(({ className, children, ...props }, ref) => (
|
| 118 |
+
<DropdownMenuPrimitive.RadioItem
|
| 119 |
+
ref={ref}
|
| 120 |
+
className={cn(
|
| 121 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 122 |
+
className,
|
| 123 |
+
)}
|
| 124 |
+
{...props}
|
| 125 |
+
>
|
| 126 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 127 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 128 |
+
<Circle className="h-2 w-2 fill-current" />
|
| 129 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 130 |
+
</span>
|
| 131 |
+
{children}
|
| 132 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 133 |
+
));
|
| 134 |
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
| 135 |
+
|
| 136 |
+
const DropdownMenuLabel = React.forwardRef<
|
| 137 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
| 138 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
| 139 |
+
inset?: boolean;
|
| 140 |
+
}
|
| 141 |
+
>(({ className, inset, ...props }, ref) => (
|
| 142 |
+
<DropdownMenuPrimitive.Label
|
| 143 |
+
ref={ref}
|
| 144 |
+
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
| 145 |
+
{...props}
|
| 146 |
+
/>
|
| 147 |
+
));
|
| 148 |
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
| 149 |
+
|
| 150 |
+
const DropdownMenuSeparator = React.forwardRef<
|
| 151 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
| 152 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
| 153 |
+
>(({ className, ...props }, ref) => (
|
| 154 |
+
<DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
| 155 |
+
));
|
| 156 |
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
| 157 |
+
|
| 158 |
+
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 159 |
+
return <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />;
|
| 160 |
+
};
|
| 161 |
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
| 162 |
+
|
| 163 |
+
export {
|
| 164 |
+
DropdownMenu,
|
| 165 |
+
DropdownMenuTrigger,
|
| 166 |
+
DropdownMenuContent,
|
| 167 |
+
DropdownMenuItem,
|
| 168 |
+
DropdownMenuCheckboxItem,
|
| 169 |
+
DropdownMenuRadioItem,
|
| 170 |
+
DropdownMenuLabel,
|
| 171 |
+
DropdownMenuSeparator,
|
| 172 |
+
DropdownMenuShortcut,
|
| 173 |
+
DropdownMenuGroup,
|
| 174 |
+
DropdownMenuPortal,
|
| 175 |
+
DropdownMenuSub,
|
| 176 |
+
DropdownMenuSubContent,
|
| 177 |
+
DropdownMenuSubTrigger,
|
| 178 |
+
DropdownMenuRadioGroup,
|
| 179 |
+
};
|
src/components/ui/form.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
| 3 |
+
import { Slot } from "@radix-ui/react-slot";
|
| 4 |
+
import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from "react-hook-form";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
import { Label } from "@/components/ui/label";
|
| 8 |
+
|
| 9 |
+
const Form = FormProvider;
|
| 10 |
+
|
| 11 |
+
type FormFieldContextValue<
|
| 12 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 13 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 14 |
+
> = {
|
| 15 |
+
name: TName;
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
|
| 19 |
+
|
| 20 |
+
const FormField = <
|
| 21 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 22 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 23 |
+
>({
|
| 24 |
+
...props
|
| 25 |
+
}: ControllerProps<TFieldValues, TName>) => {
|
| 26 |
+
return (
|
| 27 |
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
| 28 |
+
<Controller {...props} />
|
| 29 |
+
</FormFieldContext.Provider>
|
| 30 |
+
);
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
const useFormField = () => {
|
| 34 |
+
const fieldContext = React.useContext(FormFieldContext);
|
| 35 |
+
const itemContext = React.useContext(FormItemContext);
|
| 36 |
+
const { getFieldState, formState } = useFormContext();
|
| 37 |
+
|
| 38 |
+
const fieldState = getFieldState(fieldContext.name, formState);
|
| 39 |
+
|
| 40 |
+
if (!fieldContext) {
|
| 41 |
+
throw new Error("useFormField should be used within <FormField>");
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
const { id } = itemContext;
|
| 45 |
+
|
| 46 |
+
return {
|
| 47 |
+
id,
|
| 48 |
+
name: fieldContext.name,
|
| 49 |
+
formItemId: `${id}-form-item`,
|
| 50 |
+
formDescriptionId: `${id}-form-item-description`,
|
| 51 |
+
formMessageId: `${id}-form-item-message`,
|
| 52 |
+
...fieldState,
|
| 53 |
+
};
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
type FormItemContextValue = {
|
| 57 |
+
id: string;
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
|
| 61 |
+
|
| 62 |
+
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 63 |
+
({ className, ...props }, ref) => {
|
| 64 |
+
const id = React.useId();
|
| 65 |
+
|
| 66 |
+
return (
|
| 67 |
+
<FormItemContext.Provider value={{ id }}>
|
| 68 |
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
| 69 |
+
</FormItemContext.Provider>
|
| 70 |
+
);
|
| 71 |
+
},
|
| 72 |
+
);
|
| 73 |
+
FormItem.displayName = "FormItem";
|
| 74 |
+
|
| 75 |
+
const FormLabel = React.forwardRef<
|
| 76 |
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
| 77 |
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
| 78 |
+
>(({ className, ...props }, ref) => {
|
| 79 |
+
const { error, formItemId } = useFormField();
|
| 80 |
+
|
| 81 |
+
return <Label ref={ref} className={cn(error && "text-destructive", className)} htmlFor={formItemId} {...props} />;
|
| 82 |
+
});
|
| 83 |
+
FormLabel.displayName = "FormLabel";
|
| 84 |
+
|
| 85 |
+
const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
|
| 86 |
+
({ ...props }, ref) => {
|
| 87 |
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
| 88 |
+
|
| 89 |
+
return (
|
| 90 |
+
<Slot
|
| 91 |
+
ref={ref}
|
| 92 |
+
id={formItemId}
|
| 93 |
+
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
|
| 94 |
+
aria-invalid={!!error}
|
| 95 |
+
{...props}
|
| 96 |
+
/>
|
| 97 |
+
);
|
| 98 |
+
},
|
| 99 |
+
);
|
| 100 |
+
FormControl.displayName = "FormControl";
|
| 101 |
+
|
| 102 |
+
const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
| 103 |
+
({ className, ...props }, ref) => {
|
| 104 |
+
const { formDescriptionId } = useFormField();
|
| 105 |
+
|
| 106 |
+
return <p ref={ref} id={formDescriptionId} className={cn("text-sm text-muted-foreground", className)} {...props} />;
|
| 107 |
+
},
|
| 108 |
+
);
|
| 109 |
+
FormDescription.displayName = "FormDescription";
|
| 110 |
+
|
| 111 |
+
const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
| 112 |
+
({ className, children, ...props }, ref) => {
|
| 113 |
+
const { error, formMessageId } = useFormField();
|
| 114 |
+
const body = error ? String(error?.message) : children;
|
| 115 |
+
|
| 116 |
+
if (!body) {
|
| 117 |
+
return null;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
return (
|
| 121 |
+
<p ref={ref} id={formMessageId} className={cn("text-sm font-medium text-destructive", className)} {...props}>
|
| 122 |
+
{body}
|
| 123 |
+
</p>
|
| 124 |
+
);
|
| 125 |
+
},
|
| 126 |
+
);
|
| 127 |
+
FormMessage.displayName = "FormMessage";
|
| 128 |
+
|
| 129 |
+
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };
|
src/components/ui/hover-card.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const HoverCard = HoverCardPrimitive.Root;
|
| 7 |
+
|
| 8 |
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
| 9 |
+
|
| 10 |
+
const HoverCardContent = React.forwardRef<
|
| 11 |
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
| 12 |
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
| 13 |
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
| 14 |
+
<HoverCardPrimitive.Content
|
| 15 |
+
ref={ref}
|
| 16 |
+
align={align}
|
| 17 |
+
sideOffset={sideOffset}
|
| 18 |
+
className={cn(
|
| 19 |
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
|
| 20 |
+
className,
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
/>
|
| 24 |
+
));
|
| 25 |
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
| 26 |
+
|
| 27 |
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
src/components/ui/input-otp.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { OTPInput, OTPInputContext } from "input-otp";
|
| 3 |
+
import { Dot } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const InputOTP = React.forwardRef<React.ElementRef<typeof OTPInput>, React.ComponentPropsWithoutRef<typeof OTPInput>>(
|
| 8 |
+
({ className, containerClassName, ...props }, ref) => (
|
| 9 |
+
<OTPInput
|
| 10 |
+
ref={ref}
|
| 11 |
+
containerClassName={cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName)}
|
| 12 |
+
className={cn("disabled:cursor-not-allowed", className)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
),
|
| 16 |
+
);
|
| 17 |
+
InputOTP.displayName = "InputOTP";
|
| 18 |
+
|
| 19 |
+
const InputOTPGroup = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
|
| 20 |
+
({ className, ...props }, ref) => <div ref={ref} className={cn("flex items-center", className)} {...props} />,
|
| 21 |
+
);
|
| 22 |
+
InputOTPGroup.displayName = "InputOTPGroup";
|
| 23 |
+
|
| 24 |
+
const InputOTPSlot = React.forwardRef<
|
| 25 |
+
React.ElementRef<"div">,
|
| 26 |
+
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
| 27 |
+
>(({ index, className, ...props }, ref) => {
|
| 28 |
+
const inputOTPContext = React.useContext(OTPInputContext);
|
| 29 |
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
| 30 |
+
|
| 31 |
+
return (
|
| 32 |
+
<div
|
| 33 |
+
ref={ref}
|
| 34 |
+
className={cn(
|
| 35 |
+
"relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
|
| 36 |
+
isActive && "z-10 ring-2 ring-ring ring-offset-background",
|
| 37 |
+
className,
|
| 38 |
+
)}
|
| 39 |
+
{...props}
|
| 40 |
+
>
|
| 41 |
+
{char}
|
| 42 |
+
{hasFakeCaret && (
|
| 43 |
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 44 |
+
<div className="animate-caret-blink h-4 w-px bg-foreground duration-1000" />
|
| 45 |
+
</div>
|
| 46 |
+
)}
|
| 47 |
+
</div>
|
| 48 |
+
);
|
| 49 |
+
});
|
| 50 |
+
InputOTPSlot.displayName = "InputOTPSlot";
|
| 51 |
+
|
| 52 |
+
const InputOTPSeparator = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
|
| 53 |
+
({ ...props }, ref) => (
|
| 54 |
+
<div ref={ref} role="separator" {...props}>
|
| 55 |
+
<Dot />
|
| 56 |
+
</div>
|
| 57 |
+
),
|
| 58 |
+
);
|
| 59 |
+
InputOTPSeparator.displayName = "InputOTPSeparator";
|
| 60 |
+
|
| 61 |
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
src/components/ui/input.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils";
|
| 4 |
+
|
| 5 |
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
| 6 |
+
({ className, type, ...props }, ref) => {
|
| 7 |
+
return (
|
| 8 |
+
<input
|
| 9 |
+
type={type}
|
| 10 |
+
className={cn(
|
| 11 |
+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
| 12 |
+
className,
|
| 13 |
+
)}
|
| 14 |
+
ref={ref}
|
| 15 |
+
{...props}
|
| 16 |
+
/>
|
| 17 |
+
);
|
| 18 |
+
},
|
| 19 |
+
);
|
| 20 |
+
Input.displayName = "Input";
|
| 21 |
+
|
| 22 |
+
export { Input };
|
src/components/ui/label.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
| 3 |
+
import { cva, type VariantProps } from "class-variance-authority";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
| 8 |
+
|
| 9 |
+
const Label = React.forwardRef<
|
| 10 |
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
| 11 |
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
| 12 |
+
>(({ className, ...props }, ref) => (
|
| 13 |
+
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
| 14 |
+
));
|
| 15 |
+
Label.displayName = LabelPrimitive.Root.displayName;
|
| 16 |
+
|
| 17 |
+
export { Label };
|
src/components/ui/menubar.tsx
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
| 3 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const MenubarMenu = MenubarPrimitive.Menu;
|
| 8 |
+
|
| 9 |
+
const MenubarGroup = MenubarPrimitive.Group;
|
| 10 |
+
|
| 11 |
+
const MenubarPortal = MenubarPrimitive.Portal;
|
| 12 |
+
|
| 13 |
+
const MenubarSub = MenubarPrimitive.Sub;
|
| 14 |
+
|
| 15 |
+
const MenubarRadioGroup = MenubarPrimitive.RadioGroup;
|
| 16 |
+
|
| 17 |
+
const Menubar = React.forwardRef<
|
| 18 |
+
React.ElementRef<typeof MenubarPrimitive.Root>,
|
| 19 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
| 20 |
+
>(({ className, ...props }, ref) => (
|
| 21 |
+
<MenubarPrimitive.Root
|
| 22 |
+
ref={ref}
|
| 23 |
+
className={cn("flex h-10 items-center space-x-1 rounded-md border bg-background p-1", className)}
|
| 24 |
+
{...props}
|
| 25 |
+
/>
|
| 26 |
+
));
|
| 27 |
+
Menubar.displayName = MenubarPrimitive.Root.displayName;
|
| 28 |
+
|
| 29 |
+
const MenubarTrigger = React.forwardRef<
|
| 30 |
+
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
| 31 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
| 32 |
+
>(({ className, ...props }, ref) => (
|
| 33 |
+
<MenubarPrimitive.Trigger
|
| 34 |
+
ref={ref}
|
| 35 |
+
className={cn(
|
| 36 |
+
"flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
| 37 |
+
className,
|
| 38 |
+
)}
|
| 39 |
+
{...props}
|
| 40 |
+
/>
|
| 41 |
+
));
|
| 42 |
+
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName;
|
| 43 |
+
|
| 44 |
+
const MenubarSubTrigger = React.forwardRef<
|
| 45 |
+
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
| 46 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
|
| 47 |
+
inset?: boolean;
|
| 48 |
+
}
|
| 49 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 50 |
+
<MenubarPrimitive.SubTrigger
|
| 51 |
+
ref={ref}
|
| 52 |
+
className={cn(
|
| 53 |
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
| 54 |
+
inset && "pl-8",
|
| 55 |
+
className,
|
| 56 |
+
)}
|
| 57 |
+
{...props}
|
| 58 |
+
>
|
| 59 |
+
{children}
|
| 60 |
+
<ChevronRight className="ml-auto h-4 w-4" />
|
| 61 |
+
</MenubarPrimitive.SubTrigger>
|
| 62 |
+
));
|
| 63 |
+
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName;
|
| 64 |
+
|
| 65 |
+
const MenubarSubContent = React.forwardRef<
|
| 66 |
+
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
| 67 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
| 68 |
+
>(({ className, ...props }, ref) => (
|
| 69 |
+
<MenubarPrimitive.SubContent
|
| 70 |
+
ref={ref}
|
| 71 |
+
className={cn(
|
| 72 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",
|
| 73 |
+
className,
|
| 74 |
+
)}
|
| 75 |
+
{...props}
|
| 76 |
+
/>
|
| 77 |
+
));
|
| 78 |
+
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName;
|
| 79 |
+
|
| 80 |
+
const MenubarContent = React.forwardRef<
|
| 81 |
+
React.ElementRef<typeof MenubarPrimitive.Content>,
|
| 82 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
| 83 |
+
>(({ className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref) => (
|
| 84 |
+
<MenubarPrimitive.Portal>
|
| 85 |
+
<MenubarPrimitive.Content
|
| 86 |
+
ref={ref}
|
| 87 |
+
align={align}
|
| 88 |
+
alignOffset={alignOffset}
|
| 89 |
+
sideOffset={sideOffset}
|
| 90 |
+
className={cn(
|
| 91 |
+
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
|
| 92 |
+
className,
|
| 93 |
+
)}
|
| 94 |
+
{...props}
|
| 95 |
+
/>
|
| 96 |
+
</MenubarPrimitive.Portal>
|
| 97 |
+
));
|
| 98 |
+
MenubarContent.displayName = MenubarPrimitive.Content.displayName;
|
| 99 |
+
|
| 100 |
+
const MenubarItem = React.forwardRef<
|
| 101 |
+
React.ElementRef<typeof MenubarPrimitive.Item>,
|
| 102 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
|
| 103 |
+
inset?: boolean;
|
| 104 |
+
}
|
| 105 |
+
>(({ className, inset, ...props }, ref) => (
|
| 106 |
+
<MenubarPrimitive.Item
|
| 107 |
+
ref={ref}
|
| 108 |
+
className={cn(
|
| 109 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 110 |
+
inset && "pl-8",
|
| 111 |
+
className,
|
| 112 |
+
)}
|
| 113 |
+
{...props}
|
| 114 |
+
/>
|
| 115 |
+
));
|
| 116 |
+
MenubarItem.displayName = MenubarPrimitive.Item.displayName;
|
| 117 |
+
|
| 118 |
+
const MenubarCheckboxItem = React.forwardRef<
|
| 119 |
+
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
| 120 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
|
| 121 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 122 |
+
<MenubarPrimitive.CheckboxItem
|
| 123 |
+
ref={ref}
|
| 124 |
+
className={cn(
|
| 125 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 126 |
+
className,
|
| 127 |
+
)}
|
| 128 |
+
checked={checked}
|
| 129 |
+
{...props}
|
| 130 |
+
>
|
| 131 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 132 |
+
<MenubarPrimitive.ItemIndicator>
|
| 133 |
+
<Check className="h-4 w-4" />
|
| 134 |
+
</MenubarPrimitive.ItemIndicator>
|
| 135 |
+
</span>
|
| 136 |
+
{children}
|
| 137 |
+
</MenubarPrimitive.CheckboxItem>
|
| 138 |
+
));
|
| 139 |
+
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName;
|
| 140 |
+
|
| 141 |
+
const MenubarRadioItem = React.forwardRef<
|
| 142 |
+
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
| 143 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
|
| 144 |
+
>(({ className, children, ...props }, ref) => (
|
| 145 |
+
<MenubarPrimitive.RadioItem
|
| 146 |
+
ref={ref}
|
| 147 |
+
className={cn(
|
| 148 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
| 149 |
+
className,
|
| 150 |
+
)}
|
| 151 |
+
{...props}
|
| 152 |
+
>
|
| 153 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 154 |
+
<MenubarPrimitive.ItemIndicator>
|
| 155 |
+
<Circle className="h-2 w-2 fill-current" />
|
| 156 |
+
</MenubarPrimitive.ItemIndicator>
|
| 157 |
+
</span>
|
| 158 |
+
{children}
|
| 159 |
+
</MenubarPrimitive.RadioItem>
|
| 160 |
+
));
|
| 161 |
+
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName;
|
| 162 |
+
|
| 163 |
+
const MenubarLabel = React.forwardRef<
|
| 164 |
+
React.ElementRef<typeof MenubarPrimitive.Label>,
|
| 165 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
|
| 166 |
+
inset?: boolean;
|
| 167 |
+
}
|
| 168 |
+
>(({ className, inset, ...props }, ref) => (
|
| 169 |
+
<MenubarPrimitive.Label
|
| 170 |
+
ref={ref}
|
| 171 |
+
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
| 172 |
+
{...props}
|
| 173 |
+
/>
|
| 174 |
+
));
|
| 175 |
+
MenubarLabel.displayName = MenubarPrimitive.Label.displayName;
|
| 176 |
+
|
| 177 |
+
const MenubarSeparator = React.forwardRef<
|
| 178 |
+
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
| 179 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
| 180 |
+
>(({ className, ...props }, ref) => (
|
| 181 |
+
<MenubarPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
| 182 |
+
));
|
| 183 |
+
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName;
|
| 184 |
+
|
| 185 |
+
const MenubarShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 186 |
+
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
| 187 |
+
};
|
| 188 |
+
MenubarShortcut.displayname = "MenubarShortcut";
|
| 189 |
+
|
| 190 |
+
export {
|
| 191 |
+
Menubar,
|
| 192 |
+
MenubarMenu,
|
| 193 |
+
MenubarTrigger,
|
| 194 |
+
MenubarContent,
|
| 195 |
+
MenubarItem,
|
| 196 |
+
MenubarSeparator,
|
| 197 |
+
MenubarLabel,
|
| 198 |
+
MenubarCheckboxItem,
|
| 199 |
+
MenubarRadioGroup,
|
| 200 |
+
MenubarRadioItem,
|
| 201 |
+
MenubarPortal,
|
| 202 |
+
MenubarSubContent,
|
| 203 |
+
MenubarSubTrigger,
|
| 204 |
+
MenubarGroup,
|
| 205 |
+
MenubarSub,
|
| 206 |
+
MenubarShortcut,
|
| 207 |
+
};
|
src/components/ui/navigation-menu.tsx
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 { ChevronDown } from "lucide-react";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
|
| 8 |
+
const NavigationMenu = React.forwardRef<
|
| 9 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
| 10 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
| 11 |
+
>(({ className, children, ...props }, ref) => (
|
| 12 |
+
<NavigationMenuPrimitive.Root
|
| 13 |
+
ref={ref}
|
| 14 |
+
className={cn("relative z-10 flex max-w-max flex-1 items-center justify-center", className)}
|
| 15 |
+
{...props}
|
| 16 |
+
>
|
| 17 |
+
{children}
|
| 18 |
+
<NavigationMenuViewport />
|
| 19 |
+
</NavigationMenuPrimitive.Root>
|
| 20 |
+
));
|
| 21 |
+
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
| 22 |
+
|
| 23 |
+
const NavigationMenuList = React.forwardRef<
|
| 24 |
+
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
| 25 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
| 26 |
+
>(({ className, ...props }, ref) => (
|
| 27 |
+
<NavigationMenuPrimitive.List
|
| 28 |
+
ref={ref}
|
| 29 |
+
className={cn("group flex flex-1 list-none items-center justify-center space-x-1", className)}
|
| 30 |
+
{...props}
|
| 31 |
+
/>
|
| 32 |
+
));
|
| 33 |
+
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
| 34 |
+
|
| 35 |
+
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
| 36 |
+
|
| 37 |
+
const navigationMenuTriggerStyle = cva(
|
| 38 |
+
"group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
const NavigationMenuTrigger = React.forwardRef<
|
| 42 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
| 43 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
| 44 |
+
>(({ className, children, ...props }, ref) => (
|
| 45 |
+
<NavigationMenuPrimitive.Trigger
|
| 46 |
+
ref={ref}
|
| 47 |
+
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
| 48 |
+
{...props}
|
| 49 |
+
>
|
| 50 |
+
{children}{" "}
|
| 51 |
+
<ChevronDown
|
| 52 |
+
className="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180"
|
| 53 |
+
aria-hidden="true"
|
| 54 |
+
/>
|
| 55 |
+
</NavigationMenuPrimitive.Trigger>
|
| 56 |
+
));
|
| 57 |
+
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
| 58 |
+
|
| 59 |
+
const NavigationMenuContent = React.forwardRef<
|
| 60 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
| 61 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
| 62 |
+
>(({ className, ...props }, ref) => (
|
| 63 |
+
<NavigationMenuPrimitive.Content
|
| 64 |
+
ref={ref}
|
| 65 |
+
className={cn(
|
| 66 |
+
"left-0 top-0 w-full 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 md:absolute md:w-auto",
|
| 67 |
+
className,
|
| 68 |
+
)}
|
| 69 |
+
{...props}
|
| 70 |
+
/>
|
| 71 |
+
));
|
| 72 |
+
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
| 73 |
+
|
| 74 |
+
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
| 75 |
+
|
| 76 |
+
const NavigationMenuViewport = React.forwardRef<
|
| 77 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
| 78 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
| 79 |
+
>(({ className, ...props }, ref) => (
|
| 80 |
+
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
| 81 |
+
<NavigationMenuPrimitive.Viewport
|
| 82 |
+
className={cn(
|
| 83 |
+
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
| 84 |
+
className,
|
| 85 |
+
)}
|
| 86 |
+
ref={ref}
|
| 87 |
+
{...props}
|
| 88 |
+
/>
|
| 89 |
+
</div>
|
| 90 |
+
));
|
| 91 |
+
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
| 92 |
+
|
| 93 |
+
const NavigationMenuIndicator = React.forwardRef<
|
| 94 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
| 95 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
| 96 |
+
>(({ className, ...props }, ref) => (
|
| 97 |
+
<NavigationMenuPrimitive.Indicator
|
| 98 |
+
ref={ref}
|
| 99 |
+
className={cn(
|
| 100 |
+
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
|
| 101 |
+
className,
|
| 102 |
+
)}
|
| 103 |
+
{...props}
|
| 104 |
+
>
|
| 105 |
+
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
| 106 |
+
</NavigationMenuPrimitive.Indicator>
|
| 107 |
+
));
|
| 108 |
+
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
| 109 |
+
|
| 110 |
+
export {
|
| 111 |
+
navigationMenuTriggerStyle,
|
| 112 |
+
NavigationMenu,
|
| 113 |
+
NavigationMenuList,
|
| 114 |
+
NavigationMenuItem,
|
| 115 |
+
NavigationMenuContent,
|
| 116 |
+
NavigationMenuTrigger,
|
| 117 |
+
NavigationMenuLink,
|
| 118 |
+
NavigationMenuIndicator,
|
| 119 |
+
NavigationMenuViewport,
|
| 120 |
+
};
|
src/components/ui/pagination.tsx
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
import { ButtonProps, buttonVariants } from "@/components/ui/button";
|
| 6 |
+
|
| 7 |
+
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
| 8 |
+
<nav
|
| 9 |
+
role="navigation"
|
| 10 |
+
aria-label="pagination"
|
| 11 |
+
className={cn("mx-auto flex w-full justify-center", className)}
|
| 12 |
+
{...props}
|
| 13 |
+
/>
|
| 14 |
+
);
|
| 15 |
+
Pagination.displayName = "Pagination";
|
| 16 |
+
|
| 17 |
+
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
|
| 18 |
+
({ className, ...props }, ref) => (
|
| 19 |
+
<ul ref={ref} className={cn("flex flex-row items-center gap-1", className)} {...props} />
|
| 20 |
+
),
|
| 21 |
+
);
|
| 22 |
+
PaginationContent.displayName = "PaginationContent";
|
| 23 |
+
|
| 24 |
+
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
|
| 25 |
+
<li ref={ref} className={cn("", className)} {...props} />
|
| 26 |
+
));
|
| 27 |
+
PaginationItem.displayName = "PaginationItem";
|
| 28 |
+
|
| 29 |
+
type PaginationLinkProps = {
|
| 30 |
+
isActive?: boolean;
|
| 31 |
+
} & Pick<ButtonProps, "size"> &
|
| 32 |
+
React.ComponentProps<"a">;
|
| 33 |
+
|
| 34 |
+
const PaginationLink = ({ className, isActive, size = "icon", ...props }: PaginationLinkProps) => (
|
| 35 |
+
<a
|
| 36 |
+
aria-current={isActive ? "page" : undefined}
|
| 37 |
+
className={cn(
|
| 38 |
+
buttonVariants({
|
| 39 |
+
variant: isActive ? "outline" : "ghost",
|
| 40 |
+
size,
|
| 41 |
+
}),
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
);
|
| 47 |
+
PaginationLink.displayName = "PaginationLink";
|
| 48 |
+
|
| 49 |
+
const PaginationPrevious = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
| 50 |
+
<PaginationLink aria-label="Go to previous page" size="default" className={cn("gap-1 pl-2.5", className)} {...props}>
|
| 51 |
+
<ChevronLeft className="h-4 w-4" />
|
| 52 |
+
<span>Previous</span>
|
| 53 |
+
</PaginationLink>
|
| 54 |
+
);
|
| 55 |
+
PaginationPrevious.displayName = "PaginationPrevious";
|
| 56 |
+
|
| 57 |
+
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
| 58 |
+
<PaginationLink aria-label="Go to next page" size="default" className={cn("gap-1 pr-2.5", className)} {...props}>
|
| 59 |
+
<span>Next</span>
|
| 60 |
+
<ChevronRight className="h-4 w-4" />
|
| 61 |
+
</PaginationLink>
|
| 62 |
+
);
|
| 63 |
+
PaginationNext.displayName = "PaginationNext";
|
| 64 |
+
|
| 65 |
+
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
| 66 |
+
<span aria-hidden className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
|
| 67 |
+
<MoreHorizontal className="h-4 w-4" />
|
| 68 |
+
<span className="sr-only">More pages</span>
|
| 69 |
+
</span>
|
| 70 |
+
);
|
| 71 |
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
| 72 |
+
|
| 73 |
+
export {
|
| 74 |
+
Pagination,
|
| 75 |
+
PaginationContent,
|
| 76 |
+
PaginationEllipsis,
|
| 77 |
+
PaginationItem,
|
| 78 |
+
PaginationLink,
|
| 79 |
+
PaginationNext,
|
| 80 |
+
PaginationPrevious,
|
| 81 |
+
};
|
src/components/ui/popover.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const Popover = PopoverPrimitive.Root;
|
| 7 |
+
|
| 8 |
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
| 9 |
+
|
| 10 |
+
const PopoverContent = React.forwardRef<
|
| 11 |
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
| 12 |
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
| 13 |
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
| 14 |
+
<PopoverPrimitive.Portal>
|
| 15 |
+
<PopoverPrimitive.Content
|
| 16 |
+
ref={ref}
|
| 17 |
+
align={align}
|
| 18 |
+
sideOffset={sideOffset}
|
| 19 |
+
className={cn(
|
| 20 |
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
|
| 21 |
+
className,
|
| 22 |
+
)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
</PopoverPrimitive.Portal>
|
| 26 |
+
));
|
| 27 |
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
| 28 |
+
|
| 29 |
+
export { Popover, PopoverTrigger, PopoverContent };
|
src/components/ui/progress.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const Progress = React.forwardRef<
|
| 7 |
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
| 8 |
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
| 9 |
+
>(({ className, value, ...props }, ref) => (
|
| 10 |
+
<ProgressPrimitive.Root
|
| 11 |
+
ref={ref}
|
| 12 |
+
className={cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className)}
|
| 13 |
+
{...props}
|
| 14 |
+
>
|
| 15 |
+
<ProgressPrimitive.Indicator
|
| 16 |
+
className="h-full w-full flex-1 bg-primary transition-all"
|
| 17 |
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
| 18 |
+
/>
|
| 19 |
+
</ProgressPrimitive.Root>
|
| 20 |
+
));
|
| 21 |
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
| 22 |
+
|
| 23 |
+
export { Progress };
|
src/components/ui/radio-group.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
| 3 |
+
import { Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const RadioGroup = React.forwardRef<
|
| 8 |
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
| 9 |
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
| 10 |
+
>(({ className, ...props }, ref) => {
|
| 11 |
+
return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />;
|
| 12 |
+
});
|
| 13 |
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
| 14 |
+
|
| 15 |
+
const RadioGroupItem = React.forwardRef<
|
| 16 |
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
| 17 |
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
| 18 |
+
>(({ className, ...props }, ref) => {
|
| 19 |
+
return (
|
| 20 |
+
<RadioGroupPrimitive.Item
|
| 21 |
+
ref={ref}
|
| 22 |
+
className={cn(
|
| 23 |
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
| 24 |
+
className,
|
| 25 |
+
)}
|
| 26 |
+
{...props}
|
| 27 |
+
>
|
| 28 |
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
| 29 |
+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
| 30 |
+
</RadioGroupPrimitive.Indicator>
|
| 31 |
+
</RadioGroupPrimitive.Item>
|
| 32 |
+
);
|
| 33 |
+
});
|
| 34 |
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
| 35 |
+
|
| 36 |
+
export { RadioGroup, RadioGroupItem };
|
src/components/ui/resizable.tsx
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GripVertical } from "lucide-react";
|
| 2 |
+
import * as ResizablePrimitive from "react-resizable-panels";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const ResizablePanelGroup = ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
|
| 7 |
+
<ResizablePrimitive.PanelGroup
|
| 8 |
+
className={cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col", className)}
|
| 9 |
+
{...props}
|
| 10 |
+
/>
|
| 11 |
+
);
|
| 12 |
+
|
| 13 |
+
const ResizablePanel = ResizablePrimitive.Panel;
|
| 14 |
+
|
| 15 |
+
const ResizableHandle = ({
|
| 16 |
+
withHandle,
|
| 17 |
+
className,
|
| 18 |
+
...props
|
| 19 |
+
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
|
| 20 |
+
withHandle?: boolean;
|
| 21 |
+
}) => (
|
| 22 |
+
<ResizablePrimitive.PanelResizeHandle
|
| 23 |
+
className={cn(
|
| 24 |
+
"relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
| 25 |
+
className,
|
| 26 |
+
)}
|
| 27 |
+
{...props}
|
| 28 |
+
>
|
| 29 |
+
{withHandle && (
|
| 30 |
+
<div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
|
| 31 |
+
<GripVertical className="h-2.5 w-2.5" />
|
| 32 |
+
</div>
|
| 33 |
+
)}
|
| 34 |
+
</ResizablePrimitive.PanelResizeHandle>
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|