@cortexasystem/ui 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/assets/isotipo-cortexa-dark.png +0 -0
- package/src/assets/isotipo-cortexa-light.png +0 -0
- package/src/components/ai/ai-chat.tsx +597 -0
- package/src/components/branding/brand-logo.tsx +77 -0
- package/src/components/data-display/icons.tsx +81 -0
- package/src/components/data-display/profile-avatar.tsx +154 -0
- package/src/components/data-display/typography.tsx +46 -0
- package/src/components/feedback/empty-state.tsx +63 -0
- package/src/components/feedback/loading-state.tsx +93 -0
- package/src/components/feedback/module-skeleton.tsx +76 -0
- package/src/components/feedback/notification.tsx +111 -0
- package/src/components/feedback/skeleton.tsx +9 -0
- package/src/components/feedback/spinner.tsx +18 -0
- package/src/components/feedback/status-badge.tsx +44 -0
- package/src/components/feedback/sync-status-badge.tsx +54 -0
- package/src/components/feedback/sync-status-bar.tsx +92 -0
- package/src/components/feedback/toaster.tsx +36 -0
- package/src/components/forms/searchable-select.tsx +206 -0
- package/src/components/forms/select.tsx +142 -0
- package/src/components/layout/app-shell.tsx +44 -0
- package/src/components/layout/form-section.tsx +21 -0
- package/src/components/layout/page-header.tsx +21 -0
- package/src/components/layout/theme-toggle.tsx +33 -0
- package/src/components/navigation/breadcrumb.tsx +87 -0
- package/src/components/navigation/header-user-menu.tsx +108 -0
- package/src/components/navigation/navbar.tsx +30 -0
- package/src/components/navigation/page-breadcrumb.tsx +44 -0
- package/src/components/navigation/sidebar.tsx +104 -0
- package/src/components/navigation/steps.tsx +82 -0
- package/src/components/overlays/dialog.tsx +94 -0
- package/src/components/overlays/drawer.tsx +85 -0
- package/src/components/overlays/dropdown-menu.tsx +179 -0
- package/src/components/overlays/sheet.tsx +110 -0
- package/src/components/primitives/alert.tsx +43 -0
- package/src/components/primitives/avatar.tsx +41 -0
- package/src/components/primitives/badge.tsx +26 -0
- package/src/components/primitives/button.tsx +49 -0
- package/src/components/primitives/card.tsx +97 -0
- package/src/components/primitives/checkbox.tsx +52 -0
- package/src/components/primitives/input.tsx +23 -0
- package/src/components/primitives/label.tsx +18 -0
- package/src/components/primitives/radio-group.tsx +57 -0
- package/src/components/primitives/separator.tsx +23 -0
- package/src/components/primitives/switch.tsx +75 -0
- package/src/components/primitives/textarea.tsx +18 -0
- package/src/components/tables/data-table.tsx +214 -0
- package/src/components/tables/data-table.types.ts +9 -0
- package/src/components/tables/table-row-actions.tsx +61 -0
- package/src/components/tables/table.tsx +88 -0
- package/src/declarations.d.ts +14 -0
- package/src/index.ts +50 -0
- package/src/lib/cn.ts +6 -0
- package/src/providers/theme-provider.tsx +90 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Moon, Sun } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/cn";
|
|
4
|
+
import { useTheme } from "../../providers/theme-provider";
|
|
5
|
+
|
|
6
|
+
const options = [
|
|
7
|
+
{ value: "light", Icon: Sun, label: "Light" },
|
|
8
|
+
{ value: "dark", Icon: Moon, label: "Dark" }
|
|
9
|
+
] as const;
|
|
10
|
+
|
|
11
|
+
export function ThemeToggle({ className }: { className?: string }) {
|
|
12
|
+
const { theme, setTheme } = useTheme();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className={cn("flex items-center gap-1 rounded-lg border border-border bg-muted p-1", className)}>
|
|
16
|
+
{options.map(({ value, Icon, label }) => (
|
|
17
|
+
<button
|
|
18
|
+
key={value}
|
|
19
|
+
type="button"
|
|
20
|
+
onClick={() => setTheme(value)}
|
|
21
|
+
aria-label={label}
|
|
22
|
+
className={cn(
|
|
23
|
+
"flex cursor-pointer items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-all",
|
|
24
|
+
theme === value ? "bg-card text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
<Icon size={13} />
|
|
28
|
+
<span>{label}</span>
|
|
29
|
+
</button>
|
|
30
|
+
))}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/cn";
|
|
6
|
+
|
|
7
|
+
const Breadcrumb = React.forwardRef<
|
|
8
|
+
HTMLElement,
|
|
9
|
+
React.ComponentPropsWithoutRef<"nav"> & {
|
|
10
|
+
separator?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
13
|
+
|
|
14
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
15
|
+
|
|
16
|
+
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<"ol">>(
|
|
17
|
+
({ className, ...props }, ref) => (
|
|
18
|
+
<ol
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5", className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
27
|
+
|
|
28
|
+
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<"li">>(
|
|
29
|
+
({ className, ...props }, ref) => <li ref={ref} className={cn("inline-flex items-center gap-1.5", className)} {...props} />
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
33
|
+
|
|
34
|
+
const BreadcrumbLink = React.forwardRef<
|
|
35
|
+
HTMLAnchorElement,
|
|
36
|
+
React.ComponentPropsWithoutRef<"a"> & {
|
|
37
|
+
asChild?: boolean;
|
|
38
|
+
}
|
|
39
|
+
>(({ asChild, className, ...props }, ref) => {
|
|
40
|
+
const Comp = asChild ? Slot : "a";
|
|
41
|
+
|
|
42
|
+
return <Comp ref={ref} className={cn("transition-colors hover:text-foreground", className)} {...props} />;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
46
|
+
|
|
47
|
+
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<"span">>(
|
|
48
|
+
({ className, ...props }, ref) => (
|
|
49
|
+
<span
|
|
50
|
+
ref={ref}
|
|
51
|
+
role="link"
|
|
52
|
+
aria-disabled="true"
|
|
53
|
+
aria-current="page"
|
|
54
|
+
className={cn("font-normal text-foreground", className)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
61
|
+
|
|
62
|
+
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<"li">) => (
|
|
63
|
+
<li role="presentation" aria-hidden="true" className={cn("[&>svg]:h-3.5 [&>svg]:w-3.5", className)} {...props}>
|
|
64
|
+
{children ?? <ChevronRight />}
|
|
65
|
+
</li>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
69
|
+
|
|
70
|
+
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
|
71
|
+
<span role="presentation" aria-hidden="true" className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
|
|
72
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
73
|
+
<span className="sr-only">More</span>
|
|
74
|
+
</span>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
Breadcrumb,
|
|
81
|
+
BreadcrumbList,
|
|
82
|
+
BreadcrumbItem,
|
|
83
|
+
BreadcrumbLink,
|
|
84
|
+
BreadcrumbPage,
|
|
85
|
+
BreadcrumbSeparator,
|
|
86
|
+
BreadcrumbEllipsis
|
|
87
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { LogOut } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DropdownMenu,
|
|
6
|
+
DropdownMenuContent,
|
|
7
|
+
DropdownMenuItem,
|
|
8
|
+
DropdownMenuLabel,
|
|
9
|
+
DropdownMenuSeparator,
|
|
10
|
+
DropdownMenuTrigger
|
|
11
|
+
} from "../overlays/dropdown-menu";
|
|
12
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../primitives/avatar";
|
|
13
|
+
import { Badge } from "../primitives/badge";
|
|
14
|
+
import { cn } from "../../lib/cn";
|
|
15
|
+
|
|
16
|
+
function getInitials(name: string) {
|
|
17
|
+
return name
|
|
18
|
+
.trim()
|
|
19
|
+
.split(" ")
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.slice(0, 2)
|
|
22
|
+
.map((part) => part[0]?.toUpperCase() ?? "")
|
|
23
|
+
.join("");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface HeaderUserMenuProps {
|
|
27
|
+
className?: string;
|
|
28
|
+
name: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
role?: string;
|
|
31
|
+
initials?: string;
|
|
32
|
+
avatarSrc?: string;
|
|
33
|
+
logoutLabel?: string;
|
|
34
|
+
onLogout?: () => void;
|
|
35
|
+
extraItems?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function HeaderUserMenu({
|
|
39
|
+
className,
|
|
40
|
+
name,
|
|
41
|
+
email,
|
|
42
|
+
role,
|
|
43
|
+
initials,
|
|
44
|
+
avatarSrc,
|
|
45
|
+
logoutLabel = "Cerrar sesion",
|
|
46
|
+
onLogout,
|
|
47
|
+
extraItems
|
|
48
|
+
}: HeaderUserMenuProps) {
|
|
49
|
+
return (
|
|
50
|
+
<DropdownMenu>
|
|
51
|
+
<DropdownMenuTrigger asChild>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
aria-label="Menu de usuario"
|
|
55
|
+
className={cn(
|
|
56
|
+
"flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
<Avatar className="h-8 w-8">
|
|
61
|
+
{avatarSrc ? <AvatarImage src={avatarSrc} alt={name} /> : null}
|
|
62
|
+
<AvatarFallback className="bg-primary text-xs font-semibold text-primary-foreground">
|
|
63
|
+
{initials ?? getInitials(name)}
|
|
64
|
+
</AvatarFallback>
|
|
65
|
+
</Avatar>
|
|
66
|
+
</button>
|
|
67
|
+
</DropdownMenuTrigger>
|
|
68
|
+
|
|
69
|
+
<DropdownMenuContent align="end" className="w-60">
|
|
70
|
+
<DropdownMenuLabel className="font-normal">
|
|
71
|
+
<div className="flex gap-2">
|
|
72
|
+
<div className="grid min-w-0 flex-1 gap-1">
|
|
73
|
+
<p className="truncate text-sm font-semibold text-foreground">{name}</p>
|
|
74
|
+
{email ? <p className="truncate text-xs text-muted-foreground">{email}</p> : null}
|
|
75
|
+
</div>
|
|
76
|
+
{role ? (
|
|
77
|
+
<Badge variant="outline" className="h-fit max-w-[110px] truncate">
|
|
78
|
+
{role}
|
|
79
|
+
</Badge>
|
|
80
|
+
) : null}
|
|
81
|
+
</div>
|
|
82
|
+
</DropdownMenuLabel>
|
|
83
|
+
|
|
84
|
+
{extraItems ? (
|
|
85
|
+
<>
|
|
86
|
+
<DropdownMenuSeparator />
|
|
87
|
+
{extraItems}
|
|
88
|
+
</>
|
|
89
|
+
) : null}
|
|
90
|
+
|
|
91
|
+
{onLogout ? (
|
|
92
|
+
<>
|
|
93
|
+
<DropdownMenuSeparator />
|
|
94
|
+
<DropdownMenuItem
|
|
95
|
+
onClick={onLogout}
|
|
96
|
+
className="cursor-pointer gap-2 text-destructive focus:bg-destructive/10 focus:text-destructive"
|
|
97
|
+
>
|
|
98
|
+
<LogOut className="h-4 w-4" />
|
|
99
|
+
{logoutLabel}
|
|
100
|
+
</DropdownMenuItem>
|
|
101
|
+
</>
|
|
102
|
+
) : null}
|
|
103
|
+
</DropdownMenuContent>
|
|
104
|
+
</DropdownMenu>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type { HeaderUserMenuProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Menu } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/cn";
|
|
5
|
+
import { Button } from "../primitives/button";
|
|
6
|
+
|
|
7
|
+
interface NavbarProps {
|
|
8
|
+
brand?: ReactNode;
|
|
9
|
+
actions?: ReactNode;
|
|
10
|
+
onMenuClick?: () => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function Navbar({ brand, actions, onMenuClick, className }: NavbarProps) {
|
|
15
|
+
return (
|
|
16
|
+
<header className={cn("h-14 shrink-0 border-b border-border bg-card/80 px-4 backdrop-blur-sm", className)}>
|
|
17
|
+
<div className="mx-auto flex h-full w-full max-w-7xl items-center justify-between gap-3">
|
|
18
|
+
<div className="flex min-w-0 flex-1 items-center gap-3">
|
|
19
|
+
{onMenuClick ? (
|
|
20
|
+
<Button type="button" variant="ghost" size="icon" onClick={onMenuClick} aria-label="Open navigation">
|
|
21
|
+
<Menu size={20} />
|
|
22
|
+
</Button>
|
|
23
|
+
) : null}
|
|
24
|
+
{brand}
|
|
25
|
+
</div>
|
|
26
|
+
{actions ? <div className="flex shrink-0 items-center gap-3">{actions}</div> : null}
|
|
27
|
+
</div>
|
|
28
|
+
</header>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Fragment } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Breadcrumb,
|
|
5
|
+
BreadcrumbItem,
|
|
6
|
+
BreadcrumbLink,
|
|
7
|
+
BreadcrumbList,
|
|
8
|
+
BreadcrumbPage,
|
|
9
|
+
BreadcrumbSeparator
|
|
10
|
+
} from "./breadcrumb";
|
|
11
|
+
|
|
12
|
+
export interface BreadcrumbItemDef {
|
|
13
|
+
label: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface PageBreadcrumbProps {
|
|
18
|
+
items: BreadcrumbItemDef[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function PageBreadcrumb({ items }: PageBreadcrumbProps) {
|
|
22
|
+
return (
|
|
23
|
+
<Breadcrumb>
|
|
24
|
+
<BreadcrumbList>
|
|
25
|
+
{items.map((item, index) => {
|
|
26
|
+
const isLast = index === items.length - 1;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Fragment key={`${item.label}-${index}`}>
|
|
30
|
+
<BreadcrumbItem>
|
|
31
|
+
{!isLast && item.href ? (
|
|
32
|
+
<BreadcrumbLink href={item.href}>{item.label}</BreadcrumbLink>
|
|
33
|
+
) : (
|
|
34
|
+
<BreadcrumbPage>{item.label}</BreadcrumbPage>
|
|
35
|
+
)}
|
|
36
|
+
</BreadcrumbItem>
|
|
37
|
+
{!isLast ? <BreadcrumbSeparator /> : null}
|
|
38
|
+
</Fragment>
|
|
39
|
+
);
|
|
40
|
+
})}
|
|
41
|
+
</BreadcrumbList>
|
|
42
|
+
</Breadcrumb>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { LucideIcon } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/cn";
|
|
5
|
+
import { Avatar, AvatarFallback } from "../primitives/avatar";
|
|
6
|
+
import { Button } from "../primitives/button";
|
|
7
|
+
|
|
8
|
+
export interface SidebarNavItem {
|
|
9
|
+
label: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
active?: boolean;
|
|
12
|
+
icon?: LucideIcon;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SidebarGroup {
|
|
17
|
+
label: string;
|
|
18
|
+
items: SidebarNavItem[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SidebarProps {
|
|
22
|
+
brand?: ReactNode;
|
|
23
|
+
groups: SidebarGroup[];
|
|
24
|
+
user?: {
|
|
25
|
+
name: string;
|
|
26
|
+
role?: string;
|
|
27
|
+
initials?: string;
|
|
28
|
+
};
|
|
29
|
+
footerAction?: {
|
|
30
|
+
label: string;
|
|
31
|
+
onClick?: () => void;
|
|
32
|
+
};
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getInitials(name: string) {
|
|
37
|
+
return name
|
|
38
|
+
.trim()
|
|
39
|
+
.split(" ")
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.slice(0, 2)
|
|
42
|
+
.map((part) => part[0]?.toUpperCase() ?? "")
|
|
43
|
+
.join("");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function Sidebar({ brand, groups, user, footerAction, className }: SidebarProps) {
|
|
47
|
+
return (
|
|
48
|
+
<aside className={cn("flex h-full w-72 max-w-[85vw] flex-col border-r border-border bg-background", className)}>
|
|
49
|
+
<div className="border-b border-border px-5 py-4">{brand}</div>
|
|
50
|
+
<nav className="flex-1 space-y-6 overflow-y-auto px-3 py-4">
|
|
51
|
+
{groups.map((group) => (
|
|
52
|
+
<div key={group.label}>
|
|
53
|
+
<p className="mb-2 px-2 text-xs font-semibold uppercase tracking-widest text-muted-foreground">
|
|
54
|
+
{group.label}
|
|
55
|
+
</p>
|
|
56
|
+
<ul className="space-y-0.5">
|
|
57
|
+
{group.items.map((item) => {
|
|
58
|
+
const Icon = item.icon;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<li key={`${group.label}-${item.label}`}>
|
|
62
|
+
<a
|
|
63
|
+
href={item.href}
|
|
64
|
+
onClick={item.onClick}
|
|
65
|
+
className={cn(
|
|
66
|
+
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors",
|
|
67
|
+
item.active
|
|
68
|
+
? "bg-primary text-primary-foreground"
|
|
69
|
+
: "text-foreground hover:bg-accent hover:text-accent-foreground"
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
{Icon ? <Icon size={17} className="shrink-0" /> : null}
|
|
73
|
+
<span className="flex-1">{item.label}</span>
|
|
74
|
+
</a>
|
|
75
|
+
</li>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</ul>
|
|
79
|
+
</div>
|
|
80
|
+
))}
|
|
81
|
+
</nav>
|
|
82
|
+
{user ? (
|
|
83
|
+
<div className="border-t border-border px-5 py-4">
|
|
84
|
+
<div className="flex items-center gap-3">
|
|
85
|
+
<Avatar className="h-9 w-9 shrink-0">
|
|
86
|
+
<AvatarFallback className="bg-primary text-xs font-semibold text-primary-foreground">
|
|
87
|
+
{user.initials ?? getInitials(user.name)}
|
|
88
|
+
</AvatarFallback>
|
|
89
|
+
</Avatar>
|
|
90
|
+
<div className="min-w-0 flex-1">
|
|
91
|
+
<p className="truncate text-sm font-medium text-foreground">{user.name}</p>
|
|
92
|
+
{user.role ? <p className="truncate text-xs text-muted-foreground">{user.role}</p> : null}
|
|
93
|
+
</div>
|
|
94
|
+
{footerAction ? (
|
|
95
|
+
<Button type="button" variant="ghost" size="sm" onClick={footerAction.onClick}>
|
|
96
|
+
{footerAction.label}
|
|
97
|
+
</Button>
|
|
98
|
+
) : null}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
) : null}
|
|
102
|
+
</aside>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AlertCircle, Check } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/cn";
|
|
4
|
+
|
|
5
|
+
type StepStatus = "complete" | "current" | "upcoming" | "error";
|
|
6
|
+
|
|
7
|
+
interface StepItem {
|
|
8
|
+
id?: string;
|
|
9
|
+
title: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
status?: StepStatus;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface StepsProps {
|
|
15
|
+
className?: string;
|
|
16
|
+
items: StepItem[];
|
|
17
|
+
orientation?: "horizontal" | "vertical";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const indicatorStyles: Record<StepStatus, string> = {
|
|
21
|
+
complete: "border-primary bg-primary text-primary-foreground",
|
|
22
|
+
current: "border-primary bg-primary/10 text-primary",
|
|
23
|
+
upcoming: "border-border bg-background text-muted-foreground",
|
|
24
|
+
error: "border-destructive bg-destructive/10 text-destructive"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function Steps({ className, items, orientation = "horizontal" }: StepsProps) {
|
|
28
|
+
return (
|
|
29
|
+
<ol className={cn("flex", orientation === "horizontal" ? "flex-col gap-4 md:flex-row" : "flex-col", className)}>
|
|
30
|
+
{items.map((item, index) => {
|
|
31
|
+
const status = item.status ?? "upcoming";
|
|
32
|
+
const isLast = index === items.length - 1;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<li
|
|
36
|
+
key={item.id ?? item.title}
|
|
37
|
+
className={cn("relative", orientation === "horizontal" ? "flex-1" : "pb-6 last:pb-0")}
|
|
38
|
+
>
|
|
39
|
+
{!isLast ? (
|
|
40
|
+
<span
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
className={cn(
|
|
43
|
+
"absolute bg-border",
|
|
44
|
+
orientation === "horizontal"
|
|
45
|
+
? "left-[calc(50%+1rem)] top-4 hidden h-px w-[calc(100%-1rem)] md:block"
|
|
46
|
+
: "left-4 top-9 h-[calc(100%-1rem)] w-px"
|
|
47
|
+
)}
|
|
48
|
+
/>
|
|
49
|
+
) : null}
|
|
50
|
+
|
|
51
|
+
<div className={cn(
|
|
52
|
+
orientation === "horizontal"
|
|
53
|
+
? "flex flex-col items-center gap-2 text-center"
|
|
54
|
+
: "flex items-start gap-3"
|
|
55
|
+
)}>
|
|
56
|
+
<span
|
|
57
|
+
className={cn(
|
|
58
|
+
"relative z-10 inline-flex h-8 w-8 items-center justify-center rounded-full border text-sm font-semibold shadow-sm",
|
|
59
|
+
indicatorStyles[status]
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
{status === "complete" ? <Check className="h-4 w-4" /> : null}
|
|
63
|
+
{status === "error" ? <AlertCircle className="h-4 w-4" /> : null}
|
|
64
|
+
{status === "current" || status === "upcoming" ? index + 1 : null}
|
|
65
|
+
</span>
|
|
66
|
+
|
|
67
|
+
<div className={cn("grid gap-1", orientation === "vertical" && "pt-1")}>
|
|
68
|
+
<p className={cn("text-sm font-medium", status === "upcoming" ? "text-muted-foreground" : "text-foreground")}>
|
|
69
|
+
{item.title}
|
|
70
|
+
</p>
|
|
71
|
+
{item.description ? <p className="text-xs text-muted-foreground">{item.description}</p> : null}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</li>
|
|
75
|
+
);
|
|
76
|
+
})}
|
|
77
|
+
</ol>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { Steps };
|
|
82
|
+
export type { StepItem, StepStatus };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/cn";
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root;
|
|
8
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
9
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
10
|
+
const DialogClose = DialogPrimitive.Close;
|
|
11
|
+
|
|
12
|
+
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/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
27
|
+
|
|
28
|
+
const DialogContent = React.forwardRef<
|
|
29
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
30
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
31
|
+
>(({ className, children, ...props }, ref) => (
|
|
32
|
+
<DialogPortal>
|
|
33
|
+
<DialogOverlay />
|
|
34
|
+
<DialogPrimitive.Content
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(
|
|
37
|
+
"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",
|
|
38
|
+
className
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
<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">
|
|
44
|
+
<X className="h-4 w-4" />
|
|
45
|
+
<span className="sr-only">Close</span>
|
|
46
|
+
</DialogPrimitive.Close>
|
|
47
|
+
</DialogPrimitive.Content>
|
|
48
|
+
</DialogPortal>
|
|
49
|
+
));
|
|
50
|
+
|
|
51
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
52
|
+
|
|
53
|
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
54
|
+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
DialogHeader.displayName = "DialogHeader";
|
|
58
|
+
|
|
59
|
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
+
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
DialogFooter.displayName = "DialogFooter";
|
|
64
|
+
|
|
65
|
+
const DialogTitle = React.forwardRef<
|
|
66
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
67
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
68
|
+
>(({ className, ...props }, ref) => (
|
|
69
|
+
<DialogPrimitive.Title ref={ref} className={cn("text-lg font-semibold leading-none tracking-tight", className)} {...props} />
|
|
70
|
+
));
|
|
71
|
+
|
|
72
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
73
|
+
|
|
74
|
+
const DialogDescription = React.forwardRef<
|
|
75
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
77
|
+
>(({ className, ...props }, ref) => (
|
|
78
|
+
<DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
79
|
+
));
|
|
80
|
+
|
|
81
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
Dialog,
|
|
85
|
+
DialogPortal,
|
|
86
|
+
DialogOverlay,
|
|
87
|
+
DialogClose,
|
|
88
|
+
DialogTrigger,
|
|
89
|
+
DialogContent,
|
|
90
|
+
DialogHeader,
|
|
91
|
+
DialogFooter,
|
|
92
|
+
DialogTitle,
|
|
93
|
+
DialogDescription
|
|
94
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/cn";
|
|
5
|
+
|
|
6
|
+
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
7
|
+
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
Drawer.displayName = "Drawer";
|
|
11
|
+
|
|
12
|
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
13
|
+
const DrawerPortal = DrawerPrimitive.Portal;
|
|
14
|
+
const DrawerClose = DrawerPrimitive.Close;
|
|
15
|
+
|
|
16
|
+
const DrawerOverlay = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
|
19
|
+
>(({ className, ...props }, ref) => (
|
|
20
|
+
<DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
|
|
21
|
+
));
|
|
22
|
+
|
|
23
|
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
24
|
+
|
|
25
|
+
const DrawerContent = React.forwardRef<
|
|
26
|
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
|
28
|
+
>(({ className, children, ...props }, ref) => (
|
|
29
|
+
<DrawerPortal>
|
|
30
|
+
<DrawerOverlay />
|
|
31
|
+
<DrawerPrimitive.Content
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
|
37
|
+
{children}
|
|
38
|
+
</DrawerPrimitive.Content>
|
|
39
|
+
</DrawerPortal>
|
|
40
|
+
));
|
|
41
|
+
|
|
42
|
+
DrawerContent.displayName = "DrawerContent";
|
|
43
|
+
|
|
44
|
+
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
45
|
+
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
49
|
+
|
|
50
|
+
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
51
|
+
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
55
|
+
|
|
56
|
+
const DrawerTitle = React.forwardRef<
|
|
57
|
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
|
58
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
|
59
|
+
>(({ className, ...props }, ref) => (
|
|
60
|
+
<DrawerPrimitive.Title ref={ref} className={cn("text-lg font-semibold leading-none tracking-tight", className)} {...props} />
|
|
61
|
+
));
|
|
62
|
+
|
|
63
|
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
64
|
+
|
|
65
|
+
const DrawerDescription = React.forwardRef<
|
|
66
|
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
67
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
|
68
|
+
>(({ className, ...props }, ref) => (
|
|
69
|
+
<DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
70
|
+
));
|
|
71
|
+
|
|
72
|
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
Drawer,
|
|
76
|
+
DrawerPortal,
|
|
77
|
+
DrawerOverlay,
|
|
78
|
+
DrawerTrigger,
|
|
79
|
+
DrawerClose,
|
|
80
|
+
DrawerContent,
|
|
81
|
+
DrawerHeader,
|
|
82
|
+
DrawerFooter,
|
|
83
|
+
DrawerTitle,
|
|
84
|
+
DrawerDescription
|
|
85
|
+
};
|