@codeswayam/ui 1.1.1 → 1.3.0
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 +727 -173
- package/dist/components/base/badge.d.ts +1 -1
- package/dist/components/base/button.d.ts +2 -2
- package/dist/components/base/button.d.ts.map +1 -1
- package/dist/components/base/button.js +2 -2
- package/dist/components/brand/BrandFooterSection.d.ts +8 -0
- package/dist/components/brand/BrandFooterSection.d.ts.map +1 -0
- package/dist/components/brand/BrandFooterSection.js +97 -0
- package/dist/components/brand/BrandNav.d.ts +17 -0
- package/dist/components/brand/BrandNav.d.ts.map +1 -0
- package/dist/components/brand/BrandNav.js +64 -0
- package/dist/components/data/DataTable.d.ts +18 -0
- package/dist/components/data/DataTable.d.ts.map +1 -0
- package/dist/components/data/DataTable.js +36 -0
- package/dist/components/data/EmptyState.d.ts +23 -0
- package/dist/components/data/EmptyState.d.ts.map +1 -0
- package/dist/components/data/EmptyState.js +9 -0
- package/dist/components/data/TableToolbar.d.ts +17 -0
- package/dist/components/data/TableToolbar.d.ts.map +1 -0
- package/dist/components/data/TableToolbar.js +21 -0
- package/dist/components/display/CopyButton.d.ts +14 -0
- package/dist/components/display/CopyButton.d.ts.map +1 -0
- package/dist/components/display/CopyButton.js +37 -0
- package/dist/components/display/PageHeader.d.ts +11 -0
- package/dist/components/display/PageHeader.d.ts.map +1 -0
- package/dist/components/display/PageHeader.js +5 -0
- package/dist/components/display/StatCard.d.ts +23 -0
- package/dist/components/display/StatCard.d.ts.map +1 -0
- package/dist/components/display/StatCard.js +6 -0
- package/dist/components/feedback/ConfirmDialog.d.ts +18 -0
- package/dist/components/feedback/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/feedback/ConfirmDialog.js +10 -0
- package/dist/components/feedback/ErrorState.d.ts +10 -0
- package/dist/components/feedback/ErrorState.d.ts.map +1 -0
- package/dist/components/feedback/ErrorState.js +7 -0
- package/dist/components/feedback/Skeleton.d.ts +26 -0
- package/dist/components/feedback/Skeleton.d.ts.map +1 -0
- package/dist/components/feedback/Skeleton.js +31 -0
- package/dist/components/neural/AICreditBadge.d.ts +9 -0
- package/dist/components/neural/AICreditBadge.d.ts.map +1 -0
- package/dist/components/neural/AICreditBadge.js +31 -0
- package/dist/components/neural/AIImageGeneratorModal.d.ts +9 -0
- package/dist/components/neural/AIImageGeneratorModal.d.ts.map +1 -0
- package/dist/components/neural/AIImageGeneratorModal.js +66 -0
- package/dist/components/neural/AIPromptPlayground.d.ts +10 -0
- package/dist/components/neural/AIPromptPlayground.d.ts.map +1 -0
- package/dist/components/neural/AIPromptPlayground.js +66 -0
- package/dist/components/neural/KnowledgeBasePicker.d.ts +18 -0
- package/dist/components/neural/KnowledgeBasePicker.d.ts.map +1 -0
- package/dist/components/neural/KnowledgeBasePicker.js +42 -0
- package/dist/components/neural/WorkflowPicker.d.ts +18 -0
- package/dist/components/neural/WorkflowPicker.d.ts.map +1 -0
- package/dist/components/neural/WorkflowPicker.js +46 -0
- package/dist/components/neural/index.d.ts +11 -0
- package/dist/components/neural/index.d.ts.map +1 -0
- package/dist/components/neural/index.js +5 -0
- package/dist/components/saas/NotificationBell.d.ts +12 -0
- package/dist/components/saas/NotificationBell.d.ts.map +1 -0
- package/dist/components/saas/NotificationBell.js +52 -0
- package/dist/components/saas/status-badge.d.ts +15 -8
- package/dist/components/saas/status-badge.d.ts.map +1 -1
- package/dist/components/saas/status-badge.js +46 -25
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/useNotifications.d.ts +24 -0
- package/dist/utils/useNotifications.d.ts.map +1 -0
- package/dist/utils/useNotifications.js +71 -0
- package/dist/utils/useWebPush.d.ts +14 -0
- package/dist/utils/useWebPush.d.ts.map +1 -0
- package/dist/utils/useWebPush.js +110 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,323 +1,877 @@
|
|
|
1
1
|
# @codeswayam/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@codeswayam/ui)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://react.dev/)
|
|
7
|
+
[](https://tailwindcss.com/)
|
|
8
|
+
[](https://www.radix-ui.com/)
|
|
4
9
|
|
|
5
|
-
Shared
|
|
10
|
+
> Shared component library for all CodeSwayam applications — built on Radix UI primitives, styled with Tailwind CSS, and patterned after shadcn/ui conventions.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Overview](#overview)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
19
|
+
- [Setup](#setup)
|
|
20
|
+
- [Component Reference](#component-reference)
|
|
21
|
+
- [Base Components](#base-components)
|
|
22
|
+
- [Data Components](#data-components)
|
|
23
|
+
- [Display Components](#display-components)
|
|
24
|
+
- [Feedback Components](#feedback-components)
|
|
25
|
+
- [Layout Components](#layout-components)
|
|
26
|
+
- [Brand Mesh Components](#brand-mesh-components)
|
|
27
|
+
- [SaaS Components](#saas-components)
|
|
28
|
+
- [Utilities](#utilities)
|
|
29
|
+
- [Design Tokens](#design-tokens)
|
|
30
|
+
- [Code Examples](#code-examples)
|
|
31
|
+
- [Compatibility Matrix](#compatibility-matrix)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
`@codeswayam/ui` is the single source of truth for UI across all CodeSwayam products. It provides:
|
|
38
|
+
|
|
39
|
+
- **Base primitives** — Button, Card, Badge, Input, Label, Avatar, Modal, Dropdown
|
|
40
|
+
- **Data display** — Full-featured DataTable powered by TanStack Table v8
|
|
41
|
+
- **Display components** — KPI StatCards, PageHeader, CopyButton
|
|
42
|
+
- **Feedback** — Skeleton loaders, ConfirmDialog, ErrorState
|
|
43
|
+
- **Layout** — Platform-wide GlobalNavbar and GlobalFooter
|
|
44
|
+
- **SaaS-specific** — StatusBadge, UserMenu
|
|
45
|
+
|
|
46
|
+
Every component is fully typed, supports dark mode, and uses `class-variance-authority` (CVA) for variant management.
|
|
6
47
|
|
|
7
48
|
---
|
|
8
49
|
|
|
9
50
|
## Installation
|
|
10
51
|
|
|
11
52
|
```bash
|
|
53
|
+
# npm
|
|
12
54
|
npm install @codeswayam/ui
|
|
55
|
+
|
|
56
|
+
# yarn
|
|
57
|
+
yarn add @codeswayam/ui
|
|
58
|
+
|
|
59
|
+
# pnpm
|
|
60
|
+
pnpm add @codeswayam/ui
|
|
13
61
|
```
|
|
14
62
|
|
|
15
|
-
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Peer Dependencies
|
|
66
|
+
|
|
67
|
+
| Dependency | Version | Purpose |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `react` | `^18.0.0 \|\| ^19.0.0` | React runtime |
|
|
70
|
+
| `react-dom` | `^18.0.0 \|\| ^19.0.0` | DOM bindings |
|
|
71
|
+
| `tailwindcss` | `^3.4.0` | Utility-first CSS framework |
|
|
72
|
+
| `@radix-ui/react-dialog` | `^1.0.0` | Modal/Dialog primitives |
|
|
73
|
+
| `@radix-ui/react-dropdown-menu` | `^2.0.0` | Dropdown menu primitives |
|
|
74
|
+
| `@radix-ui/react-avatar` | `^1.0.0` | Avatar primitives |
|
|
75
|
+
| `@radix-ui/react-label` | `^2.0.0` | Label primitive |
|
|
76
|
+
| `@tanstack/react-table` | `^8.0.0` | Headless table for DataTable |
|
|
77
|
+
| `class-variance-authority` | `^0.7.0` | Variant class management |
|
|
78
|
+
| `clsx` | `^2.0.0` | Conditional class joining |
|
|
79
|
+
| `tailwind-merge` | `^2.0.0` | Tailwind class deduplication |
|
|
80
|
+
| `lucide-react` | `^0.400.0` | Icon set |
|
|
81
|
+
|
|
82
|
+
Install all peer dependencies:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install react react-dom tailwindcss \
|
|
86
|
+
@radix-ui/react-dialog @radix-ui/react-dropdown-menu \
|
|
87
|
+
@radix-ui/react-avatar @radix-ui/react-label \
|
|
88
|
+
@tanstack/react-table class-variance-authority \
|
|
89
|
+
clsx tailwind-merge lucide-react
|
|
90
|
+
```
|
|
16
91
|
|
|
17
92
|
---
|
|
18
93
|
|
|
19
94
|
## Setup
|
|
20
95
|
|
|
21
|
-
|
|
96
|
+
### 1. Import global CSS tokens
|
|
97
|
+
|
|
98
|
+
Add the design token stylesheet to your app's entry point (e.g., `app/layout.tsx` in Next.js):
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// app/layout.tsx
|
|
102
|
+
import '@codeswayam/ui/globals.css';
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. Configure Tailwind
|
|
106
|
+
|
|
107
|
+
Add the package to your `tailwind.config.ts` content paths so Tailwind can detect and include its classes:
|
|
22
108
|
|
|
23
|
-
```
|
|
24
|
-
// tailwind.config.
|
|
25
|
-
|
|
109
|
+
```ts
|
|
110
|
+
// tailwind.config.ts
|
|
111
|
+
import type { Config } from 'tailwindcss';
|
|
112
|
+
|
|
113
|
+
const config: Config = {
|
|
26
114
|
content: [
|
|
27
|
-
|
|
28
|
-
|
|
115
|
+
'./app/**/*.{ts,tsx}',
|
|
116
|
+
'./components/**/*.{ts,tsx}',
|
|
117
|
+
// Include the UI package
|
|
118
|
+
'./node_modules/@codeswayam/ui/src/**/*.{ts,tsx}',
|
|
29
119
|
],
|
|
120
|
+
darkMode: 'class',
|
|
121
|
+
theme: {
|
|
122
|
+
extend: {},
|
|
123
|
+
},
|
|
124
|
+
plugins: [],
|
|
30
125
|
};
|
|
126
|
+
|
|
127
|
+
export default config;
|
|
31
128
|
```
|
|
32
129
|
|
|
33
|
-
|
|
130
|
+
### 3. Import and use components
|
|
34
131
|
|
|
35
132
|
```tsx
|
|
36
|
-
|
|
37
|
-
import "@codeswayam/ui/dist/globals.css"; // design tokens + base styles
|
|
133
|
+
import { Button, Card, CardContent } from '@codeswayam/ui';
|
|
38
134
|
```
|
|
39
135
|
|
|
40
136
|
---
|
|
41
137
|
|
|
42
|
-
##
|
|
138
|
+
## Component Reference
|
|
43
139
|
|
|
44
|
-
###
|
|
140
|
+
### Base Components
|
|
45
141
|
|
|
46
|
-
|
|
142
|
+
#### Button
|
|
47
143
|
|
|
48
|
-
```
|
|
49
|
-
import {
|
|
144
|
+
```tsx
|
|
145
|
+
import { Button } from '@codeswayam/ui';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Prop | Type | Default | Description |
|
|
149
|
+
|---|---|---|---|
|
|
150
|
+
| `variant` | `'default' \| 'destructive' \| 'outline' \| 'ghost' \| 'link'` | `'default'` | Visual style variant |
|
|
151
|
+
| `size` | `'default' \| 'sm' \| 'lg' \| 'icon'` | `'default'` | Button size |
|
|
152
|
+
| `asChild` | `boolean` | `false` | Render as a child element (Radix Slot) |
|
|
153
|
+
| `disabled` | `boolean` | `false` | Disables the button |
|
|
154
|
+
| ...`ButtonHTMLAttributes` | | | All native button props |
|
|
50
155
|
|
|
51
|
-
|
|
52
|
-
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
#### Card
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@codeswayam/ui';
|
|
53
162
|
```
|
|
54
163
|
|
|
164
|
+
| Component | Description |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `Card` | Outer container with border, shadow, and rounded corners |
|
|
167
|
+
| `CardHeader` | Top section — typically holds title and description |
|
|
168
|
+
| `CardTitle` | Heading text inside the header |
|
|
169
|
+
| `CardDescription` | Subtitle / muted description inside the header |
|
|
170
|
+
| `CardContent` | Main content area with padding |
|
|
171
|
+
| `CardFooter` | Bottom section — typically holds actions |
|
|
172
|
+
|
|
55
173
|
---
|
|
56
174
|
|
|
57
|
-
|
|
175
|
+
#### Badge
|
|
58
176
|
|
|
59
|
-
|
|
177
|
+
```tsx
|
|
178
|
+
import { Badge } from '@codeswayam/ui';
|
|
179
|
+
```
|
|
60
180
|
|
|
61
|
-
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
|---|---|---|---|
|
|
183
|
+
| `variant` | `'default' \| 'secondary' \| 'destructive' \| 'outline'` | `'default'` | Color and style variant |
|
|
184
|
+
| ...`HTMLAttributes<HTMLDivElement>` | | | All native div props |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
#### Input
|
|
62
189
|
|
|
63
190
|
```tsx
|
|
64
|
-
import {
|
|
191
|
+
import { Input } from '@codeswayam/ui';
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Accepts all standard `InputHTMLAttributes<HTMLInputElement>` props. Renders a styled text input consistent with the design system.
|
|
195
|
+
|
|
196
|
+
---
|
|
65
197
|
|
|
66
|
-
|
|
67
|
-
<Button variant="outline" size="sm">Cancel</Button>
|
|
68
|
-
<Button variant="destructive">Delete</Button>
|
|
69
|
-
<Button variant="ghost" size="icon"><TrashIcon /></Button>
|
|
198
|
+
#### Label
|
|
70
199
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<a href="/dashboard">Go to Dashboard</a>
|
|
74
|
-
</Button>
|
|
200
|
+
```tsx
|
|
201
|
+
import { Label } from '@codeswayam/ui';
|
|
75
202
|
```
|
|
76
203
|
|
|
77
|
-
|
|
78
|
-
**Sizes:** `default`, `sm`, `lg`, `icon`
|
|
204
|
+
Wraps Radix `@radix-ui/react-label`. Accepts all native `LabelHTMLAttributes` and a `htmlFor` prop.
|
|
79
205
|
|
|
80
206
|
---
|
|
81
207
|
|
|
82
|
-
|
|
208
|
+
#### Avatar
|
|
83
209
|
|
|
84
210
|
```tsx
|
|
85
|
-
import {
|
|
211
|
+
import { Avatar, AvatarImage, AvatarFallback } from '@codeswayam/ui';
|
|
212
|
+
```
|
|
86
213
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
214
|
+
| Component | Description |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `Avatar` | Container with size constraints and rounded styling |
|
|
217
|
+
| `AvatarImage` | Renders the user image with `onError` fallback behaviour |
|
|
218
|
+
| `AvatarFallback` | Shown when the image fails to load (e.g., initials) |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
#### Modal
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
import { Modal } from '@codeswayam/ui';
|
|
99
226
|
```
|
|
100
227
|
|
|
228
|
+
| Prop | Type | Description |
|
|
229
|
+
|---|---|---|
|
|
230
|
+
| `open` | `boolean` | Controls open/close state |
|
|
231
|
+
| `onOpenChange` | `(open: boolean) => void` | Called when state changes |
|
|
232
|
+
| `title` | `string` | Modal heading |
|
|
233
|
+
| `description` | `string` | Optional subtitle |
|
|
234
|
+
| `children` | `ReactNode` | Modal body content |
|
|
235
|
+
| `trigger` | `ReactNode` | Optional trigger element |
|
|
236
|
+
|
|
101
237
|
---
|
|
102
238
|
|
|
103
|
-
|
|
239
|
+
#### DropdownMenu
|
|
104
240
|
|
|
105
241
|
```tsx
|
|
106
|
-
import {
|
|
242
|
+
import { DropdownMenu } from '@codeswayam/ui';
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Re-exports Radix `@radix-ui/react-dropdown-menu` primitives with consistent styling. Supports all Radix sub-components: `DropdownMenuTrigger`, `DropdownMenuContent`, `DropdownMenuItem`, `DropdownMenuSeparator`, etc.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Data Components
|
|
107
250
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<Badge variant="info">Info</Badge>
|
|
115
|
-
<Badge variant="purple">AI</Badge>
|
|
251
|
+
#### DataTable
|
|
252
|
+
|
|
253
|
+
Full TanStack Table v8 implementation with sorting, global filtering, column visibility, and pagination.
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
import { DataTable } from '@codeswayam/ui';
|
|
116
257
|
```
|
|
117
258
|
|
|
118
|
-
|
|
259
|
+
| Prop | Type | Required | Description |
|
|
260
|
+
|---|---|---|---|
|
|
261
|
+
| `columns` | `ColumnDef<TData>[]` | ✅ | TanStack Table column definitions |
|
|
262
|
+
| `data` | `TData[]` | ✅ | Array of row data |
|
|
263
|
+
| `searchKey` | `string` | ❌ | Column key to use for global search |
|
|
264
|
+
| `pagination` | `boolean` | ❌ | Enable pagination controls |
|
|
265
|
+
| `actions` | `ReactNode` | ❌ | Additional action elements in the toolbar |
|
|
119
266
|
|
|
120
267
|
---
|
|
121
268
|
|
|
122
|
-
|
|
269
|
+
#### TableToolbar
|
|
270
|
+
|
|
271
|
+
Internal toolbar used by `DataTable`, also exportable for custom table implementations.
|
|
272
|
+
|
|
273
|
+
| Prop | Type | Description |
|
|
274
|
+
|---|---|---|
|
|
275
|
+
| `table` | `Table<TData>` | TanStack Table instance |
|
|
276
|
+
| `searchKey` | `string` | Column accessor key for search |
|
|
277
|
+
| `actions` | `ReactNode` | Additional toolbar actions |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
#### EmptyState
|
|
123
282
|
|
|
124
283
|
```tsx
|
|
125
|
-
import {
|
|
284
|
+
import { EmptyState } from '@codeswayam/ui';
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| Prop | Type | Description |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `icon` | `ReactNode` | Icon element (e.g., from lucide-react) |
|
|
290
|
+
| `title` | `string` | Primary empty state message |
|
|
291
|
+
| `description` | `string` | Secondary supporting text |
|
|
292
|
+
| `action` | `ReactNode` | Optional call-to-action button |
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### Display Components
|
|
126
297
|
|
|
127
|
-
|
|
128
|
-
|
|
298
|
+
#### StatCard
|
|
299
|
+
|
|
300
|
+
KPI metric card with optional trend indicator.
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import { StatCard } from '@codeswayam/ui';
|
|
129
304
|
```
|
|
130
305
|
|
|
306
|
+
| Prop | Type | Required | Description |
|
|
307
|
+
|---|---|---|---|
|
|
308
|
+
| `title` | `string` | ✅ | Metric label |
|
|
309
|
+
| `value` | `string \| number` | ✅ | Current metric value |
|
|
310
|
+
| `trend` | `'up' \| 'down' \| 'neutral'` | ❌ | Trend direction |
|
|
311
|
+
| `trendValue` | `string` | ❌ | Trend change text (e.g., `"+12%"`) |
|
|
312
|
+
| `icon` | `ReactNode` | ❌ | Icon element |
|
|
313
|
+
| `description` | `string` | ❌ | Supporting text below the value |
|
|
314
|
+
|
|
131
315
|
---
|
|
132
316
|
|
|
133
|
-
|
|
317
|
+
#### PageHeader
|
|
134
318
|
|
|
135
319
|
```tsx
|
|
136
|
-
import {
|
|
320
|
+
import { PageHeader } from '@codeswayam/ui';
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
| Prop | Type | Description |
|
|
324
|
+
|---|---|---|
|
|
325
|
+
| `title` | `string` | Page title |
|
|
326
|
+
| `description` | `string` | Optional subtitle |
|
|
327
|
+
| `actions` | `ReactNode` | Right-side action buttons |
|
|
137
328
|
|
|
138
|
-
|
|
139
|
-
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
#### CopyButton
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
import { CopyButton } from '@codeswayam/ui';
|
|
140
335
|
```
|
|
141
336
|
|
|
337
|
+
| Prop | Type | Description |
|
|
338
|
+
|---|---|---|
|
|
339
|
+
| `value` | `string` | Text to copy to clipboard |
|
|
340
|
+
| `className` | `string` | Additional CSS classes |
|
|
341
|
+
|
|
342
|
+
Shows a checkmark icon on successful copy, then reverts after 2 seconds.
|
|
343
|
+
|
|
142
344
|
---
|
|
143
345
|
|
|
144
|
-
###
|
|
346
|
+
### Feedback Components
|
|
145
347
|
|
|
146
|
-
|
|
348
|
+
#### Skeleton
|
|
147
349
|
|
|
148
350
|
```tsx
|
|
149
|
-
import {
|
|
351
|
+
import { Skeleton } from '@codeswayam/ui';
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
| Prop | Type | Description |
|
|
355
|
+
|---|---|---|
|
|
356
|
+
| `className` | `string` | Width, height, and shape via Tailwind classes |
|
|
150
357
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</Avatar>
|
|
358
|
+
Use as a drop-in loading placeholder:
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
<Skeleton className="h-4 w-[250px]" />
|
|
362
|
+
<Skeleton className="h-12 w-12 rounded-full" />
|
|
157
363
|
```
|
|
158
364
|
|
|
159
365
|
---
|
|
160
366
|
|
|
161
|
-
|
|
367
|
+
#### ConfirmDialog
|
|
162
368
|
|
|
163
|
-
|
|
369
|
+
```tsx
|
|
370
|
+
import { ConfirmDialog } from '@codeswayam/ui';
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
| Prop | Type | Required | Description |
|
|
374
|
+
|---|---|---|---|
|
|
375
|
+
| `open` | `boolean` | ✅ | Controls open/close state |
|
|
376
|
+
| `onOpenChange` | `(open: boolean) => void` | ✅ | State change handler |
|
|
377
|
+
| `onConfirm` | `() => void` | ✅ | Called on confirmation |
|
|
378
|
+
| `title` | `string` | ✅ | Dialog heading |
|
|
379
|
+
| `description` | `string` | ✅ | Warning message |
|
|
380
|
+
| `confirmLabel` | `string` | ❌ | Confirm button text (default: `"Confirm"`) |
|
|
381
|
+
| `cancelLabel` | `string` | ❌ | Cancel button text (default: `"Cancel"`) |
|
|
382
|
+
| `variant` | `'default' \| 'destructive'` | ❌ | Confirm button style |
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
#### ErrorState
|
|
164
387
|
|
|
165
388
|
```tsx
|
|
166
|
-
import {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
DropdownMenuShortcut,
|
|
175
|
-
} from "@codeswayam/ui";
|
|
389
|
+
import { ErrorState } from '@codeswayam/ui';
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
| Prop | Type | Description |
|
|
393
|
+
|---|---|---|
|
|
394
|
+
| `title` | `string` | Error heading |
|
|
395
|
+
| `description` | `string` | Error details |
|
|
396
|
+
| `retry` | `() => void` | Optional retry callback — shows a "Try again" button |
|
|
176
397
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</DropdownMenuItem>
|
|
188
|
-
</DropdownMenuContent>
|
|
189
|
-
</DropdownMenu>
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
### Layout Components
|
|
401
|
+
|
|
402
|
+
#### GlobalNavbar
|
|
403
|
+
|
|
404
|
+
Platform-wide top navigation bar used across all CodeSwayam apps.
|
|
405
|
+
|
|
406
|
+
```tsx
|
|
407
|
+
import { GlobalNavbar } from '@codeswayam/ui';
|
|
190
408
|
```
|
|
191
409
|
|
|
410
|
+
| Prop | Type | Description |
|
|
411
|
+
|---|---|---|
|
|
412
|
+
| `links` | `NavLink[]` | Array of `{ href, label, active? }` navigation links |
|
|
413
|
+
| `user` | `NavUser` | `{ name, email, avatarUrl? }` for user display |
|
|
414
|
+
| `notifications` | `Notification[]` | Array of notification items |
|
|
415
|
+
| `credits` | `number` | Current AI credit balance to display |
|
|
416
|
+
|
|
192
417
|
---
|
|
193
418
|
|
|
194
|
-
|
|
419
|
+
#### GlobalFooter
|
|
420
|
+
|
|
421
|
+
```tsx
|
|
422
|
+
import { GlobalFooter } from '@codeswayam/ui';
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Platform-wide footer with links and branding. Accepts no required props — configuration is embedded from the package.
|
|
426
|
+
|
|
427
|
+
---
|
|
195
428
|
|
|
196
|
-
###
|
|
429
|
+
### Brand Mesh Components
|
|
197
430
|
|
|
198
|
-
|
|
431
|
+
#### BrandNav & BrandAppSwitcher
|
|
432
|
+
|
|
433
|
+
Federated ecosystem navigation and 9-dot app launcher connecting all CodeSwayam products (Code Swayam, PixelForge, PDFCraft, Neural AI, AuraFlow).
|
|
199
434
|
|
|
200
435
|
```tsx
|
|
201
|
-
import {
|
|
436
|
+
import { BrandNav, BrandAppSwitcher } from '@codeswayam/ui';
|
|
437
|
+
|
|
438
|
+
// Standalone Nav Bar
|
|
439
|
+
<BrandNav
|
|
440
|
+
currentProduct="pixelforge"
|
|
441
|
+
theme="dark" // "dark" | "light"
|
|
442
|
+
ctaText="Explore CodeSwayam"
|
|
443
|
+
ctaHref="https://codeswayam.com"
|
|
444
|
+
/>
|
|
202
445
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
onSecurityClick={() => router.push("/settings/security")}
|
|
446
|
+
// Or embed the 9-dot App Switcher inside your custom navbar:
|
|
447
|
+
<BrandAppSwitcher
|
|
448
|
+
currentProduct="pdfcraft"
|
|
449
|
+
theme="light"
|
|
208
450
|
/>
|
|
209
451
|
```
|
|
210
452
|
|
|
211
|
-
| Prop | Type | Description |
|
|
212
|
-
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `className` | `string` | Additional CSS classes |
|
|
453
|
+
| Prop | Type | Default | Description |
|
|
454
|
+
|---|---|---|---|
|
|
455
|
+
| `currentProduct` | `'codeswayam' \| 'pixelforge' \| 'pdfcraft' \| 'neural' \| 'auraflow'` | `undefined` | Highlights active application with "Current" badge |
|
|
456
|
+
| `theme` | `'dark' \| 'light'` | `'dark'` | Visual styling theme for backgrounds and text |
|
|
457
|
+
| `ctaText` | `string` | `'Explore Suite'` | Call-to-action button label |
|
|
458
|
+
| `ctaHref` | `string` | `'https://codeswayam.com'` | Destination URL for the CTA button |
|
|
218
459
|
|
|
219
460
|
---
|
|
220
461
|
|
|
221
|
-
|
|
462
|
+
#### BrandFooterSection
|
|
222
463
|
|
|
223
|
-
|
|
464
|
+
Cross-domain internal linking block with built-in Schema.org Knowledge Graph `Organization` entity JSON-LD to pass Domain Authority and topical trust across subdomains.
|
|
224
465
|
|
|
225
466
|
```tsx
|
|
226
|
-
import {
|
|
467
|
+
import { BrandFooterSection } from '@codeswayam/ui';
|
|
227
468
|
|
|
228
|
-
<
|
|
229
|
-
|
|
230
|
-
|
|
469
|
+
<BrandFooterSection
|
|
470
|
+
currentApp="pixelforge"
|
|
471
|
+
theme="dark" // "dark" | "light"
|
|
472
|
+
/>
|
|
231
473
|
```
|
|
232
474
|
|
|
233
475
|
| Prop | Type | Default | Description |
|
|
234
|
-
|
|
235
|
-
| `
|
|
236
|
-
| `
|
|
476
|
+
|---|---|---|---|
|
|
477
|
+
| `currentApp` | `'codeswayam' \| 'pixelforge' \| 'pdfcraft' \| 'neural' \| 'auraflow'` | `undefined` | Highlights active application in the ecosystem grid |
|
|
478
|
+
| `theme` | `'dark' \| 'light'` | `'dark'` | Color scheme for footer text, borders, and backgrounds |
|
|
237
479
|
|
|
238
480
|
---
|
|
239
481
|
|
|
240
|
-
###
|
|
482
|
+
### SaaS Components
|
|
241
483
|
|
|
242
|
-
|
|
484
|
+
#### StatusBadge
|
|
243
485
|
|
|
244
|
-
|
|
245
|
-
import { StatusBadge } from "@codeswayam/ui";
|
|
486
|
+
Specialized badge for subscription and plan statuses.
|
|
246
487
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
<StatusBadge status="canceled" /> // Red — "Canceled"
|
|
250
|
-
<StatusBadge status="past_due" /> // Red — "Past Due"
|
|
488
|
+
```tsx
|
|
489
|
+
import { StatusBadge } from '@codeswayam/ui';
|
|
251
490
|
```
|
|
252
491
|
|
|
253
492
|
| Prop | Type | Description |
|
|
254
|
-
|
|
255
|
-
| `status` | `
|
|
493
|
+
|---|---|---|
|
|
494
|
+
| `status` | `'active' \| 'cancelled' \| 'trial' \| 'expired'` | Subscription status |
|
|
256
495
|
| `className` | `string` | Additional CSS classes |
|
|
257
496
|
|
|
497
|
+
Color mapping:
|
|
498
|
+
|
|
499
|
+
| Status | Color |
|
|
500
|
+
|---|---|
|
|
501
|
+
| `active` | Green |
|
|
502
|
+
| `trial` | Blue / Indigo |
|
|
503
|
+
| `cancelled` | Gray |
|
|
504
|
+
| `expired` | Red |
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
#### UserMenu
|
|
509
|
+
|
|
510
|
+
User avatar dropdown with profile, settings, and logout actions.
|
|
511
|
+
|
|
512
|
+
```tsx
|
|
513
|
+
import { UserMenu } from '@codeswayam/ui';
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
| Prop | Type | Required | Description |
|
|
517
|
+
|---|---|---|---|
|
|
518
|
+
| `user` | `{ name: string; email: string; avatarUrl?: string }` | ✅ | User info for display |
|
|
519
|
+
| `onSignOut` | `() => void` | ✅ | Callback for sign-out action |
|
|
520
|
+
|
|
521
|
+
---
|
|
522
|
+
|
|
523
|
+
## Utilities
|
|
524
|
+
|
|
525
|
+
### `cn()` — className utility
|
|
526
|
+
|
|
527
|
+
```tsx
|
|
528
|
+
import { cn } from '@codeswayam/ui';
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Combines `clsx` and `tailwind-merge` to safely join conditional class names without Tailwind conflicts:
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
// Merges classes, resolving Tailwind conflicts intelligently
|
|
535
|
+
cn('px-4 py-2', isActive && 'bg-blue-600', 'px-6')
|
|
536
|
+
// → 'py-2 bg-blue-600 px-6' (px-4 is overridden by px-6)
|
|
537
|
+
```
|
|
538
|
+
|
|
258
539
|
---
|
|
259
540
|
|
|
260
|
-
##
|
|
541
|
+
## Design Tokens
|
|
261
542
|
|
|
262
|
-
|
|
543
|
+
Import the global stylesheet for CSS custom properties:
|
|
263
544
|
|
|
264
|
-
|
|
545
|
+
```tsx
|
|
546
|
+
import '@codeswayam/ui/globals.css';
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
This provides CSS variables following the shadcn/ui convention:
|
|
550
|
+
|
|
551
|
+
```css
|
|
552
|
+
:root {
|
|
553
|
+
--background: 0 0% 100%;
|
|
554
|
+
--foreground: 222.2 47.4% 11.2%;
|
|
555
|
+
--primary: 262.1 83.3% 57.8%;
|
|
556
|
+
--primary-foreground: 210 40% 98%;
|
|
557
|
+
--secondary: 210 40% 96.1%;
|
|
558
|
+
--muted: 210 40% 96.1%;
|
|
559
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
560
|
+
--border: 214.3 31.8% 91.4%;
|
|
561
|
+
--radius: 0.5rem;
|
|
562
|
+
/* ... */
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.dark {
|
|
566
|
+
--background: 224 71% 4%;
|
|
567
|
+
--foreground: 213 31% 91%;
|
|
568
|
+
/* ... dark mode overrides ... */
|
|
569
|
+
}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
To enable dark mode, apply the `dark` class to your `<html>` element.
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## Code Examples
|
|
577
|
+
|
|
578
|
+
### 1. Installation and Setup
|
|
265
579
|
|
|
266
580
|
```tsx
|
|
267
|
-
|
|
581
|
+
// app/layout.tsx (Next.js App Router)
|
|
582
|
+
import '@codeswayam/ui/globals.css';
|
|
583
|
+
import type { ReactNode } from 'react';
|
|
268
584
|
|
|
269
|
-
|
|
270
|
-
export default function RootLayout({ children }) {
|
|
585
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
271
586
|
return (
|
|
272
|
-
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
587
|
+
<html lang="en">
|
|
588
|
+
<body>{children}</body>
|
|
589
|
+
</html>
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
### 2. Button Variants
|
|
597
|
+
|
|
598
|
+
```tsx
|
|
599
|
+
import { Button } from '@codeswayam/ui';
|
|
600
|
+
|
|
601
|
+
export function ButtonShowcase() {
|
|
602
|
+
return (
|
|
603
|
+
<div className="flex flex-wrap gap-3">
|
|
604
|
+
<Button variant="default">Save Changes</Button>
|
|
605
|
+
<Button variant="outline">Cancel</Button>
|
|
606
|
+
<Button variant="destructive">Delete Account</Button>
|
|
607
|
+
<Button variant="ghost">View Details</Button>
|
|
608
|
+
<Button variant="link">Learn more →</Button>
|
|
609
|
+
<Button size="sm">Small</Button>
|
|
610
|
+
<Button size="lg">Large</Button>
|
|
611
|
+
<Button disabled>Disabled</Button>
|
|
612
|
+
</div>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
### 3. DataTable with Column Definitions
|
|
620
|
+
|
|
621
|
+
```tsx
|
|
622
|
+
import { DataTable } from '@codeswayam/ui';
|
|
623
|
+
import type { ColumnDef } from '@tanstack/react-table';
|
|
624
|
+
|
|
625
|
+
type User = {
|
|
626
|
+
id: string;
|
|
627
|
+
name: string;
|
|
628
|
+
email: string;
|
|
629
|
+
status: 'active' | 'inactive';
|
|
630
|
+
joinedAt: string;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
const columns: ColumnDef<User>[] = [
|
|
634
|
+
{
|
|
635
|
+
accessorKey: 'name',
|
|
636
|
+
header: 'Name',
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
accessorKey: 'email',
|
|
640
|
+
header: 'Email',
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
accessorKey: 'status',
|
|
644
|
+
header: 'Status',
|
|
645
|
+
cell: ({ row }) => (
|
|
646
|
+
<StatusBadge status={row.getValue('status')} />
|
|
647
|
+
),
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
accessorKey: 'joinedAt',
|
|
651
|
+
header: 'Joined',
|
|
652
|
+
cell: ({ row }) => new Date(row.getValue('joinedAt')).toLocaleDateString(),
|
|
653
|
+
},
|
|
654
|
+
];
|
|
655
|
+
|
|
656
|
+
export function UsersTable({ users }: { users: User[] }) {
|
|
657
|
+
return (
|
|
658
|
+
<DataTable
|
|
659
|
+
columns={columns}
|
|
660
|
+
data={users}
|
|
661
|
+
searchKey="name"
|
|
662
|
+
pagination
|
|
663
|
+
/>
|
|
276
664
|
);
|
|
277
665
|
}
|
|
278
666
|
```
|
|
279
667
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
668
|
+
---
|
|
669
|
+
|
|
670
|
+
### 4. StatCard for KPI Dashboard
|
|
671
|
+
|
|
672
|
+
```tsx
|
|
673
|
+
import { StatCard } from '@codeswayam/ui';
|
|
674
|
+
import { Users, TrendingUp, DollarSign, Zap } from 'lucide-react';
|
|
675
|
+
|
|
676
|
+
export function DashboardStats() {
|
|
677
|
+
return (
|
|
678
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
679
|
+
<StatCard
|
|
680
|
+
title="Total Users"
|
|
681
|
+
value="12,481"
|
|
682
|
+
trend="up"
|
|
683
|
+
trendValue="+8.2%"
|
|
684
|
+
icon={<Users className="h-5 w-5 text-blue-500" />}
|
|
685
|
+
description="vs. last month"
|
|
686
|
+
/>
|
|
687
|
+
<StatCard
|
|
688
|
+
title="Monthly Revenue"
|
|
689
|
+
value="$48,290"
|
|
690
|
+
trend="up"
|
|
691
|
+
trendValue="+14.5%"
|
|
692
|
+
icon={<DollarSign className="h-5 w-5 text-green-500" />}
|
|
693
|
+
description="vs. last month"
|
|
694
|
+
/>
|
|
695
|
+
<StatCard
|
|
696
|
+
title="Churn Rate"
|
|
697
|
+
value="2.4%"
|
|
698
|
+
trend="down"
|
|
699
|
+
trendValue="-0.8%"
|
|
700
|
+
icon={<TrendingUp className="h-5 w-5 text-red-500" />}
|
|
701
|
+
description="vs. last month"
|
|
702
|
+
/>
|
|
703
|
+
<StatCard
|
|
704
|
+
title="AI Credits Used"
|
|
705
|
+
value="1.2M"
|
|
706
|
+
trend="up"
|
|
707
|
+
trendValue="+23%"
|
|
708
|
+
icon={<Zap className="h-5 w-5 text-yellow-500" />}
|
|
709
|
+
description="this billing cycle"
|
|
710
|
+
/>
|
|
711
|
+
</div>
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
```
|
|
284
715
|
|
|
285
716
|
---
|
|
286
717
|
|
|
287
|
-
###
|
|
718
|
+
### 5. GlobalNavbar Integration
|
|
288
719
|
|
|
289
|
-
|
|
720
|
+
```tsx
|
|
721
|
+
import { GlobalNavbar } from '@codeswayam/ui';
|
|
722
|
+
import { usePathname } from 'next/navigation';
|
|
723
|
+
|
|
724
|
+
const NAV_LINKS = [
|
|
725
|
+
{ href: '/dashboard', label: 'Dashboard' },
|
|
726
|
+
{ href: '/agents', label: 'Agents' },
|
|
727
|
+
{ href: '/workflows', label: 'Workflows' },
|
|
728
|
+
{ href: '/analytics', label: 'Analytics' },
|
|
729
|
+
];
|
|
730
|
+
|
|
731
|
+
export function AppNavbar({ user, credits, notifications }) {
|
|
732
|
+
const pathname = usePathname();
|
|
733
|
+
|
|
734
|
+
return (
|
|
735
|
+
<GlobalNavbar
|
|
736
|
+
links={NAV_LINKS.map((link) => ({
|
|
737
|
+
...link,
|
|
738
|
+
active: pathname.startsWith(link.href),
|
|
739
|
+
}))}
|
|
740
|
+
user={user}
|
|
741
|
+
notifications={notifications}
|
|
742
|
+
credits={credits}
|
|
743
|
+
/>
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
### 6. StatusBadge for Subscription Status
|
|
290
751
|
|
|
291
752
|
```tsx
|
|
292
|
-
import {
|
|
753
|
+
import { StatusBadge, Card, CardContent } from '@codeswayam/ui';
|
|
293
754
|
|
|
294
|
-
|
|
755
|
+
type Subscription = {
|
|
756
|
+
planName: string;
|
|
757
|
+
status: 'active' | 'trial' | 'cancelled' | 'expired';
|
|
758
|
+
renewsAt: string;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
export function SubscriptionCard({ sub }: { sub: Subscription }) {
|
|
762
|
+
return (
|
|
763
|
+
<Card>
|
|
764
|
+
<CardContent className="pt-6 flex items-center justify-between">
|
|
765
|
+
<div>
|
|
766
|
+
<p className="font-semibold">{sub.planName}</p>
|
|
767
|
+
<p className="text-sm text-muted-foreground">
|
|
768
|
+
Renews {new Date(sub.renewsAt).toLocaleDateString()}
|
|
769
|
+
</p>
|
|
770
|
+
</div>
|
|
771
|
+
<StatusBadge status={sub.status} />
|
|
772
|
+
</CardContent>
|
|
773
|
+
</Card>
|
|
774
|
+
);
|
|
775
|
+
}
|
|
295
776
|
```
|
|
296
777
|
|
|
297
778
|
---
|
|
298
779
|
|
|
299
|
-
|
|
780
|
+
### 7. ConfirmDialog for Destructive Actions
|
|
300
781
|
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
Button,
|
|
304
|
-
Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter
|
|
305
|
-
Badge, badgeVariants
|
|
306
|
-
Input
|
|
307
|
-
Label
|
|
308
|
-
Avatar, AvatarImage, AvatarFallback
|
|
309
|
-
DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem,
|
|
310
|
-
DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel,
|
|
311
|
-
DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup,
|
|
312
|
-
DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent,
|
|
313
|
-
DropdownMenuSubTrigger, DropdownMenuRadioGroup
|
|
782
|
+
```tsx
|
|
783
|
+
import { useState } from 'react';
|
|
784
|
+
import { Button, ConfirmDialog } from '@codeswayam/ui';
|
|
314
785
|
|
|
315
|
-
|
|
316
|
-
|
|
786
|
+
export function DeleteAgentButton({ agentId, onDelete }) {
|
|
787
|
+
const [open, setOpen] = useState(false);
|
|
317
788
|
|
|
318
|
-
|
|
319
|
-
|
|
789
|
+
const handleConfirm = async () => {
|
|
790
|
+
await onDelete(agentId);
|
|
791
|
+
setOpen(false);
|
|
792
|
+
};
|
|
320
793
|
|
|
321
|
-
|
|
322
|
-
|
|
794
|
+
return (
|
|
795
|
+
<>
|
|
796
|
+
<Button variant="destructive" size="sm" onClick={() => setOpen(true)}>
|
|
797
|
+
Delete Agent
|
|
798
|
+
</Button>
|
|
799
|
+
<ConfirmDialog
|
|
800
|
+
open={open}
|
|
801
|
+
onOpenChange={setOpen}
|
|
802
|
+
onConfirm={handleConfirm}
|
|
803
|
+
title="Delete Agent"
|
|
804
|
+
description="This will permanently delete the agent and all associated conversation history. This action cannot be undone."
|
|
805
|
+
confirmLabel="Delete"
|
|
806
|
+
cancelLabel="Keep Agent"
|
|
807
|
+
variant="destructive"
|
|
808
|
+
/>
|
|
809
|
+
</>
|
|
810
|
+
);
|
|
811
|
+
}
|
|
323
812
|
```
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
### 8. Skeleton Loading States
|
|
817
|
+
|
|
818
|
+
```tsx
|
|
819
|
+
import { Skeleton, Card, CardContent, CardHeader } from '@codeswayam/ui';
|
|
820
|
+
|
|
821
|
+
export function AgentCardSkeleton() {
|
|
822
|
+
return (
|
|
823
|
+
<Card>
|
|
824
|
+
<CardHeader className="space-y-2">
|
|
825
|
+
<Skeleton className="h-5 w-1/3" />
|
|
826
|
+
<Skeleton className="h-4 w-2/3" />
|
|
827
|
+
</CardHeader>
|
|
828
|
+
<CardContent className="space-y-3">
|
|
829
|
+
<Skeleton className="h-4 w-full" />
|
|
830
|
+
<Skeleton className="h-4 w-5/6" />
|
|
831
|
+
<Skeleton className="h-4 w-4/6" />
|
|
832
|
+
</CardContent>
|
|
833
|
+
</Card>
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
export function DashboardSkeleton() {
|
|
838
|
+
return (
|
|
839
|
+
<div className="space-y-6">
|
|
840
|
+
{/* Stats row */}
|
|
841
|
+
<div className="grid grid-cols-4 gap-4">
|
|
842
|
+
{Array.from({ length: 4 }).map((_, i) => (
|
|
843
|
+
<Skeleton key={i} className="h-28 rounded-xl" />
|
|
844
|
+
))}
|
|
845
|
+
</div>
|
|
846
|
+
{/* Table */}
|
|
847
|
+
<Skeleton className="h-64 rounded-xl" />
|
|
848
|
+
</div>
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
---
|
|
854
|
+
|
|
855
|
+
## Compatibility Matrix
|
|
856
|
+
|
|
857
|
+
| Environment | Supported | Notes |
|
|
858
|
+
|---|---|---|
|
|
859
|
+
| React 18.x | ✅ | Full support |
|
|
860
|
+
| React 19.x | ✅ | Full support |
|
|
861
|
+
| Next.js 14 (App Router) | ✅ | Import CSS in root layout |
|
|
862
|
+
| Next.js 14 (Pages Router) | ✅ | Import CSS in `_app.tsx` |
|
|
863
|
+
| Next.js 15 | ✅ | Full support |
|
|
864
|
+
| Vite (React) | ✅ | Standard setup |
|
|
865
|
+
| Remix | ✅ | Import CSS in root route |
|
|
866
|
+
| Tailwind CSS 3.x | ✅ | Required — add package to content paths |
|
|
867
|
+
| TypeScript 4.x | ✅ | Minimum supported |
|
|
868
|
+
| TypeScript 5.x | ✅ | Recommended |
|
|
869
|
+
| Dark mode | ✅ | CSS class strategy (`dark` on `<html>`) |
|
|
870
|
+
| SSR | ✅ | All components are SSR-safe |
|
|
871
|
+
| Tree-shaking | ✅ | Named imports are tree-shakeable |
|
|
872
|
+
|
|
873
|
+
---
|
|
874
|
+
|
|
875
|
+
## License
|
|
876
|
+
|
|
877
|
+
MIT © CodeSwayam
|