react-groundwork 0.0.0-stage → 0.1.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.
Files changed (93) hide show
  1. package/.env.example +6 -0
  2. package/.gitattributes +2 -0
  3. package/.prettierignore +7 -0
  4. package/.prettierrc.json +12 -0
  5. package/README.md +24 -2
  6. package/cli/index.js +119 -0
  7. package/components.json +25 -0
  8. package/eslint.config.js +17 -0
  9. package/index.html +13 -0
  10. package/jsconfig.json +8 -0
  11. package/package.json +111 -4
  12. package/public/.htaccess +11 -0
  13. package/public/logo.png +0 -0
  14. package/src/App.jsx +14 -0
  15. package/src/api/api.routes.js +12 -0
  16. package/src/api/api.services.js +8 -0
  17. package/src/api/apiCall.js +128 -0
  18. package/src/api/apiHelpers.js +20 -0
  19. package/src/assets/css/index.css +173 -0
  20. package/src/assets/images/placeholders/placeholder-170x166.png +0 -0
  21. package/src/assets/images/placeholders/placeholder-360x260.png +0 -0
  22. package/src/assets/images/placeholders/placeholder-372x225.png +0 -0
  23. package/src/assets/images/placeholders/placeholder-40x40.png +0 -0
  24. package/src/assets/images/placeholders/placeholder-451x392.png +0 -0
  25. package/src/components/common/AppChart.jsx +56 -0
  26. package/src/components/common/Breadcrumbs.jsx +90 -0
  27. package/src/components/common/DataTable.jsx +203 -0
  28. package/src/components/common/DatePicker.jsx +275 -0
  29. package/src/components/common/DialogComponent.jsx +308 -0
  30. package/src/components/common/ErrorStateComponent.jsx +46 -0
  31. package/src/components/common/FullscreenToggle.jsx +54 -0
  32. package/src/components/common/HeadingComponent.jsx +29 -0
  33. package/src/components/common/LoadingComponent.jsx +33 -0
  34. package/src/components/common/NetworkStatus.jsx +103 -0
  35. package/src/components/common/NoDataComponent.jsx +45 -0
  36. package/src/components/common/Pagination.jsx +128 -0
  37. package/src/components/common/ParagraphComponent.jsx +14 -0
  38. package/src/components/common/PhoneInputComponent.jsx +242 -0
  39. package/src/components/common/ReactSelect.jsx +145 -0
  40. package/src/components/common/SearchSelect.jsx +176 -0
  41. package/src/components/common/SeeMore.jsx +26 -0
  42. package/src/components/common/SortableHeader.jsx +23 -0
  43. package/src/components/common/theme-toggle.jsx +39 -0
  44. package/src/components/layout/AuthLayout.jsx +90 -0
  45. package/src/components/layout/PageLayout.jsx +32 -0
  46. package/src/components/layout/SidebarLayout.jsx +233 -0
  47. package/src/components/ui/avatar.jsx +84 -0
  48. package/src/components/ui/badge.jsx +43 -0
  49. package/src/components/ui/button.jsx +44 -0
  50. package/src/components/ui/card.jsx +69 -0
  51. package/src/components/ui/checkbox.jsx +25 -0
  52. package/src/components/ui/dialog.jsx +149 -0
  53. package/src/components/ui/empty.jsx +82 -0
  54. package/src/components/ui/input.jsx +19 -0
  55. package/src/components/ui/label.jsx +19 -0
  56. package/src/components/ui/select.jsx +156 -0
  57. package/src/components/ui/skeleton.jsx +7 -0
  58. package/src/components/ui/sonner.jsx +37 -0
  59. package/src/components/ui/switch.jsx +23 -0
  60. package/src/components/ui/table.jsx +74 -0
  61. package/src/components/ui/textarea.jsx +16 -0
  62. package/src/constants/constant.js +16 -0
  63. package/src/context/theme-provider.jsx +48 -0
  64. package/src/features/components/ComponentFormDialog.jsx +162 -0
  65. package/src/features/components/ComponentsTable.jsx +219 -0
  66. package/src/features/components/componentStyles.js +16 -0
  67. package/src/features/components/mockData.js +407 -0
  68. package/src/features/playground/BasicsSection.jsx +122 -0
  69. package/src/features/playground/DataSection.jsx +210 -0
  70. package/src/features/playground/DemoCard.jsx +21 -0
  71. package/src/features/playground/FeedbackSection.jsx +309 -0
  72. package/src/features/playground/FormsSection.jsx +188 -0
  73. package/src/features/playground/UtilitiesSection.jsx +200 -0
  74. package/src/hooks/useApiHandler.jsx +82 -0
  75. package/src/hooks/useDebounce.js +12 -0
  76. package/src/lib/utils.js +1 -0
  77. package/src/main.jsx +16 -0
  78. package/src/pages/auth/ForgotPasswordPage.jsx +101 -0
  79. package/src/pages/auth/LoginPage.jsx +120 -0
  80. package/src/pages/auth/SignupPage.jsx +135 -0
  81. package/src/pages/views/ComponentsPage.jsx +316 -0
  82. package/src/pages/views/DashboardPage.jsx +260 -0
  83. package/src/pages/views/LandingPage.jsx +772 -0
  84. package/src/pages/views/NotFoundPage.jsx +30 -0
  85. package/src/pages/views/PlaygroundPage.jsx +50 -0
  86. package/src/routes/AppRoutes.jsx +29 -0
  87. package/src/routes/ProtectedRoute.jsx +18 -0
  88. package/src/utils/exportCsv.js +17 -0
  89. package/src/utils/formatCurrency.js +19 -0
  90. package/src/utils/formatDateTime.js +34 -0
  91. package/src/utils/handleSessionExpire.js +22 -0
  92. package/src/utils/logger.js +34 -0
  93. package/vite.config.js +23 -0
@@ -0,0 +1,173 @@
1
+ @import "tailwindcss";
2
+ @import "tw-animate-css";
3
+ @import "shadcn/tailwind.css";
4
+ @import "@fontsource-variable/geist";
5
+
6
+ @custom-variant dark (&:is(.dark *));
7
+
8
+ @theme inline {
9
+ --font-heading: var(--font-sans);
10
+ --font-sans: "Geist Variable", sans-serif;
11
+ --color-sidebar-ring: var(--sidebar-ring);
12
+ --color-sidebar-border: var(--sidebar-border);
13
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
14
+ --color-sidebar-accent: var(--sidebar-accent);
15
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
16
+ --color-sidebar-primary: var(--sidebar-primary);
17
+ --color-sidebar-foreground: var(--sidebar-foreground);
18
+ --color-sidebar: var(--sidebar);
19
+ --color-chart-5: var(--chart-5);
20
+ --color-chart-4: var(--chart-4);
21
+ --color-chart-3: var(--chart-3);
22
+ --color-chart-2: var(--chart-2);
23
+ --color-chart-1: var(--chart-1);
24
+ --color-ring: var(--ring);
25
+ --color-input: var(--input);
26
+ --color-border: var(--border);
27
+ --color-destructive: var(--destructive);
28
+ --color-accent-foreground: var(--accent-foreground);
29
+ --color-accent: var(--accent);
30
+ --color-muted-foreground: var(--muted-foreground);
31
+ --color-muted: var(--muted);
32
+ --color-secondary-foreground: var(--secondary-foreground);
33
+ --color-secondary: var(--secondary);
34
+ --color-primary-foreground: var(--primary-foreground);
35
+ --color-primary: var(--primary);
36
+ --color-primary-hover: var(--primary-hover);
37
+ --color-popover-foreground: var(--popover-foreground);
38
+ --color-popover: var(--popover);
39
+ --color-card-foreground: var(--card-foreground);
40
+ --color-card: var(--card);
41
+ --color-foreground: var(--foreground);
42
+ --color-background: var(--background);
43
+ --radius-sm: calc(var(--radius) * 0.6);
44
+ --radius-md: calc(var(--radius) * 0.8);
45
+ --radius-lg: var(--radius);
46
+ --radius-xl: calc(var(--radius) * 1.4);
47
+ --radius-2xl: calc(var(--radius) * 1.8);
48
+ --radius-3xl: calc(var(--radius) * 2.2);
49
+ --radius-4xl: calc(var(--radius) * 2.6);
50
+ }
51
+
52
+ :root {
53
+ --background: oklch(1 0 0);
54
+ --foreground: oklch(0.145 0 0);
55
+ --card: oklch(1 0 0);
56
+ --card-foreground: oklch(0.145 0 0);
57
+ --popover: oklch(1 0 0);
58
+ --popover-foreground: oklch(0.145 0 0);
59
+ --primary: #2563eb;
60
+ --primary-hover: #1d4ed8;
61
+ --primary-foreground: #ffffff;
62
+ --secondary: oklch(0.97 0 0);
63
+ --secondary-foreground: oklch(0.205 0 0);
64
+ --muted: oklch(0.97 0 0);
65
+ --muted-foreground: oklch(0.556 0 0);
66
+ --accent: oklch(0.97 0 0);
67
+ --accent-foreground: oklch(0.205 0 0);
68
+ --destructive: oklch(0.577 0.245 27.325);
69
+ --border: oklch(0.922 0 0);
70
+ --input: oklch(0.922 0 0);
71
+ --ring: #2563eb;
72
+ --chart-1: oklch(0.87 0 0);
73
+ --chart-2: oklch(0.556 0 0);
74
+ --chart-3: oklch(0.439 0 0);
75
+ --chart-4: oklch(0.371 0 0);
76
+ --chart-5: oklch(0.269 0 0);
77
+ --radius: 0.625rem;
78
+ --sidebar: oklch(0.985 0 0);
79
+ --sidebar-foreground: oklch(0.145 0 0);
80
+ --sidebar-primary: #2563eb;
81
+ --sidebar-primary-foreground: #ffffff;
82
+ --sidebar-accent: oklch(0.97 0 0);
83
+ --sidebar-accent-foreground: oklch(0.205 0 0);
84
+ --sidebar-border: oklch(0.922 0 0);
85
+ --sidebar-ring: oklch(0.708 0 0);
86
+ }
87
+
88
+ .dark {
89
+ --background: oklch(0.145 0 0);
90
+ --foreground: oklch(0.985 0 0);
91
+ --card: oklch(0.205 0 0);
92
+ --card-foreground: oklch(0.985 0 0);
93
+ --popover: oklch(0.205 0 0);
94
+ --popover-foreground: oklch(0.985 0 0);
95
+ --primary: #4c8dff;
96
+ --primary-hover: #6ea2ff;
97
+ --primary-foreground: #0b0d14;
98
+ --secondary: oklch(0.269 0 0);
99
+ --secondary-foreground: oklch(0.985 0 0);
100
+ --muted: oklch(0.269 0 0);
101
+ --muted-foreground: oklch(0.708 0 0);
102
+ --accent: oklch(0.269 0 0);
103
+ --accent-foreground: oklch(0.985 0 0);
104
+ --destructive: oklch(0.704 0.191 22.216);
105
+ --border: oklch(1 0 0 / 10%);
106
+ --input: oklch(1 0 0 / 15%);
107
+ --ring: #4c8dff;
108
+ --chart-1: oklch(0.87 0 0);
109
+ --chart-2: oklch(0.556 0 0);
110
+ --chart-3: oklch(0.439 0 0);
111
+ --chart-4: oklch(0.371 0 0);
112
+ --chart-5: oklch(0.269 0 0);
113
+ --sidebar: oklch(0.205 0 0);
114
+ --sidebar-foreground: oklch(0.985 0 0);
115
+ --sidebar-primary: #4c8dff;
116
+ --sidebar-primary-foreground: #0b0d14;
117
+ --sidebar-accent: oklch(0.269 0 0);
118
+ --sidebar-accent-foreground: oklch(0.985 0 0);
119
+ --sidebar-border: oklch(1 0 0 / 10%);
120
+ --sidebar-ring: oklch(0.556 0 0);
121
+ }
122
+
123
+ @layer base {
124
+ * {
125
+ @apply border-border outline-ring/50;
126
+ }
127
+ body {
128
+ @apply bg-background text-foreground;
129
+ }
130
+ html {
131
+ @apply font-sans;
132
+ }
133
+
134
+ * {
135
+ scrollbar-width: thin;
136
+ scrollbar-color: color-mix(in oklch, var(--foreground) 20%, transparent) transparent;
137
+ }
138
+ *::-webkit-scrollbar {
139
+ width: 8px;
140
+ height: 8px;
141
+ }
142
+ *::-webkit-scrollbar-track {
143
+ background: transparent;
144
+ }
145
+ *::-webkit-scrollbar-thumb {
146
+ background-color: color-mix(in oklch, var(--foreground) 20%, transparent);
147
+ border-radius: 9999px;
148
+ }
149
+ *::-webkit-scrollbar-thumb:hover {
150
+ background-color: color-mix(in oklch, var(--foreground) 35%, transparent);
151
+ }
152
+
153
+ :root {
154
+ --autofill-bg: var(--background);
155
+ }
156
+ [data-slot="card"] {
157
+ --autofill-bg: var(--card);
158
+ }
159
+ [data-slot="dialog-content"] {
160
+ --autofill-bg: var(--popover);
161
+ }
162
+ input:-webkit-autofill,
163
+ input:-webkit-autofill:hover,
164
+ input:-webkit-autofill:focus,
165
+ input:-webkit-autofill:active,
166
+ textarea:-webkit-autofill {
167
+ --tw-inset-shadow: inset 0 0 0 1000px var(--autofill-bg);
168
+ box-shadow: var(--tw-inset-shadow);
169
+ -webkit-text-fill-color: var(--foreground);
170
+ caret-color: var(--foreground);
171
+ transition: background-color 99999s ease-out 0s;
172
+ }
173
+ }
@@ -0,0 +1,56 @@
1
+ import {
2
+ Chart as ChartJS,
3
+ CategoryScale,
4
+ LinearScale,
5
+ PointElement,
6
+ LineElement,
7
+ BarElement,
8
+ ArcElement,
9
+ Tooltip,
10
+ Legend,
11
+ } from "chart.js";
12
+ import { Line, Bar, Pie, Doughnut } from "react-chartjs-2";
13
+ import { cn } from "@/lib/utils";
14
+ import LoadingComponent from "@/components/common/LoadingComponent";
15
+ import ErrorStateComponent from "@/components/common/ErrorStateComponent";
16
+ import NoDataComponent from "@/components/common/NoDataComponent";
17
+
18
+ ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement, ArcElement, Tooltip, Legend);
19
+
20
+ const CHART_COMPONENTS = {
21
+ line: Line,
22
+ bar: Bar,
23
+ pie: Pie,
24
+ doughnut: Doughnut,
25
+ };
26
+
27
+ const hasData = (data) => Boolean(data?.datasets?.length) && data.datasets.some((set) => set.data?.length);
28
+
29
+ const AppChart = ({
30
+ type = "line",
31
+ data,
32
+ options,
33
+ loading = false,
34
+ error = null,
35
+ onRetry,
36
+ height = 280,
37
+ className,
38
+ }) => {
39
+ if (loading) return <LoadingComponent label="Loading chart..." />;
40
+ if (error) {
41
+ return <ErrorStateComponent description={typeof error === "string" ? error : undefined} onRetry={onRetry} />;
42
+ }
43
+ if (!hasData(data)) {
44
+ return <NoDataComponent title="No chart data" description="There is nothing to visualize yet." />;
45
+ }
46
+
47
+ const ChartComponent = CHART_COMPONENTS[type] ?? Line;
48
+
49
+ return (
50
+ <div className={cn("w-full", className)} style={{ height }}>
51
+ <ChartComponent data={data} options={{ responsive: true, maintainAspectRatio: false, ...options }} />
52
+ </div>
53
+ );
54
+ };
55
+
56
+ export default AppChart;
@@ -0,0 +1,90 @@
1
+ import { Fragment } from "react";
2
+ import { Link, useLocation } from "react-router-dom";
3
+ import { ChevronRight, House } from "lucide-react";
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const HOME = { path: "/dashboard", label: "Dashboard", icon: House };
7
+
8
+ const ROUTES = {
9
+ "/dashboard": { label: "Dashboard", show: true },
10
+ "/components": { label: "Components", show: true },
11
+ "/playground": { label: "Playground", show: true },
12
+ };
13
+
14
+ const toLabel = (segment) =>
15
+ decodeURIComponent(segment)
16
+ .replace(/[-_]/g, " ")
17
+ .replace(/\b\w/g, (char) => char.toUpperCase());
18
+
19
+ const buildCrumbs = (pathname) => {
20
+ const segments = pathname.split("/").filter(Boolean);
21
+ return segments
22
+ .map((segment, idx) => {
23
+ const path = `/${segments.slice(0, idx + 1).join("/")}`;
24
+ return { path, label: ROUTES[path]?.label ?? toLabel(segment) };
25
+ })
26
+ .filter((crumb) => crumb.path !== HOME.path);
27
+ };
28
+
29
+ const Breadcrumbs = ({ className }) => {
30
+ const { pathname } = useLocation();
31
+
32
+ if (ROUTES[pathname]?.show === false) return null;
33
+
34
+ const crumbs = buildCrumbs(pathname);
35
+ const HomeIcon = HOME.icon;
36
+
37
+ return (
38
+ <div className={cn("flex min-w-0 items-center gap-3", className)}>
39
+ <span className="hidden h-5 w-px shrink-0 bg-border md:block" />
40
+ <nav aria-label="Breadcrumb" className="min-w-0">
41
+ <ol className="flex min-w-0 items-center gap-1.5 text-sm">
42
+ <li className="flex shrink-0 items-center">
43
+ {crumbs.length === 0 ? (
44
+ <span aria-current="page" className="flex items-center gap-1.5 font-medium text-foreground">
45
+ <HomeIcon className="h-4 w-4" />
46
+ {HOME.label}
47
+ </span>
48
+ ) : (
49
+ <Link
50
+ to={HOME.path}
51
+ title={HOME.label}
52
+ className="flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground"
53
+ >
54
+ <HomeIcon className="h-4 w-4" />
55
+ <span className="hidden sm:inline">{HOME.label}</span>
56
+ </Link>
57
+ )}
58
+ </li>
59
+
60
+ {crumbs.map((crumb, idx) => {
61
+ const isLast = idx === crumbs.length - 1;
62
+ return (
63
+ <Fragment key={crumb.path}>
64
+ <li aria-hidden="true" className="flex shrink-0 items-center">
65
+ <ChevronRight className="h-3.5 w-3.5 text-muted-foreground/60" />
66
+ </li>
67
+ <li className="flex min-w-0 items-center">
68
+ {isLast ? (
69
+ <span aria-current="page" className="truncate font-medium text-foreground">
70
+ {crumb.label}
71
+ </span>
72
+ ) : (
73
+ <Link
74
+ to={crumb.path}
75
+ className="truncate text-muted-foreground transition-colors hover:text-foreground"
76
+ >
77
+ {crumb.label}
78
+ </Link>
79
+ )}
80
+ </li>
81
+ </Fragment>
82
+ );
83
+ })}
84
+ </ol>
85
+ </nav>
86
+ </div>
87
+ );
88
+ };
89
+
90
+ export default Breadcrumbs;
@@ -0,0 +1,203 @@
1
+ import { Search } from "lucide-react";
2
+ import { cn } from "@/lib/utils";
3
+ import PageLayout from "@/components/layout/PageLayout";
4
+ import { Button } from "@/components/ui/button";
5
+ import { Input } from "@/components/ui/input";
6
+ import { Card, CardContent, CardHeader } from "@/components/ui/card";
7
+ import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "@/components/ui/table";
8
+ import HeadingComponent from "@/components/common/HeadingComponent";
9
+ import SortableHeader from "@/components/common/SortableHeader";
10
+ import LoadingComponent from "@/components/common/LoadingComponent";
11
+ import ErrorStateComponent from "@/components/common/ErrorStateComponent";
12
+ import NoDataComponent from "@/components/common/NoDataComponent";
13
+ import Pagination from "@/components/common/Pagination";
14
+
15
+ const DataTable = ({
16
+ pageLayout = false,
17
+ pageLayoutProps,
18
+
19
+ title,
20
+ subtitle,
21
+ headerActions,
22
+
23
+ searchValue,
24
+ onSearchChange,
25
+ searchPlaceholder = "Search...",
26
+ resultsLabel,
27
+
28
+ card = true,
29
+ bodyHeight = "26rem",
30
+
31
+ columns,
32
+ data = [],
33
+ rowActions,
34
+ loading = false,
35
+ error = null,
36
+ onRetry,
37
+ sortBy,
38
+ sortOrder,
39
+ onSort,
40
+ page,
41
+ totalPages,
42
+ onPageChange,
43
+ emptyTitle,
44
+ emptyDescription,
45
+ className,
46
+ }) => {
47
+ const resolvedColumns = rowActions?.length
48
+ ? [
49
+ ...columns,
50
+ {
51
+ key: "__actions",
52
+ label: "",
53
+ className: "text-right",
54
+ render: (row) => (
55
+ <div className="flex items-center justify-end gap-1">
56
+ {rowActions.map((action) => (
57
+ <Button
58
+ key={action.key}
59
+ type="button"
60
+ variant="ghost"
61
+ size="icon-sm"
62
+ title={action.label}
63
+ onClick={() => action.onClick?.(row)}
64
+ className={cn(
65
+ "rounded-full text-muted-foreground",
66
+ action.tone === "destructive"
67
+ ? "hover:bg-destructive/10 hover:text-destructive"
68
+ : "hover:bg-primary/10 hover:text-primary",
69
+ )}
70
+ >
71
+ <action.icon />
72
+ <span className="sr-only">{action.label}</span>
73
+ </Button>
74
+ ))}
75
+ </div>
76
+ ),
77
+ },
78
+ ]
79
+ : columns;
80
+
81
+ const searchBar = onSearchChange && (
82
+ <div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
83
+ <div className="relative w-full max-w-sm">
84
+ <Search className="pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
85
+ <Input
86
+ placeholder={searchPlaceholder}
87
+ className="h-9 pl-9 text-sm"
88
+ value={searchValue}
89
+ onChange={(e) => onSearchChange(e.target.value)}
90
+ />
91
+ </div>
92
+ {resultsLabel && <p className="shrink-0 text-xs text-muted-foreground">{resultsLabel}</p>}
93
+ </div>
94
+ );
95
+
96
+ const heading = title && (
97
+ <HeadingComponent title={title} subtitle={subtitle} actions={headerActions} size="section" />
98
+ );
99
+
100
+ const fillHeight = pageLayout;
101
+ const areaSizing = fillHeight ? { className: "h-full min-h-0" } : { style: { height: bodyHeight } };
102
+
103
+ let tableArea;
104
+ if (loading) {
105
+ tableArea = (
106
+ <div className={cn("flex items-center justify-center", areaSizing.className)} style={areaSizing.style}>
107
+ <LoadingComponent label="Loading data..." />
108
+ </div>
109
+ );
110
+ } else if (error) {
111
+ tableArea = (
112
+ <div className={cn("flex items-center justify-center", areaSizing.className)} style={areaSizing.style}>
113
+ <ErrorStateComponent description={typeof error === "string" ? error : undefined} onRetry={onRetry} />
114
+ </div>
115
+ );
116
+ } else {
117
+ tableArea = (
118
+ <div className={cn("flex flex-col gap-2", areaSizing.className)} style={areaSizing.style}>
119
+ <div className="min-h-0 flex-1 overflow-y-auto overflow-x-auto">
120
+ <Table className="text-sm">
121
+ <TableHeader>
122
+ <TableRow>
123
+ {resolvedColumns.map((col) => (
124
+ <TableHead
125
+ key={col.key}
126
+ className={cn(
127
+ "sticky top-0 z-10 h-10 bg-muted px-4 text-[11px] font-semibold tracking-wider text-muted-foreground uppercase first:rounded-l-lg last:rounded-r-lg",
128
+ col.className,
129
+ )}
130
+ >
131
+ {col.sortable ? (
132
+ <SortableHeader
133
+ label={col.label}
134
+ sortKey={col.key}
135
+ sortBy={sortBy}
136
+ sortOrder={sortOrder}
137
+ onSort={onSort}
138
+ className="font-semibold text-muted-foreground uppercase"
139
+ />
140
+ ) : (
141
+ col.label
142
+ )}
143
+ </TableHead>
144
+ ))}
145
+ </TableRow>
146
+ </TableHeader>
147
+ <TableBody>
148
+ {data.length === 0 ? (
149
+ <TableRow className="hover:bg-transparent">
150
+ <TableCell colSpan={resolvedColumns.length} className="p-0">
151
+ <NoDataComponent title={emptyTitle} description={emptyDescription} />
152
+ </TableCell>
153
+ </TableRow>
154
+ ) : (
155
+ data.map((row, idx) => (
156
+ <TableRow key={row.id ?? idx} className="transition-colors hover:bg-primary/3">
157
+ {resolvedColumns.map((col) => (
158
+ <TableCell key={col.key} className={cn("px-4 py-3 text-sm", col.className)}>
159
+ {col.render ? col.render(row) : row[col.key]}
160
+ </TableCell>
161
+ ))}
162
+ </TableRow>
163
+ ))
164
+ )}
165
+ </TableBody>
166
+ </Table>
167
+ </div>
168
+
169
+ {onPageChange && data.length > 0 && (
170
+ <Pagination page={page} totalPages={totalPages} onPageChange={onPageChange} />
171
+ )}
172
+ </div>
173
+ );
174
+ }
175
+
176
+ const cardHeader = (heading || searchBar) && (
177
+ <CardHeader className="gap-4 border-b [.border-b]:pb-4">
178
+ {heading}
179
+ {searchBar}
180
+ </CardHeader>
181
+ );
182
+
183
+ const body = (
184
+ <div className={cn("flex flex-col", fillHeight && "h-full min-h-0", className)}>
185
+ {card ? (
186
+ <Card size="sm" className={cn(fillHeight && "h-full min-h-0")}>
187
+ {cardHeader}
188
+ <CardContent className={cn("px-3", fillHeight && "min-h-0 flex-1")}>{tableArea}</CardContent>
189
+ </Card>
190
+ ) : (
191
+ <>
192
+ {heading}
193
+ {searchBar}
194
+ {tableArea}
195
+ </>
196
+ )}
197
+ </div>
198
+ );
199
+
200
+ return pageLayout ? <PageLayout {...pageLayoutProps}>{body}</PageLayout> : body;
201
+ };
202
+
203
+ export default DataTable;