create-lego-one 2.0.12 → 2.0.13
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/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
- package/template/.cursor/rules/rules.mdc +639 -0
- package/template/.dockerignore +58 -0
- package/template/.env.example +18 -0
- package/template/.eslintignore +5 -0
- package/template/.eslintrc.js +28 -0
- package/template/.prettierignore +6 -0
- package/template/.prettierrc +11 -0
- package/template/CLAUDE.md +634 -0
- package/template/Dockerfile +67 -0
- package/template/PROMPT.md +457 -0
- package/template/README.md +325 -0
- package/template/docker-compose.yml +48 -0
- package/template/docker-entrypoint.sh +23 -0
- package/template/docs/checkpoints/.template.md +64 -0
- package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
- package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
- package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
- package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
- package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
- package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
- package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
- package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
- package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
- package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
- package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
- package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
- package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
- package/template/docs/framework/plans/00-index.md +164 -0
- package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
- package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
- package/template/docs/framework/plans/03-host-kernel.md +1518 -0
- package/template/docs/framework/plans/04-auth-system.md +1466 -0
- package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
- package/template/docs/framework/plans/06-ui-components.md +1478 -0
- package/template/docs/framework/plans/07-communication-system.md +1106 -0
- package/template/docs/framework/plans/08-plugin-system.md +1179 -0
- package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
- package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
- package/template/docs/framework/plans/11-testing.md +935 -0
- package/template/docs/framework/plans/12-deployment.md +896 -0
- package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
- package/template/docs/framework/research/00-modernjs-audit.md +488 -0
- package/template/docs/framework/research/01-system-blueprint.md +721 -0
- package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
- package/template/docs/framework/research/03-host-setup.md +714 -0
- package/template/docs/framework/research/04-plugin-architecture.md +645 -0
- package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
- package/template/docs/framework/research/06-cli-strategy.md +615 -0
- package/template/docs/framework/research/07-deployment.md +629 -0
- package/template/docs/framework/research/README.md +282 -0
- package/template/docs/framework/setup/00-index.md +210 -0
- package/template/docs/framework/setup/01-framework-structure.md +308 -0
- package/template/docs/framework/setup/02-development-workflow.md +405 -0
- package/template/docs/framework/setup/03-environment-setup.md +215 -0
- package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
- package/template/docs/framework/setup/05-plugin-system.md +620 -0
- package/template/docs/framework/setup/06-communication-patterns.md +451 -0
- package/template/docs/framework/setup/07-plugin-development.md +582 -0
- package/template/docs/framework/setup/08-component-library.md +658 -0
- package/template/docs/framework/setup/09-data-integration.md +609 -0
- package/template/docs/framework/setup/10-auth-rbac.md +497 -0
- package/template/docs/framework/setup/11-hooks-api.md +393 -0
- package/template/docs/framework/setup/12-components-api.md +665 -0
- package/template/docs/framework/setup/13-deployment-guide.md +566 -0
- package/template/docs/framework/setup/README.md +548 -0
- package/template/host/package.json +1 -1
- package/template/nginx.conf +72 -0
- package/template/package.json +1 -1
- package/template/packages/plugins/@lego/plugin-dashboard/package.json +1 -1
- package/template/packages/plugins/@lego/plugin-todo/package.json +1 -1
- package/template/pocketbase/CHANGELOG.md +911 -0
- package/template/pocketbase/LICENSE.md +17 -0
- package/template/scripts/create-plugin.js +221 -0
- package/template/scripts/deploy.sh +56 -0
- package/template/tsconfig.base.json +26 -0
|
@@ -0,0 +1,1478 @@
|
|
|
1
|
+
# UI Components Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For AI Implementing This Plan:** This is document 06 of 13. Complete documents 01-05 first.
|
|
4
|
+
|
|
5
|
+
**Goal:** Create complete Shadcn UI component library with all essential and common components needed for the SaaS application.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Use Radix UI primitives as the foundation, styled with Tailwind CSS. Components follow Shadcn patterns but are adapted for Modern.js (not Next.js).
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Radix UI primitives, Tailwind CSS, class-variance-authority, tailwind-merge, lucide-react icons
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- ✅ Completed `01-infrastructure-setup.md`
|
|
16
|
+
- ✅ Completed `02-pocketbase-setup.md`
|
|
17
|
+
- ✅ Completed `03-host-kernel.md` (Tailwind configured)
|
|
18
|
+
- ✅ Completed `04-auth-system.md` (Button, Input, Label, Card, Alert, DropdownMenu already created)
|
|
19
|
+
- ✅ Completed `05-multitenancy-rbac.md`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Already Created Components
|
|
24
|
+
|
|
25
|
+
These components were created in previous documents:
|
|
26
|
+
- ✅ Button (`host/src/kernel/components/ui/button.tsx`)
|
|
27
|
+
- ✅ Input (`host/src/kernel/components/ui/input.tsx`)
|
|
28
|
+
- ✅ Label (`host/src/kernel/components/ui/label.tsx`)
|
|
29
|
+
- ✅ Card (`host/src/kernel/components/ui/card.tsx`)
|
|
30
|
+
- ✅ Alert (`host/src/kernel/components/ui/alert.tsx`)
|
|
31
|
+
- ✅ DropdownMenu (`host/src/kernel/components/ui/dropdown-menu.tsx`)
|
|
32
|
+
- ✅ Skeleton (`host/src/kernel/components/ui/skeleton.tsx`)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Task 1: Add Missing Radix Dependencies
|
|
37
|
+
|
|
38
|
+
**Files:**
|
|
39
|
+
- Modify: `host/package.json`
|
|
40
|
+
|
|
41
|
+
### Step 1: Add Radix UI packages
|
|
42
|
+
|
|
43
|
+
**File:** `host/package.json`
|
|
44
|
+
|
|
45
|
+
Add these dependencies if not already present:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@radix-ui/react-avatar": "^1.1.1",
|
|
51
|
+
"@radix-ui/react-dialog": "^1.1.2",
|
|
52
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
53
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
54
|
+
"@radix-ui/react-progress": "^1.1.0",
|
|
55
|
+
"@radix-ui/react-scroll-area": "^1.2.0",
|
|
56
|
+
"@radix-ui/react-select": "^2.1.2",
|
|
57
|
+
"@radix-ui/react-separator": "^1.1.0",
|
|
58
|
+
"@radix-ui/react-switch": "^1.1.1",
|
|
59
|
+
"@radix-ui/react-tabs": "^1.1.1",
|
|
60
|
+
"@radix-ui/react-toast": "^1.2.2",
|
|
61
|
+
"@radix-ui/react-tooltip": "^1.1.3"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 2: Install dependencies
|
|
67
|
+
|
|
68
|
+
**Run:** From root directory
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Task 2: Create Avatar Component
|
|
77
|
+
|
|
78
|
+
**Files:**
|
|
79
|
+
- Create: `host/src/kernel/components/ui/avatar.tsx`
|
|
80
|
+
|
|
81
|
+
### Step 1: Create avatar components
|
|
82
|
+
|
|
83
|
+
**File:** `host/src/kernel/components/ui/avatar.tsx`
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import * as React from 'react';
|
|
87
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
88
|
+
import { cn } from '../../../lib/utils';
|
|
89
|
+
|
|
90
|
+
const Avatar = React.forwardRef<
|
|
91
|
+
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
92
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
93
|
+
>(({ className, ...props }, ref) => (
|
|
94
|
+
<AvatarPrimitive.Root
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(
|
|
97
|
+
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
|
|
98
|
+
className
|
|
99
|
+
)}
|
|
100
|
+
{...props}
|
|
101
|
+
/>
|
|
102
|
+
));
|
|
103
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
104
|
+
|
|
105
|
+
const AvatarImage = React.forwardRef<
|
|
106
|
+
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
107
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
108
|
+
>(({ className, ...props }, ref) => (
|
|
109
|
+
<AvatarPrimitive.Image
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn('aspect-square h-full w-full', className)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
));
|
|
115
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
116
|
+
|
|
117
|
+
const AvatarFallback = React.forwardRef<
|
|
118
|
+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
119
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
120
|
+
>(({ className, ...props }, ref) => (
|
|
121
|
+
<AvatarPrimitive.Fallback
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={cn(
|
|
124
|
+
'flex h-full w-full items-center justify-center rounded-full bg-muted',
|
|
125
|
+
className
|
|
126
|
+
)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
));
|
|
130
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
131
|
+
|
|
132
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Task 3: Create Dialog Component
|
|
138
|
+
|
|
139
|
+
**Files:**
|
|
140
|
+
- Create: `host/src/kernel/components/ui/dialog.tsx`
|
|
141
|
+
|
|
142
|
+
### Step 1: Create dialog components
|
|
143
|
+
|
|
144
|
+
**File:** `host/src/kernel/components/ui/dialog.tsx`
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import * as React from 'react';
|
|
148
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
149
|
+
import { X } from 'lucide-react';
|
|
150
|
+
import { cn } from '../../../lib/utils';
|
|
151
|
+
|
|
152
|
+
const Dialog = DialogPrimitive.Root;
|
|
153
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
154
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
155
|
+
const DialogClose = DialogPrimitive.Close;
|
|
156
|
+
|
|
157
|
+
const DialogOverlay = React.forwardRef<
|
|
158
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
159
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
160
|
+
>(({ className, ...props }, ref) => (
|
|
161
|
+
<DialogPrimitive.Overlay
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn(
|
|
164
|
+
'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
));
|
|
170
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
171
|
+
|
|
172
|
+
const DialogContent = React.forwardRef<
|
|
173
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
174
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
175
|
+
>(({ className, children, ...props }, ref) => (
|
|
176
|
+
<DialogPortal>
|
|
177
|
+
<DialogOverlay />
|
|
178
|
+
<DialogPrimitive.Content
|
|
179
|
+
ref={ref}
|
|
180
|
+
className={cn(
|
|
181
|
+
'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',
|
|
182
|
+
className
|
|
183
|
+
)}
|
|
184
|
+
{...props}
|
|
185
|
+
>
|
|
186
|
+
{children}
|
|
187
|
+
<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">
|
|
188
|
+
<X className="h-4 w-4" />
|
|
189
|
+
<span className="sr-only">Close</span>
|
|
190
|
+
</DialogPrimitive.Close>
|
|
191
|
+
</DialogPrimitive.Content>
|
|
192
|
+
</DialogPortal>
|
|
193
|
+
));
|
|
194
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
195
|
+
|
|
196
|
+
const DialogHeader = ({
|
|
197
|
+
className,
|
|
198
|
+
...props
|
|
199
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
200
|
+
<div
|
|
201
|
+
className={cn(
|
|
202
|
+
'flex flex-col space-y-1.5 text-center sm:text-left',
|
|
203
|
+
className
|
|
204
|
+
)}
|
|
205
|
+
{...props}
|
|
206
|
+
/>
|
|
207
|
+
);
|
|
208
|
+
DialogHeader.displayName = 'DialogHeader';
|
|
209
|
+
|
|
210
|
+
const DialogFooter = ({
|
|
211
|
+
className,
|
|
212
|
+
...props
|
|
213
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
214
|
+
<div
|
|
215
|
+
className={cn(
|
|
216
|
+
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
|
217
|
+
className
|
|
218
|
+
)}
|
|
219
|
+
{...props}
|
|
220
|
+
/>
|
|
221
|
+
);
|
|
222
|
+
DialogFooter.displayName = 'DialogFooter';
|
|
223
|
+
|
|
224
|
+
const DialogTitle = React.forwardRef<
|
|
225
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
226
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
227
|
+
>(({ className, ...props }, ref) => (
|
|
228
|
+
<DialogPrimitive.Title
|
|
229
|
+
ref={ref}
|
|
230
|
+
className={cn(
|
|
231
|
+
'text-lg font-semibold leading-none tracking-tight',
|
|
232
|
+
className
|
|
233
|
+
)}
|
|
234
|
+
{...props}
|
|
235
|
+
/>
|
|
236
|
+
));
|
|
237
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
238
|
+
|
|
239
|
+
const DialogDescription = React.forwardRef<
|
|
240
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
241
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
242
|
+
>(({ className, ...props }, ref) => (
|
|
243
|
+
<DialogPrimitive.Description
|
|
244
|
+
ref={ref}
|
|
245
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
246
|
+
{...props}
|
|
247
|
+
/>
|
|
248
|
+
));
|
|
249
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
250
|
+
|
|
251
|
+
export {
|
|
252
|
+
Dialog,
|
|
253
|
+
DialogPortal,
|
|
254
|
+
DialogOverlay,
|
|
255
|
+
DialogClose,
|
|
256
|
+
DialogTrigger,
|
|
257
|
+
DialogContent,
|
|
258
|
+
DialogHeader,
|
|
259
|
+
DialogFooter,
|
|
260
|
+
DialogTitle,
|
|
261
|
+
DialogDescription,
|
|
262
|
+
};
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Task 4: Create Select Component
|
|
268
|
+
|
|
269
|
+
**Files:**
|
|
270
|
+
- Create: `host/src/kernel/components/ui/select.tsx`
|
|
271
|
+
|
|
272
|
+
### Step 1: Create select components
|
|
273
|
+
|
|
274
|
+
**File:** `host/src/kernel/components/ui/select.tsx`
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import * as React from 'react';
|
|
278
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
279
|
+
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
|
280
|
+
import { cn } from '../../../lib/utils';
|
|
281
|
+
|
|
282
|
+
const Select = SelectPrimitive.Root;
|
|
283
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
284
|
+
const SelectValue = SelectPrimitive.Value;
|
|
285
|
+
|
|
286
|
+
const SelectTrigger = React.forwardRef<
|
|
287
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
288
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
289
|
+
>(({ className, children, ...props }, ref) => (
|
|
290
|
+
<SelectPrimitive.Trigger
|
|
291
|
+
ref={ref}
|
|
292
|
+
className={cn(
|
|
293
|
+
'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',
|
|
294
|
+
className
|
|
295
|
+
)}
|
|
296
|
+
{...props}
|
|
297
|
+
>
|
|
298
|
+
{children}
|
|
299
|
+
<SelectPrimitive.Icon asChild>
|
|
300
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
301
|
+
</SelectPrimitive.Icon>
|
|
302
|
+
</SelectPrimitive.Trigger>
|
|
303
|
+
));
|
|
304
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
305
|
+
|
|
306
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
307
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
308
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
309
|
+
>(({ className, ...props }, ref) => (
|
|
310
|
+
<SelectPrimitive.ScrollUpButton
|
|
311
|
+
ref={ref}
|
|
312
|
+
className={cn(
|
|
313
|
+
'flex cursor-default items-center justify-center py-1',
|
|
314
|
+
className
|
|
315
|
+
)}
|
|
316
|
+
{...props}
|
|
317
|
+
>
|
|
318
|
+
<ChevronUp className="h-4 w-4" />
|
|
319
|
+
</SelectPrimitive.ScrollUpButton>
|
|
320
|
+
));
|
|
321
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
322
|
+
|
|
323
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
324
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
325
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
326
|
+
>(({ className, ...props }, ref) => (
|
|
327
|
+
<SelectPrimitive.ScrollDownButton
|
|
328
|
+
ref={ref}
|
|
329
|
+
className={cn(
|
|
330
|
+
'flex cursor-default items-center justify-center py-1',
|
|
331
|
+
className
|
|
332
|
+
)}
|
|
333
|
+
{...props}
|
|
334
|
+
>
|
|
335
|
+
<ChevronDown className="h-4 w-4" />
|
|
336
|
+
</SelectPrimitive.ScrollDownButton>
|
|
337
|
+
));
|
|
338
|
+
SelectScrollDownButton.displayName =
|
|
339
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
340
|
+
|
|
341
|
+
const SelectContent = React.forwardRef<
|
|
342
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
343
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
344
|
+
>(({ className, children, position = 'popper', ...props }, ref) => (
|
|
345
|
+
<SelectPrimitive.Portal>
|
|
346
|
+
<SelectPrimitive.Content
|
|
347
|
+
ref={ref}
|
|
348
|
+
className={cn(
|
|
349
|
+
'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',
|
|
350
|
+
position === 'popper' &&
|
|
351
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
352
|
+
className
|
|
353
|
+
)}
|
|
354
|
+
position={position}
|
|
355
|
+
{...props}
|
|
356
|
+
>
|
|
357
|
+
<SelectScrollUpButton />
|
|
358
|
+
<SelectPrimitive.Viewport
|
|
359
|
+
className={cn(
|
|
360
|
+
'p-1',
|
|
361
|
+
position === 'popper' &&
|
|
362
|
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'
|
|
363
|
+
)}
|
|
364
|
+
>
|
|
365
|
+
{children}
|
|
366
|
+
</SelectPrimitive.Viewport>
|
|
367
|
+
<SelectScrollDownButton />
|
|
368
|
+
</SelectPrimitive.Content>
|
|
369
|
+
</SelectPrimitive.Portal>
|
|
370
|
+
));
|
|
371
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
372
|
+
|
|
373
|
+
const SelectLabel = React.forwardRef<
|
|
374
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
375
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
376
|
+
>(({ className, ...props }, ref) => (
|
|
377
|
+
<SelectPrimitive.Label
|
|
378
|
+
ref={ref}
|
|
379
|
+
className={cn('py-1.5 pl-8 pr-2 text-sm font-semibold', className)}
|
|
380
|
+
{...props}
|
|
381
|
+
/>
|
|
382
|
+
));
|
|
383
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
384
|
+
|
|
385
|
+
const SelectItem = React.forwardRef<
|
|
386
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
387
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
388
|
+
>(({ className, children, ...props }, ref) => (
|
|
389
|
+
<SelectPrimitive.Item
|
|
390
|
+
ref={ref}
|
|
391
|
+
className={cn(
|
|
392
|
+
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
393
|
+
className
|
|
394
|
+
)}
|
|
395
|
+
{...props}
|
|
396
|
+
>
|
|
397
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
398
|
+
<SelectPrimitive.ItemIndicator>
|
|
399
|
+
<Check className="h-4 w-4" />
|
|
400
|
+
</SelectPrimitive.ItemIndicator>
|
|
401
|
+
</span>
|
|
402
|
+
|
|
403
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
404
|
+
</SelectPrimitive.Item>
|
|
405
|
+
));
|
|
406
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
407
|
+
|
|
408
|
+
const SelectSeparator = React.forwardRef<
|
|
409
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
410
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
411
|
+
>(({ className, ...props }, ref) => (
|
|
412
|
+
<SelectPrimitive.Separator
|
|
413
|
+
ref={ref}
|
|
414
|
+
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
|
415
|
+
{...props}
|
|
416
|
+
/>
|
|
417
|
+
));
|
|
418
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
419
|
+
|
|
420
|
+
export {
|
|
421
|
+
Select,
|
|
422
|
+
SelectGroup,
|
|
423
|
+
SelectValue,
|
|
424
|
+
SelectTrigger,
|
|
425
|
+
SelectContent,
|
|
426
|
+
SelectLabel,
|
|
427
|
+
SelectItem,
|
|
428
|
+
SelectSeparator,
|
|
429
|
+
SelectScrollUpButton,
|
|
430
|
+
SelectScrollDownButton,
|
|
431
|
+
};
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Task 5: Create Switch Component
|
|
437
|
+
|
|
438
|
+
**Files:**
|
|
439
|
+
- Create: `host/src/kernel/components/ui/switch.tsx`
|
|
440
|
+
|
|
441
|
+
### Step 1: Create switch component
|
|
442
|
+
|
|
443
|
+
**File:** `host/src/kernel/components/ui/switch.tsx`
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
import * as React from 'react';
|
|
447
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
448
|
+
import { cn } from '../../../lib/utils';
|
|
449
|
+
|
|
450
|
+
const Switch = React.forwardRef<
|
|
451
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
452
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
453
|
+
>(({ className, ...props }, ref) => (
|
|
454
|
+
<SwitchPrimitives.Root
|
|
455
|
+
className={cn(
|
|
456
|
+
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors 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 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
|
457
|
+
className
|
|
458
|
+
)}
|
|
459
|
+
{...props}
|
|
460
|
+
ref={ref}
|
|
461
|
+
>
|
|
462
|
+
<SwitchPrimitives.Thumb
|
|
463
|
+
className={cn(
|
|
464
|
+
'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'
|
|
465
|
+
)}
|
|
466
|
+
/>
|
|
467
|
+
</SwitchPrimitives.Root>
|
|
468
|
+
));
|
|
469
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
470
|
+
|
|
471
|
+
export { Switch };
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Task 6: Create Tabs Component
|
|
477
|
+
|
|
478
|
+
**Files:**
|
|
479
|
+
- Create: `host/src/kernel/components/ui/tabs.tsx`
|
|
480
|
+
|
|
481
|
+
### Step 1: Create tabs components
|
|
482
|
+
|
|
483
|
+
**File:** `host/src/kernel/components/ui/tabs.tsx`
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import * as React from 'react';
|
|
487
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
488
|
+
import { cn } from '../../../lib/utils';
|
|
489
|
+
|
|
490
|
+
const Tabs = TabsPrimitive.Root;
|
|
491
|
+
|
|
492
|
+
const TabsList = React.forwardRef<
|
|
493
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
494
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
495
|
+
>(({ className, ...props }, ref) => (
|
|
496
|
+
<TabsPrimitive.List
|
|
497
|
+
ref={ref}
|
|
498
|
+
className={cn(
|
|
499
|
+
'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
|
|
500
|
+
className
|
|
501
|
+
)}
|
|
502
|
+
{...props}
|
|
503
|
+
/>
|
|
504
|
+
));
|
|
505
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
506
|
+
|
|
507
|
+
const TabsTrigger = React.forwardRef<
|
|
508
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
509
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
510
|
+
>(({ className, ...props }, ref) => (
|
|
511
|
+
<TabsPrimitive.Trigger
|
|
512
|
+
ref={ref}
|
|
513
|
+
className={cn(
|
|
514
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all 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=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
515
|
+
className
|
|
516
|
+
)}
|
|
517
|
+
{...props}
|
|
518
|
+
/>
|
|
519
|
+
));
|
|
520
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
521
|
+
|
|
522
|
+
const TabsContent = React.forwardRef<
|
|
523
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
524
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
525
|
+
>(({ className, ...props }, ref) => (
|
|
526
|
+
<TabsPrimitive.Content
|
|
527
|
+
ref={ref}
|
|
528
|
+
className={cn(
|
|
529
|
+
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
530
|
+
className
|
|
531
|
+
)}
|
|
532
|
+
{...props}
|
|
533
|
+
/>
|
|
534
|
+
));
|
|
535
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
536
|
+
|
|
537
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## Task 7: Create Separator Component
|
|
543
|
+
|
|
544
|
+
**Files:**
|
|
545
|
+
- Create: `host/src/kernel/components/ui/separator.tsx`
|
|
546
|
+
|
|
547
|
+
### Step 1: Create separator component
|
|
548
|
+
|
|
549
|
+
**File:** `host/src/kernel/components/ui/separator.tsx`
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
import * as React from 'react';
|
|
553
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
554
|
+
import { cn } from '../../../lib/utils';
|
|
555
|
+
|
|
556
|
+
const Separator = React.forwardRef<
|
|
557
|
+
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
558
|
+
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
559
|
+
>(
|
|
560
|
+
(
|
|
561
|
+
{ className, orientation = 'horizontal', decorative = true, ...props },
|
|
562
|
+
ref
|
|
563
|
+
) => (
|
|
564
|
+
<SeparatorPrimitive.Root
|
|
565
|
+
ref={ref}
|
|
566
|
+
decorative={decorative}
|
|
567
|
+
orientation={orientation}
|
|
568
|
+
className={cn(
|
|
569
|
+
'shrink-0 bg-border',
|
|
570
|
+
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
|
|
571
|
+
className
|
|
572
|
+
)}
|
|
573
|
+
{...props}
|
|
574
|
+
/>
|
|
575
|
+
)
|
|
576
|
+
);
|
|
577
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
578
|
+
|
|
579
|
+
export { Separator };
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Task 8: Create Popover Component
|
|
585
|
+
|
|
586
|
+
**Files:**
|
|
587
|
+
- Create: `host/src/kernel/components/ui/popover.tsx`
|
|
588
|
+
|
|
589
|
+
### Step 1: Create popover components
|
|
590
|
+
|
|
591
|
+
**File:** `host/src/kernel/components/ui/popover.tsx`
|
|
592
|
+
|
|
593
|
+
```typescript
|
|
594
|
+
import * as React from 'react';
|
|
595
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
596
|
+
import { cn } from '../../../lib/utils';
|
|
597
|
+
|
|
598
|
+
const Popover = PopoverPrimitive.Root;
|
|
599
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
600
|
+
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
601
|
+
|
|
602
|
+
const PopoverContent = React.forwardRef<
|
|
603
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
604
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
605
|
+
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (
|
|
606
|
+
<PopoverPrimitive.Portal>
|
|
607
|
+
<PopoverPrimitive.Content
|
|
608
|
+
ref={ref}
|
|
609
|
+
align={align}
|
|
610
|
+
sideOffset={sideOffset}
|
|
611
|
+
className={cn(
|
|
612
|
+
'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',
|
|
613
|
+
className
|
|
614
|
+
)}
|
|
615
|
+
{...props}
|
|
616
|
+
/>
|
|
617
|
+
</PopoverPrimitive.Portal>
|
|
618
|
+
));
|
|
619
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
620
|
+
|
|
621
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## Task 9: Create ScrollArea Component
|
|
627
|
+
|
|
628
|
+
**Files:**
|
|
629
|
+
- Create: `host/src/kernel/components/ui/scroll-area.tsx`
|
|
630
|
+
|
|
631
|
+
### Step 1: Create scroll area component
|
|
632
|
+
|
|
633
|
+
**File:** `host/src/kernel/components/ui/scroll-area.tsx`
|
|
634
|
+
|
|
635
|
+
```typescript
|
|
636
|
+
import * as React from 'react';
|
|
637
|
+
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
638
|
+
import { cn } from '../../../lib/utils';
|
|
639
|
+
|
|
640
|
+
const ScrollArea = React.forwardRef<
|
|
641
|
+
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
642
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
643
|
+
>(({ className, children, ...props }, ref) => (
|
|
644
|
+
<ScrollAreaPrimitive.Root
|
|
645
|
+
ref={ref}
|
|
646
|
+
className={cn('relative overflow-hidden', className)}
|
|
647
|
+
{...props}
|
|
648
|
+
>
|
|
649
|
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
|
650
|
+
{children}
|
|
651
|
+
</ScrollAreaPrimitive.Viewport>
|
|
652
|
+
<ScrollBar />
|
|
653
|
+
<ScrollAreaPrimitive.Corner />
|
|
654
|
+
</ScrollAreaPrimitive.Root>
|
|
655
|
+
));
|
|
656
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
657
|
+
|
|
658
|
+
const ScrollBar = React.forwardRef<
|
|
659
|
+
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
660
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
661
|
+
>(({ className, orientation = 'vertical', ...props }, ref) => (
|
|
662
|
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
663
|
+
ref={ref}
|
|
664
|
+
orientation={orientation}
|
|
665
|
+
className={cn(
|
|
666
|
+
'flex touch-none select-none transition-colors',
|
|
667
|
+
orientation === 'vertical' &&
|
|
668
|
+
'h-full w-2.5 border-l border-l-transparent p-[1px]',
|
|
669
|
+
orientation === 'horizontal' &&
|
|
670
|
+
'h-2.5 flex-col border-t border-t-transparent p-[1px]',
|
|
671
|
+
className
|
|
672
|
+
)}
|
|
673
|
+
{...props}
|
|
674
|
+
>
|
|
675
|
+
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
676
|
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
677
|
+
));
|
|
678
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
679
|
+
|
|
680
|
+
export { ScrollArea, ScrollBar };
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
## Task 10: Create Progress Component
|
|
686
|
+
|
|
687
|
+
**Files:**
|
|
688
|
+
- Create: `host/src/kernel/components/ui/progress.tsx`
|
|
689
|
+
|
|
690
|
+
### Step 1: Create progress component
|
|
691
|
+
|
|
692
|
+
**File:** `host/src/kernel/components/ui/progress.tsx`
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
import * as React from 'react';
|
|
696
|
+
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
697
|
+
import { cn } from '../../../lib/utils';
|
|
698
|
+
|
|
699
|
+
const Progress = React.forwardRef<
|
|
700
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
701
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
|
702
|
+
>(({ className, value, ...props }, ref) => (
|
|
703
|
+
<ProgressPrimitive.Root
|
|
704
|
+
ref={ref}
|
|
705
|
+
className={cn(
|
|
706
|
+
'relative h-4 w-full overflow-hidden rounded-full bg-secondary',
|
|
707
|
+
className
|
|
708
|
+
)}
|
|
709
|
+
{...props}
|
|
710
|
+
>
|
|
711
|
+
<ProgressPrimitive.Indicator
|
|
712
|
+
className="h-full w-full flex-1 bg-primary transition-all"
|
|
713
|
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
714
|
+
/>
|
|
715
|
+
</ProgressPrimitive.Root>
|
|
716
|
+
));
|
|
717
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
718
|
+
|
|
719
|
+
export { Progress };
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
---
|
|
723
|
+
|
|
724
|
+
## Task 11: Create Tooltip Component
|
|
725
|
+
|
|
726
|
+
**Files:**
|
|
727
|
+
- Create: `host/src/kernel/components/ui/tooltip.tsx`
|
|
728
|
+
|
|
729
|
+
### Step 1: Create tooltip components
|
|
730
|
+
|
|
731
|
+
**File:** `host/src/kernel/components/ui/tooltip.tsx`
|
|
732
|
+
|
|
733
|
+
```typescript
|
|
734
|
+
import * as React from 'react';
|
|
735
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
736
|
+
import { cn } from '../../../lib/utils';
|
|
737
|
+
|
|
738
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
739
|
+
|
|
740
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
741
|
+
|
|
742
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
743
|
+
|
|
744
|
+
const TooltipContent = React.forwardRef<
|
|
745
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
746
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
747
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
748
|
+
<TooltipPrimitive.Content
|
|
749
|
+
ref={ref}
|
|
750
|
+
sideOffset={sideOffset}
|
|
751
|
+
className={cn(
|
|
752
|
+
'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',
|
|
753
|
+
className
|
|
754
|
+
)}
|
|
755
|
+
{...props}
|
|
756
|
+
/>
|
|
757
|
+
));
|
|
758
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
759
|
+
|
|
760
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
## Task 12: Create Toast Component
|
|
766
|
+
|
|
767
|
+
**Files:**
|
|
768
|
+
- Create: `host/src/kernel/components/ui/toast.tsx`
|
|
769
|
+
- Create: `host/src/kernel/components/ui/toaster.tsx`
|
|
770
|
+
- Create: `host/src/kernel/components/ui/use-toast.ts`
|
|
771
|
+
|
|
772
|
+
### Step 1: Create toast components
|
|
773
|
+
|
|
774
|
+
**File:** `host/src/kernel/components/ui/toast.tsx`
|
|
775
|
+
|
|
776
|
+
```typescript
|
|
777
|
+
import * as React from 'react';
|
|
778
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
779
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
780
|
+
import { X } from 'lucide-react';
|
|
781
|
+
import { cn } from '../../../lib/utils';
|
|
782
|
+
|
|
783
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
784
|
+
|
|
785
|
+
const ToastViewport = React.forwardRef<
|
|
786
|
+
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
|
787
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
|
|
788
|
+
>(({ className, ...props }, ref) => (
|
|
789
|
+
<ToastPrimitives.Viewport
|
|
790
|
+
ref={ref}
|
|
791
|
+
className={cn(
|
|
792
|
+
'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]',
|
|
793
|
+
className
|
|
794
|
+
)}
|
|
795
|
+
{...props}
|
|
796
|
+
/>
|
|
797
|
+
));
|
|
798
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
799
|
+
|
|
800
|
+
const toastVariants = cva(
|
|
801
|
+
'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',
|
|
802
|
+
{
|
|
803
|
+
variants: {
|
|
804
|
+
variant: {
|
|
805
|
+
default: 'border bg-background text-foreground',
|
|
806
|
+
destructive:
|
|
807
|
+
'destructive group border-destructive bg-destructive text-destructive-foreground',
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
defaultVariants: {
|
|
811
|
+
variant: 'default',
|
|
812
|
+
},
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
|
|
816
|
+
const Toast = React.forwardRef<
|
|
817
|
+
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
818
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
|
|
819
|
+
VariantProps<typeof toastVariants>
|
|
820
|
+
>(({ className, variant, ...props }, ref) => {
|
|
821
|
+
return (
|
|
822
|
+
<ToastPrimitives.Root
|
|
823
|
+
ref={ref}
|
|
824
|
+
className={cn(toastVariants({ variant }), className)}
|
|
825
|
+
{...props}
|
|
826
|
+
/>
|
|
827
|
+
);
|
|
828
|
+
});
|
|
829
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
830
|
+
|
|
831
|
+
const ToastAction = React.forwardRef<
|
|
832
|
+
React.ElementRef<typeof ToastPrimitives.Action>,
|
|
833
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
|
834
|
+
>(({ className, ...props }, ref) => (
|
|
835
|
+
<ToastPrimitives.Action
|
|
836
|
+
ref={ref}
|
|
837
|
+
className={cn(
|
|
838
|
+
'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 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive',
|
|
839
|
+
className
|
|
840
|
+
)}
|
|
841
|
+
{...props}
|
|
842
|
+
/>
|
|
843
|
+
));
|
|
844
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
845
|
+
|
|
846
|
+
const ToastClose = React.forwardRef<
|
|
847
|
+
React.ElementRef<typeof ToastPrimitives.Close>,
|
|
848
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
|
849
|
+
>(({ className, ...props }, ref) => (
|
|
850
|
+
<ToastPrimitives.Close
|
|
851
|
+
ref={ref}
|
|
852
|
+
className={cn(
|
|
853
|
+
'absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600',
|
|
854
|
+
className
|
|
855
|
+
)}
|
|
856
|
+
toast-close=""
|
|
857
|
+
{...props}
|
|
858
|
+
>
|
|
859
|
+
<X className="h-4 w-4" />
|
|
860
|
+
</ToastPrimitives.Close>
|
|
861
|
+
));
|
|
862
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
863
|
+
|
|
864
|
+
const ToastTitle = React.forwardRef<
|
|
865
|
+
React.ElementRef<typeof ToastPrimitives.Title>,
|
|
866
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
|
867
|
+
>(({ className, ...props }, ref) => (
|
|
868
|
+
<ToastPrimitives.Title
|
|
869
|
+
ref={ref}
|
|
870
|
+
className={cn('text-sm font-semibold', className)}
|
|
871
|
+
{...props}
|
|
872
|
+
/>
|
|
873
|
+
));
|
|
874
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
875
|
+
|
|
876
|
+
const ToastDescription = React.forwardRef<
|
|
877
|
+
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
878
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
879
|
+
>(({ className, ...props }, ref) => (
|
|
880
|
+
<ToastPrimitives.Description
|
|
881
|
+
ref={ref}
|
|
882
|
+
className={cn('text-sm opacity-90', className)}
|
|
883
|
+
{...props}
|
|
884
|
+
/>
|
|
885
|
+
));
|
|
886
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
887
|
+
|
|
888
|
+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
889
|
+
|
|
890
|
+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
891
|
+
|
|
892
|
+
export {
|
|
893
|
+
type ToastProps,
|
|
894
|
+
type ToastActionElement,
|
|
895
|
+
ToastProvider,
|
|
896
|
+
ToastViewport,
|
|
897
|
+
Toast,
|
|
898
|
+
ToastTitle,
|
|
899
|
+
ToastDescription,
|
|
900
|
+
ToastClose,
|
|
901
|
+
ToastAction,
|
|
902
|
+
};
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
### Step 2: Create toaster component
|
|
906
|
+
|
|
907
|
+
**File:** `host/src/kernel/components/ui/toaster.tsx`
|
|
908
|
+
|
|
909
|
+
```typescript
|
|
910
|
+
import {
|
|
911
|
+
Toast,
|
|
912
|
+
ToastClose,
|
|
913
|
+
ToastDescription,
|
|
914
|
+
ToastProvider,
|
|
915
|
+
ToastTitle,
|
|
916
|
+
ToastViewport,
|
|
917
|
+
} from './toast';
|
|
918
|
+
import { useToast } from './use-toast';
|
|
919
|
+
import { cn } from '../../../lib/utils';
|
|
920
|
+
|
|
921
|
+
export function Toaster() {
|
|
922
|
+
const { toasts } = useToast();
|
|
923
|
+
|
|
924
|
+
return (
|
|
925
|
+
<ToastProvider>
|
|
926
|
+
{toasts.map(function ({ id, title, description, action, ...props }) {
|
|
927
|
+
return (
|
|
928
|
+
<Toast key={id} {...props}>
|
|
929
|
+
<div className="grid gap-1">
|
|
930
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
931
|
+
{description && (
|
|
932
|
+
<ToastDescription>{description}</ToastDescription>
|
|
933
|
+
)}
|
|
934
|
+
</div>
|
|
935
|
+
{action}
|
|
936
|
+
<ToastClose />
|
|
937
|
+
</Toast>
|
|
938
|
+
);
|
|
939
|
+
})}
|
|
940
|
+
<ToastViewport />
|
|
941
|
+
</ToastProvider>
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
### Step 3: Create useToast hook
|
|
947
|
+
|
|
948
|
+
**File:** `host/src/kernel/components/ui/use-toast.ts`
|
|
949
|
+
|
|
950
|
+
```typescript
|
|
951
|
+
import * as React from 'react';
|
|
952
|
+
|
|
953
|
+
const TOAST_LIMIT = 1;
|
|
954
|
+
const TOAST_REMOVE_DELAY = 1000000;
|
|
955
|
+
|
|
956
|
+
type ToasterToast = {
|
|
957
|
+
id: string;
|
|
958
|
+
title?: React.ReactNode;
|
|
959
|
+
description?: React.ReactNode;
|
|
960
|
+
action?: React.ReactNode;
|
|
961
|
+
variant?: 'default' | 'destructive';
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
const actionTypes = {
|
|
965
|
+
ADD_TOAST: 'ADD_TOAST',
|
|
966
|
+
UPDATE_TOAST: 'UPDATE_TOAST',
|
|
967
|
+
DISMISS_TOAST: 'DISMISS_TOAST',
|
|
968
|
+
REMOVE_TOAST: 'REMOVE_TOAST',
|
|
969
|
+
} as const;
|
|
970
|
+
|
|
971
|
+
let count = 0;
|
|
972
|
+
|
|
973
|
+
function genId() {
|
|
974
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
975
|
+
return count.toString();
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
type ActionType = typeof actionTypes;
|
|
979
|
+
|
|
980
|
+
type Action =
|
|
981
|
+
| {
|
|
982
|
+
type: ActionType['ADD_TOAST'];
|
|
983
|
+
toast: ToasterToast;
|
|
984
|
+
}
|
|
985
|
+
| {
|
|
986
|
+
type: ActionType['UPDATE_TOAST'];
|
|
987
|
+
toast: Partial<ToasterToast>;
|
|
988
|
+
}
|
|
989
|
+
| {
|
|
990
|
+
type: ActionType['DISMISS_TOAST'];
|
|
991
|
+
toastId?: ToasterToast['id'];
|
|
992
|
+
}
|
|
993
|
+
| {
|
|
994
|
+
type: ActionType['REMOVE_TOAST'];
|
|
995
|
+
toastId?: ToasterToast['id'];
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
interface State {
|
|
999
|
+
toasts: ToasterToast[];
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
1003
|
+
|
|
1004
|
+
const addToRemoveQueue = (toastId: string) => {
|
|
1005
|
+
if (toastTimeouts.has(toastId)) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
const timeout = setTimeout(() => {
|
|
1010
|
+
toastTimeouts.delete(toastId);
|
|
1011
|
+
dispatch({
|
|
1012
|
+
type: 'REMOVE_TOAST',
|
|
1013
|
+
toastId: toastId,
|
|
1014
|
+
});
|
|
1015
|
+
}, TOAST_REMOVE_DELAY);
|
|
1016
|
+
|
|
1017
|
+
toastTimeouts.set(toastId, timeout);
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
export const reducer = (state: State, action: Action): State => {
|
|
1021
|
+
switch (action.type) {
|
|
1022
|
+
case 'ADD_TOAST':
|
|
1023
|
+
return {
|
|
1024
|
+
...state,
|
|
1025
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
case 'UPDATE_TOAST':
|
|
1029
|
+
return {
|
|
1030
|
+
...state,
|
|
1031
|
+
toasts: state.toasts.map((t) =>
|
|
1032
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t
|
|
1033
|
+
),
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
case 'DISMISS_TOAST': {
|
|
1037
|
+
const { toastId } = action;
|
|
1038
|
+
|
|
1039
|
+
if (toastId) {
|
|
1040
|
+
addToRemoveQueue(toastId);
|
|
1041
|
+
} else {
|
|
1042
|
+
state.toasts.forEach((toast) => {
|
|
1043
|
+
addToRemoveQueue(toast.id);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
return {
|
|
1048
|
+
...state,
|
|
1049
|
+
toasts: state.toasts.map((t) =>
|
|
1050
|
+
t.id === toastId || toastId === undefined
|
|
1051
|
+
? {
|
|
1052
|
+
...t,
|
|
1053
|
+
open: false,
|
|
1054
|
+
}
|
|
1055
|
+
: t
|
|
1056
|
+
),
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
case 'REMOVE_TOAST':
|
|
1060
|
+
if (action.toastId === undefined) {
|
|
1061
|
+
return {
|
|
1062
|
+
...state,
|
|
1063
|
+
toasts: [],
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
return {
|
|
1067
|
+
...state,
|
|
1068
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
const listeners: Array<(state: State) => void> = [];
|
|
1074
|
+
|
|
1075
|
+
let memoryState: State = { toasts: [] };
|
|
1076
|
+
|
|
1077
|
+
function dispatch(action: Action) {
|
|
1078
|
+
memoryState = reducer(memoryState, action);
|
|
1079
|
+
listeners.forEach((listener) => {
|
|
1080
|
+
listener(memoryState);
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
type Toast = Omit<ToasterToast, 'id'>;
|
|
1085
|
+
|
|
1086
|
+
function toast({ ...props }: Toast) {
|
|
1087
|
+
const id = genId();
|
|
1088
|
+
|
|
1089
|
+
const update = (props: ToasterToast) =>
|
|
1090
|
+
dispatch({
|
|
1091
|
+
type: 'UPDATE_TOAST',
|
|
1092
|
+
toast: { ...props, id },
|
|
1093
|
+
});
|
|
1094
|
+
const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
|
|
1095
|
+
|
|
1096
|
+
dispatch({
|
|
1097
|
+
type: 'ADD_TOAST',
|
|
1098
|
+
toast: {
|
|
1099
|
+
...props,
|
|
1100
|
+
id,
|
|
1101
|
+
open: true,
|
|
1102
|
+
},
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
return {
|
|
1106
|
+
id: id,
|
|
1107
|
+
dismiss,
|
|
1108
|
+
update,
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function useToast() {
|
|
1113
|
+
const [state, setState] = React.useState<State>(memoryState);
|
|
1114
|
+
|
|
1115
|
+
React.useEffect(() => {
|
|
1116
|
+
listeners.push(setState);
|
|
1117
|
+
return () => {
|
|
1118
|
+
const index = listeners.indexOf(setState);
|
|
1119
|
+
if (index > -1) {
|
|
1120
|
+
listeners.splice(index, 1);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
}, [state]);
|
|
1124
|
+
|
|
1125
|
+
return {
|
|
1126
|
+
...state,
|
|
1127
|
+
toast,
|
|
1128
|
+
dismiss: (toastId?: string) => dispatch({ type: 'DISMISS_TOAST', toastId }),
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
export { useToast, toast };
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
---
|
|
1136
|
+
|
|
1137
|
+
## Task 13: Create Table Components
|
|
1138
|
+
|
|
1139
|
+
**Files:**
|
|
1140
|
+
- Create: `host/src/kernel/components/ui/table.tsx`
|
|
1141
|
+
|
|
1142
|
+
### Step 1: Create table components
|
|
1143
|
+
|
|
1144
|
+
**File:** `host/src/kernel/components/ui/table.tsx`
|
|
1145
|
+
|
|
1146
|
+
```typescript
|
|
1147
|
+
import * as React from 'react';
|
|
1148
|
+
import { cn } from '../../../lib/utils';
|
|
1149
|
+
|
|
1150
|
+
const Table = React.forwardRef<
|
|
1151
|
+
HTMLTableElement,
|
|
1152
|
+
React.HTMLAttributes<HTMLTableElement>
|
|
1153
|
+
>(({ className, ...props }, ref) => (
|
|
1154
|
+
<div className="relative w-full overflow-auto">
|
|
1155
|
+
<table
|
|
1156
|
+
ref={ref}
|
|
1157
|
+
className={cn('w-full caption-bottom text-sm', className)}
|
|
1158
|
+
{...props}
|
|
1159
|
+
/>
|
|
1160
|
+
</div>
|
|
1161
|
+
));
|
|
1162
|
+
Table.displayName = 'Table';
|
|
1163
|
+
|
|
1164
|
+
const TableHeader = React.forwardRef<
|
|
1165
|
+
HTMLTableSectionElement,
|
|
1166
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
1167
|
+
>(({ className, ...props }, ref) => (
|
|
1168
|
+
<thead ref={ref} className={cn('[&_tr]:border-b', className)} {...props} />
|
|
1169
|
+
));
|
|
1170
|
+
TableHeader.displayName = 'TableHeader';
|
|
1171
|
+
|
|
1172
|
+
const TableBody = React.forwardRef<
|
|
1173
|
+
HTMLTableSectionElement,
|
|
1174
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
1175
|
+
>(({ className, ...props }, ref) => (
|
|
1176
|
+
<tbody
|
|
1177
|
+
ref={ref}
|
|
1178
|
+
className={cn('[&_tr:last-child]:border-0', className)}
|
|
1179
|
+
{...props}
|
|
1180
|
+
/>
|
|
1181
|
+
));
|
|
1182
|
+
TableBody.displayName = 'TableBody';
|
|
1183
|
+
|
|
1184
|
+
const TableFooter = React.forwardRef<
|
|
1185
|
+
HTMLTableSectionElement,
|
|
1186
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
1187
|
+
>(({ className, ...props }, ref) => (
|
|
1188
|
+
<tfoot
|
|
1189
|
+
ref={ref}
|
|
1190
|
+
className={cn(
|
|
1191
|
+
'border-t bg-muted/50 font-medium [&>tr]:last:border-b-0',
|
|
1192
|
+
className
|
|
1193
|
+
)}
|
|
1194
|
+
{...props}
|
|
1195
|
+
/>
|
|
1196
|
+
));
|
|
1197
|
+
TableFooter.displayName = 'TableFooter';
|
|
1198
|
+
|
|
1199
|
+
const TableRow = React.forwardRef<
|
|
1200
|
+
HTMLTableRowElement,
|
|
1201
|
+
React.HTMLAttributes<HTMLTableRowElement>
|
|
1202
|
+
>(({ className, ...props }, ref) => (
|
|
1203
|
+
<tr
|
|
1204
|
+
ref={ref}
|
|
1205
|
+
className={cn(
|
|
1206
|
+
'border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted',
|
|
1207
|
+
className
|
|
1208
|
+
)}
|
|
1209
|
+
{...props}
|
|
1210
|
+
/>
|
|
1211
|
+
));
|
|
1212
|
+
TableRow.displayName = 'TableRow';
|
|
1213
|
+
|
|
1214
|
+
const TableHead = React.forwardRef<
|
|
1215
|
+
HTMLTableCellElement,
|
|
1216
|
+
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
1217
|
+
>(({ className, ...props }, ref) => (
|
|
1218
|
+
<th
|
|
1219
|
+
ref={ref}
|
|
1220
|
+
className={cn(
|
|
1221
|
+
'h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0',
|
|
1222
|
+
className
|
|
1223
|
+
)}
|
|
1224
|
+
{...props}
|
|
1225
|
+
/>
|
|
1226
|
+
));
|
|
1227
|
+
TableHead.displayName = 'TableHead';
|
|
1228
|
+
|
|
1229
|
+
const TableCell = React.forwardRef<
|
|
1230
|
+
HTMLTableCellElement,
|
|
1231
|
+
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
1232
|
+
>(({ className, ...props }, ref) => (
|
|
1233
|
+
<td
|
|
1234
|
+
ref={ref}
|
|
1235
|
+
className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
|
|
1236
|
+
{...props}
|
|
1237
|
+
/>
|
|
1238
|
+
));
|
|
1239
|
+
TableCell.displayName = 'TableCell';
|
|
1240
|
+
|
|
1241
|
+
const TableCaption = React.forwardRef<
|
|
1242
|
+
HTMLTableCaptionElement,
|
|
1243
|
+
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
1244
|
+
>(({ className, ...props }, ref) => (
|
|
1245
|
+
<caption
|
|
1246
|
+
ref={ref}
|
|
1247
|
+
className={cn('mt-4 text-sm text-muted-foreground', className)}
|
|
1248
|
+
{...props}
|
|
1249
|
+
/>
|
|
1250
|
+
));
|
|
1251
|
+
TableCaption.displayName = 'TableCaption';
|
|
1252
|
+
|
|
1253
|
+
export {
|
|
1254
|
+
Table,
|
|
1255
|
+
TableHeader,
|
|
1256
|
+
TableBody,
|
|
1257
|
+
TableFooter,
|
|
1258
|
+
TableHead,
|
|
1259
|
+
TableRow,
|
|
1260
|
+
TableCell,
|
|
1261
|
+
TableCaption,
|
|
1262
|
+
};
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
---
|
|
1266
|
+
|
|
1267
|
+
## Task 14: Create Badge Component
|
|
1268
|
+
|
|
1269
|
+
**Files:**
|
|
1270
|
+
- Create: `host/src/kernel/components/ui/badge.tsx`
|
|
1271
|
+
|
|
1272
|
+
### Step 1: Create badge component
|
|
1273
|
+
|
|
1274
|
+
**File:** `host/src/kernel/components/ui/badge.tsx`
|
|
1275
|
+
|
|
1276
|
+
```typescript
|
|
1277
|
+
import * as React from 'react';
|
|
1278
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
1279
|
+
import { cn } from '../../../lib/utils';
|
|
1280
|
+
|
|
1281
|
+
const badgeVariants = cva(
|
|
1282
|
+
'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',
|
|
1283
|
+
{
|
|
1284
|
+
variants: {
|
|
1285
|
+
variant: {
|
|
1286
|
+
default:
|
|
1287
|
+
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',
|
|
1288
|
+
secondary:
|
|
1289
|
+
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
1290
|
+
destructive:
|
|
1291
|
+
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
|
1292
|
+
outline: 'text-foreground',
|
|
1293
|
+
},
|
|
1294
|
+
},
|
|
1295
|
+
defaultVariants: {
|
|
1296
|
+
variant: 'default',
|
|
1297
|
+
},
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
|
|
1301
|
+
export interface BadgeProps
|
|
1302
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
1303
|
+
VariantProps<typeof badgeVariants> {}
|
|
1304
|
+
|
|
1305
|
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
1306
|
+
return (
|
|
1307
|
+
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
1308
|
+
);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
export { Badge, badgeVariants };
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
---
|
|
1315
|
+
|
|
1316
|
+
## Task 15: Update Kernel Component Exports
|
|
1317
|
+
|
|
1318
|
+
**Files:**
|
|
1319
|
+
- Modify: `host/src/kernel/components/index.ts`
|
|
1320
|
+
|
|
1321
|
+
### Step 1: Create components barrel export
|
|
1322
|
+
|
|
1323
|
+
**File:** `host/src/kernel/components/index.ts`
|
|
1324
|
+
|
|
1325
|
+
```typescript
|
|
1326
|
+
export * from './ui/avatar';
|
|
1327
|
+
export * from './ui/badge';
|
|
1328
|
+
export * from './ui/button';
|
|
1329
|
+
export * from './ui/card';
|
|
1330
|
+
export * from './ui/input';
|
|
1331
|
+
export * from './ui/label';
|
|
1332
|
+
export * from './ui/alert';
|
|
1333
|
+
export * from './ui/dialog';
|
|
1334
|
+
export * from './ui/dropdown-menu';
|
|
1335
|
+
export * from './ui/select';
|
|
1336
|
+
export * from './ui/switch';
|
|
1337
|
+
export * from './ui/tabs';
|
|
1338
|
+
export * from './ui/separator';
|
|
1339
|
+
export * from './ui/popover';
|
|
1340
|
+
export * from './ui/scroll-area';
|
|
1341
|
+
export * from './ui/progress';
|
|
1342
|
+
export * from './ui/tooltip';
|
|
1343
|
+
export * from './ui/toast';
|
|
1344
|
+
export * from './ui/toaster';
|
|
1345
|
+
export * from './ui/use-toast';
|
|
1346
|
+
export * from './ui/table';
|
|
1347
|
+
export * from './ui/skeleton';
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
---
|
|
1351
|
+
|
|
1352
|
+
## Task 16: Add Toaster to App
|
|
1353
|
+
|
|
1354
|
+
**Files:**
|
|
1355
|
+
- Modify: `host/src/bootstrap.tsx`
|
|
1356
|
+
|
|
1357
|
+
### Step 1: Add Toaster to bootstrap
|
|
1358
|
+
|
|
1359
|
+
**File:** `host/src/bootstrap.tsx`
|
|
1360
|
+
|
|
1361
|
+
Update the bootstrap to include Toaster:
|
|
1362
|
+
|
|
1363
|
+
```typescript
|
|
1364
|
+
import { StrictMode } from 'react';
|
|
1365
|
+
import { createRoot } from 'react-dom/client';
|
|
1366
|
+
import { BrowserRouter } from '@modern-js/runtime/router';
|
|
1367
|
+
import App from './App';
|
|
1368
|
+
import { registerSharedState } from './kernel/shared-state';
|
|
1369
|
+
import { PocketBaseProvider } from './kernel/providers';
|
|
1370
|
+
import { QueryProvider } from './kernel/providers';
|
|
1371
|
+
import { ThemeProvider } from './kernel/providers';
|
|
1372
|
+
import { Toaster } from './kernel/components/ui/toaster';
|
|
1373
|
+
|
|
1374
|
+
// Register shared state bridge for plugins
|
|
1375
|
+
registerSharedState();
|
|
1376
|
+
|
|
1377
|
+
// Create root
|
|
1378
|
+
const container = document.getElementById('root');
|
|
1379
|
+
if (container) {
|
|
1380
|
+
const root = createRoot(container);
|
|
1381
|
+
|
|
1382
|
+
root.render(
|
|
1383
|
+
<StrictMode>
|
|
1384
|
+
<BrowserRouter>
|
|
1385
|
+
<ThemeProvider>
|
|
1386
|
+
<QueryProvider>
|
|
1387
|
+
<PocketBaseProvider>
|
|
1388
|
+
<App />
|
|
1389
|
+
<Toaster />
|
|
1390
|
+
</PocketBaseProvider>
|
|
1391
|
+
</QueryProvider>
|
|
1392
|
+
</ThemeProvider>
|
|
1393
|
+
</BrowserRouter>
|
|
1394
|
+
</StrictMode>
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
```
|
|
1398
|
+
|
|
1399
|
+
---
|
|
1400
|
+
|
|
1401
|
+
## Verification
|
|
1402
|
+
|
|
1403
|
+
### Step 1: Build the host
|
|
1404
|
+
|
|
1405
|
+
**Run:**
|
|
1406
|
+
|
|
1407
|
+
```bash
|
|
1408
|
+
cd host
|
|
1409
|
+
pnpm run build
|
|
1410
|
+
```
|
|
1411
|
+
|
|
1412
|
+
Expected: Build completes without errors.
|
|
1413
|
+
|
|
1414
|
+
### Step 2: Start development server
|
|
1415
|
+
|
|
1416
|
+
**Run:**
|
|
1417
|
+
|
|
1418
|
+
```bash
|
|
1419
|
+
cd host
|
|
1420
|
+
pnpm run dev
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
Expected: Server starts on http://localhost:8080
|
|
1424
|
+
|
|
1425
|
+
### Step 3: Verify components can be imported
|
|
1426
|
+
|
|
1427
|
+
In the browser console or by creating a test page, verify components are properly exported:
|
|
1428
|
+
|
|
1429
|
+
```typescript
|
|
1430
|
+
// Should be able to import and use any component
|
|
1431
|
+
import { Button, Card, Dialog, Select, Tabs } from '@/kernel/components';
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
---
|
|
1435
|
+
|
|
1436
|
+
## Summary
|
|
1437
|
+
|
|
1438
|
+
After completing this document, you will have:
|
|
1439
|
+
|
|
1440
|
+
1. ✅ Complete Shadcn UI component library adapted for Modern.js
|
|
1441
|
+
2. ✅ All essential UI components: Avatar, Dialog, Select, Switch, Tabs, Separator
|
|
1442
|
+
3. ✅ All common UI components: Popover, ScrollArea, Progress, Tooltip, Badge, Table
|
|
1443
|
+
4. ✅ Toast system with useToast hook and Toaster component
|
|
1444
|
+
5. ✅ Consistent theming with Tailwind CSS variables
|
|
1445
|
+
6. ✅ Proper TypeScript types for all components
|
|
1446
|
+
7. ✅ Toaster integrated into the app root
|
|
1447
|
+
|
|
1448
|
+
**Next:** `07-communication-system.md` - Implement Garfish channel bus, custom toast system, and state synchronization between host and plugins.
|
|
1449
|
+
|
|
1450
|
+
---
|
|
1451
|
+
|
|
1452
|
+
## Files Created
|
|
1453
|
+
|
|
1454
|
+
```
|
|
1455
|
+
host/
|
|
1456
|
+
└── src/
|
|
1457
|
+
└── kernel/
|
|
1458
|
+
└── components/
|
|
1459
|
+
├── ui/
|
|
1460
|
+
│ ├── avatar.tsx
|
|
1461
|
+
│ ├── badge.tsx
|
|
1462
|
+
│ ├── dialog.tsx
|
|
1463
|
+
│ ├── select.tsx
|
|
1464
|
+
│ ├── switch.tsx
|
|
1465
|
+
│ ├── tabs.tsx
|
|
1466
|
+
│ ├── separator.tsx
|
|
1467
|
+
│ ├── popover.tsx
|
|
1468
|
+
│ ├── scroll-area.tsx
|
|
1469
|
+
│ ├── progress.tsx
|
|
1470
|
+
│ ├── tooltip.tsx
|
|
1471
|
+
│ ├── toast.tsx
|
|
1472
|
+
│ ├── toaster.tsx
|
|
1473
|
+
│ ├── use-toast.ts
|
|
1474
|
+
│ └── table.tsx
|
|
1475
|
+
└── index.ts
|
|
1476
|
+
|
|
1477
|
+
bootstrap.tsx (modified)
|
|
1478
|
+
```
|