Fix e621 new posts API format (root array, files.*) + verbose logging
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +9 -0
- .gitattributes +2 -35
- .gitignore +35 -0
- .lovable/plan.md +78 -0
- .lovable/project.json +5 -0
- .prettierignore +8 -0
- .prettierrc +6 -0
- .workspace/0 +0 -0
- .workspace/git/0 +0 -0
- AGENTS.md +12 -0
- Dockerfile +25 -0
- README.md +62 -6
- ROADMAP.md +81 -0
- _gitdownloads_grabberintanstack.rar +3 -0
- bun.lock +0 -0
- bunfig.toml +7 -0
- components.json +22 -0
- eslint.config.js +40 -0
- hf_archived_difffree.rar +3 -0
- package.json +89 -0
- public/favicon.ico +0 -0
- src/components/grabber/AddSiteDialog.tsx +244 -0
- src/components/grabber/Lightbox.tsx +74 -0
- src/components/ui/accordion.tsx +51 -0
- src/components/ui/alert-dialog.tsx +115 -0
- src/components/ui/alert.tsx +49 -0
- src/components/ui/aspect-ratio.tsx +5 -0
- src/components/ui/avatar.tsx +47 -0
- src/components/ui/badge.tsx +32 -0
- src/components/ui/breadcrumb.tsx +101 -0
- src/components/ui/button.tsx +49 -0
- src/components/ui/calendar.tsx +177 -0
- src/components/ui/card.tsx +55 -0
- src/components/ui/carousel.tsx +240 -0
- src/components/ui/chart.tsx +331 -0
- src/components/ui/checkbox.tsx +26 -0
- src/components/ui/collapsible.tsx +11 -0
- src/components/ui/command.tsx +143 -0
- src/components/ui/context-menu.tsx +187 -0
- src/components/ui/dialog.tsx +104 -0
- src/components/ui/drawer.tsx +98 -0
- src/components/ui/dropdown-menu.tsx +188 -0
- src/components/ui/form.tsx +171 -0
- src/components/ui/hover-card.tsx +27 -0
- src/components/ui/input-otp.tsx +69 -0
- src/components/ui/input.tsx +22 -0
- src/components/ui/label.tsx +21 -0
- src/components/ui/menubar.tsx +229 -0
- src/components/ui/navigation-menu.tsx +120 -0
- src/components/ui/pagination.tsx +98 -0
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
.output
|
| 3 |
+
.git
|
| 4 |
+
.env
|
| 5 |
+
.env.*
|
| 6 |
+
.lovable
|
| 7 |
+
.vite
|
| 8 |
+
dist
|
| 9 |
+
*.log
|
.gitattributes
CHANGED
|
@@ -1,35 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
_gitdownloads_grabberintanstack.rar filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
hf_archived_difffree.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Logs
|
| 2 |
+
logs
|
| 3 |
+
*.log
|
| 4 |
+
npm-debug.log*
|
| 5 |
+
yarn-debug.log*
|
| 6 |
+
yarn-error.log*
|
| 7 |
+
pnpm-debug.log*
|
| 8 |
+
lerna-debug.log*
|
| 9 |
+
|
| 10 |
+
node_modules
|
| 11 |
+
dist
|
| 12 |
+
dist-ssr
|
| 13 |
+
.output
|
| 14 |
+
.vinxi
|
| 15 |
+
.tanstack/**
|
| 16 |
+
.nitro
|
| 17 |
+
*.local
|
| 18 |
+
|
| 19 |
+
# Wrangler / Cloudflare
|
| 20 |
+
.wrangler/
|
| 21 |
+
.dev.vars
|
| 22 |
+
|
| 23 |
+
# Tags directory
|
| 24 |
+
/tags
|
| 25 |
+
|
| 26 |
+
# Editor directories and files
|
| 27 |
+
.vscode/*
|
| 28 |
+
!.vscode/extensions.json
|
| 29 |
+
.idea
|
| 30 |
+
.DS_Store
|
| 31 |
+
*.suo
|
| 32 |
+
*.ntvs*
|
| 33 |
+
*.njsproj
|
| 34 |
+
*.sln
|
| 35 |
+
*.sw?
|
.lovable/plan.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Goal
|
| 2 |
+
|
| 3 |
+
For every image included in the downloaded ZIP, also add:
|
| 4 |
+
|
| 5 |
+
- `<same-basename>.txt` — UTF-8 tags file (space-separated, one line, matches the image filename exactly except for extension).
|
| 6 |
+
- `<post-id>.md` — human-readable markdown containing all extracted post metadata (all tags, source link — blank if missing, file size, sample link, original file link, rating, score, dimensions, uploader, created date, md5, etc.).
|
| 7 |
+
|
| 8 |
+
## Approach
|
| 9 |
+
|
| 10 |
+
The server currently only receives `{id, fileUrl, ext}` per post. To write rich metadata into the ZIP without a second network round-trip per post, the frontend will forward the full normalized post (plus a raw metadata bag) to `/api/download-zip`, and the server will emit the extra files alongside each image.
|
| 11 |
+
|
| 12 |
+
To capture "any data related to that post", `searchPosts` will additionally return the raw JSON entry for each post (as `raw: unknown`). The Markdown generator will pretty-print known fields first, then append the full raw JSON as a fenced code block so nothing is lost.
|
| 13 |
+
|
| 14 |
+
New optional fields (`sampleUrl`, `fileSize`, `width`, `height`, `md5`, `uploader`, `createdAt`) get added to `SiteConfig.fields` as optional dotted paths, defaulted for the built-in e621 site. Existing custom sites keep working because every new field is optional.
|
| 15 |
+
|
| 16 |
+
## Files to change
|
| 17 |
+
|
| 18 |
+
### `src/lib/grabber/sites.ts`
|
| 19 |
+
|
| 20 |
+
- Extend `FieldMap` with optional: `sampleUrl?`, `fileSize?`, `width?`, `height?`, `md5?`, `uploader?`, `createdAt?`.
|
| 21 |
+
- Extend `NormalizedPost` with the same optional fields plus `raw: unknown`.
|
| 22 |
+
- Update `normalizePost()` to resolve each new path when present and attach `raw` (the original entry).
|
| 23 |
+
- Update `BUILTIN_SITES` e621 entry `fields` with: `sampleUrl: "sample.url"`, `fileSize: "file.size"`, `width: "file.width"`, `height: "file.height"`, `md5: "file.md5"`, `uploader: "uploader_id"`, `createdAt: "created_at"`.
|
| 24 |
+
|
| 25 |
+
### `src/lib/grabber/search.functions.ts`
|
| 26 |
+
|
| 27 |
+
- Extend the `SiteSchema.fields` zod object with the new optional string paths.
|
| 28 |
+
- No handler logic changes needed — normalization already carries `raw` and new fields through.
|
| 29 |
+
|
| 30 |
+
### `src/components/grabber/AddSiteDialog.tsx`
|
| 31 |
+
|
| 32 |
+
- Add the new optional field keys to the `(["id",...] as const)` list on line 73 so users can map them for custom sites (`sampleUrl`, `fileSize`, `width`, `height`, `md5`, `uploader`, `createdAt`).
|
| 33 |
+
- Extend `DEFAULT` (lines 22–31) with sensible Danbooru mappings (`sampleUrl: "large_file_url"`, `fileSize: "file_size"`, `width: "image_width"`, `height: "image_height"`, `md5: "md5"`, `uploader: "uploader_name"`, `createdAt: "created_at"`).
|
| 34 |
+
|
| 35 |
+
### `src/routes/api/download-zip.ts` (major rewrite)
|
| 36 |
+
|
| 37 |
+
- Expand `BodySchema.posts` item to accept the full normalized post shape (all new optional fields + `tags: string[]` + `raw: unknown`).
|
| 38 |
+
- For each post:
|
| 39 |
+
1. Fetch the image bytes as today. Build image filename `base = "<siteName>_<id>"` and `<base>.<ext>`.
|
| 40 |
+
2. Write `<base>.txt` — `strToU8(tags.join(" "))` (UTF-8). Uses the exact same basename as the image so tag files pair 1:1.
|
| 41 |
+
3. Write `<id>.md` — pretty markdown with:
|
| 42 |
+
- `# Post <id>` heading
|
| 43 |
+
- Table/list of: Source (blank line if missing), Rating, Score, Dimensions (`width x height`), File size (human-readable KB/MB), MD5, Uploader, Created at, Original file URL, Sample URL, Preview URL, Ext.
|
| 44 |
+
- `## Tags` section with the tags space-separated.
|
| 45 |
+
- `## Raw metadata` fenced ```json block containing `JSON.stringify(raw, null, 2)`.
|
| 46 |
+
- Keep the existing `_errors.txt` behavior and 200-post cap.
|
| 47 |
+
- Sanitizer stays the same; md/txt names use `sanitize(id)` so filenames match the image exactly.
|
| 48 |
+
|
| 49 |
+
### `src/routes/index.tsx`
|
| 50 |
+
|
| 51 |
+
- In `downloadZip()` (the `fetch("/api/download-zip", …)` call), send the full post objects instead of a stripped `{id,fileUrl,ext}` triple. Change:
|
| 52 |
+
```
|
| 53 |
+
posts: chosen.map((p) => ({ id: p.id, fileUrl: p.fileUrl, ext: p.ext })),
|
| 54 |
+
```
|
| 55 |
+
to:
|
| 56 |
+
```
|
| 57 |
+
posts: chosen, // full NormalizedPost incl. tags + raw + optional metadata
|
| 58 |
+
```
|
| 59 |
+
- No other UI changes.
|
| 60 |
+
|
| 61 |
+
## ZIP layout example
|
| 62 |
+
|
| 63 |
+
```text
|
| 64 |
+
grabber-2026-07-17T...zip
|
| 65 |
+
├── e621_1234567.jpg
|
| 66 |
+
├── e621_1234567.txt ← "tag1 tag2 tag3 ..."
|
| 67 |
+
├── 1234567.md ← human-readable metadata + raw JSON
|
| 68 |
+
├── e621_1234568.png
|
| 69 |
+
├── e621_1234568.txt
|
| 70 |
+
├── 1234568.md
|
| 71 |
+
└── _errors.txt (only if any fetch failed)
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Notes / non-goals
|
| 75 |
+
|
| 76 |
+
- No new dependencies (still `fflate` + `zod`).
|
| 77 |
+
- No DB, no auth, no schema changes — this is presentation + payload shape only.
|
| 78 |
+
- Custom sites without the new mappings still work; missing fields render as blank lines in the `.md` and the raw JSON section still contains everything from the API.
|
.lovable/project.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schemaVersion": 1,
|
| 3 |
+
"template": "tanstack_start_ts_current",
|
| 4 |
+
"revision": "tanstack_start_ts_current-fa3af8ca0703"
|
| 5 |
+
}
|
.prettierignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
dist
|
| 3 |
+
.output
|
| 4 |
+
.vinxi
|
| 5 |
+
pnpm-lock.yaml
|
| 6 |
+
package-lock.json
|
| 7 |
+
bun.lock
|
| 8 |
+
routeTree.gen.ts
|
.prettierrc
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"printWidth": 100,
|
| 3 |
+
"semi": true,
|
| 4 |
+
"singleQuote": false,
|
| 5 |
+
"trailingComma": "all"
|
| 6 |
+
}
|
.workspace/0
ADDED
|
File without changes
|
.workspace/git/0
ADDED
|
File without changes
|
AGENTS.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- LOVABLE:BEGIN -->
|
| 2 |
+
|
| 3 |
+
> [!IMPORTANT]
|
| 4 |
+
> This project is connected to [Lovable](https://lovable.dev). Avoid rewriting
|
| 5 |
+
> published git history — force pushing, or rebasing/amending/squashing commits
|
| 6 |
+
> that are already pushed — as it rewrites history on Lovable's side and the
|
| 7 |
+
> user will likely lose their project history.
|
| 8 |
+
>
|
| 9 |
+
> Commits you push to the connected branch sync back to Lovable and show up in
|
| 10 |
+
> the editor, so keep the branch in a working state.
|
| 11 |
+
|
| 12 |
+
<!-- LOVABLE:END -->
|
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Build stage
|
| 2 |
+
FROM node:22-slim AS build
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
RUN corepack enable && npm install -g bun@1.3.3
|
| 5 |
+
COPY package.json bun.lock ./
|
| 6 |
+
RUN bun install --frozen-lockfile
|
| 7 |
+
COPY . .
|
| 8 |
+
# Build with the Node server preset so the output runs in a plain Docker container
|
| 9 |
+
ENV NITRO_PRESET=node-server
|
| 10 |
+
RUN bun run build
|
| 11 |
+
|
| 12 |
+
# Runtime stage
|
| 13 |
+
FROM node:22-slim AS runtime
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
ENV NODE_ENV=production \
|
| 16 |
+
PORT=7860 \
|
| 17 |
+
HOST=0.0.0.0
|
| 18 |
+
|
| 19 |
+
# Install Python 3 and huggingface_hub library
|
| 20 |
+
RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
|
| 21 |
+
RUN pip3 install --break-system-packages huggingface_hub
|
| 22 |
+
|
| 23 |
+
COPY --from=build /app/.output ./.output
|
| 24 |
+
EXPOSE 7860
|
| 25 |
+
CMD ["node", ".output/server/index.mjs"]
|
README.md
CHANGED
|
@@ -1,10 +1,66 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
-
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Imageboard Grabber
|
| 3 |
+
emoji: 🖼️
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: true
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Imageboard Grabber
|
| 12 |
+
|
| 13 |
+
Booru-style imageboard grabber (inspired by Bionus/Grabber): tag search, thumbnail grid, multi-select, server-side batch ZIP download. Ships with **e621** preconfigured and a **schema-based "Add site" panel** for Danbooru/Gelbooru/Safebooru/etc.
|
| 14 |
+
|
| 15 |
+
## Features
|
| 16 |
+
|
| 17 |
+
- **Tag exclusion on ZIP download:** Specify custom tags to filter out of the compiled ZIP's `.txt` tag list and markdown meta files.
|
| 18 |
+
- **Direct Hugging Face dataset upload:** Enter your Hugging Face write token and desired dataset repository name to instantly package and upload your compiled archives to a Hugging Face dataset. Creates the dataset automatically if it does not already exist.
|
| 19 |
+
|
| 20 |
+
## Run locally with Docker
|
| 21 |
+
|
| 22 |
+
```bash
|
| 23 |
+
docker build -t grabber .
|
| 24 |
+
docker run --rm -p 7860:7860 grabber
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
Then open http://localhost:7860.
|
| 28 |
+
|
| 29 |
+
## Deploy to Hugging Face Spaces
|
| 30 |
+
|
| 31 |
+
1. Push this repo to GitHub (Lovable → GitHub sync, or `git push`).
|
| 32 |
+
2. Create a new Space on Hugging Face → **SDK: Docker**.
|
| 33 |
+
3. Link the GitHub repo (or add the Space as a remote and push).
|
| 34 |
+
|
| 35 |
+
The frontmatter above tells HF Spaces to build the `Dockerfile` and serve on port `7860`.
|
| 36 |
+
|
| 37 |
+
## Adding a custom site
|
| 38 |
+
|
| 39 |
+
Click **+ Add site** and paste the site's API schema:
|
| 40 |
+
|
| 41 |
+
- **Base URL / Search Path** — e.g. `https://danbooru.donmai.us` + `/posts.json`
|
| 42 |
+
- **Param names** for tags / page / limit
|
| 43 |
+
- **JSON path** to the posts array (empty = root)
|
| 44 |
+
- **Field mappings** (dotted paths) for `id`, `previewUrl`, `fileUrl`, `ext`, `tags`, `source`, `rating`, `score`
|
| 45 |
+
|
| 46 |
+
Example (Danbooru):
|
| 47 |
+
|
| 48 |
+
```
|
| 49 |
+
baseUrl: https://danbooru.donmai.us
|
| 50 |
+
searchPath: /posts.json
|
| 51 |
+
postsPath: (empty)
|
| 52 |
+
fields.id: id
|
| 53 |
+
fields.previewUrl: preview_file_url
|
| 54 |
+
fields.fileUrl: file_url
|
| 55 |
+
fields.ext: file_ext
|
| 56 |
+
fields.tags: tag_string_general
|
| 57 |
+
fields.source: source
|
| 58 |
+
fields.rating: rating
|
| 59 |
+
fields.score: score
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Tech
|
| 63 |
+
|
| 64 |
+
- TanStack Start (React 19, Vite 7) + Tailwind v4 + shadcn/ui
|
| 65 |
+
- Server-side image fetching and streaming ZIP via `fflate`
|
| 66 |
+
- Node server build via nitro `node-server` preset
|
ROADMAP.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Imageboard Grabber - Further Development & Roadmap
|
| 2 |
+
|
| 3 |
+
This document outlines a roadmap and future development plan for the **Imageboard Grabber** application on Hugging Face Spaces.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 🚀 1. Feature Enhancements
|
| 8 |
+
|
| 9 |
+
### 1.1 Support for Authenticated APIs (API Keys & Username)
|
| 10 |
+
|
| 11 |
+
- **Goal:** Allow users to safely search and download from private or rate-limited sites (like Danbooru premium tiers, e621 personal accounts).
|
| 12 |
+
- **Implementation:**
|
| 13 |
+
- Add credential fields (API Key / Password Hash, Username) to the **Add Site** dialog.
|
| 14 |
+
- Securely transmit credentials to the server using HTTP headers or request bodies.
|
| 15 |
+
- Store credentials locally in the browser's `localStorage` or session-only cookies so they are never stored globally on the server.
|
| 16 |
+
|
| 17 |
+
### 1.2 Persistent Site Configuration
|
| 18 |
+
|
| 19 |
+
- **Goal:** Avoid losing newly added schemas when refreshing or clearing session storage.
|
| 20 |
+
- **Implementation:**
|
| 21 |
+
- Sync the list of added custom sites with IndexedDB or `localStorage`.
|
| 22 |
+
- Provide an **Export/Import Sites** button to allow users to backup their custom configurations as JSON.
|
| 23 |
+
|
| 24 |
+
### 1.3 Advanced Query Builder
|
| 25 |
+
|
| 26 |
+
- **Goal:** Help non-technical users build complex booru search queries.
|
| 27 |
+
- **Implementation:**
|
| 28 |
+
- Add UI controls for searching by rating (Safe, Questionable, Explicit), score range, upload date, or file extension.
|
| 29 |
+
- Autocomplete / tag suggestion box by querying the active site's tag API endpoint (e.g., `/tags.json?search[name_matches]=*`).
|
| 30 |
+
|
| 31 |
+
### 1.4 Enhanced Lightbox & Media Viewer
|
| 32 |
+
|
| 33 |
+
- **Goal:** Support video playback and metadata exploration.
|
| 34 |
+
- **Implementation:**
|
| 35 |
+
- Auto-detect video extensions (`.webm`, `.mp4`) in the Lightbox and render a native HTML `<video>` player with volume and speed controls.
|
| 36 |
+
- Show side-panel info: Artist, Character, Copyright, and Meta tags. Click a tag to search.
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## 🛠️ 2. Architectural & Performance Improvements
|
| 41 |
+
|
| 42 |
+
### 2.1 Concurrent / Streamed Server Downloads
|
| 43 |
+
|
| 44 |
+
- **Goal:** Speed up ZIP compilation and handle massive file downloads without causing OOM (Out Of Memory) crashes.
|
| 45 |
+
- **Implementation:**
|
| 46 |
+
- Implement streaming ZIP using `fflate` on the server so bytes are sent back to the client immediately as they download, rather than buffering entire gigabytes in server memory.
|
| 47 |
+
- Limit concurrent download workers per request to avoid IP bans from image hosters.
|
| 48 |
+
|
| 49 |
+
### 2.2 Client-Side Image Caching
|
| 50 |
+
|
| 51 |
+
- **Goal:** Reduce bandwidth usage and accelerate browsing.
|
| 52 |
+
- **Implementation:**
|
| 53 |
+
- Register a Service Worker to cache thumbnails and UI assets.
|
| 54 |
+
- Use `Cache-Control` headers for downloaded image URLs.
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## 🧪 3. Quality Assurance & Automated Testing
|
| 59 |
+
|
| 60 |
+
### 3.1 End-to-End Tests with Playwright
|
| 61 |
+
|
| 62 |
+
- **Goal:** Ensure code modifications do not break key features like site additions or tag searches.
|
| 63 |
+
- **Implementation:**
|
| 64 |
+
- Add E2E test suites inside a `tests/` directory.
|
| 65 |
+
- Mock API responses from e621/Danbooru to test search, grid rendering, and selection UI without hitting actual boorus.
|
| 66 |
+
|
| 67 |
+
### 3.2 Unit and API Integration Tests
|
| 68 |
+
|
| 69 |
+
- **Goal:** Validate parsing logic, schema validation, and URL building helpers.
|
| 70 |
+
- **Implementation:**
|
| 71 |
+
- Write Vitest suites to verify mapping functions in `src/lib/grabber/sites.ts` and zip streaming endpoints.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## 🌐 4. Deployment & Infrastructure Optimization
|
| 76 |
+
|
| 77 |
+
### 4.1 Hugging Face Storage Integration
|
| 78 |
+
|
| 79 |
+
- **Goal:** Retain user session data or cache assets on persistent storage.
|
| 80 |
+
- **Implementation:**
|
| 81 |
+
- Connect a Hugging Face Dataset or persistent Space storage to backup logs or temporary configuration files if requested.
|
_gitdownloads_grabberintanstack.rar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5af4f4a4d381b9864b7010b25efa6ba2dd18316a0b1210ca79f160b05f121e32
|
| 3 |
+
size 128
|
bun.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
bunfig.toml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[install]
|
| 2 |
+
saveTextLockfile = true
|
| 3 |
+
# 24h supply-chain guard: skip package versions published less than a day ago.
|
| 4 |
+
minimumReleaseAge = 86400
|
| 5 |
+
# Each entry bypasses the 24h guard for one package — confirm with the user
|
| 6 |
+
# before adding any.
|
| 7 |
+
minimumReleaseAgeExcludes = ["@lovable.dev/vite-tanstack-config", "@lovable.dev/mcp-js", "@lovable.dev/vite-plugin-dev-server-bridge", "@lovable.dev/vite-plugin-hmr-gate", "@lovable.dev/email-js", "@lovable.dev/webhooks-js"]
|
components.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "new-york",
|
| 4 |
+
"rsc": false,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"css": "src/styles.css",
|
| 8 |
+
"baseColor": "slate",
|
| 9 |
+
"cssVariables": true,
|
| 10 |
+
"prefix": ""
|
| 11 |
+
},
|
| 12 |
+
"iconLibrary": "lucide",
|
| 13 |
+
"rtl": false,
|
| 14 |
+
"aliases": {
|
| 15 |
+
"components": "@/components",
|
| 16 |
+
"utils": "@/lib/utils",
|
| 17 |
+
"ui": "@/components/ui",
|
| 18 |
+
"lib": "@/lib",
|
| 19 |
+
"hooks": "@/hooks"
|
| 20 |
+
},
|
| 21 |
+
"registries": {}
|
| 22 |
+
}
|
eslint.config.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import js from "@eslint/js";
|
| 2 |
+
import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
|
| 3 |
+
import globals from "globals";
|
| 4 |
+
import reactHooks from "eslint-plugin-react-hooks";
|
| 5 |
+
import reactRefresh from "eslint-plugin-react-refresh";
|
| 6 |
+
import tseslint from "typescript-eslint";
|
| 7 |
+
|
| 8 |
+
export default tseslint.config(
|
| 9 |
+
{ ignores: ["dist", ".output", ".vinxi"] },
|
| 10 |
+
{
|
| 11 |
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
| 12 |
+
files: ["**/*.{ts,tsx}"],
|
| 13 |
+
languageOptions: {
|
| 14 |
+
ecmaVersion: 2020,
|
| 15 |
+
globals: globals.browser,
|
| 16 |
+
},
|
| 17 |
+
plugins: {
|
| 18 |
+
"react-hooks": reactHooks,
|
| 19 |
+
"react-refresh": reactRefresh,
|
| 20 |
+
},
|
| 21 |
+
rules: {
|
| 22 |
+
...reactHooks.configs.recommended.rules,
|
| 23 |
+
"no-restricted-imports": [
|
| 24 |
+
"error",
|
| 25 |
+
{
|
| 26 |
+
paths: [
|
| 27 |
+
{
|
| 28 |
+
name: "server-only",
|
| 29 |
+
message:
|
| 30 |
+
"TanStack Start does not use the Next.js `server-only` package. Rename the module to `*.server.ts` or mark it with `@tanstack/react-start/server-only`.",
|
| 31 |
+
},
|
| 32 |
+
],
|
| 33 |
+
},
|
| 34 |
+
],
|
| 35 |
+
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
| 36 |
+
"@typescript-eslint/no-unused-vars": "off",
|
| 37 |
+
},
|
| 38 |
+
},
|
| 39 |
+
eslintPluginPrettier,
|
| 40 |
+
);
|
hf_archived_difffree.rar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a52249a6f8e70456f93e02cecb50ac008d9c3d96dde6631bfec7d5a17ff00f2a
|
| 3 |
+
size 895
|
package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "tanstack_start_ts",
|
| 3 |
+
"private": true,
|
| 4 |
+
"sideEffects": false,
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite dev",
|
| 8 |
+
"build": "vite build",
|
| 9 |
+
"build:dev": "vite build --mode development",
|
| 10 |
+
"preview": "vite preview",
|
| 11 |
+
"start": "node .output/server/index.mjs",
|
| 12 |
+
"lint": "eslint .",
|
| 13 |
+
"format": "prettier --write ."
|
| 14 |
+
},
|
| 15 |
+
"dependencies": {
|
| 16 |
+
"@hookform/resolvers": "^5.2.2",
|
| 17 |
+
"@radix-ui/react-accordion": "^1.2.12",
|
| 18 |
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
| 19 |
+
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
| 20 |
+
"@radix-ui/react-avatar": "^1.1.11",
|
| 21 |
+
"@radix-ui/react-checkbox": "^1.3.3",
|
| 22 |
+
"@radix-ui/react-collapsible": "^1.1.12",
|
| 23 |
+
"@radix-ui/react-context-menu": "^2.2.16",
|
| 24 |
+
"@radix-ui/react-dialog": "^1.1.15",
|
| 25 |
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
| 26 |
+
"@radix-ui/react-hover-card": "^1.1.15",
|
| 27 |
+
"@radix-ui/react-label": "^2.1.8",
|
| 28 |
+
"@radix-ui/react-menubar": "^1.1.16",
|
| 29 |
+
"@radix-ui/react-navigation-menu": "^1.2.14",
|
| 30 |
+
"@radix-ui/react-popover": "^1.1.15",
|
| 31 |
+
"@radix-ui/react-progress": "^1.1.8",
|
| 32 |
+
"@radix-ui/react-radio-group": "^1.3.8",
|
| 33 |
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
| 34 |
+
"@radix-ui/react-select": "^2.2.6",
|
| 35 |
+
"@radix-ui/react-separator": "^1.1.8",
|
| 36 |
+
"@radix-ui/react-slider": "^1.3.6",
|
| 37 |
+
"@radix-ui/react-slot": "^1.2.4",
|
| 38 |
+
"@radix-ui/react-switch": "^1.2.6",
|
| 39 |
+
"@radix-ui/react-tabs": "^1.1.13",
|
| 40 |
+
"@radix-ui/react-toggle": "^1.1.10",
|
| 41 |
+
"@radix-ui/react-toggle-group": "^1.1.11",
|
| 42 |
+
"@radix-ui/react-tooltip": "^1.2.8",
|
| 43 |
+
"@tailwindcss/vite": "^4.2.1",
|
| 44 |
+
"@tanstack/react-query": "^5.101.1",
|
| 45 |
+
"@tanstack/react-router": "^1.170.16",
|
| 46 |
+
"@tanstack/react-start": "^1.168.26",
|
| 47 |
+
"@tanstack/router-plugin": "^1.168.18",
|
| 48 |
+
"class-variance-authority": "^0.7.1",
|
| 49 |
+
"clsx": "^2.1.1",
|
| 50 |
+
"cmdk": "^1.1.1",
|
| 51 |
+
"date-fns": "^4.1.0",
|
| 52 |
+
"embla-carousel-react": "^8.6.0",
|
| 53 |
+
"fflate": "^0.8.3",
|
| 54 |
+
"input-otp": "^1.4.2",
|
| 55 |
+
"lucide-react": "^0.575.0",
|
| 56 |
+
"react": "^19.2.0",
|
| 57 |
+
"react-day-picker": "^9.14.0",
|
| 58 |
+
"react-dom": "^19.2.0",
|
| 59 |
+
"react-hook-form": "^7.71.2",
|
| 60 |
+
"react-resizable-panels": "^4.6.5",
|
| 61 |
+
"recharts": "^2.15.4",
|
| 62 |
+
"sonner": "^2.0.7",
|
| 63 |
+
"tailwind-merge": "^3.5.0",
|
| 64 |
+
"tailwindcss": "^4.2.1",
|
| 65 |
+
"tw-animate-css": "^1.3.4",
|
| 66 |
+
"vaul": "^1.1.2",
|
| 67 |
+
"vite-tsconfig-paths": "^6.0.2",
|
| 68 |
+
"zod": "^4.4.3"
|
| 69 |
+
},
|
| 70 |
+
"devDependencies": {
|
| 71 |
+
"@eslint/js": "^9.32.0",
|
| 72 |
+
"@lovable.dev/vite-tanstack-config": "2.7.6",
|
| 73 |
+
"@types/node": "^22.16.5",
|
| 74 |
+
"@types/react": "^19.2.0",
|
| 75 |
+
"@types/react-dom": "^19.2.0",
|
| 76 |
+
"@vitejs/plugin-react": "^5.2.0",
|
| 77 |
+
"eslint": "^9.32.0",
|
| 78 |
+
"eslint-config-prettier": "^10.1.1",
|
| 79 |
+
"eslint-plugin-prettier": "^5.2.6",
|
| 80 |
+
"eslint-plugin-react-hooks": "^5.2.0",
|
| 81 |
+
"eslint-plugin-react-refresh": "^0.4.20",
|
| 82 |
+
"globals": "^15.15.0",
|
| 83 |
+
"nitro": "3.0.260603-beta",
|
| 84 |
+
"prettier": "^3.7.3",
|
| 85 |
+
"typescript": "^5.8.3",
|
| 86 |
+
"typescript-eslint": "^8.56.1",
|
| 87 |
+
"vite": "^8.0.16"
|
| 88 |
+
}
|
| 89 |
+
}
|
public/favicon.ico
ADDED
|
|
src/components/grabber/AddSiteDialog.tsx
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from "react";
|
| 2 |
+
import type { SiteConfig } from "@/lib/grabber/sites";
|
| 3 |
+
import {
|
| 4 |
+
Dialog,
|
| 5 |
+
DialogContent,
|
| 6 |
+
DialogHeader,
|
| 7 |
+
DialogTitle,
|
| 8 |
+
DialogFooter,
|
| 9 |
+
} from "@/components/ui/dialog";
|
| 10 |
+
import { Input } from "@/components/ui/input";
|
| 11 |
+
import { Label } from "@/components/ui/label";
|
| 12 |
+
import { Button } from "@/components/ui/button";
|
| 13 |
+
import { Textarea } from "@/components/ui/textarea";
|
| 14 |
+
|
| 15 |
+
type Props = {
|
| 16 |
+
open: boolean;
|
| 17 |
+
onOpenChange: (v: boolean) => void;
|
| 18 |
+
onAdd: (site: SiteConfig) => void;
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
const DEFAULT: SiteConfig = {
|
| 22 |
+
id: "danbooru",
|
| 23 |
+
name: "Danbooru",
|
| 24 |
+
baseUrl: "https://danbooru.donmai.us",
|
| 25 |
+
searchPath: "/posts.json",
|
| 26 |
+
params: { tags: "tags", page: "page", limit: "limit" },
|
| 27 |
+
postsPath: "",
|
| 28 |
+
fields: {
|
| 29 |
+
id: "id",
|
| 30 |
+
previewUrl: "preview_file_url",
|
| 31 |
+
fileUrl: "file_url",
|
| 32 |
+
ext: "file_ext",
|
| 33 |
+
tags: "tag_string_general",
|
| 34 |
+
source: "source",
|
| 35 |
+
rating: "rating",
|
| 36 |
+
score: "score",
|
| 37 |
+
sampleUrl: "large_file_url",
|
| 38 |
+
fileSize: "file_size",
|
| 39 |
+
width: "image_width",
|
| 40 |
+
height: "image_height",
|
| 41 |
+
md5: "md5",
|
| 42 |
+
uploader: "uploader_name",
|
| 43 |
+
createdAt: "created_at",
|
| 44 |
+
},
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
export function AddSiteDialog({ open, onOpenChange, onAdd }: Props) {
|
| 48 |
+
const [s, setS] = useState<SiteConfig>(DEFAULT);
|
| 49 |
+
const [headersText, setHeadersText] = useState("");
|
| 50 |
+
const [pasteSchemaText, setPasteSchemaText] = useState("");
|
| 51 |
+
const [parseError, setParseError] = useState("");
|
| 52 |
+
|
| 53 |
+
const set = <K extends keyof SiteConfig>(k: K, v: SiteConfig[K]) =>
|
| 54 |
+
setS((p) => ({ ...p, [k]: v }));
|
| 55 |
+
const setField = (k: keyof SiteConfig["fields"], v: string) =>
|
| 56 |
+
setS((p) => ({ ...p, fields: { ...p.fields, [k]: v } }));
|
| 57 |
+
const setParam = (k: keyof SiteConfig["params"], v: string) =>
|
| 58 |
+
setS((p) => ({ ...p, params: { ...p.params, [k]: v } }));
|
| 59 |
+
|
| 60 |
+
const handlePasteSchema = () => {
|
| 61 |
+
setParseError("");
|
| 62 |
+
if (!pasteSchemaText.trim()) return;
|
| 63 |
+
try {
|
| 64 |
+
const parsed = JSON.parse(pasteSchemaText);
|
| 65 |
+
if (typeof parsed !== "object" || parsed === null) {
|
| 66 |
+
throw new Error("Schema must be an object");
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
const merged: SiteConfig = {
|
| 70 |
+
id: parsed.id || s.id,
|
| 71 |
+
name: parsed.name || s.name,
|
| 72 |
+
baseUrl: parsed.baseUrl || s.baseUrl,
|
| 73 |
+
searchPath: parsed.searchPath || s.searchPath,
|
| 74 |
+
params: {
|
| 75 |
+
tags: parsed.params?.tags || s.params.tags,
|
| 76 |
+
page: parsed.params?.page || s.params.page,
|
| 77 |
+
limit: parsed.params?.limit || s.params.limit,
|
| 78 |
+
},
|
| 79 |
+
postsPath: typeof parsed.postsPath === "string" ? parsed.postsPath : s.postsPath,
|
| 80 |
+
fields: {
|
| 81 |
+
id: parsed.fields?.id || s.fields.id,
|
| 82 |
+
previewUrl: parsed.fields?.previewUrl || s.fields.previewUrl,
|
| 83 |
+
fileUrl: parsed.fields?.fileUrl || s.fields.fileUrl,
|
| 84 |
+
ext: parsed.fields?.ext || s.fields.ext,
|
| 85 |
+
tags: parsed.fields?.tags || s.fields.tags,
|
| 86 |
+
source: parsed.fields?.source || s.fields.source,
|
| 87 |
+
rating: parsed.fields?.rating || s.fields.rating,
|
| 88 |
+
score: parsed.fields?.score || s.fields.score,
|
| 89 |
+
sampleUrl: parsed.fields?.sampleUrl || s.fields.sampleUrl,
|
| 90 |
+
fileSize: parsed.fields?.fileSize || s.fields.fileSize,
|
| 91 |
+
width: parsed.fields?.width || s.fields.width,
|
| 92 |
+
height: parsed.fields?.height || s.fields.height,
|
| 93 |
+
md5: parsed.fields?.md5 || s.fields.md5,
|
| 94 |
+
uploader: parsed.fields?.uploader || s.fields.uploader,
|
| 95 |
+
createdAt: parsed.fields?.createdAt || s.fields.createdAt,
|
| 96 |
+
},
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
if (parsed.headers && typeof parsed.headers === "object") {
|
| 100 |
+
setHeadersText(JSON.stringify(parsed.headers, null, 2));
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
setS(merged);
|
| 104 |
+
setPasteSchemaText("");
|
| 105 |
+
} catch (e: unknown) {
|
| 106 |
+
if (e instanceof Error) {
|
| 107 |
+
setParseError(e.message);
|
| 108 |
+
} else {
|
| 109 |
+
setParseError("Failed to parse JSON");
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
const submit = () => {
|
| 115 |
+
let headers: Record<string, string> | undefined;
|
| 116 |
+
if (headersText.trim()) {
|
| 117 |
+
try {
|
| 118 |
+
headers = JSON.parse(headersText);
|
| 119 |
+
} catch {
|
| 120 |
+
alert("Headers must be valid JSON");
|
| 121 |
+
return;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
onAdd({ ...s, headers });
|
| 125 |
+
onOpenChange(false);
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
return (
|
| 129 |
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
| 130 |
+
<DialogContent className="max-w-2xl max-h-[85vh] overflow-y-auto">
|
| 131 |
+
<DialogHeader>
|
| 132 |
+
<DialogTitle>Add Site (schema)</DialogTitle>
|
| 133 |
+
</DialogHeader>
|
| 134 |
+
|
| 135 |
+
{/* New Paste Schema Input Box */}
|
| 136 |
+
<div className="border p-3 rounded-md bg-muted/30 mb-4">
|
| 137 |
+
<Label className="text-xs font-semibold mb-1 block">
|
| 138 |
+
Paste Site Configuration JSON (API Support)
|
| 139 |
+
</Label>
|
| 140 |
+
<div className="flex gap-2">
|
| 141 |
+
<Textarea
|
| 142 |
+
rows={3}
|
| 143 |
+
value={pasteSchemaText}
|
| 144 |
+
onChange={(e) => setPasteSchemaText(e.target.value)}
|
| 145 |
+
placeholder={`Paste JSON schema here, e.g.:\n{\n "id": "danbooru",\n "name": "Danbooru",\n "baseUrl": "https://danbooru.donmai.us",\n "fields": { "fileUrl": "file_url" }\n}`}
|
| 146 |
+
className="font-mono text-xs flex-1"
|
| 147 |
+
/>
|
| 148 |
+
<Button variant="secondary" size="sm" onClick={handlePasteSchema} className="self-end">
|
| 149 |
+
Apply Schema
|
| 150 |
+
</Button>
|
| 151 |
+
</div>
|
| 152 |
+
{parseError && (
|
| 153 |
+
<div className="text-xs text-destructive mt-1 font-semibold">{parseError}</div>
|
| 154 |
+
)}
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<div className="grid grid-cols-2 gap-3">
|
| 158 |
+
<Field label="ID (unique)">
|
| 159 |
+
<Input value={s.id} onChange={(e) => set("id", e.target.value)} />
|
| 160 |
+
</Field>
|
| 161 |
+
<Field label="Name">
|
| 162 |
+
<Input value={s.name} onChange={(e) => set("name", e.target.value)} />
|
| 163 |
+
</Field>
|
| 164 |
+
<Field label="Base URL">
|
| 165 |
+
<Input value={s.baseUrl} onChange={(e) => set("baseUrl", e.target.value)} />
|
| 166 |
+
</Field>
|
| 167 |
+
<Field label="Search Path">
|
| 168 |
+
<Input value={s.searchPath} onChange={(e) => set("searchPath", e.target.value)} />
|
| 169 |
+
</Field>
|
| 170 |
+
<Field label="tags param">
|
| 171 |
+
<Input value={s.params.tags} onChange={(e) => setParam("tags", e.target.value)} />
|
| 172 |
+
</Field>
|
| 173 |
+
<Field label="page param">
|
| 174 |
+
<Input value={s.params.page} onChange={(e) => setParam("page", e.target.value)} />
|
| 175 |
+
</Field>
|
| 176 |
+
<Field label="limit param">
|
| 177 |
+
<Input value={s.params.limit} onChange={(e) => setParam("limit", e.target.value)} />
|
| 178 |
+
</Field>
|
| 179 |
+
<Field label="posts JSON path (empty = root)">
|
| 180 |
+
<Input value={s.postsPath} onChange={(e) => set("postsPath", e.target.value)} />
|
| 181 |
+
</Field>
|
| 182 |
+
<div className="col-span-2 border-t pt-3 mt-1 text-sm font-semibold">
|
| 183 |
+
Field mappings (dotted paths)
|
| 184 |
+
</div>
|
| 185 |
+
{(
|
| 186 |
+
[
|
| 187 |
+
"id",
|
| 188 |
+
"previewUrl",
|
| 189 |
+
"fileUrl",
|
| 190 |
+
"ext",
|
| 191 |
+
"tags",
|
| 192 |
+
"source",
|
| 193 |
+
"rating",
|
| 194 |
+
"score",
|
| 195 |
+
"sampleUrl",
|
| 196 |
+
"fileSize",
|
| 197 |
+
"width",
|
| 198 |
+
"height",
|
| 199 |
+
"md5",
|
| 200 |
+
"uploader",
|
| 201 |
+
"createdAt",
|
| 202 |
+
] as const
|
| 203 |
+
).map((k) => (
|
| 204 |
+
<Field key={k} label={k}>
|
| 205 |
+
<Input value={s.fields[k] ?? ""} onChange={(e) => setField(k, e.target.value)} />
|
| 206 |
+
</Field>
|
| 207 |
+
))}
|
| 208 |
+
|
| 209 |
+
<Field label="Extra headers (JSON, optional)" full>
|
| 210 |
+
<Textarea
|
| 211 |
+
rows={3}
|
| 212 |
+
value={headersText}
|
| 213 |
+
onChange={(e) => setHeadersText(e.target.value)}
|
| 214 |
+
placeholder='{"User-Agent":"MyGrabber/1.0"}'
|
| 215 |
+
/>
|
| 216 |
+
</Field>
|
| 217 |
+
</div>
|
| 218 |
+
<DialogFooter>
|
| 219 |
+
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
| 220 |
+
Cancel
|
| 221 |
+
</Button>
|
| 222 |
+
<Button onClick={submit}>Add site</Button>
|
| 223 |
+
</DialogFooter>
|
| 224 |
+
</DialogContent>
|
| 225 |
+
</Dialog>
|
| 226 |
+
);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function Field({
|
| 230 |
+
label,
|
| 231 |
+
children,
|
| 232 |
+
full,
|
| 233 |
+
}: {
|
| 234 |
+
label: string;
|
| 235 |
+
children: React.ReactNode;
|
| 236 |
+
full?: boolean;
|
| 237 |
+
}) {
|
| 238 |
+
return (
|
| 239 |
+
<div className={full ? "col-span-2" : ""}>
|
| 240 |
+
<Label className="text-xs mb-1 block">{label}</Label>
|
| 241 |
+
{children}
|
| 242 |
+
</div>
|
| 243 |
+
);
|
| 244 |
+
}
|
src/components/grabber/Lightbox.tsx
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
| 2 |
+
import { Badge } from "@/components/ui/badge";
|
| 3 |
+
import type { NormalizedPost } from "@/lib/grabber/sites";
|
| 4 |
+
|
| 5 |
+
export function Lightbox({ post, onClose }: { post: NormalizedPost | null; onClose: () => void }) {
|
| 6 |
+
return (
|
| 7 |
+
<Dialog open={!!post} onOpenChange={(v) => !v && onClose()}>
|
| 8 |
+
<DialogContent className="max-w-5xl max-h-[92vh] overflow-y-auto p-0">
|
| 9 |
+
{post && (
|
| 10 |
+
<div className="flex flex-col md:flex-row gap-4 p-4">
|
| 11 |
+
<div className="flex-1 flex items-center justify-center bg-black rounded">
|
| 12 |
+
{/\.(mp4|webm)$/i.test(post.fileUrl) ? (
|
| 13 |
+
<video src={post.fileUrl} controls className="max-h-[80vh] max-w-full" />
|
| 14 |
+
) : (
|
| 15 |
+
<img
|
| 16 |
+
src={post.fileUrl}
|
| 17 |
+
alt={`post ${post.id}`}
|
| 18 |
+
className="max-h-[80vh] max-w-full object-contain"
|
| 19 |
+
/>
|
| 20 |
+
)}
|
| 21 |
+
</div>
|
| 22 |
+
<div className="md:w-64 shrink-0 space-y-2 text-sm">
|
| 23 |
+
<div className="font-mono text-xs text-muted-foreground">#{post.id}</div>
|
| 24 |
+
<div className="flex gap-1 flex-wrap">
|
| 25 |
+
{post.rating && <Badge variant="outline">{post.rating}</Badge>}
|
| 26 |
+
{post.score !== undefined && <Badge variant="secondary">★ {post.score}</Badge>}
|
| 27 |
+
</div>
|
| 28 |
+
<div className="space-y-1">
|
| 29 |
+
{post.fileUrl && (
|
| 30 |
+
<a
|
| 31 |
+
href={post.fileUrl}
|
| 32 |
+
target="_blank"
|
| 33 |
+
rel="noreferrer"
|
| 34 |
+
className="text-primary underline text-xs block"
|
| 35 |
+
>
|
| 36 |
+
View Original Image ({post.width && post.height ? `${post.width}x${post.height}` : "Original"})
|
| 37 |
+
</a>
|
| 38 |
+
)}
|
| 39 |
+
{post.sampleUrl && (
|
| 40 |
+
<a
|
| 41 |
+
href={post.sampleUrl}
|
| 42 |
+
target="_blank"
|
| 43 |
+
rel="noreferrer"
|
| 44 |
+
className="text-primary underline text-xs block"
|
| 45 |
+
>
|
| 46 |
+
View Sample Image
|
| 47 |
+
</a>
|
| 48 |
+
)}
|
| 49 |
+
{post.source && (
|
| 50 |
+
<a
|
| 51 |
+
href={post.source}
|
| 52 |
+
target="_blank"
|
| 53 |
+
rel="noreferrer"
|
| 54 |
+
className="text-primary underline text-xs break-all block"
|
| 55 |
+
>
|
| 56 |
+
Source Link
|
| 57 |
+
</a>
|
| 58 |
+
)}
|
| 59 |
+
</div>
|
| 60 |
+
<div className="text-xs text-muted-foreground pt-2">tags</div>
|
| 61 |
+
<div className="flex gap-1 flex-wrap max-h-96 overflow-y-auto">
|
| 62 |
+
{post.tags.map((t) => (
|
| 63 |
+
<Badge key={t} variant="outline" className="font-normal">
|
| 64 |
+
{t}
|
| 65 |
+
</Badge>
|
| 66 |
+
))}
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
)}
|
| 71 |
+
</DialogContent>
|
| 72 |
+
</Dialog>
|
| 73 |
+
);
|
| 74 |
+
}
|
src/components/ui/accordion.tsx
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
| 3 |
+
import { ChevronDown } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Accordion = AccordionPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const AccordionItem = React.forwardRef<
|
| 10 |
+
React.ElementRef<typeof AccordionPrimitive.Item>,
|
| 11 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
| 12 |
+
>(({ className, ...props }, ref) => (
|
| 13 |
+
<AccordionPrimitive.Item ref={ref} className={cn("border-b", className)} {...props} />
|
| 14 |
+
));
|
| 15 |
+
AccordionItem.displayName = "AccordionItem";
|
| 16 |
+
|
| 17 |
+
const AccordionTrigger = React.forwardRef<
|
| 18 |
+
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
| 19 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
| 20 |
+
>(({ className, children, ...props }, ref) => (
|
| 21 |
+
<AccordionPrimitive.Header className="flex">
|
| 22 |
+
<AccordionPrimitive.Trigger
|
| 23 |
+
ref={ref}
|
| 24 |
+
className={cn(
|
| 25 |
+
"flex flex-1 items-center justify-between py-4 text-sm font-medium cursor-pointer transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",
|
| 26 |
+
className,
|
| 27 |
+
)}
|
| 28 |
+
{...props}
|
| 29 |
+
>
|
| 30 |
+
{children}
|
| 31 |
+
<ChevronDown className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
|
| 32 |
+
</AccordionPrimitive.Trigger>
|
| 33 |
+
</AccordionPrimitive.Header>
|
| 34 |
+
));
|
| 35 |
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
| 36 |
+
|
| 37 |
+
const AccordionContent = React.forwardRef<
|
| 38 |
+
React.ElementRef<typeof AccordionPrimitive.Content>,
|
| 39 |
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
| 40 |
+
>(({ className, children, ...props }, ref) => (
|
| 41 |
+
<AccordionPrimitive.Content
|
| 42 |
+
ref={ref}
|
| 43 |
+
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
| 44 |
+
{...props}
|
| 45 |
+
>
|
| 46 |
+
<div className={cn("pb-4 pt-0", className)}>{children}</div>
|
| 47 |
+
</AccordionPrimitive.Content>
|
| 48 |
+
));
|
| 49 |
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
| 50 |
+
|
| 51 |
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
src/components/ui/alert-dialog.tsx
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
import { buttonVariants } from "@/components/ui/button";
|
| 6 |
+
|
| 7 |
+
const AlertDialog = AlertDialogPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
| 12 |
+
|
| 13 |
+
const AlertDialogOverlay = React.forwardRef<
|
| 14 |
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
| 15 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
| 16 |
+
>(({ className, ...props }, ref) => (
|
| 17 |
+
<AlertDialogPrimitive.Overlay
|
| 18 |
+
className={cn(
|
| 19 |
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
| 20 |
+
className,
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
ref={ref}
|
| 24 |
+
/>
|
| 25 |
+
));
|
| 26 |
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
| 27 |
+
|
| 28 |
+
const AlertDialogContent = React.forwardRef<
|
| 29 |
+
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
| 30 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
| 31 |
+
>(({ className, ...props }, ref) => (
|
| 32 |
+
<AlertDialogPortal>
|
| 33 |
+
<AlertDialogOverlay />
|
| 34 |
+
<AlertDialogPrimitive.Content
|
| 35 |
+
ref={ref}
|
| 36 |
+
className={cn(
|
| 37 |
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
|
| 38 |
+
className,
|
| 39 |
+
)}
|
| 40 |
+
{...props}
|
| 41 |
+
/>
|
| 42 |
+
</AlertDialogPortal>
|
| 43 |
+
));
|
| 44 |
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
| 45 |
+
|
| 46 |
+
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 47 |
+
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
| 48 |
+
);
|
| 49 |
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
| 50 |
+
|
| 51 |
+
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 52 |
+
<div
|
| 53 |
+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
| 54 |
+
{...props}
|
| 55 |
+
/>
|
| 56 |
+
);
|
| 57 |
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
| 58 |
+
|
| 59 |
+
const AlertDialogTitle = React.forwardRef<
|
| 60 |
+
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
| 61 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
| 62 |
+
>(({ className, ...props }, ref) => (
|
| 63 |
+
<AlertDialogPrimitive.Title
|
| 64 |
+
ref={ref}
|
| 65 |
+
className={cn("text-lg font-semibold", className)}
|
| 66 |
+
{...props}
|
| 67 |
+
/>
|
| 68 |
+
));
|
| 69 |
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
| 70 |
+
|
| 71 |
+
const AlertDialogDescription = React.forwardRef<
|
| 72 |
+
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
| 73 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
| 74 |
+
>(({ className, ...props }, ref) => (
|
| 75 |
+
<AlertDialogPrimitive.Description
|
| 76 |
+
ref={ref}
|
| 77 |
+
className={cn("text-sm text-muted-foreground", className)}
|
| 78 |
+
{...props}
|
| 79 |
+
/>
|
| 80 |
+
));
|
| 81 |
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
| 82 |
+
|
| 83 |
+
const AlertDialogAction = React.forwardRef<
|
| 84 |
+
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
| 85 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
| 86 |
+
>(({ className, ...props }, ref) => (
|
| 87 |
+
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
| 88 |
+
));
|
| 89 |
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
| 90 |
+
|
| 91 |
+
const AlertDialogCancel = React.forwardRef<
|
| 92 |
+
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
| 93 |
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
| 94 |
+
>(({ className, ...props }, ref) => (
|
| 95 |
+
<AlertDialogPrimitive.Cancel
|
| 96 |
+
ref={ref}
|
| 97 |
+
className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
|
| 98 |
+
{...props}
|
| 99 |
+
/>
|
| 100 |
+
));
|
| 101 |
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
| 102 |
+
|
| 103 |
+
export {
|
| 104 |
+
AlertDialog,
|
| 105 |
+
AlertDialogPortal,
|
| 106 |
+
AlertDialogOverlay,
|
| 107 |
+
AlertDialogTrigger,
|
| 108 |
+
AlertDialogContent,
|
| 109 |
+
AlertDialogHeader,
|
| 110 |
+
AlertDialogFooter,
|
| 111 |
+
AlertDialogTitle,
|
| 112 |
+
AlertDialogDescription,
|
| 113 |
+
AlertDialogAction,
|
| 114 |
+
AlertDialogCancel,
|
| 115 |
+
};
|
src/components/ui/alert.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "bg-background text-foreground",
|
| 12 |
+
destructive:
|
| 13 |
+
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
| 14 |
+
},
|
| 15 |
+
},
|
| 16 |
+
defaultVariants: {
|
| 17 |
+
variant: "default",
|
| 18 |
+
},
|
| 19 |
+
},
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
const Alert = React.forwardRef<
|
| 23 |
+
HTMLDivElement,
|
| 24 |
+
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
| 25 |
+
>(({ className, variant, ...props }, ref) => (
|
| 26 |
+
<div ref={ref} role="alert" className={cn(alertVariants({ variant }), className)} {...props} />
|
| 27 |
+
));
|
| 28 |
+
Alert.displayName = "Alert";
|
| 29 |
+
|
| 30 |
+
const AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
| 31 |
+
({ className, ...props }, ref) => (
|
| 32 |
+
<h5
|
| 33 |
+
ref={ref}
|
| 34 |
+
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
|
| 35 |
+
{...props}
|
| 36 |
+
/>
|
| 37 |
+
),
|
| 38 |
+
);
|
| 39 |
+
AlertTitle.displayName = "AlertTitle";
|
| 40 |
+
|
| 41 |
+
const AlertDescription = React.forwardRef<
|
| 42 |
+
HTMLParagraphElement,
|
| 43 |
+
React.HTMLAttributes<HTMLParagraphElement>
|
| 44 |
+
>(({ className, ...props }, ref) => (
|
| 45 |
+
<div ref={ref} className={cn("text-sm [&_p]:leading-relaxed", className)} {...props} />
|
| 46 |
+
));
|
| 47 |
+
AlertDescription.displayName = "AlertDescription";
|
| 48 |
+
|
| 49 |
+
export { Alert, AlertTitle, AlertDescription };
|
src/components/ui/aspect-ratio.tsx
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio";
|
| 2 |
+
|
| 3 |
+
const AspectRatio = AspectRatioPrimitive.Root;
|
| 4 |
+
|
| 5 |
+
export { AspectRatio };
|
src/components/ui/avatar.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
const Avatar = React.forwardRef<
|
| 9 |
+
React.ElementRef<typeof AvatarPrimitive.Root>,
|
| 10 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
| 11 |
+
>(({ className, ...props }, ref) => (
|
| 12 |
+
<AvatarPrimitive.Root
|
| 13 |
+
ref={ref}
|
| 14 |
+
className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
|
| 15 |
+
{...props}
|
| 16 |
+
/>
|
| 17 |
+
));
|
| 18 |
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
| 19 |
+
|
| 20 |
+
const AvatarImage = React.forwardRef<
|
| 21 |
+
React.ElementRef<typeof AvatarPrimitive.Image>,
|
| 22 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
| 23 |
+
>(({ className, ...props }, ref) => (
|
| 24 |
+
<AvatarPrimitive.Image
|
| 25 |
+
ref={ref}
|
| 26 |
+
className={cn("aspect-square h-full w-full", className)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
));
|
| 30 |
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
| 31 |
+
|
| 32 |
+
const AvatarFallback = React.forwardRef<
|
| 33 |
+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
| 34 |
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
| 35 |
+
>(({ className, ...props }, ref) => (
|
| 36 |
+
<AvatarPrimitive.Fallback
|
| 37 |
+
ref={ref}
|
| 38 |
+
className={cn(
|
| 39 |
+
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
| 40 |
+
className,
|
| 41 |
+
)}
|
| 42 |
+
{...props}
|
| 43 |
+
/>
|
| 44 |
+
));
|
| 45 |
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
| 46 |
+
|
| 47 |
+
export { Avatar, AvatarImage, AvatarFallback };
|
src/components/ui/badge.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { cva, type VariantProps } from "class-variance-authority";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const badgeVariants = cva(
|
| 7 |
+
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
| 12 |
+
secondary:
|
| 13 |
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
| 14 |
+
destructive:
|
| 15 |
+
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
| 16 |
+
outline: "text-foreground",
|
| 17 |
+
},
|
| 18 |
+
},
|
| 19 |
+
defaultVariants: {
|
| 20 |
+
variant: "default",
|
| 21 |
+
},
|
| 22 |
+
},
|
| 23 |
+
);
|
| 24 |
+
|
| 25 |
+
export interface BadgeProps
|
| 26 |
+
extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
| 27 |
+
|
| 28 |
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
| 29 |
+
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
export { Badge, badgeVariants };
|
src/components/ui/breadcrumb.tsx
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { Slot } from "@radix-ui/react-slot";
|
| 3 |
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Breadcrumb = React.forwardRef<
|
| 8 |
+
HTMLElement,
|
| 9 |
+
React.ComponentPropsWithoutRef<"nav"> & {
|
| 10 |
+
separator?: React.ReactNode;
|
| 11 |
+
}
|
| 12 |
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
| 13 |
+
Breadcrumb.displayName = "Breadcrumb";
|
| 14 |
+
|
| 15 |
+
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<"ol">>(
|
| 16 |
+
({ className, ...props }, ref) => (
|
| 17 |
+
<ol
|
| 18 |
+
ref={ref}
|
| 19 |
+
className={cn(
|
| 20 |
+
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
| 21 |
+
className,
|
| 22 |
+
)}
|
| 23 |
+
{...props}
|
| 24 |
+
/>
|
| 25 |
+
),
|
| 26 |
+
);
|
| 27 |
+
BreadcrumbList.displayName = "BreadcrumbList";
|
| 28 |
+
|
| 29 |
+
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<"li">>(
|
| 30 |
+
({ className, ...props }, ref) => (
|
| 31 |
+
<li ref={ref} className={cn("inline-flex items-center gap-1.5", className)} {...props} />
|
| 32 |
+
),
|
| 33 |
+
);
|
| 34 |
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
| 35 |
+
|
| 36 |
+
const BreadcrumbLink = React.forwardRef<
|
| 37 |
+
HTMLAnchorElement,
|
| 38 |
+
React.ComponentPropsWithoutRef<"a"> & {
|
| 39 |
+
asChild?: boolean;
|
| 40 |
+
}
|
| 41 |
+
>(({ asChild, className, ...props }, ref) => {
|
| 42 |
+
const Comp = asChild ? Slot : "a";
|
| 43 |
+
|
| 44 |
+
return (
|
| 45 |
+
<Comp
|
| 46 |
+
ref={ref}
|
| 47 |
+
className={cn("transition-colors hover:text-foreground", className)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
);
|
| 51 |
+
});
|
| 52 |
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
| 53 |
+
|
| 54 |
+
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<"span">>(
|
| 55 |
+
({ className, ...props }, ref) => (
|
| 56 |
+
<span
|
| 57 |
+
ref={ref}
|
| 58 |
+
role="link"
|
| 59 |
+
aria-disabled="true"
|
| 60 |
+
aria-current="page"
|
| 61 |
+
className={cn("font-normal text-foreground", className)}
|
| 62 |
+
{...props}
|
| 63 |
+
/>
|
| 64 |
+
),
|
| 65 |
+
);
|
| 66 |
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
| 67 |
+
|
| 68 |
+
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<"li">) => (
|
| 69 |
+
<li
|
| 70 |
+
role="presentation"
|
| 71 |
+
aria-hidden="true"
|
| 72 |
+
className={cn("[&>svg]:w-3.5 [&>svg]:h-3.5", className)}
|
| 73 |
+
{...props}
|
| 74 |
+
>
|
| 75 |
+
{children ?? <ChevronRight />}
|
| 76 |
+
</li>
|
| 77 |
+
);
|
| 78 |
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
| 79 |
+
|
| 80 |
+
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
| 81 |
+
<span
|
| 82 |
+
role="presentation"
|
| 83 |
+
aria-hidden="true"
|
| 84 |
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
| 85 |
+
{...props}
|
| 86 |
+
>
|
| 87 |
+
<MoreHorizontal className="h-4 w-4" />
|
| 88 |
+
<span className="sr-only">More</span>
|
| 89 |
+
</span>
|
| 90 |
+
);
|
| 91 |
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
| 92 |
+
|
| 93 |
+
export {
|
| 94 |
+
Breadcrumb,
|
| 95 |
+
BreadcrumbList,
|
| 96 |
+
BreadcrumbItem,
|
| 97 |
+
BreadcrumbLink,
|
| 98 |
+
BreadcrumbPage,
|
| 99 |
+
BreadcrumbSeparator,
|
| 100 |
+
BreadcrumbEllipsis,
|
| 101 |
+
};
|
src/components/ui/button.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
| 13 |
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
| 14 |
+
outline:
|
| 15 |
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
| 16 |
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
| 17 |
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
| 18 |
+
link: "text-primary underline-offset-4 hover:underline",
|
| 19 |
+
},
|
| 20 |
+
size: {
|
| 21 |
+
default: "h-9 px-4 py-2",
|
| 22 |
+
sm: "h-8 rounded-md px-3 text-xs",
|
| 23 |
+
lg: "h-10 rounded-md px-8",
|
| 24 |
+
icon: "h-9 w-9",
|
| 25 |
+
},
|
| 26 |
+
},
|
| 27 |
+
defaultVariants: {
|
| 28 |
+
variant: "default",
|
| 29 |
+
size: "default",
|
| 30 |
+
},
|
| 31 |
+
},
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
export interface ButtonProps
|
| 35 |
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
| 36 |
+
asChild?: boolean;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
| 40 |
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
| 41 |
+
const Comp = asChild ? Slot : "button";
|
| 42 |
+
return (
|
| 43 |
+
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
|
| 44 |
+
);
|
| 45 |
+
},
|
| 46 |
+
);
|
| 47 |
+
Button.displayName = "Button";
|
| 48 |
+
|
| 49 |
+
export { Button, buttonVariants };
|
src/components/ui/calendar.tsx
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
| 5 |
+
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
import { Button, buttonVariants } from "@/components/ui/button";
|
| 9 |
+
|
| 10 |
+
function Calendar({
|
| 11 |
+
className,
|
| 12 |
+
classNames,
|
| 13 |
+
showOutsideDays = true,
|
| 14 |
+
captionLayout = "label",
|
| 15 |
+
buttonVariant = "ghost",
|
| 16 |
+
formatters,
|
| 17 |
+
components,
|
| 18 |
+
...props
|
| 19 |
+
}: React.ComponentProps<typeof DayPicker> & {
|
| 20 |
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
| 21 |
+
}) {
|
| 22 |
+
const defaultClassNames = getDefaultClassNames();
|
| 23 |
+
|
| 24 |
+
return (
|
| 25 |
+
<DayPicker
|
| 26 |
+
showOutsideDays={showOutsideDays}
|
| 27 |
+
className={cn(
|
| 28 |
+
"bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
| 29 |
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
| 30 |
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
| 31 |
+
className,
|
| 32 |
+
)}
|
| 33 |
+
captionLayout={captionLayout}
|
| 34 |
+
formatters={{
|
| 35 |
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
| 36 |
+
...formatters,
|
| 37 |
+
}}
|
| 38 |
+
classNames={{
|
| 39 |
+
root: cn("w-fit", defaultClassNames.root),
|
| 40 |
+
months: cn("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months),
|
| 41 |
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
| 42 |
+
nav: cn(
|
| 43 |
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
| 44 |
+
defaultClassNames.nav,
|
| 45 |
+
),
|
| 46 |
+
button_previous: cn(
|
| 47 |
+
buttonVariants({ variant: buttonVariant }),
|
| 48 |
+
"h-(--cell-size) w-(--cell-size) select-none p-0 aria-disabled:opacity-50",
|
| 49 |
+
defaultClassNames.button_previous,
|
| 50 |
+
),
|
| 51 |
+
button_next: cn(
|
| 52 |
+
buttonVariants({ variant: buttonVariant }),
|
| 53 |
+
"h-(--cell-size) w-(--cell-size) select-none p-0 aria-disabled:opacity-50",
|
| 54 |
+
defaultClassNames.button_next,
|
| 55 |
+
),
|
| 56 |
+
month_caption: cn(
|
| 57 |
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
| 58 |
+
defaultClassNames.month_caption,
|
| 59 |
+
),
|
| 60 |
+
dropdowns: cn(
|
| 61 |
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
| 62 |
+
defaultClassNames.dropdowns,
|
| 63 |
+
),
|
| 64 |
+
dropdown_root: cn(
|
| 65 |
+
"has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",
|
| 66 |
+
defaultClassNames.dropdown_root,
|
| 67 |
+
),
|
| 68 |
+
dropdown: cn("bg-popover absolute inset-0 opacity-0", defaultClassNames.dropdown),
|
| 69 |
+
caption_label: cn(
|
| 70 |
+
"select-none font-medium",
|
| 71 |
+
captionLayout === "label"
|
| 72 |
+
? "text-sm"
|
| 73 |
+
: "[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",
|
| 74 |
+
defaultClassNames.caption_label,
|
| 75 |
+
),
|
| 76 |
+
table: "w-full border-collapse",
|
| 77 |
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
| 78 |
+
weekday: cn(
|
| 79 |
+
"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",
|
| 80 |
+
defaultClassNames.weekday,
|
| 81 |
+
),
|
| 82 |
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
| 83 |
+
week_number_header: cn("w-(--cell-size) select-none", defaultClassNames.week_number_header),
|
| 84 |
+
week_number: cn(
|
| 85 |
+
"text-muted-foreground select-none text-[0.8rem]",
|
| 86 |
+
defaultClassNames.week_number,
|
| 87 |
+
),
|
| 88 |
+
day: cn(
|
| 89 |
+
"group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",
|
| 90 |
+
defaultClassNames.day,
|
| 91 |
+
),
|
| 92 |
+
range_start: cn("bg-accent rounded-l-md", defaultClassNames.range_start),
|
| 93 |
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
| 94 |
+
range_end: cn("bg-accent rounded-r-md", defaultClassNames.range_end),
|
| 95 |
+
today: cn(
|
| 96 |
+
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
| 97 |
+
defaultClassNames.today,
|
| 98 |
+
),
|
| 99 |
+
outside: cn(
|
| 100 |
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
| 101 |
+
defaultClassNames.outside,
|
| 102 |
+
),
|
| 103 |
+
disabled: cn("text-muted-foreground opacity-50", defaultClassNames.disabled),
|
| 104 |
+
hidden: cn("invisible", defaultClassNames.hidden),
|
| 105 |
+
...classNames,
|
| 106 |
+
}}
|
| 107 |
+
components={{
|
| 108 |
+
Root: ({ className, rootRef, ...props }) => {
|
| 109 |
+
return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
|
| 110 |
+
},
|
| 111 |
+
Chevron: ({ className, orientation, ...props }) => {
|
| 112 |
+
if (orientation === "left") {
|
| 113 |
+
return <ChevronLeftIcon className={cn("size-4", className)} {...props} />;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
if (orientation === "right") {
|
| 117 |
+
return <ChevronRightIcon className={cn("size-4", className)} {...props} />;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
return <ChevronDownIcon className={cn("size-4", className)} {...props} />;
|
| 121 |
+
},
|
| 122 |
+
DayButton: CalendarDayButton,
|
| 123 |
+
WeekNumber: ({ children, ...props }) => {
|
| 124 |
+
return (
|
| 125 |
+
<td {...props}>
|
| 126 |
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
| 127 |
+
{children}
|
| 128 |
+
</div>
|
| 129 |
+
</td>
|
| 130 |
+
);
|
| 131 |
+
},
|
| 132 |
+
...components,
|
| 133 |
+
}}
|
| 134 |
+
{...props}
|
| 135 |
+
/>
|
| 136 |
+
);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function CalendarDayButton({
|
| 140 |
+
className,
|
| 141 |
+
day,
|
| 142 |
+
modifiers,
|
| 143 |
+
...props
|
| 144 |
+
}: React.ComponentProps<typeof DayButton>) {
|
| 145 |
+
const defaultClassNames = getDefaultClassNames();
|
| 146 |
+
|
| 147 |
+
const ref = React.useRef<HTMLButtonElement>(null);
|
| 148 |
+
React.useEffect(() => {
|
| 149 |
+
if (modifiers.focused) ref.current?.focus();
|
| 150 |
+
}, [modifiers.focused]);
|
| 151 |
+
|
| 152 |
+
return (
|
| 153 |
+
<Button
|
| 154 |
+
ref={ref}
|
| 155 |
+
variant="ghost"
|
| 156 |
+
size="icon"
|
| 157 |
+
data-day={day.date.toLocaleDateString()}
|
| 158 |
+
data-selected-single={
|
| 159 |
+
modifiers.selected &&
|
| 160 |
+
!modifiers.range_start &&
|
| 161 |
+
!modifiers.range_end &&
|
| 162 |
+
!modifiers.range_middle
|
| 163 |
+
}
|
| 164 |
+
data-range-start={modifiers.range_start}
|
| 165 |
+
data-range-end={modifiers.range_end}
|
| 166 |
+
data-range-middle={modifiers.range_middle}
|
| 167 |
+
className={cn(
|
| 168 |
+
"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 flex aspect-square h-auto w-full min-w-(--cell-size) flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",
|
| 169 |
+
defaultClassNames.day,
|
| 170 |
+
className,
|
| 171 |
+
)}
|
| 172 |
+
{...props}
|
| 173 |
+
/>
|
| 174 |
+
);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
export { Calendar, CalendarDayButton };
|
src/components/ui/card.tsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils";
|
| 4 |
+
|
| 5 |
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 6 |
+
({ className, ...props }, ref) => (
|
| 7 |
+
<div
|
| 8 |
+
ref={ref}
|
| 9 |
+
className={cn("rounded-xl border bg-card text-card-foreground shadow", className)}
|
| 10 |
+
{...props}
|
| 11 |
+
/>
|
| 12 |
+
),
|
| 13 |
+
);
|
| 14 |
+
Card.displayName = "Card";
|
| 15 |
+
|
| 16 |
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 17 |
+
({ className, ...props }, ref) => (
|
| 18 |
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
| 19 |
+
),
|
| 20 |
+
);
|
| 21 |
+
CardHeader.displayName = "CardHeader";
|
| 22 |
+
|
| 23 |
+
const CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 24 |
+
({ className, ...props }, ref) => (
|
| 25 |
+
<div
|
| 26 |
+
ref={ref}
|
| 27 |
+
className={cn("font-semibold leading-none tracking-tight", className)}
|
| 28 |
+
{...props}
|
| 29 |
+
/>
|
| 30 |
+
),
|
| 31 |
+
);
|
| 32 |
+
CardTitle.displayName = "CardTitle";
|
| 33 |
+
|
| 34 |
+
const CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 35 |
+
({ className, ...props }, ref) => (
|
| 36 |
+
<div ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
| 37 |
+
),
|
| 38 |
+
);
|
| 39 |
+
CardDescription.displayName = "CardDescription";
|
| 40 |
+
|
| 41 |
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 42 |
+
({ className, ...props }, ref) => (
|
| 43 |
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
| 44 |
+
),
|
| 45 |
+
);
|
| 46 |
+
CardContent.displayName = "CardContent";
|
| 47 |
+
|
| 48 |
+
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 49 |
+
({ className, ...props }, ref) => (
|
| 50 |
+
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
| 51 |
+
),
|
| 52 |
+
);
|
| 53 |
+
CardFooter.displayName = "CardFooter";
|
| 54 |
+
|
| 55 |
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
src/components/ui/carousel.tsx
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
| 3 |
+
import { ArrowLeft, ArrowRight } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
import { Button } from "@/components/ui/button";
|
| 7 |
+
|
| 8 |
+
type CarouselApi = UseEmblaCarouselType[1];
|
| 9 |
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
| 10 |
+
type CarouselOptions = UseCarouselParameters[0];
|
| 11 |
+
type CarouselPlugin = UseCarouselParameters[1];
|
| 12 |
+
|
| 13 |
+
type CarouselProps = {
|
| 14 |
+
opts?: CarouselOptions;
|
| 15 |
+
plugins?: CarouselPlugin;
|
| 16 |
+
orientation?: "horizontal" | "vertical";
|
| 17 |
+
setApi?: (api: CarouselApi) => void;
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
type CarouselContextProps = {
|
| 21 |
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
| 22 |
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
| 23 |
+
scrollPrev: () => void;
|
| 24 |
+
scrollNext: () => void;
|
| 25 |
+
canScrollPrev: boolean;
|
| 26 |
+
canScrollNext: boolean;
|
| 27 |
+
} & CarouselProps;
|
| 28 |
+
|
| 29 |
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
| 30 |
+
|
| 31 |
+
function useCarousel() {
|
| 32 |
+
const context = React.useContext(CarouselContext);
|
| 33 |
+
|
| 34 |
+
if (!context) {
|
| 35 |
+
throw new Error("useCarousel must be used within a <Carousel />");
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return context;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
const Carousel = React.forwardRef<
|
| 42 |
+
HTMLDivElement,
|
| 43 |
+
React.HTMLAttributes<HTMLDivElement> & CarouselProps
|
| 44 |
+
>(({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => {
|
| 45 |
+
const [carouselRef, api] = useEmblaCarousel(
|
| 46 |
+
{
|
| 47 |
+
...opts,
|
| 48 |
+
axis: orientation === "horizontal" ? "x" : "y",
|
| 49 |
+
},
|
| 50 |
+
plugins,
|
| 51 |
+
);
|
| 52 |
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
| 53 |
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
| 54 |
+
|
| 55 |
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
| 56 |
+
if (!api) {
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
setCanScrollPrev(api.canScrollPrev());
|
| 61 |
+
setCanScrollNext(api.canScrollNext());
|
| 62 |
+
}, []);
|
| 63 |
+
|
| 64 |
+
const scrollPrev = React.useCallback(() => {
|
| 65 |
+
api?.scrollPrev();
|
| 66 |
+
}, [api]);
|
| 67 |
+
|
| 68 |
+
const scrollNext = React.useCallback(() => {
|
| 69 |
+
api?.scrollNext();
|
| 70 |
+
}, [api]);
|
| 71 |
+
|
| 72 |
+
const handleKeyDown = React.useCallback(
|
| 73 |
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
| 74 |
+
if (event.key === "ArrowLeft") {
|
| 75 |
+
event.preventDefault();
|
| 76 |
+
scrollPrev();
|
| 77 |
+
} else if (event.key === "ArrowRight") {
|
| 78 |
+
event.preventDefault();
|
| 79 |
+
scrollNext();
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
[scrollPrev, scrollNext],
|
| 83 |
+
);
|
| 84 |
+
|
| 85 |
+
React.useEffect(() => {
|
| 86 |
+
if (!api || !setApi) {
|
| 87 |
+
return;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
setApi(api);
|
| 91 |
+
}, [api, setApi]);
|
| 92 |
+
|
| 93 |
+
React.useEffect(() => {
|
| 94 |
+
if (!api) {
|
| 95 |
+
return;
|
| 96 |
+
}
|
| 97 |
+
|
| 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: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
| 114 |
+
scrollPrev,
|
| 115 |
+
scrollNext,
|
| 116 |
+
canScrollPrev,
|
| 117 |
+
canScrollNext,
|
| 118 |
+
}}
|
| 119 |
+
>
|
| 120 |
+
<div
|
| 121 |
+
ref={ref}
|
| 122 |
+
onKeyDownCapture={handleKeyDown}
|
| 123 |
+
className={cn("relative", className)}
|
| 124 |
+
role="region"
|
| 125 |
+
aria-roledescription="carousel"
|
| 126 |
+
{...props}
|
| 127 |
+
>
|
| 128 |
+
{children}
|
| 129 |
+
</div>
|
| 130 |
+
</CarouselContext.Provider>
|
| 131 |
+
);
|
| 132 |
+
});
|
| 133 |
+
Carousel.displayName = "Carousel";
|
| 134 |
+
|
| 135 |
+
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 136 |
+
({ className, ...props }, ref) => {
|
| 137 |
+
const { carouselRef, orientation } = useCarousel();
|
| 138 |
+
|
| 139 |
+
return (
|
| 140 |
+
<div ref={carouselRef} className="overflow-hidden">
|
| 141 |
+
<div
|
| 142 |
+
ref={ref}
|
| 143 |
+
className={cn(
|
| 144 |
+
"flex",
|
| 145 |
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
| 146 |
+
className,
|
| 147 |
+
)}
|
| 148 |
+
{...props}
|
| 149 |
+
/>
|
| 150 |
+
</div>
|
| 151 |
+
);
|
| 152 |
+
},
|
| 153 |
+
);
|
| 154 |
+
CarouselContent.displayName = "CarouselContent";
|
| 155 |
+
|
| 156 |
+
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 157 |
+
({ className, ...props }, ref) => {
|
| 158 |
+
const { orientation } = useCarousel();
|
| 159 |
+
|
| 160 |
+
return (
|
| 161 |
+
<div
|
| 162 |
+
ref={ref}
|
| 163 |
+
role="group"
|
| 164 |
+
aria-roledescription="slide"
|
| 165 |
+
className={cn(
|
| 166 |
+
"min-w-0 shrink-0 grow-0 basis-full",
|
| 167 |
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
| 168 |
+
className,
|
| 169 |
+
)}
|
| 170 |
+
{...props}
|
| 171 |
+
/>
|
| 172 |
+
);
|
| 173 |
+
},
|
| 174 |
+
);
|
| 175 |
+
CarouselItem.displayName = "CarouselItem";
|
| 176 |
+
|
| 177 |
+
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
| 178 |
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
| 179 |
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
| 180 |
+
|
| 181 |
+
return (
|
| 182 |
+
<Button
|
| 183 |
+
ref={ref}
|
| 184 |
+
variant={variant}
|
| 185 |
+
size={size}
|
| 186 |
+
className={cn(
|
| 187 |
+
"absolute h-8 w-8 rounded-full",
|
| 188 |
+
orientation === "horizontal"
|
| 189 |
+
? "-left-12 top-1/2 -translate-y-1/2"
|
| 190 |
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
| 191 |
+
className,
|
| 192 |
+
)}
|
| 193 |
+
disabled={!canScrollPrev}
|
| 194 |
+
onClick={scrollPrev}
|
| 195 |
+
{...props}
|
| 196 |
+
>
|
| 197 |
+
<ArrowLeft className="h-4 w-4" />
|
| 198 |
+
<span className="sr-only">Previous slide</span>
|
| 199 |
+
</Button>
|
| 200 |
+
);
|
| 201 |
+
},
|
| 202 |
+
);
|
| 203 |
+
CarouselPrevious.displayName = "CarouselPrevious";
|
| 204 |
+
|
| 205 |
+
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
| 206 |
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
| 207 |
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
| 208 |
+
|
| 209 |
+
return (
|
| 210 |
+
<Button
|
| 211 |
+
ref={ref}
|
| 212 |
+
variant={variant}
|
| 213 |
+
size={size}
|
| 214 |
+
className={cn(
|
| 215 |
+
"absolute h-8 w-8 rounded-full",
|
| 216 |
+
orientation === "horizontal"
|
| 217 |
+
? "-right-12 top-1/2 -translate-y-1/2"
|
| 218 |
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
| 219 |
+
className,
|
| 220 |
+
)}
|
| 221 |
+
disabled={!canScrollNext}
|
| 222 |
+
onClick={scrollNext}
|
| 223 |
+
{...props}
|
| 224 |
+
>
|
| 225 |
+
<ArrowRight className="h-4 w-4" />
|
| 226 |
+
<span className="sr-only">Next slide</span>
|
| 227 |
+
</Button>
|
| 228 |
+
);
|
| 229 |
+
},
|
| 230 |
+
);
|
| 231 |
+
CarouselNext.displayName = "CarouselNext";
|
| 232 |
+
|
| 233 |
+
export {
|
| 234 |
+
type CarouselApi,
|
| 235 |
+
Carousel,
|
| 236 |
+
CarouselContent,
|
| 237 |
+
CarouselItem,
|
| 238 |
+
CarouselPrevious,
|
| 239 |
+
CarouselNext,
|
| 240 |
+
};
|
src/components/ui/chart.tsx
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as RechartsPrimitive from "recharts";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
| 7 |
+
const THEMES = { light: "", dark: ".dark" } as const;
|
| 8 |
+
|
| 9 |
+
export type ChartConfig = {
|
| 10 |
+
[k in string]: {
|
| 11 |
+
label?: React.ReactNode;
|
| 12 |
+
icon?: React.ComponentType;
|
| 13 |
+
} & (
|
| 14 |
+
| { color?: string; theme?: never }
|
| 15 |
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
| 16 |
+
);
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
type ChartContextProps = {
|
| 20 |
+
config: ChartConfig;
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
| 24 |
+
|
| 25 |
+
function useChart() {
|
| 26 |
+
const context = React.useContext(ChartContext);
|
| 27 |
+
|
| 28 |
+
if (!context) {
|
| 29 |
+
throw new Error("useChart must be used within a <ChartContainer />");
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return context;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
const ChartContainer = React.forwardRef<
|
| 36 |
+
HTMLDivElement,
|
| 37 |
+
React.ComponentProps<"div"> & {
|
| 38 |
+
config: ChartConfig;
|
| 39 |
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
| 40 |
+
}
|
| 41 |
+
>(({ id, className, children, config, ...props }, ref) => {
|
| 42 |
+
const uniqueId = React.useId();
|
| 43 |
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
| 44 |
+
|
| 45 |
+
return (
|
| 46 |
+
<ChartContext.Provider value={{ config }}>
|
| 47 |
+
<div
|
| 48 |
+
data-chart={chartId}
|
| 49 |
+
ref={ref}
|
| 50 |
+
className={cn(
|
| 51 |
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
| 52 |
+
className,
|
| 53 |
+
)}
|
| 54 |
+
{...props}
|
| 55 |
+
>
|
| 56 |
+
<ChartStyle id={chartId} config={config} />
|
| 57 |
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
| 58 |
+
</div>
|
| 59 |
+
</ChartContext.Provider>
|
| 60 |
+
);
|
| 61 |
+
});
|
| 62 |
+
ChartContainer.displayName = "Chart";
|
| 63 |
+
|
| 64 |
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
| 65 |
+
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
| 66 |
+
|
| 67 |
+
if (!colorConfig.length) {
|
| 68 |
+
return null;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return (
|
| 72 |
+
<style
|
| 73 |
+
dangerouslySetInnerHTML={{
|
| 74 |
+
__html: Object.entries(THEMES)
|
| 75 |
+
.map(
|
| 76 |
+
([theme, prefix]) => `
|
| 77 |
+
${prefix} [data-chart=${id}] {
|
| 78 |
+
${colorConfig
|
| 79 |
+
.map(([key, itemConfig]) => {
|
| 80 |
+
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
| 81 |
+
return color ? ` --color-${key}: ${color};` : null;
|
| 82 |
+
})
|
| 83 |
+
.join("\n")}
|
| 84 |
+
}
|
| 85 |
+
`,
|
| 86 |
+
)
|
| 87 |
+
.join("\n"),
|
| 88 |
+
}}
|
| 89 |
+
/>
|
| 90 |
+
);
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
| 94 |
+
|
| 95 |
+
const ChartTooltipContent = React.forwardRef<
|
| 96 |
+
HTMLDivElement,
|
| 97 |
+
React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
| 98 |
+
React.ComponentProps<"div"> & {
|
| 99 |
+
hideLabel?: boolean;
|
| 100 |
+
hideIndicator?: boolean;
|
| 101 |
+
indicator?: "line" | "dot" | "dashed";
|
| 102 |
+
nameKey?: string;
|
| 103 |
+
labelKey?: string;
|
| 104 |
+
}
|
| 105 |
+
>(
|
| 106 |
+
(
|
| 107 |
+
{
|
| 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 |
+
},
|
| 122 |
+
ref,
|
| 123 |
+
) => {
|
| 124 |
+
const { config } = useChart();
|
| 125 |
+
|
| 126 |
+
const tooltipLabel = React.useMemo(() => {
|
| 127 |
+
if (hideLabel || !payload?.length) {
|
| 128 |
+
return null;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
const [item] = payload;
|
| 132 |
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
| 133 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 134 |
+
const value =
|
| 135 |
+
!labelKey && typeof label === "string"
|
| 136 |
+
? config[label as keyof typeof config]?.label || label
|
| 137 |
+
: itemConfig?.label;
|
| 138 |
+
|
| 139 |
+
if (labelFormatter) {
|
| 140 |
+
return (
|
| 141 |
+
<div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>
|
| 142 |
+
);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
if (!value) {
|
| 146 |
+
return null;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
| 150 |
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
| 151 |
+
|
| 152 |
+
if (!active || !payload?.length) {
|
| 153 |
+
return null;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
| 157 |
+
|
| 158 |
+
return (
|
| 159 |
+
<div
|
| 160 |
+
ref={ref}
|
| 161 |
+
className={cn(
|
| 162 |
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
| 163 |
+
className,
|
| 164 |
+
)}
|
| 165 |
+
>
|
| 166 |
+
{!nestLabel ? tooltipLabel : null}
|
| 167 |
+
<div className="grid gap-1.5">
|
| 168 |
+
{payload
|
| 169 |
+
.filter((item) => item.type !== "none")
|
| 170 |
+
.map((item, index) => {
|
| 171 |
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
| 172 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 173 |
+
const indicatorColor = color || item.payload.fill || item.color;
|
| 174 |
+
|
| 175 |
+
return (
|
| 176 |
+
<div
|
| 177 |
+
key={item.dataKey}
|
| 178 |
+
className={cn(
|
| 179 |
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
| 180 |
+
indicator === "dot" && "items-center",
|
| 181 |
+
)}
|
| 182 |
+
>
|
| 183 |
+
{formatter && item?.value !== undefined && item.name ? (
|
| 184 |
+
formatter(item.value, item.name, item, index, item.payload)
|
| 185 |
+
) : (
|
| 186 |
+
<>
|
| 187 |
+
{itemConfig?.icon ? (
|
| 188 |
+
<itemConfig.icon />
|
| 189 |
+
) : (
|
| 190 |
+
!hideIndicator && (
|
| 191 |
+
<div
|
| 192 |
+
className={cn(
|
| 193 |
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
| 194 |
+
{
|
| 195 |
+
"h-2.5 w-2.5": indicator === "dot",
|
| 196 |
+
"w-1": indicator === "line",
|
| 197 |
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
| 198 |
+
indicator === "dashed",
|
| 199 |
+
"my-0.5": nestLabel && indicator === "dashed",
|
| 200 |
+
},
|
| 201 |
+
)}
|
| 202 |
+
style={
|
| 203 |
+
{
|
| 204 |
+
"--color-bg": indicatorColor,
|
| 205 |
+
"--color-border": indicatorColor,
|
| 206 |
+
} as React.CSSProperties
|
| 207 |
+
}
|
| 208 |
+
/>
|
| 209 |
+
)
|
| 210 |
+
)}
|
| 211 |
+
<div
|
| 212 |
+
className={cn(
|
| 213 |
+
"flex flex-1 justify-between leading-none",
|
| 214 |
+
nestLabel ? "items-end" : "items-center",
|
| 215 |
+
)}
|
| 216 |
+
>
|
| 217 |
+
<div className="grid gap-1.5">
|
| 218 |
+
{nestLabel ? tooltipLabel : null}
|
| 219 |
+
<span className="text-muted-foreground">
|
| 220 |
+
{itemConfig?.label || item.name}
|
| 221 |
+
</span>
|
| 222 |
+
</div>
|
| 223 |
+
{item.value && (
|
| 224 |
+
<span className="font-mono font-medium tabular-nums text-foreground">
|
| 225 |
+
{item.value.toLocaleString()}
|
| 226 |
+
</span>
|
| 227 |
+
)}
|
| 228 |
+
</div>
|
| 229 |
+
</>
|
| 230 |
+
)}
|
| 231 |
+
</div>
|
| 232 |
+
);
|
| 233 |
+
})}
|
| 234 |
+
</div>
|
| 235 |
+
</div>
|
| 236 |
+
);
|
| 237 |
+
},
|
| 238 |
+
);
|
| 239 |
+
ChartTooltipContent.displayName = "ChartTooltip";
|
| 240 |
+
|
| 241 |
+
const ChartLegend = RechartsPrimitive.Legend;
|
| 242 |
+
|
| 243 |
+
const ChartLegendContent = React.forwardRef<
|
| 244 |
+
HTMLDivElement,
|
| 245 |
+
React.ComponentProps<"div"> &
|
| 246 |
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
| 247 |
+
hideIcon?: boolean;
|
| 248 |
+
nameKey?: string;
|
| 249 |
+
}
|
| 250 |
+
>(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
| 251 |
+
const { config } = useChart();
|
| 252 |
+
|
| 253 |
+
if (!payload?.length) {
|
| 254 |
+
return null;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
return (
|
| 258 |
+
<div
|
| 259 |
+
ref={ref}
|
| 260 |
+
className={cn(
|
| 261 |
+
"flex items-center justify-center gap-4",
|
| 262 |
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
| 263 |
+
className,
|
| 264 |
+
)}
|
| 265 |
+
>
|
| 266 |
+
{payload
|
| 267 |
+
.filter((item) => item.type !== "none")
|
| 268 |
+
.map((item) => {
|
| 269 |
+
const key = `${nameKey || item.dataKey || "value"}`;
|
| 270 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
| 271 |
+
|
| 272 |
+
return (
|
| 273 |
+
<div
|
| 274 |
+
key={item.value}
|
| 275 |
+
className={cn(
|
| 276 |
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
|
| 277 |
+
)}
|
| 278 |
+
>
|
| 279 |
+
{itemConfig?.icon && !hideIcon ? (
|
| 280 |
+
<itemConfig.icon />
|
| 281 |
+
) : (
|
| 282 |
+
<div
|
| 283 |
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
| 284 |
+
style={{
|
| 285 |
+
backgroundColor: item.color,
|
| 286 |
+
}}
|
| 287 |
+
/>
|
| 288 |
+
)}
|
| 289 |
+
{itemConfig?.label}
|
| 290 |
+
</div>
|
| 291 |
+
);
|
| 292 |
+
})}
|
| 293 |
+
</div>
|
| 294 |
+
);
|
| 295 |
+
});
|
| 296 |
+
ChartLegendContent.displayName = "ChartLegend";
|
| 297 |
+
|
| 298 |
+
// Helper to extract item config from a payload.
|
| 299 |
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
| 300 |
+
if (typeof payload !== "object" || payload === null) {
|
| 301 |
+
return undefined;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
const payloadPayload =
|
| 305 |
+
"payload" in payload && typeof payload.payload === "object" && payload.payload !== null
|
| 306 |
+
? payload.payload
|
| 307 |
+
: undefined;
|
| 308 |
+
|
| 309 |
+
let configLabelKey: string = key;
|
| 310 |
+
|
| 311 |
+
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
|
| 312 |
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
| 313 |
+
} else if (
|
| 314 |
+
payloadPayload &&
|
| 315 |
+
key in payloadPayload &&
|
| 316 |
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
| 317 |
+
) {
|
| 318 |
+
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
export {
|
| 325 |
+
ChartContainer,
|
| 326 |
+
ChartTooltip,
|
| 327 |
+
ChartTooltipContent,
|
| 328 |
+
ChartLegend,
|
| 329 |
+
ChartLegendContent,
|
| 330 |
+
ChartStyle,
|
| 331 |
+
};
|
src/components/ui/checkbox.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
| 3 |
+
import { Check } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const Checkbox = React.forwardRef<
|
| 8 |
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
| 9 |
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
| 10 |
+
>(({ className, ...props }, ref) => (
|
| 11 |
+
<CheckboxPrimitive.Root
|
| 12 |
+
ref={ref}
|
| 13 |
+
className={cn(
|
| 14 |
+
"grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
| 15 |
+
className,
|
| 16 |
+
)}
|
| 17 |
+
{...props}
|
| 18 |
+
>
|
| 19 |
+
<CheckboxPrimitive.Indicator className={cn("grid place-content-center text-current")}>
|
| 20 |
+
<Check className="h-4 w-4" />
|
| 21 |
+
</CheckboxPrimitive.Indicator>
|
| 22 |
+
</CheckboxPrimitive.Root>
|
| 23 |
+
));
|
| 24 |
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
| 25 |
+
|
| 26 |
+
export { Checkbox };
|
src/components/ui/collapsible.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
| 4 |
+
|
| 5 |
+
const Collapsible = CollapsiblePrimitive.Root;
|
| 6 |
+
|
| 7 |
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
| 8 |
+
|
| 9 |
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
| 10 |
+
|
| 11 |
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
src/components/ui/command.tsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import { type DialogProps } from "@radix-ui/react-dialog";
|
| 5 |
+
import { Command as CommandPrimitive } from "cmdk";
|
| 6 |
+
import { Search } from "lucide-react";
|
| 7 |
+
|
| 8 |
+
import { cn } from "@/lib/utils";
|
| 9 |
+
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
| 10 |
+
|
| 11 |
+
const Command = React.forwardRef<
|
| 12 |
+
React.ElementRef<typeof CommandPrimitive>,
|
| 13 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
| 14 |
+
>(({ className, ...props }, ref) => (
|
| 15 |
+
<CommandPrimitive
|
| 16 |
+
ref={ref}
|
| 17 |
+
className={cn(
|
| 18 |
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
| 19 |
+
className,
|
| 20 |
+
)}
|
| 21 |
+
{...props}
|
| 22 |
+
/>
|
| 23 |
+
));
|
| 24 |
+
Command.displayName = CommandPrimitive.displayName;
|
| 25 |
+
|
| 26 |
+
const CommandDialog = ({ children, ...props }: DialogProps) => {
|
| 27 |
+
return (
|
| 28 |
+
<Dialog {...props}>
|
| 29 |
+
<DialogContent className="overflow-hidden p-0">
|
| 30 |
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
| 31 |
+
{children}
|
| 32 |
+
</Command>
|
| 33 |
+
</DialogContent>
|
| 34 |
+
</Dialog>
|
| 35 |
+
);
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
const CommandInput = React.forwardRef<
|
| 39 |
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
| 40 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
| 41 |
+
>(({ className, ...props }, ref) => (
|
| 42 |
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
| 43 |
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
| 44 |
+
<CommandPrimitive.Input
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
| 48 |
+
className,
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
</div>
|
| 53 |
+
));
|
| 54 |
+
|
| 55 |
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
| 56 |
+
|
| 57 |
+
const CommandList = React.forwardRef<
|
| 58 |
+
React.ElementRef<typeof CommandPrimitive.List>,
|
| 59 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
| 60 |
+
>(({ className, ...props }, ref) => (
|
| 61 |
+
<CommandPrimitive.List
|
| 62 |
+
ref={ref}
|
| 63 |
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
| 64 |
+
{...props}
|
| 65 |
+
/>
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
| 69 |
+
|
| 70 |
+
const CommandEmpty = React.forwardRef<
|
| 71 |
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
| 72 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
| 73 |
+
>((props, ref) => (
|
| 74 |
+
<CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
|
| 75 |
+
));
|
| 76 |
+
|
| 77 |
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
| 78 |
+
|
| 79 |
+
const CommandGroup = React.forwardRef<
|
| 80 |
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
| 81 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
| 82 |
+
>(({ className, ...props }, ref) => (
|
| 83 |
+
<CommandPrimitive.Group
|
| 84 |
+
ref={ref}
|
| 85 |
+
className={cn(
|
| 86 |
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
| 87 |
+
className,
|
| 88 |
+
)}
|
| 89 |
+
{...props}
|
| 90 |
+
/>
|
| 91 |
+
));
|
| 92 |
+
|
| 93 |
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
| 94 |
+
|
| 95 |
+
const CommandSeparator = React.forwardRef<
|
| 96 |
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
| 97 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
| 98 |
+
>(({ className, ...props }, ref) => (
|
| 99 |
+
<CommandPrimitive.Separator
|
| 100 |
+
ref={ref}
|
| 101 |
+
className={cn("-mx-1 h-px bg-border", className)}
|
| 102 |
+
{...props}
|
| 103 |
+
/>
|
| 104 |
+
));
|
| 105 |
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
| 106 |
+
|
| 107 |
+
const CommandItem = React.forwardRef<
|
| 108 |
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
| 109 |
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
| 110 |
+
>(({ className, ...props }, ref) => (
|
| 111 |
+
<CommandPrimitive.Item
|
| 112 |
+
ref={ref}
|
| 113 |
+
className={cn(
|
| 114 |
+
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
| 115 |
+
className,
|
| 116 |
+
)}
|
| 117 |
+
{...props}
|
| 118 |
+
/>
|
| 119 |
+
));
|
| 120 |
+
|
| 121 |
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
| 122 |
+
|
| 123 |
+
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 124 |
+
return (
|
| 125 |
+
<span
|
| 126 |
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
| 127 |
+
{...props}
|
| 128 |
+
/>
|
| 129 |
+
);
|
| 130 |
+
};
|
| 131 |
+
CommandShortcut.displayName = "CommandShortcut";
|
| 132 |
+
|
| 133 |
+
export {
|
| 134 |
+
Command,
|
| 135 |
+
CommandDialog,
|
| 136 |
+
CommandInput,
|
| 137 |
+
CommandList,
|
| 138 |
+
CommandEmpty,
|
| 139 |
+
CommandGroup,
|
| 140 |
+
CommandItem,
|
| 141 |
+
CommandShortcut,
|
| 142 |
+
CommandSeparator,
|
| 143 |
+
};
|
src/components/ui/context-menu.tsx
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
| 3 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const ContextMenu = ContextMenuPrimitive.Root;
|
| 8 |
+
|
| 9 |
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
| 10 |
+
|
| 11 |
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
| 12 |
+
|
| 13 |
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
| 14 |
+
|
| 15 |
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
| 16 |
+
|
| 17 |
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
| 18 |
+
|
| 19 |
+
const ContextMenuSubTrigger = React.forwardRef<
|
| 20 |
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
| 21 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
| 22 |
+
inset?: boolean;
|
| 23 |
+
}
|
| 24 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 25 |
+
<ContextMenuPrimitive.SubTrigger
|
| 26 |
+
ref={ref}
|
| 27 |
+
className={cn(
|
| 28 |
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
| 29 |
+
inset && "pl-8",
|
| 30 |
+
className,
|
| 31 |
+
)}
|
| 32 |
+
{...props}
|
| 33 |
+
>
|
| 34 |
+
{children}
|
| 35 |
+
<ChevronRight className="ml-auto h-4 w-4" />
|
| 36 |
+
</ContextMenuPrimitive.SubTrigger>
|
| 37 |
+
));
|
| 38 |
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
| 39 |
+
|
| 40 |
+
const ContextMenuSubContent = React.forwardRef<
|
| 41 |
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
| 42 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
| 43 |
+
>(({ className, ...props }, ref) => (
|
| 44 |
+
<ContextMenuPrimitive.SubContent
|
| 45 |
+
ref={ref}
|
| 46 |
+
className={cn(
|
| 47 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-context-menu-content-transform-origin)",
|
| 48 |
+
className,
|
| 49 |
+
)}
|
| 50 |
+
{...props}
|
| 51 |
+
/>
|
| 52 |
+
));
|
| 53 |
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
| 54 |
+
|
| 55 |
+
const ContextMenuContent = React.forwardRef<
|
| 56 |
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
| 57 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
| 58 |
+
>(({ className, ...props }, ref) => (
|
| 59 |
+
<ContextMenuPrimitive.Portal>
|
| 60 |
+
<ContextMenuPrimitive.Content
|
| 61 |
+
ref={ref}
|
| 62 |
+
className={cn(
|
| 63 |
+
"z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-context-menu-content-transform-origin)",
|
| 64 |
+
className,
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
/>
|
| 68 |
+
</ContextMenuPrimitive.Portal>
|
| 69 |
+
));
|
| 70 |
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
| 71 |
+
|
| 72 |
+
const ContextMenuItem = React.forwardRef<
|
| 73 |
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
| 74 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
| 75 |
+
inset?: boolean;
|
| 76 |
+
}
|
| 77 |
+
>(({ className, inset, ...props }, ref) => (
|
| 78 |
+
<ContextMenuPrimitive.Item
|
| 79 |
+
ref={ref}
|
| 80 |
+
className={cn(
|
| 81 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 82 |
+
inset && "pl-8",
|
| 83 |
+
className,
|
| 84 |
+
)}
|
| 85 |
+
{...props}
|
| 86 |
+
/>
|
| 87 |
+
));
|
| 88 |
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
| 89 |
+
|
| 90 |
+
const ContextMenuCheckboxItem = React.forwardRef<
|
| 91 |
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
| 92 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
| 93 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 94 |
+
<ContextMenuPrimitive.CheckboxItem
|
| 95 |
+
ref={ref}
|
| 96 |
+
className={cn(
|
| 97 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 98 |
+
className,
|
| 99 |
+
)}
|
| 100 |
+
checked={checked}
|
| 101 |
+
{...props}
|
| 102 |
+
>
|
| 103 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 104 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 105 |
+
<Check className="h-4 w-4" />
|
| 106 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 107 |
+
</span>
|
| 108 |
+
{children}
|
| 109 |
+
</ContextMenuPrimitive.CheckboxItem>
|
| 110 |
+
));
|
| 111 |
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
| 112 |
+
|
| 113 |
+
const ContextMenuRadioItem = React.forwardRef<
|
| 114 |
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
| 115 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
| 116 |
+
>(({ className, children, ...props }, ref) => (
|
| 117 |
+
<ContextMenuPrimitive.RadioItem
|
| 118 |
+
ref={ref}
|
| 119 |
+
className={cn(
|
| 120 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 121 |
+
className,
|
| 122 |
+
)}
|
| 123 |
+
{...props}
|
| 124 |
+
>
|
| 125 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 126 |
+
<ContextMenuPrimitive.ItemIndicator>
|
| 127 |
+
<Circle className="h-4 w-4 fill-current" />
|
| 128 |
+
</ContextMenuPrimitive.ItemIndicator>
|
| 129 |
+
</span>
|
| 130 |
+
{children}
|
| 131 |
+
</ContextMenuPrimitive.RadioItem>
|
| 132 |
+
));
|
| 133 |
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
| 134 |
+
|
| 135 |
+
const ContextMenuLabel = React.forwardRef<
|
| 136 |
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
| 137 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
| 138 |
+
inset?: boolean;
|
| 139 |
+
}
|
| 140 |
+
>(({ className, inset, ...props }, ref) => (
|
| 141 |
+
<ContextMenuPrimitive.Label
|
| 142 |
+
ref={ref}
|
| 143 |
+
className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
|
| 144 |
+
{...props}
|
| 145 |
+
/>
|
| 146 |
+
));
|
| 147 |
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
| 148 |
+
|
| 149 |
+
const ContextMenuSeparator = React.forwardRef<
|
| 150 |
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
| 151 |
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
| 152 |
+
>(({ className, ...props }, ref) => (
|
| 153 |
+
<ContextMenuPrimitive.Separator
|
| 154 |
+
ref={ref}
|
| 155 |
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
| 156 |
+
{...props}
|
| 157 |
+
/>
|
| 158 |
+
));
|
| 159 |
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
| 160 |
+
|
| 161 |
+
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 162 |
+
return (
|
| 163 |
+
<span
|
| 164 |
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
| 165 |
+
{...props}
|
| 166 |
+
/>
|
| 167 |
+
);
|
| 168 |
+
};
|
| 169 |
+
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
| 170 |
+
|
| 171 |
+
export {
|
| 172 |
+
ContextMenu,
|
| 173 |
+
ContextMenuTrigger,
|
| 174 |
+
ContextMenuContent,
|
| 175 |
+
ContextMenuItem,
|
| 176 |
+
ContextMenuCheckboxItem,
|
| 177 |
+
ContextMenuRadioItem,
|
| 178 |
+
ContextMenuLabel,
|
| 179 |
+
ContextMenuSeparator,
|
| 180 |
+
ContextMenuShortcut,
|
| 181 |
+
ContextMenuGroup,
|
| 182 |
+
ContextMenuPortal,
|
| 183 |
+
ContextMenuSub,
|
| 184 |
+
ContextMenuSubContent,
|
| 185 |
+
ContextMenuSubTrigger,
|
| 186 |
+
ContextMenuRadioGroup,
|
| 187 |
+
};
|
src/components/ui/dialog.tsx
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
| 5 |
+
import { X } from "lucide-react";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
|
| 9 |
+
const Dialog = DialogPrimitive.Root;
|
| 10 |
+
|
| 11 |
+
const DialogTrigger = DialogPrimitive.Trigger;
|
| 12 |
+
|
| 13 |
+
const DialogPortal = DialogPrimitive.Portal;
|
| 14 |
+
|
| 15 |
+
const DialogClose = DialogPrimitive.Close;
|
| 16 |
+
|
| 17 |
+
const DialogOverlay = React.forwardRef<
|
| 18 |
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
| 19 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
| 20 |
+
>(({ className, ...props }, ref) => (
|
| 21 |
+
<DialogPrimitive.Overlay
|
| 22 |
+
ref={ref}
|
| 23 |
+
className={cn(
|
| 24 |
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
| 25 |
+
className,
|
| 26 |
+
)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
));
|
| 30 |
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
| 31 |
+
|
| 32 |
+
const DialogContent = React.forwardRef<
|
| 33 |
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
| 34 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
| 35 |
+
>(({ className, children, ...props }, ref) => (
|
| 36 |
+
<DialogPortal>
|
| 37 |
+
<DialogOverlay />
|
| 38 |
+
<DialogPrimitive.Content
|
| 39 |
+
ref={ref}
|
| 40 |
+
className={cn(
|
| 41 |
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
>
|
| 46 |
+
{children}
|
| 47 |
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background cursor-pointer transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
| 48 |
+
<X className="h-4 w-4" />
|
| 49 |
+
<span className="sr-only">Close</span>
|
| 50 |
+
</DialogPrimitive.Close>
|
| 51 |
+
</DialogPrimitive.Content>
|
| 52 |
+
</DialogPortal>
|
| 53 |
+
));
|
| 54 |
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
| 55 |
+
|
| 56 |
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 57 |
+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
| 58 |
+
);
|
| 59 |
+
DialogHeader.displayName = "DialogHeader";
|
| 60 |
+
|
| 61 |
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 62 |
+
<div
|
| 63 |
+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
| 64 |
+
{...props}
|
| 65 |
+
/>
|
| 66 |
+
);
|
| 67 |
+
DialogFooter.displayName = "DialogFooter";
|
| 68 |
+
|
| 69 |
+
const DialogTitle = React.forwardRef<
|
| 70 |
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
| 71 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
| 72 |
+
>(({ className, ...props }, ref) => (
|
| 73 |
+
<DialogPrimitive.Title
|
| 74 |
+
ref={ref}
|
| 75 |
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
| 76 |
+
{...props}
|
| 77 |
+
/>
|
| 78 |
+
));
|
| 79 |
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
| 80 |
+
|
| 81 |
+
const DialogDescription = React.forwardRef<
|
| 82 |
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
| 83 |
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
| 84 |
+
>(({ className, ...props }, ref) => (
|
| 85 |
+
<DialogPrimitive.Description
|
| 86 |
+
ref={ref}
|
| 87 |
+
className={cn("text-sm text-muted-foreground", className)}
|
| 88 |
+
{...props}
|
| 89 |
+
/>
|
| 90 |
+
));
|
| 91 |
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
| 92 |
+
|
| 93 |
+
export {
|
| 94 |
+
Dialog,
|
| 95 |
+
DialogPortal,
|
| 96 |
+
DialogOverlay,
|
| 97 |
+
DialogTrigger,
|
| 98 |
+
DialogClose,
|
| 99 |
+
DialogContent,
|
| 100 |
+
DialogHeader,
|
| 101 |
+
DialogFooter,
|
| 102 |
+
DialogTitle,
|
| 103 |
+
DialogDescription,
|
| 104 |
+
};
|
src/components/ui/drawer.tsx
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { Drawer as DrawerPrimitive } from "vaul";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const Drawer = ({
|
| 7 |
+
shouldScaleBackground = true,
|
| 8 |
+
...props
|
| 9 |
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
| 10 |
+
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
| 11 |
+
);
|
| 12 |
+
Drawer.displayName = "Drawer";
|
| 13 |
+
|
| 14 |
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
| 15 |
+
|
| 16 |
+
const DrawerPortal = DrawerPrimitive.Portal;
|
| 17 |
+
|
| 18 |
+
const DrawerClose = DrawerPrimitive.Close;
|
| 19 |
+
|
| 20 |
+
const DrawerOverlay = React.forwardRef<
|
| 21 |
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
| 22 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
| 23 |
+
>(({ className, ...props }, ref) => (
|
| 24 |
+
<DrawerPrimitive.Overlay
|
| 25 |
+
ref={ref}
|
| 26 |
+
className={cn("fixed inset-0 z-50 bg-black/80", className)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
));
|
| 30 |
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
| 31 |
+
|
| 32 |
+
const DrawerContent = React.forwardRef<
|
| 33 |
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
| 34 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
| 35 |
+
>(({ className, children, ...props }, ref) => (
|
| 36 |
+
<DrawerPortal>
|
| 37 |
+
<DrawerOverlay />
|
| 38 |
+
<DrawerPrimitive.Content
|
| 39 |
+
ref={ref}
|
| 40 |
+
className={cn(
|
| 41 |
+
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
>
|
| 46 |
+
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
| 47 |
+
{children}
|
| 48 |
+
</DrawerPrimitive.Content>
|
| 49 |
+
</DrawerPortal>
|
| 50 |
+
));
|
| 51 |
+
DrawerContent.displayName = "DrawerContent";
|
| 52 |
+
|
| 53 |
+
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 54 |
+
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
| 55 |
+
);
|
| 56 |
+
DrawerHeader.displayName = "DrawerHeader";
|
| 57 |
+
|
| 58 |
+
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
| 59 |
+
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
| 60 |
+
);
|
| 61 |
+
DrawerFooter.displayName = "DrawerFooter";
|
| 62 |
+
|
| 63 |
+
const DrawerTitle = React.forwardRef<
|
| 64 |
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
| 65 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
| 66 |
+
>(({ className, ...props }, ref) => (
|
| 67 |
+
<DrawerPrimitive.Title
|
| 68 |
+
ref={ref}
|
| 69 |
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
| 70 |
+
{...props}
|
| 71 |
+
/>
|
| 72 |
+
));
|
| 73 |
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
| 74 |
+
|
| 75 |
+
const DrawerDescription = React.forwardRef<
|
| 76 |
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
| 77 |
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
| 78 |
+
>(({ className, ...props }, ref) => (
|
| 79 |
+
<DrawerPrimitive.Description
|
| 80 |
+
ref={ref}
|
| 81 |
+
className={cn("text-sm text-muted-foreground", className)}
|
| 82 |
+
{...props}
|
| 83 |
+
/>
|
| 84 |
+
));
|
| 85 |
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
| 86 |
+
|
| 87 |
+
export {
|
| 88 |
+
Drawer,
|
| 89 |
+
DrawerPortal,
|
| 90 |
+
DrawerOverlay,
|
| 91 |
+
DrawerTrigger,
|
| 92 |
+
DrawerClose,
|
| 93 |
+
DrawerContent,
|
| 94 |
+
DrawerHeader,
|
| 95 |
+
DrawerFooter,
|
| 96 |
+
DrawerTitle,
|
| 97 |
+
DrawerDescription,
|
| 98 |
+
};
|
src/components/ui/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
| 5 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
|
| 9 |
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
| 10 |
+
|
| 11 |
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
| 12 |
+
|
| 13 |
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
| 14 |
+
|
| 15 |
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
| 16 |
+
|
| 17 |
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
| 18 |
+
|
| 19 |
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
| 20 |
+
|
| 21 |
+
const DropdownMenuSubTrigger = React.forwardRef<
|
| 22 |
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
| 23 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 24 |
+
inset?: boolean;
|
| 25 |
+
}
|
| 26 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 27 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 28 |
+
ref={ref}
|
| 29 |
+
className={cn(
|
| 30 |
+
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
| 31 |
+
inset && "pl-8",
|
| 32 |
+
className,
|
| 33 |
+
)}
|
| 34 |
+
{...props}
|
| 35 |
+
>
|
| 36 |
+
{children}
|
| 37 |
+
<ChevronRight className="ml-auto" />
|
| 38 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 39 |
+
));
|
| 40 |
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
| 41 |
+
|
| 42 |
+
const DropdownMenuSubContent = React.forwardRef<
|
| 43 |
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
| 44 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
| 45 |
+
>(({ className, ...props }, ref) => (
|
| 46 |
+
<DropdownMenuPrimitive.SubContent
|
| 47 |
+
ref={ref}
|
| 48 |
+
className={cn(
|
| 49 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin)",
|
| 50 |
+
className,
|
| 51 |
+
)}
|
| 52 |
+
{...props}
|
| 53 |
+
/>
|
| 54 |
+
));
|
| 55 |
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
| 56 |
+
|
| 57 |
+
const DropdownMenuContent = React.forwardRef<
|
| 58 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
| 59 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
| 60 |
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
| 61 |
+
<DropdownMenuPrimitive.Portal>
|
| 62 |
+
<DropdownMenuPrimitive.Content
|
| 63 |
+
ref={ref}
|
| 64 |
+
sideOffset={sideOffset}
|
| 65 |
+
className={cn(
|
| 66 |
+
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
| 67 |
+
"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 origin-(--radix-dropdown-menu-content-transform-origin)",
|
| 68 |
+
className,
|
| 69 |
+
)}
|
| 70 |
+
{...props}
|
| 71 |
+
/>
|
| 72 |
+
</DropdownMenuPrimitive.Portal>
|
| 73 |
+
));
|
| 74 |
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
| 75 |
+
|
| 76 |
+
const DropdownMenuItem = React.forwardRef<
|
| 77 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
| 78 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
| 79 |
+
inset?: boolean;
|
| 80 |
+
}
|
| 81 |
+
>(({ className, inset, ...props }, ref) => (
|
| 82 |
+
<DropdownMenuPrimitive.Item
|
| 83 |
+
ref={ref}
|
| 84 |
+
className={cn(
|
| 85 |
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
| 86 |
+
inset && "pl-8",
|
| 87 |
+
className,
|
| 88 |
+
)}
|
| 89 |
+
{...props}
|
| 90 |
+
/>
|
| 91 |
+
));
|
| 92 |
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
| 93 |
+
|
| 94 |
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
| 95 |
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
| 96 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
| 97 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 98 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 99 |
+
ref={ref}
|
| 100 |
+
className={cn(
|
| 101 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 102 |
+
className,
|
| 103 |
+
)}
|
| 104 |
+
checked={checked}
|
| 105 |
+
{...props}
|
| 106 |
+
>
|
| 107 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 108 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 109 |
+
<Check className="h-4 w-4" />
|
| 110 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 111 |
+
</span>
|
| 112 |
+
{children}
|
| 113 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 114 |
+
));
|
| 115 |
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
| 116 |
+
|
| 117 |
+
const DropdownMenuRadioItem = React.forwardRef<
|
| 118 |
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
| 119 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
| 120 |
+
>(({ className, children, ...props }, ref) => (
|
| 121 |
+
<DropdownMenuPrimitive.RadioItem
|
| 122 |
+
ref={ref}
|
| 123 |
+
className={cn(
|
| 124 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 125 |
+
className,
|
| 126 |
+
)}
|
| 127 |
+
{...props}
|
| 128 |
+
>
|
| 129 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 130 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 131 |
+
<Circle className="h-2 w-2 fill-current" />
|
| 132 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 133 |
+
</span>
|
| 134 |
+
{children}
|
| 135 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 136 |
+
));
|
| 137 |
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
| 138 |
+
|
| 139 |
+
const DropdownMenuLabel = React.forwardRef<
|
| 140 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
| 141 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
| 142 |
+
inset?: boolean;
|
| 143 |
+
}
|
| 144 |
+
>(({ className, inset, ...props }, ref) => (
|
| 145 |
+
<DropdownMenuPrimitive.Label
|
| 146 |
+
ref={ref}
|
| 147 |
+
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
| 148 |
+
{...props}
|
| 149 |
+
/>
|
| 150 |
+
));
|
| 151 |
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
| 152 |
+
|
| 153 |
+
const DropdownMenuSeparator = React.forwardRef<
|
| 154 |
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
| 155 |
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
| 156 |
+
>(({ className, ...props }, ref) => (
|
| 157 |
+
<DropdownMenuPrimitive.Separator
|
| 158 |
+
ref={ref}
|
| 159 |
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
| 160 |
+
{...props}
|
| 161 |
+
/>
|
| 162 |
+
));
|
| 163 |
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
| 164 |
+
|
| 165 |
+
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 166 |
+
return (
|
| 167 |
+
<span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
|
| 168 |
+
);
|
| 169 |
+
};
|
| 170 |
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
| 171 |
+
|
| 172 |
+
export {
|
| 173 |
+
DropdownMenu,
|
| 174 |
+
DropdownMenuTrigger,
|
| 175 |
+
DropdownMenuContent,
|
| 176 |
+
DropdownMenuItem,
|
| 177 |
+
DropdownMenuCheckboxItem,
|
| 178 |
+
DropdownMenuRadioItem,
|
| 179 |
+
DropdownMenuLabel,
|
| 180 |
+
DropdownMenuSeparator,
|
| 181 |
+
DropdownMenuShortcut,
|
| 182 |
+
DropdownMenuGroup,
|
| 183 |
+
DropdownMenuPortal,
|
| 184 |
+
DropdownMenuSub,
|
| 185 |
+
DropdownMenuSubContent,
|
| 186 |
+
DropdownMenuSubTrigger,
|
| 187 |
+
DropdownMenuRadioGroup,
|
| 188 |
+
};
|
src/components/ui/form.tsx
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
| 3 |
+
import { Slot } from "@radix-ui/react-slot";
|
| 4 |
+
import {
|
| 5 |
+
Controller,
|
| 6 |
+
FormProvider,
|
| 7 |
+
useFormContext,
|
| 8 |
+
type ControllerProps,
|
| 9 |
+
type FieldPath,
|
| 10 |
+
type FieldValues,
|
| 11 |
+
} from "react-hook-form";
|
| 12 |
+
|
| 13 |
+
import { cn } from "@/lib/utils";
|
| 14 |
+
import { Label } from "@/components/ui/label";
|
| 15 |
+
|
| 16 |
+
const Form = FormProvider;
|
| 17 |
+
|
| 18 |
+
type FormFieldContextValue<
|
| 19 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 20 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 21 |
+
> = {
|
| 22 |
+
name: TName;
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null);
|
| 26 |
+
|
| 27 |
+
const FormField = <
|
| 28 |
+
TFieldValues extends FieldValues = FieldValues,
|
| 29 |
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
| 30 |
+
>({
|
| 31 |
+
...props
|
| 32 |
+
}: ControllerProps<TFieldValues, TName>) => {
|
| 33 |
+
return (
|
| 34 |
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
| 35 |
+
<Controller {...props} />
|
| 36 |
+
</FormFieldContext.Provider>
|
| 37 |
+
);
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
const useFormField = () => {
|
| 41 |
+
const fieldContext = React.useContext(FormFieldContext);
|
| 42 |
+
const itemContext = React.useContext(FormItemContext);
|
| 43 |
+
const { getFieldState, formState } = useFormContext();
|
| 44 |
+
|
| 45 |
+
if (!fieldContext) {
|
| 46 |
+
throw new Error("useFormField should be used within <FormField>");
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (!itemContext) {
|
| 50 |
+
throw new Error("useFormField should be used within <FormItem>");
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
const fieldState = getFieldState(fieldContext.name, formState);
|
| 54 |
+
|
| 55 |
+
const { id } = itemContext;
|
| 56 |
+
|
| 57 |
+
return {
|
| 58 |
+
id,
|
| 59 |
+
name: fieldContext.name,
|
| 60 |
+
formItemId: `${id}-form-item`,
|
| 61 |
+
formDescriptionId: `${id}-form-item-description`,
|
| 62 |
+
formMessageId: `${id}-form-item-message`,
|
| 63 |
+
...fieldState,
|
| 64 |
+
};
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
type FormItemContextValue = {
|
| 68 |
+
id: string;
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
const FormItemContext = React.createContext<FormItemContextValue | null>(null);
|
| 72 |
+
|
| 73 |
+
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
| 74 |
+
({ className, ...props }, ref) => {
|
| 75 |
+
const id = React.useId();
|
| 76 |
+
|
| 77 |
+
return (
|
| 78 |
+
<FormItemContext.Provider value={{ id }}>
|
| 79 |
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
| 80 |
+
</FormItemContext.Provider>
|
| 81 |
+
);
|
| 82 |
+
},
|
| 83 |
+
);
|
| 84 |
+
FormItem.displayName = "FormItem";
|
| 85 |
+
|
| 86 |
+
const FormLabel = React.forwardRef<
|
| 87 |
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
| 88 |
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
| 89 |
+
>(({ className, ...props }, ref) => {
|
| 90 |
+
const { error, formItemId } = useFormField();
|
| 91 |
+
|
| 92 |
+
return (
|
| 93 |
+
<Label
|
| 94 |
+
ref={ref}
|
| 95 |
+
className={cn(error && "text-destructive", className)}
|
| 96 |
+
htmlFor={formItemId}
|
| 97 |
+
{...props}
|
| 98 |
+
/>
|
| 99 |
+
);
|
| 100 |
+
});
|
| 101 |
+
FormLabel.displayName = "FormLabel";
|
| 102 |
+
|
| 103 |
+
const FormControl = React.forwardRef<
|
| 104 |
+
React.ElementRef<typeof Slot>,
|
| 105 |
+
React.ComponentPropsWithoutRef<typeof Slot>
|
| 106 |
+
>(({ ...props }, ref) => {
|
| 107 |
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
| 108 |
+
|
| 109 |
+
return (
|
| 110 |
+
<Slot
|
| 111 |
+
ref={ref}
|
| 112 |
+
id={formItemId}
|
| 113 |
+
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
|
| 114 |
+
aria-invalid={!!error}
|
| 115 |
+
{...props}
|
| 116 |
+
/>
|
| 117 |
+
);
|
| 118 |
+
});
|
| 119 |
+
FormControl.displayName = "FormControl";
|
| 120 |
+
|
| 121 |
+
const FormDescription = React.forwardRef<
|
| 122 |
+
HTMLParagraphElement,
|
| 123 |
+
React.HTMLAttributes<HTMLParagraphElement>
|
| 124 |
+
>(({ className, ...props }, ref) => {
|
| 125 |
+
const { formDescriptionId } = useFormField();
|
| 126 |
+
|
| 127 |
+
return (
|
| 128 |
+
<p
|
| 129 |
+
ref={ref}
|
| 130 |
+
id={formDescriptionId}
|
| 131 |
+
className={cn("text-[0.8rem] text-muted-foreground", className)}
|
| 132 |
+
{...props}
|
| 133 |
+
/>
|
| 134 |
+
);
|
| 135 |
+
});
|
| 136 |
+
FormDescription.displayName = "FormDescription";
|
| 137 |
+
|
| 138 |
+
const FormMessage = React.forwardRef<
|
| 139 |
+
HTMLParagraphElement,
|
| 140 |
+
React.HTMLAttributes<HTMLParagraphElement>
|
| 141 |
+
>(({ className, children, ...props }, ref) => {
|
| 142 |
+
const { error, formMessageId } = useFormField();
|
| 143 |
+
const body = error ? String(error?.message ?? "") : children;
|
| 144 |
+
|
| 145 |
+
if (!body) {
|
| 146 |
+
return null;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
return (
|
| 150 |
+
<p
|
| 151 |
+
ref={ref}
|
| 152 |
+
id={formMessageId}
|
| 153 |
+
className={cn("text-[0.8rem] font-medium text-destructive", className)}
|
| 154 |
+
{...props}
|
| 155 |
+
>
|
| 156 |
+
{body}
|
| 157 |
+
</p>
|
| 158 |
+
);
|
| 159 |
+
});
|
| 160 |
+
FormMessage.displayName = "FormMessage";
|
| 161 |
+
|
| 162 |
+
export {
|
| 163 |
+
useFormField,
|
| 164 |
+
Form,
|
| 165 |
+
FormItem,
|
| 166 |
+
FormLabel,
|
| 167 |
+
FormControl,
|
| 168 |
+
FormDescription,
|
| 169 |
+
FormMessage,
|
| 170 |
+
FormField,
|
| 171 |
+
};
|
src/components/ui/hover-card.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
const HoverCard = HoverCardPrimitive.Root;
|
| 7 |
+
|
| 8 |
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
| 9 |
+
|
| 10 |
+
const HoverCardContent = React.forwardRef<
|
| 11 |
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
| 12 |
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
| 13 |
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
| 14 |
+
<HoverCardPrimitive.Content
|
| 15 |
+
ref={ref}
|
| 16 |
+
align={align}
|
| 17 |
+
sideOffset={sideOffset}
|
| 18 |
+
className={cn(
|
| 19 |
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-hover-card-content-transform-origin)",
|
| 20 |
+
className,
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
/>
|
| 24 |
+
));
|
| 25 |
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
| 26 |
+
|
| 27 |
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
src/components/ui/input-otp.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { OTPInput, OTPInputContext } from "input-otp";
|
| 3 |
+
import { Minus } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const InputOTP = React.forwardRef<
|
| 8 |
+
React.ElementRef<typeof OTPInput>,
|
| 9 |
+
React.ComponentPropsWithoutRef<typeof OTPInput>
|
| 10 |
+
>(({ className, containerClassName, ...props }, ref) => (
|
| 11 |
+
<OTPInput
|
| 12 |
+
ref={ref}
|
| 13 |
+
containerClassName={cn(
|
| 14 |
+
"flex items-center gap-2 has-[:disabled]:opacity-50",
|
| 15 |
+
containerClassName,
|
| 16 |
+
)}
|
| 17 |
+
className={cn("disabled:cursor-not-allowed", className)}
|
| 18 |
+
{...props}
|
| 19 |
+
/>
|
| 20 |
+
));
|
| 21 |
+
InputOTP.displayName = "InputOTP";
|
| 22 |
+
|
| 23 |
+
const InputOTPGroup = React.forwardRef<
|
| 24 |
+
React.ElementRef<"div">,
|
| 25 |
+
React.ComponentPropsWithoutRef<"div">
|
| 26 |
+
>(({ className, ...props }, ref) => (
|
| 27 |
+
<div ref={ref} className={cn("flex items-center", className)} {...props} />
|
| 28 |
+
));
|
| 29 |
+
InputOTPGroup.displayName = "InputOTPGroup";
|
| 30 |
+
|
| 31 |
+
const InputOTPSlot = React.forwardRef<
|
| 32 |
+
React.ElementRef<"div">,
|
| 33 |
+
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
| 34 |
+
>(({ index, className, ...props }, ref) => {
|
| 35 |
+
const inputOTPContext = React.useContext(OTPInputContext);
|
| 36 |
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<div
|
| 40 |
+
ref={ref}
|
| 41 |
+
className={cn(
|
| 42 |
+
"relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
|
| 43 |
+
isActive && "z-10 ring-1 ring-ring",
|
| 44 |
+
className,
|
| 45 |
+
)}
|
| 46 |
+
{...props}
|
| 47 |
+
>
|
| 48 |
+
{char}
|
| 49 |
+
{hasFakeCaret && (
|
| 50 |
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 51 |
+
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
|
| 52 |
+
</div>
|
| 53 |
+
)}
|
| 54 |
+
</div>
|
| 55 |
+
);
|
| 56 |
+
});
|
| 57 |
+
InputOTPSlot.displayName = "InputOTPSlot";
|
| 58 |
+
|
| 59 |
+
const InputOTPSeparator = React.forwardRef<
|
| 60 |
+
React.ElementRef<"div">,
|
| 61 |
+
React.ComponentPropsWithoutRef<"div">
|
| 62 |
+
>(({ ...props }, ref) => (
|
| 63 |
+
<div ref={ref} role="separator" {...props}>
|
| 64 |
+
<Minus />
|
| 65 |
+
</div>
|
| 66 |
+
));
|
| 67 |
+
InputOTPSeparator.displayName = "InputOTPSeparator";
|
| 68 |
+
|
| 69 |
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
src/components/ui/input.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils";
|
| 4 |
+
|
| 5 |
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
| 6 |
+
({ className, type, ...props }, ref) => {
|
| 7 |
+
return (
|
| 8 |
+
<input
|
| 9 |
+
type={type}
|
| 10 |
+
className={cn(
|
| 11 |
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
| 12 |
+
className,
|
| 13 |
+
)}
|
| 14 |
+
ref={ref}
|
| 15 |
+
{...props}
|
| 16 |
+
/>
|
| 17 |
+
);
|
| 18 |
+
},
|
| 19 |
+
);
|
| 20 |
+
Input.displayName = "Input";
|
| 21 |
+
|
| 22 |
+
export { Input };
|
src/components/ui/label.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
| 5 |
+
import { cva, type VariantProps } from "class-variance-authority";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
|
| 9 |
+
const labelVariants = cva(
|
| 10 |
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
| 11 |
+
);
|
| 12 |
+
|
| 13 |
+
const Label = React.forwardRef<
|
| 14 |
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
| 15 |
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
| 16 |
+
>(({ className, ...props }, ref) => (
|
| 17 |
+
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
| 18 |
+
));
|
| 19 |
+
Label.displayName = LabelPrimitive.Root.displayName;
|
| 20 |
+
|
| 21 |
+
export { Label };
|
src/components/ui/menubar.tsx
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
| 3 |
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
function MenubarMenu({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
|
| 8 |
+
return <MenubarPrimitive.Menu {...props} />;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function MenubarGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Group>) {
|
| 12 |
+
return <MenubarPrimitive.Group {...props} />;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function MenubarPortal({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
|
| 16 |
+
return <MenubarPrimitive.Portal {...props} />;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function MenubarRadioGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
|
| 20 |
+
return <MenubarPrimitive.RadioGroup {...props} />;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function MenubarSub({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
|
| 24 |
+
return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
const Menubar = React.forwardRef<
|
| 28 |
+
React.ElementRef<typeof MenubarPrimitive.Root>,
|
| 29 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
| 30 |
+
>(({ className, ...props }, ref) => (
|
| 31 |
+
<MenubarPrimitive.Root
|
| 32 |
+
ref={ref}
|
| 33 |
+
className={cn(
|
| 34 |
+
"flex h-9 items-center space-x-1 rounded-md border bg-background p-1 shadow-sm",
|
| 35 |
+
className,
|
| 36 |
+
)}
|
| 37 |
+
{...props}
|
| 38 |
+
/>
|
| 39 |
+
));
|
| 40 |
+
Menubar.displayName = MenubarPrimitive.Root.displayName;
|
| 41 |
+
|
| 42 |
+
const MenubarTrigger = React.forwardRef<
|
| 43 |
+
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
| 44 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
| 45 |
+
>(({ className, ...props }, ref) => (
|
| 46 |
+
<MenubarPrimitive.Trigger
|
| 47 |
+
ref={ref}
|
| 48 |
+
className={cn(
|
| 49 |
+
"flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
| 50 |
+
className,
|
| 51 |
+
)}
|
| 52 |
+
{...props}
|
| 53 |
+
/>
|
| 54 |
+
));
|
| 55 |
+
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName;
|
| 56 |
+
|
| 57 |
+
const MenubarSubTrigger = React.forwardRef<
|
| 58 |
+
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
| 59 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
|
| 60 |
+
inset?: boolean;
|
| 61 |
+
}
|
| 62 |
+
>(({ className, inset, children, ...props }, ref) => (
|
| 63 |
+
<MenubarPrimitive.SubTrigger
|
| 64 |
+
ref={ref}
|
| 65 |
+
className={cn(
|
| 66 |
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
| 67 |
+
inset && "pl-8",
|
| 68 |
+
className,
|
| 69 |
+
)}
|
| 70 |
+
{...props}
|
| 71 |
+
>
|
| 72 |
+
{children}
|
| 73 |
+
<ChevronRight className="ml-auto h-4 w-4" />
|
| 74 |
+
</MenubarPrimitive.SubTrigger>
|
| 75 |
+
));
|
| 76 |
+
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName;
|
| 77 |
+
|
| 78 |
+
const MenubarSubContent = React.forwardRef<
|
| 79 |
+
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
| 80 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
| 81 |
+
>(({ className, ...props }, ref) => (
|
| 82 |
+
<MenubarPrimitive.SubContent
|
| 83 |
+
ref={ref}
|
| 84 |
+
className={cn(
|
| 85 |
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-menubar-content-transform-origin)",
|
| 86 |
+
className,
|
| 87 |
+
)}
|
| 88 |
+
{...props}
|
| 89 |
+
/>
|
| 90 |
+
));
|
| 91 |
+
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName;
|
| 92 |
+
|
| 93 |
+
const MenubarContent = React.forwardRef<
|
| 94 |
+
React.ElementRef<typeof MenubarPrimitive.Content>,
|
| 95 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
| 96 |
+
>(({ className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref) => (
|
| 97 |
+
<MenubarPrimitive.Portal>
|
| 98 |
+
<MenubarPrimitive.Content
|
| 99 |
+
ref={ref}
|
| 100 |
+
align={align}
|
| 101 |
+
alignOffset={alignOffset}
|
| 102 |
+
sideOffset={sideOffset}
|
| 103 |
+
className={cn(
|
| 104 |
+
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-menubar-content-transform-origin)",
|
| 105 |
+
className,
|
| 106 |
+
)}
|
| 107 |
+
{...props}
|
| 108 |
+
/>
|
| 109 |
+
</MenubarPrimitive.Portal>
|
| 110 |
+
));
|
| 111 |
+
MenubarContent.displayName = MenubarPrimitive.Content.displayName;
|
| 112 |
+
|
| 113 |
+
const MenubarItem = React.forwardRef<
|
| 114 |
+
React.ElementRef<typeof MenubarPrimitive.Item>,
|
| 115 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
|
| 116 |
+
inset?: boolean;
|
| 117 |
+
}
|
| 118 |
+
>(({ className, inset, ...props }, ref) => (
|
| 119 |
+
<MenubarPrimitive.Item
|
| 120 |
+
ref={ref}
|
| 121 |
+
className={cn(
|
| 122 |
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 123 |
+
inset && "pl-8",
|
| 124 |
+
className,
|
| 125 |
+
)}
|
| 126 |
+
{...props}
|
| 127 |
+
/>
|
| 128 |
+
));
|
| 129 |
+
MenubarItem.displayName = MenubarPrimitive.Item.displayName;
|
| 130 |
+
|
| 131 |
+
const MenubarCheckboxItem = React.forwardRef<
|
| 132 |
+
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
| 133 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
|
| 134 |
+
>(({ className, children, checked, ...props }, ref) => (
|
| 135 |
+
<MenubarPrimitive.CheckboxItem
|
| 136 |
+
ref={ref}
|
| 137 |
+
className={cn(
|
| 138 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 139 |
+
className,
|
| 140 |
+
)}
|
| 141 |
+
checked={checked}
|
| 142 |
+
{...props}
|
| 143 |
+
>
|
| 144 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 145 |
+
<MenubarPrimitive.ItemIndicator>
|
| 146 |
+
<Check className="h-4 w-4" />
|
| 147 |
+
</MenubarPrimitive.ItemIndicator>
|
| 148 |
+
</span>
|
| 149 |
+
{children}
|
| 150 |
+
</MenubarPrimitive.CheckboxItem>
|
| 151 |
+
));
|
| 152 |
+
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName;
|
| 153 |
+
|
| 154 |
+
const MenubarRadioItem = React.forwardRef<
|
| 155 |
+
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
| 156 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
|
| 157 |
+
>(({ className, children, ...props }, ref) => (
|
| 158 |
+
<MenubarPrimitive.RadioItem
|
| 159 |
+
ref={ref}
|
| 160 |
+
className={cn(
|
| 161 |
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
| 162 |
+
className,
|
| 163 |
+
)}
|
| 164 |
+
{...props}
|
| 165 |
+
>
|
| 166 |
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
| 167 |
+
<MenubarPrimitive.ItemIndicator>
|
| 168 |
+
<Circle className="h-4 w-4 fill-current" />
|
| 169 |
+
</MenubarPrimitive.ItemIndicator>
|
| 170 |
+
</span>
|
| 171 |
+
{children}
|
| 172 |
+
</MenubarPrimitive.RadioItem>
|
| 173 |
+
));
|
| 174 |
+
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName;
|
| 175 |
+
|
| 176 |
+
const MenubarLabel = React.forwardRef<
|
| 177 |
+
React.ElementRef<typeof MenubarPrimitive.Label>,
|
| 178 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
|
| 179 |
+
inset?: boolean;
|
| 180 |
+
}
|
| 181 |
+
>(({ className, inset, ...props }, ref) => (
|
| 182 |
+
<MenubarPrimitive.Label
|
| 183 |
+
ref={ref}
|
| 184 |
+
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
| 185 |
+
{...props}
|
| 186 |
+
/>
|
| 187 |
+
));
|
| 188 |
+
MenubarLabel.displayName = MenubarPrimitive.Label.displayName;
|
| 189 |
+
|
| 190 |
+
const MenubarSeparator = React.forwardRef<
|
| 191 |
+
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
| 192 |
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
| 193 |
+
>(({ className, ...props }, ref) => (
|
| 194 |
+
<MenubarPrimitive.Separator
|
| 195 |
+
ref={ref}
|
| 196 |
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
| 197 |
+
{...props}
|
| 198 |
+
/>
|
| 199 |
+
));
|
| 200 |
+
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName;
|
| 201 |
+
|
| 202 |
+
const MenubarShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
| 203 |
+
return (
|
| 204 |
+
<span
|
| 205 |
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
| 206 |
+
{...props}
|
| 207 |
+
/>
|
| 208 |
+
);
|
| 209 |
+
};
|
| 210 |
+
MenubarShortcut.displayname = "MenubarShortcut";
|
| 211 |
+
|
| 212 |
+
export {
|
| 213 |
+
Menubar,
|
| 214 |
+
MenubarMenu,
|
| 215 |
+
MenubarTrigger,
|
| 216 |
+
MenubarContent,
|
| 217 |
+
MenubarItem,
|
| 218 |
+
MenubarSeparator,
|
| 219 |
+
MenubarLabel,
|
| 220 |
+
MenubarCheckboxItem,
|
| 221 |
+
MenubarRadioGroup,
|
| 222 |
+
MenubarRadioItem,
|
| 223 |
+
MenubarPortal,
|
| 224 |
+
MenubarSubContent,
|
| 225 |
+
MenubarSubTrigger,
|
| 226 |
+
MenubarGroup,
|
| 227 |
+
MenubarSub,
|
| 228 |
+
MenubarShortcut,
|
| 229 |
+
};
|
src/components/ui/navigation-menu.tsx
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
| 3 |
+
import { cva } from "class-variance-authority";
|
| 4 |
+
import { ChevronDown } from "lucide-react";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
|
| 8 |
+
const NavigationMenu = React.forwardRef<
|
| 9 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
| 10 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
| 11 |
+
>(({ className, children, ...props }, ref) => (
|
| 12 |
+
<NavigationMenuPrimitive.Root
|
| 13 |
+
ref={ref}
|
| 14 |
+
className={cn("relative z-10 flex max-w-max flex-1 items-center justify-center", className)}
|
| 15 |
+
{...props}
|
| 16 |
+
>
|
| 17 |
+
{children}
|
| 18 |
+
<NavigationMenuViewport />
|
| 19 |
+
</NavigationMenuPrimitive.Root>
|
| 20 |
+
));
|
| 21 |
+
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
| 22 |
+
|
| 23 |
+
const NavigationMenuList = React.forwardRef<
|
| 24 |
+
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
| 25 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
| 26 |
+
>(({ className, ...props }, ref) => (
|
| 27 |
+
<NavigationMenuPrimitive.List
|
| 28 |
+
ref={ref}
|
| 29 |
+
className={cn("group flex flex-1 list-none items-center justify-center space-x-1", className)}
|
| 30 |
+
{...props}
|
| 31 |
+
/>
|
| 32 |
+
));
|
| 33 |
+
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
| 34 |
+
|
| 35 |
+
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
| 36 |
+
|
| 37 |
+
const navigationMenuTriggerStyle = cva(
|
| 38 |
+
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium cursor-pointer transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[state=open]:text-accent-foreground data-[state=open]:bg-accent/50 data-[state=open]:hover:bg-accent data-[state=open]:focus:bg-accent",
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
const NavigationMenuTrigger = React.forwardRef<
|
| 42 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
| 43 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
| 44 |
+
>(({ className, children, ...props }, ref) => (
|
| 45 |
+
<NavigationMenuPrimitive.Trigger
|
| 46 |
+
ref={ref}
|
| 47 |
+
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
| 48 |
+
{...props}
|
| 49 |
+
>
|
| 50 |
+
{children}{" "}
|
| 51 |
+
<ChevronDown
|
| 52 |
+
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
|
| 53 |
+
aria-hidden="true"
|
| 54 |
+
/>
|
| 55 |
+
</NavigationMenuPrimitive.Trigger>
|
| 56 |
+
));
|
| 57 |
+
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
| 58 |
+
|
| 59 |
+
const NavigationMenuContent = React.forwardRef<
|
| 60 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
| 61 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
| 62 |
+
>(({ className, ...props }, ref) => (
|
| 63 |
+
<NavigationMenuPrimitive.Content
|
| 64 |
+
ref={ref}
|
| 65 |
+
className={cn(
|
| 66 |
+
"left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",
|
| 67 |
+
className,
|
| 68 |
+
)}
|
| 69 |
+
{...props}
|
| 70 |
+
/>
|
| 71 |
+
));
|
| 72 |
+
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
| 73 |
+
|
| 74 |
+
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
| 75 |
+
|
| 76 |
+
const NavigationMenuViewport = React.forwardRef<
|
| 77 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
| 78 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
| 79 |
+
>(({ className, ...props }, ref) => (
|
| 80 |
+
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
| 81 |
+
<NavigationMenuPrimitive.Viewport
|
| 82 |
+
className={cn(
|
| 83 |
+
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
| 84 |
+
className,
|
| 85 |
+
)}
|
| 86 |
+
ref={ref}
|
| 87 |
+
{...props}
|
| 88 |
+
/>
|
| 89 |
+
</div>
|
| 90 |
+
));
|
| 91 |
+
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
| 92 |
+
|
| 93 |
+
const NavigationMenuIndicator = React.forwardRef<
|
| 94 |
+
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
| 95 |
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
| 96 |
+
>(({ className, ...props }, ref) => (
|
| 97 |
+
<NavigationMenuPrimitive.Indicator
|
| 98 |
+
ref={ref}
|
| 99 |
+
className={cn(
|
| 100 |
+
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
|
| 101 |
+
className,
|
| 102 |
+
)}
|
| 103 |
+
{...props}
|
| 104 |
+
>
|
| 105 |
+
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
| 106 |
+
</NavigationMenuPrimitive.Indicator>
|
| 107 |
+
));
|
| 108 |
+
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
| 109 |
+
|
| 110 |
+
export {
|
| 111 |
+
navigationMenuTriggerStyle,
|
| 112 |
+
NavigationMenu,
|
| 113 |
+
NavigationMenuList,
|
| 114 |
+
NavigationMenuItem,
|
| 115 |
+
NavigationMenuContent,
|
| 116 |
+
NavigationMenuTrigger,
|
| 117 |
+
NavigationMenuLink,
|
| 118 |
+
NavigationMenuIndicator,
|
| 119 |
+
NavigationMenuViewport,
|
| 120 |
+
};
|
src/components/ui/pagination.tsx
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
import { ButtonProps, buttonVariants } from "@/components/ui/button";
|
| 6 |
+
|
| 7 |
+
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
| 8 |
+
<nav
|
| 9 |
+
role="navigation"
|
| 10 |
+
aria-label="pagination"
|
| 11 |
+
className={cn("mx-auto flex w-full justify-center", className)}
|
| 12 |
+
{...props}
|
| 13 |
+
/>
|
| 14 |
+
);
|
| 15 |
+
Pagination.displayName = "Pagination";
|
| 16 |
+
|
| 17 |
+
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
|
| 18 |
+
({ className, ...props }, ref) => (
|
| 19 |
+
<ul ref={ref} className={cn("flex flex-row items-center gap-1", className)} {...props} />
|
| 20 |
+
),
|
| 21 |
+
);
|
| 22 |
+
PaginationContent.displayName = "PaginationContent";
|
| 23 |
+
|
| 24 |
+
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(
|
| 25 |
+
({ className, ...props }, ref) => <li ref={ref} className={cn("", className)} {...props} />,
|
| 26 |
+
);
|
| 27 |
+
PaginationItem.displayName = "PaginationItem";
|
| 28 |
+
|
| 29 |
+
type PaginationLinkProps = {
|
| 30 |
+
isActive?: boolean;
|
| 31 |
+
} & Pick<ButtonProps, "size"> &
|
| 32 |
+
React.ComponentProps<"a">;
|
| 33 |
+
|
| 34 |
+
const PaginationLink = ({ className, isActive, size = "icon", ...props }: PaginationLinkProps) => (
|
| 35 |
+
<a
|
| 36 |
+
aria-current={isActive ? "page" : undefined}
|
| 37 |
+
className={cn(
|
| 38 |
+
buttonVariants({
|
| 39 |
+
variant: isActive ? "outline" : "ghost",
|
| 40 |
+
size,
|
| 41 |
+
}),
|
| 42 |
+
className,
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
);
|
| 47 |
+
PaginationLink.displayName = "PaginationLink";
|
| 48 |
+
|
| 49 |
+
const PaginationPrevious = ({
|
| 50 |
+
className,
|
| 51 |
+
...props
|
| 52 |
+
}: React.ComponentProps<typeof PaginationLink>) => (
|
| 53 |
+
<PaginationLink
|
| 54 |
+
aria-label="Go to previous page"
|
| 55 |
+
size="default"
|
| 56 |
+
className={cn("gap-1 pl-2.5", className)}
|
| 57 |
+
{...props}
|
| 58 |
+
>
|
| 59 |
+
<ChevronLeft className="h-4 w-4" />
|
| 60 |
+
<span>Previous</span>
|
| 61 |
+
</PaginationLink>
|
| 62 |
+
);
|
| 63 |
+
PaginationPrevious.displayName = "PaginationPrevious";
|
| 64 |
+
|
| 65 |
+
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
| 66 |
+
<PaginationLink
|
| 67 |
+
aria-label="Go to next page"
|
| 68 |
+
size="default"
|
| 69 |
+
className={cn("gap-1 pr-2.5", className)}
|
| 70 |
+
{...props}
|
| 71 |
+
>
|
| 72 |
+
<span>Next</span>
|
| 73 |
+
<ChevronRight className="h-4 w-4" />
|
| 74 |
+
</PaginationLink>
|
| 75 |
+
);
|
| 76 |
+
PaginationNext.displayName = "PaginationNext";
|
| 77 |
+
|
| 78 |
+
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
| 79 |
+
<span
|
| 80 |
+
aria-hidden
|
| 81 |
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
| 82 |
+
{...props}
|
| 83 |
+
>
|
| 84 |
+
<MoreHorizontal className="h-4 w-4" />
|
| 85 |
+
<span className="sr-only">More pages</span>
|
| 86 |
+
</span>
|
| 87 |
+
);
|
| 88 |
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
| 89 |
+
|
| 90 |
+
export {
|
| 91 |
+
Pagination,
|
| 92 |
+
PaginationContent,
|
| 93 |
+
PaginationLink,
|
| 94 |
+
PaginationItem,
|
| 95 |
+
PaginationPrevious,
|
| 96 |
+
PaginationNext,
|
| 97 |
+
PaginationEllipsis,
|
| 98 |
+
};
|