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,30 @@
1
+ import { Link } from "react-router-dom";
2
+ import { ArrowLeft, SearchX } from "lucide-react";
3
+ import PageLayout from "@/components/layout/PageLayout";
4
+ import { Button } from "@/components/ui/button";
5
+ import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
6
+
7
+ const NotFoundPage = () => {
8
+ return (
9
+ <PageLayout variant="center">
10
+ <Empty>
11
+ <EmptyHeader>
12
+ <EmptyMedia variant="icon" className="size-14 rounded-2xl">
13
+ <SearchX className="size-6" />
14
+ </EmptyMedia>
15
+ <span className="font-heading text-5xl font-semibold tracking-tight">404</span>
16
+ <EmptyTitle>Page not found</EmptyTitle>
17
+ <EmptyDescription>The page you're looking for doesn't exist or has been moved.</EmptyDescription>
18
+ </EmptyHeader>
19
+ <EmptyContent>
20
+ <Button render={<Link to="/" />}>
21
+ <ArrowLeft />
22
+ Back to home
23
+ </Button>
24
+ </EmptyContent>
25
+ </Empty>
26
+ </PageLayout>
27
+ );
28
+ };
29
+
30
+ export default NotFoundPage;
@@ -0,0 +1,50 @@
1
+ import PageLayout from "@/components/layout/PageLayout";
2
+ import HeadingComponent from "@/components/common/HeadingComponent";
3
+ import BasicsSection from "@/features/playground/BasicsSection";
4
+ import FormsSection from "@/features/playground/FormsSection";
5
+ import FeedbackSection from "@/features/playground/FeedbackSection";
6
+ import DataSection from "@/features/playground/DataSection";
7
+ import UtilitiesSection from "@/features/playground/UtilitiesSection";
8
+
9
+ const SECTIONS = [
10
+ { id: "basics", title: "Basics", subtitle: "Buttons, badges and text", Component: BasicsSection },
11
+ { id: "forms", title: "Forms", subtitle: "Inputs, selects, dates and phone numbers", Component: FormsSection },
12
+ {
13
+ id: "feedback",
14
+ title: "Dialogs and feedback",
15
+ subtitle: "Dialogs, toasts, avatars and page states",
16
+ Component: FeedbackSection,
17
+ },
18
+ { id: "data", title: "Data", subtitle: "Tables, pagination and charts", Component: DataSection },
19
+ {
20
+ id: "utilities",
21
+ title: "Hooks and utilities",
22
+ subtitle: "API handling, debouncing, formatting and export",
23
+ Component: UtilitiesSection,
24
+ },
25
+ ];
26
+
27
+ const PlaygroundPage = () => {
28
+ return (
29
+ <PageLayout showSidebar variant="primary">
30
+ <div className="flex flex-col gap-6">
31
+ <div>
32
+ <h1 className="font-heading text-2xl font-bold tracking-tight">Playground</h1>
33
+ <p className="text-sm text-muted-foreground">
34
+ Every component, hook and helper in the template, working on one page. Each card shows the file it comes
35
+ from.
36
+ </p>
37
+ </div>
38
+
39
+ {SECTIONS.map(({ id, title, subtitle, Component }) => (
40
+ <section key={id} id={id} className="space-y-3">
41
+ <HeadingComponent title={title} subtitle={subtitle} size="section" />
42
+ <Component />
43
+ </section>
44
+ ))}
45
+ </div>
46
+ </PageLayout>
47
+ );
48
+ };
49
+
50
+ export default PlaygroundPage;
@@ -0,0 +1,29 @@
1
+ import { Route, Routes } from "react-router-dom";
2
+ import ProtectedRoute from "./ProtectedRoute";
3
+ import SignupPage from "@/pages/auth/SignupPage";
4
+ import LoginPage from "@/pages/auth/LoginPage";
5
+ import ForgotPasswordPage from "@/pages/auth/ForgotPasswordPage";
6
+ import LandingPage from "@/pages/views/LandingPage";
7
+ import DashboardPage from "@/pages/views/DashboardPage";
8
+ import ComponentsPage from "@/pages/views/ComponentsPage";
9
+ import PlaygroundPage from "@/pages/views/PlaygroundPage";
10
+ import NotFoundPage from "@/pages/views/NotFoundPage";
11
+
12
+ const AppRoutes = () => {
13
+ return (
14
+ <Routes>
15
+ <Route path="/" element={<LandingPage />} />
16
+ <Route path="/signup" element={<SignupPage />} />
17
+ <Route path="/login" element={<LoginPage />} />
18
+ <Route path="/forgot-password" element={<ForgotPasswordPage />} />
19
+ <Route element={<ProtectedRoute />}>
20
+ <Route path="/dashboard" element={<DashboardPage />} />
21
+ <Route path="/components" element={<ComponentsPage />} />
22
+ <Route path="/playground" element={<PlaygroundPage />} />
23
+ <Route path="*" element={<NotFoundPage />} />
24
+ </Route>
25
+ </Routes>
26
+ );
27
+ };
28
+
29
+ export default AppRoutes;
@@ -0,0 +1,18 @@
1
+ import { useEffect } from "react";
2
+ import { Outlet, useNavigate } from "react-router-dom";
3
+ import { getToken } from "@/constants/constant";
4
+ import { handleSessionExpire } from "@/utils/handleSessionExpire";
5
+
6
+ const ProtectedRoute = () => {
7
+ const navigate = useNavigate();
8
+
9
+ useEffect(() => {
10
+ if (!getToken()) {
11
+ handleSessionExpire({ navigate, showToast: true, message: "Log in to continue." });
12
+ }
13
+ }, []);
14
+
15
+ return <Outlet />;
16
+ };
17
+
18
+ export default ProtectedRoute;
@@ -0,0 +1,17 @@
1
+ const escapeCell = (value) => {
2
+ const text = String(value ?? "");
3
+ return /[",\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
4
+ };
5
+
6
+ export const exportCsv = ({ filename, columns, rows }) => {
7
+ const header = columns.map((col) => escapeCell(col.label)).join(",");
8
+ const body = rows.map((row) => columns.map((col) => escapeCell(row[col.key])).join(","));
9
+ const blob = new Blob([[header, ...body].join("\n")], { type: "text/csv;charset=utf-8;" });
10
+
11
+ const url = URL.createObjectURL(blob);
12
+ const link = document.createElement("a");
13
+ link.href = url;
14
+ link.download = filename;
15
+ link.click();
16
+ URL.revokeObjectURL(url);
17
+ };
@@ -0,0 +1,19 @@
1
+ export const formatCurrency = ({ value, currency = "USD" }) => {
2
+ if (value === null || value === undefined || isNaN(Number(value))) return "-";
3
+
4
+ const options = {
5
+ style: "currency",
6
+ currency,
7
+ minimumFractionDigits: 0,
8
+ maximumFractionDigits: 2,
9
+ };
10
+
11
+ try {
12
+ return new Intl.NumberFormat("en-US", options).format(Number(value));
13
+ } catch {
14
+ return new Intl.NumberFormat("en-US", {
15
+ ...options,
16
+ currency: "USD",
17
+ }).format(Number(value));
18
+ }
19
+ };
@@ -0,0 +1,34 @@
1
+ export const formatDateTime = ({ dateInput, type = "full" }) => {
2
+ if (!dateInput) return "-";
3
+
4
+ const date = new Date(dateInput);
5
+
6
+ const formats = {
7
+ date: {
8
+ year: "numeric",
9
+ month: "short",
10
+ day: "2-digit",
11
+ },
12
+
13
+ time: {
14
+ hour: "2-digit",
15
+ minute: "2-digit",
16
+ hour12: true,
17
+ },
18
+
19
+ datetime: {
20
+ year: "numeric",
21
+ month: "short",
22
+ day: "2-digit",
23
+ hour: "2-digit",
24
+ minute: "2-digit",
25
+ hour12: true,
26
+ },
27
+
28
+ iso: {},
29
+ };
30
+
31
+ if (type === "iso") return date.toISOString();
32
+
33
+ return new Intl.DateTimeFormat("en-US", formats[type] || formats.full).format(date);
34
+ };
@@ -0,0 +1,22 @@
1
+ import { toast } from "sonner";
2
+
3
+ const LOGIN_PATH = "/login";
4
+ const SESSION_TOAST_ID = "session-expired";
5
+
6
+ export const handleSessionExpire = ({ navigate = null, showToast = true, message = null }) => {
7
+ localStorage.clear();
8
+
9
+ if (window.location.pathname !== LOGIN_PATH) {
10
+ if (navigate) {
11
+ navigate(LOGIN_PATH, { replace: true });
12
+ } else {
13
+ window.location.href = LOGIN_PATH;
14
+ }
15
+ }
16
+
17
+ if (showToast) {
18
+ toast.error(message || "Your session has expired. Please log in again.", {
19
+ id: SESSION_TOAST_ID,
20
+ });
21
+ }
22
+ };
@@ -0,0 +1,34 @@
1
+ const isDev = true;
2
+
3
+ const getTime = () => new Date().toISOString();
4
+
5
+ const logger = {
6
+ debug: (...args) => {
7
+ if (!isDev) return;
8
+ console.log(`[DEBUG ${getTime()}]`, ...args);
9
+ },
10
+
11
+ info: (...args) => {
12
+ if (!isDev) return;
13
+ console.info(`[INFO ${getTime()}]`, ...args);
14
+ },
15
+
16
+ warn: (...args) => {
17
+ if (!isDev) return;
18
+ console.warn(`[WARN ${getTime()}]`, ...args);
19
+ },
20
+
21
+ error: (...args) => {
22
+ console.error(`[ERROR ${getTime()}]`, ...args);
23
+ },
24
+
25
+ table: (data) => {
26
+ if (!isDev) return;
27
+ console.table(data);
28
+ },
29
+ clear: () => {
30
+ console.clear();
31
+ },
32
+ };
33
+
34
+ export default logger;
package/vite.config.js ADDED
@@ -0,0 +1,23 @@
1
+ import react, { reactCompilerPreset } from "@vitejs/plugin-react";
2
+ import babel from "@rolldown/plugin-babel";
3
+ import { defineConfig } from "vite";
4
+ import tailwindcss from "@tailwindcss/vite";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ export default defineConfig({
12
+ plugins: [react(), tailwindcss(), babel({ presets: [reactCompilerPreset()] })],
13
+ resolve: {
14
+ alias: {
15
+ "@": path.resolve(__dirname, "./src"),
16
+ },
17
+ },
18
+ server: {
19
+ open: true,
20
+ host: true,
21
+ port: 5000,
22
+ },
23
+ });