@nexys/user-management-web 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/components.json +21 -0
- package/package.json +66 -0
- package/src/components/audit/audit-log-table.test.tsx +98 -0
- package/src/components/audit/audit-log-table.tsx +227 -0
- package/src/components/auth/accept-invitation-card.tsx +104 -0
- package/src/components/auth/forgot-password-form.tsx +93 -0
- package/src/components/auth/reset-password-form.tsx +144 -0
- package/src/components/auth/sign-in-form.test.tsx +164 -0
- package/src/components/auth/sign-in-form.tsx +504 -0
- package/src/components/auth/sign-up-form.tsx +124 -0
- package/src/components/layout/app-shell.tsx +189 -0
- package/src/components/layout/auth-shell.tsx +28 -0
- package/src/components/layout/theme-toggle.tsx +55 -0
- package/src/components/layout/user-menu.tsx +84 -0
- package/src/components/primitives/empty-state.tsx +40 -0
- package/src/components/primitives/page-header.tsx +27 -0
- package/src/components/primitives/spinner.tsx +28 -0
- package/src/components/profile/api-tokens-card.tsx +238 -0
- package/src/components/profile/change-password-form.tsx +159 -0
- package/src/components/profile/passkeys-card.tsx +186 -0
- package/src/components/profile/profile-card.tsx +107 -0
- package/src/components/profile/refresh-tokens-list.tsx +176 -0
- package/src/components/profile/two-factor-card.tsx +230 -0
- package/src/components/projects/project-consents.tsx +577 -0
- package/src/components/projects/project-create-dialog.tsx +193 -0
- package/src/components/projects/project-detail-tabs.tsx +64 -0
- package/src/components/projects/project-email-templates.tsx +285 -0
- package/src/components/projects/project-notices.tsx +461 -0
- package/src/components/projects/project-settings.tsx +1059 -0
- package/src/components/projects/project-tenants.tsx +108 -0
- package/src/components/projects/projects-table.test.tsx +109 -0
- package/src/components/projects/projects-table.tsx +240 -0
- package/src/components/roles/role-badge.tsx +91 -0
- package/src/components/roles/role-select.tsx +76 -0
- package/src/components/tenants/tenant-create-dialog.tsx +164 -0
- package/src/components/tenants/tenant-detail-tabs.tsx +51 -0
- package/src/components/tenants/tenant-members.tsx +587 -0
- package/src/components/tenants/tenant-roles.test.tsx +107 -0
- package/src/components/tenants/tenant-roles.tsx +418 -0
- package/src/components/tenants/tenant-settings.tsx +392 -0
- package/src/components/tenants/tenants-table.test.tsx +81 -0
- package/src/components/tenants/tenants-table.tsx +247 -0
- package/src/components/ui/alert.tsx +52 -0
- package/src/components/ui/avatar.tsx +46 -0
- package/src/components/ui/badge.tsx +32 -0
- package/src/components/ui/button.tsx +64 -0
- package/src/components/ui/card.tsx +65 -0
- package/src/components/ui/dialog.tsx +99 -0
- package/src/components/ui/dropdown-menu.tsx +97 -0
- package/src/components/ui/field.tsx +44 -0
- package/src/components/ui/input.tsx +23 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/select.tsx +87 -0
- package/src/components/ui/separator.tsx +22 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +87 -0
- package/src/components/ui/tabs.tsx +51 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +27 -0
- package/src/components/users/user-create-dialog.tsx +229 -0
- package/src/components/users/user-delete-dialog.tsx +88 -0
- package/src/components/users/user-detail.tsx +818 -0
- package/src/components/users/users-table.test.tsx +107 -0
- package/src/components/users/users-table.tsx +386 -0
- package/src/context/auth-context.tsx +127 -0
- package/src/context/theme-context.test.tsx +78 -0
- package/src/context/theme-context.tsx +110 -0
- package/src/hooks/use-call.ts +60 -0
- package/src/index.ts +160 -0
- package/src/lib/error-message.ts +16 -0
- package/src/lib/utils.test.ts +61 -0
- package/src/lib/utils.ts +79 -0
- package/src/lib/webauthn.ts +36 -0
- package/src/styles.css +107 -0
- package/src/test-setup.ts +5 -0
- package/tailwind.preset.cjs +15 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminListTenants,
|
|
3
|
+
listProjects,
|
|
4
|
+
type TenantRow,
|
|
5
|
+
} from "@nexys/user-management-client";
|
|
6
|
+
import {
|
|
7
|
+
AlertCircle,
|
|
8
|
+
ArrowUpDown,
|
|
9
|
+
Building2,
|
|
10
|
+
ListFilter,
|
|
11
|
+
RefreshCcw,
|
|
12
|
+
Search,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
import { useMemo, useState } from "react";
|
|
15
|
+
|
|
16
|
+
import { useCall } from "../../hooks/use-call.js";
|
|
17
|
+
import { errorMessage } from "../../lib/error-message.js";
|
|
18
|
+
import { formatRelative } from "../../lib/utils.js";
|
|
19
|
+
import { EmptyState } from "../primitives/empty-state.js";
|
|
20
|
+
import { Alert, AlertDescription } from "../ui/alert.js";
|
|
21
|
+
import { Badge } from "../ui/badge.js";
|
|
22
|
+
import { Button } from "../ui/button.js";
|
|
23
|
+
import { Input } from "../ui/input.js";
|
|
24
|
+
import {
|
|
25
|
+
Select,
|
|
26
|
+
SelectContent,
|
|
27
|
+
SelectItem,
|
|
28
|
+
SelectTrigger,
|
|
29
|
+
SelectValue,
|
|
30
|
+
} from "../ui/select.js";
|
|
31
|
+
import { Skeleton } from "../ui/skeleton.js";
|
|
32
|
+
import {
|
|
33
|
+
Table,
|
|
34
|
+
TableBody,
|
|
35
|
+
TableCell,
|
|
36
|
+
TableHead,
|
|
37
|
+
TableHeader,
|
|
38
|
+
TableRow,
|
|
39
|
+
} from "../ui/table.js";
|
|
40
|
+
import { TenantCreateDialog } from "./tenant-create-dialog.js";
|
|
41
|
+
|
|
42
|
+
const SORT_OPTIONS: {
|
|
43
|
+
value: string;
|
|
44
|
+
label: string;
|
|
45
|
+
compare: (a: TenantRow, b: TenantRow) => number;
|
|
46
|
+
}[] = [
|
|
47
|
+
{
|
|
48
|
+
value: "name-asc",
|
|
49
|
+
label: "Name A–Z",
|
|
50
|
+
compare: (a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: "base" }),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: "name-desc",
|
|
54
|
+
label: "Name Z–A",
|
|
55
|
+
compare: (a, b) => b.name.localeCompare(a.name, undefined, { sensitivity: "base" }),
|
|
56
|
+
},
|
|
57
|
+
{ value: "created-desc", label: "Newest first", compare: (a, b) => b.createdAt.localeCompare(a.createdAt) },
|
|
58
|
+
{ value: "created-asc", label: "Oldest first", compare: (a, b) => a.createdAt.localeCompare(b.createdAt) },
|
|
59
|
+
{ value: "members-desc", label: "Most members", compare: (a, b) => b.memberCount - a.memberCount },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
export const TenantsTable = ({
|
|
63
|
+
allowCreate = true,
|
|
64
|
+
onSelect,
|
|
65
|
+
}: {
|
|
66
|
+
allowCreate?: boolean;
|
|
67
|
+
onSelect?: (id: string) => void;
|
|
68
|
+
}) => {
|
|
69
|
+
const [query, setQuery] = useState("");
|
|
70
|
+
const [sort, setSort] = useState("name-asc");
|
|
71
|
+
const [productFilter, setProductFilter] = useState("all");
|
|
72
|
+
const { data, error, loading, refresh } = useCall(adminListTenants);
|
|
73
|
+
// Resolve tenant.projectId → product name. Superadmins (the only
|
|
74
|
+
// callers of this table) see every project here.
|
|
75
|
+
const projects = useCall(listProjects);
|
|
76
|
+
const productNames = useMemo(() => {
|
|
77
|
+
const map = new Map<string, string>();
|
|
78
|
+
for (const p of projects.data?.projects ?? []) map.set(p.id, p.name);
|
|
79
|
+
return map;
|
|
80
|
+
}, [projects.data]);
|
|
81
|
+
|
|
82
|
+
const filtered = useMemo(() => {
|
|
83
|
+
let list = data?.tenants ?? [];
|
|
84
|
+
if (productFilter !== "all") {
|
|
85
|
+
list = list.filter((t) =>
|
|
86
|
+
productFilter === "none" ? !t.projectId : t.projectId === productFilter
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const q = query.trim().toLowerCase();
|
|
90
|
+
if (q) {
|
|
91
|
+
list = list.filter(
|
|
92
|
+
(t) =>
|
|
93
|
+
t.name.toLowerCase().includes(q) ||
|
|
94
|
+
t.slug.toLowerCase().includes(q) ||
|
|
95
|
+
t.id.toLowerCase().includes(q)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const compare = (SORT_OPTIONS.find((o) => o.value === sort) ?? SORT_OPTIONS[0]!)
|
|
99
|
+
.compare;
|
|
100
|
+
return [...list].sort(compare);
|
|
101
|
+
}, [data, query, productFilter, sort]);
|
|
102
|
+
|
|
103
|
+
const filterActive = productFilter !== "all";
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className="grid gap-3">
|
|
107
|
+
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
108
|
+
<div className="relative min-w-[14rem] max-w-sm flex-1">
|
|
109
|
+
<Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
|
|
110
|
+
<Input
|
|
111
|
+
value={query}
|
|
112
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
113
|
+
placeholder="Search tenants…"
|
|
114
|
+
className="pl-9"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
118
|
+
<Select value={productFilter} onValueChange={setProductFilter}>
|
|
119
|
+
<SelectTrigger
|
|
120
|
+
className="h-8 w-[10.5rem]"
|
|
121
|
+
aria-label="Filter by product"
|
|
122
|
+
>
|
|
123
|
+
<ListFilter className="size-3.5 text-muted-foreground" />
|
|
124
|
+
<SelectValue />
|
|
125
|
+
</SelectTrigger>
|
|
126
|
+
<SelectContent>
|
|
127
|
+
<SelectItem value="all">All products</SelectItem>
|
|
128
|
+
<SelectItem value="none">No product</SelectItem>
|
|
129
|
+
{(projects.data?.projects ?? []).map((p) => (
|
|
130
|
+
<SelectItem key={p.id} value={p.id}>
|
|
131
|
+
{p.name}
|
|
132
|
+
</SelectItem>
|
|
133
|
+
))}
|
|
134
|
+
</SelectContent>
|
|
135
|
+
</Select>
|
|
136
|
+
<Select value={sort} onValueChange={setSort}>
|
|
137
|
+
<SelectTrigger className="h-8 w-[9.5rem]" aria-label="Sort by">
|
|
138
|
+
<ArrowUpDown className="size-3.5 text-muted-foreground" />
|
|
139
|
+
<SelectValue />
|
|
140
|
+
</SelectTrigger>
|
|
141
|
+
<SelectContent>
|
|
142
|
+
{SORT_OPTIONS.map((o) => (
|
|
143
|
+
<SelectItem key={o.value} value={o.value}>
|
|
144
|
+
{o.label}
|
|
145
|
+
</SelectItem>
|
|
146
|
+
))}
|
|
147
|
+
</SelectContent>
|
|
148
|
+
</Select>
|
|
149
|
+
<Button variant="outline" size="sm" onClick={refresh}>
|
|
150
|
+
<RefreshCcw />
|
|
151
|
+
Refresh
|
|
152
|
+
</Button>
|
|
153
|
+
{allowCreate ? <TenantCreateDialog onCreated={refresh} /> : null}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{error ? (
|
|
158
|
+
<Alert variant="destructive">
|
|
159
|
+
<AlertCircle />
|
|
160
|
+
<AlertDescription>{errorMessage(error)}</AlertDescription>
|
|
161
|
+
</Alert>
|
|
162
|
+
) : null}
|
|
163
|
+
|
|
164
|
+
<div className="overflow-hidden rounded-xl border bg-card">
|
|
165
|
+
<Table>
|
|
166
|
+
<TableHeader>
|
|
167
|
+
<TableRow>
|
|
168
|
+
<TableHead>Tenant</TableHead>
|
|
169
|
+
<TableHead>Slug</TableHead>
|
|
170
|
+
<TableHead>Product</TableHead>
|
|
171
|
+
<TableHead>Members</TableHead>
|
|
172
|
+
<TableHead>Created</TableHead>
|
|
173
|
+
</TableRow>
|
|
174
|
+
</TableHeader>
|
|
175
|
+
<TableBody>
|
|
176
|
+
{loading ? (
|
|
177
|
+
Array.from({ length: 4 }).map((_, i) => (
|
|
178
|
+
<TableRow key={`sk-${i}`}>
|
|
179
|
+
<TableCell><Skeleton className="h-4 w-40" /></TableCell>
|
|
180
|
+
<TableCell><Skeleton className="h-4 w-24" /></TableCell>
|
|
181
|
+
<TableCell><Skeleton className="h-4 w-24" /></TableCell>
|
|
182
|
+
<TableCell><Skeleton className="h-4 w-10" /></TableCell>
|
|
183
|
+
<TableCell><Skeleton className="h-4 w-20" /></TableCell>
|
|
184
|
+
</TableRow>
|
|
185
|
+
))
|
|
186
|
+
) : filtered.length === 0 ? (
|
|
187
|
+
<TableRow>
|
|
188
|
+
<TableCell colSpan={5} className="p-0">
|
|
189
|
+
<EmptyState
|
|
190
|
+
icon={Building2}
|
|
191
|
+
title={
|
|
192
|
+
query || filterActive ? "No tenants match" : "No tenants yet"
|
|
193
|
+
}
|
|
194
|
+
description={
|
|
195
|
+
query || filterActive
|
|
196
|
+
? "Try a different search or filter."
|
|
197
|
+
: "Create the first tenant to get started."
|
|
198
|
+
}
|
|
199
|
+
className="border-0 rounded-none bg-transparent"
|
|
200
|
+
action={
|
|
201
|
+
!query && !filterActive && allowCreate ? (
|
|
202
|
+
<TenantCreateDialog onCreated={refresh} />
|
|
203
|
+
) : undefined
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
206
|
+
</TableCell>
|
|
207
|
+
</TableRow>
|
|
208
|
+
) : (
|
|
209
|
+
filtered.map((t) => (
|
|
210
|
+
<TableRow
|
|
211
|
+
key={t.id}
|
|
212
|
+
className={onSelect ? "cursor-pointer" : undefined}
|
|
213
|
+
onClick={onSelect ? () => onSelect(t.id) : undefined}
|
|
214
|
+
>
|
|
215
|
+
<TableCell>
|
|
216
|
+
<div className="flex items-center gap-2.5">
|
|
217
|
+
<div className="flex size-8 items-center justify-center rounded-md bg-muted text-xs font-semibold uppercase">
|
|
218
|
+
{t.name.slice(0, 2)}
|
|
219
|
+
</div>
|
|
220
|
+
<span className="font-medium">{t.name}</span>
|
|
221
|
+
</div>
|
|
222
|
+
</TableCell>
|
|
223
|
+
<TableCell className="font-mono text-xs">{t.slug}</TableCell>
|
|
224
|
+
<TableCell>
|
|
225
|
+
{t.projectId ? (
|
|
226
|
+
<Badge variant="muted">
|
|
227
|
+
{productNames.get(t.projectId) ?? t.projectId}
|
|
228
|
+
</Badge>
|
|
229
|
+
) : (
|
|
230
|
+
<span className="text-muted-foreground text-xs">—</span>
|
|
231
|
+
)}
|
|
232
|
+
</TableCell>
|
|
233
|
+
<TableCell>
|
|
234
|
+
<Badge variant="muted">{t.memberCount}</Badge>
|
|
235
|
+
</TableCell>
|
|
236
|
+
<TableCell title={t.createdAt} className="text-sm text-muted-foreground">
|
|
237
|
+
{formatRelative(t.createdAt)}
|
|
238
|
+
</TableCell>
|
|
239
|
+
</TableRow>
|
|
240
|
+
))
|
|
241
|
+
)}
|
|
242
|
+
</TableBody>
|
|
243
|
+
</Table>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
|
|
6
|
+
const alertVariants = cva(
|
|
7
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm grid grid-cols-[16px_1fr] gap-x-3 gap-y-1 [&>svg]:size-4 [&>svg]:translate-y-0.5",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-background text-foreground border-border",
|
|
12
|
+
destructive:
|
|
13
|
+
"border-destructive/40 bg-destructive/10 text-destructive [&>svg]:text-destructive",
|
|
14
|
+
warning:
|
|
15
|
+
"border-warning/40 bg-warning/10 text-warning-foreground [&>svg]:text-warning",
|
|
16
|
+
success:
|
|
17
|
+
"border-success/40 bg-success/10 text-success-foreground [&>svg]:text-success",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: { variant: "default" },
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export interface AlertProps
|
|
25
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
26
|
+
VariantProps<typeof alertVariants> {}
|
|
27
|
+
|
|
28
|
+
export const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
|
29
|
+
({ className, variant, ...props }, ref) => (
|
|
30
|
+
<div
|
|
31
|
+
ref={ref}
|
|
32
|
+
role="alert"
|
|
33
|
+
className={cn(alertVariants({ variant }), className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
Alert.displayName = "Alert";
|
|
39
|
+
|
|
40
|
+
export const AlertTitle = ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
|
|
41
|
+
<h5
|
|
42
|
+
className={cn("col-start-2 font-medium leading-tight", className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const AlertDescription = ({
|
|
48
|
+
className,
|
|
49
|
+
...props
|
|
50
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
51
|
+
<div className={cn("col-start-2 text-sm opacity-90", className)} {...props} />
|
|
52
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
|
|
6
|
+
export const Avatar = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<AvatarPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
"relative flex size-9 shrink-0 overflow-hidden rounded-full",
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
));
|
|
19
|
+
Avatar.displayName = "Avatar";
|
|
20
|
+
|
|
21
|
+
export const AvatarImage = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
24
|
+
>(({ className, ...props }, ref) => (
|
|
25
|
+
<AvatarPrimitive.Image
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn("aspect-square h-full w-full", className)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
));
|
|
31
|
+
AvatarImage.displayName = "AvatarImage";
|
|
32
|
+
|
|
33
|
+
export const AvatarFallback = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
36
|
+
>(({ className, ...props }, ref) => (
|
|
37
|
+
<AvatarPrimitive.Fallback
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
"flex h-full w-full items-center justify-center rounded-full bg-muted text-xs font-medium uppercase text-muted-foreground",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
));
|
|
46
|
+
AvatarFallback.displayName = "AvatarFallback";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring/40 focus:ring-offset-2",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "border-transparent bg-primary text-primary-foreground",
|
|
12
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground",
|
|
13
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground",
|
|
14
|
+
outline: "text-foreground",
|
|
15
|
+
success: "border-transparent bg-success text-success-foreground",
|
|
16
|
+
warning: "border-transparent bg-warning text-warning-foreground",
|
|
17
|
+
muted: "border-transparent bg-muted text-muted-foreground",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: { variant: "default" },
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export interface BadgeProps
|
|
25
|
+
extends React.HTMLAttributes<HTMLSpanElement>,
|
|
26
|
+
VariantProps<typeof badgeVariants> {}
|
|
27
|
+
|
|
28
|
+
export const Badge = ({ className, variant, ...props }: BadgeProps) => (
|
|
29
|
+
<span className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export { badgeVariants };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
15
|
+
outline:
|
|
16
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
17
|
+
secondary:
|
|
18
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
19
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
25
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
26
|
+
icon: "size-9",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: { variant: "default", size: "default" },
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export interface ButtonProps
|
|
34
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
35
|
+
VariantProps<typeof buttonVariants> {
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
loading?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
41
|
+
({ className, variant, size, asChild, loading, disabled, children, ...props }, ref) => {
|
|
42
|
+
const Comp = asChild ? Slot : "button";
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(buttonVariants({ variant, size }), className)}
|
|
47
|
+
disabled={disabled || loading}
|
|
48
|
+
data-loading={loading || undefined}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{loading ? (
|
|
52
|
+
<span
|
|
53
|
+
className="size-4 animate-spin rounded-full border-2 border-current border-r-transparent"
|
|
54
|
+
aria-hidden
|
|
55
|
+
/>
|
|
56
|
+
) : null}
|
|
57
|
+
{children}
|
|
58
|
+
</Comp>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
Button.displayName = "Button";
|
|
63
|
+
|
|
64
|
+
export { buttonVariants };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
6
|
+
({ className, ...props }, ref) => (
|
|
7
|
+
<div
|
|
8
|
+
ref={ref}
|
|
9
|
+
className={cn(
|
|
10
|
+
"rounded-xl border bg-card text-card-foreground shadow-sm",
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
Card.displayName = "Card";
|
|
18
|
+
|
|
19
|
+
export const CardHeader = React.forwardRef<
|
|
20
|
+
HTMLDivElement,
|
|
21
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
22
|
+
>(({ className, ...props }, ref) => (
|
|
23
|
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
24
|
+
));
|
|
25
|
+
CardHeader.displayName = "CardHeader";
|
|
26
|
+
|
|
27
|
+
export const CardTitle = React.forwardRef<
|
|
28
|
+
HTMLHeadingElement,
|
|
29
|
+
React.HTMLAttributes<HTMLHeadingElement>
|
|
30
|
+
>(({ className, ...props }, ref) => (
|
|
31
|
+
<h3
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
));
|
|
37
|
+
CardTitle.displayName = "CardTitle";
|
|
38
|
+
|
|
39
|
+
export const CardDescription = React.forwardRef<
|
|
40
|
+
HTMLParagraphElement,
|
|
41
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
42
|
+
>(({ className, ...props }, ref) => (
|
|
43
|
+
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
44
|
+
));
|
|
45
|
+
CardDescription.displayName = "CardDescription";
|
|
46
|
+
|
|
47
|
+
export const CardContent = React.forwardRef<
|
|
48
|
+
HTMLDivElement,
|
|
49
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
50
|
+
>(({ className, ...props }, ref) => (
|
|
51
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
52
|
+
));
|
|
53
|
+
CardContent.displayName = "CardContent";
|
|
54
|
+
|
|
55
|
+
export const CardFooter = React.forwardRef<
|
|
56
|
+
HTMLDivElement,
|
|
57
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<div
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
));
|
|
65
|
+
CardFooter.displayName = "CardFooter";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
|
|
7
|
+
export const Dialog = DialogPrimitive.Root;
|
|
8
|
+
export const DialogTrigger = DialogPrimitive.Trigger;
|
|
9
|
+
export const DialogPortal = DialogPrimitive.Portal;
|
|
10
|
+
export const DialogClose = DialogPrimitive.Close;
|
|
11
|
+
|
|
12
|
+
export const DialogOverlay = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<DialogPrimitive.Overlay
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(
|
|
19
|
+
"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",
|
|
20
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
21
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
DialogOverlay.displayName = "DialogOverlay";
|
|
28
|
+
|
|
29
|
+
export const DialogContent = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
32
|
+
>(({ className, children, ...props }, ref) => (
|
|
33
|
+
<DialogPortal>
|
|
34
|
+
<DialogOverlay />
|
|
35
|
+
<DialogPrimitive.Content
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4",
|
|
39
|
+
"border bg-background p-6 shadow-xl sm:rounded-xl",
|
|
40
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
41
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
42
|
+
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
<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">
|
|
49
|
+
<X className="size-4" />
|
|
50
|
+
<span className="sr-only">Close</span>
|
|
51
|
+
</DialogPrimitive.Close>
|
|
52
|
+
</DialogPrimitive.Content>
|
|
53
|
+
</DialogPortal>
|
|
54
|
+
));
|
|
55
|
+
DialogContent.displayName = "DialogContent";
|
|
56
|
+
|
|
57
|
+
export const DialogHeader = ({
|
|
58
|
+
className,
|
|
59
|
+
...props
|
|
60
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
61
|
+
<div
|
|
62
|
+
className={cn("flex flex-col gap-1.5 text-left", className)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const DialogFooter = ({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
71
|
+
<div
|
|
72
|
+
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
export const DialogTitle = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
79
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
80
|
+
>(({ className, ...props }, ref) => (
|
|
81
|
+
<DialogPrimitive.Title
|
|
82
|
+
ref={ref}
|
|
83
|
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
));
|
|
87
|
+
DialogTitle.displayName = "DialogTitle";
|
|
88
|
+
|
|
89
|
+
export const DialogDescription = React.forwardRef<
|
|
90
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
91
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
92
|
+
>(({ className, ...props }, ref) => (
|
|
93
|
+
<DialogPrimitive.Description
|
|
94
|
+
ref={ref}
|
|
95
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
));
|
|
99
|
+
DialogDescription.displayName = "DialogDescription";
|