pejay-ui 1.3.1 → 1.3.3

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 CHANGED
@@ -130,6 +130,13 @@ Below is the list of components you can add. Each has a copyable command block w
130
130
  npx pejay-ui add dropdown/multiselect-input
131
131
  ```
132
132
 
133
+ ### Layouts
134
+
135
+ * **`layouts/lv1`**: A responsive, collapsible sidebar-based application layout.
136
+ ```bash
137
+ npx pejay-ui add layouts/lv1
138
+ ```
139
+
133
140
  ### Scaffolds & Templates
134
141
 
135
142
  * **`tanstack-query-client`**: Bare-bone TanStack Query client and context provider setup, copied directly into your project's `src/tanstack-query/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pejay-ui",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "description": "react ui components",
6
6
  "bin": {
package/registry.json CHANGED
@@ -236,5 +236,21 @@
236
236
  "targetDirName": "rtk-query",
237
237
  "files": ["templates/scaffolds/rtk-query"],
238
238
  "peerDependencies": ["@reduxjs/toolkit", "react-redux"]
239
+ },
240
+ "layouts/lv1": {
241
+ "name": "AppLayout",
242
+ "category": "layouts",
243
+ "files": [
244
+ "templates/layouts/lv1/app-layout.tsx",
245
+ "templates/layouts/lv1/sidebar-menu.tsx",
246
+ "templates/layouts/lv1/index.ts"
247
+ ],
248
+ "utils": ["cn.ts"],
249
+ "peerDependencies": [
250
+ "clsx",
251
+ "tailwind-merge",
252
+ "lucide-react"
253
+ ]
239
254
  }
240
255
  }
256
+
@@ -0,0 +1,194 @@
1
+ import { useState, useLayoutEffect, useEffect } from "react";
2
+ import { Menu, PanelLeftOpen, PanelRightOpen, X } from "lucide-react";
3
+ import { cn } from "@/utils/cn";
4
+ import { MenuSection, SidebarMenu } from "./sidebar-menu";
5
+
6
+
7
+ // ============================================================================
8
+ // Config
9
+ // ============================================================================
10
+
11
+ const menuConfig: MenuSection[] = [];
12
+
13
+ // ============================================================================
14
+ // Types
15
+ // ============================================================================
16
+
17
+ type Variant = "none" | "semi" | "full" | "hybrid";
18
+ type ActiveVariant = "none" | "semi" | "full";
19
+
20
+ // ============================================================================
21
+ // Hook
22
+ // ============================================================================
23
+
24
+ const useAppMenu = (variant: Variant) => {
25
+ const [expandMenu, setExpandMenu] = useState(false);
26
+ const [activeVariant, setActiveVariant] = useState<ActiveVariant>("none");
27
+
28
+ useEffect(() => {
29
+ const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") setExpandMenu(false); };
30
+ window.addEventListener("keydown", onKey);
31
+ return () => window.removeEventListener("keydown", onKey);
32
+ }, []);
33
+
34
+ useLayoutEffect(() => {
35
+ const onResize = () => {
36
+ const w = window.innerWidth;
37
+ if (variant === "hybrid") {
38
+ setActiveVariant(w >= 1024 ? "none" : w >= 768 ? "semi" : "full");
39
+ } else if (variant === "full") {
40
+ setActiveVariant(w >= 768 ? "none" : "full");
41
+ } else {
42
+ setActiveVariant(variant as ActiveVariant);
43
+ }
44
+ };
45
+ window.addEventListener("resize", onResize);
46
+ onResize();
47
+ return () => window.removeEventListener("resize", onResize);
48
+ }, [variant]);
49
+
50
+ return {
51
+ activeVariant,
52
+ isExpanded: activeVariant === "none" || expandMenu,
53
+ expandMenu,
54
+ setExpandMenu,
55
+ };
56
+ };
57
+
58
+ // ============================================================================
59
+ // AppLayout
60
+ // ============================================================================
61
+
62
+ export const AppLayout = ({ variant = "hybrid" }: { variant?: Variant }) => {
63
+ const { activeVariant, isExpanded, expandMenu, setExpandMenu } = useAppMenu(variant);
64
+
65
+ return (
66
+ <div className="flex flex-row flex-1 w-full h-screen overflow-hidden bg-[#0f0f11]">
67
+ {activeVariant === "full" && isExpanded && (
68
+ <div
69
+ className="fixed inset-0 bg-black/60 z-40 backdrop-blur-sm"
70
+ onClick={() => setExpandMenu(false)}
71
+ />
72
+ )}
73
+
74
+ <SidePanel
75
+ activeVariant={activeVariant}
76
+ isExpanded={isExpanded}
77
+ expandMenu={expandMenu}
78
+ setExpandMenu={setExpandMenu}
79
+ />
80
+
81
+ <div className="flex flex-col flex-1 h-full overflow-hidden">
82
+ <TopBar
83
+ activeVariant={activeVariant}
84
+ isExpanded={isExpanded}
85
+ setExpandMenu={setExpandMenu}
86
+ />
87
+ <MainArea />
88
+ </div>
89
+ </div>
90
+ );
91
+ };
92
+
93
+ // ============================================================================
94
+ // SidePanel
95
+ // ============================================================================
96
+
97
+ const SidePanel = ({
98
+ activeVariant,
99
+ isExpanded,
100
+ expandMenu,
101
+ setExpandMenu,
102
+ }: {
103
+ activeVariant: ActiveVariant;
104
+ isExpanded: boolean;
105
+ expandMenu: boolean;
106
+ setExpandMenu: (v: boolean) => void;
107
+ }) => {
108
+ const sidebar = (
109
+ <div className="flex flex-col bg-[#141417] border-r border-white/[0.06] h-full p-2 gap-2 w-full overflow-hidden shrink-0">
110
+ {/* Header */}
111
+ {activeVariant === "none" ? (
112
+ <div className="px-2.5 py-2 shrink-0 mb-1 flex items-center gap-2 text-sm font-bold text-white/80 select-none">
113
+ <Menu size={18} />
114
+ <span>Menu</span>
115
+ </div>
116
+ ) : (
117
+ <button
118
+ onClick={() => setExpandMenu(!expandMenu)}
119
+ aria-expanded={isExpanded}
120
+ className={cn(
121
+ "w-full shrink-0 flex items-center gap-2 rounded-lg text-white/60 hover:bg-white/5 hover:text-white/90 transition-all duration-150 cursor-pointer select-none font-bold text-sm",
122
+ isExpanded ? "px-2.5 h-9 justify-start mb-1" : "justify-center aspect-square p-2.5 w-auto"
123
+ )}
124
+ >
125
+ {isExpanded ? <PanelLeftOpen size={18} /> : <PanelRightOpen size={18} />}
126
+ {isExpanded && <span>Menu</span>}
127
+ </button>
128
+ )}
129
+
130
+ <SidebarMenu
131
+ config={menuConfig}
132
+ isExpanded={activeVariant === "full" ? true : isExpanded}
133
+ />
134
+ </div>
135
+ );
136
+
137
+ if (activeVariant === "full") {
138
+ return (
139
+ <div className={cn(
140
+ "fixed top-0 left-0 h-full z-50 w-52 transform transition-transform duration-300",
141
+ isExpanded ? "translate-x-0" : "-translate-x-full"
142
+ )}>
143
+ {sidebar}
144
+ <div className={cn(
145
+ "absolute left-full top-3 ml-3 transition-opacity duration-150",
146
+ expandMenu ? "opacity-100" : "opacity-0 pointer-events-none"
147
+ )}>
148
+ <button
149
+ onClick={() => setExpandMenu(false)}
150
+ className="w-9 h-9 flex items-center justify-center rounded-lg bg-white/10 text-white hover:bg-white/20 border border-white/10 cursor-pointer"
151
+ >
152
+ <X size={16} />
153
+ </button>
154
+ </div>
155
+ </div>
156
+ );
157
+ }
158
+
159
+ return (
160
+ <div className={cn("h-full transition-all duration-200 shrink-0", isExpanded ? "w-52" : "w-max")}>
161
+ {sidebar}
162
+ </div>
163
+ );
164
+ };
165
+
166
+ // ============================================================================
167
+ // TopBar / MainArea
168
+ // ============================================================================
169
+
170
+ const TopBar = ({
171
+ activeVariant,
172
+ isExpanded,
173
+ setExpandMenu,
174
+ }: {
175
+ activeVariant: ActiveVariant;
176
+ isExpanded: boolean;
177
+ setExpandMenu: (v: boolean) => void;
178
+ }) => (
179
+ <div className="flex items-center h-14 px-3 border-b border-white/[0.06] bg-[#141417] shrink-0">
180
+ {activeVariant === "full" && !isExpanded && (
181
+ <button
182
+ onClick={() => setExpandMenu(true)}
183
+ aria-label="Open Menu"
184
+ className="w-9 h-9 flex items-center justify-center rounded-lg text-white/50 hover:bg-white/5 hover:text-white/80 transition-all duration-150 cursor-pointer"
185
+ >
186
+ <PanelRightOpen size={18} />
187
+ </button>
188
+ )}
189
+ </div>
190
+ );
191
+
192
+ const MainArea = () => (
193
+ <div className="flex-1 w-full bg-[#0f0f11] h-full overflow-y-auto" />
194
+ );
@@ -0,0 +1,2 @@
1
+ export * from "./app-layout";
2
+ export * from "./sidebar-menu";
@@ -0,0 +1,120 @@
1
+ import { type ReactNode } from "react";
2
+ import { cn } from "@/utils/cn";
3
+
4
+ // ============================================================================
5
+ // Types
6
+ // ============================================================================
7
+
8
+ export interface MenuItem {
9
+ id: string | number;
10
+ label: string;
11
+ icon?: ReactNode;
12
+ link?: string;
13
+ children?: { id: string | number; label: string; link?: string; icon?: ReactNode }[];
14
+ }
15
+
16
+ export type MenuSection =
17
+ | { id: string | number; type: "item"; label: string; icon?: ReactNode; link?: string; divider?: boolean }
18
+ | { id: string | number; type: "group"; label: string; items: MenuItem[]; divider?: boolean }
19
+ | { id: string | number; type: "bottom"; items: MenuItem[]; divider?: boolean };
20
+
21
+ export interface SidebarMenuProps {
22
+ config: MenuSection[];
23
+ isExpanded: boolean;
24
+ activeId?: string | number;
25
+ onItemClick?: (id: string | number) => void;
26
+ }
27
+
28
+ // ============================================================================
29
+ // Menu Button
30
+ // ============================================================================
31
+
32
+ const MenuBtn = ({
33
+ label,
34
+ icon,
35
+ isExpanded,
36
+ isActive,
37
+ onClick,
38
+ }: {
39
+ label: string;
40
+ icon?: ReactNode;
41
+ isExpanded: boolean;
42
+ isActive?: boolean;
43
+ onClick?: () => void;
44
+ }) => (
45
+ <button
46
+ onClick={onClick}
47
+ className={cn(
48
+ "w-full flex items-center gap-2.5 rounded-lg text-sm font-medium transition-all duration-150 cursor-pointer select-none",
49
+ isExpanded ? "px-2.5 py-2 justify-start" : "p-2.5 justify-center aspect-square w-auto",
50
+ isActive ? "bg-white/10 text-white" : "text-white/50 hover:bg-white/5 hover:text-white/80"
51
+ )}
52
+ >
53
+ <span className="shrink-0 w-[18px] h-[18px] flex items-center justify-center">
54
+ {icon ?? <span className="text-[13px] font-bold font-mono">{label.charAt(0)}</span>}
55
+ </span>
56
+ {isExpanded && <span className="whitespace-nowrap">{label}</span>}
57
+ </button>
58
+ );
59
+
60
+ // ============================================================================
61
+ // SidebarMenu
62
+ // ============================================================================
63
+
64
+ export const SidebarMenu = ({ config, isExpanded, activeId, onItemClick }: SidebarMenuProps) => {
65
+ if (!config.length) return null;
66
+
67
+ const renderItem = (item: MenuItem) => (
68
+ <MenuBtn
69
+ key={item.id}
70
+ label={item.label}
71
+ icon={item.icon}
72
+ isExpanded={isExpanded}
73
+ isActive={item.id === activeId}
74
+ onClick={() => onItemClick?.(item.id)}
75
+ />
76
+ );
77
+
78
+ const topSections = config.filter((s) => s.type !== "bottom");
79
+ const bottomSections = config.filter((s) => s.type === "bottom");
80
+
81
+ const renderSection = (section: MenuSection) => {
82
+ const el =
83
+ section.type === "group" ? (
84
+ <div key={section.id} className={cn("flex flex-col gap-0.5 w-full", isExpanded && "mt-2 first:mt-0")}>
85
+ {isExpanded && (
86
+ <span className="text-[9px] uppercase font-bold tracking-widest text-white/25 px-2.5 py-1 select-none">
87
+ {section.label}
88
+ </span>
89
+ )}
90
+ {section.items.map(renderItem)}
91
+ </div>
92
+ ) : section.type === "bottom" ? (
93
+ <div key={section.id} className="flex flex-col gap-0.5 w-full">
94
+ {section.items.map(renderItem)}
95
+ </div>
96
+ ) : (
97
+ renderItem({ id: section.id, label: section.label, icon: section.icon, link: section.link })
98
+ );
99
+
100
+ return section.divider ? (
101
+ <div key={section.id} className="flex flex-col gap-0.5 w-full">
102
+ <div className="h-px bg-white/10 my-1.5 w-full" />
103
+ {el}
104
+ </div>
105
+ ) : el;
106
+ };
107
+
108
+ return (
109
+ <div className="flex flex-col justify-between flex-1 w-full h-full overflow-hidden gap-1">
110
+ <div className="flex flex-col gap-0.5 w-full overflow-y-auto flex-1">
111
+ {topSections.map(renderSection)}
112
+ </div>
113
+ {bottomSections.length > 0 && (
114
+ <div className="flex flex-col gap-0.5 w-full shrink-0">
115
+ {bottomSections.map(renderSection)}
116
+ </div>
117
+ )}
118
+ </div>
119
+ );
120
+ };
@@ -0,0 +1,107 @@
1
+ # Codebase Scaffold Audit & Analysis
2
+
3
+ This document provides a comprehensive structural and architectural analysis of the scaffold templates in `pejay-ui` (`templates/scaffolds/`). All scaffolds are ready-to-use boilerplate templates designed to be easily injected into react-based projects using the CLI.
4
+
5
+ ---
6
+
7
+ ## 1. Axios Scaffold (`axios-client`)
8
+ * **Target Directory**: `src/axios/`
9
+ * **Peer Dependencies**: `axios`
10
+ * **Files**:
11
+ * `index.ts`: Configures the base `axiosInstance` with a local port 5001 base URL and default configurations.
12
+ * `interceptors.ts`: Configures standard request and response interceptors.
13
+ * `request.ts`: Implements a type-safe wrapper over `axios` queries with customized `CustomAxiosRequestConfig` options (such as `skipErrorToast`).
14
+ * `endpoints.ts`: Declarative endpoint configurations helper (`createResourceEndpoints`).
15
+ * `api/one.api.ts` & `index.ts`: Implements API wrapper services mapping HTTP verbs (GET, POST, PUT, DELETE, and multipart/form-data POST) using endpoints.
16
+
17
+ ### 💡 Notable Architectural Design Patterns
18
+ * **Token Injection & Eject Pattern**: Setup function allows on-demand ejection of previous interceptors to prevent interceptor duplication when token state resets.
19
+ * **Multipart uploads**: Out-of-the-box helper configuration for `multipart/form-data` uploading.
20
+ * **Commented Best Practice Guides**: Includes detailed code comments discussing error handling strategies (global vs. screen-specific alerts like 400 Validation, 422 Forms, 409 Conflicts).
21
+
22
+ ---
23
+
24
+ ## 2. React Router Scaffold (`react-router-client`)
25
+ * **Target Directory**: `src/react-router/`
26
+ * **Peer Dependencies**: `react-router-dom`
27
+ * **Files**:
28
+ * `router/index.ts`: Builds the route hierarchy using the modern object-based router syntax (`createBrowserRouter`).
29
+ * `router/path.ts`: Declares route path constants.
30
+ * `router/guards/private.route.tsx` & `public.route.tsx`: Authentication routing guards.
31
+ * `router/layouts/`: Base layout wrapper components (`auth.layout.tsx`, `error.layout.tsx`, `main.layout.tsx`).
32
+ * `routes/`: Subfolders representing each page boundary with lazy component imports.
33
+ * `hook/useRouterSearch.ts`: Utility hook for robust search parameter reading.
34
+
35
+ ### 💡 Notable Architectural Design Patterns
36
+ * **Route Guards without Paths**: Centralizes auth decisions using pathless routes (layout routes) that encapsulate authentication checks before child route components mount.
37
+ * **Target Restoration Pattern**: कमेंट-दस्तावेज demonstrates how the private route guard passes `redirectTo` in query parameters, allowing the login flow to restore user navigation state seamlessly.
38
+ * **SEO & Static Prerendering (V7)**: Extensive documentation within route components illustrating route meta configurations and Nginx deployment configurations for serving pre-rendered static HTML structures.
39
+
40
+ ---
41
+
42
+ ## 3. Redux Store Scaffold (`redux-store-client`)
43
+ * **Target Directory**: `src/redux-store/`
44
+ * **Peer Dependencies**: `@reduxjs/toolkit`, `react-redux`, `redux-persist`
45
+ * **Files**:
46
+ * `store.ts`: Configures store via `configureStore` with middleware handling to bypass serialization warnings for `redux-persist` actions.
47
+ * `reducers.ts`: Combines slices, setting up selective slice persistence configurations.
48
+ * `slices/`: Example RTK slices (`one.slice.ts` & `two.slice.ts`) containing state declarations, actions, and reducers.
49
+ * `selector/`: Selectors implementing memoized state reading.
50
+
51
+ ### 💡 Notable Architectural Design Patterns
52
+ * **Bypassing Redux-Persist Serialization Warnings**: Custom configureStore config overrides standard serialization check constraints to allow redux-persist lifecycle actions (`FLUSH`, `REHYDRATE`, etc.) without throwing warnings.
53
+ * **Slice-Level Persistence Configuration**: Configured to show developers how to selectively persist specific slices using `storageLocal` instead of forcing entire store persistence.
54
+
55
+ ---
56
+
57
+ ## 4. RTK Query Scaffold (`rtk-query-client`)
58
+ * **Target Directory**: `src/rtk-query/`
59
+ * **Peer Dependencies**: `@reduxjs/toolkit`, `react-redux`
60
+ * **Files**:
61
+ * `baseApi.ts`: Initial API framework setup using `createApi` and injecting custom base queries.
62
+ * `baseQuery.ts`: Configures base query parameters.
63
+ * `queryTags.ts`: Declarative cache tag declarations.
64
+ * `middlewares.ts`: RTK query middleware definitions.
65
+ * `endpoints/`: Route query endpoint modules.
66
+
67
+ ### 💡 Notable Architectural Design Patterns
68
+ * **Centralized Cache Tag Management**: Centralizes tag types in a single array mapping configuration to prevent magic strings and cache invalidation issues.
69
+ * **Ready-to-Plug Store Middleware**: Clear documentation showing how to connect RTK Query's reducer and middleware inside the primary Redux root store.
70
+
71
+ ---
72
+
73
+ ## 5. TanStack Query Scaffold (`tanstack-query-client`)
74
+ * **Target Directory**: `src/tanstack-query/`
75
+ * **Peer Dependencies**: `@tanstack/react-query`
76
+ * **Files**:
77
+ * `client.ts`: Configures a custom type-safe `apiClient` wrapper around the web fetch API.
78
+ * `api-base.ts`: Standard configuration settings.
79
+ * `api-queries.ts` / `api-mutations.ts`: API query hooks.
80
+ * `module/`: Modular services, mutations, queries, mappers, and cache keys configuration.
81
+
82
+ ### 💡 Notable Architectural Design Patterns
83
+ * **Type-Safe API Wrapper Client**: Provides custom `.get()`, `.post()`, `.put()`, `.patch()`, and `.delete()` wrappers on `fetch` with automated JSON serialization guards.
84
+ * **Separation of Concerns**: Structures files with clean mappers (decoupling API responses from UI representations) and query key factories (avoiding string typos).
85
+
86
+ ---
87
+
88
+ ## 6. TanStack Router Scaffold (`tanstack-router-client`)
89
+ * **Target Directory**: `src/tanstack-router/`
90
+ * **Peer Dependencies**: `@tanstack/react-router`
91
+ * **Files**:
92
+ * `router.ts`: Initializes Tanstack `createRouter` and configures defaults.
93
+ * `routes/`: File-based route trees (`__root.tsx`, `_app.tsx`, `_auth.tsx`).
94
+ * `layout/`: UI layouts (`app.layout.tsx`, `auth.layout.tsx`, etc.).
95
+ * `page/`: Visual target pages.
96
+
97
+ ### 💡 Notable Architectural Design Patterns
98
+ * **Intent-Based Preloading**: Uses `defaultPreload: "intent"` to preload route bundles and datasets immediately when a user hovers over a link, maximizing perceived UI responsiveness.
99
+ * **TypeScript Route Declaration Merging**: Employs TypeScript interface merging (`Register`) to ensure global route tree parameters are fully typed across the application.
100
+
101
+ ---
102
+
103
+ ## 🛠️ Verification & Quality Assessment
104
+
105
+ * **Relative Imports**: All internal template files reference other module files using relative imports (`./` or `../`). They do not depend on absolute webpack/vite aliases (e.g. `@/`), making them immediately compatible with any folder structure they are copied into.
106
+ * **Code Cleanliness**: Types are cleanly defined, variables are appropriately scoped, and hooks clean up event listeners on unmount.
107
+ * **Documentation Quality**: Comments explain the architectural "Why" (e.g., Suspense vs Component Skeletons, SEO Nginx server setup) instead of just repeating what the code does. This is extremely helpful for developers installing these scaffolds.
@@ -29,21 +29,25 @@ echo.
29
29
 
30
30
  set "packages="
31
31
 
32
- call :ask "@reduxjs/toolkit"
33
32
  call :ask "@tailwindcss/vite"
33
+ call :ask "tailwindcss"
34
+ call :ask "tailwind-merge"
34
35
  call :ask "clsx"
35
- call :ask "date-fns"
36
- call :ask "dayjs"
37
- call :ask "@floating-ui/react"
38
- call :ask "lucide-react"
39
36
  call :ask "react-hook-form"
40
- call :ask "react-redux"
41
37
  call :ask "react-router-dom"
42
- call :ask "tailwind-merge"
43
- call :ask "tailwindcss"
44
38
  call :ask "@tanstack/react-query"
45
- call :ask "zod"
39
+ call :ask "@tanstack/react-router"
40
+ call :ask "@reduxjs/toolkit"
41
+ call :ask "react-redux"
42
+ call :ask "redux-persist"
43
+ call :ask "lucide-react"
44
+ call :ask "react-icons"
45
+ call :ask "axios"
46
46
  call :ask "zustand"
47
+ call :ask "zod"
48
+ call :ask "@hookform/resolvers"
49
+ call :ask "@floating-ui/react"
50
+ call :ask "framer-motion"
47
51
 
48
52
  if not "!packages!"=="" (
49
53
  echo.
@@ -222,51 +226,90 @@ type nul > components\global\index.ts
222
226
  mkdir hooks
223
227
  type nul > hooks\index.ts
224
228
 
225
- mkdir lib
226
- type nul > lib\index.ts
227
-
228
- mkdir routes
229
- type nul > routes\index.ts
230
- mkdir routes\dashboard
231
- type nul > routes\dashboard\index.ts
232
- mkdir routes\dashboard\components
233
- type nul > routes\dashboard\components\index.ts
234
- mkdir routes\dashboard\hooks
235
- type nul > routes\dashboard\hooks\index.ts
236
- mkdir routes\auth
237
- type nul > routes\auth\index.ts
238
- mkdir routes\auth\components
239
- type nul > routes\auth\components\index.ts
240
- mkdir routes\auth\hooks
241
- type nul > routes\auth\hooks\index.ts
242
-
243
- mkdir router
244
- mkdir router\guards
245
- type nul > router\guards\guard.public.ts
246
- type nul > router\guards\guard.private.ts
247
- mkdir router\layout
248
- type nul > router\layout\layout.public.ts
249
- type nul > router\layout\layout.main.ts
250
- type nul > router\layout\layout.auth.ts
251
- type nul > router\index.ts
252
-
253
- mkdir providers
254
- type nul > providers\index.ts
255
- type nul > providers\app.provider.ts
256
-
257
- mkdir services
258
- type nul > services\index.ts
259
- mkdir services\dashboard
260
- mkdir services\auth
261
-
262
- mkdir store
263
- type nul > store\index.ts
264
-
265
229
  mkdir utils
266
230
  type nul > utils\index.ts
267
231
 
268
232
  cd ..
269
233
 
234
+ :: ─────────────────────────────────────────
235
+ :: pejay-ui initialization and scaffolding
236
+ :: ─────────────────────────────────────────
237
+ set "hasAxios="
238
+ set "hasTanstackQuery="
239
+ set "hasTanstackRouter="
240
+ set "hasReactRouter="
241
+ set "hasRedux="
242
+ set "hasPersist="
243
+
244
+ for %%p in (!packages!) do (
245
+ if "%%p"=="axios" set "hasAxios=1"
246
+ if "%%p"=="@tanstack/react-query" set "hasTanstackQuery=1"
247
+ if "%%p"=="@tanstack/react-router" set "hasTanstackRouter=1"
248
+ if "%%p"=="react-router-dom" set "hasReactRouter=1"
249
+ if "%%p"=="@reduxjs/toolkit" set "hasRedux=1"
250
+ if "%%p"=="react-redux" set "hasRedux=1"
251
+ if "%%p"=="redux-persist" set "hasPersist=1"
252
+ )
253
+
254
+ set "needsInit="
255
+ if defined hasAxios set "needsInit=1"
256
+ if defined hasTanstackQuery set "needsInit=1"
257
+ if defined hasTanstackRouter set "needsInit=1"
258
+ if defined hasReactRouter set "needsInit=1"
259
+ if defined hasRedux set "needsInit=1"
260
+
261
+ if defined needsInit (
262
+ echo.
263
+ echo Initializing pejay-ui...
264
+ call npx pejay-ui init
265
+
266
+ if defined hasAxios (
267
+ echo Adding axios-client...
268
+ call npx pejay-ui add axios-client
269
+ )
270
+ if defined hasTanstackQuery (
271
+ echo Adding tanstack-query-client...
272
+ call npx pejay-ui add tanstack-query-client
273
+ )
274
+ if defined hasTanstackRouter (
275
+ echo Adding tanstack-router-client...
276
+ call npx pejay-ui add tanstack-router-client
277
+ )
278
+ if defined hasReactRouter (
279
+ echo Adding react-router-client...
280
+ call npx pejay-ui add react-router-client
281
+ )
282
+ if defined hasRedux (
283
+ if defined hasPersist (
284
+ echo Adding redux-store-client...
285
+ call npx pejay-ui add redux-store-client
286
+ ) else (
287
+ echo.
288
+ echo You selected Redux. Which template would you like to add?
289
+ echo [1] Redux Store (redux-store-client)
290
+ echo [2] RTK Query (rtk-query-client)
291
+ echo [3] Both
292
+ echo [4] None
293
+ set "reduxAns=1"
294
+ set /p "reduxAns=Enter choice (1-4, default 1): "
295
+ if "!reduxAns!"=="2" (
296
+ echo Adding rtk-query-client...
297
+ call npx pejay-ui add rtk-query-client
298
+ ) else if "!reduxAns!"=="3" (
299
+ echo Adding redux-store-client...
300
+ call npx pejay-ui add redux-store-client
301
+ echo Adding rtk-query-client...
302
+ call npx pejay-ui add rtk-query-client
303
+ ) else if "!reduxAns!"=="4" (
304
+ rem Do nothing
305
+ ) else (
306
+ echo Adding redux-store-client...
307
+ call npx pejay-ui add redux-store-client
308
+ )
309
+ )
310
+ )
311
+ )
312
+
270
313
  echo.
271
314
  echo Project '%projectName%' setup complete!
272
315
  endlocal
@@ -63,28 +63,33 @@ Write-Output "Installing dependencies"
63
63
 
64
64
 
65
65
  $availablePackages = @(
66
- "@reduxjs/toolkit",
67
66
  "@tailwindcss/vite",
67
+ "tailwindcss",
68
+ "tailwind-merge",
68
69
  "clsx",
69
- "date-fns",
70
- "dayjs",
71
- "floating-ui",
72
- "lucide-react",
73
- "react-form-hook",
74
- "react-redux",
70
+ "react-hook-form",
75
71
  "react-router-dom",
76
- "tailwind-merge",
77
- "tailwindcss",
78
- "tanstack-query",
72
+ "@tanstack/react-query",
73
+ "@tanstack/react-router",
74
+ "@reduxjs/toolkit",
75
+ "react-redux",
76
+ "redux-persist",
77
+ "lucide-react",
78
+ "react-icons",
79
+ "axios",
80
+ "zustand",
79
81
  "zod",
80
- "zustand"
82
+ "@hookform/resolvers",
83
+ "@floating-ui/react",
84
+ "framer-motion"
81
85
  )
82
86
 
83
87
  $selectedPackages = Show-MultiSelect -Options $availablePackages -Title "Select packages to install (SPACE to toggle, ENTER to confirm):"
84
88
 
85
89
  if ($selectedPackages.Count -gt 0) {
86
90
  npm install
87
- npm install $selectedPackages
91
+ $packageString = $selectedPackages -join " "
92
+ Invoke-Expression "npm install $packageString"
88
93
  } else {
89
94
  Write-Output "No packages selected, skipping..."
90
95
  }
@@ -270,49 +275,66 @@ Set-Content "components/global/index.ts" ""
270
275
  mkdir hooks
271
276
  Set-Content "hooks/index.ts" ""
272
277
 
273
- mkdir lib
274
- Set-Content "lib/index.ts" ""
275
-
276
- mkdir routes
277
- Set-Content "routes/index.ts" ""
278
- mkdir routes/dashboard
279
- Set-Content "routes/dashboard/index.ts" ""
280
- mkdir routes/dashboard/components
281
- Set-Content "routes/dashboard/components/index.ts" ""
282
- mkdir routes/dashboard/hooks
283
- Set-Content "routes/dashboard/hooks/index.ts" ""
284
- mkdir routes/auth
285
- Set-Content "routes/auth/index.ts" ""
286
- mkdir routes/auth/components
287
- Set-Content "routes/auth/components/index.ts" ""
288
- mkdir routes/auth/hooks
289
- Set-Content "routes/auth/hooks/index.ts" ""
290
-
291
- mkdir router
292
- mkdir router/guards
293
- Set-Content "router/guards/guard.public.ts" ""
294
- Set-Content "router/guards/guard.private.ts" ""
295
- mkdir router/layout
296
- Set-Content "router/layout/layout.public.ts" ""
297
- Set-Content "router/layout/layout.main.ts" ""
298
- Set-Content "router/layout/layout.auth.ts" ""
299
- Set-Content "router/index.ts" ""
300
-
301
- mkdir providers
302
- Set-Content "providers/index.ts" ""
303
- Set-Content "providers/app.provider.ts" ""
304
-
305
- mkdir services
306
- Set-Content "services/index.ts" ""
307
- mkdir services/dashboard
308
- mkdir services/auth
309
-
310
- mkdir store
311
- Set-Content "store/index.ts" ""
312
-
313
278
  mkdir utils
314
279
  Set-Content "utils/index.ts" ""
315
280
 
316
281
  Set-Location ..
317
282
 
283
+ # ─────────────────────────────────────────
284
+ # pejay-ui initialization and scaffolding
285
+ # ─────────────────────────────────────────
286
+ $needsInit = $false
287
+ $templatesToAdd = @()
288
+
289
+ if ($selectedPackages -contains "axios") {
290
+ $needsInit = $true
291
+ $templatesToAdd += "axios-client"
292
+ }
293
+ if ($selectedPackages -contains "@tanstack/react-query") {
294
+ $needsInit = $true
295
+ $templatesToAdd += "tanstack-query-client"
296
+ }
297
+ if ($selectedPackages -contains "@tanstack/react-router") {
298
+ $needsInit = $true
299
+ $templatesToAdd += "tanstack-router-client"
300
+ }
301
+ if ($selectedPackages -contains "react-router-dom") {
302
+ $needsInit = $true
303
+ $templatesToAdd += "react-router-client"
304
+ }
305
+ if ($selectedPackages -contains "@reduxjs/toolkit" -or $selectedPackages -contains "react-redux") {
306
+ $needsInit = $true
307
+ if ($selectedPackages -contains "redux-persist") {
308
+ $templatesToAdd += "redux-store-client"
309
+ } else {
310
+ Write-Output ""
311
+ Write-Output "You selected Redux. Which template would you like to add?"
312
+ Write-Output "1) Redux Store (redux-store-client)"
313
+ Write-Output "2) RTK Query (rtk-query-client)"
314
+ Write-Output "3) Both"
315
+ Write-Output "4) None"
316
+ $reduxChoice = Read-Host "Select option (1-4, default 1)"
317
+ if ($reduxChoice -eq "2") {
318
+ $templatesToAdd += "rtk-query-client"
319
+ } elseif ($reduxChoice -eq "3") {
320
+ $templatesToAdd += "redux-store-client"
321
+ $templatesToAdd += "rtk-query-client"
322
+ } elseif ($reduxChoice -eq "4") {
323
+ # None
324
+ } else {
325
+ $templatesToAdd += "redux-store-client"
326
+ }
327
+ }
328
+ }
329
+
330
+ if ($needsInit) {
331
+ Write-Output "`nInitializing pejay-ui..."
332
+ npx pejay-ui init
333
+
334
+ foreach ($template in $templatesToAdd) {
335
+ Write-Output "Adding template: $template..."
336
+ npx pejay-ui add $template
337
+ }
338
+ }
339
+
318
340
  Write-Output "✅ Project '$projectName' setup complete!"