@motiadev/workbench 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/components.json +21 -0
- package/dist/.empty +0 -0
- package/dist/assets/index-DGmArPOa.css +1 -0
- package/dist/assets/index-hQsWtfVb.js +182 -0
- package/dist/index.html +20 -0
- package/eslint.config.js +28 -0
- package/index.html +19 -0
- package/index.tsx +10 -0
- package/middleware.ts +46 -0
- package/package.json +56 -0
- package/postcss.config.js +6 -0
- package/public/.empty +0 -0
- package/src/assets/.empty +0 -0
- package/src/components/app-sidebar.tsx +55 -0
- package/src/components/log-console.tsx +76 -0
- package/src/components/log-level-badge.tsx +12 -0
- package/src/components/ui/badge.tsx +31 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/dialog.tsx +120 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/select.tsx +157 -0
- package/src/components/ui/separator.tsx +22 -0
- package/src/components/ui/sheet.tsx +106 -0
- package/src/components/ui/sidebar.tsx +637 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +76 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/hooks/use-list-flows.tsx +20 -0
- package/src/hooks/use-log-listener.tsx +32 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/index.css +190 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.tsx +28 -0
- package/src/publicComponents/api-node.tsx +28 -0
- package/src/publicComponents/base-handle.tsx +43 -0
- package/src/publicComponents/base-node.tsx +57 -0
- package/src/publicComponents/emits.tsx +22 -0
- package/src/publicComponents/event-node.tsx +36 -0
- package/src/publicComponents/node-props.tsx +15 -0
- package/src/publicComponents/noop-node.tsx +21 -0
- package/src/publicComponents/subscribe.tsx +19 -0
- package/src/route-wrapper.tsx +9 -0
- package/src/routeTree.gen.ts +109 -0
- package/src/routes/__root.tsx +26 -0
- package/src/routes/flow/$id.tsx +21 -0
- package/src/routes/index.tsx +13 -0
- package/src/stores/use-logs.ts +22 -0
- package/src/views/flow/arrow-head.tsx +13 -0
- package/src/views/flow/base-edge.tsx +44 -0
- package/src/views/flow/flow-loader.tsx +3 -0
- package/src/views/flow/flow-view.tsx +72 -0
- package/src/views/flow/hooks/use-get-flow-state.tsx +109 -0
- package/src/views/flow/hooks/use-organize-nodes.ts +60 -0
- package/src/views/flow/legend.tsx +59 -0
- package/src/views/flow/node-organizer.tsx +70 -0
- package/src/views/flow/nodes/api-flow-node.tsx +6 -0
- package/src/views/flow/nodes/event-flow-node.tsx +6 -0
- package/src/views/flow/nodes/json-schema-form.tsx +110 -0
- package/src/views/flow/nodes/language-indicator.tsx +74 -0
- package/src/views/flow/nodes/nodes.types.ts +36 -0
- package/src/views/flow/nodes/noop-flow-node.tsx +6 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.ts +75 -0
- package/tsconfig.app.json +30 -0
- package/tsconfig.json +13 -0
- package/tsconfig.node.json +22 -0
- package/tsconfig.node.tsbuildinfo +1 -0
- package/vite.config.ts +14 -0
package/dist/index.html
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
|
|
6
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
7
|
+
<link
|
|
8
|
+
href="https://fonts.googleapis.com/css2?family=PT+Sans:wght@0,200..1000;1,200..1000&display=swap&family=PT+Mono:wght@0,200..1000;1,200..1000&display=swap"
|
|
9
|
+
rel="stylesheet"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
13
|
+
<title>Wistro</title>
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-hQsWtfVb.js"></script>
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DGmArPOa.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body class="dark">
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{ ignores: ['dist'] },
|
|
9
|
+
{
|
|
10
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
ecmaVersion: 2020,
|
|
14
|
+
globals: globals.browser,
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
'react-hooks': reactHooks,
|
|
18
|
+
'react-refresh': reactRefresh,
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
...reactHooks.configs.recommended.rules,
|
|
22
|
+
'react-refresh/only-export-components': [
|
|
23
|
+
'warn',
|
|
24
|
+
{ allowConstantExport: true },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
)
|
package/index.html
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
|
|
6
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
7
|
+
<link
|
|
8
|
+
href="https://fonts.googleapis.com/css2?family=PT+Sans:wght@0,200..1000;1,200..1000&display=swap&family=PT+Mono:wght@0,200..1000;1,200..1000&display=swap"
|
|
9
|
+
rel="stylesheet"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
13
|
+
<title>Motia</title>
|
|
14
|
+
</head>
|
|
15
|
+
<body class="dark">
|
|
16
|
+
<div id="root"></div>
|
|
17
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
package/index.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { EventNode } from './src/publicComponents/event-node'
|
|
2
|
+
export { ApiNode } from './src/publicComponents/api-node'
|
|
3
|
+
export { NoopNode } from './src/publicComponents/noop-node'
|
|
4
|
+
export { BaseNode } from './src/publicComponents/base-node'
|
|
5
|
+
export { BaseHandle } from './src/publicComponents/base-handle'
|
|
6
|
+
|
|
7
|
+
export { Position } from '@xyflow/react'
|
|
8
|
+
export type { EventNodeData, ApiNodeData } from './src/views/flow/nodes/nodes.types'
|
|
9
|
+
export * from './src/publicComponents/node-props'
|
|
10
|
+
export { Button } from './src/components/ui/button'
|
package/middleware.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import autoprefixer from 'autoprefixer'
|
|
2
|
+
import type { Express, NextFunction, Request, Response } from 'express'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import tailwindcss from 'tailwindcss'
|
|
6
|
+
import { createServer as createViteServer } from 'vite'
|
|
7
|
+
import tailwindcssConfig from './tailwind.config'
|
|
8
|
+
|
|
9
|
+
export const applyMiddleware = async (app: Express) => {
|
|
10
|
+
const vite = await createViteServer({
|
|
11
|
+
appType: 'spa',
|
|
12
|
+
root: __dirname,
|
|
13
|
+
|
|
14
|
+
server: {
|
|
15
|
+
middlewareMode: true,
|
|
16
|
+
fs: {
|
|
17
|
+
allow: [__dirname, path.join(process.cwd(), './steps')],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
resolve: {
|
|
21
|
+
alias: { '@': path.resolve(__dirname, './src') },
|
|
22
|
+
},
|
|
23
|
+
css: {
|
|
24
|
+
postcss: {
|
|
25
|
+
plugins: [autoprefixer(), tailwindcss(tailwindcssConfig)],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
app.use(vite.middlewares)
|
|
31
|
+
|
|
32
|
+
app.use('*', async (req: Request, res: Response, next: NextFunction) => {
|
|
33
|
+
const url = req.originalUrl
|
|
34
|
+
|
|
35
|
+
console.log('[UI] Request', { url })
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const index = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8')
|
|
39
|
+
const html = await vite.transformIndexHtml(url, index)
|
|
40
|
+
|
|
41
|
+
res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
|
|
42
|
+
} catch (e) {
|
|
43
|
+
next(e)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@motiadev/workbench",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.tsx",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@radix-ui/react-collapsible": "^1.1.2",
|
|
7
|
+
"@radix-ui/react-dialog": "^1.1.4",
|
|
8
|
+
"@radix-ui/react-label": "^2.1.1",
|
|
9
|
+
"@radix-ui/react-select": "^2.1.4",
|
|
10
|
+
"@radix-ui/react-separator": "^1.1.1",
|
|
11
|
+
"@radix-ui/react-slot": "^1.1.1",
|
|
12
|
+
"@radix-ui/react-switch": "^1.1.2",
|
|
13
|
+
"@radix-ui/react-tooltip": "^1.1.6",
|
|
14
|
+
"@tanstack/react-router": "^1.95.0",
|
|
15
|
+
"@tanstack/router-plugin": "^1.95.0",
|
|
16
|
+
"@tanstack/zod-adapter": "^1.95.0",
|
|
17
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
18
|
+
"@xyflow/react": "^12.3.6",
|
|
19
|
+
"autoprefixer": "^10.4.20",
|
|
20
|
+
"class-variance-authority": "^0.7.1",
|
|
21
|
+
"clsx": "^2.1.1",
|
|
22
|
+
"dagre": "^0.8.5",
|
|
23
|
+
"framer-motion": "^11.15.0",
|
|
24
|
+
"json-schema": "^0.4.0",
|
|
25
|
+
"lucide-react": "^0.469.0",
|
|
26
|
+
"postcss": "^8.4.49",
|
|
27
|
+
"react": "^18.3.1",
|
|
28
|
+
"react-dom": "^18.3.1",
|
|
29
|
+
"socket.io-client": "^4.8.1",
|
|
30
|
+
"tailwind-merge": "^2.6.0",
|
|
31
|
+
"tailwindcss": "^3.4.17",
|
|
32
|
+
"tailwindcss-animate": "^1.0.7",
|
|
33
|
+
"typescript": "~5.6.2",
|
|
34
|
+
"typescript-eslint": "^8.18.2",
|
|
35
|
+
"vite": "^6.0.5",
|
|
36
|
+
"zod": "^3.24.1",
|
|
37
|
+
"zustand": "^5.0.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^9.17.0",
|
|
41
|
+
"@tanstack/router-devtools": "^1.95.0",
|
|
42
|
+
"@types/dagre": "^0.7.52",
|
|
43
|
+
"@types/express": "^5.0.0",
|
|
44
|
+
"@types/json-schema": "^7.0.15",
|
|
45
|
+
"@types/node": "^22.10.2",
|
|
46
|
+
"@types/react": "^18.3.18",
|
|
47
|
+
"@types/react-dom": "^18.3.5",
|
|
48
|
+
"eslint": "^9.17.0",
|
|
49
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
50
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
51
|
+
"globals": "^15.14.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"lint": "eslint ."
|
|
55
|
+
}
|
|
56
|
+
}
|
package/public/.empty
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useListFlows } from '@/hooks/use-list-flows'
|
|
2
|
+
import {
|
|
3
|
+
Sidebar,
|
|
4
|
+
SidebarContent,
|
|
5
|
+
SidebarFooter,
|
|
6
|
+
SidebarGroup,
|
|
7
|
+
SidebarGroupContent,
|
|
8
|
+
SidebarGroupLabel,
|
|
9
|
+
SidebarHeader,
|
|
10
|
+
SidebarMenu,
|
|
11
|
+
SidebarMenuButton,
|
|
12
|
+
SidebarMenuItem,
|
|
13
|
+
} from './ui/sidebar'
|
|
14
|
+
import { Workflow } from 'lucide-react'
|
|
15
|
+
import { Link, useMatchRoute } from '@tanstack/react-router'
|
|
16
|
+
|
|
17
|
+
export const AppSidebar = () => {
|
|
18
|
+
const { flows } = useListFlows()
|
|
19
|
+
const matchRoute = useMatchRoute()
|
|
20
|
+
|
|
21
|
+
const isActive = (flowId: string) => {
|
|
22
|
+
return !!matchRoute({ to: '/flow/$id', params: { id: flowId } })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Sidebar>
|
|
27
|
+
<SidebarHeader />
|
|
28
|
+
<SidebarContent>
|
|
29
|
+
<SidebarGroup>
|
|
30
|
+
<SidebarGroupLabel>Flows</SidebarGroupLabel>
|
|
31
|
+
<SidebarGroupContent>
|
|
32
|
+
<SidebarMenu>
|
|
33
|
+
{flows.map((flow) => (
|
|
34
|
+
<SidebarMenuItem key={flow.id}>
|
|
35
|
+
<SidebarMenuButton asChild className="cursor-pointer" isActive={isActive(flow.id)}>
|
|
36
|
+
<Link
|
|
37
|
+
to="/flow/$id"
|
|
38
|
+
params={{ id: flow.id }}
|
|
39
|
+
className="flex items-center gap-2"
|
|
40
|
+
data-testid={`flow-link-${flow.id}`}
|
|
41
|
+
>
|
|
42
|
+
<Workflow />
|
|
43
|
+
<span>{flow.name}</span>
|
|
44
|
+
</Link>
|
|
45
|
+
</SidebarMenuButton>
|
|
46
|
+
</SidebarMenuItem>
|
|
47
|
+
))}
|
|
48
|
+
</SidebarMenu>
|
|
49
|
+
</SidebarGroupContent>
|
|
50
|
+
</SidebarGroup>
|
|
51
|
+
</SidebarContent>
|
|
52
|
+
<SidebarFooter />
|
|
53
|
+
</Sidebar>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible'
|
|
2
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
3
|
+
import { useLogs } from '@/stores/use-logs'
|
|
4
|
+
import { motion } from 'framer-motion'
|
|
5
|
+
import { ChevronDown, ChevronUp, Trash2 } from 'lucide-react'
|
|
6
|
+
import { useState } from 'react'
|
|
7
|
+
import { LogLevelBadge } from './log-level-badge'
|
|
8
|
+
import { Button } from './ui/button'
|
|
9
|
+
|
|
10
|
+
const timestamp = (time: number) => {
|
|
11
|
+
const date = new Date(Number(time))
|
|
12
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const LogConsole = () => {
|
|
16
|
+
const [isExpanded, setIsExpanded] = useState(false)
|
|
17
|
+
const logs = useLogs((state) => state.logs)
|
|
18
|
+
const resetLogs = useLogs((state) => state.resetLogs)
|
|
19
|
+
const toggleExpand = () => setIsExpanded((prev) => !prev)
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="absolute bottom-0 left-0 right-0 w-full bg-black h-fit z-40">
|
|
23
|
+
<div className="flex justify-between w-full items-center p-2">
|
|
24
|
+
<label className="text-green-500 w-full text-left justify-start h-full text-lg font-bold">Logs</label>
|
|
25
|
+
{logs.length > 0 && (
|
|
26
|
+
<Button variant="link" onClick={resetLogs} className="text-green-500">
|
|
27
|
+
<Trash2 className="w-4 h-4 text-green-500" />
|
|
28
|
+
Clear logs
|
|
29
|
+
</Button>
|
|
30
|
+
)}
|
|
31
|
+
<Button variant="link" onClick={toggleExpand} className="text-green-500">
|
|
32
|
+
{isExpanded && <ChevronDown className="w-4 h-4 text-green-500" />}
|
|
33
|
+
{!isExpanded && <ChevronUp className="w-4 h-4 text-green-500" />}
|
|
34
|
+
</Button>
|
|
35
|
+
</div>
|
|
36
|
+
{isExpanded && <div className="divide-solid divide-green-500 divide-y" />}
|
|
37
|
+
<Collapsible open={isExpanded} className={`w-full`}>
|
|
38
|
+
<CollapsibleContent>
|
|
39
|
+
<motion.div
|
|
40
|
+
className="overflow-y-auto h-[25vh] flex flex-col gap-2 py-2"
|
|
41
|
+
initial={{ height: 0 }}
|
|
42
|
+
animate={{ height: '25vh' }}
|
|
43
|
+
transition={{ duration: 0.3 }}
|
|
44
|
+
>
|
|
45
|
+
<Table>
|
|
46
|
+
<TableHeader className="sticky top-0 bg-black">
|
|
47
|
+
<TableRow>
|
|
48
|
+
<TableHead>Time</TableHead>
|
|
49
|
+
<TableHead>Level</TableHead>
|
|
50
|
+
<TableHead>Trace</TableHead>
|
|
51
|
+
<TableHead>Flow</TableHead>
|
|
52
|
+
<TableHead>Message</TableHead>
|
|
53
|
+
<TableHead>File</TableHead>
|
|
54
|
+
</TableRow>
|
|
55
|
+
</TableHeader>
|
|
56
|
+
<TableBody className="text-md font-mono font-bold">
|
|
57
|
+
{logs.map((log, index) => (
|
|
58
|
+
<TableRow key={index}>
|
|
59
|
+
<TableCell className="text-green-500">{timestamp(log.time)}</TableCell>
|
|
60
|
+
<TableCell>
|
|
61
|
+
<LogLevelBadge level={log.level} />
|
|
62
|
+
</TableCell>
|
|
63
|
+
<TableCell>{log.traceId.split('-').pop()}</TableCell>
|
|
64
|
+
<TableCell>{log.flows?.join?.(', ')}</TableCell>
|
|
65
|
+
<TableCell>{log.msg}</TableCell>
|
|
66
|
+
<TableCell>{log.file}</TableCell>
|
|
67
|
+
</TableRow>
|
|
68
|
+
))}
|
|
69
|
+
</TableBody>
|
|
70
|
+
</Table>
|
|
71
|
+
</motion.div>
|
|
72
|
+
</CollapsibleContent>
|
|
73
|
+
</Collapsible>
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Badge, BadgeProps } from './ui/badge'
|
|
2
|
+
|
|
3
|
+
export const LogLevelBadge: React.FC<{ level: string }> = (props) => {
|
|
4
|
+
const map: Record<string, BadgeProps['variant']> = {
|
|
5
|
+
info: 'info',
|
|
6
|
+
error: 'error',
|
|
7
|
+
warn: 'warning',
|
|
8
|
+
debug: 'info',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return <Badge variant={map[props.level] as BadgeProps['variant']}>{props.level}</Badge>
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
|
+
import { cn } from '@/lib/utils'
|
|
4
|
+
|
|
5
|
+
const badgeVariants = cva(
|
|
6
|
+
'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
|
|
11
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
12
|
+
info: 'border-transparent bg-sky-500 text-black hover:bg-sky/80',
|
|
13
|
+
error: 'border-transparent bg-rose-500 text-black shadow hover:bg-rose/80',
|
|
14
|
+
warning: 'border-transparent bg-amber-300 text-amber-950 hover:bg-amber/80',
|
|
15
|
+
destructive: 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
|
|
16
|
+
outline: 'text-foreground',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
variant: 'default',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
|
26
|
+
|
|
27
|
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
28
|
+
return <div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Badge, badgeVariants }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
+
import { cn } from '@/lib/utils'
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
|
12
|
+
destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
|
|
13
|
+
outline: 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
|
|
14
|
+
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
|
|
15
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
16
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
17
|
+
none: '',
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
default: 'h-9 px-4 py-2',
|
|
21
|
+
sm: 'h-8 rounded-md px-3 text-xs',
|
|
22
|
+
lg: 'h-10 rounded-md px-8',
|
|
23
|
+
icon: 'h-9 w-9',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: 'default',
|
|
28
|
+
size: 'default',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export interface ButtonProps
|
|
34
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
35
|
+
VariantProps<typeof buttonVariants> {
|
|
36
|
+
asChild?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
40
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
41
|
+
const Comp = asChild ? Slot : 'button'
|
|
42
|
+
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
Button.displayName = 'Button'
|
|
46
|
+
|
|
47
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
3
|
+
import { X } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root
|
|
8
|
+
|
|
9
|
+
const DialogTrigger = DialogPrimitive.Trigger
|
|
10
|
+
|
|
11
|
+
const DialogPortal = DialogPrimitive.Portal
|
|
12
|
+
|
|
13
|
+
const DialogClose = DialogPrimitive.Close
|
|
14
|
+
|
|
15
|
+
const DialogOverlay = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
18
|
+
>(({ className, ...props }, ref) => (
|
|
19
|
+
<DialogPrimitive.Overlay
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cn(
|
|
22
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
))
|
|
28
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
|
29
|
+
|
|
30
|
+
const DialogContent = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
33
|
+
>(({ className, children, ...props }, ref) => (
|
|
34
|
+
<DialogPortal>
|
|
35
|
+
<DialogOverlay />
|
|
36
|
+
<DialogPrimitive.Content
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
46
|
+
<X className="h-4 w-4" />
|
|
47
|
+
<span className="sr-only">Close</span>
|
|
48
|
+
</DialogPrimitive.Close>
|
|
49
|
+
</DialogPrimitive.Content>
|
|
50
|
+
</DialogPortal>
|
|
51
|
+
))
|
|
52
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
53
|
+
|
|
54
|
+
const DialogHeader = ({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
58
|
+
<div
|
|
59
|
+
className={cn(
|
|
60
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
)
|
|
66
|
+
DialogHeader.displayName = "DialogHeader"
|
|
67
|
+
|
|
68
|
+
const DialogFooter = ({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
72
|
+
<div
|
|
73
|
+
className={cn(
|
|
74
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
DialogFooter.displayName = "DialogFooter"
|
|
81
|
+
|
|
82
|
+
const DialogTitle = React.forwardRef<
|
|
83
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
84
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
85
|
+
>(({ className, ...props }, ref) => (
|
|
86
|
+
<DialogPrimitive.Title
|
|
87
|
+
ref={ref}
|
|
88
|
+
className={cn(
|
|
89
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
90
|
+
className
|
|
91
|
+
)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
))
|
|
95
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
|
96
|
+
|
|
97
|
+
const DialogDescription = React.forwardRef<
|
|
98
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
99
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
100
|
+
>(({ className, ...props }, ref) => (
|
|
101
|
+
<DialogPrimitive.Description
|
|
102
|
+
ref={ref}
|
|
103
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
104
|
+
{...props}
|
|
105
|
+
/>
|
|
106
|
+
))
|
|
107
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
Dialog,
|
|
111
|
+
DialogPortal,
|
|
112
|
+
DialogOverlay,
|
|
113
|
+
DialogTrigger,
|
|
114
|
+
DialogClose,
|
|
115
|
+
DialogContent,
|
|
116
|
+
DialogHeader,
|
|
117
|
+
DialogFooter,
|
|
118
|
+
DialogTitle,
|
|
119
|
+
DialogDescription,
|
|
120
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from '@/lib/utils'
|
|
3
|
+
|
|
4
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
|
5
|
+
({ className, type, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<input
|
|
8
|
+
type={type}
|
|
9
|
+
className={cn(
|
|
10
|
+
'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
ref={ref}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
},
|
|
18
|
+
)
|
|
19
|
+
Input.displayName = 'Input'
|
|
20
|
+
|
|
21
|
+
export { Input }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label"
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
const labelVariants = cva(
|
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
const Label = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
16
|
+
VariantProps<typeof labelVariants>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<LabelPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(labelVariants(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
))
|
|
24
|
+
Label.displayName = LabelPrimitive.Root.displayName
|
|
25
|
+
|
|
26
|
+
export { Label }
|