Commit
·
d328b13
1
Parent(s):
2977d7d
init
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +36 -0
- DEPLOYMENT.md +152 -0
- Dockerfile +44 -0
- README copy.md +109 -0
- README.md +4 -6
- app/globals.css +125 -0
- app/layout.tsx +36 -0
- app/page.tsx +5 -0
- components.json +21 -0
- components/dataset-atlas.tsx +597 -0
- components/dataset-statistics.tsx +297 -0
- components/scroll-to-top.tsx +49 -0
- components/site-footer.tsx +11 -0
- components/site-header.tsx +15 -0
- components/theme-provider.tsx +11 -0
- components/theme-toggle.tsx +33 -0
- components/ui/accordion.tsx +66 -0
- components/ui/alert-dialog.tsx +157 -0
- components/ui/alert.tsx +66 -0
- components/ui/aspect-ratio.tsx +11 -0
- components/ui/avatar.tsx +53 -0
- components/ui/badge.tsx +29 -0
- components/ui/breadcrumb.tsx +109 -0
- components/ui/button.tsx +60 -0
- components/ui/calendar.tsx +213 -0
- components/ui/card.tsx +92 -0
- components/ui/carousel.tsx +241 -0
- components/ui/chart.tsx +353 -0
- components/ui/checkbox.tsx +32 -0
- components/ui/collapsible.tsx +33 -0
- components/ui/command.tsx +184 -0
- components/ui/context-menu.tsx +252 -0
- components/ui/dialog.tsx +143 -0
- components/ui/drawer.tsx +135 -0
- components/ui/dropdown-menu.tsx +257 -0
- components/ui/form.tsx +167 -0
- components/ui/hover-card.tsx +44 -0
- components/ui/input-otp.tsx +77 -0
- components/ui/input.tsx +21 -0
- components/ui/label.tsx +24 -0
- components/ui/menubar.tsx +276 -0
- components/ui/navigation-menu.tsx +166 -0
- components/ui/pagination.tsx +127 -0
- components/ui/popover.tsx +48 -0
- components/ui/progress.tsx +31 -0
- components/ui/radio-group.tsx +45 -0
- components/ui/resizable.tsx +56 -0
- components/ui/scroll-area.tsx +58 -0
- components/ui/select.tsx +185 -0
- components/ui/separator.tsx +28 -0
.gitignore
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dependencies
|
| 2 |
+
node_modules/
|
| 3 |
+
/.pnp
|
| 4 |
+
.pnp.js
|
| 5 |
+
|
| 6 |
+
# Testing
|
| 7 |
+
/coverage
|
| 8 |
+
|
| 9 |
+
# Next.js
|
| 10 |
+
/.next/
|
| 11 |
+
/out/
|
| 12 |
+
|
| 13 |
+
# Production
|
| 14 |
+
/build
|
| 15 |
+
|
| 16 |
+
# Misc
|
| 17 |
+
.DS_Store
|
| 18 |
+
*.pem
|
| 19 |
+
|
| 20 |
+
# Debug
|
| 21 |
+
npm-debug.log*
|
| 22 |
+
yarn-debug.log*
|
| 23 |
+
yarn-error.log*
|
| 24 |
+
pnpm-debug.log*
|
| 25 |
+
|
| 26 |
+
# Local env files
|
| 27 |
+
.env*.local
|
| 28 |
+
.env
|
| 29 |
+
|
| 30 |
+
# Vercel
|
| 31 |
+
.vercel
|
| 32 |
+
|
| 33 |
+
# TypeScript
|
| 34 |
+
*.tsbuildinfo
|
| 35 |
+
next-env.d.ts
|
| 36 |
+
|
DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deployment Guide for Hugging Face Spaces
|
| 2 |
+
|
| 3 |
+
This guide explains how to deploy the Datasets Navigator app to Hugging Face Spaces using Docker.
|
| 4 |
+
|
| 5 |
+
## Prerequisites
|
| 6 |
+
|
| 7 |
+
- Docker installed and running (for local testing)
|
| 8 |
+
- Hugging Face account ([sign up here](https://huggingface.co/join))
|
| 9 |
+
|
| 10 |
+
## Files Created for Docker Deployment
|
| 11 |
+
|
| 12 |
+
- `Dockerfile` - Multi-stage Docker build configuration
|
| 13 |
+
- `.dockerignore` - Excludes unnecessary files from Docker build
|
| 14 |
+
- `docker-compose.yml` - For local testing
|
| 15 |
+
- `README.md` - Updated with HF Spaces metadata
|
| 16 |
+
- `next.config.mjs` - Updated with `output: 'standalone'` for Docker
|
| 17 |
+
|
| 18 |
+
## Local Testing (Optional)
|
| 19 |
+
|
| 20 |
+
Before deploying to Hugging Face Spaces, you can test the Docker build locally:
|
| 21 |
+
|
| 22 |
+
### Option 1: Using Docker directly
|
| 23 |
+
|
| 24 |
+
```bash
|
| 25 |
+
# Build the image
|
| 26 |
+
docker build -t datasets-navigator .
|
| 27 |
+
|
| 28 |
+
# Run the container
|
| 29 |
+
docker run -p 7860:7860 datasets-navigator
|
| 30 |
+
|
| 31 |
+
# Access the app at http://localhost:7860
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### Option 2: Using Docker Compose
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
# Build and run
|
| 38 |
+
docker-compose up --build
|
| 39 |
+
|
| 40 |
+
# Access the app at http://localhost:7860
|
| 41 |
+
|
| 42 |
+
# Stop with Ctrl+C, or in detached mode:
|
| 43 |
+
docker-compose down
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Deploying to Hugging Face Spaces
|
| 47 |
+
|
| 48 |
+
### Method 1: Via Hugging Face Web Interface
|
| 49 |
+
|
| 50 |
+
1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
|
| 51 |
+
2. Click "Create new Space"
|
| 52 |
+
3. Fill in the details:
|
| 53 |
+
- **Space name**: Choose a name (e.g., `datasets-navigator`)
|
| 54 |
+
- **License**: Select appropriate license
|
| 55 |
+
- **SDK**: Select "Docker"
|
| 56 |
+
- **Hardware**: Start with "CPU basic" (can upgrade later)
|
| 57 |
+
4. Clone the Space repository:
|
| 58 |
+
```bash
|
| 59 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
| 60 |
+
```
|
| 61 |
+
5. Copy all files from `datasets_navigator_app/` to the cloned repository
|
| 62 |
+
6. Push to Hugging Face:
|
| 63 |
+
```bash
|
| 64 |
+
cd YOUR_SPACE_NAME
|
| 65 |
+
git add .
|
| 66 |
+
git commit -m "Initial commit: Datasets Navigator app"
|
| 67 |
+
git push
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### Method 2: Push Existing Repository
|
| 71 |
+
|
| 72 |
+
If you already have a Space created:
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
# Add Hugging Face as a remote
|
| 76 |
+
cd datasets_navigator_app
|
| 77 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
| 78 |
+
|
| 79 |
+
# Push to Hugging Face
|
| 80 |
+
git add .
|
| 81 |
+
git commit -m "Deploy Datasets Navigator to HF Spaces"
|
| 82 |
+
git push hf main
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Configuration
|
| 86 |
+
|
| 87 |
+
The app is configured via `README.md` frontmatter:
|
| 88 |
+
|
| 89 |
+
```yaml
|
| 90 |
+
---
|
| 91 |
+
title: Prova
|
| 92 |
+
emoji: 🍽️
|
| 93 |
+
colorFrom: blue
|
| 94 |
+
colorTo: purple
|
| 95 |
+
sdk: docker
|
| 96 |
+
app_port: 7860
|
| 97 |
+
---
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
You can customize:
|
| 101 |
+
- `title`: The Space's display name
|
| 102 |
+
- `emoji`: Icon shown in the Space
|
| 103 |
+
- `colorFrom` / `colorTo`: Gradient colors for the Space card
|
| 104 |
+
- `app_port`: Must match the port in Dockerfile (7860)
|
| 105 |
+
|
| 106 |
+
## Environment Variables & Secrets
|
| 107 |
+
|
| 108 |
+
If your app needs environment variables or secrets:
|
| 109 |
+
|
| 110 |
+
1. Go to your Space settings on Hugging Face
|
| 111 |
+
2. Navigate to "Variables and secrets"
|
| 112 |
+
3. Add variables (public) or secrets (private)
|
| 113 |
+
|
| 114 |
+
They will be available as environment variables in the Docker container.
|
| 115 |
+
|
| 116 |
+
## Troubleshooting
|
| 117 |
+
|
| 118 |
+
### Build Fails
|
| 119 |
+
|
| 120 |
+
- Check the build logs in the Space's "Logs" tab
|
| 121 |
+
- Verify all dependencies are in `package.json`
|
| 122 |
+
- Ensure `package-lock.json` is committed
|
| 123 |
+
|
| 124 |
+
### App Won't Start
|
| 125 |
+
|
| 126 |
+
- Verify the app listens on `0.0.0.0:7860`
|
| 127 |
+
- Check the Docker logs for errors
|
| 128 |
+
- Ensure user permissions are correct (user ID 1000)
|
| 129 |
+
|
| 130 |
+
### Port Issues
|
| 131 |
+
|
| 132 |
+
- The app MUST listen on the port specified in `app_port` (7860)
|
| 133 |
+
- Verify `ENV PORT=7860` in Dockerfile
|
| 134 |
+
- Next.js reads the PORT environment variable automatically
|
| 135 |
+
|
| 136 |
+
## Upgrading Space Hardware
|
| 137 |
+
|
| 138 |
+
If you need more resources:
|
| 139 |
+
|
| 140 |
+
1. Go to Space settings
|
| 141 |
+
2. Select "Hardware" tab
|
| 142 |
+
3. Choose upgrade (CPU/GPU options available)
|
| 143 |
+
4. Confirm the upgrade
|
| 144 |
+
|
| 145 |
+
Note: GPU and upgraded hardware have associated costs.
|
| 146 |
+
|
| 147 |
+
## References
|
| 148 |
+
|
| 149 |
+
- [HF Spaces Docker Documentation](https://huggingface.co/docs/hub/spaces-sdks-docker)
|
| 150 |
+
- [Next.js Docker Documentation](https://nextjs.org/docs/app/building-your-application/deploying#docker-image)
|
| 151 |
+
- [Hugging Face Spaces Examples](https://huggingface.co/spaces)
|
| 152 |
+
|
Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Node.js 18 Alpine for a lightweight image
|
| 2 |
+
FROM node:18-alpine AS base
|
| 3 |
+
|
| 4 |
+
# Install dependencies only when needed
|
| 5 |
+
FROM base AS deps
|
| 6 |
+
RUN apk add --no-cache libc6-compat
|
| 7 |
+
WORKDIR /app
|
| 8 |
+
|
| 9 |
+
# Copy package files
|
| 10 |
+
COPY package.json package-lock.json ./
|
| 11 |
+
RUN npm ci
|
| 12 |
+
|
| 13 |
+
# Rebuild the source code only when needed
|
| 14 |
+
FROM base AS builder
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
COPY --from=deps /app/node_modules ./node_modules
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Build Next.js application
|
| 20 |
+
RUN npm run build
|
| 21 |
+
|
| 22 |
+
# Production image, copy all the files and run next
|
| 23 |
+
FROM base AS runner
|
| 24 |
+
WORKDIR /app
|
| 25 |
+
|
| 26 |
+
ENV NODE_ENV=production
|
| 27 |
+
ENV PORT=7860
|
| 28 |
+
ENV HOSTNAME="0.0.0.0"
|
| 29 |
+
|
| 30 |
+
# Use the existing node user (UID 1000) which matches HF Spaces requirement
|
| 31 |
+
# Copy necessary files from builder
|
| 32 |
+
COPY --from=builder --chown=node:node /app/public ./public
|
| 33 |
+
COPY --from=builder --chown=node:node /app/.next/standalone ./
|
| 34 |
+
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
|
| 35 |
+
|
| 36 |
+
# Switch to the node user (UID 1000)
|
| 37 |
+
USER node
|
| 38 |
+
|
| 39 |
+
# Expose the port the app runs on
|
| 40 |
+
EXPOSE 7860
|
| 41 |
+
|
| 42 |
+
# Start the application
|
| 43 |
+
CMD ["node", "server.js"]
|
| 44 |
+
|
README copy.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Awesome Food Allergy Datasets
|
| 3 |
+
emoji: 🍽️
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Datasets Navigator
|
| 11 |
+
|
| 12 |
+
A modern web application for navigating and exploring food allergy datasets, built with Next.js 14, React, TypeScript, and Tailwind CSS.
|
| 13 |
+
|
| 14 |
+
## Prerequisites
|
| 15 |
+
|
| 16 |
+
- [Node.js](https://nodejs.org/) (v18 or higher)
|
| 17 |
+
- [pnpm](https://pnpm.io/) (v8 or higher)
|
| 18 |
+
|
| 19 |
+
If you don't have pnpm installed, you can install it with:
|
| 20 |
+
```bash
|
| 21 |
+
npm install -g pnpm
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Getting Started
|
| 25 |
+
|
| 26 |
+
### Installation
|
| 27 |
+
|
| 28 |
+
Install all dependencies:
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
pnpm install
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### Development
|
| 35 |
+
|
| 36 |
+
Run the development server:
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
pnpm dev
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
| 43 |
+
|
| 44 |
+
The application will automatically reload when you make changes to the source files.
|
| 45 |
+
|
| 46 |
+
### Building for Production
|
| 47 |
+
|
| 48 |
+
Create an optimized production build:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
pnpm build
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
Start the production server:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
pnpm start
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### Linting
|
| 61 |
+
|
| 62 |
+
Run the linter to check for code quality issues:
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
pnpm lint
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Tech Stack
|
| 69 |
+
|
| 70 |
+
- **Framework:** [Next.js 14](https://nextjs.org/) with App Router
|
| 71 |
+
- **Language:** [TypeScript](https://www.typescriptlang.org/)
|
| 72 |
+
- **Styling:** [Tailwind CSS](https://tailwindcss.com/)
|
| 73 |
+
- **UI Components:** [Radix UI](https://www.radix-ui.com/)
|
| 74 |
+
- **Icons:** [Lucide React](https://lucide.dev/)
|
| 75 |
+
- **Charts:** [Recharts](https://recharts.org/)
|
| 76 |
+
- **Forms:** [React Hook Form](https://react-hook-form.com/) with [Zod](https://zod.dev/)
|
| 77 |
+
|
| 78 |
+
## Project Structure
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
datasets_navigator/
|
| 82 |
+
├── app/ # Next.js App Router pages
|
| 83 |
+
├── components/ # React components
|
| 84 |
+
│ └── ui/ # Reusable UI components
|
| 85 |
+
├── hooks/ # Custom React hooks
|
| 86 |
+
├── lib/ # Utility functions
|
| 87 |
+
├── public/ # Static assets
|
| 88 |
+
└── styles/ # Global styles
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
## Features
|
| 92 |
+
|
| 93 |
+
- Interactive dataset exploration interface
|
| 94 |
+
- Modern, responsive design
|
| 95 |
+
- Dark/light theme support
|
| 96 |
+
- Component-based architecture
|
| 97 |
+
- Type-safe with TypeScript
|
| 98 |
+
|
| 99 |
+
## Contributing
|
| 100 |
+
|
| 101 |
+
1. Make your changes in a feature branch
|
| 102 |
+
2. Run `pnpm lint` to ensure code quality
|
| 103 |
+
3. Test your changes with `pnpm dev`
|
| 104 |
+
4. Submit a pull request
|
| 105 |
+
|
| 106 |
+
## License
|
| 107 |
+
|
| 108 |
+
See the [LICENSE](../../LICENSE) file for details.
|
| 109 |
+
|
README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
---
|
| 2 |
-
title: Awesome Food Allergy Datasets
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
-
license: apache-2.0
|
| 9 |
-
short_description: Navigate the Awesome Food Allergy Datasets collec
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Awesome Food Allergy Datasets
|
| 3 |
+
emoji: 🍽️
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app/globals.css
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import "tailwindcss";
|
| 2 |
+
@import "tw-animate-css";
|
| 3 |
+
|
| 4 |
+
@custom-variant dark (&:is(.dark *));
|
| 5 |
+
|
| 6 |
+
:root {
|
| 7 |
+
--background: oklch(1 0 0);
|
| 8 |
+
--foreground: oklch(0.145 0 0);
|
| 9 |
+
--card: oklch(1 0 0);
|
| 10 |
+
--card-foreground: oklch(0.145 0 0);
|
| 11 |
+
--popover: oklch(1 0 0);
|
| 12 |
+
--popover-foreground: oklch(0.145 0 0);
|
| 13 |
+
--primary: oklch(0.205 0 0);
|
| 14 |
+
--primary-foreground: oklch(0.985 0 0);
|
| 15 |
+
--secondary: oklch(0.97 0 0);
|
| 16 |
+
--secondary-foreground: oklch(0.205 0 0);
|
| 17 |
+
--muted: oklch(0.97 0 0);
|
| 18 |
+
--muted-foreground: oklch(0.556 0 0);
|
| 19 |
+
--accent: oklch(0.97 0 0);
|
| 20 |
+
--accent-foreground: oklch(0.205 0 0);
|
| 21 |
+
--destructive: oklch(0.577 0.245 27.325);
|
| 22 |
+
--destructive-foreground: oklch(0.577 0.245 27.325);
|
| 23 |
+
--border: oklch(0.922 0 0);
|
| 24 |
+
--input: oklch(0.922 0 0);
|
| 25 |
+
--ring: oklch(0.708 0 0);
|
| 26 |
+
--chart-1: oklch(0.646 0.222 41.116);
|
| 27 |
+
--chart-2: oklch(0.6 0.118 184.704);
|
| 28 |
+
--chart-3: oklch(0.398 0.07 227.392);
|
| 29 |
+
--chart-4: oklch(0.828 0.189 84.429);
|
| 30 |
+
--chart-5: oklch(0.769 0.188 70.08);
|
| 31 |
+
--radius: 0.625rem;
|
| 32 |
+
--sidebar: oklch(0.985 0 0);
|
| 33 |
+
--sidebar-foreground: oklch(0.145 0 0);
|
| 34 |
+
--sidebar-primary: oklch(0.205 0 0);
|
| 35 |
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
| 36 |
+
--sidebar-accent: oklch(0.97 0 0);
|
| 37 |
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
| 38 |
+
--sidebar-border: oklch(0.922 0 0);
|
| 39 |
+
--sidebar-ring: oklch(0.708 0 0);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.dark {
|
| 43 |
+
--background: oklch(0.145 0 0);
|
| 44 |
+
--foreground: oklch(0.985 0 0);
|
| 45 |
+
--card: oklch(0.145 0 0);
|
| 46 |
+
--card-foreground: oklch(0.985 0 0);
|
| 47 |
+
--popover: oklch(0.145 0 0);
|
| 48 |
+
--popover-foreground: oklch(0.985 0 0);
|
| 49 |
+
--primary: oklch(0.985 0 0);
|
| 50 |
+
--primary-foreground: oklch(0.205 0 0);
|
| 51 |
+
--secondary: oklch(0.269 0 0);
|
| 52 |
+
--secondary-foreground: oklch(0.985 0 0);
|
| 53 |
+
--muted: oklch(0.269 0 0);
|
| 54 |
+
--muted-foreground: oklch(0.708 0 0);
|
| 55 |
+
--accent: oklch(0.269 0 0);
|
| 56 |
+
--accent-foreground: oklch(0.985 0 0);
|
| 57 |
+
--destructive: oklch(0.396 0.141 25.723);
|
| 58 |
+
--destructive-foreground: oklch(0.637 0.237 25.331);
|
| 59 |
+
--border: oklch(0.269 0 0);
|
| 60 |
+
--input: oklch(0.269 0 0);
|
| 61 |
+
--ring: oklch(0.439 0 0);
|
| 62 |
+
--chart-1: oklch(0.488 0.243 264.376);
|
| 63 |
+
--chart-2: oklch(0.696 0.17 162.48);
|
| 64 |
+
--chart-3: oklch(0.769 0.188 70.08);
|
| 65 |
+
--chart-4: oklch(0.627 0.265 303.9);
|
| 66 |
+
--chart-5: oklch(0.645 0.246 16.439);
|
| 67 |
+
--sidebar: oklch(0.205 0 0);
|
| 68 |
+
--sidebar-foreground: oklch(0.985 0 0);
|
| 69 |
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
| 70 |
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
| 71 |
+
--sidebar-accent: oklch(0.269 0 0);
|
| 72 |
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
| 73 |
+
--sidebar-border: oklch(0.269 0 0);
|
| 74 |
+
--sidebar-ring: oklch(0.439 0 0);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
@theme inline {
|
| 78 |
+
--font-sans: var(--font-inter);
|
| 79 |
+
--font-mono: var(--font-jetbrains-mono);
|
| 80 |
+
--color-background: var(--background);
|
| 81 |
+
--color-foreground: var(--foreground);
|
| 82 |
+
--color-card: var(--card);
|
| 83 |
+
--color-card-foreground: var(--card-foreground);
|
| 84 |
+
--color-popover: var(--popover);
|
| 85 |
+
--color-popover-foreground: var(--popover-foreground);
|
| 86 |
+
--color-primary: var(--primary);
|
| 87 |
+
--color-primary-foreground: var(--primary-foreground);
|
| 88 |
+
--color-secondary: var(--secondary);
|
| 89 |
+
--color-secondary-foreground: var(--secondary-foreground);
|
| 90 |
+
--color-muted: var(--muted);
|
| 91 |
+
--color-muted-foreground: var(--muted-foreground);
|
| 92 |
+
--color-accent: var(--accent);
|
| 93 |
+
--color-accent-foreground: var(--accent-foreground);
|
| 94 |
+
--color-destructive: var(--destructive);
|
| 95 |
+
--color-destructive-foreground: var(--destructive-foreground);
|
| 96 |
+
--color-border: var(--border);
|
| 97 |
+
--color-input: var(--input);
|
| 98 |
+
--color-ring: var(--ring);
|
| 99 |
+
--color-chart-1: var(--chart-1);
|
| 100 |
+
--color-chart-2: var(--chart-2);
|
| 101 |
+
--color-chart-3: var(--chart-3);
|
| 102 |
+
--color-chart-4: var(--chart-4);
|
| 103 |
+
--color-chart-5: var(--chart-5);
|
| 104 |
+
--radius-sm: calc(var(--radius) - 4px);
|
| 105 |
+
--radius-md: calc(var(--radius) - 2px);
|
| 106 |
+
--radius-lg: var(--radius);
|
| 107 |
+
--radius-xl: calc(var(--radius) + 4px);
|
| 108 |
+
--color-sidebar: var(--sidebar);
|
| 109 |
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
| 110 |
+
--color-sidebar-primary: var(--sidebar-primary);
|
| 111 |
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
| 112 |
+
--color-sidebar-accent: var(--sidebar-accent);
|
| 113 |
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
| 114 |
+
--color-sidebar-border: var(--sidebar-border);
|
| 115 |
+
--color-sidebar-ring: var(--sidebar-ring);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
@layer base {
|
| 119 |
+
* {
|
| 120 |
+
@apply border-border outline-ring/50;
|
| 121 |
+
}
|
| 122 |
+
body {
|
| 123 |
+
@apply bg-background text-foreground;
|
| 124 |
+
}
|
| 125 |
+
}
|
app/layout.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type React from "react"
|
| 2 |
+
import type { Metadata } from "next"
|
| 3 |
+
import { Inter } from "next/font/google"
|
| 4 |
+
import { JetBrains_Mono as JetBrainsMono } from "next/font/google"
|
| 5 |
+
import { Analytics } from "@vercel/analytics/next"
|
| 6 |
+
import { Suspense } from "react"
|
| 7 |
+
import "./globals.css"
|
| 8 |
+
import { ThemeProvider } from "@/theme-provider"
|
| 9 |
+
|
| 10 |
+
const inter = Inter({ subsets: ["latin"], variable: "--font-inter", display: "swap" })
|
| 11 |
+
const jetBrainsMono = JetBrainsMono({ subsets: ["latin"], variable: "--font-jetbrains-mono", display: "swap" })
|
| 12 |
+
|
| 13 |
+
export const metadata: Metadata = {
|
| 14 |
+
title: "Awesome Food Allergy Research Datasets",
|
| 15 |
+
description: "A curated collection of datasets for advancing food allergy research",
|
| 16 |
+
generator: "v0.app",
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export default function RootLayout({
|
| 20 |
+
children,
|
| 21 |
+
}: Readonly<{
|
| 22 |
+
children: React.ReactNode
|
| 23 |
+
}>) {
|
| 24 |
+
return (
|
| 25 |
+
<html lang="en" suppressHydrationWarning>
|
| 26 |
+
<body className={`font-sans ${inter.variable} ${jetBrainsMono.variable} min-h-dvh antialiased`}>
|
| 27 |
+
<ThemeProvider attribute="class" defaultTheme="light" forcedTheme="light" disableTransitionOnChange>
|
| 28 |
+
<Suspense fallback={null}>
|
| 29 |
+
{children}
|
| 30 |
+
<Analytics />
|
| 31 |
+
</Suspense>
|
| 32 |
+
</ThemeProvider>
|
| 33 |
+
</body>
|
| 34 |
+
</html>
|
| 35 |
+
)
|
| 36 |
+
}
|
app/page.tsx
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DatasetAtlas } from "@/components/dataset-atlas"
|
| 2 |
+
|
| 3 |
+
export default function Home() {
|
| 4 |
+
return <DatasetAtlas />
|
| 5 |
+
}
|
components.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "new-york",
|
| 4 |
+
"rsc": true,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "",
|
| 8 |
+
"css": "app/globals.css",
|
| 9 |
+
"baseColor": "neutral",
|
| 10 |
+
"cssVariables": true,
|
| 11 |
+
"prefix": ""
|
| 12 |
+
},
|
| 13 |
+
"aliases": {
|
| 14 |
+
"components": "@/components",
|
| 15 |
+
"utils": "@/lib/utils",
|
| 16 |
+
"ui": "@/components/ui",
|
| 17 |
+
"lib": "@/lib",
|
| 18 |
+
"hooks": "@/hooks"
|
| 19 |
+
},
|
| 20 |
+
"iconLibrary": "lucide"
|
| 21 |
+
}
|
components/dataset-atlas.tsx
ADDED
|
@@ -0,0 +1,597 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState, useMemo, useEffect, useRef } from "react"
|
| 4 |
+
import { Search, ExternalLink, Mail, FileText, X, ChevronDown, BarChart3 } from "lucide-react"
|
| 5 |
+
import { Input } from "@/components/ui/input"
|
| 6 |
+
import { Badge } from "@/components/ui/badge"
|
| 7 |
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
|
| 8 |
+
import { Button } from "@/components/ui/button"
|
| 9 |
+
import {
|
| 10 |
+
DropdownMenu,
|
| 11 |
+
DropdownMenuContent,
|
| 12 |
+
DropdownMenuCheckboxItem,
|
| 13 |
+
DropdownMenuTrigger,
|
| 14 |
+
} from "@/components/ui/dropdown-menu"
|
| 15 |
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
| 16 |
+
import { DatasetStatistics } from "@/components/dataset-statistics"
|
| 17 |
+
import { ScrollToTop } from "@/components/scroll-to-top"
|
| 18 |
+
|
| 19 |
+
interface Dataset {
|
| 20 |
+
Name: string
|
| 21 |
+
Category: string
|
| 22 |
+
Description: string
|
| 23 |
+
Task: string
|
| 24 |
+
Data_Type: string
|
| 25 |
+
Source: string
|
| 26 |
+
"Paper link": string
|
| 27 |
+
Availability: string
|
| 28 |
+
Contact: string
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function getCategoryColor(category: string): { bg: string; text: string; hover: string } {
|
| 32 |
+
const colors = [
|
| 33 |
+
{ bg: "bg-blue-100 dark:bg-blue-950", text: "text-blue-700 dark:text-blue-300", hover: "hover:bg-blue-200 dark:hover:bg-blue-900" },
|
| 34 |
+
{ bg: "bg-emerald-100 dark:bg-emerald-950", text: "text-emerald-700 dark:text-emerald-300", hover: "hover:bg-emerald-200 dark:hover:bg-emerald-900" },
|
| 35 |
+
{ bg: "bg-amber-100 dark:bg-amber-950", text: "text-amber-700 dark:text-amber-300", hover: "hover:bg-amber-200 dark:hover:bg-amber-900" },
|
| 36 |
+
{ bg: "bg-rose-100 dark:bg-rose-950", text: "text-rose-700 dark:text-rose-300", hover: "hover:bg-rose-200 dark:hover:bg-rose-900" },
|
| 37 |
+
{ bg: "bg-cyan-100 dark:bg-cyan-950", text: "text-cyan-700 dark:text-cyan-300", hover: "hover:bg-cyan-200 dark:hover:bg-cyan-900" },
|
| 38 |
+
]
|
| 39 |
+
const hash = category.split("").reduce((acc, char) => acc + char.charCodeAt(0), 0)
|
| 40 |
+
return colors[hash % colors.length]
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function getDataTypeColor(dataType: string): { bg: string; text: string; hover: string } {
|
| 44 |
+
const colors = [
|
| 45 |
+
{ bg: "bg-indigo-100 dark:bg-indigo-950", text: "text-indigo-700 dark:text-indigo-300", hover: "hover:bg-indigo-200 dark:hover:bg-indigo-900" },
|
| 46 |
+
{ bg: "bg-teal-100 dark:bg-teal-950", text: "text-teal-700 dark:text-teal-300", hover: "hover:bg-teal-200 dark:hover:bg-teal-900" },
|
| 47 |
+
{ bg: "bg-orange-100 dark:bg-orange-950", text: "text-orange-700 dark:text-orange-300", hover: "hover:bg-orange-200 dark:hover:bg-orange-900" },
|
| 48 |
+
{ bg: "bg-pink-100 dark:bg-pink-950", text: "text-pink-700 dark:text-pink-300", hover: "hover:bg-pink-200 dark:hover:bg-pink-900" },
|
| 49 |
+
{ bg: "bg-lime-100 dark:bg-lime-950", text: "text-lime-700 dark:text-lime-300", hover: "hover:bg-lime-200 dark:hover:bg-lime-900" },
|
| 50 |
+
{ bg: "bg-sky-100 dark:bg-sky-950", text: "text-sky-700 dark:text-sky-300", hover: "hover:bg-sky-200 dark:hover:bg-sky-900" },
|
| 51 |
+
]
|
| 52 |
+
const hash = dataType.split("").reduce((acc, char) => acc + char.charCodeAt(0), 0)
|
| 53 |
+
return colors[hash % colors.length]
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function getCategoryHoverClasses(category: string): string {
|
| 57 |
+
const sets = [
|
| 58 |
+
{ bg: "hover:!bg-blue-50 dark:hover:!bg-blue-950/40", text: "hover:!text-blue-700 dark:hover:!text-blue-300" },
|
| 59 |
+
{ bg: "hover:!bg-indigo-50 dark:hover:!bg-indigo-950/40", text: "hover:!text-indigo-700 dark:hover:!text-indigo-300" },
|
| 60 |
+
{ bg: "hover:!bg-violet-50 dark:hover:!bg-violet-950/40", text: "hover:!text-violet-700 dark:hover:!text-violet-300" },
|
| 61 |
+
{ bg: "hover:!bg-emerald-50 dark:hover:!bg-emerald-950/40", text: "hover:!text-emerald-700 dark:hover:!text-emerald-300" },
|
| 62 |
+
{ bg: "hover:!bg-amber-50 dark:hover:!bg-amber-950/40", text: "hover:!text-amber-700 dark:hover:!text-amber-300" },
|
| 63 |
+
{ bg: "hover:!bg-rose-50 dark:hover:!bg-rose-950/40", text: "hover:!text-rose-700 dark:hover:!text-rose-300" },
|
| 64 |
+
] as const
|
| 65 |
+
const hash = category.split("").reduce((acc, ch) => acc + ch.charCodeAt(0), 0)
|
| 66 |
+
const c = sets[hash % sets.length]
|
| 67 |
+
return `${c.bg} ${c.text}`
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/* ---------- Share-link + CSV helpers ---------- */
|
| 71 |
+
function buildShareUrl(opts: {
|
| 72 |
+
searchQuery: string
|
| 73 |
+
selectedCategory: string
|
| 74 |
+
selectedTasks: string[]
|
| 75 |
+
selectedDataTypes: string[]
|
| 76 |
+
}) {
|
| 77 |
+
const u = new URL(window.location.href)
|
| 78 |
+
const p = u.searchParams
|
| 79 |
+
p.set("q", opts.searchQuery || "")
|
| 80 |
+
p.set("cat", opts.selectedCategory || "all")
|
| 81 |
+
p.set("tasks", opts.selectedTasks.join(","))
|
| 82 |
+
p.set("types", opts.selectedDataTypes.join(","))
|
| 83 |
+
u.search = p.toString()
|
| 84 |
+
return u.toString()
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
function downloadCSV(rows: any[], filename = "datasets_filtered.csv") {
|
| 88 |
+
if (!rows.length) {
|
| 89 |
+
alert("Nothing to export — adjust your filters first.")
|
| 90 |
+
return
|
| 91 |
+
}
|
| 92 |
+
const headers = Object.keys(rows[0])
|
| 93 |
+
const esc = (v: any) => `"${String(v ?? "").replace(/"/g, '""')}"`
|
| 94 |
+
const csv = [headers.join(","), ...rows.map(r => headers.map(h => esc(r[h])).join(","))].join("\n")
|
| 95 |
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" })
|
| 96 |
+
const url = URL.createObjectURL(blob)
|
| 97 |
+
const a = document.createElement("a")
|
| 98 |
+
a.href = url
|
| 99 |
+
a.download = filename
|
| 100 |
+
document.body.appendChild(a)
|
| 101 |
+
a.click()
|
| 102 |
+
a.remove()
|
| 103 |
+
URL.revokeObjectURL(url)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
export function DatasetAtlas() {
|
| 107 |
+
const [datasets, setDatasets] = useState<Dataset[]>([])
|
| 108 |
+
const [searchQuery, setSearchQuery] = useState("")
|
| 109 |
+
const [selectedCategory, setSelectedCategory] = useState<string>("all")
|
| 110 |
+
const [selectedTasks, setSelectedTasks] = useState<string[]>([])
|
| 111 |
+
const [selectedDataTypes, setSelectedDataTypes] = useState<string[]>([])
|
| 112 |
+
const [loading, setLoading] = useState(true)
|
| 113 |
+
const [selectedDataset, setSelectedDataset] = useState<Dataset | null>(null)
|
| 114 |
+
const taskTriggerRef = useRef<HTMLButtonElement | null>(null)
|
| 115 |
+
const dataTypeTriggerRef = useRef<HTMLButtonElement | null>(null)
|
| 116 |
+
const [taskMenuWidth, setTaskMenuWidth] = useState<number | null>(null)
|
| 117 |
+
const [dataTypeMenuWidth, setDataTypeMenuWidth] = useState<number | null>(null)
|
| 118 |
+
|
| 119 |
+
// Chart filters passed to <DatasetStatistics />
|
| 120 |
+
const [chartFilterCategory, setChartFilterCategory] = useState<string | null>(null)
|
| 121 |
+
const [chartFilterDataType, setChartFilterDataType] = useState<string | null>(null)
|
| 122 |
+
const [chartFilterAvailability, setChartFilterAvailability] = useState<string | null>(null)
|
| 123 |
+
|
| 124 |
+
// Toggle for showing/hiding plots
|
| 125 |
+
const [showPlots, setShowPlots] = useState(false)
|
| 126 |
+
|
| 127 |
+
useEffect(() => {
|
| 128 |
+
async function fetchData() {
|
| 129 |
+
try {
|
| 130 |
+
const response = await fetch(
|
| 131 |
+
"https://blobs.vusercontent.net/blob/Awesome%20food%20allergy%20datasets%20-%20Copia%20di%20Full%20view%20%281%29-nbq61oXBgltNRiIJIq8djoMoqX7ItK.tsv",
|
| 132 |
+
)
|
| 133 |
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
|
| 134 |
+
const text = await response.text()
|
| 135 |
+
const parsed = parseTSV(text)
|
| 136 |
+
setDatasets(parsed)
|
| 137 |
+
} catch (error) {
|
| 138 |
+
console.error("[v0] Error fetching datasets:", error)
|
| 139 |
+
} finally {
|
| 140 |
+
setLoading(false)
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
fetchData()
|
| 144 |
+
}, [])
|
| 145 |
+
|
| 146 |
+
useEffect(() => {
|
| 147 |
+
function updateWidths() {
|
| 148 |
+
if (taskTriggerRef.current) setTaskMenuWidth(Math.round(taskTriggerRef.current.getBoundingClientRect().width))
|
| 149 |
+
if (dataTypeTriggerRef.current) setDataTypeMenuWidth(Math.round(dataTypeTriggerRef.current.getBoundingClientRect().width))
|
| 150 |
+
}
|
| 151 |
+
updateWidths()
|
| 152 |
+
window.addEventListener("resize", updateWidths)
|
| 153 |
+
return () => window.removeEventListener("resize", updateWidths)
|
| 154 |
+
}, [])
|
| 155 |
+
|
| 156 |
+
function parseTSV(text: string): Dataset[] {
|
| 157 |
+
const lines = text.split("\n")
|
| 158 |
+
const headers = lines[0].split("\t").map((h) => h.trim().replace(/^"|"$/g, ""))
|
| 159 |
+
return lines
|
| 160 |
+
.slice(1)
|
| 161 |
+
.filter((line) => line.trim())
|
| 162 |
+
.map((line) => {
|
| 163 |
+
const values = line.split("\t").map((v) => v.trim())
|
| 164 |
+
const dataset: any = {}
|
| 165 |
+
headers.forEach((header, index) => (dataset[header] = values[index] || ""))
|
| 166 |
+
return dataset as Dataset
|
| 167 |
+
})
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
const categories = useMemo(() => {
|
| 171 |
+
const cats = new Set(datasets.map((d) => d.Category).filter(Boolean))
|
| 172 |
+
return ["all", ...Array.from(cats).sort()]
|
| 173 |
+
}, [datasets])
|
| 174 |
+
|
| 175 |
+
const tasks = useMemo(() => {
|
| 176 |
+
const set = new Set<string>()
|
| 177 |
+
datasets.forEach((d) => {
|
| 178 |
+
if (d.Task) d.Task.split(",").map((t) => t.trim()).forEach((t) => t && set.add(t))
|
| 179 |
+
})
|
| 180 |
+
return Array.from(set).sort()
|
| 181 |
+
}, [datasets])
|
| 182 |
+
|
| 183 |
+
const dataTypes = useMemo(() => {
|
| 184 |
+
const set = new Set(datasets.map((d) => d.Data_Type).filter(Boolean))
|
| 185 |
+
return Array.from(set).sort()
|
| 186 |
+
}, [datasets])
|
| 187 |
+
|
| 188 |
+
const filteredDatasets = useMemo(() => {
|
| 189 |
+
return datasets.filter((d) => {
|
| 190 |
+
const q = searchQuery.toLowerCase()
|
| 191 |
+
const matchesSearch =
|
| 192 |
+
d.Name?.toLowerCase().includes(q) ||
|
| 193 |
+
d.Description?.toLowerCase().includes(q) ||
|
| 194 |
+
d.Category?.toLowerCase().includes(q) ||
|
| 195 |
+
d.Task?.toLowerCase().includes(q) ||
|
| 196 |
+
d.Data_Type?.toLowerCase().includes(q)
|
| 197 |
+
|
| 198 |
+
const matchesCategory = selectedCategory === "all" || d.Category === selectedCategory
|
| 199 |
+
const matchesTask =
|
| 200 |
+
selectedTasks.length === 0 ||
|
| 201 |
+
d.Task.split(",").map((t) => t.trim()).some((t) => selectedTasks.includes(t))
|
| 202 |
+
const matchesDataType = selectedDataTypes.length === 0 || selectedDataTypes.includes(d.Data_Type)
|
| 203 |
+
|
| 204 |
+
const matchesChartCategory = !chartFilterCategory || d.Category === chartFilterCategory
|
| 205 |
+
const matchesChartDataType = !chartFilterDataType || d.Data_Type === chartFilterDataType
|
| 206 |
+
const matchesChartAvailability = !chartFilterAvailability || d.Availability === chartFilterAvailability
|
| 207 |
+
|
| 208 |
+
return matchesSearch && matchesCategory && matchesTask && matchesDataType &&
|
| 209 |
+
matchesChartCategory && matchesChartDataType && matchesChartAvailability
|
| 210 |
+
})
|
| 211 |
+
}, [datasets, searchQuery, selectedCategory, selectedTasks, selectedDataTypes, chartFilterCategory, chartFilterDataType, chartFilterAvailability])
|
| 212 |
+
|
| 213 |
+
const toggleTask = (task: string) =>
|
| 214 |
+
setSelectedTasks((prev) => (prev.includes(task) ? prev.filter((t) => t !== task) : [...prev, task]))
|
| 215 |
+
const removeTask = (task: string) => setSelectedTasks((prev) => prev.filter((t) => t !== task))
|
| 216 |
+
const clearAllTasks = () => setSelectedTasks([])
|
| 217 |
+
|
| 218 |
+
const toggleDataType = (dataType: string) =>
|
| 219 |
+
setSelectedDataTypes((prev) => (prev.includes(dataType) ? prev.filter((t) => t !== dataType) : [...prev, dataType]))
|
| 220 |
+
const removeDataType = (dataType: string) => setSelectedDataTypes((prev) => prev.filter((t) => t !== dataType))
|
| 221 |
+
const clearAllDataTypes = () => setSelectedDataTypes([])
|
| 222 |
+
|
| 223 |
+
const handleCategoryChartClick = (category: string) =>
|
| 224 |
+
setChartFilterCategory((prev) => (prev === category ? null : category))
|
| 225 |
+
const handleDataTypeChartClick = (dataType: string) =>
|
| 226 |
+
setChartFilterDataType((prev) => (prev === dataType ? null : dataType))
|
| 227 |
+
const handleAvailabilityChartClick = (availability: string) =>
|
| 228 |
+
setChartFilterAvailability((prev) => (prev === availability ? null : availability))
|
| 229 |
+
|
| 230 |
+
return (
|
| 231 |
+
<div className="min-h-screen bg-background">
|
| 232 |
+
{/* Header */}
|
| 233 |
+
<header className="border-b border-border bg-card">
|
| 234 |
+
<div className="container mx-auto px-4 py-6 md:py-8">
|
| 235 |
+
<h1 className="text-3xl md:text-4xl font-bold text-balance mb-2">Awesome Food Allergy Research Datasets</h1>
|
| 236 |
+
<p className="text-muted-foreground text-lg text-pretty">
|
| 237 |
+
A curated collection of datasets for advancing food allergy research
|
| 238 |
+
</p>
|
| 239 |
+
</div>
|
| 240 |
+
</header>
|
| 241 |
+
|
| 242 |
+
<div className="container mx-auto px-4 py-8">
|
| 243 |
+
{/* Search and Filters */}
|
| 244 |
+
<div className="mb-6 space-y-4">
|
| 245 |
+
<div className="relative">
|
| 246 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-muted-foreground" />
|
| 247 |
+
<Input
|
| 248 |
+
type="text"
|
| 249 |
+
placeholder="Search datasets by name, description, category, task, or data type..."
|
| 250 |
+
value={searchQuery}
|
| 251 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 252 |
+
className="pl-10 h-12 text-base"
|
| 253 |
+
/>
|
| 254 |
+
</div>
|
| 255 |
+
|
| 256 |
+
{/* --- Actions bar (Share + Export + Toggle Plots) — right under search --- */}
|
| 257 |
+
<div className="flex flex-wrap items-center gap-2">
|
| 258 |
+
<Button
|
| 259 |
+
variant={showPlots ? "outline" : "default"}
|
| 260 |
+
size="sm"
|
| 261 |
+
onClick={() => setShowPlots(!showPlots)}
|
| 262 |
+
className="font-semibold"
|
| 263 |
+
title={showPlots ? "Hide statistics charts" : "Show statistics charts"}
|
| 264 |
+
aria-expanded={showPlots}
|
| 265 |
+
aria-controls="statistics-section"
|
| 266 |
+
aria-label={showPlots ? "Hide statistics" : "Show statistics"}
|
| 267 |
+
>
|
| 268 |
+
<BarChart3 className="h-4 w-4 mr-2" />
|
| 269 |
+
{showPlots ? "Hide Statistics" : "Show Statistics"}
|
| 270 |
+
</Button>
|
| 271 |
+
|
| 272 |
+
<Button
|
| 273 |
+
variant="outline"
|
| 274 |
+
size="sm"
|
| 275 |
+
onClick={() => {
|
| 276 |
+
const url = buildShareUrl({
|
| 277 |
+
searchQuery,
|
| 278 |
+
selectedCategory,
|
| 279 |
+
selectedTasks,
|
| 280 |
+
selectedDataTypes,
|
| 281 |
+
})
|
| 282 |
+
if (navigator.clipboard?.writeText) {
|
| 283 |
+
navigator.clipboard.writeText(url)
|
| 284 |
+
.then(() => alert("Shareable link copied to clipboard!"))
|
| 285 |
+
.catch(() => prompt("Copy this link:", url))
|
| 286 |
+
} else {
|
| 287 |
+
prompt("Copy this link:", url)
|
| 288 |
+
}
|
| 289 |
+
}}
|
| 290 |
+
>
|
| 291 |
+
Share this view (copy link)
|
| 292 |
+
</Button>
|
| 293 |
+
|
| 294 |
+
<Button
|
| 295 |
+
variant="outline"
|
| 296 |
+
size="sm"
|
| 297 |
+
onClick={() => {
|
| 298 |
+
const rows = filteredDatasets.map(d => ({
|
| 299 |
+
Name: d.Name,
|
| 300 |
+
Category: d.Category,
|
| 301 |
+
"Data Type": d.Data_Type,
|
| 302 |
+
Task: d.Task,
|
| 303 |
+
Availability: d.Availability,
|
| 304 |
+
"Access URL": d.Source,
|
| 305 |
+
"Paper URL": d["Paper link"],
|
| 306 |
+
Contact: d.Contact,
|
| 307 |
+
Description: d.Description,
|
| 308 |
+
}))
|
| 309 |
+
downloadCSV(rows)
|
| 310 |
+
}}
|
| 311 |
+
>
|
| 312 |
+
Export current list (CSV)
|
| 313 |
+
</Button>
|
| 314 |
+
</div>
|
| 315 |
+
|
| 316 |
+
<div className="flex flex-col gap-4 pt-2">
|
| 317 |
+
<div>
|
| 318 |
+
<label className="text-sm font-medium mb-2 block">Filter by Category</label>
|
| 319 |
+
<div className="flex flex-wrap gap-2">
|
| 320 |
+
{categories.map((category) => (
|
| 321 |
+
<Button
|
| 322 |
+
key={category}
|
| 323 |
+
variant={selectedCategory === category ? "default" : "outline"}
|
| 324 |
+
size="sm"
|
| 325 |
+
onClick={() => setSelectedCategory(category)}
|
| 326 |
+
className={`capitalize transition-colors ${getCategoryHoverClasses(category)}`}
|
| 327 |
+
>
|
| 328 |
+
{category}
|
| 329 |
+
</Button>
|
| 330 |
+
))}
|
| 331 |
+
</div>
|
| 332 |
+
</div>
|
| 333 |
+
|
| 334 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 335 |
+
<div>
|
| 336 |
+
<label className="text-sm font-medium mb-2 block">Filter by Task</label>
|
| 337 |
+
<div className="space-y-2">
|
| 338 |
+
<DropdownMenu>
|
| 339 |
+
<DropdownMenuTrigger asChild>
|
| 340 |
+
<Button ref={taskTriggerRef} variant="outline" className="w-full justify-between bg-transparent">
|
| 341 |
+
<span>
|
| 342 |
+
{selectedTasks.length === 0
|
| 343 |
+
? "Select tasks..."
|
| 344 |
+
: `${selectedTasks.length} task${selectedTasks.length > 1 ? "s" : ""} selected`}
|
| 345 |
+
</span>
|
| 346 |
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
| 347 |
+
</Button>
|
| 348 |
+
</DropdownMenuTrigger>
|
| 349 |
+
<DropdownMenuContent className="max-h-[300px] overflow-y-auto" style={{ width: taskMenuWidth ?? undefined }}>
|
| 350 |
+
{tasks.map((task) => (
|
| 351 |
+
<DropdownMenuCheckboxItem key={task} checked={selectedTasks.includes(task)} onCheckedChange={() => toggleTask(task)}>
|
| 352 |
+
{task}
|
| 353 |
+
</DropdownMenuCheckboxItem>
|
| 354 |
+
))}
|
| 355 |
+
</DropdownMenuContent>
|
| 356 |
+
</DropdownMenu>
|
| 357 |
+
|
| 358 |
+
{selectedTasks.length > 0 && (
|
| 359 |
+
<div className="flex flex-wrap gap-2">
|
| 360 |
+
{selectedTasks.map((task) => (
|
| 361 |
+
<Badge key={task} variant="secondary" className="pl-2 pr-1 py-1 text-xs shadow-none">
|
| 362 |
+
{task}
|
| 363 |
+
<button onClick={() => removeTask(task)} className="ml-1 hover:bg-muted rounded-full p-0.5">
|
| 364 |
+
<X className="h-3 w-3" />
|
| 365 |
+
</button>
|
| 366 |
+
</Badge>
|
| 367 |
+
))}
|
| 368 |
+
<Button variant="ghost" size="sm" onClick={clearAllTasks} className="h-6 px-2 text-xs">
|
| 369 |
+
Clear all
|
| 370 |
+
</Button>
|
| 371 |
+
</div>
|
| 372 |
+
)}
|
| 373 |
+
</div>
|
| 374 |
+
</div>
|
| 375 |
+
|
| 376 |
+
<div>
|
| 377 |
+
<label className="text-sm font-medium mb-2 block">Filter by Data Type</label>
|
| 378 |
+
<div className="space-y-2">
|
| 379 |
+
<DropdownMenu>
|
| 380 |
+
<DropdownMenuTrigger asChild>
|
| 381 |
+
<Button ref={dataTypeTriggerRef} variant="outline" className="w-full justify-between bg-transparent">
|
| 382 |
+
<span>
|
| 383 |
+
{selectedDataTypes.length === 0
|
| 384 |
+
? "Select data types..."
|
| 385 |
+
: `${selectedDataTypes.length} type${selectedDataTypes.length > 1 ? "s" : ""} selected`}
|
| 386 |
+
</span>
|
| 387 |
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
| 388 |
+
</Button>
|
| 389 |
+
</DropdownMenuTrigger>
|
| 390 |
+
<DropdownMenuContent className="max-h-[300px] overflow-y-auto" style={{ width: dataTypeMenuWidth ?? undefined }}>
|
| 391 |
+
{dataTypes.map((dataType) => (
|
| 392 |
+
<DropdownMenuCheckboxItem key={dataType} checked={selectedDataTypes.includes(dataType)} onCheckedChange={() => toggleDataType(dataType)}>
|
| 393 |
+
{dataType}
|
| 394 |
+
</DropdownMenuCheckboxItem>
|
| 395 |
+
))}
|
| 396 |
+
</DropdownMenuContent>
|
| 397 |
+
</DropdownMenu>
|
| 398 |
+
|
| 399 |
+
{selectedDataTypes.length > 0 && (
|
| 400 |
+
<div className="flex flex-wrap gap-2">
|
| 401 |
+
{selectedDataTypes.map((dataType) => (
|
| 402 |
+
<Badge key={dataType} variant="secondary" className="pl-2 pr-1 py-1 text-xs shadow-none">
|
| 403 |
+
{dataType}
|
| 404 |
+
<button onClick={() => removeDataType(dataType)} className="ml-1 hover:bg-muted rounded-full p-0.5">
|
| 405 |
+
<X className="h-3 w-3" />
|
| 406 |
+
</button>
|
| 407 |
+
</Badge>
|
| 408 |
+
))}
|
| 409 |
+
<Button variant="ghost" size="sm" onClick={clearAllDataTypes} className="h-6 px-2 text-xs">
|
| 410 |
+
Clear all
|
| 411 |
+
</Button>
|
| 412 |
+
</div>
|
| 413 |
+
)}
|
| 414 |
+
</div>
|
| 415 |
+
</div>
|
| 416 |
+
</div>
|
| 417 |
+
</div>
|
| 418 |
+
</div>
|
| 419 |
+
|
| 420 |
+
{/* Statistics Charts */}
|
| 421 |
+
{!loading && datasets.length > 0 && showPlots && (
|
| 422 |
+
<section id="statistics-section" aria-label="Dataset statistics" className="mb-6">
|
| 423 |
+
<DatasetStatistics
|
| 424 |
+
datasets={datasets}
|
| 425 |
+
selectedCategory={chartFilterCategory}
|
| 426 |
+
selectedDataType={chartFilterDataType}
|
| 427 |
+
selectedAvailability={chartFilterAvailability}
|
| 428 |
+
onCategoryClick={handleCategoryChartClick}
|
| 429 |
+
onDataTypeClick={handleDataTypeChartClick}
|
| 430 |
+
onAvailabilityClick={handleAvailabilityChartClick}
|
| 431 |
+
/>
|
| 432 |
+
</section>
|
| 433 |
+
)}
|
| 434 |
+
|
| 435 |
+
{/* Results Count */}
|
| 436 |
+
<div className="mb-6">
|
| 437 |
+
<p className="text-sm text-muted-foreground">
|
| 438 |
+
Showing <span className="font-semibold text-foreground">{filteredDatasets.length}</span> of{" "}
|
| 439 |
+
<span className="font-semibold text-foreground">{datasets.length}</span> datasets
|
| 440 |
+
</p>
|
| 441 |
+
</div>
|
| 442 |
+
|
| 443 |
+
{/* Dataset Grid */}
|
| 444 |
+
{loading ? (
|
| 445 |
+
<div className="text-center py-12">
|
| 446 |
+
<p className="text-muted-foreground">Loading datasets...</p>
|
| 447 |
+
</div>
|
| 448 |
+
) : filteredDatasets.length === 0 ? (
|
| 449 |
+
<div className="text-center py-12">
|
| 450 |
+
<p className="text-muted-foreground">No datasets found matching your criteria.</p>
|
| 451 |
+
</div>
|
| 452 |
+
) : (
|
| 453 |
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 454 |
+
{filteredDatasets.map((dataset, index) => {
|
| 455 |
+
const categoryColors = getCategoryColor(dataset.Category)
|
| 456 |
+
const dataTypeColors = getDataTypeColor(dataset.Data_Type)
|
| 457 |
+
return (
|
| 458 |
+
<Card key={index} className="flex flex-col hover:shadow-lg transition-shadow cursor-pointer h-[480px]" onClick={() => setSelectedDataset(dataset)}>
|
| 459 |
+
<CardHeader className="pb-3">
|
| 460 |
+
<div className="flex gap-2 mb-3 flex-wrap">
|
| 461 |
+
{dataset.Category && (
|
| 462 |
+
<Badge className={`text-xs border-0 shadow-none ${categoryColors.bg} ${categoryColors.text} ${categoryColors.hover}`}>
|
| 463 |
+
{dataset.Category}
|
| 464 |
+
</Badge>
|
| 465 |
+
)}
|
| 466 |
+
{dataset.Data_Type && (
|
| 467 |
+
<Badge className={`text-xs border-0 shadow-none ${dataTypeColors.bg} ${dataTypeColors.text} ${dataTypeColors.hover}`}>
|
| 468 |
+
{dataset.Data_Type}
|
| 469 |
+
</Badge>
|
| 470 |
+
)}
|
| 471 |
+
{dataset.Availability && (
|
| 472 |
+
<Badge variant={dataset.Availability.toLowerCase().includes("open") ? "default" : "outline"} className="text-xs shadow-none">
|
| 473 |
+
{dataset.Availability}
|
| 474 |
+
</Badge>
|
| 475 |
+
)}
|
| 476 |
+
</div>
|
| 477 |
+
<CardTitle className="text-xl text-balance leading-tight">{dataset.Name}</CardTitle>
|
| 478 |
+
{dataset.Task && (
|
| 479 |
+
<CardDescription className="text-sm font-medium line-clamp-2">
|
| 480 |
+
Task: {dataset.Task}
|
| 481 |
+
</CardDescription>
|
| 482 |
+
)}
|
| 483 |
+
</CardHeader>
|
| 484 |
+
<CardContent className="flex-1 pb-3">
|
| 485 |
+
<p className="text-sm text-muted-foreground text-pretty leading-relaxed line-clamp-4">
|
| 486 |
+
{dataset.Description}
|
| 487 |
+
</p>
|
| 488 |
+
</CardContent>
|
| 489 |
+
<CardFooter className="flex flex-col gap-2 items-stretch pt-3 pb-5">
|
| 490 |
+
{dataset.Source && (
|
| 491 |
+
<Button variant="default" size="sm" asChild className="w-full" onClick={(e) => e.stopPropagation()}>
|
| 492 |
+
<a href={dataset.Source} target="_blank" rel="noopener noreferrer">
|
| 493 |
+
<ExternalLink className="h-4 w-4 mr-2" />
|
| 494 |
+
Access Dataset
|
| 495 |
+
</a>
|
| 496 |
+
</Button>
|
| 497 |
+
)}
|
| 498 |
+
<div className="flex gap-2">
|
| 499 |
+
{dataset["Paper link"] && (
|
| 500 |
+
<Button variant="outline" size="sm" asChild className="flex-1 bg-transparent" onClick={(e) => e.stopPropagation()}>
|
| 501 |
+
<a href={dataset["Paper link"]} target="_blank" rel="noopener noreferrer">
|
| 502 |
+
<FileText className="h-4 w-4 mr-2" />
|
| 503 |
+
Paper
|
| 504 |
+
</a>
|
| 505 |
+
</Button>
|
| 506 |
+
)}
|
| 507 |
+
{dataset.Contact && (
|
| 508 |
+
<Button variant="outline" size="sm" asChild className="flex-1 bg-transparent" onClick={(e) => e.stopPropagation()}>
|
| 509 |
+
<a href={`mailto:${dataset.Contact}`}>
|
| 510 |
+
<Mail className="h-4 w-4 mr-2" />
|
| 511 |
+
Contact
|
| 512 |
+
</a>
|
| 513 |
+
</Button>
|
| 514 |
+
)}
|
| 515 |
+
</div>
|
| 516 |
+
</CardFooter>
|
| 517 |
+
</Card>
|
| 518 |
+
)
|
| 519 |
+
})}
|
| 520 |
+
</div>
|
| 521 |
+
)}
|
| 522 |
+
</div>
|
| 523 |
+
|
| 524 |
+
{/* Modal Dialog for Expanded Dataset View */}
|
| 525 |
+
<Dialog open={!!selectedDataset} onOpenChange={(open) => !open && setSelectedDataset(null)}>
|
| 526 |
+
<DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
|
| 527 |
+
{selectedDataset && (
|
| 528 |
+
<>
|
| 529 |
+
<DialogHeader>
|
| 530 |
+
<div className="flex gap-2 mb-3 flex-wrap">
|
| 531 |
+
{selectedDataset.Category && (
|
| 532 |
+
<Badge className={`text-xs border-0 shadow-none ${getCategoryColor(selectedDataset.Category).bg} ${getCategoryColor(selectedDataset.Category).text} ${getCategoryColor(selectedDataset.Category).hover}`}>
|
| 533 |
+
{selectedDataset.Category}
|
| 534 |
+
</Badge>
|
| 535 |
+
)}
|
| 536 |
+
{selectedDataset.Data_Type && (
|
| 537 |
+
<Badge className={`text-xs border-0 shadow-none ${getDataTypeColor(selectedDataset.Data_Type).bg} ${getDataTypeColor(selectedDataset.Data_Type).text} ${getDataTypeColor(selectedDataset.Data_Type).hover}`}>
|
| 538 |
+
{selectedDataset.Data_Type}
|
| 539 |
+
</Badge>
|
| 540 |
+
)}
|
| 541 |
+
{selectedDataset.Availability && (
|
| 542 |
+
<Badge variant={selectedDataset.Availability.toLowerCase().includes("open") ? "default" : "outline"} className="text-xs shadow-none">
|
| 543 |
+
{selectedDataset.Availability}
|
| 544 |
+
</Badge>
|
| 545 |
+
)}
|
| 546 |
+
</div>
|
| 547 |
+
<DialogTitle className="text-2xl text-balance">{selectedDataset.Name}</DialogTitle>
|
| 548 |
+
{selectedDataset.Task && (
|
| 549 |
+
<DialogDescription className="text-base font-medium text-foreground">
|
| 550 |
+
Task: {selectedDataset.Task}
|
| 551 |
+
</DialogDescription>
|
| 552 |
+
)}
|
| 553 |
+
</DialogHeader>
|
| 554 |
+
<div className="space-y-6 mt-4">
|
| 555 |
+
<div>
|
| 556 |
+
<h3 className="font-semibold mb-2 text-sm uppercase tracking-wide text-muted-foreground">Description</h3>
|
| 557 |
+
<p className="text-sm leading-relaxed">{selectedDataset.Description}</p>
|
| 558 |
+
</div>
|
| 559 |
+
|
| 560 |
+
<div className="flex flex-col gap-3">
|
| 561 |
+
{selectedDataset.Source && (
|
| 562 |
+
<Button variant="default" size="default" asChild className="w-full">
|
| 563 |
+
<a href={selectedDataset.Source} target="_blank" rel="noopener noreferrer">
|
| 564 |
+
<ExternalLink className="h-4 w-4 mr-2" />
|
| 565 |
+
Access Dataset
|
| 566 |
+
</a>
|
| 567 |
+
</Button>
|
| 568 |
+
)}
|
| 569 |
+
<div className="flex gap-3">
|
| 570 |
+
{selectedDataset["Paper link"] && (
|
| 571 |
+
<Button variant="outline" size="default" asChild className="flex-1 bg-transparent">
|
| 572 |
+
<a href={selectedDataset["Paper link"]} target="_blank" rel="noopener noreferrer">
|
| 573 |
+
<FileText className="h-4 w-4 mr-2" />
|
| 574 |
+
Read Paper
|
| 575 |
+
</a>
|
| 576 |
+
</Button>
|
| 577 |
+
)}
|
| 578 |
+
{selectedDataset.Contact && (
|
| 579 |
+
<Button variant="outline" size="default" asChild className="flex-1 bg-transparent">
|
| 580 |
+
<a href={`mailto:${selectedDataset.Contact}`}>
|
| 581 |
+
<Mail className="h-4 w-4 mr-2" />
|
| 582 |
+
Contact
|
| 583 |
+
</a>
|
| 584 |
+
</Button>
|
| 585 |
+
)}
|
| 586 |
+
</div>
|
| 587 |
+
</div>
|
| 588 |
+
</div>
|
| 589 |
+
</>
|
| 590 |
+
)}
|
| 591 |
+
</DialogContent>
|
| 592 |
+
</Dialog>
|
| 593 |
+
|
| 594 |
+
<ScrollToTop />
|
| 595 |
+
</div>
|
| 596 |
+
)
|
| 597 |
+
}
|
components/dataset-statistics.tsx
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useMemo } from "react"
|
| 4 |
+
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell, Legend } from "recharts"
|
| 5 |
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
| 6 |
+
|
| 7 |
+
interface Dataset {
|
| 8 |
+
Name: string
|
| 9 |
+
Category: string
|
| 10 |
+
Description: string
|
| 11 |
+
Task: string
|
| 12 |
+
Data_Type: string
|
| 13 |
+
Source: string
|
| 14 |
+
"Paper link": string
|
| 15 |
+
Availability: string
|
| 16 |
+
Contact: string
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
interface DatasetStatisticsProps {
|
| 20 |
+
datasets: Dataset[]
|
| 21 |
+
selectedCategory: string | null
|
| 22 |
+
selectedDataType: string | null
|
| 23 |
+
selectedAvailability: string | null
|
| 24 |
+
onCategoryClick: (category: string) => void
|
| 25 |
+
onDataTypeClick: (dataType: string) => void
|
| 26 |
+
onAvailabilityClick: (availability: string) => void
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
const CATEGORY_COLORS = [
|
| 30 |
+
"#6366f1", // indigo
|
| 31 |
+
"#10b981", // emerald
|
| 32 |
+
"#f59e0b", // amber
|
| 33 |
+
"#3b82f6", // blue
|
| 34 |
+
"#8b5cf6", // violet
|
| 35 |
+
"#06b6d4", // cyan
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
const DATA_TYPE_COLORS = [
|
| 39 |
+
"#3b82f6", // blue
|
| 40 |
+
"#10b981", // emerald
|
| 41 |
+
"#6366f1", // indigo
|
| 42 |
+
"#f59e0b", // amber
|
| 43 |
+
"#8b5cf6", // violet
|
| 44 |
+
"#06b6d4", // cyan
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
const AVAILABILITY_COLORS = {
|
| 48 |
+
"Open source": "#3b82f6", // blue
|
| 49 |
+
"Gated": "#10b981", // emerald
|
| 50 |
+
"Unknown": "#6b7280", // gray
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export function DatasetStatistics({
|
| 54 |
+
datasets,
|
| 55 |
+
selectedCategory,
|
| 56 |
+
selectedDataType,
|
| 57 |
+
selectedAvailability,
|
| 58 |
+
onCategoryClick,
|
| 59 |
+
onDataTypeClick,
|
| 60 |
+
onAvailabilityClick
|
| 61 |
+
}: DatasetStatisticsProps) {
|
| 62 |
+
const categoryData = useMemo(() => {
|
| 63 |
+
const counts: Record<string, number> = {}
|
| 64 |
+
datasets.forEach((dataset) => {
|
| 65 |
+
if (dataset.Category) {
|
| 66 |
+
counts[dataset.Category] = (counts[dataset.Category] || 0) + 1
|
| 67 |
+
}
|
| 68 |
+
})
|
| 69 |
+
return Object.entries(counts)
|
| 70 |
+
.map(([name, value]) => ({ name, value }))
|
| 71 |
+
.sort((a, b) => b.value - a.value)
|
| 72 |
+
}, [datasets])
|
| 73 |
+
|
| 74 |
+
const dataTypeData = useMemo(() => {
|
| 75 |
+
const counts: Record<string, number> = {}
|
| 76 |
+
datasets.forEach((dataset) => {
|
| 77 |
+
if (dataset.Data_Type) {
|
| 78 |
+
counts[dataset.Data_Type] = (counts[dataset.Data_Type] || 0) + 1
|
| 79 |
+
}
|
| 80 |
+
})
|
| 81 |
+
return Object.entries(counts)
|
| 82 |
+
.map(([name, value]) => ({ name, value }))
|
| 83 |
+
.sort((a, b) => b.value - a.value)
|
| 84 |
+
}, [datasets])
|
| 85 |
+
|
| 86 |
+
const availabilityData = useMemo(() => {
|
| 87 |
+
const counts: Record<string, number> = {}
|
| 88 |
+
datasets.forEach((dataset) => {
|
| 89 |
+
if (dataset.Availability) {
|
| 90 |
+
counts[dataset.Availability] = (counts[dataset.Availability] || 0) + 1
|
| 91 |
+
}
|
| 92 |
+
})
|
| 93 |
+
return Object.entries(counts).map(([name, value]) => ({ name, value }))
|
| 94 |
+
}, [datasets])
|
| 95 |
+
|
| 96 |
+
const CustomTooltip = ({ active, payload }: any) => {
|
| 97 |
+
if (active && payload && payload.length) {
|
| 98 |
+
return (
|
| 99 |
+
<div className="bg-popover border border-border rounded-lg shadow-lg p-3">
|
| 100 |
+
<p className="font-medium text-sm">{payload[0].payload.name}</p>
|
| 101 |
+
<p className="text-sm text-muted-foreground">Count: {payload[0].value}</p>
|
| 102 |
+
</div>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
return null
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
const renderCustomBarLabel = (props: any) => {
|
| 109 |
+
const { x, y, width, height, value } = props
|
| 110 |
+
return (
|
| 111 |
+
<text
|
| 112 |
+
x={x + width + 5}
|
| 113 |
+
y={y + height / 2}
|
| 114 |
+
fill="currentColor"
|
| 115 |
+
className="text-sm font-medium fill-foreground"
|
| 116 |
+
textAnchor="start"
|
| 117 |
+
dominantBaseline="middle"
|
| 118 |
+
>
|
| 119 |
+
{value}
|
| 120 |
+
</text>
|
| 121 |
+
)
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return (
|
| 125 |
+
<div className="space-y-6 mb-8">
|
| 126 |
+
{/* Top Row: By Data Type and Availability */}
|
| 127 |
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
| 128 |
+
{/* By Data Type */}
|
| 129 |
+
<Card>
|
| 130 |
+
<CardHeader>
|
| 131 |
+
<CardTitle className="text-lg font-semibold">
|
| 132 |
+
By Data Type
|
| 133 |
+
{selectedDataType && (
|
| 134 |
+
<span className="text-sm font-normal text-muted-foreground ml-2">
|
| 135 |
+
(Click to clear filter)
|
| 136 |
+
</span>
|
| 137 |
+
)}
|
| 138 |
+
</CardTitle>
|
| 139 |
+
</CardHeader>
|
| 140 |
+
<CardContent>
|
| 141 |
+
<ResponsiveContainer width="100%" height={300}>
|
| 142 |
+
<BarChart
|
| 143 |
+
data={dataTypeData}
|
| 144 |
+
layout="vertical"
|
| 145 |
+
margin={{ top: 5, right: 40, left: 5, bottom: 5 }}
|
| 146 |
+
>
|
| 147 |
+
<CartesianGrid strokeDasharray="3 3" className="stroke-border" />
|
| 148 |
+
<XAxis type="number" className="text-xs" tick={{ fill: "currentColor" }} />
|
| 149 |
+
<YAxis
|
| 150 |
+
type="category"
|
| 151 |
+
dataKey="name"
|
| 152 |
+
width={100}
|
| 153 |
+
className="text-xs"
|
| 154 |
+
tick={{ fill: "currentColor" }}
|
| 155 |
+
/>
|
| 156 |
+
<Tooltip content={<CustomTooltip />} />
|
| 157 |
+
<Bar
|
| 158 |
+
dataKey="value"
|
| 159 |
+
radius={[0, 4, 4, 0]}
|
| 160 |
+
label={renderCustomBarLabel}
|
| 161 |
+
onClick={(data) => onDataTypeClick(data.name)}
|
| 162 |
+
cursor="pointer"
|
| 163 |
+
>
|
| 164 |
+
{dataTypeData.map((entry, index) => {
|
| 165 |
+
const isSelected = selectedDataType === entry.name
|
| 166 |
+
const shouldGreyscale = selectedDataType && !isSelected
|
| 167 |
+
const color = shouldGreyscale
|
| 168 |
+
? "#94a3b8"
|
| 169 |
+
: DATA_TYPE_COLORS[index % DATA_TYPE_COLORS.length]
|
| 170 |
+
return (
|
| 171 |
+
<Cell
|
| 172 |
+
key={`cell-${index}`}
|
| 173 |
+
fill={color}
|
| 174 |
+
opacity={shouldGreyscale ? 0.4 : 1}
|
| 175 |
+
/>
|
| 176 |
+
)
|
| 177 |
+
})}
|
| 178 |
+
</Bar>
|
| 179 |
+
</BarChart>
|
| 180 |
+
</ResponsiveContainer>
|
| 181 |
+
</CardContent>
|
| 182 |
+
</Card>
|
| 183 |
+
|
| 184 |
+
{/* Availability */}
|
| 185 |
+
<Card>
|
| 186 |
+
<CardHeader>
|
| 187 |
+
<CardTitle className="text-lg font-semibold">
|
| 188 |
+
Availability
|
| 189 |
+
{selectedAvailability && (
|
| 190 |
+
<span className="text-sm font-normal text-muted-foreground ml-2">
|
| 191 |
+
(Click to clear filter)
|
| 192 |
+
</span>
|
| 193 |
+
)}
|
| 194 |
+
</CardTitle>
|
| 195 |
+
</CardHeader>
|
| 196 |
+
<CardContent>
|
| 197 |
+
<ResponsiveContainer width="100%" height={300}>
|
| 198 |
+
<PieChart>
|
| 199 |
+
<Pie
|
| 200 |
+
data={availabilityData}
|
| 201 |
+
cx="50%"
|
| 202 |
+
cy="50%"
|
| 203 |
+
labelLine={false}
|
| 204 |
+
label={({ name, value, percent }) => `${name}: ${value}`}
|
| 205 |
+
outerRadius={80}
|
| 206 |
+
fill="#8884d8"
|
| 207 |
+
dataKey="value"
|
| 208 |
+
onClick={(data) => onAvailabilityClick(data.name)}
|
| 209 |
+
cursor="pointer"
|
| 210 |
+
>
|
| 211 |
+
{availabilityData.map((entry, index) => {
|
| 212 |
+
const isSelected = selectedAvailability === entry.name
|
| 213 |
+
const shouldGreyscale = selectedAvailability && !isSelected
|
| 214 |
+
const originalColor = AVAILABILITY_COLORS[entry.name as keyof typeof AVAILABILITY_COLORS] || "#6b7280"
|
| 215 |
+
const color = shouldGreyscale ? "#94a3b8" : originalColor
|
| 216 |
+
return (
|
| 217 |
+
<Cell
|
| 218 |
+
key={`cell-${index}`}
|
| 219 |
+
fill={color}
|
| 220 |
+
opacity={shouldGreyscale ? 0.4 : 1}
|
| 221 |
+
/>
|
| 222 |
+
)
|
| 223 |
+
})}
|
| 224 |
+
</Pie>
|
| 225 |
+
<Tooltip content={<CustomTooltip />} />
|
| 226 |
+
<Legend
|
| 227 |
+
verticalAlign="bottom"
|
| 228 |
+
height={36}
|
| 229 |
+
iconType="circle"
|
| 230 |
+
formatter={(value) => <span className="text-sm">{value}</span>}
|
| 231 |
+
/>
|
| 232 |
+
</PieChart>
|
| 233 |
+
</ResponsiveContainer>
|
| 234 |
+
</CardContent>
|
| 235 |
+
</Card>
|
| 236 |
+
</div>
|
| 237 |
+
|
| 238 |
+
{/* Bottom Row: By Category */}
|
| 239 |
+
<div className="grid grid-cols-1 gap-6">
|
| 240 |
+
<Card>
|
| 241 |
+
<CardHeader>
|
| 242 |
+
<CardTitle className="text-lg font-semibold">
|
| 243 |
+
By Category
|
| 244 |
+
{selectedCategory && (
|
| 245 |
+
<span className="text-sm font-normal text-muted-foreground ml-2">
|
| 246 |
+
(Click to clear filter)
|
| 247 |
+
</span>
|
| 248 |
+
)}
|
| 249 |
+
</CardTitle>
|
| 250 |
+
</CardHeader>
|
| 251 |
+
<CardContent>
|
| 252 |
+
<ResponsiveContainer width="100%" height={300}>
|
| 253 |
+
<BarChart
|
| 254 |
+
data={categoryData}
|
| 255 |
+
layout="vertical"
|
| 256 |
+
margin={{ top: 5, right: 40, left: 5, bottom: 5 }}
|
| 257 |
+
>
|
| 258 |
+
<CartesianGrid strokeDasharray="3 3" className="stroke-border" />
|
| 259 |
+
<XAxis type="number" className="text-xs" tick={{ fill: "currentColor" }} />
|
| 260 |
+
<YAxis
|
| 261 |
+
type="category"
|
| 262 |
+
dataKey="name"
|
| 263 |
+
width={180}
|
| 264 |
+
className="text-xs"
|
| 265 |
+
tick={{ fill: "currentColor" }}
|
| 266 |
+
/>
|
| 267 |
+
<Tooltip content={<CustomTooltip />} />
|
| 268 |
+
<Bar
|
| 269 |
+
dataKey="value"
|
| 270 |
+
radius={[0, 4, 4, 0]}
|
| 271 |
+
label={renderCustomBarLabel}
|
| 272 |
+
onClick={(data) => onCategoryClick(data.name)}
|
| 273 |
+
cursor="pointer"
|
| 274 |
+
>
|
| 275 |
+
{categoryData.map((entry, index) => {
|
| 276 |
+
const isSelected = selectedCategory === entry.name
|
| 277 |
+
const shouldGreyscale = selectedCategory && !isSelected
|
| 278 |
+
const color = shouldGreyscale
|
| 279 |
+
? "#94a3b8"
|
| 280 |
+
: CATEGORY_COLORS[index % CATEGORY_COLORS.length]
|
| 281 |
+
return (
|
| 282 |
+
<Cell
|
| 283 |
+
key={`cell-${index}`}
|
| 284 |
+
fill={color}
|
| 285 |
+
opacity={shouldGreyscale ? 0.4 : 1}
|
| 286 |
+
/>
|
| 287 |
+
)
|
| 288 |
+
})}
|
| 289 |
+
</Bar>
|
| 290 |
+
</BarChart>
|
| 291 |
+
</ResponsiveContainer>
|
| 292 |
+
</CardContent>
|
| 293 |
+
</Card>
|
| 294 |
+
</div>
|
| 295 |
+
</div>
|
| 296 |
+
)
|
| 297 |
+
}
|
components/scroll-to-top.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect } from "react"
|
| 4 |
+
import { ArrowUp } from "lucide-react"
|
| 5 |
+
import { Button } from "@/components/ui/button"
|
| 6 |
+
|
| 7 |
+
export function ScrollToTop() {
|
| 8 |
+
const [isVisible, setIsVisible] = useState(false)
|
| 9 |
+
|
| 10 |
+
useEffect(() => {
|
| 11 |
+
const toggleVisibility = () => {
|
| 12 |
+
// Show button when page is scrolled down 300px
|
| 13 |
+
if (window.scrollY > 300) {
|
| 14 |
+
setIsVisible(true)
|
| 15 |
+
} else {
|
| 16 |
+
setIsVisible(false)
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
window.addEventListener("scroll", toggleVisibility)
|
| 21 |
+
|
| 22 |
+
return () => {
|
| 23 |
+
window.removeEventListener("scroll", toggleVisibility)
|
| 24 |
+
}
|
| 25 |
+
}, [])
|
| 26 |
+
|
| 27 |
+
const scrollToTop = () => {
|
| 28 |
+
window.scrollTo({
|
| 29 |
+
top: 0,
|
| 30 |
+
behavior: "smooth",
|
| 31 |
+
})
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return (
|
| 35 |
+
<>
|
| 36 |
+
{isVisible && (
|
| 37 |
+
<Button
|
| 38 |
+
onClick={scrollToTop}
|
| 39 |
+
size="icon"
|
| 40 |
+
className="fixed bottom-8 right-8 z-50 h-12 w-12 rounded-full shadow-lg transition-all duration-300 hover:scale-110"
|
| 41 |
+
aria-label="Scroll to top"
|
| 42 |
+
>
|
| 43 |
+
<ArrowUp className="h-5 w-5" />
|
| 44 |
+
</Button>
|
| 45 |
+
)}
|
| 46 |
+
</>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
components/site-footer.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function SiteFooter() {
|
| 2 |
+
const year = new Date().getFullYear()
|
| 3 |
+
return (
|
| 4 |
+
<footer className="border-t">
|
| 5 |
+
<div className="container mx-auto px-4 md:px-6 py-8 text-sm text-muted-foreground flex flex-col md:flex-row items-center justify-between gap-3">
|
| 6 |
+
<p className="text-center md:text-left">© {year} Awesome Food Allergy Research Datasets</p>
|
| 7 |
+
<p className="text-center md:text-left">Powered by Next.js, Tailwind CSS, and shadcn/ui</p>
|
| 8 |
+
</div>
|
| 9 |
+
</footer>
|
| 10 |
+
)
|
| 11 |
+
}
|
components/site-header.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import Link from "next/link"
|
| 4 |
+
|
| 5 |
+
export function SiteHeader() {
|
| 6 |
+
return (
|
| 7 |
+
<header className="sticky top-0 z-50 border-b bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
| 8 |
+
<div className="container mx-auto h-14 px-4 md:px-6 flex items-center justify-between">
|
| 9 |
+
<Link href="/" className="font-semibold tracking-tight text-sm md:text-base">
|
| 10 |
+
Awesome Food Allergy Research Datasets
|
| 11 |
+
</Link>
|
| 12 |
+
</div>
|
| 13 |
+
</header>
|
| 14 |
+
)
|
| 15 |
+
}
|
components/theme-provider.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import {
|
| 5 |
+
ThemeProvider as NextThemesProvider,
|
| 6 |
+
type ThemeProviderProps,
|
| 7 |
+
} from 'next-themes'
|
| 8 |
+
|
| 9 |
+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
| 10 |
+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
| 11 |
+
}
|
components/theme-toggle.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useEffect, useState } from "react"
|
| 4 |
+
import { useTheme } from "next-themes"
|
| 5 |
+
import { Sun, Moon } from "lucide-react"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
|
| 8 |
+
export function ThemeToggle() {
|
| 9 |
+
const { theme, setTheme } = useTheme()
|
| 10 |
+
const [mounted, setMounted] = useState(false)
|
| 11 |
+
|
| 12 |
+
useEffect(() => setMounted(true), [])
|
| 13 |
+
|
| 14 |
+
const cycleTheme = () => {
|
| 15 |
+
const next = theme === "light" ? "dark" : theme === "dark" ? "system" : "light"
|
| 16 |
+
setTheme(next)
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
if (!mounted) return null
|
| 20 |
+
|
| 21 |
+
return (
|
| 22 |
+
<Button
|
| 23 |
+
variant="ghost"
|
| 24 |
+
size="icon"
|
| 25 |
+
className="relative"
|
| 26 |
+
onClick={cycleTheme}
|
| 27 |
+
aria-label={`Toggle theme (current: ${theme ?? "system"})`}
|
| 28 |
+
>
|
| 29 |
+
<Sun className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
|
| 30 |
+
<Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
|
| 31 |
+
</Button>
|
| 32 |
+
)
|
| 33 |
+
}
|
components/ui/accordion.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as AccordionPrimitive from '@radix-ui/react-accordion'
|
| 5 |
+
import { ChevronDownIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Accordion({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof AccordionPrimitive.Root>) {
|
| 12 |
+
return <AccordionPrimitive.Root data-slot="accordion" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function AccordionItem({
|
| 16 |
+
className,
|
| 17 |
+
...props
|
| 18 |
+
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
| 19 |
+
return (
|
| 20 |
+
<AccordionPrimitive.Item
|
| 21 |
+
data-slot="accordion-item"
|
| 22 |
+
className={cn('border-b last:border-b-0', className)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function AccordionTrigger({
|
| 29 |
+
className,
|
| 30 |
+
children,
|
| 31 |
+
...props
|
| 32 |
+
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
| 33 |
+
return (
|
| 34 |
+
<AccordionPrimitive.Header className="flex">
|
| 35 |
+
<AccordionPrimitive.Trigger
|
| 36 |
+
data-slot="accordion-trigger"
|
| 37 |
+
className={cn(
|
| 38 |
+
'focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180',
|
| 39 |
+
className,
|
| 40 |
+
)}
|
| 41 |
+
{...props}
|
| 42 |
+
>
|
| 43 |
+
{children}
|
| 44 |
+
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
|
| 45 |
+
</AccordionPrimitive.Trigger>
|
| 46 |
+
</AccordionPrimitive.Header>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function AccordionContent({
|
| 51 |
+
className,
|
| 52 |
+
children,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
| 55 |
+
return (
|
| 56 |
+
<AccordionPrimitive.Content
|
| 57 |
+
data-slot="accordion-content"
|
| 58 |
+
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
|
| 59 |
+
{...props}
|
| 60 |
+
>
|
| 61 |
+
<div className={cn('pt-0 pb-4', className)}>{children}</div>
|
| 62 |
+
</AccordionPrimitive.Content>
|
| 63 |
+
)
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
|
components/ui/alert-dialog.tsx
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
import { buttonVariants } from '@/components/ui/button'
|
| 8 |
+
|
| 9 |
+
function AlertDialog({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
|
| 12 |
+
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function AlertDialogTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
|
| 18 |
+
return (
|
| 19 |
+
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function AlertDialogPortal({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
|
| 26 |
+
return (
|
| 27 |
+
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function AlertDialogOverlay({
|
| 32 |
+
className,
|
| 33 |
+
...props
|
| 34 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
|
| 35 |
+
return (
|
| 36 |
+
<AlertDialogPrimitive.Overlay
|
| 37 |
+
data-slot="alert-dialog-overlay"
|
| 38 |
+
className={cn(
|
| 39 |
+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
|
| 40 |
+
className,
|
| 41 |
+
)}
|
| 42 |
+
{...props}
|
| 43 |
+
/>
|
| 44 |
+
)
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function AlertDialogContent({
|
| 48 |
+
className,
|
| 49 |
+
...props
|
| 50 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
|
| 51 |
+
return (
|
| 52 |
+
<AlertDialogPortal>
|
| 53 |
+
<AlertDialogOverlay />
|
| 54 |
+
<AlertDialogPrimitive.Content
|
| 55 |
+
data-slot="alert-dialog-content"
|
| 56 |
+
className={cn(
|
| 57 |
+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
| 58 |
+
className,
|
| 59 |
+
)}
|
| 60 |
+
{...props}
|
| 61 |
+
/>
|
| 62 |
+
</AlertDialogPortal>
|
| 63 |
+
)
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function AlertDialogHeader({
|
| 67 |
+
className,
|
| 68 |
+
...props
|
| 69 |
+
}: React.ComponentProps<'div'>) {
|
| 70 |
+
return (
|
| 71 |
+
<div
|
| 72 |
+
data-slot="alert-dialog-header"
|
| 73 |
+
className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
|
| 74 |
+
{...props}
|
| 75 |
+
/>
|
| 76 |
+
)
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
function AlertDialogFooter({
|
| 80 |
+
className,
|
| 81 |
+
...props
|
| 82 |
+
}: React.ComponentProps<'div'>) {
|
| 83 |
+
return (
|
| 84 |
+
<div
|
| 85 |
+
data-slot="alert-dialog-footer"
|
| 86 |
+
className={cn(
|
| 87 |
+
'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
|
| 88 |
+
className,
|
| 89 |
+
)}
|
| 90 |
+
{...props}
|
| 91 |
+
/>
|
| 92 |
+
)
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function AlertDialogTitle({
|
| 96 |
+
className,
|
| 97 |
+
...props
|
| 98 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
| 99 |
+
return (
|
| 100 |
+
<AlertDialogPrimitive.Title
|
| 101 |
+
data-slot="alert-dialog-title"
|
| 102 |
+
className={cn('text-lg font-semibold', className)}
|
| 103 |
+
{...props}
|
| 104 |
+
/>
|
| 105 |
+
)
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function AlertDialogDescription({
|
| 109 |
+
className,
|
| 110 |
+
...props
|
| 111 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
| 112 |
+
return (
|
| 113 |
+
<AlertDialogPrimitive.Description
|
| 114 |
+
data-slot="alert-dialog-description"
|
| 115 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 116 |
+
{...props}
|
| 117 |
+
/>
|
| 118 |
+
)
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
function AlertDialogAction({
|
| 122 |
+
className,
|
| 123 |
+
...props
|
| 124 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
|
| 125 |
+
return (
|
| 126 |
+
<AlertDialogPrimitive.Action
|
| 127 |
+
className={cn(buttonVariants(), className)}
|
| 128 |
+
{...props}
|
| 129 |
+
/>
|
| 130 |
+
)
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function AlertDialogCancel({
|
| 134 |
+
className,
|
| 135 |
+
...props
|
| 136 |
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
|
| 137 |
+
return (
|
| 138 |
+
<AlertDialogPrimitive.Cancel
|
| 139 |
+
className={cn(buttonVariants({ variant: 'outline' }), className)}
|
| 140 |
+
{...props}
|
| 141 |
+
/>
|
| 142 |
+
)
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
export {
|
| 146 |
+
AlertDialog,
|
| 147 |
+
AlertDialogPortal,
|
| 148 |
+
AlertDialogOverlay,
|
| 149 |
+
AlertDialogTrigger,
|
| 150 |
+
AlertDialogContent,
|
| 151 |
+
AlertDialogHeader,
|
| 152 |
+
AlertDialogFooter,
|
| 153 |
+
AlertDialogTitle,
|
| 154 |
+
AlertDialogDescription,
|
| 155 |
+
AlertDialogAction,
|
| 156 |
+
AlertDialogCancel,
|
| 157 |
+
}
|
components/ui/alert.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 3 |
+
|
| 4 |
+
import { cn } from '@/lib/utils'
|
| 5 |
+
|
| 6 |
+
const alertVariants = cva(
|
| 7 |
+
'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: 'bg-card text-card-foreground',
|
| 12 |
+
destructive:
|
| 13 |
+
'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
|
| 14 |
+
},
|
| 15 |
+
},
|
| 16 |
+
defaultVariants: {
|
| 17 |
+
variant: 'default',
|
| 18 |
+
},
|
| 19 |
+
},
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
function Alert({
|
| 23 |
+
className,
|
| 24 |
+
variant,
|
| 25 |
+
...props
|
| 26 |
+
}: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
|
| 27 |
+
return (
|
| 28 |
+
<div
|
| 29 |
+
data-slot="alert"
|
| 30 |
+
role="alert"
|
| 31 |
+
className={cn(alertVariants({ variant }), className)}
|
| 32 |
+
{...props}
|
| 33 |
+
/>
|
| 34 |
+
)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 38 |
+
return (
|
| 39 |
+
<div
|
| 40 |
+
data-slot="alert-title"
|
| 41 |
+
className={cn(
|
| 42 |
+
'col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight',
|
| 43 |
+
className,
|
| 44 |
+
)}
|
| 45 |
+
{...props}
|
| 46 |
+
/>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function AlertDescription({
|
| 51 |
+
className,
|
| 52 |
+
...props
|
| 53 |
+
}: React.ComponentProps<'div'>) {
|
| 54 |
+
return (
|
| 55 |
+
<div
|
| 56 |
+
data-slot="alert-description"
|
| 57 |
+
className={cn(
|
| 58 |
+
'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',
|
| 59 |
+
className,
|
| 60 |
+
)}
|
| 61 |
+
{...props}
|
| 62 |
+
/>
|
| 63 |
+
)
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
export { Alert, AlertTitle, AlertDescription }
|
components/ui/aspect-ratio.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio'
|
| 4 |
+
|
| 5 |
+
function AspectRatio({
|
| 6 |
+
...props
|
| 7 |
+
}: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {
|
| 8 |
+
return <AspectRatioPrimitive.Root data-slot="aspect-ratio" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
export { AspectRatio }
|
components/ui/avatar.tsx
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as AvatarPrimitive from '@radix-ui/react-avatar'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Avatar({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<AvatarPrimitive.Root
|
| 14 |
+
data-slot="avatar"
|
| 15 |
+
className={cn(
|
| 16 |
+
'relative flex size-8 shrink-0 overflow-hidden rounded-full',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function AvatarImage({
|
| 25 |
+
className,
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
| 28 |
+
return (
|
| 29 |
+
<AvatarPrimitive.Image
|
| 30 |
+
data-slot="avatar-image"
|
| 31 |
+
className={cn('aspect-square size-full', className)}
|
| 32 |
+
{...props}
|
| 33 |
+
/>
|
| 34 |
+
)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function AvatarFallback({
|
| 38 |
+
className,
|
| 39 |
+
...props
|
| 40 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
| 41 |
+
return (
|
| 42 |
+
<AvatarPrimitive.Fallback
|
| 43 |
+
data-slot="avatar-fallback"
|
| 44 |
+
className={cn(
|
| 45 |
+
'bg-muted flex size-full items-center justify-center rounded-full',
|
| 46 |
+
className,
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export { Avatar, AvatarImage, AvatarFallback }
|
components/ui/badge.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * 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-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "border-transparent bg-primary text-primary-foreground shadow 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 shadow 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 }
|
components/ui/breadcrumb.tsx
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 3 |
+
import { ChevronRight, MoreHorizontal } from 'lucide-react'
|
| 4 |
+
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
|
| 7 |
+
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
| 8 |
+
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
| 12 |
+
return (
|
| 13 |
+
<ol
|
| 14 |
+
data-slot="breadcrumb-list"
|
| 15 |
+
className={cn(
|
| 16 |
+
'text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
|
| 25 |
+
return (
|
| 26 |
+
<li
|
| 27 |
+
data-slot="breadcrumb-item"
|
| 28 |
+
className={cn('inline-flex items-center gap-1.5', className)}
|
| 29 |
+
{...props}
|
| 30 |
+
/>
|
| 31 |
+
)
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function BreadcrumbLink({
|
| 35 |
+
asChild,
|
| 36 |
+
className,
|
| 37 |
+
...props
|
| 38 |
+
}: React.ComponentProps<'a'> & {
|
| 39 |
+
asChild?: boolean
|
| 40 |
+
}) {
|
| 41 |
+
const Comp = asChild ? Slot : 'a'
|
| 42 |
+
|
| 43 |
+
return (
|
| 44 |
+
<Comp
|
| 45 |
+
data-slot="breadcrumb-link"
|
| 46 |
+
className={cn('hover:text-foreground transition-colors', className)}
|
| 47 |
+
{...props}
|
| 48 |
+
/>
|
| 49 |
+
)
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
|
| 53 |
+
return (
|
| 54 |
+
<span
|
| 55 |
+
data-slot="breadcrumb-page"
|
| 56 |
+
role="link"
|
| 57 |
+
aria-disabled="true"
|
| 58 |
+
aria-current="page"
|
| 59 |
+
className={cn('text-foreground font-normal', className)}
|
| 60 |
+
{...props}
|
| 61 |
+
/>
|
| 62 |
+
)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function BreadcrumbSeparator({
|
| 66 |
+
children,
|
| 67 |
+
className,
|
| 68 |
+
...props
|
| 69 |
+
}: React.ComponentProps<'li'>) {
|
| 70 |
+
return (
|
| 71 |
+
<li
|
| 72 |
+
data-slot="breadcrumb-separator"
|
| 73 |
+
role="presentation"
|
| 74 |
+
aria-hidden="true"
|
| 75 |
+
className={cn('[&>svg]:size-3.5', className)}
|
| 76 |
+
{...props}
|
| 77 |
+
>
|
| 78 |
+
{children ?? <ChevronRight />}
|
| 79 |
+
</li>
|
| 80 |
+
)
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function BreadcrumbEllipsis({
|
| 84 |
+
className,
|
| 85 |
+
...props
|
| 86 |
+
}: React.ComponentProps<'span'>) {
|
| 87 |
+
return (
|
| 88 |
+
<span
|
| 89 |
+
data-slot="breadcrumb-ellipsis"
|
| 90 |
+
role="presentation"
|
| 91 |
+
aria-hidden="true"
|
| 92 |
+
className={cn('flex size-9 items-center justify-center', className)}
|
| 93 |
+
{...props}
|
| 94 |
+
>
|
| 95 |
+
<MoreHorizontal className="size-4" />
|
| 96 |
+
<span className="sr-only">More</span>
|
| 97 |
+
</span>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
export {
|
| 102 |
+
Breadcrumb,
|
| 103 |
+
BreadcrumbList,
|
| 104 |
+
BreadcrumbItem,
|
| 105 |
+
BreadcrumbLink,
|
| 106 |
+
BreadcrumbPage,
|
| 107 |
+
BreadcrumbSeparator,
|
| 108 |
+
BreadcrumbEllipsis,
|
| 109 |
+
}
|
components/ui/button.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 3 |
+
import { cva, type VariantProps } from 'class-variance-authority'
|
| 4 |
+
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
|
| 7 |
+
const buttonVariants = cva(
|
| 8 |
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default:
|
| 13 |
+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
|
| 14 |
+
destructive:
|
| 15 |
+
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
| 16 |
+
outline:
|
| 17 |
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
| 18 |
+
secondary:
|
| 19 |
+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
|
| 20 |
+
ghost:
|
| 21 |
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
| 22 |
+
link: 'text-primary underline-offset-4 hover:underline',
|
| 23 |
+
},
|
| 24 |
+
size: {
|
| 25 |
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
| 26 |
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
| 27 |
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
| 28 |
+
icon: 'size-9',
|
| 29 |
+
},
|
| 30 |
+
},
|
| 31 |
+
defaultVariants: {
|
| 32 |
+
variant: 'default',
|
| 33 |
+
size: 'default',
|
| 34 |
+
},
|
| 35 |
+
},
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
type ButtonProps = React.ComponentProps<'button'> &
|
| 39 |
+
VariantProps<typeof buttonVariants> & {
|
| 40 |
+
asChild?: boolean
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
| 44 |
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
| 45 |
+
const Comp = asChild ? Slot : 'button'
|
| 46 |
+
|
| 47 |
+
return (
|
| 48 |
+
<Comp
|
| 49 |
+
ref={ref}
|
| 50 |
+
data-slot="button"
|
| 51 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 52 |
+
{...props}
|
| 53 |
+
/>
|
| 54 |
+
)
|
| 55 |
+
},
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
Button.displayName = 'Button'
|
| 59 |
+
|
| 60 |
+
export { Button, buttonVariants }
|
components/ui/calendar.tsx
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import {
|
| 5 |
+
ChevronDownIcon,
|
| 6 |
+
ChevronLeftIcon,
|
| 7 |
+
ChevronRightIcon,
|
| 8 |
+
} from 'lucide-react'
|
| 9 |
+
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker'
|
| 10 |
+
|
| 11 |
+
import { cn } from '@/lib/utils'
|
| 12 |
+
import { Button, buttonVariants } from '@/components/ui/button'
|
| 13 |
+
|
| 14 |
+
function Calendar({
|
| 15 |
+
className,
|
| 16 |
+
classNames,
|
| 17 |
+
showOutsideDays = true,
|
| 18 |
+
captionLayout = 'label',
|
| 19 |
+
buttonVariant = 'ghost',
|
| 20 |
+
formatters,
|
| 21 |
+
components,
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof DayPicker> & {
|
| 24 |
+
buttonVariant?: React.ComponentProps<typeof Button>['variant']
|
| 25 |
+
}) {
|
| 26 |
+
const defaultClassNames = getDefaultClassNames()
|
| 27 |
+
|
| 28 |
+
return (
|
| 29 |
+
<DayPicker
|
| 30 |
+
showOutsideDays={showOutsideDays}
|
| 31 |
+
className={cn(
|
| 32 |
+
'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
|
| 33 |
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
| 34 |
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
| 35 |
+
className,
|
| 36 |
+
)}
|
| 37 |
+
captionLayout={captionLayout}
|
| 38 |
+
formatters={{
|
| 39 |
+
formatMonthDropdown: (date) =>
|
| 40 |
+
date.toLocaleString('default', { month: 'short' }),
|
| 41 |
+
...formatters,
|
| 42 |
+
}}
|
| 43 |
+
classNames={{
|
| 44 |
+
root: cn('w-fit', defaultClassNames.root),
|
| 45 |
+
months: cn(
|
| 46 |
+
'flex gap-4 flex-col md:flex-row relative',
|
| 47 |
+
defaultClassNames.months,
|
| 48 |
+
),
|
| 49 |
+
month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
|
| 50 |
+
nav: cn(
|
| 51 |
+
'flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between',
|
| 52 |
+
defaultClassNames.nav,
|
| 53 |
+
),
|
| 54 |
+
button_previous: cn(
|
| 55 |
+
buttonVariants({ variant: buttonVariant }),
|
| 56 |
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
| 57 |
+
defaultClassNames.button_previous,
|
| 58 |
+
),
|
| 59 |
+
button_next: cn(
|
| 60 |
+
buttonVariants({ variant: buttonVariant }),
|
| 61 |
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
| 62 |
+
defaultClassNames.button_next,
|
| 63 |
+
),
|
| 64 |
+
month_caption: cn(
|
| 65 |
+
'flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)',
|
| 66 |
+
defaultClassNames.month_caption,
|
| 67 |
+
),
|
| 68 |
+
dropdowns: cn(
|
| 69 |
+
'w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5',
|
| 70 |
+
defaultClassNames.dropdowns,
|
| 71 |
+
),
|
| 72 |
+
dropdown_root: cn(
|
| 73 |
+
'relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md',
|
| 74 |
+
defaultClassNames.dropdown_root,
|
| 75 |
+
),
|
| 76 |
+
dropdown: cn(
|
| 77 |
+
'absolute bg-popover inset-0 opacity-0',
|
| 78 |
+
defaultClassNames.dropdown,
|
| 79 |
+
),
|
| 80 |
+
caption_label: cn(
|
| 81 |
+
'select-none font-medium',
|
| 82 |
+
captionLayout === 'label'
|
| 83 |
+
? 'text-sm'
|
| 84 |
+
: 'rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5',
|
| 85 |
+
defaultClassNames.caption_label,
|
| 86 |
+
),
|
| 87 |
+
table: 'w-full border-collapse',
|
| 88 |
+
weekdays: cn('flex', defaultClassNames.weekdays),
|
| 89 |
+
weekday: cn(
|
| 90 |
+
'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none',
|
| 91 |
+
defaultClassNames.weekday,
|
| 92 |
+
),
|
| 93 |
+
week: cn('flex w-full mt-2', defaultClassNames.week),
|
| 94 |
+
week_number_header: cn(
|
| 95 |
+
'select-none w-(--cell-size)',
|
| 96 |
+
defaultClassNames.week_number_header,
|
| 97 |
+
),
|
| 98 |
+
week_number: cn(
|
| 99 |
+
'text-[0.8rem] select-none text-muted-foreground',
|
| 100 |
+
defaultClassNames.week_number,
|
| 101 |
+
),
|
| 102 |
+
day: cn(
|
| 103 |
+
'relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none',
|
| 104 |
+
defaultClassNames.day,
|
| 105 |
+
),
|
| 106 |
+
range_start: cn(
|
| 107 |
+
'rounded-l-md bg-accent',
|
| 108 |
+
defaultClassNames.range_start,
|
| 109 |
+
),
|
| 110 |
+
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
| 111 |
+
range_end: cn('rounded-r-md bg-accent', defaultClassNames.range_end),
|
| 112 |
+
today: cn(
|
| 113 |
+
'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
|
| 114 |
+
defaultClassNames.today,
|
| 115 |
+
),
|
| 116 |
+
outside: cn(
|
| 117 |
+
'text-muted-foreground aria-selected:text-muted-foreground',
|
| 118 |
+
defaultClassNames.outside,
|
| 119 |
+
),
|
| 120 |
+
disabled: cn(
|
| 121 |
+
'text-muted-foreground opacity-50',
|
| 122 |
+
defaultClassNames.disabled,
|
| 123 |
+
),
|
| 124 |
+
hidden: cn('invisible', defaultClassNames.hidden),
|
| 125 |
+
...classNames,
|
| 126 |
+
}}
|
| 127 |
+
components={{
|
| 128 |
+
Root: ({ className, rootRef, ...props }) => {
|
| 129 |
+
return (
|
| 130 |
+
<div
|
| 131 |
+
data-slot="calendar"
|
| 132 |
+
ref={rootRef}
|
| 133 |
+
className={cn(className)}
|
| 134 |
+
{...props}
|
| 135 |
+
/>
|
| 136 |
+
)
|
| 137 |
+
},
|
| 138 |
+
Chevron: ({ className, orientation, ...props }) => {
|
| 139 |
+
if (orientation === 'left') {
|
| 140 |
+
return (
|
| 141 |
+
<ChevronLeftIcon className={cn('size-4', className)} {...props} />
|
| 142 |
+
)
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
if (orientation === 'right') {
|
| 146 |
+
return (
|
| 147 |
+
<ChevronRightIcon
|
| 148 |
+
className={cn('size-4', className)}
|
| 149 |
+
{...props}
|
| 150 |
+
/>
|
| 151 |
+
)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
return (
|
| 155 |
+
<ChevronDownIcon className={cn('size-4', className)} {...props} />
|
| 156 |
+
)
|
| 157 |
+
},
|
| 158 |
+
DayButton: CalendarDayButton,
|
| 159 |
+
WeekNumber: ({ children, ...props }) => {
|
| 160 |
+
return (
|
| 161 |
+
<td {...props}>
|
| 162 |
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
| 163 |
+
{children}
|
| 164 |
+
</div>
|
| 165 |
+
</td>
|
| 166 |
+
)
|
| 167 |
+
},
|
| 168 |
+
...components,
|
| 169 |
+
}}
|
| 170 |
+
{...props}
|
| 171 |
+
/>
|
| 172 |
+
)
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
function CalendarDayButton({
|
| 176 |
+
className,
|
| 177 |
+
day,
|
| 178 |
+
modifiers,
|
| 179 |
+
...props
|
| 180 |
+
}: React.ComponentProps<typeof DayButton>) {
|
| 181 |
+
const defaultClassNames = getDefaultClassNames()
|
| 182 |
+
|
| 183 |
+
const ref = React.useRef<HTMLButtonElement>(null)
|
| 184 |
+
React.useEffect(() => {
|
| 185 |
+
if (modifiers.focused) ref.current?.focus()
|
| 186 |
+
}, [modifiers.focused])
|
| 187 |
+
|
| 188 |
+
return (
|
| 189 |
+
<Button
|
| 190 |
+
ref={ref}
|
| 191 |
+
variant="ghost"
|
| 192 |
+
size="icon"
|
| 193 |
+
data-day={day.date.toLocaleDateString()}
|
| 194 |
+
data-selected-single={
|
| 195 |
+
modifiers.selected &&
|
| 196 |
+
!modifiers.range_start &&
|
| 197 |
+
!modifiers.range_end &&
|
| 198 |
+
!modifiers.range_middle
|
| 199 |
+
}
|
| 200 |
+
data-range-start={modifiers.range_start}
|
| 201 |
+
data-range-end={modifiers.range_end}
|
| 202 |
+
data-range-middle={modifiers.range_middle}
|
| 203 |
+
className={cn(
|
| 204 |
+
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70',
|
| 205 |
+
defaultClassNames.day,
|
| 206 |
+
className,
|
| 207 |
+
)}
|
| 208 |
+
{...props}
|
| 209 |
+
/>
|
| 210 |
+
)
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
export { Calendar, CalendarDayButton }
|
components/ui/card.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
|
| 3 |
+
import { cn } from '@/lib/utils'
|
| 4 |
+
|
| 5 |
+
function Card({ className, ...props }: React.ComponentProps<'div'>) {
|
| 6 |
+
return (
|
| 7 |
+
<div
|
| 8 |
+
data-slot="card"
|
| 9 |
+
className={cn(
|
| 10 |
+
'bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
|
| 11 |
+
className,
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 19 |
+
return (
|
| 20 |
+
<div
|
| 21 |
+
data-slot="card-header"
|
| 22 |
+
className={cn(
|
| 23 |
+
'@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
|
| 24 |
+
className,
|
| 25 |
+
)}
|
| 26 |
+
{...props}
|
| 27 |
+
/>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
| 32 |
+
return (
|
| 33 |
+
<div
|
| 34 |
+
data-slot="card-title"
|
| 35 |
+
className={cn('leading-none font-semibold', className)}
|
| 36 |
+
{...props}
|
| 37 |
+
/>
|
| 38 |
+
)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
|
| 42 |
+
return (
|
| 43 |
+
<div
|
| 44 |
+
data-slot="card-description"
|
| 45 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 46 |
+
{...props}
|
| 47 |
+
/>
|
| 48 |
+
)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
|
| 52 |
+
return (
|
| 53 |
+
<div
|
| 54 |
+
data-slot="card-action"
|
| 55 |
+
className={cn(
|
| 56 |
+
'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
|
| 57 |
+
className,
|
| 58 |
+
)}
|
| 59 |
+
{...props}
|
| 60 |
+
/>
|
| 61 |
+
)
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 65 |
+
return (
|
| 66 |
+
<div
|
| 67 |
+
data-slot="card-content"
|
| 68 |
+
className={cn('px-6', className)}
|
| 69 |
+
{...props}
|
| 70 |
+
/>
|
| 71 |
+
)
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 75 |
+
return (
|
| 76 |
+
<div
|
| 77 |
+
data-slot="card-footer"
|
| 78 |
+
className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
|
| 79 |
+
{...props}
|
| 80 |
+
/>
|
| 81 |
+
)
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
export {
|
| 85 |
+
Card,
|
| 86 |
+
CardHeader,
|
| 87 |
+
CardFooter,
|
| 88 |
+
CardTitle,
|
| 89 |
+
CardAction,
|
| 90 |
+
CardDescription,
|
| 91 |
+
CardContent,
|
| 92 |
+
}
|
components/ui/carousel.tsx
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import useEmblaCarousel, {
|
| 5 |
+
type UseEmblaCarouselType,
|
| 6 |
+
} from 'embla-carousel-react'
|
| 7 |
+
import { ArrowLeft, ArrowRight } from 'lucide-react'
|
| 8 |
+
|
| 9 |
+
import { cn } from '@/lib/utils'
|
| 10 |
+
import { Button } from '@/components/ui/button'
|
| 11 |
+
|
| 12 |
+
type CarouselApi = UseEmblaCarouselType[1]
|
| 13 |
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
| 14 |
+
type CarouselOptions = UseCarouselParameters[0]
|
| 15 |
+
type CarouselPlugin = UseCarouselParameters[1]
|
| 16 |
+
|
| 17 |
+
type CarouselProps = {
|
| 18 |
+
opts?: CarouselOptions
|
| 19 |
+
plugins?: CarouselPlugin
|
| 20 |
+
orientation?: 'horizontal' | 'vertical'
|
| 21 |
+
setApi?: (api: CarouselApi) => void
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
type CarouselContextProps = {
|
| 25 |
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
| 26 |
+
api: ReturnType<typeof useEmblaCarousel>[1]
|
| 27 |
+
scrollPrev: () => void
|
| 28 |
+
scrollNext: () => void
|
| 29 |
+
canScrollPrev: boolean
|
| 30 |
+
canScrollNext: boolean
|
| 31 |
+
} & CarouselProps
|
| 32 |
+
|
| 33 |
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
| 34 |
+
|
| 35 |
+
function useCarousel() {
|
| 36 |
+
const context = React.useContext(CarouselContext)
|
| 37 |
+
|
| 38 |
+
if (!context) {
|
| 39 |
+
throw new Error('useCarousel must be used within a <Carousel />')
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return context
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function Carousel({
|
| 46 |
+
orientation = 'horizontal',
|
| 47 |
+
opts,
|
| 48 |
+
setApi,
|
| 49 |
+
plugins,
|
| 50 |
+
className,
|
| 51 |
+
children,
|
| 52 |
+
...props
|
| 53 |
+
}: React.ComponentProps<'div'> & CarouselProps) {
|
| 54 |
+
const [carouselRef, api] = useEmblaCarousel(
|
| 55 |
+
{
|
| 56 |
+
...opts,
|
| 57 |
+
axis: orientation === 'horizontal' ? 'x' : 'y',
|
| 58 |
+
},
|
| 59 |
+
plugins,
|
| 60 |
+
)
|
| 61 |
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
| 62 |
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
| 63 |
+
|
| 64 |
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
| 65 |
+
if (!api) return
|
| 66 |
+
setCanScrollPrev(api.canScrollPrev())
|
| 67 |
+
setCanScrollNext(api.canScrollNext())
|
| 68 |
+
}, [])
|
| 69 |
+
|
| 70 |
+
const scrollPrev = React.useCallback(() => {
|
| 71 |
+
api?.scrollPrev()
|
| 72 |
+
}, [api])
|
| 73 |
+
|
| 74 |
+
const scrollNext = React.useCallback(() => {
|
| 75 |
+
api?.scrollNext()
|
| 76 |
+
}, [api])
|
| 77 |
+
|
| 78 |
+
const handleKeyDown = React.useCallback(
|
| 79 |
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
| 80 |
+
if (event.key === 'ArrowLeft') {
|
| 81 |
+
event.preventDefault()
|
| 82 |
+
scrollPrev()
|
| 83 |
+
} else if (event.key === 'ArrowRight') {
|
| 84 |
+
event.preventDefault()
|
| 85 |
+
scrollNext()
|
| 86 |
+
}
|
| 87 |
+
},
|
| 88 |
+
[scrollPrev, scrollNext],
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
React.useEffect(() => {
|
| 92 |
+
if (!api || !setApi) return
|
| 93 |
+
setApi(api)
|
| 94 |
+
}, [api, setApi])
|
| 95 |
+
|
| 96 |
+
React.useEffect(() => {
|
| 97 |
+
if (!api) return
|
| 98 |
+
onSelect(api)
|
| 99 |
+
api.on('reInit', onSelect)
|
| 100 |
+
api.on('select', onSelect)
|
| 101 |
+
|
| 102 |
+
return () => {
|
| 103 |
+
api?.off('select', onSelect)
|
| 104 |
+
}
|
| 105 |
+
}, [api, onSelect])
|
| 106 |
+
|
| 107 |
+
return (
|
| 108 |
+
<CarouselContext.Provider
|
| 109 |
+
value={{
|
| 110 |
+
carouselRef,
|
| 111 |
+
api: api,
|
| 112 |
+
opts,
|
| 113 |
+
orientation:
|
| 114 |
+
orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
| 115 |
+
scrollPrev,
|
| 116 |
+
scrollNext,
|
| 117 |
+
canScrollPrev,
|
| 118 |
+
canScrollNext,
|
| 119 |
+
}}
|
| 120 |
+
>
|
| 121 |
+
<div
|
| 122 |
+
onKeyDownCapture={handleKeyDown}
|
| 123 |
+
className={cn('relative', className)}
|
| 124 |
+
role="region"
|
| 125 |
+
aria-roledescription="carousel"
|
| 126 |
+
data-slot="carousel"
|
| 127 |
+
{...props}
|
| 128 |
+
>
|
| 129 |
+
{children}
|
| 130 |
+
</div>
|
| 131 |
+
</CarouselContext.Provider>
|
| 132 |
+
)
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
|
| 136 |
+
const { carouselRef, orientation } = useCarousel()
|
| 137 |
+
|
| 138 |
+
return (
|
| 139 |
+
<div
|
| 140 |
+
ref={carouselRef}
|
| 141 |
+
className="overflow-hidden"
|
| 142 |
+
data-slot="carousel-content"
|
| 143 |
+
>
|
| 144 |
+
<div
|
| 145 |
+
className={cn(
|
| 146 |
+
'flex',
|
| 147 |
+
orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col',
|
| 148 |
+
className,
|
| 149 |
+
)}
|
| 150 |
+
{...props}
|
| 151 |
+
/>
|
| 152 |
+
</div>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
|
| 157 |
+
const { orientation } = useCarousel()
|
| 158 |
+
|
| 159 |
+
return (
|
| 160 |
+
<div
|
| 161 |
+
role="group"
|
| 162 |
+
aria-roledescription="slide"
|
| 163 |
+
data-slot="carousel-item"
|
| 164 |
+
className={cn(
|
| 165 |
+
'min-w-0 shrink-0 grow-0 basis-full',
|
| 166 |
+
orientation === 'horizontal' ? 'pl-4' : 'pt-4',
|
| 167 |
+
className,
|
| 168 |
+
)}
|
| 169 |
+
{...props}
|
| 170 |
+
/>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
function CarouselPrevious({
|
| 175 |
+
className,
|
| 176 |
+
variant = 'outline',
|
| 177 |
+
size = 'icon',
|
| 178 |
+
...props
|
| 179 |
+
}: React.ComponentProps<typeof Button>) {
|
| 180 |
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
| 181 |
+
|
| 182 |
+
return (
|
| 183 |
+
<Button
|
| 184 |
+
data-slot="carousel-previous"
|
| 185 |
+
variant={variant}
|
| 186 |
+
size={size}
|
| 187 |
+
className={cn(
|
| 188 |
+
'absolute size-8 rounded-full',
|
| 189 |
+
orientation === 'horizontal'
|
| 190 |
+
? 'top-1/2 -left-12 -translate-y-1/2'
|
| 191 |
+
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
| 192 |
+
className,
|
| 193 |
+
)}
|
| 194 |
+
disabled={!canScrollPrev}
|
| 195 |
+
onClick={scrollPrev}
|
| 196 |
+
{...props}
|
| 197 |
+
>
|
| 198 |
+
<ArrowLeft />
|
| 199 |
+
<span className="sr-only">Previous slide</span>
|
| 200 |
+
</Button>
|
| 201 |
+
)
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function CarouselNext({
|
| 205 |
+
className,
|
| 206 |
+
variant = 'outline',
|
| 207 |
+
size = 'icon',
|
| 208 |
+
...props
|
| 209 |
+
}: React.ComponentProps<typeof Button>) {
|
| 210 |
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
| 211 |
+
|
| 212 |
+
return (
|
| 213 |
+
<Button
|
| 214 |
+
data-slot="carousel-next"
|
| 215 |
+
variant={variant}
|
| 216 |
+
size={size}
|
| 217 |
+
className={cn(
|
| 218 |
+
'absolute size-8 rounded-full',
|
| 219 |
+
orientation === 'horizontal'
|
| 220 |
+
? 'top-1/2 -right-12 -translate-y-1/2'
|
| 221 |
+
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
| 222 |
+
className,
|
| 223 |
+
)}
|
| 224 |
+
disabled={!canScrollNext}
|
| 225 |
+
onClick={scrollNext}
|
| 226 |
+
{...props}
|
| 227 |
+
>
|
| 228 |
+
<ArrowRight />
|
| 229 |
+
<span className="sr-only">Next slide</span>
|
| 230 |
+
</Button>
|
| 231 |
+
)
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
export {
|
| 235 |
+
type CarouselApi,
|
| 236 |
+
Carousel,
|
| 237 |
+
CarouselContent,
|
| 238 |
+
CarouselItem,
|
| 239 |
+
CarouselPrevious,
|
| 240 |
+
CarouselNext,
|
| 241 |
+
}
|
components/ui/chart.tsx
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as RechartsPrimitive from 'recharts'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
| 9 |
+
const THEMES = { light: '', dark: '.dark' } as const
|
| 10 |
+
|
| 11 |
+
export type ChartConfig = {
|
| 12 |
+
[k in string]: {
|
| 13 |
+
label?: React.ReactNode
|
| 14 |
+
icon?: React.ComponentType
|
| 15 |
+
} & (
|
| 16 |
+
| { color?: string; theme?: never }
|
| 17 |
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
type ChartContextProps = {
|
| 22 |
+
config: ChartConfig
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
| 26 |
+
|
| 27 |
+
function useChart() {
|
| 28 |
+
const context = React.useContext(ChartContext)
|
| 29 |
+
|
| 30 |
+
if (!context) {
|
| 31 |
+
throw new Error('useChart must be used within a <ChartContainer />')
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return context
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function ChartContainer({
|
| 38 |
+
id,
|
| 39 |
+
className,
|
| 40 |
+
children,
|
| 41 |
+
config,
|
| 42 |
+
...props
|
| 43 |
+
}: React.ComponentProps<'div'> & {
|
| 44 |
+
config: ChartConfig
|
| 45 |
+
children: React.ComponentProps<
|
| 46 |
+
typeof RechartsPrimitive.ResponsiveContainer
|
| 47 |
+
>['children']
|
| 48 |
+
}) {
|
| 49 |
+
const uniqueId = React.useId()
|
| 50 |
+
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`
|
| 51 |
+
|
| 52 |
+
return (
|
| 53 |
+
<ChartContext.Provider value={{ config }}>
|
| 54 |
+
<div
|
| 55 |
+
data-slot="chart"
|
| 56 |
+
data-chart={chartId}
|
| 57 |
+
className={cn(
|
| 58 |
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
| 59 |
+
className,
|
| 60 |
+
)}
|
| 61 |
+
{...props}
|
| 62 |
+
>
|
| 63 |
+
<ChartStyle id={chartId} config={config} />
|
| 64 |
+
<RechartsPrimitive.ResponsiveContainer>
|
| 65 |
+
{children}
|
| 66 |
+
</RechartsPrimitive.ResponsiveContainer>
|
| 67 |
+
</div>
|
| 68 |
+
</ChartContext.Provider>
|
| 69 |
+
)
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
| 73 |
+
const colorConfig = Object.entries(config).filter(
|
| 74 |
+
([, config]) => config.theme || config.color,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
if (!colorConfig.length) {
|
| 78 |
+
return null
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
return (
|
| 82 |
+
<style
|
| 83 |
+
dangerouslySetInnerHTML={{
|
| 84 |
+
__html: Object.entries(THEMES)
|
| 85 |
+
.map(
|
| 86 |
+
([theme, prefix]) => `
|
| 87 |
+
${prefix} [data-chart=${id}] {
|
| 88 |
+
${colorConfig
|
| 89 |
+
.map(([key, itemConfig]) => {
|
| 90 |
+
const color =
|
| 91 |
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
| 92 |
+
itemConfig.color
|
| 93 |
+
return color ? ` --color-${key}: ${color};` : null
|
| 94 |
+
})
|
| 95 |
+
.join('\n')}
|
| 96 |
+
}
|
| 97 |
+
`,
|
| 98 |
+
)
|
| 99 |
+
.join('\n'),
|
| 100 |
+
}}
|
| 101 |
+
/>
|
| 102 |
+
)
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
| 106 |
+
|
| 107 |
+
function ChartTooltipContent({
|
| 108 |
+
active,
|
| 109 |
+
payload,
|
| 110 |
+
className,
|
| 111 |
+
indicator = 'dot',
|
| 112 |
+
hideLabel = false,
|
| 113 |
+
hideIndicator = false,
|
| 114 |
+
label,
|
| 115 |
+
labelFormatter,
|
| 116 |
+
labelClassName,
|
| 117 |
+
formatter,
|
| 118 |
+
color,
|
| 119 |
+
nameKey,
|
| 120 |
+
labelKey,
|
| 121 |
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
| 122 |
+
React.ComponentProps<'div'> & {
|
| 123 |
+
hideLabel?: boolean
|
| 124 |
+
hideIndicator?: boolean
|
| 125 |
+
indicator?: 'line' | 'dot' | 'dashed'
|
| 126 |
+
nameKey?: string
|
| 127 |
+
labelKey?: string
|
| 128 |
+
}) {
|
| 129 |
+
const { config } = useChart()
|
| 130 |
+
|
| 131 |
+
const tooltipLabel = React.useMemo(() => {
|
| 132 |
+
if (hideLabel || !payload?.length) {
|
| 133 |
+
return null
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
const [item] = payload
|
| 137 |
+
const key = `${labelKey || item?.dataKey || item?.name || 'value'}`
|
| 138 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 139 |
+
const value =
|
| 140 |
+
!labelKey && typeof label === 'string'
|
| 141 |
+
? config[label as keyof typeof config]?.label || label
|
| 142 |
+
: itemConfig?.label
|
| 143 |
+
|
| 144 |
+
if (labelFormatter) {
|
| 145 |
+
return (
|
| 146 |
+
<div className={cn('font-medium', labelClassName)}>
|
| 147 |
+
{labelFormatter(value, payload)}
|
| 148 |
+
</div>
|
| 149 |
+
)
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
if (!value) {
|
| 153 |
+
return null
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
return <div className={cn('font-medium', labelClassName)}>{value}</div>
|
| 157 |
+
}, [
|
| 158 |
+
label,
|
| 159 |
+
labelFormatter,
|
| 160 |
+
payload,
|
| 161 |
+
hideLabel,
|
| 162 |
+
labelClassName,
|
| 163 |
+
config,
|
| 164 |
+
labelKey,
|
| 165 |
+
])
|
| 166 |
+
|
| 167 |
+
if (!active || !payload?.length) {
|
| 168 |
+
return null
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
const nestLabel = payload.length === 1 && indicator !== 'dot'
|
| 172 |
+
|
| 173 |
+
return (
|
| 174 |
+
<div
|
| 175 |
+
className={cn(
|
| 176 |
+
'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
| 177 |
+
className,
|
| 178 |
+
)}
|
| 179 |
+
>
|
| 180 |
+
{!nestLabel ? tooltipLabel : null}
|
| 181 |
+
<div className="grid gap-1.5">
|
| 182 |
+
{payload.map((item, index) => {
|
| 183 |
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`
|
| 184 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 185 |
+
const indicatorColor = color || item.payload.fill || item.color
|
| 186 |
+
|
| 187 |
+
return (
|
| 188 |
+
<div
|
| 189 |
+
key={item.dataKey}
|
| 190 |
+
className={cn(
|
| 191 |
+
'[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
|
| 192 |
+
indicator === 'dot' && 'items-center',
|
| 193 |
+
)}
|
| 194 |
+
>
|
| 195 |
+
{formatter && item?.value !== undefined && item.name ? (
|
| 196 |
+
formatter(item.value, item.name, item, index, item.payload)
|
| 197 |
+
) : (
|
| 198 |
+
<>
|
| 199 |
+
{itemConfig?.icon ? (
|
| 200 |
+
<itemConfig.icon />
|
| 201 |
+
) : (
|
| 202 |
+
!hideIndicator && (
|
| 203 |
+
<div
|
| 204 |
+
className={cn(
|
| 205 |
+
'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
|
| 206 |
+
{
|
| 207 |
+
'h-2.5 w-2.5': indicator === 'dot',
|
| 208 |
+
'w-1': indicator === 'line',
|
| 209 |
+
'w-0 border-[1.5px] border-dashed bg-transparent':
|
| 210 |
+
indicator === 'dashed',
|
| 211 |
+
'my-0.5': nestLabel && indicator === 'dashed',
|
| 212 |
+
},
|
| 213 |
+
)}
|
| 214 |
+
style={
|
| 215 |
+
{
|
| 216 |
+
'--color-bg': indicatorColor,
|
| 217 |
+
'--color-border': indicatorColor,
|
| 218 |
+
} as React.CSSProperties
|
| 219 |
+
}
|
| 220 |
+
/>
|
| 221 |
+
)
|
| 222 |
+
)}
|
| 223 |
+
<div
|
| 224 |
+
className={cn(
|
| 225 |
+
'flex flex-1 justify-between leading-none',
|
| 226 |
+
nestLabel ? 'items-end' : 'items-center',
|
| 227 |
+
)}
|
| 228 |
+
>
|
| 229 |
+
<div className="grid gap-1.5">
|
| 230 |
+
{nestLabel ? tooltipLabel : null}
|
| 231 |
+
<span className="text-muted-foreground">
|
| 232 |
+
{itemConfig?.label || item.name}
|
| 233 |
+
</span>
|
| 234 |
+
</div>
|
| 235 |
+
{item.value && (
|
| 236 |
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
| 237 |
+
{item.value.toLocaleString()}
|
| 238 |
+
</span>
|
| 239 |
+
)}
|
| 240 |
+
</div>
|
| 241 |
+
</>
|
| 242 |
+
)}
|
| 243 |
+
</div>
|
| 244 |
+
)
|
| 245 |
+
})}
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
)
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
const ChartLegend = RechartsPrimitive.Legend
|
| 252 |
+
|
| 253 |
+
function ChartLegendContent({
|
| 254 |
+
className,
|
| 255 |
+
hideIcon = false,
|
| 256 |
+
payload,
|
| 257 |
+
verticalAlign = 'bottom',
|
| 258 |
+
nameKey,
|
| 259 |
+
}: React.ComponentProps<'div'> &
|
| 260 |
+
Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
|
| 261 |
+
hideIcon?: boolean
|
| 262 |
+
nameKey?: string
|
| 263 |
+
}) {
|
| 264 |
+
const { config } = useChart()
|
| 265 |
+
|
| 266 |
+
if (!payload?.length) {
|
| 267 |
+
return null
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
return (
|
| 271 |
+
<div
|
| 272 |
+
className={cn(
|
| 273 |
+
'flex items-center justify-center gap-4',
|
| 274 |
+
verticalAlign === 'top' ? 'pb-3' : 'pt-3',
|
| 275 |
+
className,
|
| 276 |
+
)}
|
| 277 |
+
>
|
| 278 |
+
{payload.map((item) => {
|
| 279 |
+
const key = `${nameKey || item.dataKey || 'value'}`
|
| 280 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 281 |
+
|
| 282 |
+
return (
|
| 283 |
+
<div
|
| 284 |
+
key={item.value}
|
| 285 |
+
className={
|
| 286 |
+
'[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3'
|
| 287 |
+
}
|
| 288 |
+
>
|
| 289 |
+
{itemConfig?.icon && !hideIcon ? (
|
| 290 |
+
<itemConfig.icon />
|
| 291 |
+
) : (
|
| 292 |
+
<div
|
| 293 |
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
| 294 |
+
style={{
|
| 295 |
+
backgroundColor: item.color,
|
| 296 |
+
}}
|
| 297 |
+
/>
|
| 298 |
+
)}
|
| 299 |
+
{itemConfig?.label}
|
| 300 |
+
</div>
|
| 301 |
+
)
|
| 302 |
+
})}
|
| 303 |
+
</div>
|
| 304 |
+
)
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
// Helper to extract item config from a payload.
|
| 308 |
+
function getPayloadConfigFromPayload(
|
| 309 |
+
config: ChartConfig,
|
| 310 |
+
payload: unknown,
|
| 311 |
+
key: string,
|
| 312 |
+
) {
|
| 313 |
+
if (typeof payload !== 'object' || payload === null) {
|
| 314 |
+
return undefined
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
const payloadPayload =
|
| 318 |
+
'payload' in payload &&
|
| 319 |
+
typeof payload.payload === 'object' &&
|
| 320 |
+
payload.payload !== null
|
| 321 |
+
? payload.payload
|
| 322 |
+
: undefined
|
| 323 |
+
|
| 324 |
+
let configLabelKey: string = key
|
| 325 |
+
|
| 326 |
+
if (
|
| 327 |
+
key in payload &&
|
| 328 |
+
typeof payload[key as keyof typeof payload] === 'string'
|
| 329 |
+
) {
|
| 330 |
+
configLabelKey = payload[key as keyof typeof payload] as string
|
| 331 |
+
} else if (
|
| 332 |
+
payloadPayload &&
|
| 333 |
+
key in payloadPayload &&
|
| 334 |
+
typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
|
| 335 |
+
) {
|
| 336 |
+
configLabelKey = payloadPayload[
|
| 337 |
+
key as keyof typeof payloadPayload
|
| 338 |
+
] as string
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
return configLabelKey in config
|
| 342 |
+
? config[configLabelKey]
|
| 343 |
+
: config[key as keyof typeof config]
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
export {
|
| 347 |
+
ChartContainer,
|
| 348 |
+
ChartTooltip,
|
| 349 |
+
ChartTooltipContent,
|
| 350 |
+
ChartLegend,
|
| 351 |
+
ChartLegendContent,
|
| 352 |
+
ChartStyle,
|
| 353 |
+
}
|
components/ui/checkbox.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
|
| 5 |
+
import { CheckIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Checkbox({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<CheckboxPrimitive.Root
|
| 15 |
+
data-slot="checkbox"
|
| 16 |
+
className={cn(
|
| 17 |
+
'peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
>
|
| 22 |
+
<CheckboxPrimitive.Indicator
|
| 23 |
+
data-slot="checkbox-indicator"
|
| 24 |
+
className="flex items-center justify-center text-current transition-none"
|
| 25 |
+
>
|
| 26 |
+
<CheckIcon className="size-3.5" />
|
| 27 |
+
</CheckboxPrimitive.Indicator>
|
| 28 |
+
</CheckboxPrimitive.Root>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
export { Checkbox }
|
components/ui/collapsible.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible'
|
| 4 |
+
|
| 5 |
+
function Collapsible({
|
| 6 |
+
...props
|
| 7 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
| 8 |
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function CollapsibleTrigger({
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
| 14 |
+
return (
|
| 15 |
+
<CollapsiblePrimitive.CollapsibleTrigger
|
| 16 |
+
data-slot="collapsible-trigger"
|
| 17 |
+
{...props}
|
| 18 |
+
/>
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function CollapsibleContent({
|
| 23 |
+
...props
|
| 24 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
| 25 |
+
return (
|
| 26 |
+
<CollapsiblePrimitive.CollapsibleContent
|
| 27 |
+
data-slot="collapsible-content"
|
| 28 |
+
{...props}
|
| 29 |
+
/>
|
| 30 |
+
)
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
components/ui/command.tsx
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { Command as CommandPrimitive } from 'cmdk'
|
| 5 |
+
import { SearchIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
import {
|
| 9 |
+
Dialog,
|
| 10 |
+
DialogContent,
|
| 11 |
+
DialogDescription,
|
| 12 |
+
DialogHeader,
|
| 13 |
+
DialogTitle,
|
| 14 |
+
} from '@/components/ui/dialog'
|
| 15 |
+
|
| 16 |
+
function Command({
|
| 17 |
+
className,
|
| 18 |
+
...props
|
| 19 |
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
| 20 |
+
return (
|
| 21 |
+
<CommandPrimitive
|
| 22 |
+
data-slot="command"
|
| 23 |
+
className={cn(
|
| 24 |
+
'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
|
| 25 |
+
className,
|
| 26 |
+
)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function CommandDialog({
|
| 33 |
+
title = 'Command Palette',
|
| 34 |
+
description = 'Search for a command to run...',
|
| 35 |
+
children,
|
| 36 |
+
className,
|
| 37 |
+
showCloseButton = true,
|
| 38 |
+
...props
|
| 39 |
+
}: React.ComponentProps<typeof Dialog> & {
|
| 40 |
+
title?: string
|
| 41 |
+
description?: string
|
| 42 |
+
className?: string
|
| 43 |
+
showCloseButton?: boolean
|
| 44 |
+
}) {
|
| 45 |
+
return (
|
| 46 |
+
<Dialog {...props}>
|
| 47 |
+
<DialogHeader className="sr-only">
|
| 48 |
+
<DialogTitle>{title}</DialogTitle>
|
| 49 |
+
<DialogDescription>{description}</DialogDescription>
|
| 50 |
+
</DialogHeader>
|
| 51 |
+
<DialogContent
|
| 52 |
+
className={cn('overflow-hidden p-0', className)}
|
| 53 |
+
showCloseButton={showCloseButton}
|
| 54 |
+
>
|
| 55 |
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
| 56 |
+
{children}
|
| 57 |
+
</Command>
|
| 58 |
+
</DialogContent>
|
| 59 |
+
</Dialog>
|
| 60 |
+
)
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
function CommandInput({
|
| 64 |
+
className,
|
| 65 |
+
...props
|
| 66 |
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
| 67 |
+
return (
|
| 68 |
+
<div
|
| 69 |
+
data-slot="command-input-wrapper"
|
| 70 |
+
className="flex h-9 items-center gap-2 border-b px-3"
|
| 71 |
+
>
|
| 72 |
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
| 73 |
+
<CommandPrimitive.Input
|
| 74 |
+
data-slot="command-input"
|
| 75 |
+
className={cn(
|
| 76 |
+
'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
|
| 77 |
+
className,
|
| 78 |
+
)}
|
| 79 |
+
{...props}
|
| 80 |
+
/>
|
| 81 |
+
</div>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function CommandList({
|
| 86 |
+
className,
|
| 87 |
+
...props
|
| 88 |
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
| 89 |
+
return (
|
| 90 |
+
<CommandPrimitive.List
|
| 91 |
+
data-slot="command-list"
|
| 92 |
+
className={cn(
|
| 93 |
+
'max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto',
|
| 94 |
+
className,
|
| 95 |
+
)}
|
| 96 |
+
{...props}
|
| 97 |
+
/>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function CommandEmpty({
|
| 102 |
+
...props
|
| 103 |
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
| 104 |
+
return (
|
| 105 |
+
<CommandPrimitive.Empty
|
| 106 |
+
data-slot="command-empty"
|
| 107 |
+
className="py-6 text-center text-sm"
|
| 108 |
+
{...props}
|
| 109 |
+
/>
|
| 110 |
+
)
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function CommandGroup({
|
| 114 |
+
className,
|
| 115 |
+
...props
|
| 116 |
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
| 117 |
+
return (
|
| 118 |
+
<CommandPrimitive.Group
|
| 119 |
+
data-slot="command-group"
|
| 120 |
+
className={cn(
|
| 121 |
+
'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
|
| 122 |
+
className,
|
| 123 |
+
)}
|
| 124 |
+
{...props}
|
| 125 |
+
/>
|
| 126 |
+
)
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
function CommandSeparator({
|
| 130 |
+
className,
|
| 131 |
+
...props
|
| 132 |
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
| 133 |
+
return (
|
| 134 |
+
<CommandPrimitive.Separator
|
| 135 |
+
data-slot="command-separator"
|
| 136 |
+
className={cn('bg-border -mx-1 h-px', className)}
|
| 137 |
+
{...props}
|
| 138 |
+
/>
|
| 139 |
+
)
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
function CommandItem({
|
| 143 |
+
className,
|
| 144 |
+
...props
|
| 145 |
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
| 146 |
+
return (
|
| 147 |
+
<CommandPrimitive.Item
|
| 148 |
+
data-slot="command-item"
|
| 149 |
+
className={cn(
|
| 150 |
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 151 |
+
className,
|
| 152 |
+
)}
|
| 153 |
+
{...props}
|
| 154 |
+
/>
|
| 155 |
+
)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
function CommandShortcut({
|
| 159 |
+
className,
|
| 160 |
+
...props
|
| 161 |
+
}: React.ComponentProps<'span'>) {
|
| 162 |
+
return (
|
| 163 |
+
<span
|
| 164 |
+
data-slot="command-shortcut"
|
| 165 |
+
className={cn(
|
| 166 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 167 |
+
className,
|
| 168 |
+
)}
|
| 169 |
+
{...props}
|
| 170 |
+
/>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
export {
|
| 175 |
+
Command,
|
| 176 |
+
CommandDialog,
|
| 177 |
+
CommandInput,
|
| 178 |
+
CommandList,
|
| 179 |
+
CommandEmpty,
|
| 180 |
+
CommandGroup,
|
| 181 |
+
CommandItem,
|
| 182 |
+
CommandShortcut,
|
| 183 |
+
CommandSeparator,
|
| 184 |
+
}
|
components/ui/context-menu.tsx
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function ContextMenu({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
| 12 |
+
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function ContextMenuTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>) {
|
| 18 |
+
return (
|
| 19 |
+
<ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function ContextMenuGroup({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Group>) {
|
| 26 |
+
return (
|
| 27 |
+
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function ContextMenuPortal({
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Portal>) {
|
| 34 |
+
return (
|
| 35 |
+
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
| 36 |
+
)
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function ContextMenuSub({
|
| 40 |
+
...props
|
| 41 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Sub>) {
|
| 42 |
+
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function ContextMenuRadioGroup({
|
| 46 |
+
...props
|
| 47 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>) {
|
| 48 |
+
return (
|
| 49 |
+
<ContextMenuPrimitive.RadioGroup
|
| 50 |
+
data-slot="context-menu-radio-group"
|
| 51 |
+
{...props}
|
| 52 |
+
/>
|
| 53 |
+
)
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function ContextMenuSubTrigger({
|
| 57 |
+
className,
|
| 58 |
+
inset,
|
| 59 |
+
children,
|
| 60 |
+
...props
|
| 61 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
| 62 |
+
inset?: boolean
|
| 63 |
+
}) {
|
| 64 |
+
return (
|
| 65 |
+
<ContextMenuPrimitive.SubTrigger
|
| 66 |
+
data-slot="context-menu-sub-trigger"
|
| 67 |
+
data-inset={inset}
|
| 68 |
+
className={cn(
|
| 69 |
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 70 |
+
className,
|
| 71 |
+
)}
|
| 72 |
+
{...props}
|
| 73 |
+
>
|
| 74 |
+
{children}
|
| 75 |
+
<ChevronRightIcon className="ml-auto" />
|
| 76 |
+
</ContextMenuPrimitive.SubTrigger>
|
| 77 |
+
)
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
function ContextMenuSubContent({
|
| 81 |
+
className,
|
| 82 |
+
...props
|
| 83 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
| 84 |
+
return (
|
| 85 |
+
<ContextMenuPrimitive.SubContent
|
| 86 |
+
data-slot="context-menu-sub-content"
|
| 87 |
+
className={cn(
|
| 88 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 89 |
+
className,
|
| 90 |
+
)}
|
| 91 |
+
{...props}
|
| 92 |
+
/>
|
| 93 |
+
)
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
function ContextMenuContent({
|
| 97 |
+
className,
|
| 98 |
+
...props
|
| 99 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
| 100 |
+
return (
|
| 101 |
+
<ContextMenuPrimitive.Portal>
|
| 102 |
+
<ContextMenuPrimitive.Content
|
| 103 |
+
data-slot="context-menu-content"
|
| 104 |
+
className={cn(
|
| 105 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md',
|
| 106 |
+
className,
|
| 107 |
+
)}
|
| 108 |
+
{...props}
|
| 109 |
+
/>
|
| 110 |
+
</ContextMenuPrimitive.Portal>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
function ContextMenuItem({
|
| 115 |
+
className,
|
| 116 |
+
inset,
|
| 117 |
+
variant = 'default',
|
| 118 |
+
...props
|
| 119 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
| 120 |
+
inset?: boolean
|
| 121 |
+
variant?: 'default' | 'destructive'
|
| 122 |
+
}) {
|
| 123 |
+
return (
|
| 124 |
+
<ContextMenuPrimitive.Item
|
| 125 |
+
data-slot="context-menu-item"
|
| 126 |
+
data-inset={inset}
|
| 127 |
+
data-variant={variant}
|
| 128 |
+
className={cn(
|
| 129 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 130 |
+
className,
|
| 131 |
+
)}
|
| 132 |
+
{...props}
|
| 133 |
+
/>
|
| 134 |
+
)
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
function ContextMenuCheckboxItem({
|
| 138 |
+
className,
|
| 139 |
+
children,
|
| 140 |
+
checked,
|
| 141 |
+
...props
|
| 142 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>) {
|
| 143 |
+
return (
|
| 144 |
+
<ContextMenuPrimitive.CheckboxItem
|
| 145 |
+
data-slot="context-menu-checkbox-item"
|
| 146 |
+
className={cn(
|
| 147 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 148 |
+
className,
|
| 149 |
+
)}
|
| 150 |
+
checked={checked}
|
| 151 |
+
{...props}
|
| 152 |
+
>
|
| 153 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 154 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 155 |
+
<CheckIcon className="size-4" />
|
| 156 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 157 |
+
</span>
|
| 158 |
+
{children}
|
| 159 |
+
</ContextMenuPrimitive.CheckboxItem>
|
| 160 |
+
)
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
function ContextMenuRadioItem({
|
| 164 |
+
className,
|
| 165 |
+
children,
|
| 166 |
+
...props
|
| 167 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>) {
|
| 168 |
+
return (
|
| 169 |
+
<ContextMenuPrimitive.RadioItem
|
| 170 |
+
data-slot="context-menu-radio-item"
|
| 171 |
+
className={cn(
|
| 172 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 173 |
+
className,
|
| 174 |
+
)}
|
| 175 |
+
{...props}
|
| 176 |
+
>
|
| 177 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 178 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 179 |
+
<CircleIcon className="size-2 fill-current" />
|
| 180 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 181 |
+
</span>
|
| 182 |
+
{children}
|
| 183 |
+
</ContextMenuPrimitive.RadioItem>
|
| 184 |
+
)
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function ContextMenuLabel({
|
| 188 |
+
className,
|
| 189 |
+
inset,
|
| 190 |
+
...props
|
| 191 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
| 192 |
+
inset?: boolean
|
| 193 |
+
}) {
|
| 194 |
+
return (
|
| 195 |
+
<ContextMenuPrimitive.Label
|
| 196 |
+
data-slot="context-menu-label"
|
| 197 |
+
data-inset={inset}
|
| 198 |
+
className={cn(
|
| 199 |
+
'text-foreground px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 200 |
+
className,
|
| 201 |
+
)}
|
| 202 |
+
{...props}
|
| 203 |
+
/>
|
| 204 |
+
)
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function ContextMenuSeparator({
|
| 208 |
+
className,
|
| 209 |
+
...props
|
| 210 |
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
| 211 |
+
return (
|
| 212 |
+
<ContextMenuPrimitive.Separator
|
| 213 |
+
data-slot="context-menu-separator"
|
| 214 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 215 |
+
{...props}
|
| 216 |
+
/>
|
| 217 |
+
)
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
function ContextMenuShortcut({
|
| 221 |
+
className,
|
| 222 |
+
...props
|
| 223 |
+
}: React.ComponentProps<'span'>) {
|
| 224 |
+
return (
|
| 225 |
+
<span
|
| 226 |
+
data-slot="context-menu-shortcut"
|
| 227 |
+
className={cn(
|
| 228 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 229 |
+
className,
|
| 230 |
+
)}
|
| 231 |
+
{...props}
|
| 232 |
+
/>
|
| 233 |
+
)
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
export {
|
| 237 |
+
ContextMenu,
|
| 238 |
+
ContextMenuTrigger,
|
| 239 |
+
ContextMenuContent,
|
| 240 |
+
ContextMenuItem,
|
| 241 |
+
ContextMenuCheckboxItem,
|
| 242 |
+
ContextMenuRadioItem,
|
| 243 |
+
ContextMenuLabel,
|
| 244 |
+
ContextMenuSeparator,
|
| 245 |
+
ContextMenuShortcut,
|
| 246 |
+
ContextMenuGroup,
|
| 247 |
+
ContextMenuPortal,
|
| 248 |
+
ContextMenuSub,
|
| 249 |
+
ContextMenuSubContent,
|
| 250 |
+
ContextMenuSubTrigger,
|
| 251 |
+
ContextMenuRadioGroup,
|
| 252 |
+
}
|
components/ui/dialog.tsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
| 5 |
+
import { XIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Dialog({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
| 12 |
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DialogTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
| 18 |
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function DialogPortal({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
| 24 |
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function DialogClose({
|
| 28 |
+
...props
|
| 29 |
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
| 30 |
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function DialogOverlay({
|
| 34 |
+
className,
|
| 35 |
+
...props
|
| 36 |
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
| 37 |
+
return (
|
| 38 |
+
<DialogPrimitive.Overlay
|
| 39 |
+
data-slot="dialog-overlay"
|
| 40 |
+
className={cn(
|
| 41 |
+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function DialogContent({
|
| 50 |
+
className,
|
| 51 |
+
children,
|
| 52 |
+
showCloseButton = true,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
| 55 |
+
showCloseButton?: boolean
|
| 56 |
+
}) {
|
| 57 |
+
return (
|
| 58 |
+
<DialogPortal data-slot="dialog-portal">
|
| 59 |
+
<DialogOverlay />
|
| 60 |
+
<DialogPrimitive.Content
|
| 61 |
+
data-slot="dialog-content"
|
| 62 |
+
className={cn(
|
| 63 |
+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
{children}
|
| 69 |
+
{showCloseButton && (
|
| 70 |
+
<DialogPrimitive.Close
|
| 71 |
+
data-slot="dialog-close"
|
| 72 |
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
| 73 |
+
>
|
| 74 |
+
<XIcon />
|
| 75 |
+
<span className="sr-only">Close</span>
|
| 76 |
+
</DialogPrimitive.Close>
|
| 77 |
+
)}
|
| 78 |
+
</DialogPrimitive.Content>
|
| 79 |
+
</DialogPortal>
|
| 80 |
+
)
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 84 |
+
return (
|
| 85 |
+
<div
|
| 86 |
+
data-slot="dialog-header"
|
| 87 |
+
className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
|
| 88 |
+
{...props}
|
| 89 |
+
/>
|
| 90 |
+
)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 94 |
+
return (
|
| 95 |
+
<div
|
| 96 |
+
data-slot="dialog-footer"
|
| 97 |
+
className={cn(
|
| 98 |
+
'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
|
| 99 |
+
className,
|
| 100 |
+
)}
|
| 101 |
+
{...props}
|
| 102 |
+
/>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function DialogTitle({
|
| 107 |
+
className,
|
| 108 |
+
...props
|
| 109 |
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
| 110 |
+
return (
|
| 111 |
+
<DialogPrimitive.Title
|
| 112 |
+
data-slot="dialog-title"
|
| 113 |
+
className={cn('text-lg leading-none font-semibold', className)}
|
| 114 |
+
{...props}
|
| 115 |
+
/>
|
| 116 |
+
)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function DialogDescription({
|
| 120 |
+
className,
|
| 121 |
+
...props
|
| 122 |
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
| 123 |
+
return (
|
| 124 |
+
<DialogPrimitive.Description
|
| 125 |
+
data-slot="dialog-description"
|
| 126 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 127 |
+
{...props}
|
| 128 |
+
/>
|
| 129 |
+
)
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
export {
|
| 133 |
+
Dialog,
|
| 134 |
+
DialogClose,
|
| 135 |
+
DialogContent,
|
| 136 |
+
DialogDescription,
|
| 137 |
+
DialogFooter,
|
| 138 |
+
DialogHeader,
|
| 139 |
+
DialogOverlay,
|
| 140 |
+
DialogPortal,
|
| 141 |
+
DialogTitle,
|
| 142 |
+
DialogTrigger,
|
| 143 |
+
}
|
components/ui/drawer.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { Drawer as DrawerPrimitive } from 'vaul'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Drawer({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
| 11 |
+
return <DrawerPrimitive.Root data-slot="drawer" {...props} />
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function DrawerTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
| 17 |
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function DrawerPortal({
|
| 21 |
+
...props
|
| 22 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
| 23 |
+
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function DrawerClose({
|
| 27 |
+
...props
|
| 28 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
| 29 |
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function DrawerOverlay({
|
| 33 |
+
className,
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {
|
| 36 |
+
return (
|
| 37 |
+
<DrawerPrimitive.Overlay
|
| 38 |
+
data-slot="drawer-overlay"
|
| 39 |
+
className={cn(
|
| 40 |
+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
|
| 41 |
+
className,
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function DrawerContent({
|
| 49 |
+
className,
|
| 50 |
+
children,
|
| 51 |
+
...props
|
| 52 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Content>) {
|
| 53 |
+
return (
|
| 54 |
+
<DrawerPortal data-slot="drawer-portal">
|
| 55 |
+
<DrawerOverlay />
|
| 56 |
+
<DrawerPrimitive.Content
|
| 57 |
+
data-slot="drawer-content"
|
| 58 |
+
className={cn(
|
| 59 |
+
'group/drawer-content bg-background fixed z-50 flex h-auto flex-col',
|
| 60 |
+
'data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b',
|
| 61 |
+
'data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t',
|
| 62 |
+
'data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm',
|
| 63 |
+
'data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm',
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
<div className="bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />
|
| 69 |
+
{children}
|
| 70 |
+
</DrawerPrimitive.Content>
|
| 71 |
+
</DrawerPortal>
|
| 72 |
+
)
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
| 76 |
+
return (
|
| 77 |
+
<div
|
| 78 |
+
data-slot="drawer-header"
|
| 79 |
+
className={cn(
|
| 80 |
+
'flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left',
|
| 81 |
+
className,
|
| 82 |
+
)}
|
| 83 |
+
{...props}
|
| 84 |
+
/>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
| 89 |
+
return (
|
| 90 |
+
<div
|
| 91 |
+
data-slot="drawer-footer"
|
| 92 |
+
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
|
| 93 |
+
{...props}
|
| 94 |
+
/>
|
| 95 |
+
)
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function DrawerTitle({
|
| 99 |
+
className,
|
| 100 |
+
...props
|
| 101 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
| 102 |
+
return (
|
| 103 |
+
<DrawerPrimitive.Title
|
| 104 |
+
data-slot="drawer-title"
|
| 105 |
+
className={cn('text-foreground font-semibold', className)}
|
| 106 |
+
{...props}
|
| 107 |
+
/>
|
| 108 |
+
)
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function DrawerDescription({
|
| 112 |
+
className,
|
| 113 |
+
...props
|
| 114 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Description>) {
|
| 115 |
+
return (
|
| 116 |
+
<DrawerPrimitive.Description
|
| 117 |
+
data-slot="drawer-description"
|
| 118 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 119 |
+
{...props}
|
| 120 |
+
/>
|
| 121 |
+
)
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
export {
|
| 125 |
+
Drawer,
|
| 126 |
+
DrawerPortal,
|
| 127 |
+
DrawerOverlay,
|
| 128 |
+
DrawerTrigger,
|
| 129 |
+
DrawerClose,
|
| 130 |
+
DrawerContent,
|
| 131 |
+
DrawerHeader,
|
| 132 |
+
DrawerFooter,
|
| 133 |
+
DrawerTitle,
|
| 134 |
+
DrawerDescription,
|
| 135 |
+
}
|
components/ui/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function DropdownMenu({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
| 12 |
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DropdownMenuPortal({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
| 18 |
+
return (
|
| 19 |
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function DropdownMenuTrigger({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
| 26 |
+
return (
|
| 27 |
+
<DropdownMenuPrimitive.Trigger
|
| 28 |
+
data-slot="dropdown-menu-trigger"
|
| 29 |
+
{...props}
|
| 30 |
+
/>
|
| 31 |
+
)
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function DropdownMenuContent({
|
| 35 |
+
className,
|
| 36 |
+
sideOffset = 4,
|
| 37 |
+
...props
|
| 38 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
| 39 |
+
return (
|
| 40 |
+
<DropdownMenuPrimitive.Portal>
|
| 41 |
+
<DropdownMenuPrimitive.Content
|
| 42 |
+
data-slot="dropdown-menu-content"
|
| 43 |
+
sideOffset={sideOffset}
|
| 44 |
+
className={cn(
|
| 45 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md w-(--radix-dropdown-menu-trigger-width)',
|
| 46 |
+
className,
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
</DropdownMenuPrimitive.Portal>
|
| 51 |
+
)
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function DropdownMenuGroup({
|
| 55 |
+
...props
|
| 56 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
| 57 |
+
return (
|
| 58 |
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
| 59 |
+
)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function DropdownMenuItem({
|
| 63 |
+
className,
|
| 64 |
+
inset,
|
| 65 |
+
variant = 'default',
|
| 66 |
+
...props
|
| 67 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
| 68 |
+
inset?: boolean
|
| 69 |
+
variant?: 'default' | 'destructive'
|
| 70 |
+
}) {
|
| 71 |
+
return (
|
| 72 |
+
<DropdownMenuPrimitive.Item
|
| 73 |
+
data-slot="dropdown-menu-item"
|
| 74 |
+
data-inset={inset}
|
| 75 |
+
data-variant={variant}
|
| 76 |
+
className={cn(
|
| 77 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 78 |
+
className,
|
| 79 |
+
)}
|
| 80 |
+
{...props}
|
| 81 |
+
/>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function DropdownMenuCheckboxItem({
|
| 86 |
+
className,
|
| 87 |
+
children,
|
| 88 |
+
checked,
|
| 89 |
+
...props
|
| 90 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
| 91 |
+
return (
|
| 92 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 93 |
+
data-slot="dropdown-menu-checkbox-item"
|
| 94 |
+
className={cn(
|
| 95 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 96 |
+
className,
|
| 97 |
+
)}
|
| 98 |
+
checked={checked}
|
| 99 |
+
{...props}
|
| 100 |
+
>
|
| 101 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 102 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 103 |
+
<CheckIcon className="size-4" />
|
| 104 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 105 |
+
</span>
|
| 106 |
+
{children}
|
| 107 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 108 |
+
)
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function DropdownMenuRadioGroup({
|
| 112 |
+
...props
|
| 113 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
| 114 |
+
return (
|
| 115 |
+
<DropdownMenuPrimitive.RadioGroup
|
| 116 |
+
data-slot="dropdown-menu-radio-group"
|
| 117 |
+
{...props}
|
| 118 |
+
/>
|
| 119 |
+
)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function DropdownMenuRadioItem({
|
| 123 |
+
className,
|
| 124 |
+
children,
|
| 125 |
+
...props
|
| 126 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
| 127 |
+
return (
|
| 128 |
+
<DropdownMenuPrimitive.RadioItem
|
| 129 |
+
data-slot="dropdown-menu-radio-item"
|
| 130 |
+
className={cn(
|
| 131 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 132 |
+
className,
|
| 133 |
+
)}
|
| 134 |
+
{...props}
|
| 135 |
+
>
|
| 136 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 137 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 138 |
+
<CircleIcon className="size-2 fill-current" />
|
| 139 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 140 |
+
</span>
|
| 141 |
+
{children}
|
| 142 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 143 |
+
)
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function DropdownMenuLabel({
|
| 147 |
+
className,
|
| 148 |
+
inset,
|
| 149 |
+
...props
|
| 150 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
| 151 |
+
inset?: boolean
|
| 152 |
+
}) {
|
| 153 |
+
return (
|
| 154 |
+
<DropdownMenuPrimitive.Label
|
| 155 |
+
data-slot="dropdown-menu-label"
|
| 156 |
+
data-inset={inset}
|
| 157 |
+
className={cn(
|
| 158 |
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 159 |
+
className,
|
| 160 |
+
)}
|
| 161 |
+
{...props}
|
| 162 |
+
/>
|
| 163 |
+
)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function DropdownMenuSeparator({
|
| 167 |
+
className,
|
| 168 |
+
...props
|
| 169 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
| 170 |
+
return (
|
| 171 |
+
<DropdownMenuPrimitive.Separator
|
| 172 |
+
data-slot="dropdown-menu-separator"
|
| 173 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 174 |
+
{...props}
|
| 175 |
+
/>
|
| 176 |
+
)
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
function DropdownMenuShortcut({
|
| 180 |
+
className,
|
| 181 |
+
...props
|
| 182 |
+
}: React.ComponentProps<'span'>) {
|
| 183 |
+
return (
|
| 184 |
+
<span
|
| 185 |
+
data-slot="dropdown-menu-shortcut"
|
| 186 |
+
className={cn(
|
| 187 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 188 |
+
className,
|
| 189 |
+
)}
|
| 190 |
+
{...props}
|
| 191 |
+
/>
|
| 192 |
+
)
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function DropdownMenuSub({
|
| 196 |
+
...props
|
| 197 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
| 198 |
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function DropdownMenuSubTrigger({
|
| 202 |
+
className,
|
| 203 |
+
inset,
|
| 204 |
+
children,
|
| 205 |
+
...props
|
| 206 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 207 |
+
inset?: boolean
|
| 208 |
+
}) {
|
| 209 |
+
return (
|
| 210 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 211 |
+
data-slot="dropdown-menu-sub-trigger"
|
| 212 |
+
data-inset={inset}
|
| 213 |
+
className={cn(
|
| 214 |
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8',
|
| 215 |
+
className,
|
| 216 |
+
)}
|
| 217 |
+
{...props}
|
| 218 |
+
>
|
| 219 |
+
{children}
|
| 220 |
+
<ChevronRightIcon className="ml-auto size-4" />
|
| 221 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 222 |
+
)
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function DropdownMenuSubContent({
|
| 226 |
+
className,
|
| 227 |
+
...props
|
| 228 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
| 229 |
+
return (
|
| 230 |
+
<DropdownMenuPrimitive.SubContent
|
| 231 |
+
data-slot="dropdown-menu-sub-content"
|
| 232 |
+
className={cn(
|
| 233 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 234 |
+
className,
|
| 235 |
+
)}
|
| 236 |
+
{...props}
|
| 237 |
+
/>
|
| 238 |
+
)
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
export {
|
| 242 |
+
DropdownMenu,
|
| 243 |
+
DropdownMenuPortal,
|
| 244 |
+
DropdownMenuTrigger,
|
| 245 |
+
DropdownMenuContent,
|
| 246 |
+
DropdownMenuGroup,
|
| 247 |
+
DropdownMenuLabel,
|
| 248 |
+
DropdownMenuItem,
|
| 249 |
+
DropdownMenuCheckboxItem,
|
| 250 |
+
DropdownMenuRadioGroup,
|
| 251 |
+
DropdownMenuRadioItem,
|
| 252 |
+
DropdownMenuSeparator,
|
| 253 |
+
DropdownMenuShortcut,
|
| 254 |
+
DropdownMenuSub,
|
| 255 |
+
DropdownMenuSubTrigger,
|
| 256 |
+
DropdownMenuSubContent,
|
| 257 |
+
}
|
components/ui/form.tsx
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
| 5 |
+
import { Slot } from '@radix-ui/react-slot'
|
| 6 |
+
import {
|
| 7 |
+
Controller,
|
| 8 |
+
FormProvider,
|
| 9 |
+
useFormContext,
|
| 10 |
+
useFormState,
|
| 11 |
+
type ControllerProps,
|
| 12 |
+
type FieldPath,
|
| 13 |
+
type FieldValues,
|
| 14 |
+
} from 'react-hook-form'
|
| 15 |
+
|
| 16 |
+
import { cn } from '@/lib/utils'
|
| 17 |
+
import { Label } from '@/components/ui/label'
|
| 18 |
+
|
| 19 |
+
const Form = FormProvider
|
| 20 |
+
|
| 21 |
+
type FormFieldContextValue<
|
| 22 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 23 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 24 |
+
> = {
|
| 25 |
+
name: TName
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
| 29 |
+
{} as FormFieldContextValue,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
const FormField = <
|
| 33 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 34 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 35 |
+
>({
|
| 36 |
+
...props
|
| 37 |
+
}: ControllerProps<TFieldValues, TName>) => {
|
| 38 |
+
return (
|
| 39 |
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
| 40 |
+
<Controller {...props} />
|
| 41 |
+
</FormFieldContext.Provider>
|
| 42 |
+
)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
const useFormField = () => {
|
| 46 |
+
const fieldContext = React.useContext(FormFieldContext)
|
| 47 |
+
const itemContext = React.useContext(FormItemContext)
|
| 48 |
+
const { getFieldState } = useFormContext()
|
| 49 |
+
const formState = useFormState({ name: fieldContext.name })
|
| 50 |
+
const fieldState = getFieldState(fieldContext.name, formState)
|
| 51 |
+
|
| 52 |
+
if (!fieldContext) {
|
| 53 |
+
throw new Error('useFormField should be used within <FormField>')
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
const { id } = itemContext
|
| 57 |
+
|
| 58 |
+
return {
|
| 59 |
+
id,
|
| 60 |
+
name: fieldContext.name,
|
| 61 |
+
formItemId: `${id}-form-item`,
|
| 62 |
+
formDescriptionId: `${id}-form-item-description`,
|
| 63 |
+
formMessageId: `${id}-form-item-message`,
|
| 64 |
+
...fieldState,
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
type FormItemContextValue = {
|
| 69 |
+
id: string
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
| 73 |
+
{} as FormItemContextValue,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
|
| 77 |
+
const id = React.useId()
|
| 78 |
+
|
| 79 |
+
return (
|
| 80 |
+
<FormItemContext.Provider value={{ id }}>
|
| 81 |
+
<div
|
| 82 |
+
data-slot="form-item"
|
| 83 |
+
className={cn('grid gap-2', className)}
|
| 84 |
+
{...props}
|
| 85 |
+
/>
|
| 86 |
+
</FormItemContext.Provider>
|
| 87 |
+
)
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
function FormLabel({
|
| 91 |
+
className,
|
| 92 |
+
...props
|
| 93 |
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
| 94 |
+
const { error, formItemId } = useFormField()
|
| 95 |
+
|
| 96 |
+
return (
|
| 97 |
+
<Label
|
| 98 |
+
data-slot="form-label"
|
| 99 |
+
data-error={!!error}
|
| 100 |
+
className={cn('data-[error=true]:text-destructive', className)}
|
| 101 |
+
htmlFor={formItemId}
|
| 102 |
+
{...props}
|
| 103 |
+
/>
|
| 104 |
+
)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
| 108 |
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
| 109 |
+
|
| 110 |
+
return (
|
| 111 |
+
<Slot
|
| 112 |
+
data-slot="form-control"
|
| 113 |
+
id={formItemId}
|
| 114 |
+
aria-describedby={
|
| 115 |
+
!error
|
| 116 |
+
? `${formDescriptionId}`
|
| 117 |
+
: `${formDescriptionId} ${formMessageId}`
|
| 118 |
+
}
|
| 119 |
+
aria-invalid={!!error}
|
| 120 |
+
{...props}
|
| 121 |
+
/>
|
| 122 |
+
)
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function FormDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
| 126 |
+
const { formDescriptionId } = useFormField()
|
| 127 |
+
|
| 128 |
+
return (
|
| 129 |
+
<p
|
| 130 |
+
data-slot="form-description"
|
| 131 |
+
id={formDescriptionId}
|
| 132 |
+
className={cn('text-muted-foreground text-sm', className)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
|
| 139 |
+
const { error, formMessageId } = useFormField()
|
| 140 |
+
const body = error ? String(error?.message ?? '') : props.children
|
| 141 |
+
|
| 142 |
+
if (!body) {
|
| 143 |
+
return null
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
return (
|
| 147 |
+
<p
|
| 148 |
+
data-slot="form-message"
|
| 149 |
+
id={formMessageId}
|
| 150 |
+
className={cn('text-destructive text-sm', className)}
|
| 151 |
+
{...props}
|
| 152 |
+
>
|
| 153 |
+
{body}
|
| 154 |
+
</p>
|
| 155 |
+
)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
export {
|
| 159 |
+
useFormField,
|
| 160 |
+
Form,
|
| 161 |
+
FormItem,
|
| 162 |
+
FormLabel,
|
| 163 |
+
FormControl,
|
| 164 |
+
FormDescription,
|
| 165 |
+
FormMessage,
|
| 166 |
+
FormField,
|
| 167 |
+
}
|
components/ui/hover-card.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as HoverCardPrimitive from '@radix-ui/react-hover-card'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function HoverCard({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
| 11 |
+
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function HoverCardTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
| 17 |
+
return (
|
| 18 |
+
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function HoverCardContent({
|
| 23 |
+
className,
|
| 24 |
+
align = 'center',
|
| 25 |
+
sideOffset = 4,
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
| 28 |
+
return (
|
| 29 |
+
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
| 30 |
+
<HoverCardPrimitive.Content
|
| 31 |
+
data-slot="hover-card-content"
|
| 32 |
+
align={align}
|
| 33 |
+
sideOffset={sideOffset}
|
| 34 |
+
className={cn(
|
| 35 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
|
| 36 |
+
className,
|
| 37 |
+
)}
|
| 38 |
+
{...props}
|
| 39 |
+
/>
|
| 40 |
+
</HoverCardPrimitive.Portal>
|
| 41 |
+
)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
components/ui/input-otp.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { OTPInput, OTPInputContext } from 'input-otp'
|
| 5 |
+
import { MinusIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function InputOTP({
|
| 10 |
+
className,
|
| 11 |
+
containerClassName,
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof OTPInput> & {
|
| 14 |
+
containerClassName?: string
|
| 15 |
+
}) {
|
| 16 |
+
return (
|
| 17 |
+
<OTPInput
|
| 18 |
+
data-slot="input-otp"
|
| 19 |
+
containerClassName={cn(
|
| 20 |
+
'flex items-center gap-2 has-disabled:opacity-50',
|
| 21 |
+
containerClassName,
|
| 22 |
+
)}
|
| 23 |
+
className={cn('disabled:cursor-not-allowed', className)}
|
| 24 |
+
{...props}
|
| 25 |
+
/>
|
| 26 |
+
)
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
| 30 |
+
return (
|
| 31 |
+
<div
|
| 32 |
+
data-slot="input-otp-group"
|
| 33 |
+
className={cn('flex items-center', className)}
|
| 34 |
+
{...props}
|
| 35 |
+
/>
|
| 36 |
+
)
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function InputOTPSlot({
|
| 40 |
+
index,
|
| 41 |
+
className,
|
| 42 |
+
...props
|
| 43 |
+
}: React.ComponentProps<'div'> & {
|
| 44 |
+
index: number
|
| 45 |
+
}) {
|
| 46 |
+
const inputOTPContext = React.useContext(OTPInputContext)
|
| 47 |
+
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<div
|
| 51 |
+
data-slot="input-otp-slot"
|
| 52 |
+
data-active={isActive}
|
| 53 |
+
className={cn(
|
| 54 |
+
'data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]',
|
| 55 |
+
className,
|
| 56 |
+
)}
|
| 57 |
+
{...props}
|
| 58 |
+
>
|
| 59 |
+
{char}
|
| 60 |
+
{hasFakeCaret && (
|
| 61 |
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 62 |
+
<div className="animate-caret-blink bg-foreground h-4 w-px duration-1000" />
|
| 63 |
+
</div>
|
| 64 |
+
)}
|
| 65 |
+
</div>
|
| 66 |
+
)
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {
|
| 70 |
+
return (
|
| 71 |
+
<div data-slot="input-otp-separator" role="separator" {...props}>
|
| 72 |
+
<MinusIcon />
|
| 73 |
+
</div>
|
| 74 |
+
)
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
components/ui/input.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
|
| 3 |
+
import { cn } from '@/lib/utils'
|
| 4 |
+
|
| 5 |
+
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
| 6 |
+
return (
|
| 7 |
+
<input
|
| 8 |
+
type={type}
|
| 9 |
+
data-slot="input"
|
| 10 |
+
className={cn(
|
| 11 |
+
'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
| 12 |
+
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
| 13 |
+
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
| 14 |
+
className,
|
| 15 |
+
)}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export { Input }
|
components/ui/label.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Label({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<LabelPrimitive.Root
|
| 14 |
+
data-slot="label"
|
| 15 |
+
className={cn(
|
| 16 |
+
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
|
| 17 |
+
className,
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export { Label }
|
components/ui/menubar.tsx
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as MenubarPrimitive from '@radix-ui/react-menubar'
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Menubar({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<MenubarPrimitive.Root
|
| 15 |
+
data-slot="menubar"
|
| 16 |
+
className={cn(
|
| 17 |
+
'bg-background flex h-9 items-center gap-1 rounded-md border p-1 shadow-xs',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
)
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function MenubarMenu({
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
|
| 28 |
+
return <MenubarPrimitive.Menu data-slot="menubar-menu" {...props} />
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function MenubarGroup({
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Group>) {
|
| 34 |
+
return <MenubarPrimitive.Group data-slot="menubar-group" {...props} />
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function MenubarPortal({
|
| 38 |
+
...props
|
| 39 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
|
| 40 |
+
return <MenubarPrimitive.Portal data-slot="menubar-portal" {...props} />
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function MenubarRadioGroup({
|
| 44 |
+
...props
|
| 45 |
+
}: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
|
| 46 |
+
return (
|
| 47 |
+
<MenubarPrimitive.RadioGroup data-slot="menubar-radio-group" {...props} />
|
| 48 |
+
)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function MenubarTrigger({
|
| 52 |
+
className,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Trigger>) {
|
| 55 |
+
return (
|
| 56 |
+
<MenubarPrimitive.Trigger
|
| 57 |
+
data-slot="menubar-trigger"
|
| 58 |
+
className={cn(
|
| 59 |
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none',
|
| 60 |
+
className,
|
| 61 |
+
)}
|
| 62 |
+
{...props}
|
| 63 |
+
/>
|
| 64 |
+
)
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
function MenubarContent({
|
| 68 |
+
className,
|
| 69 |
+
align = 'start',
|
| 70 |
+
alignOffset = -4,
|
| 71 |
+
sideOffset = 8,
|
| 72 |
+
...props
|
| 73 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Content>) {
|
| 74 |
+
return (
|
| 75 |
+
<MenubarPortal>
|
| 76 |
+
<MenubarPrimitive.Content
|
| 77 |
+
data-slot="menubar-content"
|
| 78 |
+
align={align}
|
| 79 |
+
alignOffset={alignOffset}
|
| 80 |
+
sideOffset={sideOffset}
|
| 81 |
+
className={cn(
|
| 82 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[12rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-md',
|
| 83 |
+
className,
|
| 84 |
+
)}
|
| 85 |
+
{...props}
|
| 86 |
+
/>
|
| 87 |
+
</MenubarPortal>
|
| 88 |
+
)
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function MenubarItem({
|
| 92 |
+
className,
|
| 93 |
+
inset,
|
| 94 |
+
variant = 'default',
|
| 95 |
+
...props
|
| 96 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Item> & {
|
| 97 |
+
inset?: boolean
|
| 98 |
+
variant?: 'default' | 'destructive'
|
| 99 |
+
}) {
|
| 100 |
+
return (
|
| 101 |
+
<MenubarPrimitive.Item
|
| 102 |
+
data-slot="menubar-item"
|
| 103 |
+
data-inset={inset}
|
| 104 |
+
data-variant={variant}
|
| 105 |
+
className={cn(
|
| 106 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 107 |
+
className,
|
| 108 |
+
)}
|
| 109 |
+
{...props}
|
| 110 |
+
/>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
function MenubarCheckboxItem({
|
| 115 |
+
className,
|
| 116 |
+
children,
|
| 117 |
+
checked,
|
| 118 |
+
...props
|
| 119 |
+
}: React.ComponentProps<typeof MenubarPrimitive.CheckboxItem>) {
|
| 120 |
+
return (
|
| 121 |
+
<MenubarPrimitive.CheckboxItem
|
| 122 |
+
data-slot="menubar-checkbox-item"
|
| 123 |
+
className={cn(
|
| 124 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 125 |
+
className,
|
| 126 |
+
)}
|
| 127 |
+
checked={checked}
|
| 128 |
+
{...props}
|
| 129 |
+
>
|
| 130 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 131 |
+
<MenubarPrimitive.ItemIndicator>
|
| 132 |
+
<CheckIcon className="size-4" />
|
| 133 |
+
</MenubarPrimitive.ItemIndicator>
|
| 134 |
+
</span>
|
| 135 |
+
{children}
|
| 136 |
+
</MenubarPrimitive.CheckboxItem>
|
| 137 |
+
)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function MenubarRadioItem({
|
| 141 |
+
className,
|
| 142 |
+
children,
|
| 143 |
+
...props
|
| 144 |
+
}: React.ComponentProps<typeof MenubarPrimitive.RadioItem>) {
|
| 145 |
+
return (
|
| 146 |
+
<MenubarPrimitive.RadioItem
|
| 147 |
+
data-slot="menubar-radio-item"
|
| 148 |
+
className={cn(
|
| 149 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 150 |
+
className,
|
| 151 |
+
)}
|
| 152 |
+
{...props}
|
| 153 |
+
>
|
| 154 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 155 |
+
<MenubarPrimitive.ItemIndicator>
|
| 156 |
+
<CircleIcon className="size-2 fill-current" />
|
| 157 |
+
</MenubarPrimitive.ItemIndicator>
|
| 158 |
+
</span>
|
| 159 |
+
{children}
|
| 160 |
+
</MenubarPrimitive.RadioItem>
|
| 161 |
+
)
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
function MenubarLabel({
|
| 165 |
+
className,
|
| 166 |
+
inset,
|
| 167 |
+
...props
|
| 168 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Label> & {
|
| 169 |
+
inset?: boolean
|
| 170 |
+
}) {
|
| 171 |
+
return (
|
| 172 |
+
<MenubarPrimitive.Label
|
| 173 |
+
data-slot="menubar-label"
|
| 174 |
+
data-inset={inset}
|
| 175 |
+
className={cn(
|
| 176 |
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
| 177 |
+
className,
|
| 178 |
+
)}
|
| 179 |
+
{...props}
|
| 180 |
+
/>
|
| 181 |
+
)
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
function MenubarSeparator({
|
| 185 |
+
className,
|
| 186 |
+
...props
|
| 187 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Separator>) {
|
| 188 |
+
return (
|
| 189 |
+
<MenubarPrimitive.Separator
|
| 190 |
+
data-slot="menubar-separator"
|
| 191 |
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
| 192 |
+
{...props}
|
| 193 |
+
/>
|
| 194 |
+
)
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
function MenubarShortcut({
|
| 198 |
+
className,
|
| 199 |
+
...props
|
| 200 |
+
}: React.ComponentProps<'span'>) {
|
| 201 |
+
return (
|
| 202 |
+
<span
|
| 203 |
+
data-slot="menubar-shortcut"
|
| 204 |
+
className={cn(
|
| 205 |
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
| 206 |
+
className,
|
| 207 |
+
)}
|
| 208 |
+
{...props}
|
| 209 |
+
/>
|
| 210 |
+
)
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function MenubarSub({
|
| 214 |
+
...props
|
| 215 |
+
}: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
|
| 216 |
+
return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
function MenubarSubTrigger({
|
| 220 |
+
className,
|
| 221 |
+
inset,
|
| 222 |
+
children,
|
| 223 |
+
...props
|
| 224 |
+
}: React.ComponentProps<typeof MenubarPrimitive.SubTrigger> & {
|
| 225 |
+
inset?: boolean
|
| 226 |
+
}) {
|
| 227 |
+
return (
|
| 228 |
+
<MenubarPrimitive.SubTrigger
|
| 229 |
+
data-slot="menubar-sub-trigger"
|
| 230 |
+
data-inset={inset}
|
| 231 |
+
className={cn(
|
| 232 |
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[inset]:pl-8',
|
| 233 |
+
className,
|
| 234 |
+
)}
|
| 235 |
+
{...props}
|
| 236 |
+
>
|
| 237 |
+
{children}
|
| 238 |
+
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
| 239 |
+
</MenubarPrimitive.SubTrigger>
|
| 240 |
+
)
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function MenubarSubContent({
|
| 244 |
+
className,
|
| 245 |
+
...props
|
| 246 |
+
}: React.ComponentProps<typeof MenubarPrimitive.SubContent>) {
|
| 247 |
+
return (
|
| 248 |
+
<MenubarPrimitive.SubContent
|
| 249 |
+
data-slot="menubar-sub-content"
|
| 250 |
+
className={cn(
|
| 251 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
| 252 |
+
className,
|
| 253 |
+
)}
|
| 254 |
+
{...props}
|
| 255 |
+
/>
|
| 256 |
+
)
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
export {
|
| 260 |
+
Menubar,
|
| 261 |
+
MenubarPortal,
|
| 262 |
+
MenubarMenu,
|
| 263 |
+
MenubarTrigger,
|
| 264 |
+
MenubarContent,
|
| 265 |
+
MenubarGroup,
|
| 266 |
+
MenubarSeparator,
|
| 267 |
+
MenubarLabel,
|
| 268 |
+
MenubarItem,
|
| 269 |
+
MenubarShortcut,
|
| 270 |
+
MenubarCheckboxItem,
|
| 271 |
+
MenubarRadioGroup,
|
| 272 |
+
MenubarRadioItem,
|
| 273 |
+
MenubarSub,
|
| 274 |
+
MenubarSubTrigger,
|
| 275 |
+
MenubarSubContent,
|
| 276 |
+
}
|
components/ui/navigation-menu.tsx
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'
|
| 3 |
+
import { cva } from 'class-variance-authority'
|
| 4 |
+
import { ChevronDownIcon } from 'lucide-react'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function NavigationMenu({
|
| 9 |
+
className,
|
| 10 |
+
children,
|
| 11 |
+
viewport = true,
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
|
| 14 |
+
viewport?: boolean
|
| 15 |
+
}) {
|
| 16 |
+
return (
|
| 17 |
+
<NavigationMenuPrimitive.Root
|
| 18 |
+
data-slot="navigation-menu"
|
| 19 |
+
data-viewport={viewport}
|
| 20 |
+
className={cn(
|
| 21 |
+
'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',
|
| 22 |
+
className,
|
| 23 |
+
)}
|
| 24 |
+
{...props}
|
| 25 |
+
>
|
| 26 |
+
{children}
|
| 27 |
+
{viewport && <NavigationMenuViewport />}
|
| 28 |
+
</NavigationMenuPrimitive.Root>
|
| 29 |
+
)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function NavigationMenuList({
|
| 33 |
+
className,
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
|
| 36 |
+
return (
|
| 37 |
+
<NavigationMenuPrimitive.List
|
| 38 |
+
data-slot="navigation-menu-list"
|
| 39 |
+
className={cn(
|
| 40 |
+
'group flex flex-1 list-none items-center justify-center gap-1',
|
| 41 |
+
className,
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function NavigationMenuItem({
|
| 49 |
+
className,
|
| 50 |
+
...props
|
| 51 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
|
| 52 |
+
return (
|
| 53 |
+
<NavigationMenuPrimitive.Item
|
| 54 |
+
data-slot="navigation-menu-item"
|
| 55 |
+
className={cn('relative', className)}
|
| 56 |
+
{...props}
|
| 57 |
+
/>
|
| 58 |
+
)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const navigationMenuTriggerStyle = cva(
|
| 62 |
+
'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1',
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
function NavigationMenuTrigger({
|
| 66 |
+
className,
|
| 67 |
+
children,
|
| 68 |
+
...props
|
| 69 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
|
| 70 |
+
return (
|
| 71 |
+
<NavigationMenuPrimitive.Trigger
|
| 72 |
+
data-slot="navigation-menu-trigger"
|
| 73 |
+
className={cn(navigationMenuTriggerStyle(), 'group', className)}
|
| 74 |
+
{...props}
|
| 75 |
+
>
|
| 76 |
+
{children}{' '}
|
| 77 |
+
<ChevronDownIcon
|
| 78 |
+
className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
|
| 79 |
+
aria-hidden="true"
|
| 80 |
+
/>
|
| 81 |
+
</NavigationMenuPrimitive.Trigger>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function NavigationMenuContent({
|
| 86 |
+
className,
|
| 87 |
+
...props
|
| 88 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
|
| 89 |
+
return (
|
| 90 |
+
<NavigationMenuPrimitive.Content
|
| 91 |
+
data-slot="navigation-menu-content"
|
| 92 |
+
className={cn(
|
| 93 |
+
'data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto',
|
| 94 |
+
'group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none',
|
| 95 |
+
className,
|
| 96 |
+
)}
|
| 97 |
+
{...props}
|
| 98 |
+
/>
|
| 99 |
+
)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function NavigationMenuViewport({
|
| 103 |
+
className,
|
| 104 |
+
...props
|
| 105 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) {
|
| 106 |
+
return (
|
| 107 |
+
<div
|
| 108 |
+
className={'absolute top-full left-0 isolate z-50 flex justify-center'}
|
| 109 |
+
>
|
| 110 |
+
<NavigationMenuPrimitive.Viewport
|
| 111 |
+
data-slot="navigation-menu-viewport"
|
| 112 |
+
className={cn(
|
| 113 |
+
'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]',
|
| 114 |
+
className,
|
| 115 |
+
)}
|
| 116 |
+
{...props}
|
| 117 |
+
/>
|
| 118 |
+
</div>
|
| 119 |
+
)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function NavigationMenuLink({
|
| 123 |
+
className,
|
| 124 |
+
...props
|
| 125 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
|
| 126 |
+
return (
|
| 127 |
+
<NavigationMenuPrimitive.Link
|
| 128 |
+
data-slot="navigation-menu-link"
|
| 129 |
+
className={cn(
|
| 130 |
+
"data-[active=true]:focus:bg-accent data-[active=true]:hover:bg-accent data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-ring/50 [&_svg:not([class*='text-'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4",
|
| 131 |
+
className,
|
| 132 |
+
)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function NavigationMenuIndicator({
|
| 139 |
+
className,
|
| 140 |
+
...props
|
| 141 |
+
}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
|
| 142 |
+
return (
|
| 143 |
+
<NavigationMenuPrimitive.Indicator
|
| 144 |
+
data-slot="navigation-menu-indicator"
|
| 145 |
+
className={cn(
|
| 146 |
+
'data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
| 147 |
+
className,
|
| 148 |
+
)}
|
| 149 |
+
{...props}
|
| 150 |
+
>
|
| 151 |
+
<div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
|
| 152 |
+
</NavigationMenuPrimitive.Indicator>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
export {
|
| 157 |
+
NavigationMenu,
|
| 158 |
+
NavigationMenuList,
|
| 159 |
+
NavigationMenuItem,
|
| 160 |
+
NavigationMenuContent,
|
| 161 |
+
NavigationMenuTrigger,
|
| 162 |
+
NavigationMenuLink,
|
| 163 |
+
NavigationMenuIndicator,
|
| 164 |
+
NavigationMenuViewport,
|
| 165 |
+
navigationMenuTriggerStyle,
|
| 166 |
+
}
|
components/ui/pagination.tsx
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from 'react'
|
| 2 |
+
import {
|
| 3 |
+
ChevronLeftIcon,
|
| 4 |
+
ChevronRightIcon,
|
| 5 |
+
MoreHorizontalIcon,
|
| 6 |
+
} from 'lucide-react'
|
| 7 |
+
|
| 8 |
+
import { cn } from '@/lib/utils'
|
| 9 |
+
import { Button, buttonVariants } from '@/components/ui/button'
|
| 10 |
+
|
| 11 |
+
function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
|
| 12 |
+
return (
|
| 13 |
+
<nav
|
| 14 |
+
role="navigation"
|
| 15 |
+
aria-label="pagination"
|
| 16 |
+
data-slot="pagination"
|
| 17 |
+
className={cn('mx-auto flex w-full justify-center', className)}
|
| 18 |
+
{...props}
|
| 19 |
+
/>
|
| 20 |
+
)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function PaginationContent({
|
| 24 |
+
className,
|
| 25 |
+
...props
|
| 26 |
+
}: React.ComponentProps<'ul'>) {
|
| 27 |
+
return (
|
| 28 |
+
<ul
|
| 29 |
+
data-slot="pagination-content"
|
| 30 |
+
className={cn('flex flex-row items-center gap-1', className)}
|
| 31 |
+
{...props}
|
| 32 |
+
/>
|
| 33 |
+
)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function PaginationItem({ ...props }: React.ComponentProps<'li'>) {
|
| 37 |
+
return <li data-slot="pagination-item" {...props} />
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
type PaginationLinkProps = {
|
| 41 |
+
isActive?: boolean
|
| 42 |
+
} & Pick<React.ComponentProps<typeof Button>, 'size'> &
|
| 43 |
+
React.ComponentProps<'a'>
|
| 44 |
+
|
| 45 |
+
function PaginationLink({
|
| 46 |
+
className,
|
| 47 |
+
isActive,
|
| 48 |
+
size = 'icon',
|
| 49 |
+
...props
|
| 50 |
+
}: PaginationLinkProps) {
|
| 51 |
+
return (
|
| 52 |
+
<a
|
| 53 |
+
aria-current={isActive ? 'page' : undefined}
|
| 54 |
+
data-slot="pagination-link"
|
| 55 |
+
data-active={isActive}
|
| 56 |
+
className={cn(
|
| 57 |
+
buttonVariants({
|
| 58 |
+
variant: isActive ? 'outline' : 'ghost',
|
| 59 |
+
size,
|
| 60 |
+
}),
|
| 61 |
+
className,
|
| 62 |
+
)}
|
| 63 |
+
{...props}
|
| 64 |
+
/>
|
| 65 |
+
)
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
function PaginationPrevious({
|
| 69 |
+
className,
|
| 70 |
+
...props
|
| 71 |
+
}: React.ComponentProps<typeof PaginationLink>) {
|
| 72 |
+
return (
|
| 73 |
+
<PaginationLink
|
| 74 |
+
aria-label="Go to previous page"
|
| 75 |
+
size="default"
|
| 76 |
+
className={cn('gap-1 px-2.5 sm:pl-2.5', className)}
|
| 77 |
+
{...props}
|
| 78 |
+
>
|
| 79 |
+
<ChevronLeftIcon />
|
| 80 |
+
<span className="hidden sm:block">Previous</span>
|
| 81 |
+
</PaginationLink>
|
| 82 |
+
)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function PaginationNext({
|
| 86 |
+
className,
|
| 87 |
+
...props
|
| 88 |
+
}: React.ComponentProps<typeof PaginationLink>) {
|
| 89 |
+
return (
|
| 90 |
+
<PaginationLink
|
| 91 |
+
aria-label="Go to next page"
|
| 92 |
+
size="default"
|
| 93 |
+
className={cn('gap-1 px-2.5 sm:pr-2.5', className)}
|
| 94 |
+
{...props}
|
| 95 |
+
>
|
| 96 |
+
<span className="hidden sm:block">Next</span>
|
| 97 |
+
<ChevronRightIcon />
|
| 98 |
+
</PaginationLink>
|
| 99 |
+
)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function PaginationEllipsis({
|
| 103 |
+
className,
|
| 104 |
+
...props
|
| 105 |
+
}: React.ComponentProps<'span'>) {
|
| 106 |
+
return (
|
| 107 |
+
<span
|
| 108 |
+
aria-hidden
|
| 109 |
+
data-slot="pagination-ellipsis"
|
| 110 |
+
className={cn('flex size-9 items-center justify-center', className)}
|
| 111 |
+
{...props}
|
| 112 |
+
>
|
| 113 |
+
<MoreHorizontalIcon className="size-4" />
|
| 114 |
+
<span className="sr-only">More pages</span>
|
| 115 |
+
</span>
|
| 116 |
+
)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
export {
|
| 120 |
+
Pagination,
|
| 121 |
+
PaginationContent,
|
| 122 |
+
PaginationLink,
|
| 123 |
+
PaginationItem,
|
| 124 |
+
PaginationPrevious,
|
| 125 |
+
PaginationNext,
|
| 126 |
+
PaginationEllipsis,
|
| 127 |
+
}
|
components/ui/popover.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Popover({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
| 11 |
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function PopoverTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
| 17 |
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function PopoverContent({
|
| 21 |
+
className,
|
| 22 |
+
align = 'center',
|
| 23 |
+
sideOffset = 4,
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
| 26 |
+
return (
|
| 27 |
+
<PopoverPrimitive.Portal>
|
| 28 |
+
<PopoverPrimitive.Content
|
| 29 |
+
data-slot="popover-content"
|
| 30 |
+
align={align}
|
| 31 |
+
sideOffset={sideOffset}
|
| 32 |
+
className={cn(
|
| 33 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
|
| 34 |
+
className,
|
| 35 |
+
)}
|
| 36 |
+
{...props}
|
| 37 |
+
/>
|
| 38 |
+
</PopoverPrimitive.Portal>
|
| 39 |
+
)
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function PopoverAnchor({
|
| 43 |
+
...props
|
| 44 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
| 45 |
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
components/ui/progress.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as ProgressPrimitive from '@radix-ui/react-progress'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Progress({
|
| 9 |
+
className,
|
| 10 |
+
value,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof ProgressPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<ProgressPrimitive.Root
|
| 15 |
+
data-slot="progress"
|
| 16 |
+
className={cn(
|
| 17 |
+
'bg-primary/20 relative h-2 w-full overflow-hidden rounded-full',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
>
|
| 22 |
+
<ProgressPrimitive.Indicator
|
| 23 |
+
data-slot="progress-indicator"
|
| 24 |
+
className="bg-primary h-full w-full flex-1 transition-all"
|
| 25 |
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
| 26 |
+
/>
|
| 27 |
+
</ProgressPrimitive.Root>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export { Progress }
|
components/ui/radio-group.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
|
| 5 |
+
import { CircleIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function RadioGroup({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<RadioGroupPrimitive.Root
|
| 15 |
+
data-slot="radio-group"
|
| 16 |
+
className={cn('grid gap-3', className)}
|
| 17 |
+
{...props}
|
| 18 |
+
/>
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function RadioGroupItem({
|
| 23 |
+
className,
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
| 26 |
+
return (
|
| 27 |
+
<RadioGroupPrimitive.Item
|
| 28 |
+
data-slot="radio-group-item"
|
| 29 |
+
className={cn(
|
| 30 |
+
'border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
| 31 |
+
className,
|
| 32 |
+
)}
|
| 33 |
+
{...props}
|
| 34 |
+
>
|
| 35 |
+
<RadioGroupPrimitive.Indicator
|
| 36 |
+
data-slot="radio-group-indicator"
|
| 37 |
+
className="relative flex items-center justify-center"
|
| 38 |
+
>
|
| 39 |
+
<CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
|
| 40 |
+
</RadioGroupPrimitive.Indicator>
|
| 41 |
+
</RadioGroupPrimitive.Item>
|
| 42 |
+
)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
export { RadioGroup, RadioGroupItem }
|
components/ui/resizable.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import { GripVerticalIcon } from 'lucide-react'
|
| 5 |
+
import * as ResizablePrimitive from 'react-resizable-panels'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function ResizablePanelGroup({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) {
|
| 13 |
+
return (
|
| 14 |
+
<ResizablePrimitive.PanelGroup
|
| 15 |
+
data-slot="resizable-panel-group"
|
| 16 |
+
className={cn(
|
| 17 |
+
'flex h-full w-full data-[panel-group-direction=vertical]:flex-col',
|
| 18 |
+
className,
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
)
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function ResizablePanel({
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof ResizablePrimitive.Panel>) {
|
| 28 |
+
return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function ResizableHandle({
|
| 32 |
+
withHandle,
|
| 33 |
+
className,
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
|
| 36 |
+
withHandle?: boolean
|
| 37 |
+
}) {
|
| 38 |
+
return (
|
| 39 |
+
<ResizablePrimitive.PanelResizeHandle
|
| 40 |
+
data-slot="resizable-handle"
|
| 41 |
+
className={cn(
|
| 42 |
+
'bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden 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-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90',
|
| 43 |
+
className,
|
| 44 |
+
)}
|
| 45 |
+
{...props}
|
| 46 |
+
>
|
| 47 |
+
{withHandle && (
|
| 48 |
+
<div className="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border">
|
| 49 |
+
<GripVerticalIcon className="size-2.5" />
|
| 50 |
+
</div>
|
| 51 |
+
)}
|
| 52 |
+
</ResizablePrimitive.PanelResizeHandle>
|
| 53 |
+
)
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
export { ResizablePanelGroup, ResizablePanel, ResizableHandle }
|
components/ui/scroll-area.tsx
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function ScrollArea({
|
| 9 |
+
className,
|
| 10 |
+
children,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<ScrollAreaPrimitive.Root
|
| 15 |
+
data-slot="scroll-area"
|
| 16 |
+
className={cn('relative', className)}
|
| 17 |
+
{...props}
|
| 18 |
+
>
|
| 19 |
+
<ScrollAreaPrimitive.Viewport
|
| 20 |
+
data-slot="scroll-area-viewport"
|
| 21 |
+
className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
|
| 22 |
+
>
|
| 23 |
+
{children}
|
| 24 |
+
</ScrollAreaPrimitive.Viewport>
|
| 25 |
+
<ScrollBar />
|
| 26 |
+
<ScrollAreaPrimitive.Corner />
|
| 27 |
+
</ScrollAreaPrimitive.Root>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function ScrollBar({
|
| 32 |
+
className,
|
| 33 |
+
orientation = 'vertical',
|
| 34 |
+
...props
|
| 35 |
+
}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
|
| 36 |
+
return (
|
| 37 |
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
| 38 |
+
data-slot="scroll-area-scrollbar"
|
| 39 |
+
orientation={orientation}
|
| 40 |
+
className={cn(
|
| 41 |
+
'flex touch-none p-px transition-colors select-none',
|
| 42 |
+
orientation === 'vertical' &&
|
| 43 |
+
'h-full w-2.5 border-l border-l-transparent',
|
| 44 |
+
orientation === 'horizontal' &&
|
| 45 |
+
'h-2.5 flex-col border-t border-t-transparent',
|
| 46 |
+
className,
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
>
|
| 50 |
+
<ScrollAreaPrimitive.ScrollAreaThumb
|
| 51 |
+
data-slot="scroll-area-thumb"
|
| 52 |
+
className="bg-border relative flex-1 rounded-full"
|
| 53 |
+
/>
|
| 54 |
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
| 55 |
+
)
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
export { ScrollArea, ScrollBar }
|
components/ui/select.tsx
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as SelectPrimitive from '@radix-ui/react-select'
|
| 5 |
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
|
| 6 |
+
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
|
| 9 |
+
function Select({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
| 12 |
+
return <SelectPrimitive.Root data-slot="select" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function SelectGroup({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
| 18 |
+
return <SelectPrimitive.Group data-slot="select-group" {...props} />
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function SelectValue({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
| 24 |
+
return <SelectPrimitive.Value data-slot="select-value" {...props} />
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function SelectTrigger({
|
| 28 |
+
className,
|
| 29 |
+
size = 'default',
|
| 30 |
+
children,
|
| 31 |
+
...props
|
| 32 |
+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
| 33 |
+
size?: 'sm' | 'default'
|
| 34 |
+
}) {
|
| 35 |
+
return (
|
| 36 |
+
<SelectPrimitive.Trigger
|
| 37 |
+
data-slot="select-trigger"
|
| 38 |
+
data-size={size}
|
| 39 |
+
className={cn(
|
| 40 |
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 41 |
+
className,
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
>
|
| 45 |
+
{children}
|
| 46 |
+
<SelectPrimitive.Icon asChild>
|
| 47 |
+
<ChevronDownIcon className="size-4 opacity-50" />
|
| 48 |
+
</SelectPrimitive.Icon>
|
| 49 |
+
</SelectPrimitive.Trigger>
|
| 50 |
+
)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function SelectContent({
|
| 54 |
+
className,
|
| 55 |
+
children,
|
| 56 |
+
position = 'popper',
|
| 57 |
+
...props
|
| 58 |
+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
| 59 |
+
return (
|
| 60 |
+
<SelectPrimitive.Portal>
|
| 61 |
+
<SelectPrimitive.Content
|
| 62 |
+
data-slot="select-content"
|
| 63 |
+
className={cn(
|
| 64 |
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md',
|
| 65 |
+
position === 'popper' &&
|
| 66 |
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
| 67 |
+
className,
|
| 68 |
+
)}
|
| 69 |
+
position={position}
|
| 70 |
+
{...props}
|
| 71 |
+
>
|
| 72 |
+
<SelectScrollUpButton />
|
| 73 |
+
<SelectPrimitive.Viewport
|
| 74 |
+
className={cn(
|
| 75 |
+
'p-1',
|
| 76 |
+
position === 'popper' &&
|
| 77 |
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1',
|
| 78 |
+
)}
|
| 79 |
+
>
|
| 80 |
+
{children}
|
| 81 |
+
</SelectPrimitive.Viewport>
|
| 82 |
+
<SelectScrollDownButton />
|
| 83 |
+
</SelectPrimitive.Content>
|
| 84 |
+
</SelectPrimitive.Portal>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function SelectLabel({
|
| 89 |
+
className,
|
| 90 |
+
...props
|
| 91 |
+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
| 92 |
+
return (
|
| 93 |
+
<SelectPrimitive.Label
|
| 94 |
+
data-slot="select-label"
|
| 95 |
+
className={cn('text-muted-foreground px-2 py-1.5 text-xs', className)}
|
| 96 |
+
{...props}
|
| 97 |
+
/>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function SelectItem({
|
| 102 |
+
className,
|
| 103 |
+
children,
|
| 104 |
+
...props
|
| 105 |
+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
| 106 |
+
return (
|
| 107 |
+
<SelectPrimitive.Item
|
| 108 |
+
data-slot="select-item"
|
| 109 |
+
className={cn(
|
| 110 |
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
| 111 |
+
className,
|
| 112 |
+
)}
|
| 113 |
+
{...props}
|
| 114 |
+
>
|
| 115 |
+
<span className="absolute right-2 flex size-3.5 items-center justify-center">
|
| 116 |
+
<SelectPrimitive.ItemIndicator>
|
| 117 |
+
<CheckIcon className="size-4" />
|
| 118 |
+
</SelectPrimitive.ItemIndicator>
|
| 119 |
+
</span>
|
| 120 |
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
| 121 |
+
</SelectPrimitive.Item>
|
| 122 |
+
)
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function SelectSeparator({
|
| 126 |
+
className,
|
| 127 |
+
...props
|
| 128 |
+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
| 129 |
+
return (
|
| 130 |
+
<SelectPrimitive.Separator
|
| 131 |
+
data-slot="select-separator"
|
| 132 |
+
className={cn('bg-border pointer-events-none -mx-1 my-1 h-px', className)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function SelectScrollUpButton({
|
| 139 |
+
className,
|
| 140 |
+
...props
|
| 141 |
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
| 142 |
+
return (
|
| 143 |
+
<SelectPrimitive.ScrollUpButton
|
| 144 |
+
data-slot="select-scroll-up-button"
|
| 145 |
+
className={cn(
|
| 146 |
+
'flex cursor-default items-center justify-center py-1',
|
| 147 |
+
className,
|
| 148 |
+
)}
|
| 149 |
+
{...props}
|
| 150 |
+
>
|
| 151 |
+
<ChevronUpIcon className="size-4" />
|
| 152 |
+
</SelectPrimitive.ScrollUpButton>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function SelectScrollDownButton({
|
| 157 |
+
className,
|
| 158 |
+
...props
|
| 159 |
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
| 160 |
+
return (
|
| 161 |
+
<SelectPrimitive.ScrollDownButton
|
| 162 |
+
data-slot="select-scroll-down-button"
|
| 163 |
+
className={cn(
|
| 164 |
+
'flex cursor-default items-center justify-center py-1',
|
| 165 |
+
className,
|
| 166 |
+
)}
|
| 167 |
+
{...props}
|
| 168 |
+
>
|
| 169 |
+
<ChevronDownIcon className="size-4" />
|
| 170 |
+
</SelectPrimitive.ScrollDownButton>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
export {
|
| 175 |
+
Select,
|
| 176 |
+
SelectContent,
|
| 177 |
+
SelectGroup,
|
| 178 |
+
SelectItem,
|
| 179 |
+
SelectLabel,
|
| 180 |
+
SelectScrollDownButton,
|
| 181 |
+
SelectScrollUpButton,
|
| 182 |
+
SelectSeparator,
|
| 183 |
+
SelectTrigger,
|
| 184 |
+
SelectValue,
|
| 185 |
+
}
|
components/ui/separator.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import * as React from 'react'
|
| 4 |
+
import * as SeparatorPrimitive from '@radix-ui/react-separator'
|
| 5 |
+
|
| 6 |
+
import { cn } from '@/lib/utils'
|
| 7 |
+
|
| 8 |
+
function Separator({
|
| 9 |
+
className,
|
| 10 |
+
orientation = 'horizontal',
|
| 11 |
+
decorative = true,
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
| 14 |
+
return (
|
| 15 |
+
<SeparatorPrimitive.Root
|
| 16 |
+
data-slot="separator"
|
| 17 |
+
decorative={decorative}
|
| 18 |
+
orientation={orientation}
|
| 19 |
+
className={cn(
|
| 20 |
+
'bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
|
| 21 |
+
className,
|
| 22 |
+
)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
export { Separator }
|