@donotdev/ui 0.0.31 → 0.1.1

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 (335) hide show
  1. package/LICENSE.md +3 -3
  2. package/dist/{GoToDialog-CR4VOVXT.js → GoToDialog-RU5RP7S2.js} +1 -1
  3. package/dist/chunk-ETE4RC7M.js +1 -0
  4. package/dist/components/auth/AuthHeader.d.ts +8 -3
  5. package/dist/components/auth/AuthHeader.d.ts.map +1 -1
  6. package/dist/components/auth/AuthHeader.js +6 -6
  7. package/dist/components/auth/AuthMenu.d.ts +2 -2
  8. package/dist/components/auth/AuthMenu.js +1 -1
  9. package/dist/components/common/FeatureCard.d.ts +2 -0
  10. package/dist/components/common/FeatureCard.d.ts.map +1 -1
  11. package/dist/components/common/FeatureCard.js +1 -1
  12. package/dist/components/common/FeatureDisabled.d.ts +2 -1
  13. package/dist/components/common/FeatureDisabled.d.ts.map +1 -1
  14. package/dist/components/common/FeatureDisabled.js +2 -2
  15. package/dist/components/common/ProgressBar.d.ts +1 -1
  16. package/dist/components/common/ProgressBar.js +2 -2
  17. package/dist/components/common/RedirectOverlay.d.ts +1 -1
  18. package/dist/components/common/RedirectOverlay.js +2 -2
  19. package/dist/components/common/Skeleton.d.ts +7 -7
  20. package/dist/components/common/Skeleton.js +8 -8
  21. package/dist/components/common/TechBento.d.ts +1 -0
  22. package/dist/components/common/TechBento.d.ts.map +1 -1
  23. package/dist/components/common/icon.d.ts +2 -1
  24. package/dist/components/common/icon.d.ts.map +1 -1
  25. package/dist/components/common/icon.js +2 -2
  26. package/dist/components/common/index.d.ts +1 -1
  27. package/dist/components/common/index.js +1 -1
  28. package/dist/components/cookie-consent/ConsentBanner.d.ts +1 -1
  29. package/dist/components/cookie-consent/ConsentBanner.js +2 -2
  30. package/dist/components/cookie-consent/CookieConsent.d.ts +1 -0
  31. package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
  32. package/dist/components/cookie-consent/index.d.ts +1 -1
  33. package/dist/components/cookie-consent/index.js +1 -1
  34. package/dist/components/index.d.ts +1 -1
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/layout/GameContainer.d.ts +1 -1
  37. package/dist/components/layout/GameContainer.js +2 -2
  38. package/dist/components/layout/GameFlow.d.ts +2 -2
  39. package/dist/components/layout/GameFlow.js +2 -2
  40. package/dist/components/layout/PageConfig.d.ts +25 -0
  41. package/dist/components/layout/PageConfig.d.ts.map +1 -0
  42. package/dist/components/layout/PageConfig.js +47 -0
  43. package/dist/components/layout/PageContainer.d.ts +1 -1
  44. package/dist/components/layout/PageContainer.js +2 -2
  45. package/dist/components/layout/components/Breadcrumbs.d.ts +3 -1
  46. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  47. package/dist/components/layout/components/Breadcrumbs.js +2 -2
  48. package/dist/components/layout/components/DropdownNavigation.d.ts +1 -1
  49. package/dist/components/layout/components/DropdownNavigation.js +2 -2
  50. package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts +2 -1
  51. package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
  52. package/dist/components/layout/components/FloatingLanguageSwitcher.js +2 -2
  53. package/dist/components/layout/components/Notifications.d.ts +4 -4
  54. package/dist/components/layout/components/Notifications.js +3 -3
  55. package/dist/components/layout/components/header/AppBranding.d.ts +3 -2
  56. package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
  57. package/dist/components/layout/components/header/AppBranding.js +2 -2
  58. package/dist/components/layout/components/header/AppIcon.d.ts +2 -1
  59. package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
  60. package/dist/components/layout/components/header/AppIcon.js +2 -2
  61. package/dist/components/layout/components/header/AppTitle.d.ts +2 -1
  62. package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
  63. package/dist/components/layout/components/header/AppTitle.js +2 -2
  64. package/dist/components/layout/components/header/CacheSettings.d.ts +1 -1
  65. package/dist/components/layout/components/header/CacheSettings.js +5 -5
  66. package/dist/components/layout/components/header/GameTitle.d.ts +2 -1
  67. package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
  68. package/dist/components/layout/components/header/GameTitle.js +2 -2
  69. package/dist/components/layout/components/header/HeaderMenu.d.ts +2 -1
  70. package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
  71. package/dist/components/layout/components/header/HeaderMenu.js +2 -2
  72. package/dist/components/layout/components/header/HeaderNavigation.d.ts +2 -1
  73. package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
  74. package/dist/components/layout/components/header/HeaderNavigation.js +2 -2
  75. package/dist/components/layout/components/header/SettingsMenu.d.ts +2 -1
  76. package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
  77. package/dist/components/layout/components/header/SettingsMenu.js +2 -2
  78. package/dist/components/layout/components/header/ThemeToggle.d.ts +1 -1
  79. package/dist/components/layout/components/header/ThemeToggle.js +2 -2
  80. package/dist/components/layout/components/index.d.ts +1 -1
  81. package/dist/components/layout/components/index.js +1 -1
  82. package/dist/components/layout/index.d.ts +2 -1
  83. package/dist/components/layout/index.d.ts.map +1 -1
  84. package/dist/components/layout/index.js +2 -1
  85. package/dist/components/license/LicenseWatermark.d.ts +1 -1
  86. package/dist/components/license/LicenseWatermark.js +2 -2
  87. package/dist/components/license/watermarkData.js +1 -1
  88. package/dist/crud/components/CrudCardLink.d.ts +1 -1
  89. package/dist/crud/components/EntityCardList.d.ts +1 -1
  90. package/dist/crud/components/EntityCardList.d.ts.map +1 -1
  91. package/dist/crud/components/EntityCardList.js +33 -22
  92. package/dist/crud/components/EntityDisplayRenderer.d.ts +1 -1
  93. package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
  94. package/dist/crud/components/EntityDisplayRenderer.js +14 -13
  95. package/dist/crud/components/EntityFormRenderer.d.ts +1 -1
  96. package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
  97. package/dist/crud/components/EntityFormRenderer.js +18 -20
  98. package/dist/crud/components/EntityList.d.ts +1 -1
  99. package/dist/crud/components/EntityList.d.ts.map +1 -1
  100. package/dist/crud/components/EntityList.js +41 -25
  101. package/dist/crud/components/EntityRecommendations.d.ts +2 -2
  102. package/dist/crud/components/EntityRecommendations.d.ts.map +1 -1
  103. package/dist/crud/components/EntityRecommendations.js +6 -6
  104. package/dist/crud/components/EntityWorkflow.js +1 -1
  105. package/dist/crud/components/Form.d.ts +10 -10
  106. package/dist/crud/components/Form.js +12 -12
  107. package/dist/crud/components/index.d.ts +1 -1
  108. package/dist/crud/components/index.js +1 -1
  109. package/dist/crud/crudImports.d.ts +2 -1
  110. package/dist/crud/crudImports.d.ts.map +1 -1
  111. package/dist/crud/crudImports.js +2 -1
  112. package/dist/crud/index.d.ts +1 -1
  113. package/dist/crud/index.js +1 -1
  114. package/dist/data/techLogos.d.ts +1 -1
  115. package/dist/data/techLogos.js +1 -1
  116. package/dist/dndev-next.css +374 -81
  117. package/dist/dndev.css +455 -80
  118. package/dist/index.d.ts +1 -1
  119. package/dist/index.js +4 -4
  120. package/dist/internal/common/DnDevErrorBoundary.d.ts +2 -2
  121. package/dist/internal/common/DnDevErrorBoundary.js +2 -2
  122. package/dist/internal/common/ErrorFallback.d.ts +1 -1
  123. package/dist/internal/common/ErrorFallback.js +3 -3
  124. package/dist/internal/common/GlobalErrorFallback.d.ts +1 -1
  125. package/dist/internal/common/GlobalErrorFallback.js +2 -2
  126. package/dist/internal/common/RouteErrorFallback.d.ts +1 -1
  127. package/dist/internal/common/RouteErrorFallback.js +2 -2
  128. package/dist/internal/devtools/DebugTools.js +2 -2
  129. package/dist/internal/devtools/components/AuthDebugButton.js +1 -1
  130. package/dist/internal/devtools/components/ConfigTab.js +1 -1
  131. package/dist/internal/devtools/components/CookieTab.js +1 -1
  132. package/dist/internal/devtools/components/DebugDialog.js +1 -1
  133. package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
  134. package/dist/internal/devtools/components/DesignTab.js +7 -3
  135. package/dist/internal/devtools/components/LayoutReset.js +2 -2
  136. package/dist/internal/devtools/components/MaskedValue.js +1 -1
  137. package/dist/internal/devtools/components/StoresTab.js +1 -1
  138. package/dist/internal/devtools/components/index.d.ts +1 -1
  139. package/dist/internal/devtools/components/index.js +1 -1
  140. package/dist/internal/devtools/index.d.ts +1 -1
  141. package/dist/internal/devtools/index.js +1 -1
  142. package/dist/internal/devtools/types.d.ts +9 -9
  143. package/dist/internal/devtools/utils/envVarDiscovery.d.ts.map +1 -1
  144. package/dist/internal/devtools/utils/envVarDiscovery.js +5 -6
  145. package/dist/internal/devtools/utils/index.d.ts +1 -1
  146. package/dist/internal/devtools/utils/index.js +1 -1
  147. package/dist/internal/devtools/utils/maskSensitive.js +1 -1
  148. package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
  149. package/dist/internal/devtools/utils/virtualModuleInspector.js +3 -1
  150. package/dist/internal/initializers/BaseStoresInitializer.d.ts +3 -3
  151. package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
  152. package/dist/internal/initializers/BaseStoresInitializer.js +13 -4
  153. package/dist/internal/initializers/NextJsStoresInitializer.d.ts +1 -1
  154. package/dist/internal/initializers/NextJsStoresInitializer.js +2 -2
  155. package/dist/internal/initializers/ViteStoresInitializer.d.ts +1 -1
  156. package/dist/internal/initializers/ViteStoresInitializer.js +2 -2
  157. package/dist/internal/initializers/index.d.ts +1 -1
  158. package/dist/internal/initializers/index.js +1 -1
  159. package/dist/internal/layout/DnDevLayout.d.ts +2 -2
  160. package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
  161. package/dist/internal/layout/DnDevLayout.js +45 -18
  162. package/dist/internal/layout/components/AutoMetaTags.d.ts +4 -2
  163. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  164. package/dist/internal/layout/components/AutoMetaTags.js +193 -57
  165. package/dist/internal/layout/components/FaviconHead.d.ts +1 -1
  166. package/dist/internal/layout/components/FaviconHead.js +2 -2
  167. package/dist/internal/layout/components/FontPreloadLinks.d.ts +1 -1
  168. package/dist/internal/layout/components/FontPreloadLinks.js +1 -1
  169. package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +3 -1
  170. package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +1 -1
  171. package/dist/internal/layout/components/NextJsAutoMetaTags.js +47 -17
  172. package/dist/internal/layout/components/PWAUpdateNotification.d.ts +1 -1
  173. package/dist/internal/layout/components/PWAUpdateNotification.d.ts.map +1 -1
  174. package/dist/internal/layout/components/PWAUpdateNotification.js +17 -4
  175. package/dist/internal/layout/components/PerformanceHints.js +1 -1
  176. package/dist/internal/layout/components/footer/FooterBranding.d.ts +1 -1
  177. package/dist/internal/layout/components/footer/FooterBranding.js +2 -2
  178. package/dist/internal/layout/components/footer/FooterCopyright.d.ts +1 -1
  179. package/dist/internal/layout/components/footer/FooterCopyright.js +2 -2
  180. package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts +1 -1
  181. package/dist/internal/layout/components/footer/FooterLegalLinks.js +2 -2
  182. package/dist/internal/layout/components/index.d.ts +1 -1
  183. package/dist/internal/layout/components/index.js +1 -1
  184. package/dist/internal/layout/config/defaults.js +1 -1
  185. package/dist/internal/layout/config/index.d.ts +1 -1
  186. package/dist/internal/layout/config/index.js +1 -1
  187. package/dist/internal/layout/config/presets/admin.d.ts +1 -1
  188. package/dist/internal/layout/config/presets/blog.d.ts +1 -1
  189. package/dist/internal/layout/config/presets/docs.js +1 -1
  190. package/dist/internal/layout/config/presets/game.js +1 -1
  191. package/dist/internal/layout/config/presets/index.d.ts +1 -1
  192. package/dist/internal/layout/config/presets/landing.js +1 -1
  193. package/dist/internal/layout/config/presets/moolti.js +1 -1
  194. package/dist/internal/layout/config/presets/plain.d.ts +2 -2
  195. package/dist/internal/layout/config/presets/plain.d.ts.map +1 -1
  196. package/dist/internal/layout/config/presets/plain.js +12 -1
  197. package/dist/internal/layout/renderers/index.d.ts +1 -1
  198. package/dist/internal/layout/renderers/index.js +1 -1
  199. package/dist/internal/layout/zones/DnDevFooter.d.ts +3 -1
  200. package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
  201. package/dist/internal/layout/zones/DnDevFooter.js +6 -2
  202. package/dist/internal/layout/zones/DnDevHeader.d.ts +3 -1
  203. package/dist/internal/layout/zones/DnDevHeader.d.ts.map +1 -1
  204. package/dist/internal/layout/zones/DnDevHeader.js +8 -3
  205. package/dist/internal/layout/zones/DnDevMergedBar.js +1 -1
  206. package/dist/internal/layout/zones/DnDevSidebar.d.ts +3 -1
  207. package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
  208. package/dist/internal/layout/zones/DnDevSidebar.js +10 -4
  209. package/dist/internal/layout/zones/index.d.ts +1 -1
  210. package/dist/internal/layout/zones/index.js +1 -1
  211. package/dist/internal/providers/NavigationProvider.d.ts +1 -1
  212. package/dist/internal/providers/NavigationProvider.js +2 -2
  213. package/dist/internal/providers/SentryInitializer.d.ts +1 -1
  214. package/dist/internal/providers/SentryInitializer.js +2 -2
  215. package/dist/internal/providers/UIProviders.d.ts +1 -1
  216. package/dist/internal/providers/UIProviders.js +3 -3
  217. package/dist/internal/providers/index.d.ts +1 -1
  218. package/dist/internal/providers/index.js +1 -1
  219. package/dist/next.d.ts +1 -1
  220. package/dist/next.js +1 -1
  221. package/dist/providers/NextJsAppProviders.d.ts +1 -1
  222. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  223. package/dist/providers/NextJsAppProviders.js +5 -3
  224. package/dist/providers/ViteAppProviders.d.ts +1 -1
  225. package/dist/providers/ViteAppProviders.js +2 -2
  226. package/dist/providers/index.d.ts +1 -1
  227. package/dist/providers/index.js +1 -1
  228. package/dist/routing/404.d.ts +2 -2
  229. package/dist/routing/404.js +3 -3
  230. package/dist/routing/AuthGuard.d.ts +14 -29
  231. package/dist/routing/AuthGuard.d.ts.map +1 -1
  232. package/dist/routing/AuthGuard.js +27 -72
  233. package/dist/routing/AuthGuardFallback.d.ts +1 -1
  234. package/dist/routing/AuthGuardFallback.js +2 -2
  235. package/dist/routing/AuthReturnTo.d.ts +13 -0
  236. package/dist/routing/AuthReturnTo.d.ts.map +1 -0
  237. package/dist/routing/AuthReturnTo.js +61 -0
  238. package/dist/routing/DnDevNavigationMenu.d.ts +2 -1
  239. package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
  240. package/dist/routing/DnDevNavigationMenu.js +2 -2
  241. package/dist/routing/GoTo.d.ts +1 -0
  242. package/dist/routing/GoTo.d.ts.map +1 -1
  243. package/dist/routing/GoTo.js +1 -1
  244. package/dist/routing/GoToDialog.js +1 -1
  245. package/dist/routing/GoToInput.js +1 -1
  246. package/dist/routing/GoToWrapper.d.ts +1 -1
  247. package/dist/routing/GoToWrapper.js +2 -2
  248. package/dist/routing/Link.d.ts +2 -2
  249. package/dist/routing/Link.js +2 -2
  250. package/dist/routing/NavigationItem.d.ts +1 -1
  251. package/dist/routing/NavigationItem.js +2 -2
  252. package/dist/routing/hooks/hooks.next.d.ts +1 -1
  253. package/dist/routing/hooks/hooks.next.js +1 -1
  254. package/dist/routing/hooks/hooks.vite.d.ts +1 -1
  255. package/dist/routing/hooks/hooks.vite.js +1 -1
  256. package/dist/routing/hooks/index.d.ts +1 -1
  257. package/dist/routing/hooks/index.js +1 -1
  258. package/dist/routing/hooks/types.d.ts +1 -1
  259. package/dist/routing/hooks/useLocation.next.js +1 -1
  260. package/dist/routing/hooks/useLocation.vite.js +1 -1
  261. package/dist/routing/hooks/useNavigate.next.d.ts +8 -0
  262. package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
  263. package/dist/routing/hooks/useNavigate.next.js +59 -9
  264. package/dist/routing/hooks/useNavigate.vite.d.ts +8 -0
  265. package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
  266. package/dist/routing/hooks/useNavigate.vite.js +65 -15
  267. package/dist/routing/hooks/useQueryParams.next.js +1 -1
  268. package/dist/routing/hooks/useQueryParams.vite.js +1 -1
  269. package/dist/routing/hooks/useRedirectGuard.next.d.ts +2 -0
  270. package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
  271. package/dist/routing/hooks/useRedirectGuard.next.js +12 -28
  272. package/dist/routing/hooks/useRedirectGuard.vite.d.ts +2 -0
  273. package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
  274. package/dist/routing/hooks/useRedirectGuard.vite.js +12 -28
  275. package/dist/routing/hooks/useRouteParam.next.js +1 -1
  276. package/dist/routing/hooks/useRouteParam.vite.js +1 -1
  277. package/dist/routing/index.d.ts +2 -1
  278. package/dist/routing/index.d.ts.map +1 -1
  279. package/dist/routing/index.js +2 -1
  280. package/dist/routing/useGoTo.js +1 -1
  281. package/dist/routing/useNavigation.d.ts +2 -2
  282. package/dist/routing/useNavigation.js +3 -3
  283. package/dist/routing/useRouteDiscovery.d.ts +7 -7
  284. package/dist/routing/useRouteDiscovery.js +6 -6
  285. package/dist/styles/index.css +455 -80
  286. package/dist/styles/index.d.ts +1 -1
  287. package/dist/styles/index.js +1 -1
  288. package/dist/styles/layoutConstants.d.ts +6 -6
  289. package/dist/styles/layoutConstants.js +5 -5
  290. package/dist/symbol-index.json +1 -0
  291. package/dist/utils/assetResolver.d.ts +5 -5
  292. package/dist/utils/assetResolver.js +4 -4
  293. package/dist/utils/index.d.ts +2 -1
  294. package/dist/utils/index.d.ts.map +1 -1
  295. package/dist/utils/index.js +2 -1
  296. package/dist/utils/sanitizeSvg.d.ts +4 -0
  297. package/dist/utils/sanitizeSvg.d.ts.map +1 -1
  298. package/dist/utils/sanitizeSvg.js +5 -1
  299. package/dist/utils/tList.js +1 -1
  300. package/dist/utils/useAISafe.d.ts +28 -0
  301. package/dist/utils/useAISafe.d.ts.map +1 -0
  302. package/dist/utils/useAISafe.js +53 -0
  303. package/dist/utils/useAuthSafe.d.ts +39 -0
  304. package/dist/utils/useAuthSafe.d.ts.map +1 -1
  305. package/dist/utils/useAuthSafe.js +6 -1
  306. package/dist/utils/useAuthVisibility.d.ts +1 -0
  307. package/dist/utils/useAuthVisibility.d.ts.map +1 -1
  308. package/dist/utils/useAuthVisibility.js +1 -1
  309. package/dist/utils/useBillingVisibility.d.ts +1 -0
  310. package/dist/utils/useBillingVisibility.d.ts.map +1 -1
  311. package/dist/utils/useBillingVisibility.js +1 -1
  312. package/dist/utils/useCrudSafe.js +1 -1
  313. package/dist/utils/useFormStoreSafe.js +1 -1
  314. package/dist/utils/useOAuthSafe.d.ts +1 -1
  315. package/dist/utils/useSeo.d.ts +121 -0
  316. package/dist/utils/useSeo.d.ts.map +1 -0
  317. package/dist/utils/useSeo.js +114 -0
  318. package/dist/utils/useStripeBillingSafe.js +1 -1
  319. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  320. package/dist/vite-routing/AppRoutes.js +15 -5
  321. package/dist/vite-routing/RootLayout.d.ts +1 -1
  322. package/dist/vite-routing/RootLayout.d.ts.map +1 -1
  323. package/dist/vite-routing/RootLayout.js +11 -9
  324. package/dist/vite-routing/index.d.ts +1 -1
  325. package/dist/vite-routing/index.js +1 -1
  326. package/dist/vite.d.ts +1 -1
  327. package/dist/vite.js +1 -1
  328. package/guidelines/COMPONENTS.md +136 -0
  329. package/guidelines/GOTCHAS.md +66 -0
  330. package/guidelines/LAYOUTS.md +310 -0
  331. package/guidelines/PAGES.md +205 -0
  332. package/guidelines/ROUTING.md +499 -0
  333. package/guidelines/SEO.md +275 -0
  334. package/package.json +12 -7
  335. package/dist/chunk-XHGRMKOY.js +0 -1
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  * @fileoverview AuthGuardFallback component
5
5
  * @description Shows login options when users hit protected routes
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -27,7 +27,7 @@ const MultipleAuthProviders = lazy(() => import('@donotdev/auth').then((module)
27
27
  * the authentication options directly on the protected route, providing
28
28
  * better UX and keeping users in context.
29
29
  *
30
- * @version 0.0.1
30
+ * @version 0.1.0
31
31
  * @since 0.0.1
32
32
  * @author AMBROISE PARK Consulting
33
33
  */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * AuthReturnTo - Restores navigation after OAuth redirect.
3
+ *
4
+ * OAuth always lands on `/` (origin). This component watches for sign-in,
5
+ * reads the saved returnTo path, and navigates back. Runs once per sign-in.
6
+ *
7
+ * Also shows a warning toast when the user was redirected by the auth guard
8
+ * (flag set by useNavigate, consumed here on mount of the landing page).
9
+ *
10
+ * @component
11
+ */
12
+ export declare function AuthReturnTo(): null;
13
+ //# sourceMappingURL=AuthReturnTo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthReturnTo.d.ts","sourceRoot":"","sources":["../../src/routing/AuthReturnTo.tsx"],"names":[],"mappings":"AA0BA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,SA2B3B"}
@@ -0,0 +1,61 @@
1
+ 'use client';
2
+ // packages/ui/src/routing/AuthReturnTo.tsx
3
+ /**
4
+ * @fileoverview Auth Return-To Navigation + Guard Toast
5
+ * @description Consumes `dndev.auth.returnTo` from sessionStorage after OAuth
6
+ * redirect and navigates back to the pre-auth path.
7
+ * Also consumes `dndev.auth.guardToast` flag to show a toast when
8
+ * useNavigate blocked a SPA nav to a protected route.
9
+ *
10
+ * Mount once at layout/provider level (RootLayout). Renders nothing.
11
+ * Works on all routes - unlike AuthGuard which only runs on guarded pages.
12
+ *
13
+ * @version 0.1.0
14
+ * @since 0.6.0
15
+ * @author AMBROISE PARK Consulting
16
+ */
17
+ import { useEffect } from 'react';
18
+ import { useToast } from '@donotdev/components';
19
+ import { isClient, safeSessionStorage, useTranslation } from '@donotdev/core';
20
+ import { useAuthSafe } from '../utils/useAuthSafe';
21
+ import { useNavigate } from '@donotdev/ui/routing/hooks';
22
+ /**
23
+ * AuthReturnTo - Restores navigation after OAuth redirect.
24
+ *
25
+ * OAuth always lands on `/` (origin). This component watches for sign-in,
26
+ * reads the saved returnTo path, and navigates back. Runs once per sign-in.
27
+ *
28
+ * Also shows a warning toast when the user was redirected by the auth guard
29
+ * (flag set by useNavigate, consumed here on mount of the landing page).
30
+ *
31
+ * @component
32
+ */
33
+ export function AuthReturnTo() {
34
+ const user = useAuthSafe('user');
35
+ const navigate = useNavigate();
36
+ const { t } = useTranslation('dndev');
37
+ const { toast } = useToast();
38
+ // Show guard toast on landing page after auth redirect
39
+ useEffect(() => {
40
+ if (!isClient())
41
+ return;
42
+ const flag = safeSessionStorage.getItem('dndev.auth.guardToast');
43
+ if (!flag)
44
+ return;
45
+ safeSessionStorage.removeItem('dndev.auth.guardToast');
46
+ toast('warning', t('guard.signInRequired', 'Please sign in to access this page'));
47
+ }, []);
48
+ // Return-to after sign-in
49
+ useEffect(() => {
50
+ if (!user || !isClient())
51
+ return;
52
+ const returnTo = safeSessionStorage.getItem('dndev.auth.returnTo');
53
+ if (!returnTo)
54
+ return;
55
+ safeSessionStorage.removeItem('dndev.auth.returnTo');
56
+ if (returnTo !== window.location.pathname) {
57
+ navigate(returnTo, { replace: true });
58
+ }
59
+ }, [user, navigate]);
60
+ return null;
61
+ }
@@ -1,6 +1,7 @@
1
1
  import { type ComponentType } from 'react';
2
2
  import { DISPLAY } from '@donotdev/components';
3
3
  import type { NavigationItem } from './useNavigation';
4
+ /** Props for the DnDevNavigationMenu component. */
4
5
  export interface DnDevNavigationMenuProps {
5
6
  /** Routes to display (optional - auto-fetches if not provided) */
6
7
  routes?: NavigationItem[];
@@ -29,7 +30,7 @@ export interface DnDevNavigationMenuProps {
29
30
  *
30
31
  * Works for sidebars, headers, dropdowns, anywhere navigation is needed.
31
32
  *
32
- * @version 0.0.1
33
+ * @version 0.1.0
33
34
  * @since 0.0.1
34
35
  * @author AMBROISE PARK Consulting
35
36
  *
@@ -1 +1 @@
1
- {"version":3,"file":"DnDevNavigationMenu.d.ts","sourceRoot":"","sources":["../../src/routing/DnDevNavigationMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAOL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,wBAAwB,CA8KvE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"DnDevNavigationMenu.d.ts","sourceRoot":"","sources":["../../src/routing/DnDevNavigationMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAOL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,mDAAmD;AACnD,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,wBAAwB,CA8KvE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -12,7 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  * - Optional overflow detection with "More" dropdown (for headers)
13
13
  * - Works for sidebars, headers, dropdowns, anywhere navigation is needed
14
14
  *
15
- * @version 0.0.1
15
+ * @version 0.1.0
16
16
  * @since 0.0.1
17
17
  * @author AMBROISE PARK Consulting
18
18
  */
@@ -35,7 +35,7 @@ import { Icon } from '../components/common/icon';
35
35
  *
36
36
  * Works for sidebars, headers, dropdowns, anywhere navigation is needed.
37
37
  *
38
- * @version 0.0.1
38
+ * @version 0.1.0
39
39
  * @since 0.0.1
40
40
  * @author AMBROISE PARK Consulting
41
41
  *
@@ -1,4 +1,5 @@
1
1
  import { DISPLAY } from '@donotdev/components';
2
+ /** Props for the GoTo command palette trigger. */
2
3
  export interface GoToProps {
3
4
  /**
4
5
  * Display - controls button presentation
@@ -1 +1 @@
1
- {"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,iCAIlB,SAAS,4CA0CX,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,iCAIlB,SAAS,4CA0CX,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  * @fileoverview GoTo component
5
5
  * @description Navigation command palette button
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  * @fileoverview GoToDialog - Navigation command palette implementation
5
5
  * @description Clean Cmd+K navigation with favorites, recents, and smart filtering
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  * @fileoverview GoToInput - Typeable navigation input
5
5
  * @description Real input that opens command dialog with current search value
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -6,7 +6,7 @@
6
6
  * - Cmd+K listener always active
7
7
  * - Dialog lazy-loaded on first open
8
8
  *
9
- * @version 0.0.1
9
+ * @version 0.1.0
10
10
  * @since 0.0.1
11
11
  * @author AMBROISE PARK Consulting
12
12
  */
@@ -9,7 +9,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  * - Lazy-loaded dialog for optimal performance
10
10
  * - CSR/SSR safe with graceful fallbacks
11
11
  *
12
- * @version 0.0.1
12
+ * @version 0.1.0
13
13
  * @since 0.0.1
14
14
  * @author AMBROISE PARK Consulting
15
15
  */
@@ -25,7 +25,7 @@ const GoToDialog = lazy(() => import('./GoToDialog'));
25
25
  * - Cmd+K listener always active
26
26
  * - Dialog lazy-loaded on first open
27
27
  *
28
- * @version 0.0.1
28
+ * @version 0.1.0
29
29
  * @since 0.0.1
30
30
  * @author AMBROISE PARK Consulting
31
31
  */
@@ -2,7 +2,7 @@ import { type ReactNode, type ComponentType, type AnchorHTMLAttributes } from 'r
2
2
  /**
3
3
  * Link component props interface
4
4
  *
5
- * @version 0.0.3
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -23,7 +23,7 @@ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
23
23
  /**
24
24
  * Link component
25
25
  *
26
- * @version 0.0.3
26
+ * @version 0.1.0
27
27
  * @since 0.0.1
28
28
  * @author AMBROISE PARK Consulting
29
29
  */
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
5
5
  * @fileoverview Link component
6
6
  * @description Platform-agnostic link component for navigation
7
7
  *
8
- * @version 0.0.3
8
+ * @version 0.1.0
9
9
  * @since 0.0.1
10
10
  * @author AMBROISE PARK Consulting
11
11
  */
@@ -19,7 +19,7 @@ import { Icon } from '../components/common/icon';
19
19
  /**
20
20
  * Link component
21
21
  *
22
- * @version 0.0.3
22
+ * @version 0.1.0
23
23
  * @since 0.0.1
24
24
  * @author AMBROISE PARK Consulting
25
25
  */
@@ -26,7 +26,7 @@ export type NavigationItemProps = ({
26
26
  * For standalone Button-style navigation (e.g. header end slot), use
27
27
  * `useNavigationRoute(path)` and compose with `Button` + `render` prop directly.
28
28
  *
29
- * @version 0.0.2
29
+ * @version 0.1.0
30
30
  * @since 0.0.1
31
31
  * @author AMBROISE PARK Consulting
32
32
  *
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  * @fileoverview NavigationItem component
5
5
  * @description Universal navigation item component with icon and label
6
6
  *
7
- * @version 0.0.2
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -23,7 +23,7 @@ import { Icon } from '../components/common/icon';
23
23
  * For standalone Button-style navigation (e.g. header end slot), use
24
24
  * `useNavigationRoute(path)` and compose with `Button` + `render` prop directly.
25
25
  *
26
- * @version 0.0.2
26
+ * @version 0.1.0
27
27
  * @since 0.0.1
28
28
  * @author AMBROISE PARK Consulting
29
29
  *
@@ -3,7 +3,7 @@
3
3
  * @description Exports Next.js App Router implementations of routing hooks.
4
4
  * This file is resolved via package.json conditional exports when bundled with Next.js.
5
5
  *
6
- * @version 0.0.1
6
+ * @version 0.1.0
7
7
  * @since 0.0.1
8
8
  * @author AMBROISE PARK Consulting
9
9
  */
@@ -1 +1 @@
1
- "use client";import{useRouter as f}from"next/navigation";import{useCallback as h}from"react";import{isClient as S,useOverlayStore as y}from"@donotdev/core";function d(){let e=f(),r=y(t=>t.closeAll);return h((t,s)=>{if(t==="back")return r(),e.back();if(r(),s?.preserveScroll&&S()){let o=window.scrollY;s?.replace?e.replace(t):e.push(t),requestAnimationFrame(()=>{window.scrollTo({top:o,behavior:"auto"})});return}return s?.replace?e.replace(t):e.push(t)},[e,r])}function k(){let e=f();return h(()=>e.back(),[e])}function T(){let e=f();return h(()=>e.refresh(),[e])}function v(){let e=f();return h(r=>e.prefetch(r),[e])}import{usePathname as b,useSearchParams as N}from"next/navigation";function m(){let e=b(),t=N().toString(),s=t?`?${t}`:void 0;return{pathname:e||"/",search:s,hash:"",state:null}}import{useParams as w}from"next/navigation";function g(){let e=w();return e||{}}function C(e){let t=g()[e];if(typeof t=="string")return t;if(Array.isArray(t)&&t.length>0)return t[0]}import{useSearchParams as I}from"next/navigation";function R(){return I()}import{usePathname as G}from"next/navigation";function $(e){let r=G(),t=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),s=new RegExp(`^${t}$`),o=r.match(s);if(!o)return null;let n=e.match(/:[^/]+/g)?.map(u=>u.slice(1))||[],a={};return n.forEach((u,c)=>{a[u]=o[c+1]||""}),{params:a,pathname:r,pattern:e}}import{useCallback as P}from"react";function K(){let e=R(),r=d(),t=m(),s=P((a,u)=>{let c=new URLSearchParams(e.toString());c.set(a,u);let l=c.toString(),x=`${t.pathname||"/"}${l?`?${l}`:""}`;r(x)},[e,r,t.pathname]),o=P(a=>{let u=new URLSearchParams(e.toString());u.delete(a);let c=u.toString(),i=`${t.pathname||"/"}${c?`?${c}`:""}`;r(i)},[e,r,t.pathname]),n=P(()=>{let a=t.pathname||"/";r(a)},[r,t.pathname]);return{query:e,setQuery:s,removeQuery:o,clearQueries:n}}import{useMemo as E}from"react";import{isClient as Q,FEATURE_STATUS as F}from"@donotdev/core";import{useAuthConfig as M}from"@donotdev/core";import*as O from"@donotdev/auth";import{DEGRADED_AUTH_API as U}from"@donotdev/core";var A=O?.useAuth;function L(e){return U[e]}function p(e){return A?A(e):L(e)}function j(e={}){let{auth:r,redirectTo:t,condition:s}=e,o=m(),n=M(),a=p("user"),u=p("can"),c=p("status");return E(()=>{if(!Q())return{shouldRedirect:!1,redirectTo:null,isChecking:!1};if(c===F.INITIALIZING)return{shouldRedirect:!1,redirectTo:null,isChecking:!0};if(s){let i=s(a,c);return{shouldRedirect:i,redirectTo:i&&t||null,isChecking:!1}}if(r!==!1&&r!==void 0){if(!u)return{shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!u.navigate(r)){let i=null;return typeof r=="object"&&r.required&&!a?o.search?.includes("code=")||o.search?.includes("state=")||o.search?.includes("error=")?i=`${n.authRoute}${o.search}`:i=n.authRoute:typeof r=="object"&&r.role?i=n.roleRoute:typeof r=="object"&&r.tier?i=n.tierRoute:i=n.roleRoute,{shouldRedirect:!0,redirectTo:t||i,isChecking:!1}}}return{shouldRedirect:!1,redirectTo:null,isChecking:!1}},[r,c,a,u,s,t,o.search,n.authRoute,n.roleRoute,n.tierRoute])}export{k as useBack,m as useLocation,$ as useMatch,d as useNavigate,g as useParams,v as usePrefetch,K as useQueryParams,j as useRedirectGuard,T as useRefresh,C as useRouteParam,R as useSearchParams};
1
+ "use client";import{useRouter as p}from"next/navigation";import{isClient as b,useOverlayStore as k,useAuthConfig as N,FEATURE_STATUS as w,getRoutes as C,safeSessionStorage as y}from"@donotdev/core";import*as S from"@donotdev/auth";import{DEGRADED_AUTH_API as T}from"@donotdev/core";var x=S?.useAuth;function v(e){return T[e]}function m(e){return x?x(e):v(e)}var W=S?.PasswordResetCallback??(()=>null);function G(e){try{let t=C();if(!t?.length)return!1;let r=t.find(n=>n.path===e||e.startsWith(n.path+"/"));return r?!!(r.auth===!0||typeof r.auth=="object"&&r.auth?.required):!1}catch{return!1}}function d(){let e=p(),t=k(s=>s.closeAll),r=m("user"),n=m("status"),u=N();return(s,o)=>{if(s==="back")return t(),e.back();if(!r&&n!==w.INITIALIZING&&G(s))return y.setItem("dndev.auth.returnTo",s),y.setItem("dndev.auth.guardToast","1"),t(),e.replace(u.authRoute);if(t(),o?.preserveScroll&&b()){let a=window.scrollY;o?.replace?e.replace(s):e.push(s),requestAnimationFrame(()=>{window.scrollTo({top:a,behavior:"auto"})});return}return o?.replace?e.replace(s):e.push(s)}}function $(){let e=p();return()=>e.back()}function U(){let e=p();return()=>e.refresh()}function K(){let e=p();return t=>e.prefetch(t)}import{usePathname as E,useSearchParams as L}from"next/navigation";function l(){let e=E(),r=L().toString(),n=r?`?${r}`:void 0;return{pathname:e||"/",search:n,hash:"",state:null}}import{useParams as O}from"next/navigation";function g(){let e=O();return e||{}}function q(e){let r=g()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as F}from"next/navigation";function R(){return F()}import{usePathname as Q}from"next/navigation";function j(e){let t=Q(),r=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),n=new RegExp(`^${r}$`),u=t.match(n);if(!u)return null;let s=e.match(/:[^/]+/g)?.map(a=>a.slice(1))||[],o={};return s.forEach((a,i)=>{o[a]=u[i+1]||""}),{params:o,pathname:t,pattern:e}}import{useCallback as A}from"react";function M(){let e=R(),t=d(),r=l(),n=A((o,a)=>{let i=new URLSearchParams(e.toString());i.set(o,a);let h=i.toString(),c=`${r.pathname||"/"}${h?`?${h}`:""}`;t(c)},[e,t,r.pathname]),u=A(o=>{let a=new URLSearchParams(e.toString());a.delete(o);let i=a.toString(),f=`${r.pathname||"/"}${i?`?${i}`:""}`;t(f)},[e,t,r.pathname]),s=A(()=>{let o=r.pathname||"/";t(o)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:u,clearQueries:s}}import{useMemo as _}from"react";import{isClient as D,FEATURE_STATUS as B}from"@donotdev/core";import{useAuthConfig as Y}from"@donotdev/core";function Z(e={}){let{auth:t,redirectTo:r,condition:n}=e,u=l(),s=Y(),o=m("user"),a=m("can"),i=m("status");return _(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!D())return f;if(i===B.INITIALIZING)return{...f,isChecking:!0};if(n){let c=n(o,i);return{shouldRedirect:c,redirectTo:c&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!a)return f;if(!a.navigate(t)){let c=null;if(typeof t=="object"&&t.required&&!o){let I=u.search?.includes("code=")||u.search?.includes("state=")||u.search?.includes("error="),P=s.authRoute;I?c=`${P}${u.search}`:c=P}else typeof t=="object"&&t.role?c=s.roleRoute:typeof t=="object"&&t.tier?c=s.tierRoute:c=s.roleRoute;return{shouldRedirect:!0,redirectTo:r||c,isChecking:!1}}}return f},[t,i,o,a,n,r,u.search,s.authRoute,s.roleRoute,s.tierRoute])}export{$ as useBack,l as useLocation,j as useMatch,d as useNavigate,g as useParams,K as usePrefetch,M as useQueryParams,Z as useRedirectGuard,U as useRefresh,q as useRouteParam,R as useSearchParams};
@@ -3,7 +3,7 @@
3
3
  * @description Exports Vite/React Router implementations of routing hooks.
4
4
  * This file is resolved via package.json conditional exports when bundled with Vite.
5
5
  *
6
- * @version 0.0.1
6
+ * @version 0.1.0
7
7
  * @since 0.0.1
8
8
  * @author AMBROISE PARK Consulting
9
9
  */
@@ -1 +1 @@
1
- "use client";import{useCallback as m}from"react";import{useNavigate as P}from"react-router-dom";import{isClient as y,useOverlayStore as S}from"@donotdev/core";function h(){let e=P(),t=S(r=>r.closeAll);return m((r,i)=>r==="back"?(t(),e(-1)):(t(),i?.replace?e(r,{replace:!0}):e(r)),[e,t])}function v(){let e=P();return m(()=>e(-1),[e])}function k(){return m(()=>{y()&&window.location.reload()},[])}function T(){return m(e=>{},[])}import{useLocation as C}from"react-router-dom";function f(){return C()}import{useParams as I}from"react-router-dom";function d(){return I()}function b(e){let r=d()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as G}from"react-router-dom";function g(){return G()[0]}import{useMatch as w}from"react-router-dom";function L(e){return w(e)}import{useCallback as R}from"react";function N(){let e=g(),t=h(),r=f(),i=R((n,u)=>{let a=new URLSearchParams(e.toString());a.set(n,u);let l=a.toString(),A=`${r.pathname||"/"}${l?`?${l}`:""}`;t(A)},[e,t,r.pathname]),c=R(n=>{let u=new URLSearchParams(e.toString());u.delete(n);let a=u.toString(),o=`${r.pathname||"/"}${a?`?${a}`:""}`;t(o)},[e,t,r.pathname]),s=R(()=>{let n=r.pathname||"/";t(n)},[t,r.pathname]);return{query:e,setQuery:i,removeQuery:c,clearQueries:s}}import{useMemo as $}from"react";import{isClient as M,FEATURE_STATUS as Q}from"@donotdev/core";import{useAuthConfig as E}from"@donotdev/core";import*as K from"@donotdev/auth";import{DEGRADED_AUTH_API as O}from"@donotdev/core";var x=K?.useAuth;function U(e){return O[e]}function p(e){return x?x(e):U(e)}function _(e={}){let{auth:t,redirectTo:r,condition:i}=e,c=f(),s=E(),n=p("user"),u=p("can"),a=p("status");return $(()=>{if(!M())return{shouldRedirect:!1,redirectTo:null,isChecking:!1};if(a===Q.INITIALIZING)return{shouldRedirect:!1,redirectTo:null,isChecking:!0};if(i){let o=i(n,a);return{shouldRedirect:o,redirectTo:o&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!u)return{shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!u.navigate(t)){let o=null;return typeof t=="object"&&t.required&&!n?c.search.includes("code=")||c.search.includes("state=")||c.search.includes("error=")?o=`${s.authRoute}${c.search}`:o=s.authRoute:typeof t=="object"&&t.role?o=s.roleRoute:typeof t=="object"&&t.tier?o=s.tierRoute:o=s.roleRoute,{shouldRedirect:!0,redirectTo:r||o,isChecking:!1}}}return{shouldRedirect:!1,redirectTo:null,isChecking:!1}},[t,a,n,u,i,r,c.search,s.authRoute,s.roleRoute,s.tierRoute])}export{v as useBack,f as useLocation,L as useMatch,h as useNavigate,d as useParams,T as usePrefetch,N as useQueryParams,_ as useRedirectGuard,k as useRefresh,b as useRouteParam,g as useSearchParams};
1
+ "use client";import{useNavigate as y}from"react-router-dom";import{isClient as b,useOverlayStore as k,useAuthConfig as C,FEATURE_STATUS as G,getRoutes as N,safeSessionStorage as S}from"@donotdev/core";import*as x from"@donotdev/auth";import{DEGRADED_AUTH_API as I}from"@donotdev/core";var P=x?.useAuth;function T(e){return I[e]}function m(e){return P?P(e):T(e)}var W=x?.PasswordResetCallback??(()=>null);function w(e){try{let t=N();if(!t?.length)return!1;let r=t.find(n=>n.path===e||e.startsWith(n.path+"/"));return r?!!(r.auth===!0||typeof r.auth=="object"&&r.auth?.required):!1}catch{return!1}}function p(){let e=y(),t=k(o=>o.closeAll),r=m("user"),n=m("status"),a=C();return(o,s)=>o==="back"?(t(),e(-1)):!r&&n!==G.INITIALIZING&&w(o)?(S.setItem("dndev.auth.returnTo",o),S.setItem("dndev.auth.guardToast","1"),t(),e(a.authRoute,{replace:!0})):(t(),s?.replace?e(o,{replace:!0}):e(o))}function L(){let e=y();return()=>e(-1)}function U(){return()=>{b()&&window.location.reload()}}function K(){return e=>{}}import{useLocation as O}from"react-router-dom";function l(){return O()}import{useParams as $}from"react-router-dom";function d(){return $()}function E(e){let r=d()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as M}from"react-router-dom";function g(){return M()[0]}import{useMatch as Q}from"react-router-dom";function _(e){return Q(e)}import{useCallback as R}from"react";function j(){let e=g(),t=p(),r=l(),n=R((s,c)=>{let i=new URLSearchParams(e.toString());i.set(s,c);let h=i.toString(),u=`${r.pathname||"/"}${h?`?${h}`:""}`;t(u)},[e,t,r.pathname]),a=R(s=>{let c=new URLSearchParams(e.toString());c.delete(s);let i=c.toString(),f=`${r.pathname||"/"}${i?`?${i}`:""}`;t(f)},[e,t,r.pathname]),o=R(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:a,clearQueries:o}}import{useMemo as q}from"react";import{isClient as F,FEATURE_STATUS as D}from"@donotdev/core";import{useAuthConfig as B}from"@donotdev/core";function Z(e={}){let{auth:t,redirectTo:r,condition:n}=e,a=l(),o=B(),s=m("user"),c=m("can"),i=m("status");return q(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!F())return f;if(i===D.INITIALIZING)return{...f,isChecking:!0};if(n){let u=n(s,i);return{shouldRedirect:u,redirectTo:u&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!c)return f;if(!c.navigate(t)){let u=null;if(typeof t=="object"&&t.required&&!s){let v=a.search.includes("code=")||a.search.includes("state=")||a.search.includes("error="),A=o.authRoute;v?u=`${A}${a.search}`:u=A}else typeof t=="object"&&t.role?u=o.roleRoute:typeof t=="object"&&t.tier?u=o.tierRoute:u=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||u,isChecking:!1}}}return f},[t,i,s,c,n,r,a.search,o.authRoute,o.roleRoute,o.tierRoute])}export{L as useBack,l as useLocation,_ as useMatch,p as useNavigate,d as useParams,K as usePrefetch,j as useQueryParams,Z as useRedirectGuard,U as useRefresh,E as useRouteParam,g as useSearchParams};
@@ -14,7 +14,7 @@
14
14
  * - Vite: resolve.conditions ['vite-app'] → hooks.vite.ts (React Router)
15
15
  * - Next.js: default → hooks.next.ts (App Router)
16
16
  *
17
- * @version 0.0.1
17
+ * @version 0.1.0
18
18
  * @since 0.0.1
19
19
  * @author AMBROISE PARK Consulting
20
20
  */
@@ -16,7 +16,7 @@
16
16
  * - Vite: resolve.conditions ['vite-app'] → hooks.vite.ts (React Router)
17
17
  * - Next.js: default → hooks.next.ts (App Router)
18
18
  *
19
- * @version 0.0.1
19
+ * @version 0.1.0
20
20
  * @since 0.0.1
21
21
  * @author AMBROISE PARK Consulting
22
22
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Routing hook types
3
3
  *
4
- * @version 0.0.1
4
+ * @version 0.1.0
5
5
  * @since 0.0.1
6
6
  * @author AMBROISE PARK Consulting
7
7
  */
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @fileoverview Next.js-specific location hook
5
5
  *
6
- * @version 0.0.1
6
+ * @version 0.1.0
7
7
  * @since 0.0.1
8
8
  * @author AMBROISE PARK Consulting
9
9
  */
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @fileoverview Vite-specific location hook
5
5
  *
6
- * @version 0.0.1
6
+ * @version 0.1.0
7
7
  * @since 0.0.1
8
8
  * @author AMBROISE PARK Consulting
9
9
  */
@@ -1,4 +1,12 @@
1
1
  import type { NavigateOptions } from './types';
2
+ /**
3
+ * Navigation hook with auth interception.
4
+ *
5
+ * @grill-refuted Returns a new function ref each render (no useCallback). Safe because
6
+ * AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
7
+ * the effect body is a no-op when not redirecting, and after redirect the component unmounts.
8
+ * React 19 - no useCallback unless profiler proves bottleneck.
9
+ */
2
10
  export declare function useNavigate(): (to: string, options?: NavigateOptions) => void;
3
11
  export declare function useBack(): () => void;
4
12
  export declare function useRefresh(): () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,WAAW,SAKlB,MAAM,YAAY,eAAe,UA0BzC;AAED,wBAAgB,OAAO,eAGtB;AAED,wBAAgB,UAAU,eAGzB;AAED,wBAAgB,WAAW,SAED,MAAM,UAC/B"}
1
+ {"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA8B/C;;;;;;;GAOG;AACH,wBAAgB,WAAW,KAOjB,IAAI,MAAM,EAAE,UAAU,eAAe,UAkC9C;AAED,wBAAgB,OAAO,eAGtB;AAED,wBAAgB,UAAU,eAGzB;AAED,wBAAgB,WAAW,KAEjB,IAAI,MAAM,UACnB"}
@@ -2,23 +2,73 @@
2
2
  // packages/ui/src/routing/hooks/useNavigate.next.ts
3
3
  /**
4
4
  * @fileoverview Next.js-specific navigation hooks
5
- * @description Navigation hooks for Next.js App Router
5
+ * @description Navigation hooks for Next.js App Router with auth interception
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
  import { useRouter as useNextRouter } from 'next/navigation';
12
- import { useCallback } from 'react';
13
- import { isClient, useOverlayStore } from '@donotdev/core';
12
+ import { isClient, useOverlayStore, useAuthConfig, FEATURE_STATUS, getRoutes, safeSessionStorage, } from '@donotdev/core';
13
+ import { useAuthSafe } from '../../utils/useAuthSafe';
14
+ /**
15
+ * Check if a route requires auth by reading discovered routes.
16
+ *
17
+ * Uses exact path match + startsWith for nested routes. Does NOT handle
18
+ * parameterized routes (e.g. `/blog/:slug`). Current protected routes are
19
+ * all exact paths. If parameterized auth routes are added, this needs
20
+ * pattern matching (pathToRegexp or similar).
21
+ *
22
+ * @grill-refuted getRoutes() timing is safe - virtual module hydrates synchronously
23
+ * before React renders. If routes aren't loaded, returns false (fail-open).
24
+ * Cold load is covered by AuthGuard as belt-and-suspenders.
25
+ */
26
+ function routeRequiresAuth(path) {
27
+ try {
28
+ const routes = getRoutes();
29
+ if (!routes?.length)
30
+ return false;
31
+ const route = routes.find((r) => r.path === path || path.startsWith(r.path + '/'));
32
+ if (!route)
33
+ return false;
34
+ if (route.auth === true)
35
+ return true;
36
+ if (typeof route.auth === 'object' && route.auth?.required)
37
+ return true;
38
+ return false;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ /**
45
+ * Navigation hook with auth interception.
46
+ *
47
+ * @grill-refuted Returns a new function ref each render (no useCallback). Safe because
48
+ * AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
49
+ * the effect body is a no-op when not redirecting, and after redirect the component unmounts.
50
+ * React 19 - no useCallback unless profiler proves bottleneck.
51
+ */
14
52
  export function useNavigate() {
15
53
  const router = useNextRouter();
16
54
  const closeAll = useOverlayStore((state) => state.closeAll);
17
- return useCallback((to, options) => {
55
+ const user = useAuthSafe('user');
56
+ const status = useAuthSafe('status');
57
+ const authConfig = useAuthConfig();
58
+ return (to, options) => {
18
59
  if (to === 'back') {
19
60
  closeAll();
20
61
  return router.back();
21
62
  }
63
+ // Auth interception: block SPA nav to protected routes when not auth'd.
64
+ // Skip while INITIALIZING - user may be authenticated but not resolved yet.
65
+ if (!user && status !== FEATURE_STATUS.INITIALIZING && routeRequiresAuth(to)) {
66
+ safeSessionStorage.setItem('dndev.auth.returnTo', to);
67
+ safeSessionStorage.setItem('dndev.auth.guardToast', '1');
68
+ closeAll();
69
+ /** @grill-refuted authRoute! safe - useAuthConfig() guarantees DEFAULT_AUTH merge provides '/' */
70
+ return router.replace(authConfig.authRoute);
71
+ }
22
72
  closeAll();
23
73
  if (options?.preserveScroll && isClient()) {
24
74
  const scrollY = window.scrollY;
@@ -36,17 +86,17 @@ export function useNavigate() {
36
86
  if (options?.replace)
37
87
  return router.replace(to);
38
88
  return router.push(to);
39
- }, [router, closeAll]);
89
+ };
40
90
  }
41
91
  export function useBack() {
42
92
  const router = useNextRouter();
43
- return useCallback(() => router.back(), [router]);
93
+ return () => router.back();
44
94
  }
45
95
  export function useRefresh() {
46
96
  const router = useNextRouter();
47
- return useCallback(() => router.refresh(), [router]);
97
+ return () => router.refresh();
48
98
  }
49
99
  export function usePrefetch() {
50
100
  const router = useNextRouter();
51
- return useCallback((to) => router.prefetch(to), [router]);
101
+ return (to) => router.prefetch(to);
52
102
  }
@@ -1,4 +1,12 @@
1
1
  import type { NavigateOptions } from './types';
2
+ /**
3
+ * Navigation hook with auth interception.
4
+ *
5
+ * @grill-refuted Returns a new function ref each render (no useCallback). Safe because
6
+ * AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
7
+ * the effect body is a no-op when not redirecting, and after redirect the component unmounts.
8
+ * React 19 - no useCallback unless profiler proves bottleneck.
9
+ */
2
10
  export declare function useNavigate(): (to: string, options?: NavigateOptions) => void | Promise<void>;
3
11
  export declare function useBack(): () => void | Promise<void>;
4
12
  export declare function useRefresh(): () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,WAAW,SAKlB,MAAM,YAAY,eAAe,0BAazC;AAED,wBAAgB,OAAO,+BAGtB;AAED,wBAAgB,UAAU,eAIzB;AAED,wBAAgB,WAAW,UACA,MAAM,UAGhC"}
1
+ {"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA8B/C;;;;;;;GAOG;AACH,wBAAgB,WAAW,KAOjB,IAAI,MAAM,EAAE,UAAU,eAAe,0BAqB9C;AAED,wBAAgB,OAAO,+BAGtB;AAED,wBAAgB,UAAU,eAIzB;AAED,wBAAgB,WAAW,KACjB,KAAK,MAAM,UAGpB"}