mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
feat(goal_ui): RuFlo Research at goal.ruv.io — rebrand + cleanup (#1693)
* feat(goal_ui): import goap-ui-main (GOAP research UI) Unzipped from v3/goal_ui/goap-ui-main.zip — a Vite + React + Supabase research planning UI. 354 files including: - React UI (src/, components.json, tailwind, vite config) - Supabase Edge Functions (generate-action-items, generate-research- goal, optimize-research-config, research-api, research-step) - Widget build pipeline (build-widget.sh) - Deployment notes (DEPLOYMENT*.md, netlify.toml) .env is intentionally force-committed (overrides root .gitignore entries on lines 61 + 161). It contains only Vite's VITE_* prefixed client-public Supabase config: VITE_SUPABASE_PROJECT_ID VITE_SUPABASE_PUBLISHABLE_KEY ← Supabase publishable/anon key VITE_SUPABASE_URL These values ship in every Vite client bundle by design — RLS on the Supabase project is the actual access gate, not key secrecy. No sk-*, JWT, or service_role keys in the file (verified with secret heuristic regex). Co-Authored-By: RuFlo <ruv@ruv.net> * refactor(goal_ui): flatten goap-ui-main/ into goal_ui/ The previous import nested everything under v3/goal_ui/goap-ui-main/ — two folders for one project. Move all 354 files up one level so the layout reads: v3/goal_ui/ .env package.json src/ supabase/ ... instead of the redundant v3/goal_ui/goap-ui-main/... Build output dist/ removed (it was untracked and shouldn't ship — generated by `npm run build`). Co-Authored-By: RuFlo <ruv@ruv.net> * feat(goal_ui): rebrand to RuFlo Research, clean up scaffolding, drop Lovable favicon - Rebrand v3/goal_ui as RuFlo Research (https://goal.ruv.io/) - package.json: name → @ruflo/research, drop lovable-tagger - vite.config.ts: remove componentTagger / lovable-tagger import - index.html: SEO/OG/Twitter meta retargeted to goal.ruv.io - src/widget.tsx + Demo.tsx + WidgetCustomizer.tsx + widget-embed.html: window.GOAPWidget* → window.RufloResearchWidget* container id → ruflo-research-widget-container - Replace Lovable purple-gradient favicon.ico (PNG) with RuFlo SVG mark - Drop unreferenced placeholder.svg boilerplate - Move docs into v3/goal_ui/docs/ (DEPLOYMENT, WIDGET-INTEGRATION, WIDGET_SETUP) - Delete out-of-scope plans/agentic-flow/, duplicate WIDGET-INTEGRATION.md, bun.lockb (npm-only project), TEMPLATE_README, SETUP_GUIDE, DEPLOYMENT-FIX, nested CLAUDE.md, and stale .claude/.github duplicates from flatten residue - Rewrite v3/goal_ui/README.md as RuFlo Research overview - Update root README "What You Get": add RuFlo Research row pointing at goal.ruv.io - Drop SEO keyword spam lines from Web UI and Goal Planner sections Algorithm references to GOAP (goapPlanner.ts, GOAPPlanner, parseGoal) preserved — GOAP is the algorithm name, not the brand. Co-Authored-By: RuFlo <ruv@ruv.net> --------- Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
This commit is contained in:
1 parent
71ab7a282d
commit
e58154a426
120 files changed
+24960
-4
No files matched your search
@@ -174,20 +174,21 @@ claude mcp add ruflo -- npx -y @claude-flow/cli@latest
|
||||
| 🛡️ **Security** | AIDefence, input validation, CVE remediation, path traversal prevention |
|
||||
| 🌐 **Agent Federation** | Cross-installation agent collaboration with zero-trust security |
|
||||
| 💬 **[Web UI Beta](https://flo.ruv.io/)** | Multi-model chat at flo.ruv.io with parallel MCP tool calling and an in-browser WASM tool gallery |
|
||||
| 🎯 **[RuFlo Research](https://goal.ruv.io/)** | GOAP A\* planner at goal.ruv.io — plain-English goals → executable agent plans, with a live agent dashboard at [/agents](https://goal.ruv.io/agents) |
|
||||
|
||||
<p align="center">
|
||||
<a href="https://flo.ruv.io/">
|
||||
<img src="v3/docs/assets/ruVocal.png" alt="RuFlo Web UI executing parallel MCP tool calls at flo.ruv.io — ruflo__memory_store and ruflo__memory_search firing in a single model turn with the 'Step 1 — 2 tools completed' parallel-execution indicator, thinking process panel visible, Qwen 3.6 Max as the active model. Multi-agent AI chat with Model Context Protocol (MCP) tool calling, persistent vector memory via AgentDB + HNSW, swarm coordination, and 6 frontier models including Claude Sonnet 4.6, Gemini 2.5 Pro, and GPT-4o through OpenRouter." width="100%" />
|
||||
<img src="v3/docs/assets/ruVocal.png" alt="RuFlo Web UI executing parallel MCP tool calls at flo.ruv.io — ruflo__memory_store and ruflo__memory_search firing in a single model turn with the 'Step 1 — 2 tools completed' parallel-execution indicator, thinking process panel visible, Qwen 3.6 Max as the active model. Multi-agent AI chat with Model Context Protocol (MCP) tool calling, persistent vector memory via AgentDB + HNSW, swarm coordination, and 6 frontier models including Claude Sonnet 4.6, Gemini 2.5 Pro, and OpenAI through OpenRouter." width="100%" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
### Web UI (Beta) — self-hostable, hosted demo at [flo.ruv.io](https://flo.ruv.io/)
|
||||
|
||||
**RuFlo's web UI is a multi-model AI chat with built-in Model Context Protocol (MCP) tool calling.** Talk to Qwen, Claude, Gemini, or GPT-4o while RuFlo invokes the same MCP tools the CLI uses — agent orchestration, persistent memory, swarm coordination, code review, GitHub ops — directly from chat. No install, no API key needed to try it.
|
||||
**RuFlo's web UI is a multi-model AI chat with built-in Model Context Protocol (MCP) tool calling.** Talk to Qwen, Claude, Gemini, or OpenAI while RuFlo invokes the same MCP tools the CLI uses — agent orchestration, persistent memory, swarm coordination, code review, GitHub ops — directly from chat. No install, no API key needed to try it.
|
||||
|
||||
| | What it is | Why it matters |
|
||||
|---|------------|----------------|
|
||||
| 🧠 | **Any model, local or remote** | 6 curated frontier models out-of-the-box — Qwen 3.6 Max (default), Claude Sonnet 4.6, Claude Haiku 4.5, Gemini 2.5 Pro, Gemini 2.5 Flash, GPT-4o — via OpenRouter. Add your own: any OpenAI-compatible endpoint (vLLM, Ollama, LM Studio, Together, Groq, self-hosted). |
|
||||
| 🧠 | **Any model, local or remote** | 6 curated frontier models out-of-the-box — Qwen 3.6 Max (default), Claude Sonnet 4.6, Claude Haiku 4.5, Gemini 2.5 Pro, Gemini 2.5 Flash, OpenAI — via OpenRouter. Add your own: any OpenAI-compatible endpoint (vLLM, Ollama, LM Studio, Together, Groq, self-hosted). |
|
||||
| 🦾 | **ruvLLM self-learning AI** | Native support for [ruvLLM](https://github.com/ruvnet/RuVector/tree/main/examples/ruvLLM) (lives in `ruvnet/RuVector/examples/ruvLLM`) — RuFlo's self-improving local model layer. Routes to MicroLoRA adapters, learns from your trajectories via SONA, and stays on your machine. Pair with the cloud models or run fully offline. |
|
||||
| 🛠️ | **~210 tools, ready to call** | 5 server groups (Core, Intelligence, Agents, Memory, DevTools) plus an 18-tool gallery that runs entirely in your browser — works offline. |
|
||||
| 🔌 | **Bring your own MCP servers** | Click the **MCP (n)** pill in the chat input → *Add Server* and paste any MCP endpoint (HTTP, SSE, or stdio). Your tools join RuFlo's native ones in the same parallel-execution flow. Run a local MCP server on `localhost:3000` and it just works. |
|
||||
@@ -199,7 +200,28 @@ claude mcp add ruflo -- npx -y @claude-flow/cli@latest
|
||||
|
||||
**Try the hosted demo:** [https://flo.ruv.io/](https://flo.ruv.io/) — no account, no API key. **Run your own:** the source lives in [`ruflo/src/ruvocal/`](ruflo/src/ruvocal/) with a multi-stage Dockerfile (`INCLUDE_DB=true` builds in MongoDB) and a `cloudbuild.yaml` for Google Cloud Run. See [ADR-033](ruflo/docs/adr/ADR-033-RUVOCAL-WASM-MCP-INTEGRATION.md) for the architecture and [issue #1689](https://github.com/ruvnet/ruflo/issues/1689) for the roadmap.
|
||||
|
||||
> **Keywords**: AI chat UI · MCP server · Model Context Protocol · multi-agent orchestration · Claude · Gemini · Qwen · GPT-4o · vector memory · HNSW · agent swarms · parallel tool calling · LLM tool use · OpenRouter · AgentDB · semantic search · ruvocal · ruflo.ruv.io
|
||||
<p align="center">
|
||||
<a href="https://goal.ruv.io/agents">
|
||||
<img src="v3/docs/assets/goal.png" alt="goal.ruv.io/agents — RuFlo Goal-Oriented Action Planning (GOAP) UI for autonomous AI agents. Visual goal decomposition, A* search through state spaces, multi-agent task assignment, and live agent telemetry." width="100%" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
### Goal Planner UI — autonomous agents at [goal.ruv.io](https://goal.ruv.io/)
|
||||
|
||||
**Turn high-level goals into executable agent plans.** `goal.ruv.io` is RuFlo's hosted Goal-Oriented Action Planning (GOAP) front-end — describe an outcome in plain English and watch RuFlo decompose it into preconditions, actions, and an A* path through state space, then dispatch the work to live agents at [`/agents`](https://goal.ruv.io/agents).
|
||||
|
||||
| | What it is | Why it matters |
|
||||
|---|------------|----------------|
|
||||
| 🎯 | **Plain-English goals** | Type *"ship the auth refactor with tests and a PR"* — RuFlo extracts the success criteria, the constraints, and the implicit preconditions. No JSON, no DSL. |
|
||||
| 🧭 | **GOAP A\* planner** | Classic gaming-AI planning ported to software work: state-space search through actions with preconditions/effects to find the shortest viable path. Replans on the fly when state changes. |
|
||||
| 🤖 | **Live agent dashboard** | [goal.ruv.io/agents](https://goal.ruv.io/agents) shows every spawned agent — role, current step, memory namespace, token budget, status. Click in to inspect trajectories, kill runaway workers, or reassign. |
|
||||
| 🌳 | **Visual plan tree** | Goals render as collapsible action trees with progress, blocked branches, and rollbacks highlighted. See *exactly* why an agent picked a path — no opaque chain-of-thought. |
|
||||
| ♻️ | **Adaptive replanning** | When an action fails or new info arrives, the planner re-runs A\* from the current state instead of restarting. Failures become learning, not loops. |
|
||||
| 🧠 | **Shared memory + SONA** | Plans, trajectories, and outcomes flow into AgentDB. Future plans retrieve past solutions via HNSW — the planner gets smarter with every run. |
|
||||
| 🔗 | **Wired to MCP tools** | Every action node maps to a tool call (RuFlo's ~210 MCP tools, your custom servers, or shell). The planner schedules them in parallel where the dependency graph allows. |
|
||||
| 🚀 | **Zero install to try** | Open [goal.ruv.io](https://goal.ruv.io/), describe a goal, watch it run. Source lives in [`v3/goal_ui/`](v3/goal_ui/) — Vite + Supabase, self-hostable. |
|
||||
|
||||
**Try it:** [https://goal.ruv.io/](https://goal.ruv.io/) for goals · [https://goal.ruv.io/agents](https://goal.ruv.io/agents) for live agents. **Run your own:** clone the `goal` branch and `cd v3/goal_ui && npm install && npm run dev`.
|
||||
|
||||
### Agent Federation — Slack for Agents
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
VITE_SUPABASE_PROJECT_ID="eqzmqxtngbulzhimrymr"
|
||||
VITE_SUPABASE_PUBLISHABLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVxem1xeHRuZ2J1bHpoaW1yeW1yIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTk4NjUxNzksImV4cCI6MjA3NTQ0MTE3OX0.PhcjlpXVD3HmYVSz28NqiB2v1S0XehQhFIg__PF925M"
|
||||
VITE_SUPABASE_URL="https://eqzmqxtngbulzhimrymr.supabase.co"
|
||||
@@ -0,0 +1,55 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
# dist - commenting out so dist folder is included in git for deployment
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Widget build artifacts (copied to public for dev)
|
||||
public/widget.js
|
||||
public/widget.css
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Claude Flow generated files
|
||||
.claude/settings.local.json
|
||||
.mcp.json
|
||||
claude-flow.config.json
|
||||
.swarm/
|
||||
.hive-mind/
|
||||
.claude-flow/
|
||||
memory/
|
||||
coordination/
|
||||
memory/claude-flow-data.json
|
||||
memory/sessions/*
|
||||
!memory/sessions/README.md
|
||||
memory/agents/*
|
||||
!memory/agents/README.md
|
||||
coordination/memory_bank/*
|
||||
coordination/subtasks/*
|
||||
coordination/orchestration/*
|
||||
*.db
|
||||
*.db-journal
|
||||
*.db-wal
|
||||
*.sqlite
|
||||
*.sqlite-journal
|
||||
*.sqlite-wal
|
||||
claude-flow
|
||||
# Removed Windows wrapper files per user request
|
||||
hive-mind-prompt-*.txt
|
||||
@@ -0,0 +1,86 @@
|
||||
# RuFlo Research
|
||||
|
||||
> Goal-Oriented Action Planning UI for autonomous AI research workflows. Part of the [RuFlo](https://github.com/ruvnet/ruflo) platform.
|
||||
> Live: [goal.ruv.io](https://goal.ruv.io/) · Agents dashboard: [goal.ruv.io/agents](https://goal.ruv.io/agents)
|
||||
|
||||
Turn plain-English research goals into executable agent plans. RuFlo Research applies classic Goal-Oriented Action Planning (GOAP) — A* search through a state space of actions with preconditions and effects — to autonomous AI research, then dispatches the work to live agents you can inspect in real time.
|
||||
|
||||
## Highlights
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 🎯 **Plain-English goals** | Describe an outcome — RuFlo extracts success criteria, constraints, and implicit preconditions |
|
||||
| 🧭 **GOAP A\* planner** | Shortest-path search through actions with preconditions/effects; replans on the fly when state changes |
|
||||
| 🤖 **Live agent dashboard** | `/agents` shows every spawned agent — role, current step, status, trajectories |
|
||||
| 🌳 **Visual plan tree** | Goals render as collapsible action trees with progress, blocked branches, rollbacks |
|
||||
| ♻️ **Adaptive replanning** | When an action fails, A* re-runs from the current state instead of restarting |
|
||||
| 🔌 **Embeddable widget** | Drop the research UI into any site via `<script src="widget.js">` |
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# from /v3/goal_ui
|
||||
npm install
|
||||
npm run dev # main app on http://localhost:8080
|
||||
```
|
||||
|
||||
For the embeddable widget:
|
||||
|
||||
```bash
|
||||
npm run build:widget # produces dist/widget.js + dist/widget.css
|
||||
npm run widget:dev # build widget + start dev server
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
v3/goal_ui/
|
||||
├── src/
|
||||
│ ├── components/ # React components (GoalInput, AgentStep, ResearchReportModal, …)
|
||||
│ ├── pages/ # Index, Agents, Demo, NotFound
|
||||
│ ├── lib/goapPlanner.ts # GOAP A* implementation
|
||||
│ ├── integrations/supabase/ # Supabase client + types
|
||||
│ └── widget.tsx # Embeddable widget entry
|
||||
├── supabase/functions/ # Edge functions (research-step, generate-research-goal, …)
|
||||
├── public/ # Static assets, widget-embed.html demo
|
||||
├── docs/ # DEPLOYMENT.md, WIDGET-INTEGRATION.md, WIDGET_SETUP.md
|
||||
└── netlify.toml # Hosting config
|
||||
```
|
||||
|
||||
## Embedding the Widget
|
||||
|
||||
```html
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6",
|
||||
accentColor: "#10b981",
|
||||
};
|
||||
</script>
|
||||
<script src="https://goal.ruv.io/widget.js"></script>
|
||||
<link rel="stylesheet" href="https://goal.ruv.io/widget.css" />
|
||||
```
|
||||
|
||||
The widget exposes a global `window.RufloResearchWidget` with `init(containerId)` and `version` for programmatic control. See [`docs/WIDGET-INTEGRATION.md`](docs/WIDGET-INTEGRATION.md) for the full integration guide.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
React 18 · TypeScript 5 · Vite 5 · Tailwind 3 · shadcn/ui · Radix UI · React Query · React Router · Supabase Edge Functions · GOAP A* planner
|
||||
|
||||
## Deployment
|
||||
|
||||
Hosted on Netlify (`netlify.toml`) at [goal.ruv.io](https://goal.ruv.io/). See [`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md) for self-hosting instructions and edge-function deploy steps.
|
||||
|
||||
## Environment
|
||||
|
||||
Copy `example.env` → `.env` and set the Supabase publishable variables (all `VITE_*` prefixed and safe to ship to the browser):
|
||||
|
||||
```
|
||||
VITE_SUPABASE_URL=...
|
||||
VITE_SUPABASE_PROJECT_ID=...
|
||||
VITE_SUPABASE_PUBLISHABLE_KEY=...
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT — same as the parent [RuFlo](https://github.com/ruvnet/ruflo) project.
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Building RuFlo Research Widget..."
|
||||
echo ""
|
||||
|
||||
# Build the widget
|
||||
echo "Step 1/2: Building widget bundle..."
|
||||
BUILD_WIDGET=true npm run build
|
||||
|
||||
# Check if build was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "✅ Widget built successfully!"
|
||||
echo ""
|
||||
echo "📦 Output files:"
|
||||
echo " - dist/widget.js (main bundle)"
|
||||
echo " - dist/widget.css (styles)"
|
||||
echo ""
|
||||
echo "🚀 Usage on external sites:"
|
||||
echo ""
|
||||
echo "<div id=\"ruflo-research-widget-container\"></div>"
|
||||
echo "<script src=\"https://your-domain.com/widget.js\"></script>"
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Widget build failed"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "default",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.ts",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "slate",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
# Deployment Guide
|
||||
|
||||
## ✅ Pre-Deployment Checklist
|
||||
|
||||
Before deploying, ensure:
|
||||
|
||||
1. **Widget files are built**: Run `npm run build`
|
||||
- This builds widget first, then the main app
|
||||
- Widget files end up in `dist/` folder
|
||||
|
||||
2. **Required files in dist/**:
|
||||
- ✅ `widget.js` (595KB)
|
||||
- ✅ `widget.css` (65KB)
|
||||
- ✅ `widget-embed.html`
|
||||
- ✅ `_headers` (CORS configuration)
|
||||
- ✅ `_redirects` (routing rules)
|
||||
|
||||
3. **Verify locally**:
|
||||
```bash
|
||||
npm run build
|
||||
npm run preview
|
||||
# Visit http://localhost:4173/demo
|
||||
```
|
||||
|
||||
## 🚀 Netlify Deployment
|
||||
|
||||
### Build Settings
|
||||
|
||||
Ensure your Netlify site has these build settings:
|
||||
|
||||
- **Build command**: `npm run build`
|
||||
- **Publish directory**: `dist`
|
||||
- **Node version**: 18 or higher (set in Environment Variables: `NODE_VERSION=18`)
|
||||
|
||||
### Deployment Process
|
||||
|
||||
1. **Push to Git**:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Add widget embed system"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
2. **Netlify will automatically**:
|
||||
- Run `npm install`
|
||||
- Run `npm run build`
|
||||
- Deploy `dist/` folder
|
||||
- Apply `_headers` and `_redirects` rules
|
||||
|
||||
3. **Verify deployment**:
|
||||
- Visit `https://your-domain.com/widget.js` - should return JavaScript
|
||||
- Visit `https://your-domain.com/widget.css` - should return CSS
|
||||
- Visit `https://your-domain.com/demo` - should load widget demo
|
||||
- Visit `https://your-domain.com/widget-embed.html` - should show embed example
|
||||
|
||||
## 🔍 Troubleshooting
|
||||
|
||||
### Widget files 404 error
|
||||
|
||||
**Symptom**: `widget.js` and `widget.css` return 404
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Check build logs**:
|
||||
- Look for "BUILD_WIDGET=true vite build" in logs
|
||||
- Ensure both widget and app builds completed
|
||||
|
||||
2. **Verify _redirects file**:
|
||||
- Check if `_redirects` file exists in deployed site
|
||||
- Should contain explicit rules for widget files
|
||||
|
||||
3. **Clear Netlify cache**:
|
||||
```bash
|
||||
# In Netlify dashboard:
|
||||
Site settings > Build & deploy > Clear cache and retry deploy
|
||||
```
|
||||
|
||||
4. **Manual verification**:
|
||||
```bash
|
||||
# Locally verify build output
|
||||
npm run build
|
||||
ls -la dist/ | grep widget
|
||||
# Should show widget.js, widget.css, widget-embed.html
|
||||
```
|
||||
|
||||
### CORS errors
|
||||
|
||||
**Symptom**: Widget loads on same domain but fails on external sites
|
||||
|
||||
**Solution**: Verify `_headers` file contains:
|
||||
```
|
||||
/widget.js
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/javascript; charset=utf-8
|
||||
|
||||
/widget.css
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: text/css; charset=utf-8
|
||||
```
|
||||
|
||||
### SPA routing issues
|
||||
|
||||
**Symptom**: Direct URLs to `/demo` return 404
|
||||
|
||||
**Solution**: The `_redirects` file should have the SPA fallback as the LAST rule:
|
||||
```
|
||||
/* /index.html 200
|
||||
```
|
||||
|
||||
## 📦 Manual Build & Deploy
|
||||
|
||||
If automatic deployment fails, you can build and deploy manually:
|
||||
|
||||
```bash
|
||||
# 1. Build locally
|
||||
npm run build
|
||||
|
||||
# 2. Verify files
|
||||
ls -la dist/ | grep -E "(widget|_headers|_redirects)"
|
||||
|
||||
# 3. Deploy via Netlify CLI
|
||||
npm install -g netlify-cli
|
||||
netlify deploy --prod --dir=dist
|
||||
```
|
||||
|
||||
## 🔗 Widget URLs After Deployment
|
||||
|
||||
Once deployed, your widget will be available at:
|
||||
|
||||
- **Widget script**: `https://your-domain.com/widget.js`
|
||||
- **Widget styles**: `https://your-domain.com/widget.css`
|
||||
- **Demo page**: `https://your-domain.com/demo`
|
||||
- **Embed example**: `https://your-domain.com/widget-embed.html`
|
||||
|
||||
## 📝 Embed Code for Third-Party Sites
|
||||
|
||||
Share this code with users who want to embed the widget:
|
||||
|
||||
```html
|
||||
<!-- RuFlo Research Widget Container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- Configuration (optional) -->
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6",
|
||||
accentColor: "#22c55e",
|
||||
backgroundColor: "#1a1a1a"
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Load Widget -->
|
||||
<link rel="stylesheet" href="https://your-domain.com/widget.css">
|
||||
<script src="https://your-domain.com/widget.js"></script>
|
||||
```
|
||||
|
||||
## 🛠️ Environment Variables
|
||||
|
||||
No environment variables are required for the widget to work. However, if you're using Supabase functions, ensure these are set in Netlify:
|
||||
|
||||
- `VITE_SUPABASE_URL`
|
||||
- `VITE_SUPABASE_ANON_KEY`
|
||||
|
||||
## ✨ Post-Deployment Testing
|
||||
|
||||
After deployment, test:
|
||||
|
||||
1. **Main app**: Visit homepage, create a research goal
|
||||
2. **Demo page**: Visit `/demo`, verify widget loads
|
||||
3. **Widget files**: Direct access to `/widget.js` and `/widget.css`
|
||||
4. **Embed example**: Visit `/widget-embed.html`
|
||||
5. **CORS**: Test widget on external domain (e.g., CodePen, JSFiddle)
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
Monitor widget usage:
|
||||
- Check Netlify Analytics for `/widget.js` and `/widget.css` requests
|
||||
- Use browser DevTools Network tab to verify CORS headers
|
||||
- Monitor error logs for failed widget loads
|
||||
|
||||
## 🔄 Updating the Widget
|
||||
|
||||
When you make changes:
|
||||
|
||||
1. Update source code
|
||||
2. Run `npm run build` locally to test
|
||||
3. Commit and push to Git
|
||||
4. Netlify auto-deploys
|
||||
5. Widget updates are live immediately (users may need to clear cache)
|
||||
|
||||
## 💾 Caching Strategy
|
||||
|
||||
The `_headers` file sets:
|
||||
- Widget files: 1 year cache (`max-age=31536000`)
|
||||
- Immutable flag for faster loads
|
||||
|
||||
To force users to get new version:
|
||||
- Change widget version in code
|
||||
- Or rename files (e.g., `widget.v2.js`)
|
||||
- Or use cache busting query params
|
||||
@@ -0,0 +1,341 @@
|
||||
# RuFlo Research Widget Integration Guide
|
||||
|
||||
## 📦 Overview
|
||||
|
||||
The RuFlo Research Widget is a standalone, embeddable component that brings Goal-Oriented Action Planning research capabilities to any website. It's fully self-contained with no external dependencies required on the host page.
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Basic Integration
|
||||
|
||||
Add this code to any HTML page:
|
||||
|
||||
```html
|
||||
<!-- 1. Add widget container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- 2. Load widget files -->
|
||||
<link rel="stylesheet" href="https://YOUR-DOMAIN/widget.css">
|
||||
<script src="https://YOUR-DOMAIN/widget.js"></script>
|
||||
```
|
||||
|
||||
That's it! The widget will automatically initialize.
|
||||
|
||||
### With Configuration
|
||||
|
||||
```html
|
||||
<!-- Widget container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- Configuration (optional) -->
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6",
|
||||
accentColor: "#22c55e",
|
||||
backgroundColor: "#1a1a1a",
|
||||
cardBackgroundColor: "#262626",
|
||||
textColor: "#ffffff",
|
||||
fontFamily: "system-ui",
|
||||
defaultGoal: "Research the latest advancements in quantum computing"
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Load widget -->
|
||||
<link rel="stylesheet" href="https://YOUR-DOMAIN/widget.css">
|
||||
<script src="https://YOUR-DOMAIN/widget.js"></script>
|
||||
```
|
||||
|
||||
## ⚙️ Configuration Options
|
||||
|
||||
All configuration options are optional. The widget will use sensible defaults.
|
||||
|
||||
```javascript
|
||||
window.RufloResearchWidgetConfig = {
|
||||
// Colors (use hex format)
|
||||
primaryColor: "#8b5cf6", // Main brand color
|
||||
accentColor: "#22c55e", // Success/highlight color
|
||||
backgroundColor: "#1a1a1a", // Page background
|
||||
cardBackgroundColor: "#262626", // Card backgrounds
|
||||
cardBorderColor: "#404040", // Card borders
|
||||
textColor: "#ffffff", // Primary text
|
||||
secondaryTextColor: "#a3a3a3", // Secondary text
|
||||
successColor: "#22c55e", // Success indicators
|
||||
|
||||
// Content
|
||||
title: "Goal-Oriented Action Planning",
|
||||
description: "AI-powered research planning...",
|
||||
brandName: "Your Brand",
|
||||
defaultGoal: "Default research goal",
|
||||
|
||||
// Styling
|
||||
fontFamily: "system-ui", // Font family
|
||||
borderRadius: "0.5rem", // Border radius for cards
|
||||
animationSpeed: "normal", // Animation speed: "slow", "normal", "fast"
|
||||
cardSpacing: "1rem", // Space between cards
|
||||
|
||||
// Features
|
||||
showMetrics: true, // Show step metrics
|
||||
showStats: true, // Show statistics
|
||||
compactMode: false, // Compact layout
|
||||
enableAI: true, // Enable AI features
|
||||
aiModel: "google/gemini-2.5-flash" // AI model to use
|
||||
};
|
||||
```
|
||||
|
||||
## 🎨 Custom Container
|
||||
|
||||
Use a custom container ID:
|
||||
|
||||
```html
|
||||
<div id="my-custom-container"></div>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
if (window.RufloResearchWidget) {
|
||||
window.RufloResearchWidget.init('my-custom-container');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
## 🌐 CORS & Security
|
||||
|
||||
### CORS Headers
|
||||
|
||||
The widget files are configured with proper CORS headers to work on any domain:
|
||||
|
||||
```
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, OPTIONS
|
||||
```
|
||||
|
||||
### Content Security Policy
|
||||
|
||||
If your site uses CSP, add these directives:
|
||||
|
||||
```html
|
||||
<meta http-equiv="Content-Security-Policy"
|
||||
content="script-src 'self' https://YOUR-DOMAIN;
|
||||
style-src 'self' https://YOUR-DOMAIN 'unsafe-inline';">
|
||||
```
|
||||
|
||||
### Iframe Embedding
|
||||
|
||||
To embed via iframe:
|
||||
|
||||
```html
|
||||
<iframe
|
||||
src="https://YOUR-DOMAIN/widget-embed.html"
|
||||
width="100%"
|
||||
height="800"
|
||||
frameborder="0"
|
||||
style="border: none;">
|
||||
</iframe>
|
||||
```
|
||||
|
||||
## 📱 Responsive Design
|
||||
|
||||
The widget is fully responsive and mobile-friendly. It will automatically adapt to:
|
||||
- Mobile devices (< 640px)
|
||||
- Tablets (640px - 1024px)
|
||||
- Desktops (> 1024px)
|
||||
|
||||
## 🔧 Advanced Usage
|
||||
|
||||
### Manual Initialization
|
||||
|
||||
Disable auto-initialization and manually control when the widget loads:
|
||||
|
||||
```javascript
|
||||
// The widget auto-initializes by default
|
||||
// To prevent this, load the widget script with defer
|
||||
<script src="/widget.js" defer></script>
|
||||
|
||||
// Then manually initialize when ready
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
if (window.RufloResearchWidget) {
|
||||
window.RufloResearchWidget.init('ruflo-research-widget-container');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Version Check
|
||||
|
||||
Check the widget version:
|
||||
|
||||
```javascript
|
||||
console.log(window.RufloResearchWidget.version); // "1.0.0"
|
||||
```
|
||||
|
||||
### Multiple Widgets
|
||||
|
||||
Load multiple widgets on the same page:
|
||||
|
||||
```html
|
||||
<div id="widget-1"></div>
|
||||
<div id="widget-2"></div>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
window.RufloResearchWidget.init('widget-1');
|
||||
window.RufloResearchWidget.init('widget-2');
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Widget Not Loading
|
||||
|
||||
1. Check browser console for errors
|
||||
2. Verify widget.js and widget.css URLs are correct
|
||||
3. Check CORS headers are properly configured
|
||||
4. Ensure container element exists before widget loads
|
||||
|
||||
### CORS Errors
|
||||
|
||||
If you see CORS errors:
|
||||
```
|
||||
Access to script at 'https://your-domain/widget.js' from origin 'https://other-domain'
|
||||
has been blocked by CORS policy
|
||||
```
|
||||
|
||||
Solutions:
|
||||
1. Ensure `_headers` file is deployed with proper CORS headers
|
||||
2. Check your hosting platform's CORS configuration
|
||||
3. For Netlify: Ensure `netlify.toml` is configured correctly
|
||||
|
||||
### Styling Issues
|
||||
|
||||
If widget styling looks broken:
|
||||
1. Ensure widget.css is loaded before widget.js
|
||||
2. Check for CSS conflicts with your site's styles
|
||||
3. Try adding `!important` to widget container styles
|
||||
4. Use a unique ID for the widget container
|
||||
|
||||
### Performance Issues
|
||||
|
||||
For large pages or slow connections:
|
||||
1. Load widget files with `defer` or `async`
|
||||
2. Place widget at the bottom of the page
|
||||
3. Use lazy loading for the widget container
|
||||
|
||||
## 📊 Browser Support
|
||||
|
||||
- Chrome/Edge: Latest 2 versions
|
||||
- Firefox: Latest 2 versions
|
||||
- Safari: Latest 2 versions
|
||||
- Mobile browsers: iOS Safari 12+, Chrome Android latest
|
||||
|
||||
## 🔒 Privacy & Data
|
||||
|
||||
- Widget runs entirely client-side
|
||||
- No data collection by default
|
||||
- AI features connect to configured backend only when used
|
||||
- No cookies or local storage used without explicit configuration
|
||||
|
||||
## 📝 Example Implementations
|
||||
|
||||
### WordPress
|
||||
|
||||
```php
|
||||
<?php
|
||||
// Add to your theme's functions.php
|
||||
function add_goap_widget() {
|
||||
?>
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "<?php echo get_theme_mod('primary_color', '#8b5cf6'); ?>",
|
||||
defaultGoal: "<?php echo get_option('goap_default_goal'); ?>"
|
||||
};
|
||||
</script>
|
||||
<link rel="stylesheet" href="https://YOUR-DOMAIN/widget.css">
|
||||
<script src="https://YOUR-DOMAIN/widget.js"></script>
|
||||
<?php
|
||||
}
|
||||
add_action('wp_footer', 'add_goap_widget');
|
||||
?>
|
||||
```
|
||||
|
||||
### React/Next.js
|
||||
|
||||
```javascript
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function RufloResearchWidget() {
|
||||
useEffect(() => {
|
||||
// Load widget script
|
||||
const script = document.createElement('script');
|
||||
script.src = 'https://YOUR-DOMAIN/widget.js';
|
||||
script.async = true;
|
||||
document.body.appendChild(script);
|
||||
|
||||
// Load widget CSS
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://YOUR-DOMAIN/widget.css';
|
||||
document.head.appendChild(link);
|
||||
|
||||
return () => {
|
||||
document.body.removeChild(script);
|
||||
document.head.removeChild(link);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <div id="ruflo-research-widget-container" />;
|
||||
}
|
||||
```
|
||||
|
||||
### Vue.js
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
// Set configuration
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: this.$root.theme.primaryColor
|
||||
};
|
||||
|
||||
// Load widget
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://YOUR-DOMAIN/widget.css';
|
||||
document.head.appendChild(link);
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.src = 'https://YOUR-DOMAIN/widget.js';
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
## 📦 Build Your Own
|
||||
|
||||
To build the widget from source:
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Build widget
|
||||
npm run build:widget
|
||||
|
||||
# Output will be in dist/widget.js and dist/widget.css
|
||||
```
|
||||
|
||||
## 🤝 Support
|
||||
|
||||
- Documentation: [View README](./README.md)
|
||||
- Issues: [GitHub Issues](https://github.com/ruvnet/goap-ui/issues)
|
||||
- Demo: [Live Demo](https://lovable.dev/projects/598e2f1d-b876-4347-bb4f-379bdab134b0)
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT License - See LICENSE file for details
|
||||
@@ -0,0 +1,192 @@
|
||||
# RuFlo Research Widget - Embeddable Research Interface
|
||||
|
||||
## Overview
|
||||
The GOAP widget is a fully-featured, embeddable research planning interface with 100% fidelity to the main application. It can be embedded on any website using a simple script tag.
|
||||
|
||||
## Features
|
||||
✅ Complete GOAP planning workflow
|
||||
✅ AI-powered research with Gemini integration
|
||||
✅ State assessment and configuration display
|
||||
✅ Full research report modal
|
||||
✅ Customizable appearance via configuration
|
||||
✅ Self-contained bundle with all dependencies
|
||||
|
||||
## Building the Widget
|
||||
|
||||
To generate the embeddable `widget.js` file:
|
||||
|
||||
```bash
|
||||
# Using the build script
|
||||
chmod +x build-widget.sh
|
||||
./build-widget.sh
|
||||
|
||||
# Or manually
|
||||
BUILD_WIDGET=true npm run build
|
||||
```
|
||||
|
||||
This creates:
|
||||
- `dist/widget.js` - Standalone IIFE bundle with all dependencies
|
||||
- `dist/widget.css` - Compiled styles
|
||||
|
||||
The widget.js is a self-contained bundle that includes:
|
||||
- React & React DOM
|
||||
- All UI components
|
||||
- Supabase client
|
||||
- TanStack Query
|
||||
- All dependencies inlined
|
||||
|
||||
## Embedding on External Sites
|
||||
|
||||
### Basic Embed
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>My Site with RuFlo Research Widget</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Widget Container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- Load Widget Script -->
|
||||
<script src="https://your-domain.com/widget.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
### With Custom Configuration
|
||||
|
||||
```html
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<script>
|
||||
// Configure widget appearance (optional)
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6",
|
||||
accentColor: "#22c55e",
|
||||
backgroundColor: "#1a1a1a",
|
||||
cardBackgroundColor: "#262626",
|
||||
textColor: "#ffffff",
|
||||
fontFamily: "system-ui",
|
||||
defaultGoal: "Research the latest advancements in quantum computing"
|
||||
};
|
||||
</script>
|
||||
|
||||
<script src="https://your-domain.com/widget.js"></script>
|
||||
```
|
||||
|
||||
### Custom Container ID
|
||||
|
||||
```html
|
||||
<div id="my-custom-container"></div>
|
||||
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = { /* ... */ };
|
||||
</script>
|
||||
|
||||
<script src="https://your-domain.com/widget.js"></script>
|
||||
<script>
|
||||
// Manually initialize with custom container
|
||||
window.RufloResearchWidget.init('my-custom-container');
|
||||
</script>
|
||||
```
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `primaryColor` | string | `#8b5cf6` | Primary brand color |
|
||||
| `accentColor` | string | `#22c55e` | Accent/success color |
|
||||
| `backgroundColor` | string | `#1a1a1a` | Background color |
|
||||
| `cardBackgroundColor` | string | `#262626` | Card background |
|
||||
| `textColor` | string | `#ffffff` | Primary text color |
|
||||
| `fontFamily` | string | `system-ui` | Font family |
|
||||
| `defaultGoal` | string | - | Pre-populated research goal |
|
||||
|
||||
## API
|
||||
|
||||
The widget exposes a global `RufloResearchWidget` object:
|
||||
|
||||
```javascript
|
||||
window.RufloResearchWidget = {
|
||||
init: (containerId?: string) => void,
|
||||
version: string
|
||||
}
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
- **`init(containerId)`**: Manually initialize the widget in a specific container
|
||||
- **`version`**: Current widget version
|
||||
|
||||
## Testing Locally
|
||||
|
||||
1. Build the widget:
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. Serve the dist folder:
|
||||
```bash
|
||||
npx serve dist
|
||||
```
|
||||
|
||||
3. Open the example embed page:
|
||||
```
|
||||
http://localhost:3000/widget-embed.html
|
||||
```
|
||||
|
||||
## Demo Page
|
||||
|
||||
Visit `/demo` in your application to see:
|
||||
- Live widget preview
|
||||
- Copyable embed code
|
||||
- Integration instructions
|
||||
- Configuration examples
|
||||
|
||||
## Requirements
|
||||
|
||||
- Modern browser with ES2015+ support
|
||||
- Container element with a unique ID
|
||||
- Internet connection for AI features (Gemini API)
|
||||
|
||||
## Supabase Integration
|
||||
|
||||
The widget includes full Supabase integration for:
|
||||
- AI-powered goal generation
|
||||
- Research step execution
|
||||
- Configuration optimization
|
||||
- Report generation
|
||||
|
||||
Ensure your Supabase project is configured with the required edge functions:
|
||||
- `generate-research-goal`
|
||||
- `research-step`
|
||||
- `optimize-research-config`
|
||||
- `generate-action-items`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Widget not appearing
|
||||
- Check browser console for errors
|
||||
- Verify the container ID matches
|
||||
- Ensure widget.js is loaded correctly
|
||||
|
||||
### Styling conflicts
|
||||
- Widget uses scoped CSS variables
|
||||
- Customize via `RufloResearchWidgetConfig`
|
||||
- Override specific styles if needed
|
||||
|
||||
### API errors
|
||||
- Verify Supabase configuration
|
||||
- Check edge function deployment
|
||||
- Review network requests in DevTools
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
- Check the demo page at `/demo`
|
||||
- Review console logs with `[RuFlo Research]` prefix
|
||||
- Inspect network requests for API failures
|
||||
@@ -0,0 +1,26 @@
|
||||
import js from "@eslint/js";
|
||||
import globals from "globals";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import reactRefresh from "eslint-plugin-react-refresh";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ["dist"] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
"react-hooks": reactHooks,
|
||||
"react-refresh": reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,20 @@
|
||||
# Supabase Configuration
|
||||
# These are automatically provided by Lovable Cloud
|
||||
# For manual setup, get these from your Supabase project settings
|
||||
|
||||
VITE_SUPABASE_URL=https://your-project-id.supabase.co
|
||||
VITE_SUPABASE_PUBLISHABLE_KEY=your-publishable-anon-key-here
|
||||
VITE_SUPABASE_PROJECT_ID=your-project-id
|
||||
|
||||
# Supabase Secrets (Server-side only - DO NOT expose in frontend)
|
||||
# These should be configured in Supabase Dashboard → Project Settings → Edge Functions → Secrets
|
||||
|
||||
# LOVABLE_API_KEY=automatically-provided-by-lovable-cloud
|
||||
# SUPABASE_URL=automatically-provided
|
||||
# SUPABASE_ANON_KEY=automatically-provided
|
||||
# SUPABASE_SERVICE_ROLE_KEY=automatically-provided-keep-secret
|
||||
# SUPABASE_DB_URL=automatically-provided
|
||||
# SUPABASE_PUBLISHABLE_KEY=automatically-provided
|
||||
|
||||
# Note: If using Lovable Cloud, these are auto-configured
|
||||
# If self-hosting, you'll need to manually set these in your Supabase project
|
||||
@@ -0,0 +1,41 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<title>RuFlo Research — Autonomous AI Research with Goal-Oriented Action Planning</title>
|
||||
<meta name="description" content="RuFlo Research turns plain-English goals into executable agent plans. Goal-Oriented Action Planning (GOAP) with A* search, multi-agent coordination, real-time web research, and live agent telemetry — part of the RuFlo platform." />
|
||||
<meta name="keywords" content="RuFlo, RuFlo Research, autonomous AI agents, GOAP, goal-oriented action planning, A* search, multi-agent orchestration, AI research assistant, agent dashboard, MCP tools, ruflo.ruv.io" />
|
||||
<meta name="author" content="RuFlo" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<link rel="canonical" href="https://goal.ruv.io/" />
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://goal.ruv.io/" />
|
||||
<meta property="og:title" content="RuFlo Research — Autonomous AI Research with GOAP" />
|
||||
<meta property="og:description" content="Plain-English goals → executable agent plans. GOAP A* planning, multi-agent coordination, live agent dashboard at goal.ruv.io/agents." />
|
||||
<meta property="og:image" content="/og-image.png" />
|
||||
<meta property="og:site_name" content="RuFlo Research" />
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta property="twitter:url" content="https://goal.ruv.io/" />
|
||||
<meta property="twitter:title" content="RuFlo Research — Autonomous AI Research with GOAP" />
|
||||
<meta property="twitter:description" content="Plain-English goals → executable agent plans. GOAP A* planning, multi-agent coordination, live agent dashboard." />
|
||||
<meta property="twitter:image" content="/og-image.png" />
|
||||
|
||||
<!-- Additional SEO -->
|
||||
<meta name="theme-color" content="#8b5cf6" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,49 @@
|
||||
[build]
|
||||
command = "npm run build"
|
||||
publish = "dist"
|
||||
|
||||
# SPA redirect - must come AFTER specific file rules
|
||||
# This catches all routes and sends them to index.html for client-side routing
|
||||
[[redirects]]
|
||||
from = "/*"
|
||||
to = "/index.html"
|
||||
status = 200
|
||||
|
||||
# CORS headers for widget files
|
||||
[[headers]]
|
||||
for = "/widget.js"
|
||||
[headers.values]
|
||||
Access-Control-Allow-Origin = "*"
|
||||
Access-Control-Allow-Methods = "GET, OPTIONS"
|
||||
Access-Control-Allow-Headers = "Content-Type"
|
||||
Cache-Control = "public, max-age=31536000, immutable"
|
||||
Content-Type = "application/javascript; charset=utf-8"
|
||||
|
||||
[[headers]]
|
||||
for = "/widget.css"
|
||||
[headers.values]
|
||||
Access-Control-Allow-Origin = "*"
|
||||
Access-Control-Allow-Methods = "GET, OPTIONS"
|
||||
Access-Control-Allow-Headers = "Content-Type"
|
||||
Cache-Control = "public, max-age=31536000, immutable"
|
||||
Content-Type = "text/css; charset=utf-8"
|
||||
|
||||
[[headers]]
|
||||
for = "/widget-embed.html"
|
||||
[headers.values]
|
||||
Access-Control-Allow-Origin = "*"
|
||||
X-Frame-Options = "ALLOWALL"
|
||||
Content-Security-Policy = "frame-ancestors *"
|
||||
|
||||
# General security headers for the main app
|
||||
[[headers]]
|
||||
for = "/*"
|
||||
[headers.values]
|
||||
X-Content-Type-Options = "nosniff"
|
||||
Referrer-Policy = "strict-origin-when-cross-origin"
|
||||
|
||||
# Cache static assets
|
||||
[[headers]]
|
||||
for = "/assets/*"
|
||||
[headers.values]
|
||||
Cache-Control = "public, max-age=31536000, immutable"
|
||||
Generated
+7426
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "@ruflo/research",
|
||||
"description": "RuFlo Research — Goal-Oriented Action Planning UI for autonomous AI research workflows",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "npm run build:widget-only && npm run copy:widget && vite build && npm run copy:widget-to-dist",
|
||||
"build:app": "vite build",
|
||||
"build:dev": "vite build --mode development",
|
||||
"build:widget-only": "BUILD_WIDGET=true vite build",
|
||||
"build:widget": "npm run build:widget-only && npm run copy:widget",
|
||||
"copy:widget": "cp dist/widget.js public/ && cp dist/widget.css public/",
|
||||
"copy:widget-to-dist": "cp public/widget.js dist/ && cp public/widget.css dist/",
|
||||
"widget:dev": "npm run build:widget && npm run dev",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.10.0",
|
||||
"@radix-ui/react-accordion": "^1.2.11",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.14",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
||||
"@radix-ui/react-avatar": "^1.1.10",
|
||||
"@radix-ui/react-checkbox": "^1.3.2",
|
||||
"@radix-ui/react-collapsible": "^1.1.11",
|
||||
"@radix-ui/react-context-menu": "^2.2.15",
|
||||
"@radix-ui/react-dialog": "^1.1.14",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||
"@radix-ui/react-hover-card": "^1.1.14",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-menubar": "^1.1.15",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.13",
|
||||
"@radix-ui/react-popover": "^1.1.14",
|
||||
"@radix-ui/react-progress": "^1.1.7",
|
||||
"@radix-ui/react-radio-group": "^1.3.7",
|
||||
"@radix-ui/react-scroll-area": "^1.2.9",
|
||||
"@radix-ui/react-select": "^2.2.5",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slider": "^1.3.5",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-switch": "^1.2.5",
|
||||
"@radix-ui/react-tabs": "^1.1.12",
|
||||
"@radix-ui/react-toast": "^1.2.14",
|
||||
"@radix-ui/react-toggle": "^1.1.9",
|
||||
"@radix-ui/react-toggle-group": "^1.1.10",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@supabase/supabase-js": "^2.74.0",
|
||||
"@tanstack/react-query": "^5.83.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^0.462.0",
|
||||
"next-themes": "^0.3.0",
|
||||
"react": "^18.3.1",
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-hook-form": "^7.61.1",
|
||||
"react-resizable-panels": "^2.1.9",
|
||||
"react-router-dom": "^6.30.1",
|
||||
"reactflow": "^11.11.4",
|
||||
"recharts": "^2.15.4",
|
||||
"sonner": "^1.7.4",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"vaul": "^0.9.9",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.32.0",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/node": "^22.16.5",
|
||||
"@types/react": "^18.3.23",
|
||||
"@types/react-dom": "^18.3.7",
|
||||
"@vitejs/plugin-react-swc": "^3.11.0",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"globals": "^15.15.0",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.38.0",
|
||||
"vite": "^5.4.19"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
# CORS headers for widget files to allow embedding in third-party sites
|
||||
/widget.js
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, OPTIONS
|
||||
Access-Control-Allow-Headers: Content-Type
|
||||
Cache-Control: public, max-age=31536000
|
||||
Content-Type: application/javascript
|
||||
|
||||
/widget.css
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, OPTIONS
|
||||
Access-Control-Allow-Headers: Content-Type
|
||||
Cache-Control: public, max-age=31536000
|
||||
Content-Type: text/css
|
||||
|
||||
# Allow widget-embed.html to be iframed
|
||||
/widget-embed.html
|
||||
Access-Control-Allow-Origin: *
|
||||
X-Frame-Options: ALLOWALL
|
||||
Content-Security-Policy: frame-ancestors *
|
||||
|
||||
# API endpoints - if using Supabase functions
|
||||
/api/*
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
|
||||
Access-Control-Allow-Headers: Content-Type, Authorization
|
||||
@@ -0,0 +1,8 @@
|
||||
# Widget files should be served directly (not redirected to SPA)
|
||||
/widget.js /widget.js 200
|
||||
/widget.css /widget.css 200
|
||||
/widget-embed.html /widget-embed.html 200
|
||||
/_headers /_headers 200
|
||||
|
||||
# SPA fallback - all other routes go to index.html for client-side routing
|
||||
/* /index.html 200
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
|
||||
<path d="M16 2L30 10v12L16 30 2 22V10z" stroke="#7c3aed" stroke-width="2" fill="#ffffff"/>
|
||||
<circle cx="16" cy="16" r="5" fill="#00d4ff"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 222 B |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,14 @@
|
||||
User-agent: Googlebot
|
||||
Allow: /
|
||||
|
||||
User-agent: Bingbot
|
||||
Allow: /
|
||||
|
||||
User-agent: Twitterbot
|
||||
Allow: /
|
||||
|
||||
User-agent: facebookexternalhit
|
||||
Allow: /
|
||||
|
||||
User-agent: *
|
||||
Allow: /
|
||||
@@ -0,0 +1,146 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>RuFlo Research Widget Embed Example</title>
|
||||
<meta name="description" content="Example of embedding RuFlo Research Widget on third-party sites">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
background: #0a0a0a;
|
||||
color: #fff;
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
h1 {
|
||||
margin: 0 0 0.5rem;
|
||||
font-size: 2rem;
|
||||
}
|
||||
p {
|
||||
color: #a3a3a3;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
.instructions {
|
||||
max-width: 800px;
|
||||
margin: 0 auto 2rem;
|
||||
padding: 1rem;
|
||||
background: #1a1a1a;
|
||||
border: 1px solid #333;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.instructions h2 {
|
||||
margin: 0 0 1rem;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
.instructions code {
|
||||
background: #262626;
|
||||
padding: 0.2rem 0.4rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.instructions pre {
|
||||
background: #262626;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
overflow-x: auto;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
#ruflo-research-widget-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
min-height: 400px;
|
||||
}
|
||||
.alert {
|
||||
padding: 1rem;
|
||||
margin: 1rem auto;
|
||||
max-width: 800px;
|
||||
background: #1a3a1a;
|
||||
border: 1px solid #22c55e;
|
||||
border-radius: 8px;
|
||||
color: #22c55e;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>🎯 RuFlo Research Widget</h1>
|
||||
<p>Goal-Oriented Action Planning for AI Research</p>
|
||||
<p style="font-size: 0.9rem;">Embedded Widget Example</p>
|
||||
</div>
|
||||
|
||||
<div class="instructions">
|
||||
<h2>📦 How to Embed This Widget</h2>
|
||||
<p>Copy and paste this code into your website:</p>
|
||||
<pre><code><!-- RuFlo Research Widget Container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- Optional: Configuration -->
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6",
|
||||
accentColor: "#22c55e",
|
||||
backgroundColor: "#1a1a1a",
|
||||
defaultGoal: "Your default research goal"
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Load Widget (replace YOUR-DOMAIN with your actual domain) -->
|
||||
<link rel="stylesheet" href="https://YOUR-DOMAIN/widget.css">
|
||||
<script src="https://YOUR-DOMAIN/widget.js"></script></code></pre>
|
||||
</div>
|
||||
|
||||
<div class="alert">
|
||||
✨ Widget is loading below. If you don't see it, check the browser console for errors.
|
||||
</div>
|
||||
|
||||
<!-- Widget Container -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
|
||||
<!-- Widget Configuration (Optional) -->
|
||||
<script>
|
||||
// Configuration for the RuFlo Research Widget
|
||||
// All properties are optional - widget will use defaults if not specified
|
||||
window.RufloResearchWidgetConfig = {
|
||||
primaryColor: "#8b5cf6", // Purple - main brand color
|
||||
accentColor: "#22c55e", // Green - success/accent color
|
||||
backgroundColor: "#1a1a1a", // Dark background
|
||||
cardBackgroundColor: "#262626", // Card backgrounds
|
||||
textColor: "#ffffff", // Primary text color
|
||||
fontFamily: "system-ui", // Font family
|
||||
defaultGoal: "Research the latest advancements in quantum computing"
|
||||
};
|
||||
|
||||
// Log when widget is ready
|
||||
window.addEventListener('load', function() {
|
||||
if (window.RufloResearchWidget) {
|
||||
console.log('✅ RuFlo Research Widget loaded successfully!');
|
||||
console.log('Widget version:', window.RufloResearchWidget.version);
|
||||
} else {
|
||||
console.error('❌ RuFlo Research Widget failed to load');
|
||||
}
|
||||
});
|
||||
|
||||
// Error handling for widget script loading
|
||||
window.addEventListener('error', function(e) {
|
||||
if (e.filename && e.filename.includes('widget.js')) {
|
||||
console.error('Failed to load widget.js:', e.message);
|
||||
document.getElementById('ruflo-research-widget-container').innerHTML =
|
||||
'<div style="padding: 2rem; text-align: center; color: #ef4444;">' +
|
||||
'⚠️ Failed to load RuFlo Research Widget. Please check console for details.' +
|
||||
'</div>';
|
||||
}
|
||||
}, true);
|
||||
</script>
|
||||
|
||||
<!-- Load Widget CSS -->
|
||||
<link rel="stylesheet" href="/widget.css" onerror="console.error('Failed to load widget.css')">
|
||||
|
||||
<!-- Load Widget Script -->
|
||||
<script src="/widget.js" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,42 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import Index from "./pages/Index";
|
||||
import Demo from "./pages/Demo";
|
||||
import Agents from "./pages/Agents";
|
||||
import NotFound from "./pages/NotFound";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const App = () => (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TooltipProvider>
|
||||
<Toaster />
|
||||
<Sonner />
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Index />} />
|
||||
<Route path="/demo" element={<Demo />} />
|
||||
<Route path="/agents" element={<Agents />} />
|
||||
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</TooltipProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,343 @@
|
||||
import { LucideIcon, ChevronRight, Loader2, ChevronDown } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
export type StepStatus = "pending" | "active" | "completed" | "error";
|
||||
|
||||
interface DataItem {
|
||||
text: string;
|
||||
icon?: LucideIcon;
|
||||
details?: {
|
||||
objective?: string;
|
||||
sources?: string[];
|
||||
citations?: string[];
|
||||
agents?: string[];
|
||||
preconditions?: string[];
|
||||
effects?: string[];
|
||||
source?: string;
|
||||
confidence?: number;
|
||||
timestamp?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface AgentStepProps {
|
||||
title: string;
|
||||
description: string;
|
||||
icon: LucideIcon;
|
||||
status: StepStatus;
|
||||
delay?: number;
|
||||
data?: DataItem[];
|
||||
metrics?: { label: string; value: string }[];
|
||||
primaryColor?: string;
|
||||
accentColor?: string;
|
||||
cardBackgroundColor?: string;
|
||||
cardBorderColor?: string;
|
||||
textColor?: string;
|
||||
secondaryTextColor?: string;
|
||||
successColor?: string;
|
||||
borderRadius?: string;
|
||||
animationSpeed?: string;
|
||||
compactMode?: boolean;
|
||||
}
|
||||
|
||||
export const AgentStep = ({
|
||||
title,
|
||||
description,
|
||||
icon: Icon,
|
||||
status,
|
||||
delay = 0,
|
||||
data = [],
|
||||
metrics = [],
|
||||
primaryColor = "#6b7280",
|
||||
accentColor = "#22c55e",
|
||||
cardBackgroundColor = "#262626",
|
||||
cardBorderColor = "#404040",
|
||||
textColor = "#ffffff",
|
||||
secondaryTextColor = "#a3a3a3",
|
||||
successColor = "#22c55e",
|
||||
borderRadius = "0.5rem",
|
||||
animationSpeed = "normal",
|
||||
compactMode = false,
|
||||
}: AgentStepProps) => {
|
||||
const [loadingItems, setLoadingItems] = useState<Set<number>>(new Set());
|
||||
const [completedItems, setCompletedItems] = useState<Set<number>>(new Set());
|
||||
const [expandedItems, setExpandedItems] = useState<Set<number>>(new Set());
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "active" && data.length > 0) {
|
||||
// Reset states when step becomes active
|
||||
setLoadingItems(new Set());
|
||||
setCompletedItems(new Set());
|
||||
|
||||
// Simulate loading each item
|
||||
data.forEach((_, idx) => {
|
||||
setTimeout(() => {
|
||||
setLoadingItems(prev => new Set([...prev, idx]));
|
||||
|
||||
// Complete item after 800ms
|
||||
setTimeout(() => {
|
||||
setLoadingItems(prev => {
|
||||
const next = new Set(prev);
|
||||
next.delete(idx);
|
||||
return next;
|
||||
});
|
||||
setCompletedItems(prev => new Set([...prev, idx]));
|
||||
}, 800);
|
||||
}, idx * 150);
|
||||
});
|
||||
} else if (status === "completed") {
|
||||
// All items completed
|
||||
setCompletedItems(new Set(data.map((_, idx) => idx)));
|
||||
setLoadingItems(new Set());
|
||||
}
|
||||
}, [status, data.length]);
|
||||
|
||||
const animationDuration = animationSpeed === "fast" ? "250ms" : animationSpeed === "slow" ? "750ms" : "500ms";
|
||||
const padding = compactMode ? "0.75rem" : "1.25rem";
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"relative group animate-slide-up opacity-0",
|
||||
"border bg-card",
|
||||
"transition-all",
|
||||
status === "pending" && "border-border",
|
||||
)}
|
||||
style={{
|
||||
animationDelay: `${delay}ms`,
|
||||
animationFillMode: "forwards",
|
||||
borderColor: status === "active" ? `${primaryColor}80` : status === "completed" ? `${successColor}4d` : cardBorderColor,
|
||||
backgroundColor: status === "completed" ? `${successColor}0d` : cardBackgroundColor,
|
||||
boxShadow: status === "active" ? `0 4px 12px ${primaryColor}33` : undefined,
|
||||
borderRadius,
|
||||
padding,
|
||||
transitionDuration: animationDuration,
|
||||
}}
|
||||
>
|
||||
{/* Status indicator */}
|
||||
<div className="absolute -left-2 sm:-left-3 top-1/2 -translate-y-1/2">
|
||||
<div
|
||||
className="w-4 h-4 sm:w-5 sm:h-5 rounded-full border-3 border-background transition-all duration-500"
|
||||
style={{
|
||||
backgroundColor: status === "pending" ? cardBorderColor : status === "active" ? primaryColor : status === "completed" ? successColor : cardBorderColor,
|
||||
animation: status === "active" ? "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite" : undefined,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-2 sm:gap-4">
|
||||
{/* Icon */}
|
||||
<div
|
||||
className="p-1.5 sm:p-2.5 rounded-md transition-all duration-500 flex-shrink-0"
|
||||
style={{
|
||||
backgroundColor: status === "pending" ? `${cardBorderColor}40` : status === "active" ? `${primaryColor}1a` : status === "completed" ? `${successColor}33` : `${cardBorderColor}40`,
|
||||
color: status === "pending" ? secondaryTextColor : status === "active" ? primaryColor : status === "completed" ? successColor : secondaryTextColor,
|
||||
}}
|
||||
>
|
||||
{status === "active" ? (
|
||||
<Loader2 className="w-4 h-4 sm:w-5 sm:h-5 animate-spin" style={{ color: primaryColor }} />
|
||||
) : (
|
||||
<Icon className="w-4 h-4 sm:w-5 sm:h-5" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3
|
||||
className="font-medium mb-1"
|
||||
style={{ fontSize: compactMode ? "0.875rem" : "1rem", color: textColor }}
|
||||
>
|
||||
{title}
|
||||
</h3>
|
||||
<p
|
||||
className="text-sm"
|
||||
style={{ color: secondaryTextColor, fontSize: compactMode ? "0.75rem" : "0.875rem" }}
|
||||
>
|
||||
{description}
|
||||
</p>
|
||||
|
||||
{/* Progress indicator for active state */}
|
||||
{status === "active" && (
|
||||
<div className="mt-2.5 h-0.5 bg-muted rounded-full overflow-hidden">
|
||||
<div
|
||||
className="h-full transition-all duration-1000 ease-out"
|
||||
style={{
|
||||
width: `${(completedItems.size / data.length) * 100}%`,
|
||||
backgroundColor: `${primaryColor}99`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Data display for active/completed states */}
|
||||
{(status === "active" || status === "completed") && data.length > 0 && (
|
||||
<div className="mt-3 space-y-1.5">
|
||||
{data.map((item, idx) => {
|
||||
const ItemIcon = item.icon || ChevronRight;
|
||||
const isLoading = loadingItems.has(idx);
|
||||
const isCompleted = completedItems.has(idx);
|
||||
const isExpanded = expandedItems.has(idx);
|
||||
const hasDetails = !!item.details;
|
||||
|
||||
return (
|
||||
<div key={idx} className="space-y-1">
|
||||
<div
|
||||
onClick={() => {
|
||||
if (hasDetails && isCompleted) {
|
||||
setExpandedItems(prev => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(idx)) next.delete(idx);
|
||||
else next.add(idx);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
}}
|
||||
className={cn(
|
||||
"text-xs flex items-center gap-1.5 transition-all duration-500",
|
||||
"opacity-0 -translate-x-4",
|
||||
"animate-fade-in",
|
||||
hasDetails && isCompleted && "cursor-pointer hover:bg-muted/20 rounded px-1 -mx-1 py-0.5"
|
||||
)}
|
||||
style={{
|
||||
animationDelay: `${idx * 150}ms`,
|
||||
animationFillMode: "forwards",
|
||||
transform: isCompleted ? 'translateX(0) scale(1.05)' : isLoading ? 'translateX(0) scale(1.02)' : 'translateX(0)',
|
||||
color: isCompleted ? successColor : isLoading ? primaryColor : secondaryTextColor,
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
<Loader2 className="w-3 h-3 flex-shrink-0 animate-spin" style={{ color: primaryColor }} />
|
||||
) : (
|
||||
<ItemIcon
|
||||
className="w-3 h-3 flex-shrink-0 transition-all duration-300"
|
||||
style={{
|
||||
animation: isCompleted ? "bounce 0.5s ease-in-out 2" : undefined,
|
||||
color: isCompleted ? successColor : undefined,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
className={cn(
|
||||
"transition-all duration-300 flex-1",
|
||||
isLoading && "animate-pulse"
|
||||
)}
|
||||
style={{ fontWeight: isCompleted ? 500 : undefined }}
|
||||
>
|
||||
{item.text}
|
||||
</span>
|
||||
{isCompleted && (
|
||||
<>
|
||||
<span className="text-[10px]" style={{ color: successColor }}>✓</span>
|
||||
{hasDetails && (
|
||||
<ChevronDown className={cn(
|
||||
"w-3 h-3 transition-transform duration-200",
|
||||
isExpanded && "rotate-180"
|
||||
)} style={{ color: successColor }} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Expanded Details */}
|
||||
{hasDetails && isCompleted && (
|
||||
<div
|
||||
className={cn(
|
||||
"ml-5 pl-3 border-l space-y-2 text-[11px] overflow-hidden transition-all duration-300 ease-in-out origin-top",
|
||||
isExpanded ? "max-h-96 opacity-100 scale-y-100 mt-1.5" : "max-h-0 opacity-0 scale-y-0"
|
||||
)}
|
||||
style={{ borderColor: `${successColor}4d` }}
|
||||
>
|
||||
{item.details.objective && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "50ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Objective:</span>
|
||||
<p className="text-foreground/80 mt-0.5">{item.details.objective}</p>
|
||||
</div>
|
||||
)}
|
||||
{item.details.preconditions && item.details.preconditions.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "100ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Preconditions:</span>
|
||||
<ul className="text-foreground/80 mt-0.5 space-y-0.5">
|
||||
{item.details.preconditions.map((p, i) => (
|
||||
<li key={i}>• {p}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{item.details.effects && item.details.effects.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "150ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Effects:</span>
|
||||
<ul className="text-foreground/80 mt-0.5 space-y-0.5">
|
||||
{item.details.effects.map((e, i) => (
|
||||
<li key={i}>• {e}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{item.details.agents && item.details.agents.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "200ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Agents:</span>
|
||||
<div className="flex flex-wrap gap-1 mt-0.5">
|
||||
{item.details.agents.map((a, i) => (
|
||||
<span key={i} className="bg-muted/50 px-1.5 py-0.5 rounded text-foreground/80">{a}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{item.details.sources && item.details.sources.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "250ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Sources:</span>
|
||||
<ul className="text-foreground/80 mt-0.5 space-y-0.5">
|
||||
{item.details.sources.map((s, i) => (
|
||||
<li key={i}>• {s}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{item.details.citations && item.details.citations.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "300ms" }}>
|
||||
<span className="text-muted-foreground font-medium">Citations:</span>
|
||||
<ul className="text-foreground/80 mt-0.5 space-y-0.5">
|
||||
{item.details.citations.map((c, i) => (
|
||||
<li key={i} className="italic">"{c}"</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Metrics for completed state */}
|
||||
{status === "completed" && metrics.length > 0 && (
|
||||
<div className="mt-3 flex gap-4 animate-fade-in">
|
||||
{metrics.map((metric, idx) => (
|
||||
<div key={idx} className="flex items-center gap-1.5 text-xs">
|
||||
<span className="text-muted-foreground">{metric.label}:</span>
|
||||
<span className="text-foreground font-medium">{metric.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Status badge */}
|
||||
<div
|
||||
className="text-[10px] sm:text-xs font-medium px-1.5 sm:px-2 py-0.5 rounded transition-all duration-500 flex-shrink-0"
|
||||
style={{
|
||||
backgroundColor: status === "pending" ? `${cardBorderColor}40` : status === "active" ? `${primaryColor}1a` : status === "completed" ? `${successColor}33` : `${cardBorderColor}40`,
|
||||
color: status === "pending" ? secondaryTextColor : status === "active" ? primaryColor : status === "completed" ? successColor : secondaryTextColor,
|
||||
}}
|
||||
>
|
||||
{status === "pending" && "Pending"}
|
||||
{status === "active" && "Researching..."}
|
||||
{status === "completed" && "Complete"}
|
||||
{status === "error" && "Error"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,294 @@
|
||||
import { LucideIcon, ChevronRight, Loader2, ChevronDown } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
export type StepStatus = "pending" | "active" | "completed" | "error";
|
||||
|
||||
interface DataItem {
|
||||
text: string;
|
||||
icon?: LucideIcon;
|
||||
details?: {
|
||||
objective?: string;
|
||||
files?: string[];
|
||||
agents?: string[];
|
||||
preconditions?: string[];
|
||||
effects?: string[];
|
||||
metrics?: { label: string; value: string }[];
|
||||
};
|
||||
}
|
||||
|
||||
interface DevelopmentStepProps {
|
||||
title: string;
|
||||
description: string;
|
||||
icon: LucideIcon;
|
||||
status: StepStatus;
|
||||
delay?: number;
|
||||
data?: DataItem[];
|
||||
metrics?: { label: string; value: string }[];
|
||||
}
|
||||
|
||||
export const DevelopmentStep = ({
|
||||
title,
|
||||
description,
|
||||
icon: Icon,
|
||||
status,
|
||||
delay = 0,
|
||||
data = [],
|
||||
metrics = [],
|
||||
}: DevelopmentStepProps) => {
|
||||
const [loadingItems, setLoadingItems] = useState<Set<number>>(new Set());
|
||||
const [completedItems, setCompletedItems] = useState<Set<number>>(new Set());
|
||||
const [expandedItems, setExpandedItems] = useState<Set<number>>(new Set());
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "active" && data.length > 0) {
|
||||
setLoadingItems(new Set());
|
||||
setCompletedItems(new Set());
|
||||
|
||||
data.forEach((_, idx) => {
|
||||
setTimeout(() => {
|
||||
setLoadingItems(prev => new Set([...prev, idx]));
|
||||
|
||||
setTimeout(() => {
|
||||
setLoadingItems(prev => {
|
||||
const next = new Set(prev);
|
||||
next.delete(idx);
|
||||
return next;
|
||||
});
|
||||
setCompletedItems(prev => new Set([...prev, idx]));
|
||||
}, 1200);
|
||||
}, idx * 200);
|
||||
});
|
||||
} else if (status === "completed") {
|
||||
setCompletedItems(new Set(data.map((_, idx) => idx)));
|
||||
setLoadingItems(new Set());
|
||||
}
|
||||
}, [status, data.length]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"relative group animate-slide-up opacity-0 border-l-4 rounded-r-lg overflow-hidden",
|
||||
"transition-all duration-500",
|
||||
status === "pending" && "border-l-border bg-card/50",
|
||||
status === "active" && "border-l-primary bg-primary/5 shadow-lg shadow-primary/20",
|
||||
status === "completed" && "border-l-green-500 bg-green-500/5"
|
||||
)}
|
||||
style={{
|
||||
animationDelay: `${delay}ms`,
|
||||
animationFillMode: "forwards",
|
||||
}}
|
||||
>
|
||||
<div className="p-5">
|
||||
<div className="flex items-start gap-4 mb-4">
|
||||
{/* Icon with different styling */}
|
||||
<div
|
||||
className={cn(
|
||||
"p-3 rounded-xl transition-all duration-500 flex-shrink-0 shadow-md",
|
||||
status === "pending" && "bg-muted/50 text-muted-foreground",
|
||||
status === "active" && "bg-primary/20 text-primary ring-2 ring-primary/30",
|
||||
status === "completed" && "bg-green-500/20 text-green-500"
|
||||
)}
|
||||
>
|
||||
{status === "active" ? (
|
||||
<Loader2 className="w-6 h-6 animate-spin" />
|
||||
) : (
|
||||
<Icon className="w-6 h-6" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center justify-between gap-2 mb-1">
|
||||
<h3 className="font-semibold text-lg text-foreground">
|
||||
{title}
|
||||
</h3>
|
||||
<div
|
||||
className={cn(
|
||||
"text-xs font-medium px-3 py-1 rounded-full whitespace-nowrap",
|
||||
status === "pending" && "bg-muted text-muted-foreground",
|
||||
status === "active" && "bg-primary/20 text-primary animate-pulse",
|
||||
status === "completed" && "bg-green-500/20 text-green-500"
|
||||
)}
|
||||
>
|
||||
{status === "pending" && "Queued"}
|
||||
{status === "active" && "Building..."}
|
||||
{status === "completed" && "Done"}
|
||||
{status === "error" && "Failed"}
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Progress bar for active state */}
|
||||
{status === "active" && (
|
||||
<div className="mb-4 h-1 bg-primary/20 rounded-full overflow-hidden">
|
||||
<div
|
||||
className="h-full bg-primary transition-all duration-1000 ease-out rounded-full"
|
||||
style={{
|
||||
width: `${(completedItems.size / data.length) * 100}%`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Task items with different styling */}
|
||||
{(status === "active" || status === "completed") && data.length > 0 && (
|
||||
<div className="space-y-2 pl-2">
|
||||
{data.map((item, idx) => {
|
||||
const ItemIcon = item.icon || ChevronRight;
|
||||
const isLoading = loadingItems.has(idx);
|
||||
const isCompleted = completedItems.has(idx);
|
||||
const isExpanded = expandedItems.has(idx);
|
||||
const hasDetails = !!item.details;
|
||||
|
||||
return (
|
||||
<div key={idx} className="space-y-2">
|
||||
<div
|
||||
onClick={() => {
|
||||
if (hasDetails && isCompleted) {
|
||||
setExpandedItems(prev => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(idx)) next.delete(idx);
|
||||
else next.add(idx);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
}}
|
||||
className={cn(
|
||||
"flex items-center gap-2 p-2 rounded-lg transition-all duration-500",
|
||||
"opacity-0 animate-fade-in border",
|
||||
isCompleted && "bg-green-500/5 border-green-500/20",
|
||||
isLoading && "bg-primary/5 border-primary/20",
|
||||
!isLoading && !isCompleted && "bg-muted/30 border-transparent",
|
||||
hasDetails && isCompleted && "cursor-pointer hover:bg-green-500/10"
|
||||
)}
|
||||
style={{
|
||||
animationDelay: `${idx * 200}ms`,
|
||||
animationFillMode: "forwards",
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
<Loader2 className="w-4 h-4 flex-shrink-0 animate-spin text-primary" />
|
||||
) : (
|
||||
<ItemIcon
|
||||
className={cn(
|
||||
"w-4 h-4 flex-shrink-0 transition-all duration-300",
|
||||
isCompleted && "text-green-500"
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
className={cn(
|
||||
"text-sm flex-1 transition-all duration-300",
|
||||
isCompleted && "text-foreground font-medium",
|
||||
isLoading && "text-primary animate-pulse",
|
||||
!isLoading && !isCompleted && "text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
{item.text}
|
||||
</span>
|
||||
{isCompleted && (
|
||||
<>
|
||||
<div className="w-5 h-5 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0">
|
||||
<span className="text-white text-xs">✓</span>
|
||||
</div>
|
||||
{hasDetails && (
|
||||
<ChevronDown className={cn(
|
||||
"w-4 h-4 transition-transform duration-200 text-green-500",
|
||||
isExpanded && "rotate-180"
|
||||
)} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Expanded Details with different styling */}
|
||||
{hasDetails && isCompleted && (
|
||||
<div
|
||||
className={cn(
|
||||
"ml-8 p-3 rounded-lg bg-muted/30 border border-green-500/20 space-y-2.5 text-xs overflow-hidden transition-all duration-300 ease-in-out origin-top",
|
||||
isExpanded ? "max-h-96 opacity-100 scale-y-100" : "max-h-0 opacity-0 scale-y-0 p-0 border-0"
|
||||
)}
|
||||
>
|
||||
{item.details.objective && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "50ms" }}>
|
||||
<span className="text-primary font-semibold">Objective:</span>
|
||||
<p className="text-foreground/90 mt-1">{item.details.objective}</p>
|
||||
</div>
|
||||
)}
|
||||
{item.details.files && item.details.files.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "100ms" }}>
|
||||
<span className="text-primary font-semibold">Files Modified:</span>
|
||||
<div className="mt-1 space-y-1">
|
||||
{item.details.files.map((f, i) => (
|
||||
<div key={i} className="font-mono text-[11px] text-foreground/80 bg-background/50 px-2 py-1 rounded">
|
||||
{f}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{item.details.effects && item.details.effects.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "150ms" }}>
|
||||
<span className="text-primary font-semibold">Completed:</span>
|
||||
<ul className="text-foreground/80 mt-1 space-y-1">
|
||||
{item.details.effects.map((e, i) => (
|
||||
<li key={i} className="flex items-start gap-2">
|
||||
<span className="text-green-500 mt-0.5">✓</span>
|
||||
<span>{e}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{item.details.agents && item.details.agents.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "200ms" }}>
|
||||
<span className="text-primary font-semibold">Agents:</span>
|
||||
<div className="flex flex-wrap gap-1.5 mt-1">
|
||||
{item.details.agents.map((a, i) => (
|
||||
<span key={i} className="bg-primary/10 text-primary px-2 py-1 rounded-md font-medium">
|
||||
{a}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{item.details.metrics && item.details.metrics.length > 0 && (
|
||||
<div className="animate-fade-in" style={{ animationDelay: "250ms" }}>
|
||||
<span className="text-primary font-semibold">Metrics:</span>
|
||||
<div className="flex flex-wrap gap-3 mt-1">
|
||||
{item.details.metrics.map((m, i) => (
|
||||
<div key={i} className="flex items-center gap-1.5">
|
||||
<span className="text-muted-foreground">{m.label}:</span>
|
||||
<span className="text-foreground font-semibold">{m.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Summary metrics for completed state */}
|
||||
{status === "completed" && metrics.length > 0 && (
|
||||
<div className="mt-4 pt-4 border-t border-green-500/20 flex gap-6 animate-fade-in">
|
||||
{metrics.map((metric, idx) => (
|
||||
<div key={idx} className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{metric.label}:</span>
|
||||
<span className="text-sm text-foreground font-semibold">{metric.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Settings, Zap, Shield, RefreshCw } from "lucide-react";
|
||||
|
||||
interface GOAPConfigDisplayProps {
|
||||
executionMode: "focused" | "closed" | "open";
|
||||
enableReplanning: boolean;
|
||||
replanningTriggers: string[];
|
||||
costOptimization: boolean;
|
||||
parallelExecution: boolean;
|
||||
maxActionCost: number;
|
||||
primaryColor: string;
|
||||
}
|
||||
|
||||
export const GOAPConfigDisplay = ({
|
||||
executionMode,
|
||||
enableReplanning,
|
||||
replanningTriggers,
|
||||
costOptimization,
|
||||
parallelExecution,
|
||||
maxActionCost,
|
||||
primaryColor,
|
||||
}: GOAPConfigDisplayProps) => {
|
||||
const modeDescriptions = {
|
||||
focused: "Direct action execution with precondition checking",
|
||||
closed: "Single-domain planning with type safety",
|
||||
open: "Creative problem solving across all domains",
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="border" style={{ borderColor: `${primaryColor}40` }}>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-base">
|
||||
<Settings className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
GOAP Configuration
|
||||
</CardTitle>
|
||||
<CardDescription className="text-xs">
|
||||
Active planning and execution settings
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-medium">Execution Mode</span>
|
||||
<Badge variant="outline" className="text-xs capitalize">
|
||||
{executionMode}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{modeDescriptions[executionMode]}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2 pt-2 border-t">
|
||||
<div className="flex items-center gap-2">
|
||||
{costOptimization ? (
|
||||
<Zap className="w-3 h-3 text-yellow-500" />
|
||||
) : (
|
||||
<Zap className="w-3 h-3 text-muted-foreground" />
|
||||
)}
|
||||
<span className="text-xs">Cost Optimization</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{parallelExecution ? (
|
||||
<RefreshCw className="w-3 h-3 text-blue-500" />
|
||||
) : (
|
||||
<RefreshCw className="w-3 h-3 text-muted-foreground" />
|
||||
)}
|
||||
<span className="text-xs">Parallel Execution</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{enableReplanning ? (
|
||||
<Shield className="w-3 h-3 text-green-500" />
|
||||
) : (
|
||||
<Shield className="w-3 h-3 text-muted-foreground" />
|
||||
)}
|
||||
<span className="text-xs">Replanning Enabled</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs font-mono">Max Cost: {maxActionCost}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{enableReplanning && replanningTriggers.length > 0 && (
|
||||
<div className="space-y-2 pt-2 border-t">
|
||||
<span className="text-xs font-medium">Active Triggers ({replanningTriggers.length})</span>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{replanningTriggers.map((trigger) => (
|
||||
<Badge key={trigger} variant="secondary" className="text-xs">
|
||||
{trigger}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,185 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Target, Sparkles, Settings, TrendingUp, Building2, Heart, GraduationCap, Code, Cpu, Brain, Megaphone } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { supabase } from "@/integrations/supabase/client";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
|
||||
interface GoalInputProps {
|
||||
onSubmit: (goal: string) => void;
|
||||
isPlanning: boolean;
|
||||
onAdvancedSettings?: () => void;
|
||||
onConfigUpdate?: (config: any) => void;
|
||||
}
|
||||
|
||||
export const GoalInput = ({ onSubmit, isPlanning, onAdvancedSettings, onConfigUpdate }: GoalInputProps) => {
|
||||
const [goal, setGoal] = useState("");
|
||||
const [isGenerating, setIsGenerating] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (goal.trim()) {
|
||||
onSubmit(goal.trim());
|
||||
}
|
||||
};
|
||||
|
||||
const categoryToPresetMap: Record<string, string> = {
|
||||
'finance': 'market-trends',
|
||||
'business': 'startup-validation',
|
||||
'marketing': 'competitive-analysis',
|
||||
'medical': 'medical-clinical',
|
||||
'education': 'academic-deep',
|
||||
'coding': 'technical-feasibility',
|
||||
'technical': 'technical-feasibility',
|
||||
'ai-ml': 'technical-feasibility',
|
||||
};
|
||||
|
||||
const categories = [
|
||||
{ id: 'finance', label: 'Finance', icon: TrendingUp, color: '#10b981' },
|
||||
{ id: 'business', label: 'Business', icon: Building2, color: '#3b82f6' },
|
||||
{ id: 'marketing', label: 'Marketing', icon: Megaphone, color: '#f97316' },
|
||||
{ id: 'medical', label: 'Medical', icon: Heart, color: '#ef4444' },
|
||||
{ id: 'education', label: 'Education', icon: GraduationCap, color: '#f59e0b' },
|
||||
{ id: 'coding', label: 'Coding', icon: Code, color: '#8b5cf6' },
|
||||
{ id: 'technical', label: 'Technical', icon: Cpu, color: '#06b6d4' },
|
||||
{ id: 'ai-ml', label: 'AI & ML', icon: Brain, color: '#ec4899' },
|
||||
];
|
||||
|
||||
const generateGoals = async (category: string) => {
|
||||
setIsGenerating(true);
|
||||
try {
|
||||
// Generate goal and optimize config in parallel
|
||||
const [goalResult, configResult] = await Promise.all([
|
||||
supabase.functions.invoke('generate-research-goal', {
|
||||
body: { category }
|
||||
}),
|
||||
supabase.functions.invoke('optimize-research-config', {
|
||||
body: {
|
||||
preset: categoryToPresetMap[category] || 'academic-deep',
|
||||
currentGoal: ''
|
||||
}
|
||||
})
|
||||
]);
|
||||
|
||||
if (goalResult.error) throw goalResult.error;
|
||||
|
||||
if (goalResult.data?.goals && goalResult.data.goals.length > 0) {
|
||||
// Set the first generated goal
|
||||
setGoal(goalResult.data.goals[0]);
|
||||
|
||||
// Update config if available and callback provided
|
||||
if (configResult.data?.config && onConfigUpdate) {
|
||||
onConfigUpdate(configResult.data.config);
|
||||
}
|
||||
|
||||
toast({
|
||||
title: "Goal & Settings Optimized",
|
||||
description: `Generated research goal and optimized settings for ${category}`,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error generating goals:', error);
|
||||
toast({
|
||||
title: "Generation Failed",
|
||||
description: "Could not generate research goals. Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
} finally {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="bg-card border border-border rounded-lg p-4 sm:p-6">
|
||||
<div className="flex items-center justify-between mb-3 sm:mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Target className="w-4 h-4 sm:w-5 sm:h-5 text-foreground" />
|
||||
<h2 className="text-base sm:text-lg font-semibold text-foreground">Define Research Objective</h2>
|
||||
</div>
|
||||
{onAdvancedSettings && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={onAdvancedSettings}
|
||||
disabled={isPlanning}
|
||||
className="gap-2"
|
||||
>
|
||||
<Settings className="w-4 h-4" />
|
||||
<span className="hidden sm:inline text-xs">Advanced</span>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Textarea
|
||||
value={goal}
|
||||
onChange={(e) => setGoal(e.target.value)}
|
||||
placeholder="Enter your research goal or objective..."
|
||||
className="min-h-[80px] sm:min-h-[100px] resize-none bg-background border-border text-foreground text-sm"
|
||||
disabled={isPlanning}
|
||||
/>
|
||||
<p className="text-[10px] sm:text-xs text-muted-foreground mt-1.5 sm:mt-2">
|
||||
The GOAP system will analyze your objective and plan the optimal research workflow
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Sparkles className="w-3 h-3 text-primary" />
|
||||
<span className="text-xs font-medium text-foreground">AI-Generate by Category:</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
|
||||
{categories.map((cat) => (
|
||||
<button
|
||||
key={cat.id}
|
||||
type="button"
|
||||
onClick={() => generateGoals(cat.id)}
|
||||
disabled={isPlanning || isGenerating}
|
||||
className={cn(
|
||||
"flex items-center gap-1.5 px-2 py-1.5 rounded-md transition-all text-xs",
|
||||
"border border-border hover:border-primary/50",
|
||||
"bg-card hover:bg-muted",
|
||||
(isPlanning || isGenerating) && "opacity-50 cursor-not-allowed"
|
||||
)}
|
||||
style={{
|
||||
borderColor: isGenerating ? cat.color : undefined,
|
||||
}}
|
||||
>
|
||||
<cat.icon className="w-3 h-3" style={{ color: cat.color }} />
|
||||
<span className="text-foreground">{cat.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{isGenerating && (
|
||||
<p className="text-xs text-primary flex items-center gap-1.5 mt-2">
|
||||
<Sparkles className="w-3 h-3 animate-spin" />
|
||||
Generating research goals...
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!goal.trim() || isPlanning}
|
||||
className="w-full text-sm"
|
||||
>
|
||||
{isPlanning ? (
|
||||
<>
|
||||
<Sparkles className="w-3 h-3 sm:w-4 sm:h-4 mr-2 animate-spin" />
|
||||
<span className="text-xs sm:text-sm">Planning Research Workflow...</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Target className="w-3 h-3 sm:w-4 sm:h-4 mr-2" />
|
||||
<span className="text-xs sm:text-sm">Generate Research Plan</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,978 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import {
|
||||
FileText,
|
||||
Lightbulb,
|
||||
BookOpen,
|
||||
TrendingUp,
|
||||
Download,
|
||||
RefreshCw,
|
||||
Share2,
|
||||
ChevronRight,
|
||||
CheckCircle2,
|
||||
Target,
|
||||
Brain,
|
||||
Search,
|
||||
FileSearch,
|
||||
GitBranch,
|
||||
Sparkles,
|
||||
ChevronDown,
|
||||
Clock,
|
||||
Users,
|
||||
DollarSign,
|
||||
BarChart3,
|
||||
AlertTriangle,
|
||||
ExternalLink,
|
||||
FileDown,
|
||||
CheckSquare,
|
||||
} from "lucide-react";
|
||||
import { Step } from "@/lib/goapPlanner";
|
||||
import { supabase } from "@/integrations/supabase/client";
|
||||
|
||||
interface ResearchReportModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
userGoal: string;
|
||||
steps: Step[];
|
||||
onRevise: () => void;
|
||||
primaryColor?: string;
|
||||
accentColor?: string;
|
||||
successColor?: string;
|
||||
}
|
||||
|
||||
interface ActionItem {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
timeline: string;
|
||||
timelineDetails: string;
|
||||
priority: "High" | "Medium" | "Low";
|
||||
resources: {
|
||||
budget?: string;
|
||||
team?: string;
|
||||
tools?: string[];
|
||||
};
|
||||
metrics: string[];
|
||||
risks: {
|
||||
risk: string;
|
||||
mitigation: string;
|
||||
}[];
|
||||
references: {
|
||||
title: string;
|
||||
url: string;
|
||||
}[];
|
||||
researchContext: string;
|
||||
}
|
||||
|
||||
export const ResearchReportModal = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
userGoal,
|
||||
steps,
|
||||
onRevise,
|
||||
primaryColor = "#6b7280",
|
||||
accentColor = "#22c55e",
|
||||
successColor = "#22c55e",
|
||||
}: ResearchReportModalProps) => {
|
||||
const [activeTab, setActiveTab] = useState("summary");
|
||||
const [expandedActions, setExpandedActions] = useState<Set<string>>(new Set());
|
||||
const [aiActionItems, setAiActionItems] = useState<ActionItem[]>([]);
|
||||
const [aiSummary, setAiSummary] = useState<string>("");
|
||||
const [isGeneratingActions, setIsGeneratingActions] = useState(false);
|
||||
|
||||
// Generate AI-powered action items and summary on mount
|
||||
useEffect(() => {
|
||||
if (open && steps.length > 0 && aiActionItems.length === 0) {
|
||||
generateAIContent();
|
||||
}
|
||||
}, [open, steps]);
|
||||
|
||||
const generateAIContent = async () => {
|
||||
setIsGeneratingActions(true);
|
||||
|
||||
try {
|
||||
// Build research context from all steps
|
||||
const researchContext = steps.map(step => ({
|
||||
stepTitle: step.title,
|
||||
findings: step.data.map(item => {
|
||||
const details = item.details as any;
|
||||
return {
|
||||
title: item.text,
|
||||
content: details?.objective || details?.content || item.text,
|
||||
source: details?.source
|
||||
};
|
||||
})
|
||||
}));
|
||||
|
||||
// Call AI to generate contextual action items
|
||||
const { data, error } = await supabase.functions.invoke('generate-action-items', {
|
||||
body: {
|
||||
goal: userGoal,
|
||||
researchContext: researchContext,
|
||||
totalSteps: steps.length,
|
||||
totalDataPoints: steps.reduce((sum, step) => sum + step.data.length, 0)
|
||||
}
|
||||
});
|
||||
|
||||
if (!error && data) {
|
||||
if (data.actionItems) {
|
||||
setAiActionItems(data.actionItems);
|
||||
}
|
||||
if (data.summary) {
|
||||
setAiSummary(data.summary);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error generating AI content:', err);
|
||||
} finally {
|
||||
setIsGeneratingActions(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Extract all research items with their sources as citations
|
||||
const allCitations = steps.flatMap(step =>
|
||||
step.data.map(item => {
|
||||
const details = item.details as any;
|
||||
return {
|
||||
title: item.text,
|
||||
source: details?.source || 'Research Analysis',
|
||||
content: details?.objective || details?.content || item.text
|
||||
};
|
||||
})
|
||||
).filter(item => item.source && item.source !== 'Research Analysis');
|
||||
|
||||
const allSources = new Set(allCitations.map(item => item.source).filter(Boolean));
|
||||
const totalDataPoints = steps.reduce((sum, step) => sum + step.data.length, 0);
|
||||
|
||||
// Fallback action items if AI generation fails
|
||||
const generateActionItems = (): ActionItem[] => {
|
||||
const domain = userGoal.toLowerCase();
|
||||
const isQuantum = domain.includes('quantum');
|
||||
const isAI = domain.includes('ai') || domain.includes('artificial intelligence');
|
||||
const isBlockchain = domain.includes('blockchain');
|
||||
const isSustainability = domain.includes('sustainability') || domain.includes('green') || domain.includes('climate');
|
||||
|
||||
// Extract key insights from research data
|
||||
const keyInsights = steps.flatMap(step =>
|
||||
step.data.map(item => item.text)
|
||||
).slice(0, 5);
|
||||
|
||||
const actionItems: ActionItem[] = [];
|
||||
|
||||
// Action 1: Pilot/Proof of Concept
|
||||
actionItems.push({
|
||||
id: "1",
|
||||
title: `Launch Pilot Program Based on ${steps[0]?.title || 'Initial Research'}`,
|
||||
description: `Initiate a controlled pilot to validate key findings from the research. ${keyInsights[0] ? `Focus on "${keyInsights[0]}"` : ''} to establish baseline metrics and identify implementation challenges early.`,
|
||||
timeline: "Week 1-4",
|
||||
timelineDetails: "Week 1: Team setup and requirements. Week 2-3: Pilot execution. Week 4: Analysis and reporting.",
|
||||
priority: "High",
|
||||
resources: {
|
||||
budget: "$15,000 - $30,000 (pilot phase)",
|
||||
team: "3-5 people: 1 project lead, 2 technical specialists, 1 analyst, 1 stakeholder liaison",
|
||||
tools: isQuantum ? ["Quantum simulator", "QPU access", "Analysis toolkit"] :
|
||||
isAI ? ["ML framework", "GPU compute", "Data pipeline"] :
|
||||
isBlockchain ? ["Test network", "Smart contract tools", "Analytics platform"] :
|
||||
["Project management software", "Analytics tools", "Collaboration platform"]
|
||||
},
|
||||
metrics: [
|
||||
"Pilot success rate (target: >75%)",
|
||||
"Time to first result (target: <2 weeks)",
|
||||
"Cost per transaction/operation",
|
||||
"User satisfaction score (target: >4/5)",
|
||||
"Technical feasibility score"
|
||||
],
|
||||
risks: [
|
||||
{
|
||||
risk: "Insufficient stakeholder buy-in during pilot phase",
|
||||
mitigation: "Conduct pre-pilot workshops and establish clear communication channels with weekly updates"
|
||||
},
|
||||
{
|
||||
risk: "Technical challenges exceeding initial scope",
|
||||
mitigation: "Build 30% buffer time into pilot timeline and have backup technical experts on standby"
|
||||
},
|
||||
{
|
||||
risk: "Resource constraints or budget overruns",
|
||||
mitigation: "Implement phased approach with clear go/no-go decision points after each phase"
|
||||
}
|
||||
],
|
||||
references: [
|
||||
{ title: "Pilot Program Best Practices", url: "https://www.pmi.org/learning/library/pilot-project-best-practices-6498" },
|
||||
{ title: "Measuring Pilot Success", url: "https://hbr.org/2018/11/how-to-design-a-pilot-study" }
|
||||
],
|
||||
researchContext: `Based on ${steps.length} research steps analyzing "${userGoal}", this pilot directly addresses findings from the initial goal analysis phase.`
|
||||
});
|
||||
|
||||
// Action 2: Scale Implementation
|
||||
actionItems.push({
|
||||
id: "2",
|
||||
title: `Scale to Production: Full Implementation Rollout`,
|
||||
description: `Based on successful pilot validation, scale the solution to production environment. ${keyInsights[1] ? `Leverage insight: "${keyInsights[1]}"` : ''} to optimize the deployment strategy and minimize disruption.`,
|
||||
timeline: "Month 2-4",
|
||||
timelineDetails: "Month 2: Infrastructure setup. Month 3: Staged rollout (10% → 50% → 100%). Month 4: Optimization and stabilization.",
|
||||
priority: "High",
|
||||
resources: {
|
||||
budget: "$100,000 - $250,000 (full implementation)",
|
||||
team: "8-12 people: 1 program manager, 3-4 engineers, 2 QA specialists, 1 DevOps, 1 security lead, 2 business analysts",
|
||||
tools: isQuantum ? ["Production QPU", "Error correction", "Monitoring suite", "Integration middleware"] :
|
||||
isAI ? ["Production ML infrastructure", "Model registry", "Feature store", "Monitoring tools"] :
|
||||
isBlockchain ? ["Mainnet deployment", "Security audit tools", "Node infrastructure", "Wallet integration"] :
|
||||
["CI/CD pipeline", "Production infrastructure", "Monitoring stack", "Security tools"]
|
||||
},
|
||||
metrics: [
|
||||
"System uptime (target: 99.5%+)",
|
||||
"Deployment velocity (features/month)",
|
||||
"Error rate (target: <0.1%)",
|
||||
"Cost efficiency vs. baseline (target: 20% improvement)",
|
||||
"User adoption rate (target: 70% within 3 months)",
|
||||
"ROI timeline (target: break-even within 12 months)"
|
||||
],
|
||||
risks: [
|
||||
{
|
||||
risk: "Production issues impacting existing operations",
|
||||
mitigation: "Implement blue-green deployment with instant rollback capability and 24/7 monitoring"
|
||||
},
|
||||
{
|
||||
risk: "Scaling costs exceeding projections",
|
||||
mitigation: "Implement cost tracking dashboards with automated alerts at 80% budget thresholds"
|
||||
},
|
||||
{
|
||||
risk: "User resistance to new system",
|
||||
mitigation: "Develop comprehensive training program and provide dedicated support team during transition"
|
||||
},
|
||||
{
|
||||
risk: "Integration challenges with legacy systems",
|
||||
mitigation: "Build abstraction layer and maintain parallel systems during transition period"
|
||||
}
|
||||
],
|
||||
references: [
|
||||
{ title: "Scaling Best Practices", url: "https://aws.amazon.com/architecture/well-architected/" },
|
||||
{ title: "Production Readiness Checklist", url: "https://www.atlassian.com/incident-management/devops/production-ready" }
|
||||
],
|
||||
researchContext: `This phase builds on the ${totalDataPoints} data points collected during research, particularly insights from the verification and synthesis stages.`
|
||||
});
|
||||
|
||||
// Action 3: Optimization & Enhancement
|
||||
actionItems.push({
|
||||
id: "3",
|
||||
title: `Continuous Improvement: Optimize Based on Real-World Data`,
|
||||
description: `Establish feedback loops and optimization cycles to continuously improve performance. ${keyInsights[2] ? `Apply research finding: "${keyInsights[2]}"` : ''} to drive iterative enhancements and competitive advantages.`,
|
||||
timeline: "Month 4-6 (ongoing)",
|
||||
timelineDetails: "Month 4: Baseline performance analysis. Month 5: Implement optimization v1. Month 6: A/B testing and refinement. Then quarterly improvement cycles.",
|
||||
priority: "Medium",
|
||||
resources: {
|
||||
budget: "$25,000 - $50,000 per quarter (optimization budget)",
|
||||
team: "4-6 people: 1 optimization lead, 2 data scientists, 1 engineer, 1 UX researcher, 1 product analyst",
|
||||
tools: ["A/B testing platform", "Analytics suite", "Performance monitoring", "User feedback tools", "Data visualization platform"]
|
||||
},
|
||||
metrics: [
|
||||
"Performance improvement rate (target: 10% per quarter)",
|
||||
"User engagement increase (target: 15% growth)",
|
||||
"Cost reduction achieved (target: 5% per quarter)",
|
||||
"Feature adoption velocity",
|
||||
"Customer satisfaction (NPS target: >50)",
|
||||
"Mean time to resolution (MTTR) for issues"
|
||||
],
|
||||
risks: [
|
||||
{
|
||||
risk: "Optimization causing unintended regressions",
|
||||
mitigation: "Implement comprehensive test coverage (>80%) and gradual rollout of optimizations"
|
||||
},
|
||||
{
|
||||
risk: "Diminishing returns on optimization efforts",
|
||||
mitigation: "Establish clear ROI thresholds and prioritize optimizations based on impact analysis"
|
||||
},
|
||||
{
|
||||
risk: "Team burnout from continuous changes",
|
||||
mitigation: "Balance optimization sprints with stabilization periods and rotate team responsibilities"
|
||||
}
|
||||
],
|
||||
references: [
|
||||
{ title: "Continuous Improvement Framework", url: "https://www.lean.org/lexicon-terms/continuous-improvement/" },
|
||||
{ title: "Data-Driven Optimization", url: "https://hbr.org/2012/09/big-data-the-management-revolution" }
|
||||
],
|
||||
researchContext: `Drawing from the knowledge synthesis and insight generation phases of the research, this ensures long-term value realization.`
|
||||
});
|
||||
|
||||
// Action 4: Knowledge Sharing & Scaling
|
||||
actionItems.push({
|
||||
id: "4",
|
||||
title: `Document & Share Learnings Across Organization`,
|
||||
description: `Create comprehensive documentation and training materials to scale adoption and build organizational capability. Capture lessons learned and best practices for future initiatives in this domain.`,
|
||||
timeline: "Month 5-7",
|
||||
timelineDetails: "Month 5: Documentation creation. Month 6: Training program development and pilot. Month 7: Organization-wide rollout and feedback collection.",
|
||||
priority: "Medium",
|
||||
resources: {
|
||||
budget: "$20,000 - $40,000 (documentation and training)",
|
||||
team: "3-5 people: 1 technical writer, 1 training specialist, 1 subject matter expert, 1 instructional designer, 1 community manager",
|
||||
tools: ["Documentation platform", "Learning management system (LMS)", "Video recording tools", "Knowledge base software", "Community forum"]
|
||||
},
|
||||
metrics: [
|
||||
"Documentation completeness (target: 100% coverage)",
|
||||
"Training completion rate (target: >85% of target audience)",
|
||||
"Knowledge base engagement (views, searches, contributions)",
|
||||
"Support ticket reduction (target: 30% decrease)",
|
||||
"Cross-team adoption rate",
|
||||
"Time to onboard new team members (target: <1 week)"
|
||||
],
|
||||
risks: [
|
||||
{
|
||||
risk: "Documentation becoming outdated quickly",
|
||||
mitigation: "Assign documentation owners and implement quarterly review cycles with version control"
|
||||
},
|
||||
{
|
||||
risk: "Low engagement with training materials",
|
||||
mitigation: "Gamify learning experience and tie completion to performance reviews or certifications"
|
||||
},
|
||||
{
|
||||
risk: "Knowledge silos persisting despite documentation",
|
||||
mitigation: "Establish communities of practice and regular knowledge-sharing sessions"
|
||||
}
|
||||
],
|
||||
references: [
|
||||
{ title: "Documentation Best Practices", url: "https://documentation.divio.com/" },
|
||||
{ title: "Effective Knowledge Management", url: "https://www.mckinsey.com/capabilities/people-and-organizational-performance/our-insights/building-organizational-capabilities-knowledge-management" }
|
||||
],
|
||||
researchContext: `This ensures the research findings from all ${steps.length} steps are institutionalized and can benefit future projects.`
|
||||
});
|
||||
|
||||
return actionItems;
|
||||
};
|
||||
|
||||
const actionItems = aiActionItems.length > 0 ? aiActionItems : generateActionItems();
|
||||
|
||||
const toggleAction = (id: string) => {
|
||||
setExpandedActions(prev => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(id)) {
|
||||
next.delete(id);
|
||||
} else {
|
||||
next.add(id);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const exportActionItems = () => {
|
||||
let checklist = `# Action Items Checklist: ${userGoal}\n\n`;
|
||||
checklist += `Generated: ${new Date().toLocaleString()}\n`;
|
||||
checklist += `Research Steps: ${steps.length} | Data Points: ${totalDataPoints}\n\n`;
|
||||
checklist += `---\n\n`;
|
||||
|
||||
actionItems.forEach((item, idx) => {
|
||||
checklist += `## ${idx + 1}. ${item.title}\n\n`;
|
||||
checklist += `**Timeline:** ${item.timeline}\n`;
|
||||
checklist += `**Priority:** ${item.priority}\n\n`;
|
||||
checklist += `**Description:** ${item.description}\n\n`;
|
||||
|
||||
checklist += `**Timeline Breakdown:**\n${item.timelineDetails}\n\n`;
|
||||
|
||||
if (item.resources.budget) {
|
||||
checklist += `**Budget:** ${item.resources.budget}\n`;
|
||||
}
|
||||
if (item.resources.team) {
|
||||
checklist += `**Team:** ${item.resources.team}\n`;
|
||||
}
|
||||
if (item.resources.tools && item.resources.tools.length > 0) {
|
||||
checklist += `**Required Tools:**\n`;
|
||||
item.resources.tools.forEach(tool => checklist += ` - ${tool}\n`);
|
||||
checklist += `\n`;
|
||||
}
|
||||
|
||||
checklist += `**Success Metrics:**\n`;
|
||||
item.metrics.forEach(metric => checklist += ` - [ ] ${metric}\n`);
|
||||
checklist += `\n`;
|
||||
|
||||
checklist += `**Risks & Mitigation:**\n`;
|
||||
item.risks.forEach(risk => {
|
||||
checklist += ` - **Risk:** ${risk.risk}\n`;
|
||||
checklist += ` **Mitigation:** ${risk.mitigation}\n`;
|
||||
});
|
||||
checklist += `\n`;
|
||||
|
||||
if (item.references.length > 0) {
|
||||
checklist += `**References:**\n`;
|
||||
item.references.forEach(ref => {
|
||||
checklist += ` - [${ref.title}](${ref.url})\n`;
|
||||
});
|
||||
checklist += `\n`;
|
||||
}
|
||||
|
||||
checklist += `**Research Context:** ${item.researchContext}\n\n`;
|
||||
checklist += `---\n\n`;
|
||||
});
|
||||
|
||||
const blob = new Blob([checklist], { type: 'text/markdown' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `action-items-checklist-${Date.now()}.md`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
const handleDownload = () => {
|
||||
const report = generateReportText();
|
||||
const blob = new Blob([report], { type: 'text/markdown' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `research-report-${Date.now()}.md`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
const generateReportText = () => {
|
||||
let report = `# Research Report: ${userGoal}\n\n`;
|
||||
report += `Generated: ${new Date().toLocaleString()}\n`;
|
||||
report += `Total Steps: ${steps.length}\n`;
|
||||
report += `Data Points: ${totalDataPoints}\n\n`;
|
||||
report += `---\n\n`;
|
||||
|
||||
report += `## Executive Summary\n\n`;
|
||||
report += `This research analyzed "${userGoal}" through a ${steps.length}-step Goal-Oriented Action Planning (GOAP) workflow.\n\n`;
|
||||
|
||||
steps.forEach((step, idx) => {
|
||||
report += `## ${idx + 1}. ${step.title}\n\n`;
|
||||
report += `${step.description}\n\n`;
|
||||
step.data.forEach(item => {
|
||||
const details = item.details as any;
|
||||
report += `- **${item.text}**: ${details?.objective || item.text}\n`;
|
||||
});
|
||||
report += `\n`;
|
||||
});
|
||||
|
||||
if (allCitations.length > 0) {
|
||||
report += `## Citations\n\n`;
|
||||
allCitations.forEach((citation, idx) => {
|
||||
report += `${idx + 1}. ${citation}\n`;
|
||||
});
|
||||
}
|
||||
|
||||
return report;
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-5xl h-[85vh] p-0 flex flex-col">
|
||||
<DialogHeader className="px-6 pt-6 pb-4 border-b shrink-0">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<DialogTitle className="text-2xl font-bold mb-2">
|
||||
Research Report
|
||||
</DialogTitle>
|
||||
<DialogDescription className="text-base">
|
||||
{userGoal}
|
||||
</DialogDescription>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleDownload}
|
||||
className="gap-2"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
Export
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onRevise}
|
||||
className="gap-2"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4" />
|
||||
Revise
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-2"
|
||||
>
|
||||
<Share2 className="w-4 h-4" />
|
||||
Share
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<Tabs value={activeTab} onValueChange={(value) => {
|
||||
setActiveTab(value);
|
||||
// Auto-scroll to top when tab changes
|
||||
const scrollArea = document.querySelector('[data-radix-scroll-area-viewport]');
|
||||
if (scrollArea) {
|
||||
scrollArea.scrollTop = 0;
|
||||
}
|
||||
}} className="flex-1 flex flex-col min-h-0">
|
||||
<TabsList className="mx-6 mt-4 shrink-0">
|
||||
<TabsTrigger value="summary" className="gap-2">
|
||||
<FileText className="w-4 h-4" />
|
||||
Summary
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="findings" className="gap-2">
|
||||
<Lightbulb className="w-4 h-4" />
|
||||
Key Findings
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="methodology" className="gap-2">
|
||||
<Target className="w-4 h-4" />
|
||||
Methodology
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="citations" className="gap-2">
|
||||
<BookOpen className="w-4 h-4" />
|
||||
Citations ({allCitations.length})
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="insights" className="gap-2">
|
||||
<TrendingUp className="w-4 h-4" />
|
||||
Next Steps
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<div className="flex-1 overflow-y-auto px-6 min-h-0">
|
||||
{/* Summary Tab */}
|
||||
<TabsContent value="summary" className="mt-4 space-y-6 pb-6">
|
||||
<div className="rounded-lg border p-6" style={{ borderColor: `${accentColor}4d`, backgroundColor: `${accentColor}0d` }}>
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="p-2 rounded-lg" style={{ backgroundColor: `${accentColor}33` }}>
|
||||
<Sparkles className="w-5 h-5" style={{ color: accentColor }} />
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold">Executive Summary</h3>
|
||||
</div>
|
||||
<p className="text-sm leading-relaxed text-muted-foreground whitespace-pre-wrap">
|
||||
{aiSummary || `This comprehensive research successfully analyzed "${userGoal}" through a ${steps.length}-step Goal-Oriented Action Planning (GOAP) workflow. The system coordinated multiple specialized agents to gather information, analyze documents, synthesize knowledge, and generate actionable insights with high confidence scores across all validation checks.`}
|
||||
</p>
|
||||
{isGeneratingActions && (
|
||||
<div className="mt-3 text-xs text-muted-foreground flex items-center gap-2">
|
||||
<div className="w-4 h-4 border-2 border-t-transparent rounded-full animate-spin" style={{ borderColor: accentColor, borderTopColor: 'transparent' }}></div>
|
||||
Generating contextual summary...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-4 gap-4">
|
||||
<div className="rounded-lg border p-4">
|
||||
<div className="text-2xl font-bold mb-1">{steps.length}</div>
|
||||
<div className="text-xs text-muted-foreground">Research Steps</div>
|
||||
</div>
|
||||
<div className="rounded-lg border p-4">
|
||||
<div className="text-2xl font-bold mb-1">{totalDataPoints}</div>
|
||||
<div className="text-xs text-muted-foreground">Data Points</div>
|
||||
</div>
|
||||
<div className="rounded-lg border p-4">
|
||||
<div className="text-2xl font-bold mb-1" style={{ color: accentColor }}>94%</div>
|
||||
<div className="text-xs text-muted-foreground">Confidence</div>
|
||||
</div>
|
||||
<div className="rounded-lg border p-4">
|
||||
<div className="text-2xl font-bold mb-1">{allSources.size}</div>
|
||||
<div className="text-xs text-muted-foreground">Sources</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h4 className="font-semibold flex items-center gap-2">
|
||||
<CheckCircle2 className="w-4 h-4" style={{ color: successColor }} />
|
||||
Completed Steps
|
||||
</h4>
|
||||
{steps.map((step, idx) => (
|
||||
<div key={idx} className="flex items-start gap-3 rounded-lg border p-4 hover:bg-muted/50 transition-colors">
|
||||
<div className="p-2 rounded" style={{ backgroundColor: `${primaryColor}1a` }}>
|
||||
{step.icon && <step.icon className="w-4 h-4" style={{ color: primaryColor }} />}
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<h5 className="font-medium text-sm mb-1">{step.title}</h5>
|
||||
<p className="text-xs text-muted-foreground">{step.description}</p>
|
||||
</div>
|
||||
<Badge variant="outline" className="text-xs" style={{ borderColor: successColor, color: successColor }}>
|
||||
{step.data.length} items
|
||||
</Badge>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Key Findings Tab */}
|
||||
<TabsContent value="findings" className="mt-4 space-y-4 pb-6">
|
||||
<div className="rounded-lg border p-4 bg-muted/30">
|
||||
<h3 className="font-semibold mb-2 flex items-center gap-2">
|
||||
<Lightbulb className="w-4 h-4" style={{ color: accentColor }} />
|
||||
Key Research Findings
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Critical insights and discoveries from the research process
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{steps.map((step, stepIdx) => (
|
||||
<div key={stepIdx} className="space-y-3">
|
||||
<h4 className="font-semibold text-sm flex items-center gap-2 sticky top-0 bg-background py-2">
|
||||
<step.icon className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
{step.title}
|
||||
</h4>
|
||||
{step.data.map((item, itemIdx) => {
|
||||
const details = item.details as any;
|
||||
return (
|
||||
<div key={itemIdx} className="rounded-lg border p-4 space-y-2">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<h5 className="font-medium text-sm flex-1">{item.text}</h5>
|
||||
{details?.confidence && (
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
{Math.round(details.confidence * 100)}% confidence
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground leading-relaxed">
|
||||
{details?.objective || item.text}
|
||||
</p>
|
||||
{details?.source && (
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<BookOpen className="w-3 h-3" />
|
||||
Source: {details.source}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</TabsContent>
|
||||
|
||||
{/* Methodology Tab */}
|
||||
<TabsContent value="methodology" className="mt-4 space-y-4 pb-6">
|
||||
<div className="rounded-lg border p-4 bg-muted/30">
|
||||
<h3 className="font-semibold mb-2 flex items-center gap-2">
|
||||
<Target className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
Research Methodology
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
GOAP-based systematic approach with sequential step execution
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
{steps.map((step, idx) => (
|
||||
<div key={idx} className="flex gap-4">
|
||||
<div className="flex flex-col items-center">
|
||||
<div
|
||||
className="w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold"
|
||||
style={{ backgroundColor: `${successColor}33`, color: successColor }}
|
||||
>
|
||||
{idx + 1}
|
||||
</div>
|
||||
{idx < steps.length - 1 && (
|
||||
<div className="w-0.5 flex-1 my-2" style={{ backgroundColor: `${successColor}33` }} />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex-1 pb-6">
|
||||
<div className="rounded-lg border p-4 space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
{step.icon && <step.icon className="w-4 h-4" style={{ color: primaryColor }} />}
|
||||
<h4 className="font-semibold text-sm">{step.title}</h4>
|
||||
<CheckCircle2 className="w-4 h-4 ml-auto" style={{ color: successColor }} />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">{step.description}</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{step.data.slice(0, 3).map((item, i) => (
|
||||
<Badge key={i} variant="secondary" className="text-xs">
|
||||
{item.text}
|
||||
</Badge>
|
||||
))}
|
||||
{step.data.length > 3 && (
|
||||
<Badge variant="outline" className="text-xs">
|
||||
+{step.data.length - 3} more
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Citations Tab */}
|
||||
<TabsContent value="citations" className="mt-4 space-y-4 pb-6">
|
||||
<div className="rounded-lg border p-4 bg-muted/30">
|
||||
<h3 className="font-semibold mb-2 flex items-center gap-2">
|
||||
<BookOpen className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
References & Citations
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Academic references and sources used in this research
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{allCitations.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{allCitations.map((citation, idx) => (
|
||||
<div key={idx} className="rounded-lg border p-4 space-y-2">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="text-sm font-semibold text-muted-foreground min-w-[32px]">[{idx + 1}]</div>
|
||||
<div className="flex-1 space-y-1">
|
||||
<p className="text-sm font-medium leading-relaxed">{citation.title}</p>
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<BookOpen className="w-3 h-3" />
|
||||
<span className="font-medium">{citation.source}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-8 text-muted-foreground">
|
||||
No citations were generated for this research
|
||||
</div>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
{/* Next Steps Tab */}
|
||||
<TabsContent value="insights" className="mt-4 space-y-4 pb-6">
|
||||
<div className="rounded-lg border p-4 bg-muted/30">
|
||||
<div className="flex items-start justify-between gap-3 mb-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<TrendingUp className="w-4 h-4" style={{ color: accentColor }} />
|
||||
<h3 className="font-semibold">Actionable Next Steps</h3>
|
||||
</div>
|
||||
<Button
|
||||
onClick={exportActionItems}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="gap-2 text-xs"
|
||||
>
|
||||
<FileDown className="w-3 h-3" />
|
||||
Export Checklist
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{isGeneratingActions
|
||||
? "Generating contextual action items based on your research..."
|
||||
: "Contextualized recommendations with timelines, resources, metrics, and risk mitigation based on your research findings"}
|
||||
</p>
|
||||
{isGeneratingActions && (
|
||||
<div className="mt-2 flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<div className="w-4 h-4 border-2 border-t-transparent rounded-full animate-spin" style={{ borderColor: accentColor, borderTopColor: 'transparent' }}></div>
|
||||
AI is analyzing your research to generate relevant next steps...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
{actionItems.map((action) => (
|
||||
<Collapsible
|
||||
key={action.id}
|
||||
open={expandedActions.has(action.id)}
|
||||
onOpenChange={() => toggleAction(action.id)}
|
||||
>
|
||||
<div className="rounded-lg border">
|
||||
<CollapsibleTrigger className="w-full p-4 hover:bg-muted/50 transition-colors">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="flex items-start gap-3 flex-1 text-left">
|
||||
<ChevronDown
|
||||
className={`w-4 h-4 mt-0.5 transition-transform flex-shrink-0 ${
|
||||
expandedActions.has(action.id) ? 'rotate-180' : ''
|
||||
}`}
|
||||
style={{ color: accentColor }}
|
||||
/>
|
||||
<div className="space-y-1 flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<h5 className="font-medium text-sm">{action.title}</h5>
|
||||
<Badge
|
||||
variant={action.priority === "High" ? "default" : action.priority === "Medium" ? "secondary" : "outline"}
|
||||
className="text-[10px] px-1.5 py-0"
|
||||
>
|
||||
{action.priority}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="flex items-center gap-4 text-xs text-muted-foreground">
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{action.timeline}</span>
|
||||
</div>
|
||||
{action.resources.budget && (
|
||||
<div className="flex items-center gap-1">
|
||||
<DollarSign className="w-3 h-3" />
|
||||
<span className="hidden sm:inline">{action.resources.budget}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground line-clamp-2">
|
||||
{action.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CollapsibleTrigger>
|
||||
|
||||
<CollapsibleContent>
|
||||
<div className="px-4 pb-4 space-y-4 border-t pt-4">
|
||||
{/* Research Context */}
|
||||
<div className="rounded-lg p-3 text-xs" style={{ backgroundColor: `${primaryColor}0d` }}>
|
||||
<div className="flex items-center gap-1.5 mb-1">
|
||||
<Brain className="w-3 h-3" style={{ color: primaryColor }} />
|
||||
<span className="font-medium">Research Context</span>
|
||||
</div>
|
||||
<p className="text-muted-foreground">{action.researchContext}</p>
|
||||
</div>
|
||||
|
||||
{/* Timeline Details */}
|
||||
<div>
|
||||
<div className="flex items-center gap-1.5 mb-2">
|
||||
<Clock className="w-3 h-3" style={{ color: accentColor }} />
|
||||
<h6 className="text-xs font-semibold">Timeline Breakdown</h6>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{action.timelineDetails}</p>
|
||||
</div>
|
||||
|
||||
{/* Resources */}
|
||||
<div>
|
||||
<h6 className="text-xs font-semibold mb-2">Resource Requirements</h6>
|
||||
<div className="space-y-2">
|
||||
{action.resources.budget && (
|
||||
<div className="flex items-start gap-2 text-xs">
|
||||
<DollarSign className="w-3 h-3 mt-0.5 flex-shrink-0" style={{ color: accentColor }} />
|
||||
<div>
|
||||
<span className="font-medium">Budget:</span>
|
||||
<span className="text-muted-foreground ml-1">{action.resources.budget}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{action.resources.team && (
|
||||
<div className="flex items-start gap-2 text-xs">
|
||||
<Users className="w-3 h-3 mt-0.5 flex-shrink-0" style={{ color: accentColor }} />
|
||||
<div>
|
||||
<span className="font-medium">Team:</span>
|
||||
<span className="text-muted-foreground ml-1">{action.resources.team}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{action.resources.tools && action.resources.tools.length > 0 && (
|
||||
<div className="flex items-start gap-2 text-xs">
|
||||
<Target className="w-3 h-3 mt-0.5 flex-shrink-0" style={{ color: accentColor }} />
|
||||
<div className="flex-1">
|
||||
<span className="font-medium">Required Tools:</span>
|
||||
<div className="flex flex-wrap gap-1 mt-1">
|
||||
{action.resources.tools.map((tool, idx) => (
|
||||
<span key={idx} className="bg-muted px-2 py-0.5 rounded text-[10px]">
|
||||
{tool}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Success Metrics */}
|
||||
<div>
|
||||
<div className="flex items-center gap-1.5 mb-2">
|
||||
<BarChart3 className="w-3 h-3" style={{ color: accentColor }} />
|
||||
<h6 className="text-xs font-semibold">Success Metrics & KPIs</h6>
|
||||
</div>
|
||||
<ul className="space-y-1">
|
||||
{action.metrics.map((metric, idx) => (
|
||||
<li key={idx} className="flex items-start gap-2 text-xs">
|
||||
<CheckSquare className="w-3 h-3 mt-0.5 flex-shrink-0 text-muted-foreground" />
|
||||
<span className="text-muted-foreground">{metric}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Risks & Mitigation */}
|
||||
<div>
|
||||
<div className="flex items-center gap-1.5 mb-2">
|
||||
<AlertTriangle className="w-3 h-3 text-orange-500" />
|
||||
<h6 className="text-xs font-semibold">Risks & Mitigation Strategies</h6>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{action.risks.map((risk, idx) => (
|
||||
<div key={idx} className="rounded-lg bg-muted/50 p-2 text-xs">
|
||||
<div className="flex items-start gap-1.5 mb-1">
|
||||
<span className="font-medium text-orange-600">⚠</span>
|
||||
<span className="font-medium">{risk.risk}</span>
|
||||
</div>
|
||||
<div className="flex items-start gap-1.5 ml-4">
|
||||
<span className="text-green-600">→</span>
|
||||
<span className="text-muted-foreground">{risk.mitigation}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* References */}
|
||||
{action.references.length > 0 && (
|
||||
<div>
|
||||
<div className="flex items-center gap-1.5 mb-2">
|
||||
<ExternalLink className="w-3 h-3" style={{ color: accentColor }} />
|
||||
<h6 className="text-xs font-semibold">Implementation Resources</h6>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
{action.references.map((ref, idx) => (
|
||||
<a
|
||||
key={idx}
|
||||
href={ref.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1.5 text-xs hover:underline group"
|
||||
style={{ color: primaryColor }}
|
||||
>
|
||||
<ExternalLink className="w-3 h-3 opacity-50 group-hover:opacity-100" />
|
||||
<span>{ref.title}</span>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</div>
|
||||
</Collapsible>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="rounded-lg border p-4 mt-6" style={{ borderColor: `${successColor}4d`, backgroundColor: `${successColor}0d` }}>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<CheckCircle2 className="w-4 h-4" style={{ color: successColor }} />
|
||||
<h4 className="font-semibold text-sm">Implementation Ready</h4>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mb-3">
|
||||
All research verification checks passed. These action items are directly derived from your {steps.length} research steps and {totalDataPoints} data points collected. Ready for stakeholder review and implementation planning.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2 text-xs">
|
||||
<Badge variant="outline" className="gap-1">
|
||||
<CheckCircle2 className="w-3 h-3" />
|
||||
{actionItems.length} Action Items
|
||||
</Badge>
|
||||
<Badge variant="outline" className="gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
{actionItems[0]?.timeline} to Start
|
||||
</Badge>
|
||||
<Badge variant="outline" className="gap-1">
|
||||
<Target className="w-3 h-3" />
|
||||
{actionItems.reduce((sum, item) => sum + item.metrics.length, 0)} Success Metrics
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</div>
|
||||
</Tabs>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,154 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { CheckCircle2, Edit3, Target, GitBranch, Code, TestTube, FileText } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
|
||||
interface ResearchReviewCardProps {
|
||||
onApprove: () => void;
|
||||
onRevise: (feedback: string) => void;
|
||||
goal: string;
|
||||
}
|
||||
|
||||
export const ResearchReviewCard = ({ onApprove, onRevise, goal }: ResearchReviewCardProps) => {
|
||||
const [feedback, setFeedback] = useState("");
|
||||
const [showFeedback, setShowFeedback] = useState(false);
|
||||
|
||||
const handleRevise = () => {
|
||||
if (showFeedback) {
|
||||
onRevise(feedback);
|
||||
setFeedback("");
|
||||
setShowFeedback(false);
|
||||
} else {
|
||||
setShowFeedback(true);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-primary/30 bg-gradient-to-br from-background to-primary/5">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-2">
|
||||
<CardTitle className="flex items-center gap-2 text-2xl">
|
||||
<CheckCircle2 className="w-6 h-6 text-primary" />
|
||||
Research Complete - Ready for Review
|
||||
</CardTitle>
|
||||
<CardDescription className="text-base">
|
||||
Review the research findings and execution plan before launching development
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Goal Summary */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 text-sm font-medium text-muted-foreground">
|
||||
<Target className="w-4 h-4" />
|
||||
Project Goal
|
||||
</div>
|
||||
<p className="text-foreground pl-6">{goal}</p>
|
||||
</div>
|
||||
|
||||
{/* Research Summary */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div className="space-y-2 p-4 rounded-lg bg-card border">
|
||||
<div className="flex items-center gap-2">
|
||||
<Target className="w-5 h-5 text-primary" />
|
||||
<span className="font-medium">Goal Assessment</span>
|
||||
</div>
|
||||
<Badge variant="secondary" className="w-fit">Completed</Badge>
|
||||
<p className="text-sm text-muted-foreground">Requirements analyzed, agents identified</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 p-4 rounded-lg bg-card border">
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch className="w-5 h-5 text-purple-500" />
|
||||
<span className="font-medium">Architecture</span>
|
||||
</div>
|
||||
<Badge variant="secondary" className="w-fit">Completed</Badge>
|
||||
<p className="text-sm text-muted-foreground">System design, API contracts planned</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 p-4 rounded-lg bg-card border">
|
||||
<div className="flex items-center gap-2">
|
||||
<Code className="w-5 h-5 text-blue-500" />
|
||||
<span className="font-medium">Implementation</span>
|
||||
</div>
|
||||
<Badge variant="secondary" className="w-fit">Ready</Badge>
|
||||
<p className="text-sm text-muted-foreground">42 files, 1,247 LOC planned</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 p-4 rounded-lg bg-card border">
|
||||
<div className="flex items-center gap-2">
|
||||
<TestTube className="w-5 h-5 text-green-500" />
|
||||
<span className="font-medium">Testing</span>
|
||||
</div>
|
||||
<Badge variant="secondary" className="w-fit">Ready</Badge>
|
||||
<p className="text-sm text-muted-foreground">124 tests, 87% coverage target</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Execution Plan Summary */}
|
||||
<div className="space-y-3 p-4 rounded-lg bg-muted/30 border border-muted">
|
||||
<h4 className="font-semibold flex items-center gap-2">
|
||||
<FileText className="w-4 h-4 text-primary" />
|
||||
Execution Plan Summary
|
||||
</h4>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
||||
<div>
|
||||
<span className="text-muted-foreground">Total Phases:</span>
|
||||
<p className="font-medium">5 phases</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground">Estimated Duration:</span>
|
||||
<p className="font-medium">~40 seconds</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground">Agents Required:</span>
|
||||
<p className="font-medium">6 agents</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground">Complexity:</span>
|
||||
<p className="font-medium">Medium</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Revision Feedback */}
|
||||
{showFeedback && (
|
||||
<div className="space-y-2 animate-fade-in">
|
||||
<label className="text-sm font-medium">Revision Feedback (Optional)</label>
|
||||
<Textarea
|
||||
placeholder="Describe what should be changed in the research or plan..."
|
||||
value={feedback}
|
||||
onChange={(e) => setFeedback(e.target.value)}
|
||||
className="min-h-[100px]"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex gap-3 pt-2">
|
||||
<Button
|
||||
onClick={onApprove}
|
||||
size="lg"
|
||||
className="flex-1 gap-2 bg-gradient-to-r from-primary to-purple-600 hover:from-primary/90 hover:to-purple-600/90"
|
||||
>
|
||||
<CheckCircle2 className="w-5 h-5" />
|
||||
Approve & Launch Development
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleRevise}
|
||||
variant="outline"
|
||||
size="lg"
|
||||
className="gap-2"
|
||||
>
|
||||
<Edit3 className="w-5 h-5" />
|
||||
{showFeedback ? "Submit Revision Request" : "Request Revision"}
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,309 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { CheckCircle2, Circle, Target, TrendingUp, ArrowRight, Zap } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface StateAssessmentCardProps {
|
||||
currentState: Record<string, boolean | string | number>;
|
||||
goalState: Record<string, boolean | string | number>;
|
||||
stateGaps: string[];
|
||||
primaryColor: string;
|
||||
accentColor: string;
|
||||
}
|
||||
|
||||
export const StateAssessmentCard = ({
|
||||
currentState,
|
||||
goalState,
|
||||
stateGaps,
|
||||
primaryColor,
|
||||
accentColor,
|
||||
}: StateAssessmentCardProps) => {
|
||||
const [visibleStates, setVisibleStates] = useState<string[]>([]);
|
||||
const [animatingState, setAnimatingState] = useState<string | null>(null);
|
||||
|
||||
const currentStateEntries = Object.entries(currentState);
|
||||
const goalStateEntries = Object.entries(goalState);
|
||||
|
||||
// Calculate progress percentage
|
||||
const completedCount = currentStateEntries.filter(([_, value]) => value === true).length;
|
||||
const totalCount = goalStateEntries.length;
|
||||
const progressPercentage = Math.round((completedCount / totalCount) * 100);
|
||||
|
||||
// Animate state entries appearing one by one
|
||||
useEffect(() => {
|
||||
const allKeys = currentStateEntries.map(([key]) => key);
|
||||
setVisibleStates([]);
|
||||
|
||||
allKeys.forEach((key, index) => {
|
||||
setTimeout(() => {
|
||||
setVisibleStates(prev => [...prev, key]);
|
||||
setAnimatingState(key);
|
||||
setTimeout(() => setAnimatingState(null), 600);
|
||||
}, index * 150);
|
||||
});
|
||||
}, [JSON.stringify(currentState)]);
|
||||
|
||||
// Check if state has changed (for highlighting)
|
||||
const hasStateChanged = (key: string) => {
|
||||
return currentState[key] === true && animatingState === key;
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="border-2 overflow-hidden relative" style={{ borderColor: `${primaryColor}40` }}>
|
||||
{/* Animated background gradient */}
|
||||
<div
|
||||
className="absolute inset-0 opacity-5 pointer-events-none"
|
||||
style={{
|
||||
background: `linear-gradient(135deg, ${primaryColor} 0%, ${accentColor} 100%)`,
|
||||
}}
|
||||
/>
|
||||
|
||||
<CardHeader className="relative">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-1">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Target className="w-5 h-5 animate-pulse" style={{ color: primaryColor }} />
|
||||
GOAP State Assessment
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Real-time state progression tracking
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-2xl font-bold" style={{ color: primaryColor }}>
|
||||
{progressPercentage}%
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{completedCount}/{totalCount} complete
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Overall Progress Bar */}
|
||||
<div className="mt-4">
|
||||
<Progress
|
||||
value={progressPercentage}
|
||||
className="h-2"
|
||||
style={{
|
||||
backgroundColor: `${primaryColor}20`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="space-y-4 relative">
|
||||
{/* State Comparison Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
{/* Current State */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2 pb-2 border-b">
|
||||
<Circle className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
<h4 className="text-sm font-semibold">System State</h4>
|
||||
<Badge variant="outline" className="ml-auto text-xs">
|
||||
Current
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
{currentStateEntries.map(([key, value], index) => {
|
||||
const isVisible = visibleStates.includes(key);
|
||||
const isAnimating = hasStateChanged(key);
|
||||
const isTrue = value === true;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`
|
||||
flex items-center gap-3 p-2 rounded-lg border transition-all duration-500
|
||||
${!isVisible ? 'opacity-0 translate-x-4' : 'opacity-100 translate-x-0'}
|
||||
${isAnimating ? 'ring-2 scale-105' : 'scale-100'}
|
||||
${isTrue ? 'bg-green-500/10 border-green-500/30' : 'bg-muted/50 border-border'}
|
||||
`}
|
||||
style={{
|
||||
animationDelay: `${index * 100}ms`,
|
||||
...(isAnimating && { ringColor: primaryColor }),
|
||||
}}
|
||||
>
|
||||
<div className={`
|
||||
flex items-center justify-center w-6 h-6 rounded-full transition-all duration-500
|
||||
${isTrue ? 'bg-green-500' : 'bg-muted'}
|
||||
`}>
|
||||
{isTrue ? (
|
||||
<CheckCircle2 className="w-4 h-4 text-white" />
|
||||
) : (
|
||||
<Circle className="w-4 h-4 text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1">
|
||||
<span className="font-mono text-xs font-medium">
|
||||
{key.replace(/_/g, ' ')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Badge
|
||||
variant={isTrue ? "default" : "secondary"}
|
||||
className={`text-xs transition-all duration-300 ${isAnimating ? 'animate-pulse' : ''}`}
|
||||
>
|
||||
{String(value)}
|
||||
</Badge>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Goal State */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2 pb-2 border-b">
|
||||
<CheckCircle2 className="w-4 h-4" style={{ color: accentColor }} />
|
||||
<h4 className="text-sm font-semibold" style={{ color: accentColor }}>
|
||||
Goal State
|
||||
</h4>
|
||||
<Badge variant="outline" className="ml-auto text-xs" style={{ borderColor: accentColor, color: accentColor }}>
|
||||
Target
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
{goalStateEntries.map(([key, value], index) => {
|
||||
const isVisible = visibleStates.includes(key);
|
||||
const isAchieved = currentState[key] === value;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`
|
||||
flex items-center gap-3 p-2 rounded-lg transition-all duration-500 border
|
||||
${!isVisible ? 'opacity-0 -translate-x-4' : 'opacity-100 translate-x-0'}
|
||||
${isAchieved ? 'bg-green-500/10 border-green-500/30' : ''}
|
||||
`}
|
||||
style={{
|
||||
backgroundColor: isAchieved ? undefined : `${accentColor}10`,
|
||||
borderColor: isAchieved ? undefined : `${accentColor}30`,
|
||||
animationDelay: `${index * 100}ms`,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={`
|
||||
flex items-center justify-center w-6 h-6 rounded-full transition-all duration-500
|
||||
${isAchieved ? 'bg-green-500' : ''}
|
||||
`}
|
||||
style={{
|
||||
backgroundColor: isAchieved ? undefined : accentColor,
|
||||
}}
|
||||
>
|
||||
<CheckCircle2 className="w-4 h-4 text-white" />
|
||||
</div>
|
||||
|
||||
<div className="flex-1">
|
||||
<span className="font-mono text-xs font-medium">
|
||||
{key.replace(/_/g, ' ')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Badge
|
||||
className="text-xs"
|
||||
style={{
|
||||
backgroundColor: isAchieved ? undefined : accentColor,
|
||||
color: 'white'
|
||||
}}
|
||||
>
|
||||
{String(value)}
|
||||
</Badge>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* State Transitions */}
|
||||
<div className="pt-2 border-t">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<ArrowRight className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
<h4 className="text-sm font-semibold">State Transitions</h4>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-2">
|
||||
{currentStateEntries.slice(0, 3).map(([key, currentValue], index) => {
|
||||
const goalValue = goalState[key];
|
||||
const isTransitioning = currentValue !== goalValue;
|
||||
const isVisible = visibleStates.includes(key);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`
|
||||
p-2 rounded-lg border bg-card transition-all duration-500
|
||||
${!isVisible ? 'opacity-0 translate-y-4' : 'opacity-100 translate-y-0'}
|
||||
`}
|
||||
style={{ animationDelay: `${(index + currentStateEntries.length) * 100}ms` }}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-xs font-mono font-medium">
|
||||
{key.replace(/_/g, ' ')}
|
||||
</span>
|
||||
{isTransitioning && (
|
||||
<Zap className="w-3 h-3 text-yellow-500 animate-pulse" />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
{String(currentValue)}
|
||||
</Badge>
|
||||
<ArrowRight className="w-3 h-3 text-muted-foreground" />
|
||||
<Badge
|
||||
className="text-xs"
|
||||
style={{ backgroundColor: accentColor, color: 'white' }}
|
||||
>
|
||||
{String(goalValue)}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* State Gaps - Animated List */}
|
||||
{stateGaps.length > 0 && (
|
||||
<div className="space-y-3 pt-4 border-t">
|
||||
<div className="flex items-center gap-2">
|
||||
<TrendingUp className="w-4 h-4" style={{ color: primaryColor }} />
|
||||
<h4 className="text-sm font-semibold">Action Plan</h4>
|
||||
<Badge variant="outline" className="ml-auto text-xs">
|
||||
{stateGaps.length} steps remaining
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{stateGaps.map((gap, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex items-start gap-3 p-3 rounded-lg border bg-card hover:bg-accent/50 transition-all duration-300 animate-fade-in group"
|
||||
style={{
|
||||
animationDelay: `${(idx + currentStateEntries.length * 2) * 100}ms`,
|
||||
animationFillMode: 'forwards',
|
||||
opacity: 0,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="flex items-center justify-center w-6 h-6 rounded-full font-bold text-xs transition-all duration-300 group-hover:scale-110"
|
||||
style={{
|
||||
backgroundColor: `${primaryColor}20`,
|
||||
color: primaryColor,
|
||||
}}
|
||||
>
|
||||
{idx + 1}
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm leading-relaxed">{gap}</p>
|
||||
</div>
|
||||
<ArrowRight className="w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity duration-300" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,454 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Settings, Palette, Type, Copy, Check, Sliders } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface WidgetConfig {
|
||||
primaryColor: string;
|
||||
accentColor: string;
|
||||
backgroundColor: string;
|
||||
cardBackgroundColor: string;
|
||||
cardBorderColor: string;
|
||||
textColor: string;
|
||||
secondaryTextColor: string;
|
||||
successColor: string;
|
||||
title: string;
|
||||
description: string;
|
||||
brandName: string;
|
||||
defaultGoal: string;
|
||||
fontFamily: string;
|
||||
borderRadius: string;
|
||||
animationSpeed: string;
|
||||
cardSpacing: string;
|
||||
showMetrics: boolean;
|
||||
showStats: boolean;
|
||||
compactMode: boolean;
|
||||
enableAI: boolean;
|
||||
aiModel: string;
|
||||
}
|
||||
|
||||
interface WidgetCustomizerProps {
|
||||
config: WidgetConfig;
|
||||
onConfigChange: (config: WidgetConfig) => void;
|
||||
onGenerate: () => void;
|
||||
}
|
||||
|
||||
export const WidgetCustomizer = ({ config, onConfigChange, onGenerate }: WidgetCustomizerProps) => {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [showEmbedCode, setShowEmbedCode] = useState(false);
|
||||
|
||||
const updateConfig = (key: keyof WidgetConfig, value: string | boolean) => {
|
||||
onConfigChange({ ...config, [key]: value });
|
||||
};
|
||||
|
||||
const generateEmbedCode = () => {
|
||||
const embedCode = `<!-- RuFlo Research Widget -->
|
||||
<div id="ruflo-research-widget-container"></div>
|
||||
<script>
|
||||
window.RufloResearchWidgetConfig = ${JSON.stringify(config, null, 2)};
|
||||
</script>
|
||||
<script src="${window.location.origin}/widget.js"></script>
|
||||
<style>
|
||||
#ruflo-research-widget-container {
|
||||
max-width: 100%;
|
||||
margin: 2rem auto;
|
||||
}
|
||||
</style>`;
|
||||
return embedCode;
|
||||
};
|
||||
|
||||
const copyEmbedCode = () => {
|
||||
navigator.clipboard.writeText(generateEmbedCode());
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
const ColorInput = ({ id, label, value, onChange }: { id: string; label: string; value: string; onChange: (value: string) => void }) => (
|
||||
<div>
|
||||
<Label htmlFor={id} className="text-xs text-muted-foreground">
|
||||
{label}
|
||||
</Label>
|
||||
<div className="flex gap-2 mt-1">
|
||||
<Input
|
||||
id={id}
|
||||
type="color"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="w-16 h-10 p-1 cursor-pointer"
|
||||
/>
|
||||
<Input
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="flex-1 text-xs"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
|
||||
<p className="text-xs sm:text-sm text-muted-foreground">
|
||||
Customize the appearance and content of your embeddable research widget
|
||||
</p>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setShowEmbedCode(!showEmbedCode);
|
||||
if (!showEmbedCode) {
|
||||
onGenerate();
|
||||
}
|
||||
}}
|
||||
size="sm"
|
||||
variant={showEmbedCode ? "outline" : "default"}
|
||||
className="w-full sm:w-auto text-xs sm:text-sm whitespace-nowrap"
|
||||
>
|
||||
{showEmbedCode ? "Hide Code" : "Generate Embed Code"}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="colors" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-2 sm:grid-cols-4 gap-1">
|
||||
<TabsTrigger value="colors" className="text-xs sm:text-sm">Colors</TabsTrigger>
|
||||
<TabsTrigger value="content" className="text-xs sm:text-sm">Content</TabsTrigger>
|
||||
<TabsTrigger value="layout" className="text-xs sm:text-sm">Layout</TabsTrigger>
|
||||
<TabsTrigger value="ai" className="text-xs sm:text-sm">AI Settings</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="colors" className="space-y-4 mt-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">Primary Colors</h3>
|
||||
<ColorInput
|
||||
id="primaryColor"
|
||||
label="Primary Color"
|
||||
value={config.primaryColor}
|
||||
onChange={(value) => updateConfig("primaryColor", value)}
|
||||
/>
|
||||
<ColorInput
|
||||
id="accentColor"
|
||||
label="Accent Color"
|
||||
value={config.accentColor}
|
||||
onChange={(value) => updateConfig("accentColor", value)}
|
||||
/>
|
||||
<ColorInput
|
||||
id="successColor"
|
||||
label="Success Color"
|
||||
value={config.successColor}
|
||||
onChange={(value) => updateConfig("successColor", value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">Background & Card Colors</h3>
|
||||
<ColorInput
|
||||
id="backgroundColor"
|
||||
label="Background Color"
|
||||
value={config.backgroundColor}
|
||||
onChange={(value) => updateConfig("backgroundColor", value)}
|
||||
/>
|
||||
<ColorInput
|
||||
id="cardBackgroundColor"
|
||||
label="Card Background"
|
||||
value={config.cardBackgroundColor}
|
||||
onChange={(value) => updateConfig("cardBackgroundColor", value)}
|
||||
/>
|
||||
<ColorInput
|
||||
id="cardBorderColor"
|
||||
label="Card Border"
|
||||
value={config.cardBorderColor}
|
||||
onChange={(value) => updateConfig("cardBorderColor", value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 md:col-span-2">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">Text Colors</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<ColorInput
|
||||
id="textColor"
|
||||
label="Primary Text"
|
||||
value={config.textColor}
|
||||
onChange={(value) => updateConfig("textColor", value)}
|
||||
/>
|
||||
<ColorInput
|
||||
id="secondaryTextColor"
|
||||
label="Secondary Text"
|
||||
value={config.secondaryTextColor}
|
||||
onChange={(value) => updateConfig("secondaryTextColor", value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="content" className="space-y-4 mt-4">
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label htmlFor="title" className="text-xs text-muted-foreground">
|
||||
Widget Title
|
||||
</Label>
|
||||
<Input
|
||||
id="title"
|
||||
value={config.title}
|
||||
onChange={(e) => updateConfig("title", e.target.value)}
|
||||
className="mt-1"
|
||||
placeholder="Goal-Oriented Action Planning"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="description" className="text-xs text-muted-foreground">
|
||||
Description
|
||||
</Label>
|
||||
<Textarea
|
||||
id="description"
|
||||
value={config.description}
|
||||
onChange={(e) => updateConfig("description", e.target.value)}
|
||||
className="mt-1 min-h-[80px]"
|
||||
placeholder="AI-powered research planning..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="brandName" className="text-xs text-muted-foreground">
|
||||
Brand Name (optional)
|
||||
</Label>
|
||||
<Input
|
||||
id="brandName"
|
||||
value={config.brandName}
|
||||
onChange={(e) => updateConfig("brandName", e.target.value)}
|
||||
className="mt-1"
|
||||
placeholder="Your Company"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="defaultGoal" className="text-xs text-muted-foreground">
|
||||
Default Research Goal
|
||||
</Label>
|
||||
<Input
|
||||
id="defaultGoal"
|
||||
value={config.defaultGoal}
|
||||
onChange={(e) => updateConfig("defaultGoal", e.target.value)}
|
||||
className="mt-1"
|
||||
placeholder="Research latest AI advancements"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="layout" className="space-y-4 mt-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">Typography & Spacing</h3>
|
||||
<div>
|
||||
<Label htmlFor="fontFamily" className="text-xs text-muted-foreground">
|
||||
Font Family
|
||||
</Label>
|
||||
<Select value={config.fontFamily} onValueChange={(value) => updateConfig("fontFamily", value)}>
|
||||
<SelectTrigger className="mt-1">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="system-ui">System UI</SelectItem>
|
||||
<SelectItem value="Inter, sans-serif">Inter</SelectItem>
|
||||
<SelectItem value="Roboto, sans-serif">Roboto</SelectItem>
|
||||
<SelectItem value="'Open Sans', sans-serif">Open Sans</SelectItem>
|
||||
<SelectItem value="'Poppins', sans-serif">Poppins</SelectItem>
|
||||
<SelectItem value="monospace">Monospace</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="borderRadius" className="text-xs text-muted-foreground">
|
||||
Border Radius
|
||||
</Label>
|
||||
<Select value={config.borderRadius} onValueChange={(value) => updateConfig("borderRadius", value)}>
|
||||
<SelectTrigger className="mt-1">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">None (0px)</SelectItem>
|
||||
<SelectItem value="0.25rem">Small (4px)</SelectItem>
|
||||
<SelectItem value="0.5rem">Medium (8px)</SelectItem>
|
||||
<SelectItem value="0.75rem">Large (12px)</SelectItem>
|
||||
<SelectItem value="1rem">XL (16px)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="cardSpacing" className="text-xs text-muted-foreground">
|
||||
Card Spacing
|
||||
</Label>
|
||||
<Select value={config.cardSpacing} onValueChange={(value) => updateConfig("cardSpacing", value)}>
|
||||
<SelectTrigger className="mt-1">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0.5rem">Tight</SelectItem>
|
||||
<SelectItem value="1rem">Normal</SelectItem>
|
||||
<SelectItem value="1.5rem">Relaxed</SelectItem>
|
||||
<SelectItem value="2rem">Loose</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="animationSpeed" className="text-xs text-muted-foreground">
|
||||
Animation Speed
|
||||
</Label>
|
||||
<Select value={config.animationSpeed} onValueChange={(value) => updateConfig("animationSpeed", value)}>
|
||||
<SelectTrigger className="mt-1">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="fast">Fast</SelectItem>
|
||||
<SelectItem value="normal">Normal</SelectItem>
|
||||
<SelectItem value="slow">Slow</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">Display Options</h3>
|
||||
<div className="space-y-3 pt-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="showMetrics" className="text-xs text-muted-foreground">
|
||||
Show Metrics
|
||||
</Label>
|
||||
<Switch
|
||||
id="showMetrics"
|
||||
checked={config.showMetrics}
|
||||
onCheckedChange={(checked) => updateConfig("showMetrics", checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="showStats" className="text-xs text-muted-foreground">
|
||||
Show Stats
|
||||
</Label>
|
||||
<Switch
|
||||
id="showStats"
|
||||
checked={config.showStats}
|
||||
onCheckedChange={(checked) => updateConfig("showStats", checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="compactMode" className="text-xs text-muted-foreground">
|
||||
Compact Mode
|
||||
</Label>
|
||||
<Switch
|
||||
id="compactMode"
|
||||
checked={config.compactMode}
|
||||
onCheckedChange={(checked) => updateConfig("compactMode", checked)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="ai" className="space-y-4 mt-4">
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-xs sm:text-sm font-medium text-foreground">AI Research Settings</h3>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Configure AI-powered research data generation using Google Gemini models
|
||||
</p>
|
||||
|
||||
<div className="flex items-center justify-between pt-2">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="enableAI" className="text-xs text-muted-foreground">
|
||||
Enable AI Research
|
||||
</Label>
|
||||
<p className="text-[10px] text-muted-foreground/70">
|
||||
Use AI to generate real research data instead of mock data
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="enableAI"
|
||||
checked={config.enableAI}
|
||||
onCheckedChange={(checked) => updateConfig("enableAI", checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{config.enableAI && (
|
||||
<div className="space-y-2 pt-2">
|
||||
<Label htmlFor="aiModel" className="text-xs text-muted-foreground">
|
||||
AI Model
|
||||
</Label>
|
||||
<Select value={config.aiModel} onValueChange={(value) => updateConfig("aiModel", value)}>
|
||||
<SelectTrigger className="mt-1">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="google/gemini-2.5-flash">
|
||||
Gemini 2.5 Flash (Balanced)
|
||||
</SelectItem>
|
||||
<SelectItem value="google/gemini-2.5-pro">
|
||||
Gemini 2.5 Pro (Most Powerful)
|
||||
</SelectItem>
|
||||
<SelectItem value="google/gemini-2.5-flash-lite">
|
||||
Gemini 2.5 Flash Lite (Fastest)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p className="text-[10px] text-muted-foreground/70">
|
||||
{config.aiModel === "google/gemini-2.5-pro" && "Best for complex reasoning and accuracy"}
|
||||
{config.aiModel === "google/gemini-2.5-flash" && "Balanced performance and speed"}
|
||||
{config.aiModel === "google/gemini-2.5-flash-lite" && "Optimized for speed and cost"}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
{/* Embed Code Section */}
|
||||
{showEmbedCode && (
|
||||
<div className="space-y-3 animate-fade-in border-t border-border pt-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label className="text-sm font-medium text-foreground">Embed Code</Label>
|
||||
<Button
|
||||
onClick={copyEmbedCode}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="gap-2"
|
||||
>
|
||||
{copied ? (
|
||||
<>
|
||||
<Check className="w-3 h-3" />
|
||||
Copied!
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Copy className="w-3 h-3" />
|
||||
Copy Code
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<pre className="bg-muted/50 border border-border rounded p-4 text-xs overflow-x-auto">
|
||||
<code className="text-foreground">{generateEmbedCode()}</code>
|
||||
</pre>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Copy this code and paste it into your website where you want the widget to appear.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,658 @@
|
||||
import { useState } from "react";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Slider } from "@/components/ui/slider";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Settings2, Save, RotateCcw } from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
|
||||
interface AdvancedSettings {
|
||||
// Swarm Configuration
|
||||
swarm: {
|
||||
topology: 'mesh' | 'hierarchical' | 'ring' | 'star';
|
||||
maxAgents: number;
|
||||
strategy: 'balanced' | 'specialized' | 'adaptive';
|
||||
autoScaling: {
|
||||
enabled: boolean;
|
||||
minAgents: number;
|
||||
maxAgents: number;
|
||||
scaleUpThreshold: number;
|
||||
scaleDownThreshold: number;
|
||||
};
|
||||
};
|
||||
|
||||
// GOAP Configuration
|
||||
goap: {
|
||||
algorithm: 'a-star' | 'greedy' | 'dijkstra' | 'bfs' | 'dfs';
|
||||
heuristic: 'manhattan' | 'euclidean' | 'hamming' | 'custom';
|
||||
costMethod: 'uniform' | 'time' | 'resources' | 'tokens' | 'hybrid';
|
||||
optimization: {
|
||||
enabled: boolean;
|
||||
detectParallel: boolean;
|
||||
removeRedundant: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
// Execution Configuration
|
||||
execution: {
|
||||
strategy: 'sequential' | 'parallel' | 'hybrid' | 'adaptive';
|
||||
maxParallelTasks: number;
|
||||
timeout: number;
|
||||
enableQualityGates: boolean;
|
||||
};
|
||||
|
||||
// Model Router Configuration
|
||||
modelRouter: {
|
||||
primaryProvider: 'anthropic' | 'openrouter' | 'gemini' | 'local';
|
||||
strategy: 'cost' | 'speed' | 'quality' | 'privacy' | 'balanced';
|
||||
maxCostPerRequest: number;
|
||||
enableFallback: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
const defaultSettings: AdvancedSettings = {
|
||||
swarm: {
|
||||
topology: 'hierarchical',
|
||||
maxAgents: 10,
|
||||
strategy: 'adaptive',
|
||||
autoScaling: {
|
||||
enabled: true,
|
||||
minAgents: 2,
|
||||
maxAgents: 20,
|
||||
scaleUpThreshold: 80,
|
||||
scaleDownThreshold: 20,
|
||||
},
|
||||
},
|
||||
goap: {
|
||||
algorithm: 'a-star',
|
||||
heuristic: 'manhattan',
|
||||
costMethod: 'hybrid',
|
||||
optimization: {
|
||||
enabled: true,
|
||||
detectParallel: true,
|
||||
removeRedundant: true,
|
||||
},
|
||||
},
|
||||
execution: {
|
||||
strategy: 'adaptive',
|
||||
maxParallelTasks: 5,
|
||||
timeout: 300000,
|
||||
enableQualityGates: true,
|
||||
},
|
||||
modelRouter: {
|
||||
primaryProvider: 'anthropic',
|
||||
strategy: 'balanced',
|
||||
maxCostPerRequest: 1.0,
|
||||
enableFallback: true,
|
||||
},
|
||||
};
|
||||
|
||||
const presets = {
|
||||
development: {
|
||||
name: 'Development',
|
||||
description: 'Fast iteration, verbose logging',
|
||||
badge: 'default' as const,
|
||||
},
|
||||
production: {
|
||||
name: 'Production',
|
||||
description: 'Optimized performance, strict validation',
|
||||
badge: 'default' as const,
|
||||
},
|
||||
budget: {
|
||||
name: 'Budget',
|
||||
description: 'Cost-optimized, slower execution',
|
||||
badge: 'secondary' as const,
|
||||
},
|
||||
quality: {
|
||||
name: 'Quality',
|
||||
description: 'Maximum quality, higher cost',
|
||||
badge: 'destructive' as const,
|
||||
},
|
||||
};
|
||||
|
||||
export function AdvancedSettingsModal() {
|
||||
const [settings, setSettings] = useState<AdvancedSettings>(() => {
|
||||
const saved = localStorage.getItem('agenticflow-settings');
|
||||
return saved ? JSON.parse(saved) : defaultSettings;
|
||||
});
|
||||
const [open, setOpen] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
const handleSave = () => {
|
||||
localStorage.setItem('agenticflow-settings', JSON.stringify(settings));
|
||||
toast({
|
||||
title: "Settings Saved",
|
||||
description: "Your advanced configuration has been saved.",
|
||||
});
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
setSettings(defaultSettings);
|
||||
toast({
|
||||
title: "Settings Reset",
|
||||
description: "Configuration has been reset to defaults.",
|
||||
});
|
||||
};
|
||||
|
||||
const applyPreset = (presetName: keyof typeof presets) => {
|
||||
const presetConfigs: Record<keyof typeof presets, Partial<AdvancedSettings>> = {
|
||||
development: {
|
||||
swarm: { ...settings.swarm, maxAgents: 5, strategy: 'balanced' },
|
||||
execution: { ...settings.execution, strategy: 'sequential', enableQualityGates: false },
|
||||
modelRouter: { ...settings.modelRouter, strategy: 'speed' },
|
||||
},
|
||||
production: {
|
||||
swarm: { ...settings.swarm, maxAgents: 15, strategy: 'adaptive' },
|
||||
execution: { ...settings.execution, strategy: 'adaptive', enableQualityGates: true },
|
||||
modelRouter: { ...settings.modelRouter, strategy: 'balanced' },
|
||||
},
|
||||
budget: {
|
||||
swarm: { ...settings.swarm, maxAgents: 3, strategy: 'specialized' },
|
||||
execution: { ...settings.execution, strategy: 'sequential', maxParallelTasks: 2 },
|
||||
modelRouter: { ...settings.modelRouter, primaryProvider: 'openrouter', strategy: 'cost' },
|
||||
},
|
||||
quality: {
|
||||
swarm: { ...settings.swarm, maxAgents: 20, strategy: 'adaptive' },
|
||||
execution: { ...settings.execution, strategy: 'parallel', enableQualityGates: true },
|
||||
modelRouter: { ...settings.modelRouter, primaryProvider: 'anthropic', strategy: 'quality' },
|
||||
},
|
||||
};
|
||||
|
||||
setSettings({ ...settings, ...presetConfigs[presetName] });
|
||||
toast({
|
||||
title: `${presets[presetName].name} Preset Applied`,
|
||||
description: presets[presetName].description,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="gap-2">
|
||||
<Settings2 className="w-4 h-4" />
|
||||
Advanced Settings
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
<Settings2 className="w-5 h-5 text-purple-500" />
|
||||
Advanced Agent Configuration
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Configure swarm topology, GOAP planning, execution strategy, and model routing
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{/* Presets */}
|
||||
<div className="space-y-2">
|
||||
<Label>Quick Presets</Label>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
|
||||
{Object.entries(presets).map(([key, preset]) => (
|
||||
<Button
|
||||
key={key}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => applyPreset(key as keyof typeof presets)}
|
||||
className="flex flex-col h-auto py-3 items-start"
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="font-semibold">{preset.name}</span>
|
||||
<Badge variant={preset.badge} className="text-xs">
|
||||
{key}
|
||||
</Badge>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground text-left">
|
||||
{preset.description}
|
||||
</span>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="swarm" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsTrigger value="swarm">Swarm</TabsTrigger>
|
||||
<TabsTrigger value="goap">GOAP</TabsTrigger>
|
||||
<TabsTrigger value="execution">Execution</TabsTrigger>
|
||||
<TabsTrigger value="model">Model</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Swarm Configuration */}
|
||||
<TabsContent value="swarm" className="space-y-4 mt-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="topology">Topology</Label>
|
||||
<Select
|
||||
value={settings.swarm.topology}
|
||||
onValueChange={(value: AdvancedSettings['swarm']['topology']) =>
|
||||
setSettings({ ...settings, swarm: { ...settings.swarm, topology: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="topology">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="mesh">Mesh - Fully connected, peer-to-peer</SelectItem>
|
||||
<SelectItem value="hierarchical">Hierarchical - Tree structure with coordinators</SelectItem>
|
||||
<SelectItem value="ring">Ring - Circular communication</SelectItem>
|
||||
<SelectItem value="star">Star - Centralized coordinator</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="maxAgents">Maximum Agents: {settings.swarm.maxAgents}</Label>
|
||||
<Slider
|
||||
id="maxAgents"
|
||||
min={1}
|
||||
max={50}
|
||||
step={1}
|
||||
value={[settings.swarm.maxAgents]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({ ...settings, swarm: { ...settings.swarm, maxAgents: value } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="strategy">Distribution Strategy</Label>
|
||||
<Select
|
||||
value={settings.swarm.strategy}
|
||||
onValueChange={(value: AdvancedSettings['swarm']['strategy']) =>
|
||||
setSettings({ ...settings, swarm: { ...settings.swarm, strategy: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="strategy">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="balanced">Balanced - Evenly distribute tasks</SelectItem>
|
||||
<SelectItem value="specialized">Specialized - Assign based on capabilities</SelectItem>
|
||||
<SelectItem value="adaptive">Adaptive - Dynamic based on load</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 border rounded-lg p-4 bg-muted/30">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="autoScaling">Auto-Scaling</Label>
|
||||
<Switch
|
||||
id="autoScaling"
|
||||
checked={settings.swarm.autoScaling.enabled}
|
||||
onCheckedChange={(enabled) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
swarm: {
|
||||
...settings.swarm,
|
||||
autoScaling: { ...settings.swarm.autoScaling, enabled },
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{settings.swarm.autoScaling.enabled && (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label>Min Agents</Label>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={settings.swarm.autoScaling.minAgents}
|
||||
onChange={(e) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
swarm: {
|
||||
...settings.swarm,
|
||||
autoScaling: {
|
||||
...settings.swarm.autoScaling,
|
||||
minAgents: parseInt(e.target.value),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Max Agents</Label>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={settings.swarm.autoScaling.maxAgents}
|
||||
onChange={(e) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
swarm: {
|
||||
...settings.swarm,
|
||||
autoScaling: {
|
||||
...settings.swarm.autoScaling,
|
||||
maxAgents: parseInt(e.target.value),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label>Scale Up Threshold (%): {settings.swarm.autoScaling.scaleUpThreshold}</Label>
|
||||
<Slider
|
||||
min={0}
|
||||
max={100}
|
||||
step={5}
|
||||
value={[settings.swarm.autoScaling.scaleUpThreshold]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
swarm: {
|
||||
...settings.swarm,
|
||||
autoScaling: { ...settings.swarm.autoScaling, scaleUpThreshold: value },
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label>Scale Down Threshold (%): {settings.swarm.autoScaling.scaleDownThreshold}</Label>
|
||||
<Slider
|
||||
min={0}
|
||||
max={100}
|
||||
step={5}
|
||||
value={[settings.swarm.autoScaling.scaleDownThreshold]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
swarm: {
|
||||
...settings.swarm,
|
||||
autoScaling: { ...settings.swarm.autoScaling, scaleDownThreshold: value },
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* GOAP Configuration */}
|
||||
<TabsContent value="goap" className="space-y-4 mt-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="algorithm">Planning Algorithm</Label>
|
||||
<Select
|
||||
value={settings.goap.algorithm}
|
||||
onValueChange={(value: AdvancedSettings['goap']['algorithm']) =>
|
||||
setSettings({ ...settings, goap: { ...settings.goap, algorithm: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="algorithm">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="a-star">A* - Optimal pathfinding</SelectItem>
|
||||
<SelectItem value="greedy">Greedy - Fast, not optimal</SelectItem>
|
||||
<SelectItem value="dijkstra">Dijkstra - Guaranteed optimal</SelectItem>
|
||||
<SelectItem value="bfs">BFS - Breadth-first search</SelectItem>
|
||||
<SelectItem value="dfs">DFS - Depth-first search</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="heuristic">Heuristic Function</Label>
|
||||
<Select
|
||||
value={settings.goap.heuristic}
|
||||
onValueChange={(value: AdvancedSettings['goap']['heuristic']) =>
|
||||
setSettings({ ...settings, goap: { ...settings.goap, heuristic: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="heuristic">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="manhattan">Manhattan Distance</SelectItem>
|
||||
<SelectItem value="euclidean">Euclidean Distance</SelectItem>
|
||||
<SelectItem value="hamming">Hamming Distance</SelectItem>
|
||||
<SelectItem value="custom">Custom Heuristic</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="costMethod">Cost Calculation Method</Label>
|
||||
<Select
|
||||
value={settings.goap.costMethod}
|
||||
onValueChange={(value: AdvancedSettings['goap']['costMethod']) =>
|
||||
setSettings({ ...settings, goap: { ...settings.goap, costMethod: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="costMethod">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="uniform">Uniform - All actions same cost</SelectItem>
|
||||
<SelectItem value="time">Time - Based on execution time</SelectItem>
|
||||
<SelectItem value="resources">Resources - Based on resource usage</SelectItem>
|
||||
<SelectItem value="tokens">Tokens - Based on token consumption</SelectItem>
|
||||
<SelectItem value="hybrid">Hybrid - Combination of factors</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 border rounded-lg p-4 bg-muted/30">
|
||||
<Label>Optimization Options</Label>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label>Enable Optimization</Label>
|
||||
<p className="text-xs text-muted-foreground">Optimize generated plans</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={settings.goap.optimization.enabled}
|
||||
onCheckedChange={(enabled) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
goap: { ...settings.goap, optimization: { ...settings.goap.optimization, enabled } },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label>Detect Parallel Actions</Label>
|
||||
<p className="text-xs text-muted-foreground">Find actions that can run concurrently</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={settings.goap.optimization.detectParallel}
|
||||
onCheckedChange={(detectParallel) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
goap: { ...settings.goap, optimization: { ...settings.goap.optimization, detectParallel } },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label>Remove Redundant Actions</Label>
|
||||
<p className="text-xs text-muted-foreground">Eliminate unnecessary steps</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={settings.goap.optimization.removeRedundant}
|
||||
onCheckedChange={(removeRedundant) =>
|
||||
setSettings({
|
||||
...settings,
|
||||
goap: { ...settings.goap, optimization: { ...settings.goap.optimization, removeRedundant } },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Execution Configuration */}
|
||||
<TabsContent value="execution" className="space-y-4 mt-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="execStrategy">Execution Strategy</Label>
|
||||
<Select
|
||||
value={settings.execution.strategy}
|
||||
onValueChange={(value: AdvancedSettings['execution']['strategy']) =>
|
||||
setSettings({ ...settings, execution: { ...settings.execution, strategy: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="execStrategy">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="sequential">Sequential - One task at a time</SelectItem>
|
||||
<SelectItem value="parallel">Parallel - Maximum concurrency</SelectItem>
|
||||
<SelectItem value="hybrid">Hybrid - Mixed approach</SelectItem>
|
||||
<SelectItem value="adaptive">Adaptive - Dynamic based on load</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="maxParallelTasks">Max Parallel Tasks: {settings.execution.maxParallelTasks}</Label>
|
||||
<Slider
|
||||
id="maxParallelTasks"
|
||||
min={1}
|
||||
max={20}
|
||||
step={1}
|
||||
value={[settings.execution.maxParallelTasks]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({ ...settings, execution: { ...settings.execution, maxParallelTasks: value } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="timeout">Timeout (seconds): {settings.execution.timeout / 1000}</Label>
|
||||
<Slider
|
||||
id="timeout"
|
||||
min={30000}
|
||||
max={900000}
|
||||
step={30000}
|
||||
value={[settings.execution.timeout]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({ ...settings, execution: { ...settings.execution, timeout: value } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between border rounded-lg p-4 bg-muted/30">
|
||||
<div className="space-y-0.5">
|
||||
<Label>Enable Quality Gates</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Run compile checks, test coverage, code quality, and security scans
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={settings.execution.enableQualityGates}
|
||||
onCheckedChange={(enableQualityGates) =>
|
||||
setSettings({ ...settings, execution: { ...settings.execution, enableQualityGates } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Model Router Configuration */}
|
||||
<TabsContent value="model" className="space-y-4 mt-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="provider">Primary Provider</Label>
|
||||
<Select
|
||||
value={settings.modelRouter.primaryProvider}
|
||||
onValueChange={(value: AdvancedSettings['modelRouter']['primaryProvider']) =>
|
||||
setSettings({ ...settings, modelRouter: { ...settings.modelRouter, primaryProvider: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="provider">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="anthropic">Anthropic - Highest quality</SelectItem>
|
||||
<SelectItem value="openrouter">OpenRouter - 99% cost savings</SelectItem>
|
||||
<SelectItem value="gemini">Gemini - Optimized for speed</SelectItem>
|
||||
<SelectItem value="local">Local - Privacy-focused (ONNX)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="routingStrategy">Routing Strategy</Label>
|
||||
<Select
|
||||
value={settings.modelRouter.strategy}
|
||||
onValueChange={(value: AdvancedSettings['modelRouter']['strategy']) =>
|
||||
setSettings({ ...settings, modelRouter: { ...settings.modelRouter, strategy: value } })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="routingStrategy">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="cost">Cost - Prefer cheapest models</SelectItem>
|
||||
<SelectItem value="speed">Speed - Prefer fastest models</SelectItem>
|
||||
<SelectItem value="quality">Quality - Prefer highest quality</SelectItem>
|
||||
<SelectItem value="privacy">Privacy - Use local models only</SelectItem>
|
||||
<SelectItem value="balanced">Balanced - Optimize all factors</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="maxCost">Max Cost Per Request ($): {settings.modelRouter.maxCostPerRequest.toFixed(2)}</Label>
|
||||
<Slider
|
||||
id="maxCost"
|
||||
min={0.01}
|
||||
max={5.0}
|
||||
step={0.01}
|
||||
value={[settings.modelRouter.maxCostPerRequest]}
|
||||
onValueChange={([value]) =>
|
||||
setSettings({ ...settings, modelRouter: { ...settings.modelRouter, maxCostPerRequest: value } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between border rounded-lg p-4 bg-muted/30">
|
||||
<div className="space-y-0.5">
|
||||
<Label>Enable Fallback</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Automatically fallback to alternative providers on failure
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={settings.modelRouter.enableFallback}
|
||||
onCheckedChange={(enableFallback) =>
|
||||
setSettings({ ...settings, modelRouter: { ...settings.modelRouter, enableFallback } })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex items-center justify-between pt-4 border-t">
|
||||
<Button variant="outline" onClick={handleReset} className="gap-2">
|
||||
<RotateCcw className="w-4 h-4" />
|
||||
Reset to Defaults
|
||||
</Button>
|
||||
<Button onClick={handleSave} className="gap-2">
|
||||
<Save className="w-4 h-4" />
|
||||
Save Configuration
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
import { useState } from 'react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Bot, Cpu, HardDrive, Zap, Clock } from 'lucide-react';
|
||||
|
||||
interface Agent {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
status: string;
|
||||
currentTask?: string;
|
||||
}
|
||||
|
||||
interface AgentMetrics {
|
||||
tasksCompleted: number;
|
||||
tasksActive: number;
|
||||
tasksFailed: number;
|
||||
avgCompletionTime: number;
|
||||
totalTokens: number;
|
||||
uptime: number;
|
||||
}
|
||||
|
||||
interface AgentActivityPanelProps {
|
||||
agents: Agent[];
|
||||
metrics: Map<string, AgentMetrics>;
|
||||
}
|
||||
|
||||
export function AgentActivityPanel({ agents, metrics }: AgentActivityPanelProps) {
|
||||
const [selectedAgent, setSelectedAgent] = useState<Agent | null>(
|
||||
agents[0] || null
|
||||
);
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Bot className="w-5 h-5 text-blue-500" />
|
||||
Agent Activity Monitor
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Tabs value={selectedAgent?.id} onValueChange={(id) => {
|
||||
const agent = agents.find(a => a.id === id);
|
||||
if (agent) setSelectedAgent(agent);
|
||||
}}>
|
||||
<TabsList className="w-full grid grid-cols-3 lg:grid-cols-5 mb-4">
|
||||
{agents.map(agent => (
|
||||
<TabsTrigger key={agent.id} value={agent.id} className="gap-1 text-xs">
|
||||
<Bot className="w-3 h-3" />
|
||||
<span className="hidden sm:inline">{agent.name}</span>
|
||||
<Badge
|
||||
variant={
|
||||
agent.status === 'working'
|
||||
? 'default'
|
||||
: agent.status === 'idle'
|
||||
? 'secondary'
|
||||
: 'destructive'
|
||||
}
|
||||
className="ml-1 h-2 w-2 p-0 rounded-full"
|
||||
>
|
||||
<span className="sr-only">{agent.status}</span>
|
||||
</Badge>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
|
||||
{agents.map(agent => {
|
||||
const agentMetrics = metrics.get(agent.id);
|
||||
|
||||
return (
|
||||
<TabsContent key={agent.id} value={agent.id} className="space-y-4">
|
||||
{/* Agent Info */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<div className="text-sm font-medium text-muted-foreground">Agent Type</div>
|
||||
<Badge variant="outline" className="text-sm">{agent.type}</Badge>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<div className="text-sm font-medium text-muted-foreground">Status</div>
|
||||
<Badge
|
||||
variant={
|
||||
agent.status === 'working'
|
||||
? 'default'
|
||||
: agent.status === 'idle'
|
||||
? 'secondary'
|
||||
: 'destructive'
|
||||
}
|
||||
className="text-sm"
|
||||
>
|
||||
{agent.status}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Current Task */}
|
||||
{agent.currentTask && (
|
||||
<div className="p-3 bg-gradient-to-r from-purple-500/10 to-blue-500/10 border border-purple-500/20 rounded-lg">
|
||||
<div className="text-sm font-medium mb-1 flex items-center gap-2">
|
||||
<Zap className="w-4 h-4 text-yellow-500 animate-pulse" />
|
||||
Current Task
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{agent.currentTask}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Metrics */}
|
||||
{agentMetrics && (
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="p-3 bg-green-500/10 border border-green-500/20 rounded-lg">
|
||||
<div className="text-xs font-medium mb-1 text-muted-foreground">Tasks Completed</div>
|
||||
<div className="text-2xl font-bold text-green-500">
|
||||
{agentMetrics.tasksCompleted}
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-3 bg-blue-500/10 border border-blue-500/20 rounded-lg">
|
||||
<div className="text-xs font-medium mb-1 text-muted-foreground">Tasks Active</div>
|
||||
<div className="text-2xl font-bold text-blue-500">
|
||||
{agentMetrics.tasksActive}
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-3 bg-red-500/10 border border-red-500/20 rounded-lg">
|
||||
<div className="text-xs font-medium mb-1 text-muted-foreground">Tasks Failed</div>
|
||||
<div className="text-2xl font-bold text-red-500">
|
||||
{agentMetrics.tasksFailed}
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-3 bg-purple-500/10 border border-purple-500/20 rounded-lg">
|
||||
<div className="text-xs font-medium mb-1 text-muted-foreground">Avg Time</div>
|
||||
<div className="text-2xl font-bold text-purple-500">
|
||||
{formatDuration(agentMetrics.avgCompletionTime)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Resource Usage */}
|
||||
<div className="space-y-3 p-4 bg-muted/30 rounded-lg border">
|
||||
<h5 className="text-sm font-semibold mb-2">Resource Usage</h5>
|
||||
|
||||
<div>
|
||||
<div className="flex items-center justify-between text-sm mb-1">
|
||||
<span className="flex items-center gap-1">
|
||||
<Cpu className="w-4 h-4 text-blue-500" /> CPU Usage
|
||||
</span>
|
||||
<span className="font-mono">65%</span>
|
||||
</div>
|
||||
<Progress value={65} className="h-2" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="flex items-center justify-between text-sm mb-1">
|
||||
<span className="flex items-center gap-1">
|
||||
<HardDrive className="w-4 h-4 text-green-500" /> Memory Usage
|
||||
</span>
|
||||
<span className="font-mono">420 MB</span>
|
||||
</div>
|
||||
<Progress value={82} className="h-2" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="flex items-center justify-between text-sm mb-1">
|
||||
<span className="flex items-center gap-1">
|
||||
<Zap className="w-4 h-4 text-yellow-500" /> Token Usage
|
||||
</span>
|
||||
<span className="font-mono">{agentMetrics.totalTokens.toLocaleString()}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="pt-2 border-t">
|
||||
<div className="flex items-center justify-between text-xs text-muted-foreground">
|
||||
<span className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" /> Uptime
|
||||
</span>
|
||||
<span className="font-mono">{formatDuration(agentMetrics.uptime)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</TabsContent>
|
||||
);
|
||||
})}
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function formatDuration(ms: number): string {
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
if (seconds < 60) return `${seconds}s`;
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const remainingSeconds = seconds % 60;
|
||||
if (minutes < 60) return `${minutes}m ${remainingSeconds}s`;
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const remainingMinutes = minutes % 60;
|
||||
return `${hours}h ${remainingMinutes}m`;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { LucideIcon } from "lucide-react";
|
||||
|
||||
interface Agent {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: LucideIcon;
|
||||
status: "idle" | "working" | "blocked";
|
||||
currentTask?: string;
|
||||
}
|
||||
|
||||
interface AgentStatusCardProps {
|
||||
agent: Agent;
|
||||
}
|
||||
|
||||
const statusConfig = {
|
||||
idle: { color: "bg-muted text-muted-foreground", label: "Idle", pulse: false },
|
||||
working: { color: "bg-green-500/20 text-green-500 border-green-500/50", label: "Working", pulse: true },
|
||||
blocked: { color: "bg-red-500/20 text-red-500 border-red-500/50", label: "Blocked", pulse: false },
|
||||
};
|
||||
|
||||
export const AgentStatusCard = ({ agent }: AgentStatusCardProps) => {
|
||||
const Icon = agent.icon;
|
||||
const config = statusConfig[agent.status];
|
||||
|
||||
return (
|
||||
<Card className="border-2 hover:border-primary/50 transition-all">
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="flex items-center justify-between text-base">
|
||||
<div className="flex items-center gap-2">
|
||||
<Icon className="w-5 h-5 text-primary" />
|
||||
{agent.name}
|
||||
</div>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={`${config.color} ${config.pulse ? 'animate-pulse' : ''}`}
|
||||
>
|
||||
{config.label}
|
||||
</Badge>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{agent.currentTask ? (
|
||||
<p className="text-xs text-muted-foreground">{agent.currentTask}</p>
|
||||
) : (
|
||||
<p className="text-xs text-muted-foreground italic">Waiting for tasks...</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,108 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Eye, Code, FileText } from "lucide-react";
|
||||
|
||||
export const CodePreview = () => {
|
||||
const files = [
|
||||
{
|
||||
name: "auth.ts",
|
||||
language: "typescript",
|
||||
code: `import { Request, Response } from 'express';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
export const authenticate = async (req: Request, res: Response) => {
|
||||
const token = req.headers.authorization?.split(' ')[1];
|
||||
|
||||
if (!token) {
|
||||
return res.status(401).json({ error: 'No token provided' });
|
||||
}
|
||||
|
||||
try {
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET);
|
||||
req.user = decoded;
|
||||
return res.status(200).json({ success: true });
|
||||
} catch (error) {
|
||||
return res.status(401).json({ error: 'Invalid token' });
|
||||
}
|
||||
};`,
|
||||
agent: "Implementation",
|
||||
status: "modified",
|
||||
},
|
||||
{
|
||||
name: "auth.test.ts",
|
||||
language: "typescript",
|
||||
code: `import { authenticate } from './auth';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
describe('Authentication', () => {
|
||||
it('should reject requests without token', async () => {
|
||||
const req = { headers: {} } as Request;
|
||||
const res = {
|
||||
status: jest.fn().mockReturnThis(),
|
||||
json: jest.fn()
|
||||
} as unknown as Response;
|
||||
|
||||
await authenticate(req, res);
|
||||
|
||||
expect(res.status).toHaveBeenCalledWith(401);
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
error: 'No token provided'
|
||||
});
|
||||
});
|
||||
});`,
|
||||
agent: "Testing",
|
||||
status: "new",
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Eye className="w-5 h-5 text-primary" />
|
||||
Live Code Preview
|
||||
</CardTitle>
|
||||
<CardDescription>Real-time view of generated code</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Tabs defaultValue={files[0].name}>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
{files.map((file) => (
|
||||
<TabsTrigger key={file.name} value={file.name} className="gap-2">
|
||||
<Code className="w-3 h-3" />
|
||||
{file.name}
|
||||
<Badge
|
||||
variant={file.status === "new" ? "default" : "secondary"}
|
||||
className="text-xs ml-2"
|
||||
>
|
||||
{file.status}
|
||||
</Badge>
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
|
||||
{files.map((file) => (
|
||||
<TabsContent key={file.name} value={file.name} className="mt-4">
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<Badge variant="outline">{file.language}</Badge>
|
||||
<Badge variant="outline">Agent: {file.agent}</Badge>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[500px] w-full">
|
||||
<pre className="p-4 rounded-lg bg-muted/50 text-sm font-mono">
|
||||
<code>{file.code}</code>
|
||||
</pre>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</TabsContent>
|
||||
))}
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { MessageSquare, ArrowRight } from "lucide-react";
|
||||
|
||||
export const CommunicationLog = () => {
|
||||
const messages = [
|
||||
{
|
||||
id: 1,
|
||||
from: "Architecture",
|
||||
to: "Implementation",
|
||||
message: "Database schema design completed. Ready for implementation.",
|
||||
timestamp: "2m ago",
|
||||
type: "info",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
from: "Implementation",
|
||||
to: "Testing",
|
||||
message: "Auth module implemented. Please write unit tests.",
|
||||
timestamp: "1m ago",
|
||||
type: "request",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
from: "Testing",
|
||||
to: "Code Review",
|
||||
message: "Test coverage at 85%. Ready for review.",
|
||||
timestamp: "30s ago",
|
||||
type: "success",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
from: "Code Review",
|
||||
to: "Implementation",
|
||||
message: "Security concern found in auth middleware. Please fix.",
|
||||
timestamp: "10s ago",
|
||||
type: "warning",
|
||||
},
|
||||
];
|
||||
|
||||
const typeColors = {
|
||||
info: "bg-blue-500/20 text-blue-500",
|
||||
request: "bg-purple-500/20 text-purple-500",
|
||||
success: "bg-green-500/20 text-green-500",
|
||||
warning: "bg-yellow-500/20 text-yellow-500",
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<MessageSquare className="w-5 h-5 text-primary" />
|
||||
Inter-Agent Communication
|
||||
</CardTitle>
|
||||
<CardDescription>Real-time message exchange between agents</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ScrollArea className="h-[300px] pr-4">
|
||||
<div className="space-y-3">
|
||||
{messages.map((msg) => (
|
||||
<div
|
||||
key={msg.id}
|
||||
className="p-3 rounded-lg border bg-card/50 hover:bg-card transition-colors"
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{msg.from}
|
||||
</Badge>
|
||||
<ArrowRight className="w-3 h-3 text-muted-foreground" />
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{msg.to}
|
||||
</Badge>
|
||||
<Badge className={`ml-auto text-xs ${typeColors[msg.type as keyof typeof typeColors]}`}>
|
||||
{msg.type}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="text-sm">{msg.message}</p>
|
||||
<p className="text-xs text-muted-foreground mt-2">{msg.timestamp}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { GitBranch, ArrowRight } from "lucide-react";
|
||||
|
||||
export const DependencyGraph = () => {
|
||||
const dependencies = [
|
||||
{ from: "Architecture", to: "Implementation", status: "complete" },
|
||||
{ from: "Implementation", to: "Testing", status: "active" },
|
||||
{ from: "Testing", to: "Code Review", status: "pending" },
|
||||
{ from: "Code Review", to: "Documentation", status: "pending" },
|
||||
{ from: "Documentation", to: "DevOps", status: "pending" },
|
||||
];
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-purple-500/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<GitBranch className="w-5 h-5 text-purple-500" />
|
||||
Task Dependencies
|
||||
</CardTitle>
|
||||
<CardDescription>Workflow execution order</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-3">
|
||||
{dependencies.map((dep, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex items-center gap-3 p-3 rounded-lg border bg-card/50"
|
||||
>
|
||||
<div className="flex-1 text-sm font-medium">{dep.from}</div>
|
||||
<ArrowRight className="w-4 h-4 text-muted-foreground" />
|
||||
<div className="flex-1 text-sm font-medium">{dep.to}</div>
|
||||
<div
|
||||
className={`w-2 h-2 rounded-full ${
|
||||
dep.status === "complete"
|
||||
? "bg-green-500"
|
||||
: dep.status === "active"
|
||||
? "bg-blue-500 animate-pulse"
|
||||
: "bg-muted"
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,403 @@
|
||||
import { useState } from "react";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
Network,
|
||||
Clock,
|
||||
Coins,
|
||||
Play,
|
||||
SkipForward,
|
||||
RotateCw,
|
||||
CheckCircle2,
|
||||
Circle,
|
||||
Download,
|
||||
Search,
|
||||
Cpu,
|
||||
HardDrive,
|
||||
Zap,
|
||||
Activity
|
||||
} from "lucide-react";
|
||||
|
||||
interface ExecutionDashboardProps {
|
||||
isRunning: boolean;
|
||||
currentPhase: number;
|
||||
onResume: () => void;
|
||||
onSkip: () => void;
|
||||
onRetry: () => void;
|
||||
}
|
||||
|
||||
export const ExecutionDashboard = ({
|
||||
isRunning,
|
||||
currentPhase,
|
||||
onResume,
|
||||
onSkip,
|
||||
onRetry
|
||||
}: ExecutionDashboardProps) => {
|
||||
const [executionView, setExecutionView] = useState<"graph" | "timeline">("graph");
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
const actions = [
|
||||
{ id: '1', name: 'Goal Assessment', cost: 2, status: 'completed' },
|
||||
{ id: '2', name: 'Architecture Planning', cost: 3, status: currentPhase >= 2 ? 'completed' : currentPhase === 1 ? 'active' : 'pending' },
|
||||
{ id: '3', name: 'Implementation', cost: 5, status: currentPhase >= 3 ? 'completed' : currentPhase === 2 ? 'active' : 'pending' },
|
||||
{ id: '4', name: 'Testing & Review', cost: 4, status: currentPhase >= 4 ? 'completed' : currentPhase === 3 ? 'active' : 'pending' },
|
||||
{ id: '5', name: 'Documentation & Deployment', cost: 3, status: currentPhase >= 5 ? 'completed' : currentPhase === 4 ? 'active' : 'pending' }
|
||||
];
|
||||
|
||||
const agents = [
|
||||
{ name: "Architecture", status: currentPhase === 1 ? "working" : "idle", tasksCompleted: 3 },
|
||||
{ name: "Implementation", status: currentPhase === 2 ? "working" : "idle", tasksCompleted: 7 },
|
||||
{ name: "Testing", status: currentPhase === 3 ? "working" : "idle", tasksCompleted: 5 },
|
||||
{ name: "Code Review", status: currentPhase === 3 ? "working" : "idle", tasksCompleted: 4 },
|
||||
{ name: "Documentation", status: currentPhase === 4 ? "working" : "idle", tasksCompleted: 2 },
|
||||
{ name: "DevOps", status: currentPhase === 4 ? "working" : "idle", tasksCompleted: 6 }
|
||||
];
|
||||
|
||||
const events = [
|
||||
{ type: 'PLAN_GENERATED', time: '2:49:19 PM', data: { actions: 5 } },
|
||||
{ type: 'AGENT_STARTED', time: '2:49:20 PM', data: { agent: 'Architecture' } },
|
||||
{ type: 'STEP_COMPLETED', time: '2:49:22 PM', data: { step: 'Analysis' } }
|
||||
];
|
||||
|
||||
const currentAction = actions[Math.min(currentPhase, actions.length - 1)];
|
||||
const completedActions = actions.filter(a => a.status === 'completed').length;
|
||||
const totalCost = actions.reduce((sum, a) => sum + a.cost, 0);
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-primary/30 shadow-lg">
|
||||
<CardHeader className="border-b bg-gradient-to-r from-primary/5 to-blue-500/5">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle className="flex items-center gap-2 text-lg">
|
||||
<Activity className="w-5 h-5 text-primary" />
|
||||
Execution Dashboard
|
||||
</CardTitle>
|
||||
<CardDescription className="mt-1">
|
||||
Real-time monitoring and control
|
||||
</CardDescription>
|
||||
</div>
|
||||
{isRunning && (
|
||||
<Badge className="animate-pulse bg-primary">
|
||||
<span className="inline-block w-2 h-2 bg-white rounded-full mr-2 animate-pulse"></span>
|
||||
Executing
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<Tabs defaultValue="execution" className="w-full">
|
||||
<TabsList className="w-full grid grid-cols-4 rounded-none border-b">
|
||||
<TabsTrigger value="execution">Execution Plan</TabsTrigger>
|
||||
<TabsTrigger value="current">Current Step</TabsTrigger>
|
||||
<TabsTrigger value="agents">Agent Activity</TabsTrigger>
|
||||
<TabsTrigger value="events">Event Log</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Execution Plan Tab */}
|
||||
<TabsContent value="execution" className="p-6 space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex gap-4">
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Network className="w-4 h-4 text-primary" />
|
||||
<span className="font-semibold">{actions.length} Actions</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Coins className="w-4 h-4 text-amber-500" />
|
||||
<span className="font-semibold">Cost: {totalCost}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Clock className="w-4 h-4 text-blue-500" />
|
||||
<span className="font-semibold">Est. 8m</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant={executionView === "graph" ? "default" : "outline"}
|
||||
size="sm"
|
||||
onClick={() => setExecutionView("graph")}
|
||||
>
|
||||
Graph View
|
||||
</Button>
|
||||
<Button
|
||||
variant={executionView === "timeline" ? "default" : "outline"}
|
||||
size="sm"
|
||||
onClick={() => setExecutionView("timeline")}
|
||||
>
|
||||
Timeline View
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[300px]">
|
||||
<div className="space-y-2">
|
||||
{actions.map((action, idx) => (
|
||||
<div
|
||||
key={action.id}
|
||||
className="flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-accent/50 transition-colors"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{action.status === 'completed' ? (
|
||||
<CheckCircle2 className="w-5 h-5 text-green-500" />
|
||||
) : action.status === 'active' ? (
|
||||
<div className="w-5 h-5 rounded-full border-2 border-primary border-t-transparent animate-spin" />
|
||||
) : (
|
||||
<Circle className="w-5 h-5 text-muted-foreground" />
|
||||
)}
|
||||
<span className="font-medium">{action.name}</span>
|
||||
</div>
|
||||
<div className="ml-auto flex items-center gap-3">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
Cost: {action.cost}
|
||||
</Badge>
|
||||
{action.status === 'active' && (
|
||||
<Badge className="text-xs animate-pulse">In Progress</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
|
||||
<div className="space-y-2 pt-2 border-t">
|
||||
<div className="flex justify-between text-sm">
|
||||
<span className="text-muted-foreground">Overall Progress</span>
|
||||
<span className="font-semibold">{completedActions} / {actions.length} steps</span>
|
||||
</div>
|
||||
<Progress value={(completedActions / actions.length) * 100} className="h-2" />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Current Step Tab */}
|
||||
<TabsContent value="current" className="p-6 space-y-4">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="space-y-1">
|
||||
<h3 className="text-lg font-semibold">{currentAction?.name}</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Finalizing documentation and deploying to production
|
||||
</p>
|
||||
<div className="flex items-center gap-2 mt-2">
|
||||
<Coins className="w-4 h-4 text-amber-500" />
|
||||
<span className="text-sm font-medium">Cost: {currentAction?.cost}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm" variant="outline" onClick={onResume} disabled={isRunning}>
|
||||
<Play className="w-4 h-4 mr-1" />
|
||||
Resume
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onSkip}>
|
||||
<SkipForward className="w-4 h-4 mr-1" />
|
||||
Skip
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onRetry}>
|
||||
<RotateCw className="w-4 h-4 mr-1" />
|
||||
Retry
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm">Assigned Agent</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm font-medium">Documentation</span>
|
||||
<Badge variant="secondary" className="text-xs">Specialist</Badge>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-muted-foreground">Status</span>
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{isRunning ? "working" : "idle"}
|
||||
</Badge>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm">Progress</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<Progress value={isRunning ? 65 : 0} className="h-2" />
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{isRunning ? "65%" : "0%"}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<h4 className="text-sm font-semibold">Preconditions</h4>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-500" />
|
||||
<span>initialized: true</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-500" />
|
||||
<span>requirements_clear: true</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h4 className="text-sm font-semibold">Effects</h4>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-500" />
|
||||
<span>architecture_defined: true</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-500" />
|
||||
<span>api_designed: true</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h4 className="text-sm font-semibold">Execution Log</h4>
|
||||
<ScrollArea className="h-[120px] rounded border bg-muted/50 p-3">
|
||||
<div className="space-y-1 font-mono text-xs">
|
||||
<div>[2:49:25 PM] Starting architecture planning...</div>
|
||||
<div>[2:49:25 PM] Analyzing requirements...</div>
|
||||
<div>[2:49:25 PM] Generating system design...</div>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Agent Activity Tab */}
|
||||
<TabsContent value="agents" className="p-6 space-y-4">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
{agents.map((agent) => (
|
||||
<Card key={agent.name} className="border-2">
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="text-sm">{agent.name}</CardTitle>
|
||||
<Badge
|
||||
variant={agent.status === "working" ? "default" : "secondary"}
|
||||
className="text-xs"
|
||||
>
|
||||
{agent.status}
|
||||
</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-muted-foreground">Agent Type</span>
|
||||
<span className="font-medium">Specialist</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-muted-foreground">Status</span>
|
||||
<span className="font-medium">{agent.status}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-muted-foreground">Tasks Completed</span>
|
||||
<span className="font-medium">{agent.tasksCompleted}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<Card className="border-2">
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm">Resource Usage</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<Cpu className="w-4 h-4 text-blue-500" />
|
||||
<span>CPU Usage</span>
|
||||
</div>
|
||||
<span className="font-semibold">65%</span>
|
||||
</div>
|
||||
<Progress value={65} className="h-2" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<HardDrive className="w-4 h-4 text-green-500" />
|
||||
<span>Memory Usage</span>
|
||||
</div>
|
||||
<span className="font-semibold">420 MB</span>
|
||||
</div>
|
||||
<Progress value={42} className="h-2" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<Zap className="w-4 h-4 text-amber-500" />
|
||||
<span>Token Usage</span>
|
||||
</div>
|
||||
<span className="font-semibold">15,000</span>
|
||||
</div>
|
||||
<Progress value={30} className="h-2" />
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm pt-2 border-t">
|
||||
<span className="text-muted-foreground">Uptime</span>
|
||||
<span className="font-semibold">1h 0m</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{/* Event Log Tab */}
|
||||
<TabsContent value="events" className="p-6 space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline">{events.length}</Badge>
|
||||
<span className="text-sm font-medium">Events</span>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="Search events..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-8 w-64"
|
||||
/>
|
||||
</div>
|
||||
<Button variant="outline" size="sm">
|
||||
<Download className="w-4 h-4 mr-1" />
|
||||
Export
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[400px]">
|
||||
<div className="space-y-2">
|
||||
{events.map((event, idx) => (
|
||||
<Card key={idx} className="border">
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="text-sm font-mono">{event.type}</CardTitle>
|
||||
<span className="text-xs text-muted-foreground">{event.time}</span>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<pre className="text-xs bg-muted p-2 rounded overflow-x-auto">
|
||||
{JSON.stringify(event.data, null, 2)}
|
||||
</pre>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Zap, Clock, Coins, Activity } from "lucide-react";
|
||||
|
||||
interface ExecutionMonitorProps {
|
||||
isRunning: boolean;
|
||||
}
|
||||
|
||||
export const ExecutionMonitor = ({ isRunning }: ExecutionMonitorProps) => {
|
||||
const metrics = {
|
||||
parallelTasks: 3,
|
||||
apiTokensUsed: 12450,
|
||||
apiTokensLimit: 50000,
|
||||
elapsedTime: "2m 34s",
|
||||
estimatedCompletion: "8m 15s",
|
||||
throughput: "4.2 tasks/min",
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Zap className="w-5 h-5 text-primary" />
|
||||
Parallel Execution Monitor
|
||||
</CardTitle>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
Status: {isRunning ? (
|
||||
<Badge variant="default" className="animate-pulse">Active</Badge>
|
||||
) : (
|
||||
<Badge variant="secondary">Idle</Badge>
|
||||
)}
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Metrics Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div className="space-y-2 p-4 rounded-lg border bg-card/50">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Activity className="w-4 h-4" />
|
||||
Parallel Tasks
|
||||
</div>
|
||||
<div className="text-2xl font-bold">{metrics.parallelTasks}</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 p-4 rounded-lg border bg-card/50">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Clock className="w-4 h-4" />
|
||||
Elapsed Time
|
||||
</div>
|
||||
<div className="text-2xl font-bold">{metrics.elapsedTime}</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 p-4 rounded-lg border bg-card/50">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Zap className="w-4 h-4" />
|
||||
Throughput
|
||||
</div>
|
||||
<div className="text-2xl font-bold">{metrics.throughput}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* API Token Usage */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Coins className="w-4 h-4 text-primary" />
|
||||
<span className="font-semibold">API Token Usage</span>
|
||||
</div>
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{metrics.apiTokensUsed.toLocaleString()} / {metrics.apiTokensLimit.toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
<Progress
|
||||
value={(metrics.apiTokensUsed / metrics.apiTokensLimit) * 100}
|
||||
className="h-2"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Estimated Completion */}
|
||||
<div className="flex items-center justify-between p-4 rounded-lg border bg-primary/5">
|
||||
<span className="text-sm font-medium">Estimated Completion</span>
|
||||
<span className="text-sm font-mono text-primary">{metrics.estimatedCompletion}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,201 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import ReactFlow, {
|
||||
Node,
|
||||
Edge,
|
||||
Background,
|
||||
Controls,
|
||||
MiniMap,
|
||||
MarkerType
|
||||
} from 'reactflow';
|
||||
import 'reactflow/dist/style.css';
|
||||
import { GitBranch, Clock } from 'lucide-react';
|
||||
|
||||
interface Action {
|
||||
id: string;
|
||||
name: string;
|
||||
cost: number;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface PlanVisualizationProps {
|
||||
actions: Action[];
|
||||
currentActionId?: string;
|
||||
completedActionIds: string[];
|
||||
onActionClick?: (action: Action) => void;
|
||||
}
|
||||
|
||||
export function PlanVisualization({
|
||||
actions,
|
||||
currentActionId,
|
||||
completedActionIds,
|
||||
onActionClick
|
||||
}: PlanVisualizationProps) {
|
||||
const [viewMode, setViewMode] = useState<'graph' | 'timeline'>('graph');
|
||||
|
||||
const { nodes, edges } = useMemo(() => {
|
||||
return convertPlanToGraph(actions, currentActionId, completedActionIds);
|
||||
}, [actions, currentActionId, completedActionIds]);
|
||||
|
||||
const totalCost = actions.reduce((sum, a) => sum + a.cost, 0);
|
||||
|
||||
return (
|
||||
<Card className="col-span-full border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<GitBranch className="w-5 h-5 text-purple-500" />
|
||||
Execution Plan
|
||||
</CardTitle>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline">
|
||||
{actions.length} Actions
|
||||
</Badge>
|
||||
<Badge variant="outline">
|
||||
Cost: {totalCost}
|
||||
</Badge>
|
||||
<Badge variant="outline" className="gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
Est. {Math.ceil(totalCost * 0.5)}m
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Tabs value={viewMode} onValueChange={(v) => setViewMode(v as any)}>
|
||||
<TabsList className="mb-4">
|
||||
<TabsTrigger value="graph">Graph View</TabsTrigger>
|
||||
<TabsTrigger value="timeline">Timeline View</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="graph" className="h-[500px] border rounded-lg">
|
||||
<ReactFlow
|
||||
nodes={nodes}
|
||||
edges={edges}
|
||||
onNodeClick={(event, node) => {
|
||||
const action = actions.find(a => a.id === node.id);
|
||||
if (action && onActionClick) {
|
||||
onActionClick(action);
|
||||
}
|
||||
}}
|
||||
fitView
|
||||
className="bg-muted/30 rounded-lg"
|
||||
>
|
||||
<Background />
|
||||
<Controls />
|
||||
<MiniMap />
|
||||
</ReactFlow>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="timeline" className="space-y-2">
|
||||
{actions.map((action, index) => {
|
||||
const isCompleted = completedActionIds.includes(action.id);
|
||||
const isCurrent = action.id === currentActionId;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={action.id}
|
||||
className={`
|
||||
p-4 rounded-lg border transition-all cursor-pointer
|
||||
${isCurrent ? 'bg-purple-500/10 border-purple-500/50' : 'bg-card hover:bg-muted/50'}
|
||||
${isCompleted ? 'opacity-60' : ''}
|
||||
`}
|
||||
onClick={() => onActionClick?.(action)}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`
|
||||
w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold
|
||||
${isCompleted ? 'bg-green-500 text-white' : isCurrent ? 'bg-purple-500 text-white animate-pulse' : 'bg-muted text-muted-foreground'}
|
||||
`}>
|
||||
{isCompleted ? '✓' : index + 1}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-semibold">{action.name}</div>
|
||||
{action.description && (
|
||||
<div className="text-sm text-muted-foreground">{action.description}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant="outline">Cost: {action.cost}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function convertPlanToGraph(
|
||||
actions: Action[],
|
||||
currentActionId?: string,
|
||||
completedActionIds: string[] = []
|
||||
): { nodes: Node[]; edges: Edge[] } {
|
||||
const nodes: Node[] = actions.map((action, index) => {
|
||||
const isCompleted = completedActionIds.includes(action.id);
|
||||
const isCurrent = action.id === currentActionId;
|
||||
|
||||
return {
|
||||
id: action.id,
|
||||
position: calculateNodePosition(index, actions.length),
|
||||
data: {
|
||||
label: (
|
||||
<div className="text-center">
|
||||
<div className="font-semibold text-sm">{action.name}</div>
|
||||
<div className="text-xs text-muted-foreground">Cost: {action.cost}</div>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
style: {
|
||||
background: isCompleted
|
||||
? 'linear-gradient(135deg, #10b981 0%, #059669 100%)'
|
||||
: isCurrent
|
||||
? 'linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%)'
|
||||
: 'linear-gradient(135deg, #64748b 0%, #475569 100%)',
|
||||
color: 'white',
|
||||
border: isCurrent ? '2px solid #a855f7' : '1px solid transparent',
|
||||
borderRadius: '8px',
|
||||
padding: '12px',
|
||||
width: 180,
|
||||
boxShadow: isCurrent ? '0 0 20px rgba(168, 85, 247, 0.5)' : undefined
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const edges: Edge[] = [];
|
||||
for (let i = 0; i < actions.length - 1; i++) {
|
||||
const isCompleted = completedActionIds.includes(actions[i].id);
|
||||
edges.push({
|
||||
id: `${actions[i].id}-${actions[i + 1].id}`,
|
||||
source: actions[i].id,
|
||||
target: actions[i + 1].id,
|
||||
animated: actions[i + 1].id === currentActionId,
|
||||
style: {
|
||||
stroke: isCompleted ? '#10b981' : '#64748b',
|
||||
strokeWidth: 2
|
||||
},
|
||||
markerEnd: {
|
||||
type: MarkerType.ArrowClosed,
|
||||
color: isCompleted ? '#10b981' : '#64748b'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { nodes, edges };
|
||||
}
|
||||
|
||||
function calculateNodePosition(index: number, total: number): { x: number; y: number } {
|
||||
const nodesPerRow = Math.ceil(Math.sqrt(total));
|
||||
const row = Math.floor(index / nodesPerRow);
|
||||
const col = index % nodesPerRow;
|
||||
|
||||
return {
|
||||
x: col * 250,
|
||||
y: row * 150
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Shield, CheckCircle2, XCircle, AlertTriangle } from "lucide-react";
|
||||
|
||||
interface QualityMetrics {
|
||||
compileCheck: boolean;
|
||||
testCoverage: number;
|
||||
securityScore: number;
|
||||
}
|
||||
|
||||
interface QualityGatesProps {
|
||||
metrics: QualityMetrics;
|
||||
}
|
||||
|
||||
export const QualityGates = ({ metrics }: QualityGatesProps) => {
|
||||
const gates = [
|
||||
{
|
||||
name: "Compile Check",
|
||||
status: metrics.compileCheck ? "passed" : "failed",
|
||||
icon: metrics.compileCheck ? CheckCircle2 : XCircle,
|
||||
color: metrics.compileCheck ? "text-green-500" : "text-red-500",
|
||||
},
|
||||
{
|
||||
name: "Test Coverage",
|
||||
status: metrics.testCoverage >= 80 ? "passed" : metrics.testCoverage >= 60 ? "warning" : "failed",
|
||||
value: metrics.testCoverage,
|
||||
threshold: 80,
|
||||
},
|
||||
{
|
||||
name: "Security Scan",
|
||||
status: metrics.securityScore >= 90 ? "passed" : metrics.securityScore >= 70 ? "warning" : "failed",
|
||||
value: metrics.securityScore,
|
||||
threshold: 90,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card className="border-2 border-green-500/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Shield className="w-5 h-5 text-green-500" />
|
||||
Quality Gates
|
||||
</CardTitle>
|
||||
<CardDescription>Automated quality assurance checkpoints</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{gates.map((gate, idx) => (
|
||||
<div key={idx} className="space-y-3 p-4 rounded-lg border bg-card/50">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
{gate.icon ? (
|
||||
<gate.icon className={`w-5 h-5 ${gate.color}`} />
|
||||
) : gate.status === "passed" ? (
|
||||
<CheckCircle2 className="w-5 h-5 text-green-500" />
|
||||
) : gate.status === "warning" ? (
|
||||
<AlertTriangle className="w-5 h-5 text-yellow-500" />
|
||||
) : (
|
||||
<XCircle className="w-5 h-5 text-red-500" />
|
||||
)}
|
||||
<span className="font-semibold">{gate.name}</span>
|
||||
</div>
|
||||
<Badge
|
||||
variant={
|
||||
gate.status === "passed"
|
||||
? "default"
|
||||
: gate.status === "warning"
|
||||
? "secondary"
|
||||
: "destructive"
|
||||
}
|
||||
>
|
||||
{gate.status}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{gate.value !== undefined && (
|
||||
<>
|
||||
<Progress value={gate.value} className="h-2" />
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>Current: {gate.value}%</span>
|
||||
<span>Threshold: {gate.threshold}%</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,139 @@
|
||||
import { useState, useMemo } from 'react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Search, Download, Filter, MessageSquare } from 'lucide-react';
|
||||
|
||||
interface AgenticFlowEvent {
|
||||
type: string;
|
||||
timestamp: number;
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface RealTimeEventLogProps {
|
||||
events: AgenticFlowEvent[];
|
||||
maxEvents?: number;
|
||||
}
|
||||
|
||||
export function RealTimeEventLog({ events, maxEvents = 100 }: RealTimeEventLogProps) {
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [selectedTypes, setSelectedTypes] = useState<Set<string>>(new Set());
|
||||
|
||||
const filteredEvents = useMemo(() => {
|
||||
return events
|
||||
.filter(event => {
|
||||
if (searchTerm && !JSON.stringify(event).toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
if (selectedTypes.size > 0 && !selectedTypes.has(event.type)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.slice(-maxEvents);
|
||||
}, [events, searchTerm, selectedTypes, maxEvents]);
|
||||
|
||||
const eventTypes = useMemo(() => {
|
||||
return Array.from(new Set(events.map(e => e.type)));
|
||||
}, [events]);
|
||||
|
||||
const handleExport = () => {
|
||||
const data = JSON.stringify(filteredEvents, null, 2);
|
||||
const blob = new Blob([data], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `events-${Date.now()}.json`;
|
||||
a.click();
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<MessageSquare className="w-5 h-5 text-green-500" />
|
||||
Event Log
|
||||
<Badge variant="outline">{filteredEvents.length}</Badge>
|
||||
</CardTitle>
|
||||
<Button size="sm" variant="outline" onClick={handleExport}>
|
||||
<Download className="w-4 h-4 mr-1" /> Export
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{/* Search and Filter */}
|
||||
<div className="flex gap-2">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="Search events..."
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
className="pl-9"
|
||||
/>
|
||||
</div>
|
||||
<Button variant="outline" size="icon">
|
||||
<Filter className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Event Type Filters */}
|
||||
{eventTypes.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{eventTypes.map(type => (
|
||||
<Badge
|
||||
key={type}
|
||||
variant={selectedTypes.has(type) ? 'default' : 'outline'}
|
||||
className="cursor-pointer transition-all hover:scale-105"
|
||||
onClick={() => {
|
||||
const newTypes = new Set(selectedTypes);
|
||||
if (newTypes.has(type)) {
|
||||
newTypes.delete(type);
|
||||
} else {
|
||||
newTypes.add(type);
|
||||
}
|
||||
setSelectedTypes(newTypes);
|
||||
}}
|
||||
>
|
||||
{type}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Event List */}
|
||||
<ScrollArea className="h-[400px] border rounded-lg">
|
||||
<div className="space-y-2 p-3 font-mono text-xs">
|
||||
{filteredEvents.length > 0 ? (
|
||||
filteredEvents.map((event, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="p-3 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors animate-fade-in"
|
||||
>
|
||||
<div className="flex items-start justify-between gap-2 mb-1">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{event.type}
|
||||
</Badge>
|
||||
<span className="text-muted-foreground">
|
||||
{new Date(event.timestamp).toLocaleTimeString()}
|
||||
</span>
|
||||
</div>
|
||||
<pre className="text-xs overflow-x-auto whitespace-pre-wrap">
|
||||
{JSON.stringify(event.data, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<div className="text-center text-muted-foreground py-8">
|
||||
{events.length === 0 ? 'No events yet...' : 'No events match your filters'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Play, Pause, SkipForward, RotateCcw, Zap, Bot, CheckCircle2, ArrowRight } from 'lucide-react';
|
||||
|
||||
interface StepExecutionPanelProps {
|
||||
currentAction: {
|
||||
name: string;
|
||||
description?: string;
|
||||
cost: number;
|
||||
preconditions?: Record<string, boolean | string>;
|
||||
effects?: Record<string, boolean | string>;
|
||||
};
|
||||
assignedAgent: {
|
||||
name: string;
|
||||
type: string;
|
||||
status: string;
|
||||
};
|
||||
progress: number;
|
||||
logs: string[];
|
||||
onPause?: () => void;
|
||||
onResume?: () => void;
|
||||
onSkip?: () => void;
|
||||
onRetry?: () => void;
|
||||
isPaused: boolean;
|
||||
}
|
||||
|
||||
export function StepExecutionPanel({
|
||||
currentAction,
|
||||
assignedAgent,
|
||||
progress,
|
||||
logs,
|
||||
onPause,
|
||||
onResume,
|
||||
onSkip,
|
||||
onRetry,
|
||||
isPaused
|
||||
}: StepExecutionPanelProps) {
|
||||
return (
|
||||
<Card className="border-2 border-primary/20">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Zap className="w-5 h-5 text-yellow-500 animate-pulse" />
|
||||
Current Step
|
||||
</CardTitle>
|
||||
<div className="flex gap-2">
|
||||
{isPaused ? (
|
||||
<Button size="sm" variant="outline" onClick={onResume}>
|
||||
<Play className="w-4 h-4 mr-1" /> Resume
|
||||
</Button>
|
||||
) : (
|
||||
<Button size="sm" variant="outline" onClick={onPause}>
|
||||
<Pause className="w-4 h-4 mr-1" /> Pause
|
||||
</Button>
|
||||
)}
|
||||
<Button size="sm" variant="outline" onClick={onSkip}>
|
||||
<SkipForward className="w-4 h-4 mr-1" /> Skip
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onRetry}>
|
||||
<RotateCcw className="w-4 h-4 mr-1" /> Retry
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{/* Action Info */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<h4 className="font-semibold text-lg">{currentAction.name}</h4>
|
||||
<Badge variant="outline">Cost: {currentAction.cost}</Badge>
|
||||
</div>
|
||||
{currentAction.description && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{currentAction.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Assigned Agent */}
|
||||
<div className="flex items-center gap-3 p-3 bg-gradient-to-r from-purple-500/10 to-blue-500/10 rounded-lg border border-purple-500/20">
|
||||
<Bot className="w-5 h-5 text-purple-500" />
|
||||
<div className="flex-1">
|
||||
<div className="text-sm font-medium">{assignedAgent.name}</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{assignedAgent.type}
|
||||
</div>
|
||||
</div>
|
||||
<Badge
|
||||
variant={
|
||||
assignedAgent.status === 'working'
|
||||
? 'default'
|
||||
: assignedAgent.status === 'blocked'
|
||||
? 'destructive'
|
||||
: 'secondary'
|
||||
}
|
||||
>
|
||||
{assignedAgent.status}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{/* Progress */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="font-medium">Progress</span>
|
||||
<span className="font-bold text-lg" style={{ color: '#a855f7' }}>{progress}%</span>
|
||||
</div>
|
||||
<Progress value={progress} className="h-3" />
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{getProgressLabel(progress)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Preconditions & Effects */}
|
||||
{(currentAction.preconditions || currentAction.effects) && (
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{currentAction.preconditions && (
|
||||
<div>
|
||||
<h5 className="text-sm font-semibold mb-2 flex items-center gap-1">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-500" />
|
||||
Preconditions
|
||||
</h5>
|
||||
<div className="space-y-1">
|
||||
{Object.entries(currentAction.preconditions).map(([key, value]) => (
|
||||
<div
|
||||
key={key}
|
||||
className="text-xs flex items-center gap-2 p-2 bg-green-500/10 border border-green-500/20 rounded"
|
||||
>
|
||||
<CheckCircle2 className="w-3 h-3 text-green-500" />
|
||||
<span className="font-mono">{key}: {String(value)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{currentAction.effects && (
|
||||
<div>
|
||||
<h5 className="text-sm font-semibold mb-2 flex items-center gap-1">
|
||||
<ArrowRight className="w-4 h-4 text-blue-500" />
|
||||
Effects
|
||||
</h5>
|
||||
<div className="space-y-1">
|
||||
{Object.entries(currentAction.effects).map(([key, value]) => (
|
||||
<div
|
||||
key={key}
|
||||
className="text-xs flex items-center gap-2 p-2 bg-blue-500/10 border border-blue-500/20 rounded"
|
||||
>
|
||||
<ArrowRight className="w-3 h-3 text-blue-500" />
|
||||
<span className="font-mono">{key}: {String(value)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Real-time Logs */}
|
||||
<div>
|
||||
<h5 className="text-sm font-semibold mb-2">Execution Log</h5>
|
||||
<ScrollArea className="h-[150px] rounded-md border bg-muted/30 p-3">
|
||||
<div className="space-y-1 font-mono text-xs">
|
||||
{logs.map((log, index) => (
|
||||
<div key={index} className="text-muted-foreground animate-fade-in">
|
||||
<span className="text-purple-500">
|
||||
[{new Date().toLocaleTimeString()}]
|
||||
</span>{' '}
|
||||
{log}
|
||||
</div>
|
||||
))}
|
||||
{logs.length === 0 && (
|
||||
<div className="text-center text-muted-foreground py-4">
|
||||
No logs yet...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function getProgressLabel(progress: number): string {
|
||||
if (progress < 25) return 'Initializing...';
|
||||
if (progress < 50) return 'Processing...';
|
||||
if (progress < 75) return 'Executing...';
|
||||
if (progress < 100) return 'Finalizing...';
|
||||
return 'Complete!';
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { GripVertical, Clock, CheckCircle2, AlertCircle } from "lucide-react";
|
||||
|
||||
interface TaskBoardProps {
|
||||
swarmMode: string;
|
||||
}
|
||||
|
||||
const tasks = [
|
||||
{ id: 1, title: "Design database schema", agent: "Architecture", status: "todo", priority: "high" },
|
||||
{ id: 2, title: "Implement user authentication", agent: "Implementation", status: "in-progress", priority: "high" },
|
||||
{ id: 3, title: "Write unit tests for auth", agent: "Testing", status: "todo", priority: "medium" },
|
||||
{ id: 4, title: "Review authentication code", agent: "Code Review", status: "blocked", priority: "high" },
|
||||
{ id: 5, title: "Document API endpoints", agent: "Documentation", status: "todo", priority: "low" },
|
||||
{ id: 6, title: "Setup CI/CD pipeline", agent: "DevOps", status: "in-progress", priority: "medium" },
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{ id: "todo", title: "To Do", icon: Clock },
|
||||
{ id: "in-progress", title: "In Progress", icon: AlertCircle },
|
||||
{ id: "blocked", title: "Blocked", icon: AlertCircle },
|
||||
{ id: "done", title: "Done", icon: CheckCircle2 },
|
||||
];
|
||||
|
||||
export const TaskBoard = ({ swarmMode }: TaskBoardProps) => {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Card className="border-primary/20">
|
||||
<CardHeader>
|
||||
<CardTitle>Task Assignment Board</CardTitle>
|
||||
<CardDescription>Drag and drop tasks to assign agents</CardDescription>
|
||||
<div className="flex items-center gap-2 mt-2 text-sm text-muted-foreground">
|
||||
<span>Mode:</span>
|
||||
<Badge variant="outline">{swarmMode}</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
{columns.map((column) => {
|
||||
const Icon = column.icon;
|
||||
const columnTasks = tasks.filter(t => t.status === column.id);
|
||||
|
||||
return (
|
||||
<div key={column.id} className="space-y-3">
|
||||
<div className="flex items-center gap-2 font-semibold">
|
||||
<Icon className="w-4 h-4" />
|
||||
{column.title}
|
||||
<Badge variant="secondary" className="ml-auto">
|
||||
{columnTasks.length}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[500px] pr-4">
|
||||
<div className="space-y-2">
|
||||
{columnTasks.map((task) => (
|
||||
<Card key={task.id} className="border cursor-move hover:border-primary/50 transition-all">
|
||||
<CardContent className="p-3">
|
||||
<div className="flex items-start gap-2">
|
||||
<GripVertical className="w-4 h-4 text-muted-foreground mt-1" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<p className="text-sm font-medium">{task.title}</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{task.agent}
|
||||
</Badge>
|
||||
<Badge
|
||||
variant={task.priority === 'high' ? 'destructive' : task.priority === 'medium' ? 'default' : 'secondary'}
|
||||
className="text-xs"
|
||||
>
|
||||
{task.priority}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
import * as React from "react";
|
||||
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Accordion = AccordionPrimitive.Root;
|
||||
|
||||
const AccordionItem = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AccordionPrimitive.Item ref={ref} className={cn("border-b", className)} {...props} />
|
||||
));
|
||||
AccordionItem.displayName = "AccordionItem";
|
||||
|
||||
const AccordionTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
));
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
||||
|
||||
const AccordionContent = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Content
|
||||
ref={ref}
|
||||
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
||||
{...props}
|
||||
>
|
||||
<div className={cn("pb-4 pt-0", className)}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
));
|
||||
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
||||
@@ -0,0 +1,104 @@
|
||||
import * as React from "react";
|
||||
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
|
||||
const AlertDialog = AlertDialogPrimitive.Root;
|
||||
|
||||
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
||||
|
||||
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
||||
|
||||
const AlertDialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Overlay
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
));
|
||||
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
||||
|
||||
const AlertDialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPortal>
|
||||
<AlertDialogOverlay />
|
||||
<AlertDialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</AlertDialogPortal>
|
||||
));
|
||||
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
||||
|
||||
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
||||
);
|
||||
AlertDialogHeader.displayName = "AlertDialogHeader";
|
||||
|
||||
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
||||
);
|
||||
AlertDialogFooter.displayName = "AlertDialogFooter";
|
||||
|
||||
const AlertDialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Title ref={ref} className={cn("text-lg font-semibold", className)} {...props} />
|
||||
));
|
||||
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
||||
|
||||
const AlertDialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
||||
));
|
||||
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
||||
|
||||
const AlertDialogAction = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
||||
));
|
||||
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
||||
|
||||
const AlertDialogCancel = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Cancel
|
||||
ref={ref}
|
||||
className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
||||
|
||||
export {
|
||||
AlertDialog,
|
||||
AlertDialogPortal,
|
||||
AlertDialogOverlay,
|
||||
AlertDialogTrigger,
|
||||
AlertDialogContent,
|
||||
AlertDialogHeader,
|
||||
AlertDialogFooter,
|
||||
AlertDialogTitle,
|
||||
AlertDialogDescription,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as React from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const alertVariants = cva(
|
||||
"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-background text-foreground",
|
||||
destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const Alert = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
||||
>(({ className, variant, ...props }, ref) => (
|
||||
<div ref={ref} role="alert" className={cn(alertVariants({ variant }), className)} {...props} />
|
||||
));
|
||||
Alert.displayName = "Alert";
|
||||
|
||||
const AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<h5 ref={ref} className={cn("mb-1 font-medium leading-none tracking-tight", className)} {...props} />
|
||||
),
|
||||
);
|
||||
AlertTitle.displayName = "AlertTitle";
|
||||
|
||||
const AlertDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("text-sm [&_p]:leading-relaxed", className)} {...props} />
|
||||
),
|
||||
);
|
||||
AlertDescription.displayName = "AlertDescription";
|
||||
|
||||
export { Alert, AlertTitle, AlertDescription };
|
||||
@@ -0,0 +1,5 @@
|
||||
import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio";
|
||||
|
||||
const AspectRatio = AspectRatioPrimitive.Root;
|
||||
|
||||
export { AspectRatio };
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as React from "react";
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Avatar = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
||||
|
||||
const AvatarImage = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Image ref={ref} className={cn("aspect-square h-full w-full", className)} {...props} />
|
||||
));
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
||||
|
||||
const AvatarFallback = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Fallback
|
||||
ref={ref}
|
||||
className={cn("flex h-full w-full items-center justify-center rounded-full bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
||||
|
||||
export { Avatar, AvatarImage, AvatarFallback };
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as React from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
||||
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
||||
outline: "text-foreground",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants };
|
||||
@@ -0,0 +1,90 @@
|
||||
import * as React from "react";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Breadcrumb = React.forwardRef<
|
||||
HTMLElement,
|
||||
React.ComponentPropsWithoutRef<"nav"> & {
|
||||
separator?: React.ReactNode;
|
||||
}
|
||||
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
||||
Breadcrumb.displayName = "Breadcrumb";
|
||||
|
||||
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<"ol">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<ol
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
BreadcrumbList.displayName = "BreadcrumbList";
|
||||
|
||||
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<"li">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<li ref={ref} className={cn("inline-flex items-center gap-1.5", className)} {...props} />
|
||||
),
|
||||
);
|
||||
BreadcrumbItem.displayName = "BreadcrumbItem";
|
||||
|
||||
const BreadcrumbLink = React.forwardRef<
|
||||
HTMLAnchorElement,
|
||||
React.ComponentPropsWithoutRef<"a"> & {
|
||||
asChild?: boolean;
|
||||
}
|
||||
>(({ asChild, className, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "a";
|
||||
|
||||
return <Comp ref={ref} className={cn("transition-colors hover:text-foreground", className)} {...props} />;
|
||||
});
|
||||
BreadcrumbLink.displayName = "BreadcrumbLink";
|
||||
|
||||
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<"span">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<span
|
||||
ref={ref}
|
||||
role="link"
|
||||
aria-disabled="true"
|
||||
aria-current="page"
|
||||
className={cn("font-normal text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
BreadcrumbPage.displayName = "BreadcrumbPage";
|
||||
|
||||
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<"li">) => (
|
||||
<li role="presentation" aria-hidden="true" className={cn("[&>svg]:size-3.5", className)} {...props}>
|
||||
{children ?? <ChevronRight />}
|
||||
</li>
|
||||
);
|
||||
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
||||
|
||||
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
||||
<span
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
<span className="sr-only">More</span>
|
||||
</span>
|
||||
);
|
||||
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
||||
|
||||
export {
|
||||
Breadcrumb,
|
||||
BreadcrumbList,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
BreadcrumbEllipsis,
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
import * as React from "react";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
||||
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-10 px-4 py-2",
|
||||
sm: "h-9 rounded-md px-3",
|
||||
lg: "h-11 rounded-md px-8",
|
||||
icon: "h-10 w-10",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
|
||||
},
|
||||
);
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button, buttonVariants };
|
||||
@@ -0,0 +1,54 @@
|
||||
import * as React from "react";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { DayPicker } from "react-day-picker";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
|
||||
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
||||
|
||||
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn("p-3", className)}
|
||||
classNames={{
|
||||
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
||||
month: "space-y-4",
|
||||
caption: "flex justify-center pt-1 relative items-center",
|
||||
caption_label: "text-sm font-medium",
|
||||
nav: "space-x-1 flex items-center",
|
||||
nav_button: cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
||||
),
|
||||
nav_button_previous: "absolute left-1",
|
||||
nav_button_next: "absolute right-1",
|
||||
table: "w-full border-collapse space-y-1",
|
||||
head_row: "flex",
|
||||
head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
||||
row: "flex w-full mt-2",
|
||||
cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
|
||||
day: cn(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100"),
|
||||
day_range_end: "day-range-end",
|
||||
day_selected:
|
||||
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
||||
day_today: "bg-accent text-accent-foreground",
|
||||
day_outside:
|
||||
"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
||||
day_disabled: "text-muted-foreground opacity-50",
|
||||
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
||||
day_hidden: "invisible",
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
IconLeft: ({ ..._props }) => <ChevronLeft className="h-4 w-4" />,
|
||||
IconRight: ({ ..._props }) => <ChevronRight className="h-4 w-4" />,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Calendar.displayName = "Calendar";
|
||||
|
||||
export { Calendar };
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} {...props} />
|
||||
));
|
||||
Card.displayName = "Card";
|
||||
|
||||
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
||||
),
|
||||
);
|
||||
CardHeader.displayName = "CardHeader";
|
||||
|
||||
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-tight", className)} {...props} />
|
||||
),
|
||||
);
|
||||
CardTitle.displayName = "CardTitle";
|
||||
|
||||
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
||||
),
|
||||
);
|
||||
CardDescription.displayName = "CardDescription";
|
||||
|
||||
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
|
||||
);
|
||||
CardContent.displayName = "CardContent";
|
||||
|
||||
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
||||
),
|
||||
);
|
||||
CardFooter.displayName = "CardFooter";
|
||||
|
||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
||||
@@ -0,0 +1,224 @@
|
||||
import * as React from "react";
|
||||
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
||||
import { ArrowLeft, ArrowRight } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
type CarouselApi = UseEmblaCarouselType[1];
|
||||
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
||||
type CarouselOptions = UseCarouselParameters[0];
|
||||
type CarouselPlugin = UseCarouselParameters[1];
|
||||
|
||||
type CarouselProps = {
|
||||
opts?: CarouselOptions;
|
||||
plugins?: CarouselPlugin;
|
||||
orientation?: "horizontal" | "vertical";
|
||||
setApi?: (api: CarouselApi) => void;
|
||||
};
|
||||
|
||||
type CarouselContextProps = {
|
||||
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
||||
api: ReturnType<typeof useEmblaCarousel>[1];
|
||||
scrollPrev: () => void;
|
||||
scrollNext: () => void;
|
||||
canScrollPrev: boolean;
|
||||
canScrollNext: boolean;
|
||||
} & CarouselProps;
|
||||
|
||||
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
||||
|
||||
function useCarousel() {
|
||||
const context = React.useContext(CarouselContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useCarousel must be used within a <Carousel />");
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & CarouselProps>(
|
||||
({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => {
|
||||
const [carouselRef, api] = useEmblaCarousel(
|
||||
{
|
||||
...opts,
|
||||
axis: orientation === "horizontal" ? "x" : "y",
|
||||
},
|
||||
plugins,
|
||||
);
|
||||
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
||||
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
||||
|
||||
const onSelect = React.useCallback((api: CarouselApi) => {
|
||||
if (!api) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCanScrollPrev(api.canScrollPrev());
|
||||
setCanScrollNext(api.canScrollNext());
|
||||
}, []);
|
||||
|
||||
const scrollPrev = React.useCallback(() => {
|
||||
api?.scrollPrev();
|
||||
}, [api]);
|
||||
|
||||
const scrollNext = React.useCallback(() => {
|
||||
api?.scrollNext();
|
||||
}, [api]);
|
||||
|
||||
const handleKeyDown = React.useCallback(
|
||||
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (event.key === "ArrowLeft") {
|
||||
event.preventDefault();
|
||||
scrollPrev();
|
||||
} else if (event.key === "ArrowRight") {
|
||||
event.preventDefault();
|
||||
scrollNext();
|
||||
}
|
||||
},
|
||||
[scrollPrev, scrollNext],
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api || !setApi) {
|
||||
return;
|
||||
}
|
||||
|
||||
setApi(api);
|
||||
}, [api, setApi]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api) {
|
||||
return;
|
||||
}
|
||||
|
||||
onSelect(api);
|
||||
api.on("reInit", onSelect);
|
||||
api.on("select", onSelect);
|
||||
|
||||
return () => {
|
||||
api?.off("select", onSelect);
|
||||
};
|
||||
}, [api, onSelect]);
|
||||
|
||||
return (
|
||||
<CarouselContext.Provider
|
||||
value={{
|
||||
carouselRef,
|
||||
api: api,
|
||||
opts,
|
||||
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
||||
scrollPrev,
|
||||
scrollNext,
|
||||
canScrollPrev,
|
||||
canScrollNext,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={ref}
|
||||
onKeyDownCapture={handleKeyDown}
|
||||
className={cn("relative", className)}
|
||||
role="region"
|
||||
aria-roledescription="carousel"
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</CarouselContext.Provider>
|
||||
);
|
||||
},
|
||||
);
|
||||
Carousel.displayName = "Carousel";
|
||||
|
||||
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const { carouselRef, orientation } = useCarousel();
|
||||
|
||||
return (
|
||||
<div ref={carouselRef} className="overflow-hidden">
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
CarouselContent.displayName = "CarouselContent";
|
||||
|
||||
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const { orientation } = useCarousel();
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
role="group"
|
||||
aria-roledescription="slide"
|
||||
className={cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
CarouselItem.displayName = "CarouselItem";
|
||||
|
||||
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
||||
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
||||
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute h-8 w-8 rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "-left-12 top-1/2 -translate-y-1/2"
|
||||
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className,
|
||||
)}
|
||||
disabled={!canScrollPrev}
|
||||
onClick={scrollPrev}
|
||||
{...props}
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
<span className="sr-only">Previous slide</span>
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
);
|
||||
CarouselPrevious.displayName = "CarouselPrevious";
|
||||
|
||||
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
||||
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
||||
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute h-8 w-8 rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "-right-12 top-1/2 -translate-y-1/2"
|
||||
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className,
|
||||
)}
|
||||
disabled={!canScrollNext}
|
||||
onClick={scrollNext}
|
||||
{...props}
|
||||
>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
<span className="sr-only">Next slide</span>
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
);
|
||||
CarouselNext.displayName = "CarouselNext";
|
||||
|
||||
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };
|
||||
@@ -0,0 +1,303 @@
|
||||
import * as React from "react";
|
||||
import * as RechartsPrimitive from "recharts";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// Format: { THEME_NAME: CSS_SELECTOR }
|
||||
const THEMES = { light: "", dark: ".dark" } as const;
|
||||
|
||||
export type ChartConfig = {
|
||||
[k in string]: {
|
||||
label?: React.ReactNode;
|
||||
icon?: React.ComponentType;
|
||||
} & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
|
||||
};
|
||||
|
||||
type ChartContextProps = {
|
||||
config: ChartConfig;
|
||||
};
|
||||
|
||||
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
||||
|
||||
function useChart() {
|
||||
const context = React.useContext(ChartContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useChart must be used within a <ChartContainer />");
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
const ChartContainer = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<"div"> & {
|
||||
config: ChartConfig;
|
||||
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
||||
}
|
||||
>(({ id, className, children, config, ...props }, ref) => {
|
||||
const uniqueId = React.useId();
|
||||
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
||||
|
||||
return (
|
||||
<ChartContext.Provider value={{ config }}>
|
||||
<div
|
||||
data-chart={chartId}
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChartStyle id={chartId} config={config} />
|
||||
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
||||
</div>
|
||||
</ChartContext.Provider>
|
||||
);
|
||||
});
|
||||
ChartContainer.displayName = "Chart";
|
||||
|
||||
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
||||
const colorConfig = Object.entries(config).filter(([_, config]) => config.theme || config.color);
|
||||
|
||||
if (!colorConfig.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<style
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: Object.entries(THEMES)
|
||||
.map(
|
||||
([theme, prefix]) => `
|
||||
${prefix} [data-chart=${id}] {
|
||||
${colorConfig
|
||||
.map(([key, itemConfig]) => {
|
||||
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
||||
return color ? ` --color-${key}: ${color};` : null;
|
||||
})
|
||||
.join("\n")}
|
||||
}
|
||||
`,
|
||||
)
|
||||
.join("\n"),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const ChartTooltip = RechartsPrimitive.Tooltip;
|
||||
|
||||
const ChartTooltipContent = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
||||
React.ComponentProps<"div"> & {
|
||||
hideLabel?: boolean;
|
||||
hideIndicator?: boolean;
|
||||
indicator?: "line" | "dot" | "dashed";
|
||||
nameKey?: string;
|
||||
labelKey?: string;
|
||||
}
|
||||
>(
|
||||
(
|
||||
{
|
||||
active,
|
||||
payload,
|
||||
className,
|
||||
indicator = "dot",
|
||||
hideLabel = false,
|
||||
hideIndicator = false,
|
||||
label,
|
||||
labelFormatter,
|
||||
labelClassName,
|
||||
formatter,
|
||||
color,
|
||||
nameKey,
|
||||
labelKey,
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const { config } = useChart();
|
||||
|
||||
const tooltipLabel = React.useMemo(() => {
|
||||
if (hideLabel || !payload?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [item] = payload;
|
||||
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
||||
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
||||
const value =
|
||||
!labelKey && typeof label === "string"
|
||||
? config[label as keyof typeof config]?.label || label
|
||||
: itemConfig?.label;
|
||||
|
||||
if (labelFormatter) {
|
||||
return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
||||
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
||||
|
||||
if (!active || !payload?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const nestLabel = payload.length === 1 && indicator !== "dot";
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{!nestLabel ? tooltipLabel : null}
|
||||
<div className="grid gap-1.5">
|
||||
{payload.map((item, index) => {
|
||||
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
||||
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
||||
const indicatorColor = color || item.payload.fill || item.color;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.dataKey}
|
||||
className={cn(
|
||||
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
||||
indicator === "dot" && "items-center",
|
||||
)}
|
||||
>
|
||||
{formatter && item?.value !== undefined && item.name ? (
|
||||
formatter(item.value, item.name, item, index, item.payload)
|
||||
) : (
|
||||
<>
|
||||
{itemConfig?.icon ? (
|
||||
<itemConfig.icon />
|
||||
) : (
|
||||
!hideIndicator && (
|
||||
<div
|
||||
className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
||||
"h-2.5 w-2.5": indicator === "dot",
|
||||
"w-1": indicator === "line",
|
||||
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
||||
"my-0.5": nestLabel && indicator === "dashed",
|
||||
})}
|
||||
style={
|
||||
{
|
||||
"--color-bg": indicatorColor,
|
||||
"--color-border": indicatorColor,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-1 justify-between leading-none",
|
||||
nestLabel ? "items-end" : "items-center",
|
||||
)}
|
||||
>
|
||||
<div className="grid gap-1.5">
|
||||
{nestLabel ? tooltipLabel : null}
|
||||
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
||||
</div>
|
||||
{item.value && (
|
||||
<span className="font-mono font-medium tabular-nums text-foreground">
|
||||
{item.value.toLocaleString()}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
ChartTooltipContent.displayName = "ChartTooltip";
|
||||
|
||||
const ChartLegend = RechartsPrimitive.Legend;
|
||||
|
||||
const ChartLegendContent = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<"div"> &
|
||||
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
||||
hideIcon?: boolean;
|
||||
nameKey?: string;
|
||||
}
|
||||
>(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
||||
const { config } = useChart();
|
||||
|
||||
if (!payload?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}
|
||||
>
|
||||
{payload.map((item) => {
|
||||
const key = `${nameKey || item.dataKey || "value"}`;
|
||||
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.value}
|
||||
className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
|
||||
>
|
||||
{itemConfig?.icon && !hideIcon ? (
|
||||
<itemConfig.icon />
|
||||
) : (
|
||||
<div
|
||||
className="h-2 w-2 shrink-0 rounded-[2px]"
|
||||
style={{
|
||||
backgroundColor: item.color,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{itemConfig?.label}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
ChartLegendContent.displayName = "ChartLegend";
|
||||
|
||||
// Helper to extract item config from a payload.
|
||||
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
||||
if (typeof payload !== "object" || payload === null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const payloadPayload =
|
||||
"payload" in payload && typeof payload.payload === "object" && payload.payload !== null
|
||||
? payload.payload
|
||||
: undefined;
|
||||
|
||||
let configLabelKey: string = key;
|
||||
|
||||
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
|
||||
configLabelKey = payload[key as keyof typeof payload] as string;
|
||||
} else if (
|
||||
payloadPayload &&
|
||||
key in payloadPayload &&
|
||||
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
||||
) {
|
||||
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
||||
}
|
||||
|
||||
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
||||
}
|
||||
|
||||
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as React from "react";
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
||||
import { Check } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
|
||||
<Check className="h-4 w-4" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
));
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
||||
|
||||
export { Checkbox };
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
|
||||
const Collapsible = CollapsiblePrimitive.Root;
|
||||
|
||||
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
||||
|
||||
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
||||
|
||||
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
||||
@@ -0,0 +1,132 @@
|
||||
import * as React from "react";
|
||||
import { type DialogProps } from "@radix-ui/react-dialog";
|
||||
import { Command as CommandPrimitive } from "cmdk";
|
||||
import { Search } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
||||
|
||||
const Command = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CommandPrimitive
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Command.displayName = CommandPrimitive.displayName;
|
||||
|
||||
interface CommandDialogProps extends DialogProps {}
|
||||
|
||||
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
||||
<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">
|
||||
{children}
|
||||
</Command>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const CommandInput = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.Input>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
||||
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
<CommandPrimitive.Input
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
));
|
||||
|
||||
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
||||
|
||||
const CommandList = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CommandPrimitive.List
|
||||
ref={ref}
|
||||
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
|
||||
CommandList.displayName = CommandPrimitive.List.displayName;
|
||||
|
||||
const CommandEmpty = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.Empty>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
||||
>((props, ref) => <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />);
|
||||
|
||||
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
||||
|
||||
const CommandGroup = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.Group>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CommandPrimitive.Group
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
|
||||
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
||||
|
||||
const CommandSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CommandPrimitive.Separator ref={ref} className={cn("-mx-1 h-px bg-border", className)} {...props} />
|
||||
));
|
||||
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
||||
|
||||
const CommandItem = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CommandPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
|
||||
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
||||
|
||||
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
||||
};
|
||||
CommandShortcut.displayName = "CommandShortcut";
|
||||
|
||||
export {
|
||||
Command,
|
||||
CommandDialog,
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandItem,
|
||||
CommandShortcut,
|
||||
CommandSeparator,
|
||||
};
|
||||
@@ -0,0 +1,178 @@
|
||||
import * as React from "react";
|
||||
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
||||
import { Check, ChevronRight, Circle } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const ContextMenu = ContextMenuPrimitive.Root;
|
||||
|
||||
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
||||
|
||||
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
||||
|
||||
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
||||
|
||||
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
||||
|
||||
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
||||
|
||||
const ContextMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto h-4 w-4" />
|
||||
</ContextMenuPrimitive.SubTrigger>
|
||||
));
|
||||
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
||||
|
||||
const ContextMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
||||
|
||||
const ContextMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.Portal>
|
||||
<ContextMenuPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</ContextMenuPrimitive.Portal>
|
||||
));
|
||||
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
||||
|
||||
const ContextMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
||||
|
||||
const ContextMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<ContextMenuPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</ContextMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</ContextMenuPrimitive.CheckboxItem>
|
||||
));
|
||||
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
||||
|
||||
const ContextMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<ContextMenuPrimitive.ItemIndicator>
|
||||
<Circle className="h-2 w-2 fill-current" />
|
||||
</ContextMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</ContextMenuPrimitive.RadioItem>
|
||||
));
|
||||
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
||||
|
||||
const ContextMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
||||
|
||||
const ContextMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ContextMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
|
||||
));
|
||||
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
||||
|
||||
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
||||
};
|
||||
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
||||
|
||||
export {
|
||||
ContextMenu,
|
||||
ContextMenuTrigger,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuCheckboxItem,
|
||||
ContextMenuRadioItem,
|
||||
ContextMenuLabel,
|
||||
ContextMenuSeparator,
|
||||
ContextMenuShortcut,
|
||||
ContextMenuGroup,
|
||||
ContextMenuPortal,
|
||||
ContextMenuSub,
|
||||
ContextMenuSubContent,
|
||||
ContextMenuSubTrigger,
|
||||
ContextMenuRadioGroup,
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
import * as React from "react";
|
||||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Dialog = DialogPrimitive.Root;
|
||||
|
||||
const DialogTrigger = DialogPrimitive.Trigger;
|
||||
|
||||
const DialogPortal = DialogPrimitive.Portal;
|
||||
|
||||
const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
));
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
||||
|
||||
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
||||
);
|
||||
DialogHeader.displayName = "DialogHeader";
|
||||
|
||||
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
||||
);
|
||||
DialogFooter.displayName = "DialogFooter";
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
||||
));
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogClose,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
import * as React from "react";
|
||||
import { Drawer as DrawerPrimitive } from "vaul";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
||||
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
||||
);
|
||||
Drawer.displayName = "Drawer";
|
||||
|
||||
const DrawerTrigger = DrawerPrimitive.Trigger;
|
||||
|
||||
const DrawerPortal = DrawerPrimitive.Portal;
|
||||
|
||||
const DrawerClose = DrawerPrimitive.Close;
|
||||
|
||||
const DrawerOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
|
||||
));
|
||||
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
||||
|
||||
const DrawerContent = React.forwardRef<
|
||||
React.ElementRef<typeof DrawerPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DrawerPortal>
|
||||
<DrawerOverlay />
|
||||
<DrawerPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
||||
{children}
|
||||
</DrawerPrimitive.Content>
|
||||
</DrawerPortal>
|
||||
));
|
||||
DrawerContent.displayName = "DrawerContent";
|
||||
|
||||
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
||||
);
|
||||
DrawerHeader.displayName = "DrawerHeader";
|
||||
|
||||
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
||||
);
|
||||
DrawerFooter.displayName = "DrawerFooter";
|
||||
|
||||
const DrawerTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DrawerPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DrawerPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
||||
|
||||
const DrawerDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DrawerPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
||||
));
|
||||
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Drawer,
|
||||
DrawerPortal,
|
||||
DrawerOverlay,
|
||||
DrawerTrigger,
|
||||
DrawerClose,
|
||||
DrawerContent,
|
||||
DrawerHeader,
|
||||
DrawerFooter,
|
||||
DrawerTitle,
|
||||
DrawerDescription,
|
||||
};
|
||||
@@ -0,0 +1,179 @@
|
||||
import * as React from "react";
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
||||
import { Check, ChevronRight, Circle } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root;
|
||||
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
||||
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
||||
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
||||
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
||||
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto h-4 w-4" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
));
|
||||
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
));
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
));
|
||||
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
||||
|
||||
const DropdownMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Circle className="h-2 w-2 fill-current" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
));
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
||||
));
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
||||
|
||||
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />;
|
||||
};
|
||||
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuRadioGroup,
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
import * as React from "react";
|
||||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from "react-hook-form";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
const Form = FormProvider;
|
||||
|
||||
type FormFieldContextValue<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = {
|
||||
name: TName;
|
||||
};
|
||||
|
||||
const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
|
||||
|
||||
const FormField = <
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
>({
|
||||
...props
|
||||
}: ControllerProps<TFieldValues, TName>) => {
|
||||
return (
|
||||
<FormFieldContext.Provider value={{ name: props.name }}>
|
||||
<Controller {...props} />
|
||||
</FormFieldContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
const useFormField = () => {
|
||||
const fieldContext = React.useContext(FormFieldContext);
|
||||
const itemContext = React.useContext(FormItemContext);
|
||||
const { getFieldState, formState } = useFormContext();
|
||||
|
||||
const fieldState = getFieldState(fieldContext.name, formState);
|
||||
|
||||
if (!fieldContext) {
|
||||
throw new Error("useFormField should be used within <FormField>");
|
||||
}
|
||||
|
||||
const { id } = itemContext;
|
||||
|
||||
return {
|
||||
id,
|
||||
name: fieldContext.name,
|
||||
formItemId: `${id}-form-item`,
|
||||
formDescriptionId: `${id}-form-item-description`,
|
||||
formMessageId: `${id}-form-item-message`,
|
||||
...fieldState,
|
||||
};
|
||||
};
|
||||
|
||||
type FormItemContextValue = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
|
||||
|
||||
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const id = React.useId();
|
||||
|
||||
return (
|
||||
<FormItemContext.Provider value={{ id }}>
|
||||
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
||||
</FormItemContext.Provider>
|
||||
);
|
||||
},
|
||||
);
|
||||
FormItem.displayName = "FormItem";
|
||||
|
||||
const FormLabel = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const { error, formItemId } = useFormField();
|
||||
|
||||
return <Label ref={ref} className={cn(error && "text-destructive", className)} htmlFor={formItemId} {...props} />;
|
||||
});
|
||||
FormLabel.displayName = "FormLabel";
|
||||
|
||||
const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
|
||||
({ ...props }, ref) => {
|
||||
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
||||
|
||||
return (
|
||||
<Slot
|
||||
ref={ref}
|
||||
id={formItemId}
|
||||
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
|
||||
aria-invalid={!!error}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
FormControl.displayName = "FormControl";
|
||||
|
||||
const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const { formDescriptionId } = useFormField();
|
||||
|
||||
return <p ref={ref} id={formDescriptionId} className={cn("text-sm text-muted-foreground", className)} {...props} />;
|
||||
},
|
||||
);
|
||||
FormDescription.displayName = "FormDescription";
|
||||
|
||||
const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
||||
({ className, children, ...props }, ref) => {
|
||||
const { error, formMessageId } = useFormField();
|
||||
const body = error ? String(error?.message) : children;
|
||||
|
||||
if (!body) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<p ref={ref} id={formMessageId} className={cn("text-sm font-medium text-destructive", className)} {...props}>
|
||||
{body}
|
||||
</p>
|
||||
);
|
||||
},
|
||||
);
|
||||
FormMessage.displayName = "FormMessage";
|
||||
|
||||
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as React from "react";
|
||||
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const HoverCard = HoverCardPrimitive.Root;
|
||||
|
||||
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
||||
|
||||
const HoverCardContent = React.forwardRef<
|
||||
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
||||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
||||
<HoverCardPrimitive.Content
|
||||
ref={ref}
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
||||
|
||||
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
||||
@@ -0,0 +1,61 @@
|
||||
import * as React from "react";
|
||||
import { OTPInput, OTPInputContext } from "input-otp";
|
||||
import { Dot } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const InputOTP = React.forwardRef<React.ElementRef<typeof OTPInput>, React.ComponentPropsWithoutRef<typeof OTPInput>>(
|
||||
({ className, containerClassName, ...props }, ref) => (
|
||||
<OTPInput
|
||||
ref={ref}
|
||||
containerClassName={cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName)}
|
||||
className={cn("disabled:cursor-not-allowed", className)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
InputOTP.displayName = "InputOTP";
|
||||
|
||||
const InputOTPGroup = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
|
||||
({ className, ...props }, ref) => <div ref={ref} className={cn("flex items-center", className)} {...props} />,
|
||||
);
|
||||
InputOTPGroup.displayName = "InputOTPGroup";
|
||||
|
||||
const InputOTPSlot = React.forwardRef<
|
||||
React.ElementRef<"div">,
|
||||
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
||||
>(({ index, className, ...props }, ref) => {
|
||||
const inputOTPContext = React.useContext(OTPInputContext);
|
||||
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
|
||||
isActive && "z-10 ring-2 ring-ring ring-offset-background",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{char}
|
||||
{hasFakeCaret && (
|
||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
||||
<div className="animate-caret-blink h-4 w-px bg-foreground duration-1000" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
InputOTPSlot.displayName = "InputOTPSlot";
|
||||
|
||||
const InputOTPSeparator = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
|
||||
({ ...props }, ref) => (
|
||||
<div ref={ref} role="separator" {...props}>
|
||||
<Dot />
|
||||
</div>
|
||||
),
|
||||
);
|
||||
InputOTPSeparator.displayName = "InputOTPSeparator";
|
||||
|
||||
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
Input.displayName = "Input";
|
||||
|
||||
export { Input };
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as React from "react";
|
||||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
||||
|
||||
const Label = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
||||
));
|
||||
Label.displayName = LabelPrimitive.Root.displayName;
|
||||
|
||||
export { Label };
|
||||
@@ -0,0 +1,207 @@
|
||||
import * as React from "react";
|
||||
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
||||
import { Check, ChevronRight, Circle } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const MenubarMenu = MenubarPrimitive.Menu;
|
||||
|
||||
const MenubarGroup = MenubarPrimitive.Group;
|
||||
|
||||
const MenubarPortal = MenubarPrimitive.Portal;
|
||||
|
||||
const MenubarSub = MenubarPrimitive.Sub;
|
||||
|
||||
const MenubarRadioGroup = MenubarPrimitive.RadioGroup;
|
||||
|
||||
const Menubar = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<MenubarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("flex h-10 items-center space-x-1 rounded-md border bg-background p-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Menubar.displayName = MenubarPrimitive.Root.displayName;
|
||||
|
||||
const MenubarTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<MenubarPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName;
|
||||
|
||||
const MenubarSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<MenubarPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto h-4 w-4" />
|
||||
</MenubarPrimitive.SubTrigger>
|
||||
));
|
||||
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName;
|
||||
|
||||
const MenubarSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<MenubarPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName;
|
||||
|
||||
const MenubarContent = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
||||
>(({ className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref) => (
|
||||
<MenubarPrimitive.Portal>
|
||||
<MenubarPrimitive.Content
|
||||
ref={ref}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</MenubarPrimitive.Portal>
|
||||
));
|
||||
MenubarContent.displayName = MenubarPrimitive.Content.displayName;
|
||||
|
||||
const MenubarItem = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<MenubarPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
MenubarItem.displayName = MenubarPrimitive.Item.displayName;
|
||||
|
||||
const MenubarCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<MenubarPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<MenubarPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</MenubarPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenubarPrimitive.CheckboxItem>
|
||||
));
|
||||
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName;
|
||||
|
||||
const MenubarRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<MenubarPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<MenubarPrimitive.ItemIndicator>
|
||||
<Circle className="h-2 w-2 fill-current" />
|
||||
</MenubarPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenubarPrimitive.RadioItem>
|
||||
));
|
||||
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName;
|
||||
|
||||
const MenubarLabel = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<MenubarPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
MenubarLabel.displayName = MenubarPrimitive.Label.displayName;
|
||||
|
||||
const MenubarSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<MenubarPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
||||
));
|
||||
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName;
|
||||
|
||||
const MenubarShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
||||
};
|
||||
MenubarShortcut.displayname = "MenubarShortcut";
|
||||
|
||||
export {
|
||||
Menubar,
|
||||
MenubarMenu,
|
||||
MenubarTrigger,
|
||||
MenubarContent,
|
||||
MenubarItem,
|
||||
MenubarSeparator,
|
||||
MenubarLabel,
|
||||
MenubarCheckboxItem,
|
||||
MenubarRadioGroup,
|
||||
MenubarRadioItem,
|
||||
MenubarPortal,
|
||||
MenubarSubContent,
|
||||
MenubarSubTrigger,
|
||||
MenubarGroup,
|
||||
MenubarSub,
|
||||
MenubarShortcut,
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
import * as React from "react";
|
||||
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
||||
import { cva } from "class-variance-authority";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const NavigationMenu = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative z-10 flex max-w-max flex-1 items-center justify-center", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<NavigationMenuViewport />
|
||||
</NavigationMenuPrimitive.Root>
|
||||
));
|
||||
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
||||
|
||||
const NavigationMenuList = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.List
|
||||
ref={ref}
|
||||
className={cn("group flex flex-1 list-none items-center justify-center space-x-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
||||
|
||||
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
||||
|
||||
const navigationMenuTriggerStyle = cva(
|
||||
"group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",
|
||||
);
|
||||
|
||||
const NavigationMenuTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}{" "}
|
||||
<ChevronDown
|
||||
className="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NavigationMenuPrimitive.Trigger>
|
||||
));
|
||||
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
||||
|
||||
const NavigationMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
||||
|
||||
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
||||
|
||||
const NavigationMenuViewport = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
||||
<NavigationMenuPrimitive.Viewport
|
||||
className={cn(
|
||||
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
));
|
||||
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
||||
|
||||
const NavigationMenuIndicator = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Indicator
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
||||
</NavigationMenuPrimitive.Indicator>
|
||||
));
|
||||
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
||||
|
||||
export {
|
||||
navigationMenuTriggerStyle,
|
||||
NavigationMenu,
|
||||
NavigationMenuList,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuContent,
|
||||
NavigationMenuTrigger,
|
||||
NavigationMenuLink,
|
||||
NavigationMenuIndicator,
|
||||
NavigationMenuViewport,
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
import * as React from "react";
|
||||
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ButtonProps, buttonVariants } from "@/components/ui/button";
|
||||
|
||||
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
||||
<nav
|
||||
role="navigation"
|
||||
aria-label="pagination"
|
||||
className={cn("mx-auto flex w-full justify-center", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
Pagination.displayName = "Pagination";
|
||||
|
||||
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<ul ref={ref} className={cn("flex flex-row items-center gap-1", className)} {...props} />
|
||||
),
|
||||
);
|
||||
PaginationContent.displayName = "PaginationContent";
|
||||
|
||||
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
|
||||
<li ref={ref} className={cn("", className)} {...props} />
|
||||
));
|
||||
PaginationItem.displayName = "PaginationItem";
|
||||
|
||||
type PaginationLinkProps = {
|
||||
isActive?: boolean;
|
||||
} & Pick<ButtonProps, "size"> &
|
||||
React.ComponentProps<"a">;
|
||||
|
||||
const PaginationLink = ({ className, isActive, size = "icon", ...props }: PaginationLinkProps) => (
|
||||
<a
|
||||
aria-current={isActive ? "page" : undefined}
|
||||
className={cn(
|
||||
buttonVariants({
|
||||
variant: isActive ? "outline" : "ghost",
|
||||
size,
|
||||
}),
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
PaginationLink.displayName = "PaginationLink";
|
||||
|
||||
const PaginationPrevious = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
||||
<PaginationLink aria-label="Go to previous page" size="default" className={cn("gap-1 pl-2.5", className)} {...props}>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
<span>Previous</span>
|
||||
</PaginationLink>
|
||||
);
|
||||
PaginationPrevious.displayName = "PaginationPrevious";
|
||||
|
||||
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
||||
<PaginationLink aria-label="Go to next page" size="default" className={cn("gap-1 pr-2.5", className)} {...props}>
|
||||
<span>Next</span>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</PaginationLink>
|
||||
);
|
||||
PaginationNext.displayName = "PaginationNext";
|
||||
|
||||
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
||||
<span aria-hidden className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
<span className="sr-only">More pages</span>
|
||||
</span>
|
||||
);
|
||||
PaginationEllipsis.displayName = "PaginationEllipsis";
|
||||
|
||||
export {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
PaginationEllipsis,
|
||||
PaginationItem,
|
||||
PaginationLink,
|
||||
PaginationNext,
|
||||
PaginationPrevious,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as React from "react";
|
||||
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Popover = PopoverPrimitive.Root;
|
||||
|
||||
const PopoverTrigger = PopoverPrimitive.Trigger;
|
||||
|
||||
const PopoverContent = React.forwardRef<
|
||||
React.ElementRef<typeof PopoverPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
||||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
ref={ref}
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</PopoverPrimitive.Portal>
|
||||
));
|
||||
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
||||
|
||||
export { Popover, PopoverTrigger, PopoverContent };
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as React from "react";
|
||||
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Progress = React.forwardRef<
|
||||
React.ElementRef<typeof ProgressPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
||||
>(({ className, value, ...props }, ref) => (
|
||||
<ProgressPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className)}
|
||||
{...props}
|
||||
>
|
||||
<ProgressPrimitive.Indicator
|
||||
className="h-full w-full flex-1 bg-primary transition-all"
|
||||
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
||||
/>
|
||||
</ProgressPrimitive.Root>
|
||||
));
|
||||
Progress.displayName = ProgressPrimitive.Root.displayName;
|
||||
|
||||
export { Progress };
|
||||
@@ -0,0 +1,36 @@
|
||||
import * as React from "react";
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
import { Circle } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const RadioGroup = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />;
|
||||
});
|
||||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
||||
|
||||
const RadioGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
||||
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
||||
</RadioGroupPrimitive.Indicator>
|
||||
</RadioGroupPrimitive.Item>
|
||||
);
|
||||
});
|
||||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
||||
|
||||
export { RadioGroup, RadioGroupItem };
|
||||
@@ -0,0 +1,37 @@
|
||||
import { GripVertical } from "lucide-react";
|
||||
import * as ResizablePrimitive from "react-resizable-panels";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const ResizablePanelGroup = ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
|
||||
<ResizablePrimitive.PanelGroup
|
||||
className={cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
const ResizablePanel = ResizablePrimitive.Panel;
|
||||
|
||||
const ResizableHandle = ({
|
||||
withHandle,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
|
||||
withHandle?: boolean;
|
||||
}) => (
|
||||
<ResizablePrimitive.PanelResizeHandle
|
||||
className={cn(
|
||||
"relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{withHandle && (
|
||||
<div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
|
||||
<GripVertical className="h-2.5 w-2.5" />
|
||||
</div>
|
||||
)}
|
||||
</ResizablePrimitive.PanelResizeHandle>
|
||||
);
|
||||
|
||||
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as React from "react";
|
||||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const ScrollArea = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.Root ref={ref} className={cn("relative overflow-hidden", className)} {...props}>
|
||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">{children}</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
));
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
||||
|
||||
const ScrollBar = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none select-none transition-colors",
|
||||
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
));
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
||||
|
||||
export { ScrollArea, ScrollBar };
|
||||
@@ -0,0 +1,143 @@
|
||||
import * as React from "react";
|
||||
import * as SelectPrimitive from "@radix-ui/react-select";
|
||||
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Select = SelectPrimitive.Root;
|
||||
|
||||
const SelectGroup = SelectPrimitive.Group;
|
||||
|
||||
const SelectValue = SelectPrimitive.Value;
|
||||
|
||||
const SelectTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDown className="h-4 w-4 opacity-50" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
));
|
||||
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
||||
|
||||
const SelectScrollUpButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollUpButton
|
||||
ref={ref}
|
||||
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollUpButton>
|
||||
));
|
||||
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
||||
|
||||
const SelectScrollDownButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollDownButton
|
||||
ref={ref}
|
||||
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollDownButton>
|
||||
));
|
||||
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
||||
|
||||
const SelectContent = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||
>(({ className, children, position = "popper", ...props }, ref) => (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover 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",
|
||||
position === "popper" &&
|
||||
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||
className,
|
||||
)}
|
||||
position={position}
|
||||
{...props}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.Viewport
|
||||
className={cn(
|
||||
"p-1",
|
||||
position === "popper" &&
|
||||
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</SelectPrimitive.Viewport>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
));
|
||||
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
||||
|
||||
const SelectLabel = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Label ref={ref} className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)} {...props} />
|
||||
));
|
||||
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
||||
|
||||
const SelectItem = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</span>
|
||||
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
</SelectPrimitive.Item>
|
||||
));
|
||||
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
||||
|
||||
const SelectSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
||||
));
|
||||
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectGroup,
|
||||
SelectValue,
|
||||
SelectTrigger,
|
||||
SelectContent,
|
||||
SelectLabel,
|
||||
SelectItem,
|
||||
SelectSeparator,
|
||||
SelectScrollUpButton,
|
||||
SelectScrollDownButton,
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as React from "react";
|
||||
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Separator = React.forwardRef<
|
||||
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
||||
>(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
|
||||
<SeparatorPrimitive.Root
|
||||
ref={ref}
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn("shrink-0 bg-border", orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
||||
|
||||
export { Separator };
|
||||
@@ -0,0 +1,107 @@
|
||||
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { X } from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Sheet = SheetPrimitive.Root;
|
||||
|
||||
const SheetTrigger = SheetPrimitive.Trigger;
|
||||
|
||||
const SheetClose = SheetPrimitive.Close;
|
||||
|
||||
const SheetPortal = SheetPrimitive.Portal;
|
||||
|
||||
const SheetOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Overlay
|
||||
className={cn(
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
));
|
||||
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
||||
|
||||
const sheetVariants = cva(
|
||||
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
||||
{
|
||||
variants: {
|
||||
side: {
|
||||
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
||||
bottom:
|
||||
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
||||
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
||||
right:
|
||||
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
side: "right",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
interface SheetContentProps
|
||||
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
||||
VariantProps<typeof sheetVariants> {}
|
||||
|
||||
const SheetContent = React.forwardRef<React.ElementRef<typeof SheetPrimitive.Content>, SheetContentProps>(
|
||||
({ side = "right", className, children, ...props }, ref) => (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
||||
{children}
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
),
|
||||
);
|
||||
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
||||
|
||||
const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
||||
);
|
||||
SheetHeader.displayName = "SheetHeader";
|
||||
|
||||
const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
||||
);
|
||||
SheetFooter.displayName = "SheetFooter";
|
||||
|
||||
const SheetTitle = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Title ref={ref} className={cn("text-lg font-semibold text-foreground", className)} {...props} />
|
||||
));
|
||||
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
||||
|
||||
const SheetDescription = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
||||
));
|
||||
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
SheetClose,
|
||||
SheetContent,
|
||||
SheetDescription,
|
||||
SheetFooter,
|
||||
SheetHeader,
|
||||
SheetOverlay,
|
||||
SheetPortal,
|
||||
SheetTitle,
|
||||
SheetTrigger,
|
||||
};
|
||||
@@ -0,0 +1,637 @@
|
||||
import * as React from "react";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { VariantProps, cva } from "class-variance-authority";
|
||||
import { PanelLeft } from "lucide-react";
|
||||
|
||||
import { useIsMobile } from "@/hooks/use-mobile";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Sheet, SheetContent } from "@/components/ui/sheet";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
|
||||
const SIDEBAR_COOKIE_NAME = "sidebar:state";
|
||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||
const SIDEBAR_WIDTH = "16rem";
|
||||
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
||||
const SIDEBAR_WIDTH_ICON = "3rem";
|
||||
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
||||
|
||||
type SidebarContext = {
|
||||
state: "expanded" | "collapsed";
|
||||
open: boolean;
|
||||
setOpen: (open: boolean) => void;
|
||||
openMobile: boolean;
|
||||
setOpenMobile: (open: boolean) => void;
|
||||
isMobile: boolean;
|
||||
toggleSidebar: () => void;
|
||||
};
|
||||
|
||||
const SidebarContext = React.createContext<SidebarContext | null>(null);
|
||||
|
||||
function useSidebar() {
|
||||
const context = React.useContext(SidebarContext);
|
||||
if (!context) {
|
||||
throw new Error("useSidebar must be used within a SidebarProvider.");
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
const SidebarProvider = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<"div"> & {
|
||||
defaultOpen?: boolean;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}
|
||||
>(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }, ref) => {
|
||||
const isMobile = useIsMobile();
|
||||
const [openMobile, setOpenMobile] = React.useState(false);
|
||||
|
||||
// This is the internal state of the sidebar.
|
||||
// We use openProp and setOpenProp for control from outside the component.
|
||||
const [_open, _setOpen] = React.useState(defaultOpen);
|
||||
const open = openProp ?? _open;
|
||||
const setOpen = React.useCallback(
|
||||
(value: boolean | ((value: boolean) => boolean)) => {
|
||||
const openState = typeof value === "function" ? value(open) : value;
|
||||
if (setOpenProp) {
|
||||
setOpenProp(openState);
|
||||
} else {
|
||||
_setOpen(openState);
|
||||
}
|
||||
|
||||
// This sets the cookie to keep the sidebar state.
|
||||
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
||||
},
|
||||
[setOpenProp, open],
|
||||
);
|
||||
|
||||
// Helper to toggle the sidebar.
|
||||
const toggleSidebar = React.useCallback(() => {
|
||||
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
||||
}, [isMobile, setOpen, setOpenMobile]);
|
||||
|
||||
// Adds a keyboard shortcut to toggle the sidebar.
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
||||
event.preventDefault();
|
||||
toggleSidebar();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [toggleSidebar]);
|
||||
|
||||
// We add a state so that we can do data-state="expanded" or "collapsed".
|
||||
// This makes it easier to style the sidebar with Tailwind classes.
|
||||
const state = open ? "expanded" : "collapsed";
|
||||
|
||||
const contextValue = React.useMemo<SidebarContext>(
|
||||
() => ({
|
||||
state,
|
||||
open,
|
||||
setOpen,
|
||||
isMobile,
|
||||
openMobile,
|
||||
setOpenMobile,
|
||||
toggleSidebar,
|
||||
}),
|
||||
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
|
||||
);
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider value={contextValue}>
|
||||
<TooltipProvider delayDuration={0}>
|
||||
<div
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH,
|
||||
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
||||
...style,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
className={cn("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar", className)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</TooltipProvider>
|
||||
</SidebarContext.Provider>
|
||||
);
|
||||
});
|
||||
SidebarProvider.displayName = "SidebarProvider";
|
||||
|
||||
const Sidebar = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<"div"> & {
|
||||
side?: "left" | "right";
|
||||
variant?: "sidebar" | "floating" | "inset";
|
||||
collapsible?: "offcanvas" | "icon" | "none";
|
||||
}
|
||||
>(({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, ...props }, ref) => {
|
||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
||||
|
||||
if (collapsible === "none") {
|
||||
return (
|
||||
<div
|
||||
className={cn("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground", className)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
||||
<SheetContent
|
||||
data-sidebar="sidebar"
|
||||
data-mobile="true"
|
||||
className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
side={side}
|
||||
>
|
||||
<div className="flex h-full w-full flex-col">{children}</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className="group peer hidden text-sidebar-foreground md:block"
|
||||
data-state={state}
|
||||
data-collapsible={state === "collapsed" ? collapsible : ""}
|
||||
data-variant={variant}
|
||||
data-side={side}
|
||||
>
|
||||
{/* This is what handles the sidebar gap on desktop */}
|
||||
<div
|
||||
className={cn(
|
||||
"relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
|
||||
"group-data-[collapsible=offcanvas]:w-0",
|
||||
"group-data-[side=right]:rotate-180",
|
||||
variant === "floating" || variant === "inset"
|
||||
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
|
||||
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon]",
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
"fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
|
||||
side === "left"
|
||||
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
||||
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
||||
// Adjust the padding for floating and inset variants.
|
||||
variant === "floating" || variant === "inset"
|
||||
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
|
||||
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
data-sidebar="sidebar"
|
||||
className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Sidebar.displayName = "Sidebar";
|
||||
|
||||
const SidebarTrigger = React.forwardRef<React.ElementRef<typeof Button>, React.ComponentProps<typeof Button>>(
|
||||
({ className, onClick, ...props }, ref) => {
|
||||
const { toggleSidebar } = useSidebar();
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
data-sidebar="trigger"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={cn("h-7 w-7", className)}
|
||||
onClick={(event) => {
|
||||
onClick?.(event);
|
||||
toggleSidebar();
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
<PanelLeft />
|
||||
<span className="sr-only">Toggle Sidebar</span>
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarTrigger.displayName = "SidebarTrigger";
|
||||
|
||||
const SidebarRail = React.forwardRef<HTMLButtonElement, React.ComponentProps<"button">>(
|
||||
({ className, ...props }, ref) => {
|
||||
const { toggleSidebar } = useSidebar();
|
||||
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
data-sidebar="rail"
|
||||
aria-label="Toggle Sidebar"
|
||||
tabIndex={-1}
|
||||
onClick={toggleSidebar}
|
||||
title="Toggle Sidebar"
|
||||
className={cn(
|
||||
"absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 hover:after:bg-sidebar-border sm:flex",
|
||||
"[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
|
||||
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
||||
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
|
||||
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
||||
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarRail.displayName = "SidebarRail";
|
||||
|
||||
const SidebarInset = React.forwardRef<HTMLDivElement, React.ComponentProps<"main">>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<main
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex min-h-svh flex-1 flex-col bg-background",
|
||||
"peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
SidebarInset.displayName = "SidebarInset";
|
||||
|
||||
const SidebarInput = React.forwardRef<React.ElementRef<typeof Input>, React.ComponentProps<typeof Input>>(
|
||||
({ className, ...props }, ref) => {
|
||||
return (
|
||||
<Input
|
||||
ref={ref}
|
||||
data-sidebar="input"
|
||||
className={cn(
|
||||
"h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarInput.displayName = "SidebarInput";
|
||||
|
||||
const SidebarHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
|
||||
return <div ref={ref} data-sidebar="header" className={cn("flex flex-col gap-2 p-2", className)} {...props} />;
|
||||
});
|
||||
SidebarHeader.displayName = "SidebarHeader";
|
||||
|
||||
const SidebarFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
|
||||
return <div ref={ref} data-sidebar="footer" className={cn("flex flex-col gap-2 p-2", className)} {...props} />;
|
||||
});
|
||||
SidebarFooter.displayName = "SidebarFooter";
|
||||
|
||||
const SidebarSeparator = React.forwardRef<React.ElementRef<typeof Separator>, React.ComponentProps<typeof Separator>>(
|
||||
({ className, ...props }, ref) => {
|
||||
return (
|
||||
<Separator
|
||||
ref={ref}
|
||||
data-sidebar="separator"
|
||||
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarSeparator.displayName = "SidebarSeparator";
|
||||
|
||||
const SidebarContent = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
data-sidebar="content"
|
||||
className={cn(
|
||||
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
SidebarContent.displayName = "SidebarContent";
|
||||
|
||||
const SidebarGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
data-sidebar="group"
|
||||
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
SidebarGroup.displayName = "SidebarGroup";
|
||||
|
||||
const SidebarGroupLabel = React.forwardRef<HTMLDivElement, React.ComponentProps<"div"> & { asChild?: boolean }>(
|
||||
({ className, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "div";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-sidebar="group-label"
|
||||
className={cn(
|
||||
"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarGroupLabel.displayName = "SidebarGroupLabel";
|
||||
|
||||
const SidebarGroupAction = React.forwardRef<HTMLButtonElement, React.ComponentProps<"button"> & { asChild?: boolean }>(
|
||||
({ className, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-sidebar="group-action"
|
||||
className={cn(
|
||||
"absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
// Increases the hit area of the button on mobile.
|
||||
"after:absolute after:-inset-2 after:md:hidden",
|
||||
"group-data-[collapsible=icon]:hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
SidebarGroupAction.displayName = "SidebarGroupAction";
|
||||
|
||||
const SidebarGroupContent = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div ref={ref} data-sidebar="group-content" className={cn("w-full text-sm", className)} {...props} />
|
||||
),
|
||||
);
|
||||
SidebarGroupContent.displayName = "SidebarGroupContent";
|
||||
|
||||
const SidebarMenu = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(({ className, ...props }, ref) => (
|
||||
<ul ref={ref} data-sidebar="menu" className={cn("flex w-full min-w-0 flex-col gap-1", className)} {...props} />
|
||||
));
|
||||
SidebarMenu.displayName = "SidebarMenu";
|
||||
|
||||
const SidebarMenuItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
|
||||
<li ref={ref} data-sidebar="menu-item" className={cn("group/menu-item relative", className)} {...props} />
|
||||
));
|
||||
SidebarMenuItem.displayName = "SidebarMenuItem";
|
||||
|
||||
const sidebarMenuButtonVariants = cva(
|
||||
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
outline:
|
||||
"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
|
||||
},
|
||||
size: {
|
||||
default: "h-8 text-sm",
|
||||
sm: "h-7 text-xs",
|
||||
lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const SidebarMenuButton = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
React.ComponentProps<"button"> & {
|
||||
asChild?: boolean;
|
||||
isActive?: boolean;
|
||||
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
||||
} & VariantProps<typeof sidebarMenuButtonVariants>
|
||||
>(({ asChild = false, isActive = false, variant = "default", size = "default", tooltip, className, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
const { isMobile, state } = useSidebar();
|
||||
|
||||
const button = (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-sidebar="menu-button"
|
||||
data-size={size}
|
||||
data-active={isActive}
|
||||
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
if (!tooltip) {
|
||||
return button;
|
||||
}
|
||||
|
||||
if (typeof tooltip === "string") {
|
||||
tooltip = {
|
||||
children: tooltip,
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
||||
<TooltipContent side="right" align="center" hidden={state !== "collapsed" || isMobile} {...tooltip} />
|
||||
</Tooltip>
|
||||
);
|
||||
});
|
||||
SidebarMenuButton.displayName = "SidebarMenuButton";
|
||||
|
||||
const SidebarMenuAction = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
React.ComponentProps<"button"> & {
|
||||
asChild?: boolean;
|
||||
showOnHover?: boolean;
|
||||
}
|
||||
>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-sidebar="menu-action"
|
||||
className={cn(
|
||||
"absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
// Increases the hit area of the button on mobile.
|
||||
"after:absolute after:-inset-2 after:md:hidden",
|
||||
"peer-data-[size=sm]/menu-button:top-1",
|
||||
"peer-data-[size=default]/menu-button:top-1.5",
|
||||
"peer-data-[size=lg]/menu-button:top-2.5",
|
||||
"group-data-[collapsible=icon]:hidden",
|
||||
showOnHover &&
|
||||
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
SidebarMenuAction.displayName = "SidebarMenuAction";
|
||||
|
||||
const SidebarMenuBadge = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
data-sidebar="menu-badge"
|
||||
className={cn(
|
||||
"pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground",
|
||||
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
||||
"peer-data-[size=sm]/menu-button:top-1",
|
||||
"peer-data-[size=default]/menu-button:top-1.5",
|
||||
"peer-data-[size=lg]/menu-button:top-2.5",
|
||||
"group-data-[collapsible=icon]:hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
SidebarMenuBadge.displayName = "SidebarMenuBadge";
|
||||
|
||||
const SidebarMenuSkeleton = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.ComponentProps<"div"> & {
|
||||
showIcon?: boolean;
|
||||
}
|
||||
>(({ className, showIcon = false, ...props }, ref) => {
|
||||
// Random width between 50 to 90%.
|
||||
const width = React.useMemo(() => {
|
||||
return `${Math.floor(Math.random() * 40) + 50}%`;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
data-sidebar="menu-skeleton"
|
||||
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
||||
{...props}
|
||||
>
|
||||
{showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
|
||||
<Skeleton
|
||||
className="h-4 max-w-[--skeleton-width] flex-1"
|
||||
data-sidebar="menu-skeleton-text"
|
||||
style={
|
||||
{
|
||||
"--skeleton-width": width,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
|
||||
|
||||
const SidebarMenuSub = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<ul
|
||||
ref={ref}
|
||||
data-sidebar="menu-sub"
|
||||
className={cn(
|
||||
"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
|
||||
"group-data-[collapsible=icon]:hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
SidebarMenuSub.displayName = "SidebarMenuSub";
|
||||
|
||||
const SidebarMenuSubItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ ...props }, ref) => (
|
||||
<li ref={ref} {...props} />
|
||||
));
|
||||
SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
||||
|
||||
const SidebarMenuSubButton = React.forwardRef<
|
||||
HTMLAnchorElement,
|
||||
React.ComponentProps<"a"> & {
|
||||
asChild?: boolean;
|
||||
size?: "sm" | "md";
|
||||
isActive?: boolean;
|
||||
}
|
||||
>(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "a";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-sidebar="menu-sub-button"
|
||||
data-size={size}
|
||||
data-active={isActive}
|
||||
className={cn(
|
||||
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
|
||||
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
||||
size === "sm" && "text-xs",
|
||||
size === "md" && "text-sm",
|
||||
"group-data-[collapsible=icon]:hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
||||
|
||||
export {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupAction,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
SidebarHeader,
|
||||
SidebarInput,
|
||||
SidebarInset,
|
||||
SidebarMenu,
|
||||
SidebarMenuAction,
|
||||
SidebarMenuBadge,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarMenuSkeleton,
|
||||
SidebarMenuSub,
|
||||
SidebarMenuSubButton,
|
||||
SidebarMenuSubItem,
|
||||
SidebarProvider,
|
||||
SidebarRail,
|
||||
SidebarSeparator,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn("animate-pulse rounded-md bg-muted", className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Skeleton };
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as React from "react";
|
||||
import * as SliderPrimitive from "@radix-ui/react-slider";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Slider = React.forwardRef<
|
||||
React.ElementRef<typeof SliderPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SliderPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative flex w-full touch-none select-none items-center", className)}
|
||||
{...props}
|
||||
>
|
||||
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
||||
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
||||
</SliderPrimitive.Track>
|
||||
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
|
||||
</SliderPrimitive.Root>
|
||||
));
|
||||
Slider.displayName = SliderPrimitive.Root.displayName;
|
||||
|
||||
export { Slider };
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useTheme } from "next-themes";
|
||||
import { Toaster as Sonner, toast } from "sonner";
|
||||
|
||||
type ToasterProps = React.ComponentProps<typeof Sonner>;
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
const { theme = "system" } = useTheme();
|
||||
|
||||
return (
|
||||
<Sonner
|
||||
theme={theme as ToasterProps["theme"]}
|
||||
className="toaster group"
|
||||
toastOptions={{
|
||||
classNames: {
|
||||
toast:
|
||||
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
||||
description: "group-[.toast]:text-muted-foreground",
|
||||
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
||||
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
||||
},
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export { Toaster, toast };
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as React from "react";
|
||||
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Switch = React.forwardRef<
|
||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SwitchPrimitives.Root
|
||||
className={cn(
|
||||
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<SwitchPrimitives.Thumb
|
||||
className={cn(
|
||||
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
|
||||
)}
|
||||
/>
|
||||
</SwitchPrimitives.Root>
|
||||
));
|
||||
Switch.displayName = SwitchPrimitives.Root.displayName;
|
||||
|
||||
export { Switch };
|
||||
@@ -0,0 +1,72 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div className="relative w-full overflow-auto">
|
||||
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
|
||||
</div>
|
||||
),
|
||||
);
|
||||
Table.displayName = "Table";
|
||||
|
||||
const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
||||
({ className, ...props }, ref) => <thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />,
|
||||
);
|
||||
TableHeader.displayName = "TableHeader";
|
||||
|
||||
const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
|
||||
),
|
||||
);
|
||||
TableBody.displayName = "TableBody";
|
||||
|
||||
const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<tfoot ref={ref} className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)} {...props} />
|
||||
),
|
||||
);
|
||||
TableFooter.displayName = "TableFooter";
|
||||
|
||||
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<tr
|
||||
ref={ref}
|
||||
className={cn("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50", className)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
TableRow.displayName = "TableRow";
|
||||
|
||||
const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<th
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
TableHead.displayName = "TableHead";
|
||||
|
||||
const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<td ref={ref} className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} {...props} />
|
||||
),
|
||||
);
|
||||
TableCell.displayName = "TableCell";
|
||||
|
||||
const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
|
||||
),
|
||||
);
|
||||
TableCaption.displayName = "TableCaption";
|
||||
|
||||
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
|
||||
@@ -0,0 +1,53 @@
|
||||
import * as React from "react";
|
||||
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Tabs = TabsPrimitive.Root;
|
||||
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
||||
@@ -0,0 +1,21 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
||||
|
||||
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<textarea
|
||||
className={cn(
|
||||
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
Textarea.displayName = "Textarea";
|
||||
|
||||
export { Textarea };
|
||||
@@ -0,0 +1,111 @@
|
||||
import * as React from "react";
|
||||
import * as ToastPrimitives from "@radix-ui/react-toast";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const ToastProvider = ToastPrimitives.Provider;
|
||||
|
||||
const ToastViewport = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ToastPrimitives.Viewport
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
||||
|
||||
const toastVariants = cva(
|
||||
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "border bg-background text-foreground",
|
||||
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const Toast = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & VariantProps<typeof toastVariants>
|
||||
>(({ className, variant, ...props }, ref) => {
|
||||
return <ToastPrimitives.Root ref={ref} className={cn(toastVariants({ variant }), className)} {...props} />;
|
||||
});
|
||||
Toast.displayName = ToastPrimitives.Root.displayName;
|
||||
|
||||
const ToastAction = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Action>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ToastPrimitives.Action
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
||||
|
||||
const ToastClose = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Close>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ToastPrimitives.Close
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
||||
className,
|
||||
)}
|
||||
toast-close=""
|
||||
{...props}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</ToastPrimitives.Close>
|
||||
));
|
||||
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
||||
|
||||
const ToastTitle = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ToastPrimitives.Title ref={ref} className={cn("text-sm font-semibold", className)} {...props} />
|
||||
));
|
||||
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
||||
|
||||
const ToastDescription = React.forwardRef<
|
||||
React.ElementRef<typeof ToastPrimitives.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ToastPrimitives.Description ref={ref} className={cn("text-sm opacity-90", className)} {...props} />
|
||||
));
|
||||
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
||||
|
||||
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
||||
|
||||
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
||||
|
||||
export {
|
||||
type ToastProps,
|
||||
type ToastActionElement,
|
||||
ToastProvider,
|
||||
ToastViewport,
|
||||
Toast,
|
||||
ToastTitle,
|
||||
ToastDescription,
|
||||
ToastClose,
|
||||
ToastAction,
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from "@/components/ui/toast";
|
||||
|
||||
export function Toaster() {
|
||||
const { toasts } = useToast();
|
||||
|
||||
return (
|
||||
<ToastProvider>
|
||||
{toasts.map(function ({ id, title, description, action, ...props }) {
|
||||
return (
|
||||
<Toast key={id} {...props}>
|
||||
<div className="grid gap-1">
|
||||
{title && <ToastTitle>{title}</ToastTitle>}
|
||||
{description && <ToastDescription>{description}</ToastDescription>}
|
||||
</div>
|
||||
{action}
|
||||
<ToastClose />
|
||||
</Toast>
|
||||
);
|
||||
})}
|
||||
<ToastViewport />
|
||||
</ToastProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import * as React from "react";
|
||||
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
||||
import { type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { toggleVariants } from "@/components/ui/toggle";
|
||||
|
||||
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({
|
||||
size: "default",
|
||||
variant: "default",
|
||||
});
|
||||
|
||||
const ToggleGroup = React.forwardRef<
|
||||
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>
|
||||
>(({ className, variant, size, children, ...props }, ref) => (
|
||||
<ToggleGroupPrimitive.Root ref={ref} className={cn("flex items-center justify-center gap-1", className)} {...props}>
|
||||
<ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
|
||||
</ToggleGroupPrimitive.Root>
|
||||
));
|
||||
|
||||
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
||||
|
||||
const ToggleGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>
|
||||
>(({ className, children, variant, size, ...props }, ref) => {
|
||||
const context = React.useContext(ToggleGroupContext);
|
||||
|
||||
return (
|
||||
<ToggleGroupPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
toggleVariants({
|
||||
variant: context.variant || variant,
|
||||
size: context.size || size,
|
||||
}),
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</ToggleGroupPrimitive.Item>
|
||||
);
|
||||
});
|
||||
|
||||
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
||||
|
||||
export { ToggleGroup, ToggleGroupItem };
|
||||
@@ -0,0 +1,37 @@
|
||||
import * as React from "react";
|
||||
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const toggleVariants = cva(
|
||||
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-transparent",
|
||||
outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
||||
},
|
||||
size: {
|
||||
default: "h-10 px-3",
|
||||
sm: "h-9 px-2.5",
|
||||
lg: "h-11 px-5",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const Toggle = React.forwardRef<
|
||||
React.ElementRef<typeof TogglePrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
|
||||
>(({ className, variant, size, ...props }, ref) => (
|
||||
<TogglePrimitive.Root ref={ref} className={cn(toggleVariants({ variant, size, className }))} {...props} />
|
||||
));
|
||||
|
||||
Toggle.displayName = TogglePrimitive.Root.displayName;
|
||||
|
||||
export { Toggle, toggleVariants };
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as React from "react";
|
||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const TooltipProvider = TooltipPrimitive.Provider;
|
||||
|
||||
const Tooltip = TooltipPrimitive.Root;
|
||||
|
||||
const TooltipTrigger = TooltipPrimitive.Trigger;
|
||||
|
||||
const TooltipContent = React.forwardRef<
|
||||
React.ElementRef<typeof TooltipPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<TooltipPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
||||
@@ -0,0 +1,3 @@
|
||||
import { useToast, toast } from "@/hooks/use-toast";
|
||||
|
||||
export { useToast, toast };
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as React from "react";
|
||||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
};
|
||||
mql.addEventListener("change", onChange);
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
return () => mql.removeEventListener("change", onChange);
|
||||
}, []);
|
||||
|
||||
return !!isMobile;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
import * as React from "react";
|
||||
|
||||
import type { ToastActionElement, ToastProps } from "@/components/ui/toast";
|
||||
|
||||
const TOAST_LIMIT = 1;
|
||||
const TOAST_REMOVE_DELAY = 1000000;
|
||||
|
||||
type ToasterToast = ToastProps & {
|
||||
id: string;
|
||||
title?: React.ReactNode;
|
||||
description?: React.ReactNode;
|
||||
action?: ToastActionElement;
|
||||
};
|
||||
|
||||
const actionTypes = {
|
||||
ADD_TOAST: "ADD_TOAST",
|
||||
UPDATE_TOAST: "UPDATE_TOAST",
|
||||
DISMISS_TOAST: "DISMISS_TOAST",
|
||||
REMOVE_TOAST: "REMOVE_TOAST",
|
||||
} as const;
|
||||
|
||||
let count = 0;
|
||||
|
||||
function genId() {
|
||||
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
||||
return count.toString();
|
||||
}
|
||||
|
||||
type ActionType = typeof actionTypes;
|
||||
|
||||
type Action =
|
||||
| {
|
||||
type: ActionType["ADD_TOAST"];
|
||||
toast: ToasterToast;
|
||||
}
|
||||
| {
|
||||
type: ActionType["UPDATE_TOAST"];
|
||||
toast: Partial<ToasterToast>;
|
||||
}
|
||||
| {
|
||||
type: ActionType["DISMISS_TOAST"];
|
||||
toastId?: ToasterToast["id"];
|
||||
}
|
||||
| {
|
||||
type: ActionType["REMOVE_TOAST"];
|
||||
toastId?: ToasterToast["id"];
|
||||
};
|
||||
|
||||
interface State {
|
||||
toasts: ToasterToast[];
|
||||
}
|
||||
|
||||
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
||||
|
||||
const addToRemoveQueue = (toastId: string) => {
|
||||
if (toastTimeouts.has(toastId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
toastTimeouts.delete(toastId);
|
||||
dispatch({
|
||||
type: "REMOVE_TOAST",
|
||||
toastId: toastId,
|
||||
});
|
||||
}, TOAST_REMOVE_DELAY);
|
||||
|
||||
toastTimeouts.set(toastId, timeout);
|
||||
};
|
||||
|
||||
export const reducer = (state: State, action: Action): State => {
|
||||
switch (action.type) {
|
||||
case "ADD_TOAST":
|
||||
return {
|
||||
...state,
|
||||
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
||||
};
|
||||
|
||||
case "UPDATE_TOAST":
|
||||
return {
|
||||
...state,
|
||||
toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)),
|
||||
};
|
||||
|
||||
case "DISMISS_TOAST": {
|
||||
const { toastId } = action;
|
||||
|
||||
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
||||
// but I'll keep it here for simplicity
|
||||
if (toastId) {
|
||||
addToRemoveQueue(toastId);
|
||||
} else {
|
||||
state.toasts.forEach((toast) => {
|
||||
addToRemoveQueue(toast.id);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
toasts: state.toasts.map((t) =>
|
||||
t.id === toastId || toastId === undefined
|
||||
? {
|
||||
...t,
|
||||
open: false,
|
||||
}
|
||||
: t,
|
||||
),
|
||||
};
|
||||
}
|
||||
case "REMOVE_TOAST":
|
||||
if (action.toastId === undefined) {
|
||||
return {
|
||||
...state,
|
||||
toasts: [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const listeners: Array<(state: State) => void> = [];
|
||||
|
||||
let memoryState: State = { toasts: [] };
|
||||
|
||||
function dispatch(action: Action) {
|
||||
memoryState = reducer(memoryState, action);
|
||||
listeners.forEach((listener) => {
|
||||
listener(memoryState);
|
||||
});
|
||||
}
|
||||
|
||||
type Toast = Omit<ToasterToast, "id">;
|
||||
|
||||
function toast({ ...props }: Toast) {
|
||||
const id = genId();
|
||||
|
||||
const update = (props: ToasterToast) =>
|
||||
dispatch({
|
||||
type: "UPDATE_TOAST",
|
||||
toast: { ...props, id },
|
||||
});
|
||||
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
||||
|
||||
dispatch({
|
||||
type: "ADD_TOAST",
|
||||
toast: {
|
||||
...props,
|
||||
id,
|
||||
open: true,
|
||||
onOpenChange: (open) => {
|
||||
if (!open) dismiss();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
id: id,
|
||||
dismiss,
|
||||
update,
|
||||
};
|
||||
}
|
||||
|
||||
function useToast() {
|
||||
const [state, setState] = React.useState<State>(memoryState);
|
||||
|
||||
React.useEffect(() => {
|
||||
listeners.push(setState);
|
||||
return () => {
|
||||
const index = listeners.indexOf(setState);
|
||||
if (index > -1) {
|
||||
listeners.splice(index, 1);
|
||||
}
|
||||
};
|
||||
}, [state]);
|
||||
|
||||
return {
|
||||
...state,
|
||||
toast,
|
||||
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
||||
};
|
||||
}
|
||||
|
||||
export { useToast, toast };
|
||||
@@ -0,0 +1,84 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* Definition of the design system. All colors, gradients, fonts, etc should be defined here.
|
||||
All colors MUST be HSL.
|
||||
*/
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 10%;
|
||||
--foreground: 0 0% 95%;
|
||||
|
||||
--card: 0 0% 14%;
|
||||
--card-foreground: 0 0% 95%;
|
||||
|
||||
--popover: 0 0% 14%;
|
||||
--popover-foreground: 0 0% 95%;
|
||||
|
||||
--primary: 0 0% 50%;
|
||||
--primary-foreground: 0 0% 98%;
|
||||
--primary-glow: 0 0% 60%;
|
||||
|
||||
--secondary: 0 0% 18%;
|
||||
--secondary-foreground: 0 0% 95%;
|
||||
|
||||
--muted: 0 0% 18%;
|
||||
--muted-foreground: 0 0% 60%;
|
||||
|
||||
--accent: 0 0% 70%;
|
||||
--accent-foreground: 0 0% 10%;
|
||||
--accent-glow: 0 0% 75%;
|
||||
|
||||
--destructive: 0 0% 50%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
|
||||
--border: 0 0% 22%;
|
||||
--input: 0 0% 22%;
|
||||
--ring: 0 0% 50%;
|
||||
|
||||
--radius: 0.5rem;
|
||||
|
||||
--sidebar-background: 0 0% 12%;
|
||||
--sidebar-foreground: 0 0% 60%;
|
||||
--sidebar-primary: 0 0% 50%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 0 0% 18%;
|
||||
--sidebar-accent-foreground: 0 0% 95%;
|
||||
--sidebar-border: 0 0% 22%;
|
||||
--sidebar-ring: 0 0% 50%;
|
||||
|
||||
/* Success colors for completed states */
|
||||
--success: 142 76% 36%;
|
||||
--success-foreground: 142 76% 95%;
|
||||
|
||||
/* Custom design tokens */
|
||||
--gradient-primary: linear-gradient(135deg, hsl(0 0% 20%), hsl(0 0% 15%));
|
||||
--gradient-accent: linear-gradient(135deg, hsl(0 0% 25%), hsl(0 0% 20%));
|
||||
--gradient-card: linear-gradient(180deg, hsl(0 0% 16%), hsl(0 0% 14%));
|
||||
|
||||
--shadow-glow: 0 0 30px hsl(0 0% 0% / 0.4);
|
||||
--shadow-accent-glow: 0 0 20px hsl(0 0% 0% / 0.3);
|
||||
--shadow-card: 0 4px 20px hsl(0 0% 0% / 0.5);
|
||||
|
||||
--transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
/* Widget embed overrides */
|
||||
.widget-embed {
|
||||
--background: var(--widget-bg, 0 0% 10%);
|
||||
--primary: var(--widget-primary, 0 0% 50%);
|
||||
--accent: var(--widget-accent, 142 76% 36%);
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// This file is automatically generated. Do not edit it directly.
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import type { Database } from './types';
|
||||
|
||||
const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL;
|
||||
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;
|
||||
|
||||
// Import the supabase client like this:
|
||||
// import { supabase } from "@/integrations/supabase/client";
|
||||
|
||||
export const supabase = createClient<Database>(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
|
||||
auth: {
|
||||
storage: localStorage,
|
||||
persistSession: true,
|
||||
autoRefreshToken: true,
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,155 @@
|
||||
export type Json =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| { [key: string]: Json | undefined }
|
||||
| Json[]
|
||||
|
||||
export type Database = {
|
||||
// Allows to automatically instantiate createClient with right options
|
||||
// instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
|
||||
__InternalSupabase: {
|
||||
PostgrestVersion: "13.0.5"
|
||||
}
|
||||
public: {
|
||||
Tables: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Views: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Functions: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Enums: {
|
||||
[_ in never]: never
|
||||
}
|
||||
CompositeTypes: {
|
||||
[_ in never]: never
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
|
||||
|
||||
type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]
|
||||
|
||||
export type Tables<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
||||
Row: infer R
|
||||
}
|
||||
? R
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
|
||||
DefaultSchema["Views"])
|
||||
? (DefaultSchema["Tables"] &
|
||||
DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
|
||||
Row: infer R
|
||||
}
|
||||
? R
|
||||
: never
|
||||
: never
|
||||
|
||||
export type TablesInsert<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
Insert: infer I
|
||||
}
|
||||
? I
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
|
||||
? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
|
||||
Insert: infer I
|
||||
}
|
||||
? I
|
||||
: never
|
||||
: never
|
||||
|
||||
export type TablesUpdate<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
Update: infer U
|
||||
}
|
||||
? U
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
|
||||
? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
|
||||
Update: infer U
|
||||
}
|
||||
? U
|
||||
: never
|
||||
: never
|
||||
|
||||
export type Enums<
|
||||
DefaultSchemaEnumNameOrOptions extends
|
||||
| keyof DefaultSchema["Enums"]
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
EnumName extends DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
||||
: never = never,
|
||||
> = DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
||||
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
|
||||
? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
|
||||
: never
|
||||
|
||||
export type CompositeTypes<
|
||||
PublicCompositeTypeNameOrOptions extends
|
||||
| keyof DefaultSchema["CompositeTypes"]
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
||||
: never = never,
|
||||
> = PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
||||
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
|
||||
? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
|
||||
: never
|
||||
|
||||
export const Constants = {
|
||||
public: {
|
||||
Enums: {},
|
||||
},
|
||||
} as const
|
||||
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user