pejay-ui 1.2.2 → 1.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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/registry.json +33 -1
  3. package/templates/notes/create-pejay.md +222 -0
  4. package/templates/notes/notes-v1.md +516 -0
  5. package/templates/notes/notes-v2.md +764 -0
  6. package/templates/notes/notes-v3.md +574 -0
  7. package/templates/notes/notes-v4.md +811 -0
  8. package/templates/notes/notes-v5.md +579 -0
  9. package/templates/notes/notes-vf+1.md +311 -0
  10. package/templates/notes/notes-vfinal.md +852 -0
  11. package/templates/scaffolds/axios/api/index.ts +40 -0
  12. package/templates/scaffolds/axios/api/one.api.ts +94 -0
  13. package/templates/scaffolds/axios/endpoints.ts +9 -0
  14. package/templates/scaffolds/axios/index.ts +26 -0
  15. package/templates/scaffolds/axios/interceptors.ts +103 -0
  16. package/templates/scaffolds/axios/request.ts +32 -0
  17. package/templates/scaffolds/react-router/hook/useRouterSearch.ts +8 -0
  18. package/templates/scaffolds/react-router/router/guards/private.route.tsx +1 -0
  19. package/templates/scaffolds/react-router/router/index.ts +26 -0
  20. package/templates/scaffolds/react-router/router/layouts/error.layout.tsx +1 -1
  21. package/templates/scaffolds/redux-store/middlewares.ts +0 -0
  22. package/templates/scaffolds/redux-store/reducers.ts +30 -0
  23. package/templates/scaffolds/redux-store/selector/one.selector.ts +43 -0
  24. package/templates/scaffolds/redux-store/selector/two.selector.ts +11 -0
  25. package/templates/scaffolds/redux-store/slices/one.slice.ts +202 -0
  26. package/templates/scaffolds/redux-store/slices/two.slice.ts +21 -0
  27. package/templates/scaffolds/redux-store/store.ts +38 -0
  28. package/templates/scaffolds/rtk-query/baseApi.ts +24 -0
  29. package/templates/scaffolds/rtk-query/baseQuery.ts +12 -0
  30. package/templates/scaffolds/rtk-query/endpoints/api.one.ts +82 -0
  31. package/templates/scaffolds/rtk-query/endpoints/index.ts +1 -0
  32. package/templates/scaffolds/rtk-query/middlewares.ts +11 -0
  33. package/templates/scaffolds/rtk-query/queryTags.ts +13 -0
  34. package/templates/scaffolds/tanstack-query/api-base.ts +68 -68
  35. package/templates/scaffolds/tanstack-query/api-queries.ts +0 -19
  36. package/templates/scaffolds/tanstack-query/client.ts +8 -0
  37. package/templates/scaffolds/tanstack-query/module/index.ts +12 -12
  38. package/templates/scaffolds/tanstack-query/module/keys.ts +17 -17
  39. package/templates/scaffolds/tanstack-query/module/mappers.ts +15 -15
  40. package/templates/scaffolds/tanstack-query/module/mutations.ts +59 -55
  41. package/templates/scaffolds/tanstack-query/module/queries.ts +145 -156
  42. package/templates/scaffolds/tanstack-query/module/services.ts +74 -66
  43. package/templates/scaffolds/tanstack-router/layout/404.layout.tsx +3 -0
  44. package/templates/scaffolds/tanstack-router/layout/app.layout.tsx +10 -0
  45. package/templates/scaffolds/tanstack-router/layout/auth.layout.tsx +10 -0
  46. package/templates/scaffolds/tanstack-router/layout/error.layout.tsx +3 -0
  47. package/templates/scaffolds/tanstack-router/page/auth/login.tsx +3 -0
  48. package/templates/scaffolds/tanstack-router/page/one/index.tsx +3 -0
  49. package/templates/scaffolds/tanstack-router/page/one/one-id.tsx +128 -0
  50. package/templates/scaffolds/tanstack-router/router.ts +90 -0
  51. package/templates/scaffolds/tanstack-router/routes/_404.tsx +0 -0
  52. package/templates/scaffolds/tanstack-router/routes/__root.tsx +9 -0
  53. package/templates/scaffolds/tanstack-router/routes/_app.tsx +6 -0
  54. package/templates/scaffolds/tanstack-router/routes/_auth.tsx +6 -0
  55. package/templates/scaffolds/tanstack-router/routes/_error.tsx +0 -0
  56. package/templates/scaffolds/tanstack-router/routes/auth/login.tsx +6 -0
  57. package/templates/scaffolds/tanstack-router/routes/one/$id.tsx +191 -0
  58. package/templates/scaffolds/tanstack-router/routes/one/index.tsx +6 -0
  59. package/templates/scripts/setup.bat +284 -0
  60. package/templates/scripts/setup.ps1 +318 -0
@@ -0,0 +1,574 @@
1
+ # TanStack Router - Advanced / Overlooked APIs
2
+
3
+ These APIs are not used every day like:
4
+
5
+ ```tsx
6
+ Route.useParams()
7
+ Route.useSearch()
8
+ useNavigate()
9
+ ```
10
+
11
+ but become very useful in larger applications.
12
+
13
+ ---
14
+
15
+ # useRouter()
16
+
17
+ Provides access to the router instance from inside React components.
18
+
19
+ ```tsx
20
+ import { useRouter } from "@tanstack/react-router";
21
+
22
+ export default function MyPage() {
23
+ const router = useRouter();
24
+
25
+ return <></>;
26
+ }
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Common Usage
32
+
33
+ ### Navigate Programmatically
34
+
35
+ ```tsx
36
+ router.navigate({
37
+ to: "/users",
38
+ });
39
+ ```
40
+
41
+ Usually you'll use:
42
+
43
+ ```tsx
44
+ const navigate = useNavigate();
45
+ ```
46
+
47
+ instead.
48
+
49
+ But router navigation is useful when you need access to other router APIs as well.
50
+
51
+ ---
52
+
53
+ ### Invalidate Router
54
+
55
+ Force loaders to rerun.
56
+
57
+ ```tsx
58
+ await router.invalidate();
59
+ ```
60
+
61
+ Useful after:
62
+
63
+ ```txt
64
+ Login
65
+ Logout
66
+ Location Change
67
+ Permission Change
68
+ ```
69
+
70
+ Example:
71
+
72
+ ```tsx
73
+ const handleLogout = async () => {
74
+ await logout();
75
+
76
+ await router.invalidate();
77
+ };
78
+ ```
79
+
80
+ This causes active route loaders to re-evaluate.
81
+
82
+ ---
83
+
84
+ ### Access Current Router State
85
+
86
+ ```tsx
87
+ console.log(router.state);
88
+ ```
89
+
90
+ Contains:
91
+
92
+ ```txt
93
+ Current Location
94
+ Current Matches
95
+ Pending Navigation
96
+ Loaded Routes
97
+ ```
98
+
99
+ Mostly useful for debugging.
100
+
101
+ ---
102
+
103
+ # useRouterState()
104
+
105
+ Subscribe to router state updates.
106
+
107
+ ```tsx
108
+ import { useRouterState } from "@tanstack/react-router";
109
+
110
+ const routerState = useRouterState();
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Example
116
+
117
+ ```tsx
118
+ const routerState = useRouterState();
119
+
120
+ console.log(routerState.location.pathname);
121
+ ```
122
+
123
+ Current route:
124
+
125
+ ```txt
126
+ /users/123
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Loading Indicator Example
132
+
133
+ Global loading bar.
134
+
135
+ ```tsx
136
+ const isLoading = useRouterState({
137
+ select: (state) =>
138
+ state.status === "pending",
139
+ });
140
+ ```
141
+
142
+ Example:
143
+
144
+ ```tsx
145
+ return (
146
+ <>
147
+ {isLoading && <TopProgressBar />}
148
+ </>
149
+ );
150
+ ```
151
+
152
+ Useful for:
153
+
154
+ ```txt
155
+ NProgress
156
+ Top Loaders
157
+ Global Skeletons
158
+ ```
159
+
160
+ ---
161
+
162
+ # Route.useRouteContext()
163
+
164
+ Read route context.
165
+
166
+ Route Context is provided when creating the router.
167
+
168
+ Example:
169
+
170
+ ```tsx
171
+ const router = createRouter({
172
+ routeTree,
173
+ context: {
174
+ auth,
175
+ queryClient,
176
+ },
177
+ });
178
+ ```
179
+
180
+ ---
181
+
182
+ Read inside route:
183
+
184
+ ```tsx
185
+ const context =
186
+ Route.useRouteContext();
187
+ ```
188
+
189
+ Result:
190
+
191
+ ```tsx
192
+ context.auth
193
+ context.queryClient
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Example
199
+
200
+ ```tsx
201
+ const { auth } =
202
+ Route.useRouteContext();
203
+
204
+ if (!auth.user) {
205
+ return null;
206
+ }
207
+ ```
208
+
209
+ ---
210
+
211
+ # Route.useMatch()
212
+
213
+ Access current route match information.
214
+
215
+ ```tsx
216
+ const match = Route.useMatch();
217
+ ```
218
+
219
+ Contains information about:
220
+
221
+ ```txt
222
+ Route
223
+ Params
224
+ Search
225
+ Location
226
+ ```
227
+
228
+ Useful when building:
229
+
230
+ ```txt
231
+ Breadcrumbs
232
+ Debug Panels
233
+ Route-aware Components
234
+ ```
235
+
236
+ ---
237
+
238
+ # Route.useLoaderDeps()
239
+
240
+ Used when route loaders depend on values.
241
+
242
+ Example:
243
+
244
+ ```tsx
245
+ loaderDeps: ({ search }) => ({
246
+ search: search.search,
247
+ });
248
+ ```
249
+
250
+ Read later:
251
+
252
+ ```tsx
253
+ const deps =
254
+ Route.useLoaderDeps();
255
+ ```
256
+
257
+ Useful for advanced loader patterns.
258
+
259
+ Not commonly needed in CRUD applications.
260
+
261
+ ---
262
+
263
+ # Route.useLoaderData()
264
+
265
+ Read value returned by loader.
266
+
267
+ Route:
268
+
269
+ ```tsx
270
+ loader: async () => {
271
+ return {
272
+ title: "Users",
273
+ };
274
+ }
275
+ ```
276
+
277
+ Component:
278
+
279
+ ```tsx
280
+ const data =
281
+ Route.useLoaderData();
282
+ ```
283
+
284
+ Result:
285
+
286
+ ```tsx
287
+ data.title
288
+ ```
289
+
290
+ ---
291
+
292
+ ## When To Use
293
+
294
+ Good for:
295
+
296
+ ```txt
297
+ Page Metadata
298
+ Simple Route Data
299
+ Non-query Data
300
+ ```
301
+
302
+ ---
303
+
304
+ ## When Not To Use
305
+
306
+ If you're already using:
307
+
308
+ ```tsx
309
+ useSuspenseQuery()
310
+ ```
311
+
312
+ then usually prefer:
313
+
314
+ ```tsx
315
+ Loader
316
+
317
+ ensureQueryData()
318
+
319
+ Component
320
+
321
+ useSuspenseQuery()
322
+ ```
323
+
324
+ to leverage caching and invalidation.
325
+
326
+ ---
327
+
328
+ # Route.useParams()
329
+
330
+ Read URL params.
331
+
332
+ URL:
333
+
334
+ ```txt
335
+ /users/123
336
+ ```
337
+
338
+ Route:
339
+
340
+ ```txt
341
+ /users/$id
342
+ ```
343
+
344
+ Usage:
345
+
346
+ ```tsx
347
+ const { id } =
348
+ Route.useParams();
349
+ ```
350
+
351
+ Result:
352
+
353
+ ```tsx
354
+ id === "123"
355
+ ```
356
+
357
+ ---
358
+
359
+ # Route.useSearch()
360
+
361
+ Read validated search params.
362
+
363
+ URL:
364
+
365
+ ```txt
366
+ /users?search=john&type=active
367
+ ```
368
+
369
+ Usage:
370
+
371
+ ```tsx
372
+ const search =
373
+ Route.useSearch();
374
+ ```
375
+
376
+ Result:
377
+
378
+ ```tsx
379
+ {
380
+ search: "john",
381
+ type: "active",
382
+ }
383
+ ```
384
+
385
+ Fully typed.
386
+
387
+ ---
388
+
389
+ # Route.useNavigate()
390
+
391
+ Route-scoped navigation helper.
392
+
393
+ ```tsx
394
+ const navigate =
395
+ Route.useNavigate();
396
+ ```
397
+
398
+ Usage:
399
+
400
+ ```tsx
401
+ navigate({
402
+ search: {
403
+ page: 2,
404
+ },
405
+ });
406
+ ```
407
+
408
+ Useful when navigation should stay relative to the current route.
409
+
410
+ ---
411
+
412
+ # useCanGoBack() (Common Pattern)
413
+
414
+ TanStack doesn't provide a dedicated hook.
415
+
416
+ Typical implementation:
417
+
418
+ ```tsx
419
+ const canGoBack =
420
+ window.history.length > 1;
421
+ ```
422
+
423
+ or
424
+
425
+ ```tsx
426
+ router.history.canGoBack()
427
+ ```
428
+
429
+ depending on router/history setup.
430
+
431
+ Useful for:
432
+
433
+ ```txt
434
+ Back Buttons
435
+ Mobile Navigation
436
+ Drawers
437
+ ```
438
+
439
+ ---
440
+
441
+ # useMatchRoute()
442
+
443
+ Check if a route matches.
444
+
445
+ ```tsx
446
+ const matchRoute =
447
+ useMatchRoute();
448
+ ```
449
+
450
+ Example:
451
+
452
+ ```tsx
453
+ const isUsersPage =
454
+ matchRoute({
455
+ to: "/users",
456
+ });
457
+ ```
458
+
459
+ Useful for:
460
+
461
+ ```txt
462
+ Sidebar Active States
463
+ Menu Highlighting
464
+ Conditional UI
465
+ ```
466
+
467
+ ---
468
+
469
+ # Practical Daily Usage
470
+
471
+ For most CRM/Admin applications:
472
+
473
+ ```tsx
474
+ Route.useParams()
475
+ Route.useSearch()
476
+
477
+ useNavigate()
478
+
479
+ useSuspenseQuery()
480
+
481
+ redirect()
482
+
483
+ <Link />
484
+ <Outlet />
485
+ ```
486
+
487
+ will cover roughly:
488
+
489
+ ```txt
490
+ 90% of routing needs
491
+ ```
492
+
493
+ ---
494
+
495
+ # APIs Usually Needed Later
496
+
497
+ As application complexity grows:
498
+
499
+ ```tsx
500
+ useRouter()
501
+
502
+ useRouterState()
503
+
504
+ Route.useRouteContext()
505
+
506
+ useMatchRoute()
507
+
508
+ Route.useLoaderData()
509
+ ```
510
+
511
+ become more useful.
512
+
513
+ ---
514
+
515
+ # Recommended Learning Order
516
+
517
+ Level 1
518
+
519
+ ```tsx
520
+ <Link />
521
+ <Outlet />
522
+
523
+ Route.useParams()
524
+
525
+ Route.useSearch()
526
+
527
+ useNavigate()
528
+
529
+ redirect()
530
+ ```
531
+
532
+ ---
533
+
534
+ Level 2
535
+
536
+ ```tsx
537
+ Loader
538
+
539
+ pendingComponent
540
+
541
+ useSuspenseQuery()
542
+
543
+ ensureQueryData()
544
+ ```
545
+
546
+ ---
547
+
548
+ Level 3
549
+
550
+ ```tsx
551
+ useRouter()
552
+
553
+ useRouterState()
554
+
555
+ Route.useRouteContext()
556
+
557
+ useMatchRoute()
558
+ ```
559
+
560
+ ---
561
+
562
+ Level 4
563
+
564
+ ```tsx
565
+ Custom History
566
+
567
+ Router Invalidation
568
+
569
+ Advanced Loader Dependencies
570
+
571
+ Router State Observers
572
+ ```
573
+
574
+ Most enterprise CRUD/CRM applications rarely need to go beyond Level 3.