@ancatag/at-design 0.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 +537 -0
- package/dist/components/Sheet.d.ts +20 -0
- package/dist/components/Sheet.d.ts.map +1 -0
- package/dist/components/Sheet.js +26 -0
- package/dist/components/Sheet.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +21 -0
- package/dist/components/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog.js +27 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +9 -0
- package/dist/components/alert.d.ts.map +1 -0
- package/dist/components/alert.js +23 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.d.ts +7 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +12 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +21 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/bottom-sheet.d.ts +16 -0
- package/dist/components/bottom-sheet.d.ts.map +1 -0
- package/dist/components/bottom-sheet.js +13 -0
- package/dist/components/bottom-sheet.js.map +1 -0
- package/dist/components/button.d.ts +12 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +34 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +17 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/checkbox.d.ts +5 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/combobox.d.ts +19 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +101 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/dialog.d.ts +20 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +24 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +28 -0
- package/dist/components/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu.js +36 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/error-page.d.ts +105 -0
- package/dist/components/error-page.d.ts.map +1 -0
- package/dist/components/error-page.js +99 -0
- package/dist/components/error-page.js.map +1 -0
- package/dist/components/glass-card.d.ts +12 -0
- package/dist/components/glass-card.d.ts.map +1 -0
- package/dist/components/glass-card.js +15 -0
- package/dist/components/glass-card.js.map +1 -0
- package/dist/components/icon-badge.d.ts +15 -0
- package/dist/components/icon-badge.d.ts.map +1 -0
- package/dist/components/icon-badge.js +77 -0
- package/dist/components/icon-badge.js.map +1 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +9 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +11 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/progress.d.ts +5 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/progress.js +9 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +6 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +15 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/responsive-table.d.ts +21 -0
- package/dist/components/responsive-table.d.ts.map +1 -0
- package/dist/components/responsive-table.js +48 -0
- package/dist/components/responsive-table.js.map +1 -0
- package/dist/components/select.d.ts +14 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +27 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/skeleton.d.ts +3 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +7 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +5 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +9 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/stat-card.d.ts +17 -0
- package/dist/components/stat-card.d.ts.map +1 -0
- package/dist/components/stat-card.js +23 -0
- package/dist/components/stat-card.js.map +1 -0
- package/dist/components/switch.d.ts +5 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +11 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +21 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +8 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +14 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +6 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +14 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.d.ts +8 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +12 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +6 -0
- package/dist/utils/cn.js.map +1 -0
- package/package.json +96 -0
- package/src/components/Sheet.tsx +117 -0
- package/src/components/alert-dialog.tsx +138 -0
- package/src/components/alert.tsx +58 -0
- package/src/components/avatar.tsx +48 -0
- package/src/components/badge.tsx +36 -0
- package/src/components/bottom-sheet.tsx +68 -0
- package/src/components/button.tsx +56 -0
- package/src/components/card.tsx +85 -0
- package/src/components/checkbox.tsx +30 -0
- package/src/components/combobox.tsx +246 -0
- package/src/components/dialog.tsx +122 -0
- package/src/components/dropdown-menu.tsx +198 -0
- package/src/components/error-page.tsx +368 -0
- package/src/components/glass-card.tsx +37 -0
- package/src/components/icon-badge.tsx +126 -0
- package/src/components/input.tsx +25 -0
- package/src/components/label.tsx +26 -0
- package/src/components/progress.tsx +28 -0
- package/src/components/radio-group.tsx +42 -0
- package/src/components/responsive-table.tsx +191 -0
- package/src/components/select.tsx +158 -0
- package/src/components/skeleton.tsx +15 -0
- package/src/components/slider.tsx +27 -0
- package/src/components/stat-card.tsx +69 -0
- package/src/components/switch.tsx +29 -0
- package/src/components/table.tsx +117 -0
- package/src/components/tabs.tsx +55 -0
- package/src/components/textarea.tsx +23 -0
- package/src/components/toast.tsx +26 -0
- package/src/components/tooltip.tsx +34 -0
- package/src/index.ts +136 -0
- package/src/styles/animations.css +55 -0
- package/src/styles/base.css +51 -0
- package/src/styles/tokens.css +37 -0
- package/src/utils/cn.ts +6 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
import { Button } from "./button";
|
|
5
|
+
|
|
6
|
+
export interface ResponsiveTableColumn<T> {
|
|
7
|
+
key: string;
|
|
8
|
+
header: string;
|
|
9
|
+
render: (item: T) => React.ReactNode;
|
|
10
|
+
mobileLabel?: string; // Label for mobile card view
|
|
11
|
+
hideOnMobile?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ResponsiveTableProps<T> {
|
|
15
|
+
data: T[];
|
|
16
|
+
columns: ResponsiveTableColumn<T>[];
|
|
17
|
+
keyExtractor: (item: T) => string;
|
|
18
|
+
onRowClick?: (item: T) => void;
|
|
19
|
+
className?: string;
|
|
20
|
+
emptyMessage?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Responsive table component that shows as table on desktop and cards on mobile
|
|
25
|
+
*/
|
|
26
|
+
export function ResponsiveTable<T>({
|
|
27
|
+
data,
|
|
28
|
+
columns,
|
|
29
|
+
keyExtractor,
|
|
30
|
+
onRowClick,
|
|
31
|
+
className,
|
|
32
|
+
emptyMessage = "No data available",
|
|
33
|
+
}: ResponsiveTableProps<T>) {
|
|
34
|
+
const [expandedRows, setExpandedRows] = React.useState<Set<string>>(
|
|
35
|
+
new Set(),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const toggleRow = (key: string) => {
|
|
39
|
+
setExpandedRows((prev) => {
|
|
40
|
+
const next = new Set(prev);
|
|
41
|
+
if (next.has(key)) {
|
|
42
|
+
next.delete(key);
|
|
43
|
+
} else {
|
|
44
|
+
next.add(key);
|
|
45
|
+
}
|
|
46
|
+
return next;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const visibleColumns = columns.filter((col) => !col.hideOnMobile);
|
|
51
|
+
|
|
52
|
+
if (data.length === 0) {
|
|
53
|
+
return (
|
|
54
|
+
<div className="text-center py-12 text-muted-foreground">
|
|
55
|
+
{emptyMessage}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className={cn("w-full", className)}>
|
|
62
|
+
{/* Desktop Table View */}
|
|
63
|
+
<div className="hidden md:block rounded-md border overflow-hidden">
|
|
64
|
+
<table className="w-full">
|
|
65
|
+
<thead className="bg-muted/50">
|
|
66
|
+
<tr>
|
|
67
|
+
{columns.map((column) => (
|
|
68
|
+
<th
|
|
69
|
+
key={column.key}
|
|
70
|
+
className="px-4 py-3 text-left text-xs font-medium text-muted-foreground uppercase tracking-wider"
|
|
71
|
+
>
|
|
72
|
+
{column.header}
|
|
73
|
+
</th>
|
|
74
|
+
))}
|
|
75
|
+
</tr>
|
|
76
|
+
</thead>
|
|
77
|
+
<tbody className="divide-y divide-border">
|
|
78
|
+
{data.map((item) => {
|
|
79
|
+
const key = keyExtractor(item);
|
|
80
|
+
return (
|
|
81
|
+
<tr
|
|
82
|
+
key={key}
|
|
83
|
+
onClick={() => onRowClick?.(item)}
|
|
84
|
+
className={cn(
|
|
85
|
+
"hover:bg-muted/50 transition-colors",
|
|
86
|
+
onRowClick && "cursor-pointer",
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
{columns.map((column) => (
|
|
90
|
+
<td key={column.key} className="px-4 py-3 text-sm">
|
|
91
|
+
{column.render(item)}
|
|
92
|
+
</td>
|
|
93
|
+
))}
|
|
94
|
+
</tr>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
</tbody>
|
|
98
|
+
</table>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
{/* Mobile Card View */}
|
|
102
|
+
<div className="md:hidden space-y-3">
|
|
103
|
+
{data.map((item) => {
|
|
104
|
+
const key = keyExtractor(item);
|
|
105
|
+
const isExpanded = expandedRows.has(key);
|
|
106
|
+
const primaryColumns = visibleColumns.slice(0, 2);
|
|
107
|
+
const secondaryColumns = visibleColumns.slice(2);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
key={key}
|
|
112
|
+
className={cn(
|
|
113
|
+
"border rounded-lg overflow-hidden transition-all",
|
|
114
|
+
onRowClick && "cursor-pointer",
|
|
115
|
+
)}
|
|
116
|
+
onClick={() => {
|
|
117
|
+
if (secondaryColumns.length > 0) {
|
|
118
|
+
toggleRow(key);
|
|
119
|
+
} else {
|
|
120
|
+
onRowClick?.(item);
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{/* Primary Info */}
|
|
125
|
+
<div className="p-4 space-y-2">
|
|
126
|
+
{primaryColumns.map((column) => (
|
|
127
|
+
<div
|
|
128
|
+
key={column.key}
|
|
129
|
+
className="flex items-start justify-between gap-2"
|
|
130
|
+
>
|
|
131
|
+
<span className="text-xs font-medium text-muted-foreground min-w-[80px]">
|
|
132
|
+
{column.mobileLabel || column.header}:
|
|
133
|
+
</span>
|
|
134
|
+
<div className="flex-1 text-right text-sm">
|
|
135
|
+
{column.render(item)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
))}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
{/* Expandable Secondary Info */}
|
|
142
|
+
{secondaryColumns.length > 0 && (
|
|
143
|
+
<>
|
|
144
|
+
<Button
|
|
145
|
+
variant="ghost"
|
|
146
|
+
size="sm"
|
|
147
|
+
className="w-full h-10 rounded-none border-t"
|
|
148
|
+
onClick={(e) => {
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
toggleRow(key);
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{isExpanded ? (
|
|
154
|
+
<>
|
|
155
|
+
<ChevronUp className="h-4 w-4 mr-2" />
|
|
156
|
+
Hide Details
|
|
157
|
+
</>
|
|
158
|
+
) : (
|
|
159
|
+
<>
|
|
160
|
+
<ChevronDown className="h-4 w-4 mr-2" />
|
|
161
|
+
Show Details
|
|
162
|
+
</>
|
|
163
|
+
)}
|
|
164
|
+
</Button>
|
|
165
|
+
|
|
166
|
+
{isExpanded && (
|
|
167
|
+
<div className="p-4 pt-0 space-y-2 border-t bg-muted/30">
|
|
168
|
+
{secondaryColumns.map((column) => (
|
|
169
|
+
<div
|
|
170
|
+
key={column.key}
|
|
171
|
+
className="flex items-start justify-between gap-2"
|
|
172
|
+
>
|
|
173
|
+
<span className="text-xs font-medium text-muted-foreground min-w-[80px]">
|
|
174
|
+
{column.mobileLabel || column.header}:
|
|
175
|
+
</span>
|
|
176
|
+
<div className="flex-1 text-right text-sm">
|
|
177
|
+
{column.render(item)}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
2
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
|
|
7
|
+
const Select = SelectPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
10
|
+
|
|
11
|
+
const SelectValue = SelectPrimitive.Value;
|
|
12
|
+
|
|
13
|
+
const SelectTrigger = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
16
|
+
>(({ className, children, ...props }, ref) => (
|
|
17
|
+
<SelectPrimitive.Trigger
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
<SelectPrimitive.Icon asChild>
|
|
27
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
28
|
+
</SelectPrimitive.Icon>
|
|
29
|
+
</SelectPrimitive.Trigger>
|
|
30
|
+
));
|
|
31
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
32
|
+
|
|
33
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
36
|
+
>(({ className, ...props }, ref) => (
|
|
37
|
+
<SelectPrimitive.ScrollUpButton
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
"flex cursor-default items-center justify-center py-1",
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
<ChevronUp className="h-4 w-4" />
|
|
46
|
+
</SelectPrimitive.ScrollUpButton>
|
|
47
|
+
));
|
|
48
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
49
|
+
|
|
50
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
53
|
+
>(({ className, ...props }, ref) => (
|
|
54
|
+
<SelectPrimitive.ScrollDownButton
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(
|
|
57
|
+
"flex cursor-default items-center justify-center py-1",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
<ChevronDown className="h-4 w-4" />
|
|
63
|
+
</SelectPrimitive.ScrollDownButton>
|
|
64
|
+
));
|
|
65
|
+
SelectScrollDownButton.displayName =
|
|
66
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
67
|
+
|
|
68
|
+
const SelectContent = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
70
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
71
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
72
|
+
<SelectPrimitive.Portal>
|
|
73
|
+
<SelectPrimitive.Content
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={cn(
|
|
76
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
77
|
+
position === "popper" &&
|
|
78
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
79
|
+
className,
|
|
80
|
+
)}
|
|
81
|
+
position={position}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
<SelectScrollUpButton />
|
|
85
|
+
<SelectPrimitive.Viewport
|
|
86
|
+
className={cn(
|
|
87
|
+
"p-1",
|
|
88
|
+
position === "popper" &&
|
|
89
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</SelectPrimitive.Viewport>
|
|
94
|
+
<SelectScrollDownButton />
|
|
95
|
+
</SelectPrimitive.Content>
|
|
96
|
+
</SelectPrimitive.Portal>
|
|
97
|
+
));
|
|
98
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
99
|
+
|
|
100
|
+
const SelectLabel = React.forwardRef<
|
|
101
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
102
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
103
|
+
>(({ className, ...props }, ref) => (
|
|
104
|
+
<SelectPrimitive.Label
|
|
105
|
+
ref={ref}
|
|
106
|
+
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
));
|
|
110
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
111
|
+
|
|
112
|
+
const SelectItem = React.forwardRef<
|
|
113
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
114
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
115
|
+
>(({ className, children, ...props }, ref) => (
|
|
116
|
+
<SelectPrimitive.Item
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn(
|
|
119
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
120
|
+
className,
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
125
|
+
<SelectPrimitive.ItemIndicator>
|
|
126
|
+
<Check className="h-4 w-4" />
|
|
127
|
+
</SelectPrimitive.ItemIndicator>
|
|
128
|
+
</span>
|
|
129
|
+
|
|
130
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
131
|
+
</SelectPrimitive.Item>
|
|
132
|
+
));
|
|
133
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
134
|
+
|
|
135
|
+
const SelectSeparator = React.forwardRef<
|
|
136
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
137
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
138
|
+
>(({ className, ...props }, ref) => (
|
|
139
|
+
<SelectPrimitive.Separator
|
|
140
|
+
ref={ref}
|
|
141
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
));
|
|
145
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
Select,
|
|
149
|
+
SelectGroup,
|
|
150
|
+
SelectValue,
|
|
151
|
+
SelectTrigger,
|
|
152
|
+
SelectContent,
|
|
153
|
+
SelectLabel,
|
|
154
|
+
SelectItem,
|
|
155
|
+
SelectSeparator,
|
|
156
|
+
SelectScrollUpButton,
|
|
157
|
+
SelectScrollDownButton,
|
|
158
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cn } from "../utils/cn";
|
|
2
|
+
|
|
3
|
+
function Skeleton({
|
|
4
|
+
className,
|
|
5
|
+
...props
|
|
6
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
className={cn("animate-pulse rounded-md bg-muted", className)}
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Skeleton };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
|
|
7
|
+
const Slider = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<SliderPrimitive.Root
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
"relative flex w-full touch-none select-none items-center",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
|
20
|
+
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
21
|
+
</SliderPrimitive.Track>
|
|
22
|
+
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
|
|
23
|
+
</SliderPrimitive.Root>
|
|
24
|
+
));
|
|
25
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
26
|
+
|
|
27
|
+
export { Slider };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export interface StatCardProps {
|
|
5
|
+
icon: LucideIcon;
|
|
6
|
+
value: string | number;
|
|
7
|
+
label: string;
|
|
8
|
+
iconColor?: string;
|
|
9
|
+
iconBgColor?: string;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
action?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Apple-inspired stat card with icon and value
|
|
16
|
+
* Clean, minimal, centered layout
|
|
17
|
+
*/
|
|
18
|
+
export function StatCard({
|
|
19
|
+
icon: Icon,
|
|
20
|
+
value,
|
|
21
|
+
label,
|
|
22
|
+
iconColor = "text-blue-600 dark:text-blue-400",
|
|
23
|
+
iconBgColor = "bg-blue-500/10",
|
|
24
|
+
onClick,
|
|
25
|
+
action,
|
|
26
|
+
}: StatCardProps) {
|
|
27
|
+
const isClickable = !!onClick;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
className={`
|
|
32
|
+
flex flex-col items-center gap-4 rounded-2xl border border-border/50
|
|
33
|
+
bg-card p-8 text-center shadow-sm transition-all duration-300
|
|
34
|
+
${isClickable ? "cursor-pointer hover:shadow-lg hover:scale-[1.02] active:scale-[0.98]" : ""}
|
|
35
|
+
`}
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
{...(isClickable && {
|
|
38
|
+
role: "button",
|
|
39
|
+
tabIndex: 0,
|
|
40
|
+
onKeyDown: (e) => {
|
|
41
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
onClick?.();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
})}
|
|
47
|
+
>
|
|
48
|
+
{/* Icon Circle */}
|
|
49
|
+
<div
|
|
50
|
+
className={`flex h-14 w-14 items-center justify-center rounded-full ${iconBgColor} transition-transform duration-300 ${isClickable ? "group-hover:scale-110" : ""}`}
|
|
51
|
+
>
|
|
52
|
+
<Icon className={`h-7 w-7 ${iconColor}`} strokeWidth={2} />
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
{/* Value */}
|
|
56
|
+
<div>
|
|
57
|
+
<div className="text-4xl font-bold tabular-nums tracking-tight text-foreground">
|
|
58
|
+
{value}
|
|
59
|
+
</div>
|
|
60
|
+
<div className="mt-2 text-sm font-medium text-muted-foreground">
|
|
61
|
+
{label}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
{/* Optional Action */}
|
|
66
|
+
{action && <div className="mt-2 w-full">{action}</div>}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../utils/cn";
|
|
7
|
+
|
|
8
|
+
const Switch = React.forwardRef<
|
|
9
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
11
|
+
>(({ className, ...props }, ref) => (
|
|
12
|
+
<SwitchPrimitives.Root
|
|
13
|
+
className={cn(
|
|
14
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
ref={ref}
|
|
19
|
+
>
|
|
20
|
+
<SwitchPrimitives.Thumb
|
|
21
|
+
className={cn(
|
|
22
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
|
|
23
|
+
)}
|
|
24
|
+
/>
|
|
25
|
+
</SwitchPrimitives.Root>
|
|
26
|
+
));
|
|
27
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
28
|
+
|
|
29
|
+
export { Switch };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
|
|
5
|
+
const Table = React.forwardRef<
|
|
6
|
+
HTMLTableElement,
|
|
7
|
+
React.HTMLAttributes<HTMLTableElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div className="relative w-full overflow-auto">
|
|
10
|
+
<table
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
));
|
|
17
|
+
Table.displayName = "Table";
|
|
18
|
+
|
|
19
|
+
const TableHeader = React.forwardRef<
|
|
20
|
+
HTMLTableSectionElement,
|
|
21
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
22
|
+
>(({ className, ...props }, ref) => (
|
|
23
|
+
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
|
24
|
+
));
|
|
25
|
+
TableHeader.displayName = "TableHeader";
|
|
26
|
+
|
|
27
|
+
const TableBody = React.forwardRef<
|
|
28
|
+
HTMLTableSectionElement,
|
|
29
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
30
|
+
>(({ className, ...props }, ref) => (
|
|
31
|
+
<tbody
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
));
|
|
37
|
+
TableBody.displayName = "TableBody";
|
|
38
|
+
|
|
39
|
+
const TableFooter = React.forwardRef<
|
|
40
|
+
HTMLTableSectionElement,
|
|
41
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
42
|
+
>(({ className, ...props }, ref) => (
|
|
43
|
+
<tfoot
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(
|
|
46
|
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
));
|
|
52
|
+
TableFooter.displayName = "TableFooter";
|
|
53
|
+
|
|
54
|
+
const TableRow = React.forwardRef<
|
|
55
|
+
HTMLTableRowElement,
|
|
56
|
+
React.HTMLAttributes<HTMLTableRowElement>
|
|
57
|
+
>(({ className, ...props }, ref) => (
|
|
58
|
+
<tr
|
|
59
|
+
ref={ref}
|
|
60
|
+
className={cn(
|
|
61
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
62
|
+
className,
|
|
63
|
+
)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
));
|
|
67
|
+
TableRow.displayName = "TableRow";
|
|
68
|
+
|
|
69
|
+
const TableHead = React.forwardRef<
|
|
70
|
+
HTMLTableCellElement,
|
|
71
|
+
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
72
|
+
>(({ className, ...props }, ref) => (
|
|
73
|
+
<th
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={cn(
|
|
76
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
));
|
|
82
|
+
TableHead.displayName = "TableHead";
|
|
83
|
+
|
|
84
|
+
const TableCell = React.forwardRef<
|
|
85
|
+
HTMLTableCellElement,
|
|
86
|
+
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<td
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
));
|
|
94
|
+
TableCell.displayName = "TableCell";
|
|
95
|
+
|
|
96
|
+
const TableCaption = React.forwardRef<
|
|
97
|
+
HTMLTableCaptionElement,
|
|
98
|
+
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
99
|
+
>(({ className, ...props }, ref) => (
|
|
100
|
+
<caption
|
|
101
|
+
ref={ref}
|
|
102
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
));
|
|
106
|
+
TableCaption.displayName = "TableCaption";
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Table,
|
|
110
|
+
TableHeader,
|
|
111
|
+
TableBody,
|
|
112
|
+
TableFooter,
|
|
113
|
+
TableHead,
|
|
114
|
+
TableRow,
|
|
115
|
+
TableCell,
|
|
116
|
+
TableCaption,
|
|
117
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../utils/cn";
|
|
7
|
+
|
|
8
|
+
const Tabs = TabsPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const TabsList = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
13
|
+
>(({ className, ...props }, ref) => (
|
|
14
|
+
<TabsPrimitive.List
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
18
|
+
className,
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
));
|
|
23
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
24
|
+
|
|
25
|
+
const TabsTrigger = React.forwardRef<
|
|
26
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
28
|
+
>(({ className, ...props }, ref) => (
|
|
29
|
+
<TabsPrimitive.Trigger
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(
|
|
32
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
));
|
|
38
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
39
|
+
|
|
40
|
+
const TabsContent = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<TabsPrimitive.Content
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
));
|
|
53
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
54
|
+
|
|
55
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
|
|
4
|
+
export interface TextareaProps
|
|
5
|
+
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
6
|
+
|
|
7
|
+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
8
|
+
({ className, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<textarea
|
|
11
|
+
className={cn(
|
|
12
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
ref={ref}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
Textarea.displayName = "Textarea";
|
|
22
|
+
|
|
23
|
+
export { Textarea };
|