@donotdev/ui 0.3.1 → 0.3.2

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 (299) hide show
  1. package/dist/components/auth/AuthHeader.js +1 -93
  2. package/dist/components/auth/AuthMenu.d.ts.map +1 -1
  3. package/dist/components/auth/AuthMenu.js +3 -286
  4. package/dist/components/auth/index.js +1 -9
  5. package/dist/components/common/FeatureCard.d.ts.map +1 -1
  6. package/dist/components/common/FeatureCard.js +1 -86
  7. package/dist/components/common/FeatureDisabled.js +1 -67
  8. package/dist/components/common/IconPlaceholder.d.ts +24 -0
  9. package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
  10. package/dist/components/common/IconPlaceholder.js +1 -0
  11. package/dist/components/common/LazyLucideIcon.d.ts +39 -0
  12. package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
  13. package/dist/components/common/LazyLucideIcon.js +1 -0
  14. package/dist/components/common/ProgressBar.js +1 -84
  15. package/dist/components/common/RedirectOverlay.js +1 -243
  16. package/dist/components/common/Skeleton.js +1 -144
  17. package/dist/components/common/TechBento.d.ts.map +1 -1
  18. package/dist/components/common/TechBento.js +1 -53
  19. package/dist/components/common/icon.d.ts +1 -1
  20. package/dist/components/common/icon.d.ts.map +1 -1
  21. package/dist/components/common/icon.js +1 -84
  22. package/dist/components/common/iconByName.d.ts +33 -0
  23. package/dist/components/common/iconByName.d.ts.map +1 -0
  24. package/dist/components/common/iconByName.js +1 -0
  25. package/dist/components/common/index.js +1 -16
  26. package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
  27. package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
  28. package/dist/components/cookie-consent/ConsentBanner.js +1 -31
  29. package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
  30. package/dist/components/cookie-consent/CookieConsent.js +1 -183
  31. package/dist/components/cookie-consent/index.js +1 -11
  32. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
  33. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
  34. package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
  35. package/dist/components/index.js +1 -13
  36. package/dist/components/layout/GameContainer.d.ts.map +1 -1
  37. package/dist/components/layout/GameContainer.js +1 -72
  38. package/dist/components/layout/GameFlow.d.ts.map +1 -1
  39. package/dist/components/layout/GameFlow.js +1 -93
  40. package/dist/components/layout/PageConfig.d.ts.map +1 -1
  41. package/dist/components/layout/PageConfig.js +1 -47
  42. package/dist/components/layout/PageContainer.d.ts.map +1 -1
  43. package/dist/components/layout/PageContainer.js +1 -38
  44. package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
  45. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  46. package/dist/components/layout/components/Breadcrumbs.js +1 -89
  47. package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
  48. package/dist/components/layout/components/DropdownNavigation.js +1 -30
  49. package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
  50. package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
  51. package/dist/components/layout/components/Notifications.js +1 -182
  52. package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
  53. package/dist/components/layout/components/header/AppBranding.js +1 -54
  54. package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
  55. package/dist/components/layout/components/header/AppIcon.js +1 -59
  56. package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
  57. package/dist/components/layout/components/header/AppTitle.js +1 -40
  58. package/dist/components/layout/components/header/CacheSettings.js +1 -225
  59. package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
  60. package/dist/components/layout/components/header/GameTitle.js +1 -66
  61. package/dist/components/layout/components/header/HeaderMenu.js +1 -75
  62. package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
  63. package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
  64. package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
  65. package/dist/components/layout/components/header/SettingsMenu.js +1 -85
  66. package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
  67. package/dist/components/layout/components/header/ThemeToggle.js +1 -93
  68. package/dist/components/layout/components/index.js +1 -25
  69. package/dist/components/layout/index.js +1 -14
  70. package/dist/crud/components/ChildRowsPicker.js +1 -68
  71. package/dist/crud/components/CrudCardLink.js +1 -14
  72. package/dist/crud/components/EntityCardList.js +1 -184
  73. package/dist/crud/components/EntityDisplayRenderer.js +1 -130
  74. package/dist/crud/components/EntityFormRenderer.js +1 -433
  75. package/dist/crud/components/EntityList.js +1 -521
  76. package/dist/crud/components/EntityRecommendations.js +1 -87
  77. package/dist/crud/components/EntityWorkflow.js +1 -55
  78. package/dist/crud/components/Form.d.ts.map +1 -1
  79. package/dist/crud/components/Form.js +1 -198
  80. package/dist/crud/components/cellEditFor.js +1 -74
  81. package/dist/crud/components/entityParent.js +1 -76
  82. package/dist/crud/components/index.js +1 -16
  83. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
  84. package/dist/crud/components/useRecordBreadcrumb.js +1 -43
  85. package/dist/crud/crudImports.js +1 -51
  86. package/dist/crud/index.js +1 -11
  87. package/dist/data/techLogos.js +1 -99
  88. package/dist/dndev-next.css +25 -4
  89. package/dist/dndev.css +25 -4
  90. package/dist/index.js +1 -5
  91. package/dist/internal/common/DnDevErrorBoundary.js +1 -55
  92. package/dist/internal/common/ErrorFallback.js +3 -214
  93. package/dist/internal/common/GlobalErrorFallback.js +1 -45
  94. package/dist/internal/common/RouteErrorFallback.js +3 -140
  95. package/dist/internal/devtools/DebugTools.js +1 -131
  96. package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
  97. package/dist/internal/devtools/components/ConfigTab.js +1 -61
  98. package/dist/internal/devtools/components/CookieTab.js +1 -156
  99. package/dist/internal/devtools/components/DebugDialog.js +1 -48
  100. package/dist/internal/devtools/components/DesignTab.js +1 -469
  101. package/dist/internal/devtools/components/LayoutReset.js +1 -214
  102. package/dist/internal/devtools/components/MaskedValue.js +1 -39
  103. package/dist/internal/devtools/components/StoresTab.js +1 -90
  104. package/dist/internal/devtools/components/index.js +1 -16
  105. package/dist/internal/devtools/index.js +1 -13
  106. package/dist/internal/devtools/types.js +0 -2
  107. package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
  108. package/dist/internal/devtools/utils/index.js +1 -12
  109. package/dist/internal/devtools/utils/maskSensitive.js +1 -59
  110. package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
  111. package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
  112. package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
  113. package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
  114. package/dist/internal/initializers/index.js +1 -11
  115. package/dist/internal/layout/DnDevLayout.js +1 -321
  116. package/dist/internal/layout/components/AutoMetaTags.d.ts +2 -0
  117. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  118. package/dist/internal/layout/components/AutoMetaTags.js +1 -338
  119. package/dist/internal/layout/components/FaviconHead.js +1 -60
  120. package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
  121. package/dist/internal/layout/components/HeadTags.js +1 -20
  122. package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
  123. package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
  124. package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
  125. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  126. package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
  127. package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
  128. package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
  129. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
  130. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  131. package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
  132. package/dist/internal/layout/components/i18nSeoMeta.js +1 -53
  133. package/dist/internal/layout/components/index.js +1 -13
  134. package/dist/internal/layout/config/defaults.js +1 -47
  135. package/dist/internal/layout/config/index.js +1 -11
  136. package/dist/internal/layout/config/presets/admin.js +1 -35
  137. package/dist/internal/layout/config/presets/blog.js +1 -31
  138. package/dist/internal/layout/config/presets/docs.js +1 -51
  139. package/dist/internal/layout/config/presets/game.js +1 -53
  140. package/dist/internal/layout/config/presets/index.js +1 -24
  141. package/dist/internal/layout/config/presets/landing.js +1 -42
  142. package/dist/internal/layout/config/presets/moolti.js +1 -52
  143. package/dist/internal/layout/config/presets/plain.js +1 -25
  144. package/dist/internal/layout/renderers/index.js +0 -10
  145. package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
  146. package/dist/internal/layout/zones/DnDevFooter.js +1 -67
  147. package/dist/internal/layout/zones/DnDevHeader.js +1 -41
  148. package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
  149. package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
  150. package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
  151. package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
  152. package/dist/internal/layout/zones/index.js +1 -14
  153. package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
  154. package/dist/internal/providers/NavigationProvider.js +1 -71
  155. package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
  156. package/dist/internal/providers/SentryInitializer.js +1 -36
  157. package/dist/internal/providers/UIProviders.js +1 -79
  158. package/dist/internal/providers/index.js +1 -12
  159. package/dist/next.js +1 -11
  160. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  161. package/dist/providers/NextJsAppProviders.js +1 -107
  162. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  163. package/dist/providers/ViteAppProviders.js +1 -117
  164. package/dist/providers/index.js +1 -11
  165. package/dist/routing/404.js +1 -108
  166. package/dist/routing/AuthGuard.js +1 -178
  167. package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
  168. package/dist/routing/AuthGuardFallback.js +1 -67
  169. package/dist/routing/AuthReturnTo.js +1 -68
  170. package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
  171. package/dist/routing/DnDevNavigationMenu.js +1 -138
  172. package/dist/routing/GoTo.d.ts.map +1 -1
  173. package/dist/routing/GoTo.js +1 -38
  174. package/dist/routing/GoToDialog.d.ts.map +1 -1
  175. package/dist/routing/GoToDialog.js +1 -97
  176. package/dist/routing/GoToInput.d.ts.map +1 -1
  177. package/dist/routing/GoToInput.js +1 -49
  178. package/dist/routing/GoToWrapper.d.ts.map +1 -1
  179. package/dist/routing/GoToWrapper.js +1 -59
  180. package/dist/routing/Link.d.ts +10 -2
  181. package/dist/routing/Link.d.ts.map +1 -1
  182. package/dist/routing/Link.js +1 -109
  183. package/dist/routing/NavigationItem.d.ts.map +1 -1
  184. package/dist/routing/NavigationItem.js +1 -44
  185. package/dist/routing/NotFoundDocument.d.ts +33 -0
  186. package/dist/routing/NotFoundDocument.d.ts.map +1 -0
  187. package/dist/routing/NotFoundDocument.js +1 -0
  188. package/dist/routing/SignedInRedirect.js +1 -47
  189. package/dist/routing/hooks/hooks.vite.js +1 -1
  190. package/dist/routing/hooks/index.js +1 -26
  191. package/dist/routing/hooks/types.js +0 -2
  192. package/dist/routing/hooks/useLocation.next.js +1 -35
  193. package/dist/routing/hooks/useLocation.vite.js +1 -13
  194. package/dist/routing/hooks/useMatch.next.js +1 -31
  195. package/dist/routing/hooks/useMatch.vite.js +1 -6
  196. package/dist/routing/hooks/useNavigate.next.js +1 -64
  197. package/dist/routing/hooks/useNavigate.vite.js +1 -61
  198. package/dist/routing/hooks/useParams.next.js +1 -9
  199. package/dist/routing/hooks/useParams.vite.js +1 -6
  200. package/dist/routing/hooks/useQueryParams.next.js +1 -66
  201. package/dist/routing/hooks/useQueryParams.vite.js +1 -66
  202. package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
  203. package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
  204. package/dist/routing/hooks/useRouteParam.next.js +1 -38
  205. package/dist/routing/hooks/useRouteParam.vite.js +1 -38
  206. package/dist/routing/hooks/useRoutePath.next.js +1 -36
  207. package/dist/routing/hooks/useRoutePath.vite.js +1 -25
  208. package/dist/routing/hooks/useSearchParams.next.js +1 -22
  209. package/dist/routing/hooks/useSearchParams.vite.js +1 -22
  210. package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
  211. package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
  212. package/dist/routing/index.d.ts +1 -0
  213. package/dist/routing/index.d.ts.map +1 -1
  214. package/dist/routing/index.js +1 -32
  215. package/dist/routing/link/InternalLink.next.d.ts +23 -0
  216. package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
  217. package/dist/routing/link/InternalLink.next.js +1 -0
  218. package/dist/routing/link/InternalLink.vite.d.ts +22 -0
  219. package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
  220. package/dist/routing/link/InternalLink.vite.js +1 -0
  221. package/dist/routing/link/absolutePath.d.ts +17 -0
  222. package/dist/routing/link/absolutePath.d.ts.map +1 -0
  223. package/dist/routing/link/absolutePath.js +1 -0
  224. package/dist/routing/link/link.next.d.ts +12 -0
  225. package/dist/routing/link/link.next.d.ts.map +1 -0
  226. package/dist/routing/link/link.next.js +1 -0
  227. package/dist/routing/link/link.vite.d.ts +12 -0
  228. package/dist/routing/link/link.vite.d.ts.map +1 -0
  229. package/dist/routing/link/link.vite.js +1 -0
  230. package/dist/routing/link/types.d.ts +30 -0
  231. package/dist/routing/link/types.d.ts.map +1 -0
  232. package/dist/routing/link/types.js +0 -0
  233. package/dist/routing/parentRoute.js +1 -43
  234. package/dist/routing/useGoTo.d.ts.map +1 -1
  235. package/dist/routing/useGoTo.js +1 -59
  236. package/dist/routing/useNavigation.d.ts.map +1 -1
  237. package/dist/routing/useNavigation.js +1 -114
  238. package/dist/routing/useRouteDiscovery.d.ts +1 -0
  239. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  240. package/dist/routing/useRouteDiscovery.js +1 -313
  241. package/dist/rsc.d.ts +28 -0
  242. package/dist/rsc.d.ts.map +1 -0
  243. package/dist/rsc.js +1 -0
  244. package/dist/styles/index.css +25 -4
  245. package/dist/styles/index.js +1 -10
  246. package/dist/styles/layoutConstants.js +1 -134
  247. package/dist/symbol-index.json +1 -1
  248. package/dist/utils/assetResolver.d.ts.map +1 -1
  249. package/dist/utils/assetResolver.js +1 -297
  250. package/dist/utils/index.js +1 -23
  251. package/dist/utils/sanitizeSvg.js +1 -51
  252. package/dist/utils/tList.js +1 -42
  253. package/dist/utils/useAISafe.d.ts.map +1 -1
  254. package/dist/utils/useAISafe.js +1 -53
  255. package/dist/utils/useAuthSafe.d.ts.map +1 -1
  256. package/dist/utils/useAuthSafe.js +1 -78
  257. package/dist/utils/useAuthVisibility.d.ts.map +1 -1
  258. package/dist/utils/useAuthVisibility.js +1 -63
  259. package/dist/utils/useBillingVisibility.d.ts.map +1 -1
  260. package/dist/utils/useBillingVisibility.js +1 -57
  261. package/dist/utils/useCrudSafe.d.ts.map +1 -1
  262. package/dist/utils/useCrudSafe.js +1 -75
  263. package/dist/utils/useDeleteAccountSafe.js +1 -52
  264. package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
  265. package/dist/utils/useFormStoreSafe.js +1 -85
  266. package/dist/utils/useOAuthSafe.d.ts.map +1 -1
  267. package/dist/utils/useOAuthSafe.js +1 -38
  268. package/dist/utils/useSeo.js +1 -151
  269. package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
  270. package/dist/utils/useStripeBillingSafe.js +1 -81
  271. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  272. package/dist/vite-routing/AppRoutes.js +1 -235
  273. package/dist/vite-routing/RootLayout.d.ts.map +1 -1
  274. package/dist/vite-routing/RootLayout.js +1 -205
  275. package/dist/vite-routing/index.js +1 -11
  276. package/dist/vite.js +1 -10
  277. package/guidelines/COMPONENTS.md +3 -3
  278. package/guidelines/PAGES.md +3 -0
  279. package/guidelines/ROUTING.md +15 -0
  280. package/guidelines/SEO.md +4 -1
  281. package/package.json +18 -8
  282. package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
  283. package/dist/ChildRowsPicker-ISP365ON.js +0 -1
  284. package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
  285. package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
  286. package/dist/CookieConsent-QOUAY6B4.js +0 -1
  287. package/dist/GoToDialog-KSBGOIWO.js +0 -1
  288. package/dist/GoToDialog-XBK5EZF4.js +0 -1
  289. package/dist/chunk-3CIZFGST.js +0 -1
  290. package/dist/chunk-LHMKU342.js +0 -1
  291. package/dist/chunk-MS7ZIW5Z.js +0 -1
  292. package/dist/chunk-O2XFH626.js +0 -1
  293. package/dist/chunk-P2DHZWPY.js +0 -1
  294. package/dist/components/common/lucideIconByName.d.ts +0 -9
  295. package/dist/components/common/lucideIconByName.d.ts.map +0 -1
  296. package/dist/components/common/lucideIconByName.js +0 -32
  297. package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
  298. package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
  299. package/dist/internal/layout/components/PerformanceHints.js +0 -71
@@ -1,109 +1 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- // packages/ui/src/routing/Link.tsx
4
- /**
5
- * @fileoverview Link component
6
- * @description Platform-agnostic link component for navigation
7
- *
8
- * @version 0.1.0
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { Link as LinkIcon } from 'lucide-react';
13
- import { cn } from '@donotdev/components';
14
- import { useConsent } from '@donotdev/core';
15
- // Platform-specific hooks via conditional exports
16
- import { useLocalizedPath, useNavigate } from '@donotdev/ui/routing/hooks';
17
- import { Icon } from '../components/common/icon';
18
- /**
19
- * Link component. Internal paths are app paths (`/produits`): the rendered `href` and
20
- * the navigation use the current language's URL (`/en/produits` on an English page,
21
- * unchanged in the default language or a one-language app).
22
- *
23
- * @version 0.2.0
24
- * @since 0.0.1
25
- * @author AMBROISE PARK Consulting
26
- */
27
- export const Link = ({ path, replace, prefetch = true, children, icon, iconEnd = false, label, onClick, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, target, rel, ...rest }) => {
28
- const navigate = useNavigate();
29
- const localize = useLocalizedPath();
30
- const showCookieBanner = useConsent('showCookieBanner');
31
- // Special framework trigger: #cookie-settings
32
- if (path === '#cookie-settings') {
33
- const handleCookieSettings = (e) => {
34
- // Honor browser native open-in-new-tab on modifier+click or non-left-click.
35
- if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
36
- if (onClick)
37
- onClick(e);
38
- return;
39
- }
40
- e.preventDefault();
41
- e.stopPropagation();
42
- try {
43
- showCookieBanner();
44
- }
45
- catch (error) {
46
- console.error('Failed to show cookie banner:', error);
47
- }
48
- if (onClick) {
49
- onClick(e);
50
- }
51
- };
52
- return (_jsxs("a", { href: "#cookie-settings", onClick: handleCookieSettings, className: className, style: {
53
- display: icon && (label || children) ? 'flex' : undefined,
54
- alignItems: icon && (label || children) ? 'center' : undefined,
55
- gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
56
- ...rest.style,
57
- }, "aria-label": ariaLabel || label || 'Cookie Settings', "aria-describedby": ariaDescribedBy, ...rest, children: [icon && !iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon }), label && _jsx("span", { children: label }), children, icon && iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon })] }));
58
- }
59
- // Auto-detect external URLs
60
- const isExternal = path.startsWith('http://') ||
61
- path.startsWith('https://') ||
62
- path.startsWith('mailto:') ||
63
- path.startsWith('tel:');
64
- const handleClick = (e) => {
65
- // External links: let browser handle naturally
66
- if (isExternal) {
67
- if (onClick) {
68
- onClick(e);
69
- }
70
- return; // Don't prevent default for external links
71
- }
72
- // Honor browser native open-in-new-tab on modifier+click or non-left-click.
73
- // Without this, preventDefault() below would block the browser default,
74
- // and Ctrl/Cmd-click would silently navigate in the same tab.
75
- if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
76
- if (onClick)
77
- onClick(e);
78
- return; // browser handles new tab / new window
79
- }
80
- // Internal links: use framework navigation
81
- e.preventDefault();
82
- if (onClick) {
83
- onClick(e);
84
- }
85
- // Ensure path is absolute (starts with /) to prevent relative navigation issues
86
- // but preserve intentional relative paths (starting with '.' or '..')
87
- const absolutePath = path.startsWith('/') || path.startsWith('.') ? path : `/${path}`;
88
- navigate(absolutePath, { replace });
89
- };
90
- const accessibilityProps = {
91
- 'aria-label': ariaLabel || label,
92
- 'aria-describedby': ariaDescribedBy,
93
- };
94
- const linkContent = (_jsxs(_Fragment, { children: [icon && !iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon }), label && _jsx("span", { children: label }), children, icon && iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon })] }));
95
- // External links: use regular <a> with target/rel
96
- if (isExternal) {
97
- return (_jsx("a", { href: path, onClick: handleClick, target: target || '_blank', rel: rel || 'noopener noreferrer', className: className, style: {
98
- display: icon && (label || children) ? 'flex' : undefined,
99
- alignItems: icon && (label || children) ? 'center' : undefined,
100
- gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
101
- }, ...accessibilityProps, ...rest, children: linkContent }));
102
- }
103
- // Internal links: the URL in the current language (`/en/…`), same as navigate()
104
- return (_jsx("a", { href: localize(path), onClick: handleClick, className: className, style: {
105
- display: icon && (label || children) ? 'flex' : undefined,
106
- alignItems: icon && (label || children) ? 'center' : undefined,
107
- gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
108
- }, ...accessibilityProps, ...rest, children: linkContent }));
109
- };
1
+ "use client";import{Link as p}from"lucide-react";import{useConsent as x}from"@donotdev/core";import{InternalLink as A}from"@donotdev/ui/routing/link";import{Icon as d}from"../components/common/icon.js";import{useCookieNoticeRequired as M}from"../components/cookie-consent/useCookieNoticeRequired.js";import{Fragment as N,jsx as o,jsxs as l}from"react/jsx-runtime";var E=({path:s,replace:y,prefetch:b=!0,children:r,icon:e,iconEnd:i=!1,label:t,onClick:a,className:u,"aria-label":m,"aria-describedby":c,target:L,rel:h,...f})=>{let C=x("showCookieBanner"),I=M();if(s==="#cookie-settings")return I?l("a",{href:"#cookie-settings",onClick:n=>{if(n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0){a&&a(n);return}n.preventDefault(),n.stopPropagation();try{C()}catch{}a&&a(n)},className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0,...f.style},"aria-label":m||t||"Cookie Settings","aria-describedby":c,...f,children:[e&&!i&&o(d,{icon:e,fallback:p}),t&&o("span",{children:t}),r,e&&i&&o(d,{icon:e,fallback:p})]}):null;let v=s.startsWith("http://")||s.startsWith("https://")||s.startsWith("mailto:")||s.startsWith("tel:"),g={"aria-label":m||t,"aria-describedby":c},k=l(N,{children:[e&&!i&&o(d,{icon:e,fallback:p}),t&&o("span",{children:t}),r,e&&i&&o(d,{icon:e,fallback:p})]});return v?o("a",{href:s,onClick:a,target:L||"_blank",rel:h||"noopener noreferrer",className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0},...g,...f,children:k}):o(A,{path:s,replace:y,prefetch:b,onClick:a,className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0},...g,...f,children:k})};export{E as Link};
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationItem.d.ts","sourceRoot":"","sources":["../../src/routing/NavigationItem.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAC3C,GAAG;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,mBAAmB,CAuBtE,CAAC"}
1
+ {"version":3,"file":"NavigationItem.d.ts","sourceRoot":"","sources":["../../src/routing/NavigationItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAC3C,GAAG;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,mBAAmB,CAuBtE,CAAC"}
@@ -1,44 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // packages/ui/src/routing/NavigationItem.tsx
3
- /**
4
- * @fileoverview NavigationItem component
5
- * @description Universal navigation item component with icon and label
6
- *
7
- * @version 0.1.0
8
- * @since 0.0.1
9
- * @author AMBROISE PARK Consulting
10
- */
11
- import { Link as LinkIcon } from 'lucide-react';
12
- import { navigationMenuTriggerStylePrimitive } from '@donotdev/components';
13
- import { Link } from './Link';
14
- import { useNavigationItems } from './useNavigation';
15
- import { Icon } from '../components/common/icon';
16
- /**
17
- * Universal NavigationItem component — nav-trigger style link with icon + label.
18
- *
19
- * Used internally in menus, sidebars, and dropdowns.
20
- * Pass `path` to auto-resolve label, icon, and active state from the navigation store.
21
- * Pass `route` for an explicit one-off item not registered in the store.
22
- *
23
- * For standalone Button-style navigation (e.g. header end slot), use
24
- * `useNavigationRoute(path)` and compose with `Button` + `render` prop directly.
25
- *
26
- * @version 0.1.0
27
- * @since 0.0.1
28
- * @author AMBROISE PARK Consulting
29
- *
30
- * @example
31
- * ```tsx
32
- * <NavigationItemComponent path="/pricing" />
33
- * <NavigationItemComponent route={{ path: '/pricing', label: t('pricing'), icon: Tag }} />
34
- * ```
35
- */
36
- export const NavigationItemComponent = ({ path, route: routeProp, showIcons = true, }) => {
37
- const allItems = useNavigationItems();
38
- const route = routeProp ?? allItems.find((item) => item.path === path);
39
- if (!route)
40
- return null;
41
- const hasIcon = showIcons && !!route.icon;
42
- const hasLabel = !!route.label;
43
- return (_jsxs(Link, { path: route.path, className: navigationMenuTriggerStylePrimitive(), ...(hasIcon && !hasLabel && { 'data-display': 'compact' }), children: [showIcons && _jsx(Icon, { icon: route.icon, fallback: LinkIcon }), _jsx("span", { children: route.label })] }));
44
- };
1
+ "use client";import{Link as s}from"lucide-react";import{navigationMenuTriggerStylePrimitive as c}from"@donotdev/components";import{Link as l}from"./Link.js";import{useNavigationItems as u}from"./useNavigation.js";import{Icon as v}from"../components/common/icon.js";import{jsx as e,jsxs as f}from"react/jsx-runtime";var b=({path:n,route:a,showIcons:t=!0})=>{let i=u(),o=a??i.find(m=>m.path===n);if(!o)return null;let r=t&&!!o.icon,p=!!o.label;return f(l,{path:o.path,className:c(),...r&&!p&&{"data-display":"compact"},children:[t&&e(v,{icon:o.icon,fallback:s}),e("span",{children:o.label})]})};export{b as NavigationItemComponent};
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * Wraps the providers of a 404 document. Rendered by the framework's generated 404
4
+ * pages; an app renders it only in a 404 page of its own.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * <NotFoundDocument>
9
+ * <ClientLayout serverCookies="" acceptLanguage={null}>
10
+ * <NotFoundPage showRequestedPath={false} />
11
+ * </ClientLayout>
12
+ * </NotFoundDocument>
13
+ * ```
14
+ *
15
+ * @version 0.1.0
16
+ * @since 0.3.2
17
+ * @author AMBROISE PARK Consulting
18
+ */
19
+ export declare function NotFoundDocument({ children }: {
20
+ children: ReactNode;
21
+ }): import("react").JSX.Element;
22
+ /**
23
+ * Whether the render is inside a NotFoundDocument (the 404 document, served for
24
+ * any unknown URL): URL-derived output must be omitted there.
25
+ *
26
+ * @returns `true` inside a NotFoundDocument
27
+ *
28
+ * @version 0.1.0
29
+ * @since 0.3.2
30
+ * @author AMBROISE PARK Consulting
31
+ */
32
+ export declare function useIsNotFoundDocument(): boolean;
33
+ //# sourceMappingURL=NotFoundDocument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundDocument.d.ts","sourceRoot":"","sources":["../../src/routing/NotFoundDocument.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAMrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}
@@ -0,0 +1 @@
1
+ "use client";import{createContext as e,useContext as n}from"react";import{jsx as r}from"react/jsx-runtime";var o=e(!1);function c({children:t}){return r(o.Provider,{value:!0,children:t})}function d(){return n(o)}export{c as NotFoundDocument,d as useIsNotFoundDocument};
@@ -1,47 +1 @@
1
- 'use client';
2
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
- // packages/ui/src/routing/SignedInRedirect.tsx
4
- /**
5
- * @fileoverview SignedInRedirect component
6
- * @description Client side of PageMeta `signedInRedirect`: sends a signed-in visitor
7
- * of the page to another path. The generated Next proxy redirects before render when
8
- * it can read the session cookie; this covers sign-ins on the page itself (no server
9
- * request) and sessions the server cannot read.
10
- *
11
- * @version 0.1.0
12
- * @since 0.6.0
13
- * @author AMBROISE PARK Consulting
14
- */
15
- import { useEffect } from 'react';
16
- import { isClient, safeSessionStorage } from '@donotdev/core';
17
- import { useNavigate } from '@donotdev/ui/routing/hooks';
18
- import { useAuthSafe } from '../utils/useAuthSafe';
19
- /**
20
- * SignedInRedirect - sends signed-in visitors of a page to `to` (replace).
21
- *
22
- * Renders the page for everyone (server render, signed-out visitors). Once the auth
23
- * user is known, navigates to `to` unless a return-to is pending (`?returnTo=` or
24
- * the saved `dndev.auth.returnTo`): AuthReturnTo takes the visitor there instead.
25
- * Generated route wrappers (Next) and createAppRouter (Vite) mount it for pages whose
26
- * PageMeta sets `signedInRedirect`.
27
- *
28
- * @component
29
- * @example
30
- * ```tsx
31
- * <SignedInRedirect to="/catalogue"><HomePage /></SignedInRedirect>
32
- * ```
33
- */
34
- export function SignedInRedirect({ to, children }) {
35
- const user = useAuthSafe('user');
36
- const navigate = useNavigate();
37
- useEffect(() => {
38
- if (!user || !isClient())
39
- return;
40
- if (new URLSearchParams(window.location.search).has('returnTo'))
41
- return;
42
- if (safeSessionStorage.getItem('dndev.auth.returnTo'))
43
- return;
44
- navigate(to, { replace: true });
45
- }, [user, to, navigate]);
46
- return _jsx(_Fragment, { children: children });
47
- }
1
+ "use client";import{useEffect as o}from"react";import{isClient as i,safeSessionStorage as a}from"@donotdev/core";import{useNavigate as s}from"@donotdev/ui/routing/hooks";import{useAuthSafe as c}from"../utils/useAuthSafe.js";import{Fragment as u,jsx as f}from"react/jsx-runtime";function S({to:e,children:n}){let r=c("user"),t=s();return o(()=>{!r||!i()||new URLSearchParams(window.location.search).has("returnTo")||a.getItem("dndev.auth.returnTo")||t(e,{replace:!0})},[r,e,t]),f(u,{children:n})}export{S as SignedInRedirect};
@@ -1 +1 @@
1
- "use client";import{useNavigate as S}from"react-router-dom";import{getLanguageRouting as T,isClient as G,splitLanguagePath as U,useOverlayStore as N}from"@donotdev/core";import{useHref as b}from"react-router-dom";import{getLanguageRouting as y,localizePath as C,splitLanguagePath as k}from"@donotdev/core";function p(){return k(b("/"),y()).language}function I(){let e=p(),t=y();return r=>C(r,e,t)}function g(){let e=S(),t=N(n=>n.closeAll),r=p();return(n,a)=>{if(n==="back")return t(),e(-1);t();let o=n.startsWith("/")?U(n,T()):null;if(o?.prefixed&&o.language!==r){window.location.assign(n);return}let s=o?.prefixed?o.path:n;return a?.replace?e(s,{replace:!0}):e(s)}}function K(){let e=S();return()=>e(-1)}function O(){return()=>{G()&&window.location.reload()}}function $(){return e=>{}}import{useLocation as E}from"react-router-dom";function m(){return E()}import{useLocation as M}from"react-router-dom";function Q(){return M().pathname}import{useParams as q}from"react-router-dom";function R(){return q()}function D(e){let r=R()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as _}from"react-router-dom";function P(){return _()[0]}import{useMatch as j}from"react-router-dom";function z(e){return j(e)}import{useCallback as A}from"react";function F(){let e=P(),t=g(),r=m(),n=A((s,c)=>{let u=new URLSearchParams(e.toString());u.set(s,c);let f=u.toString(),l=`${r.pathname||"/"}${f?`?${f}`:""}`;t(l)},[e,t,r.pathname]),a=A(s=>{let c=new URLSearchParams(e.toString());c.delete(s);let u=c.toString(),d=`${r.pathname||"/"}${u?`?${u}`:""}`;t(d)},[e,t,r.pathname]),o=A(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:a,clearQueries:o}}import{useMemo as W}from"react";import{isClient as Z,FEATURE_STATUS as J}from"@donotdev/core";import{useAppConfig as V,useAuthConfig as X}from"@donotdev/core";import*as L from"@donotdev/auth";import{DEGRADED_AUTH_API as B}from"@donotdev/core";var v=L?.useAuth;function H(e){return B[e]}function h(e){return v?v(e):H(e)}var we=L?.PasswordResetCallback??(()=>null);function Y(e={}){let{auth:t,redirectTo:r,condition:n}=e,a=m(),o=X(),s=V().auth===!1,c=h("user"),u=h("can"),f=h("status");return W(()=>{let l={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!Z())return l;if(f===J.INITIALIZING)return{...l,isChecking:!0};if(n){let i=n(c,f);return{shouldRedirect:i,redirectTo:i&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!u)return l;if(!u.navigate(t)){if(s&&!r)throw new Error("[dndev] This route declares auth requirements but AppConfig.auth is false, so there is no auth route to redirect to. Enable auth in AppConfig or remove the route's auth requirement.");let i=null;if(typeof t=="object"&&t.required&&!c){let w=a.search.includes("code=")||a.search.includes("state=")||a.search.includes("error="),x=o.authRoute;w?i=`${x}${a.search}`:i=x}else typeof t=="object"&&t.role?i=o.roleRoute:typeof t=="object"&&t.tier?i=o.tierRoute:i=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||i,isChecking:!1}}}return l},[t,f,c,u,n,r,a.search,s,o.authRoute,o.roleRoute,o.tierRoute])}export{K as useBack,I as useLocalizedPath,m as useLocation,z as useMatch,g as useNavigate,R as useParams,$ as usePrefetch,F as useQueryParams,Y as useRedirectGuard,O as useRefresh,D as useRouteParam,Q as useRoutePath,P as useSearchParams,p as useUrlLanguage};
1
+ "use client";import{useNavigate as S}from"react-router-dom";import{getLanguageRouting as T,isClient as G,splitLanguagePath as U,useOverlayStore as N}from"@donotdev/core";import{useHref as b}from"react-router-dom";import{getLanguageRouting as y,localizePath as C,splitLanguagePath as k}from"@donotdev/core";function p(){return k(b("/"),y()).language}function I(){let e=p(),t=y();return r=>C(r,e,t)}function g(){let e=S(),t=N(n=>n.closeAll),r=p();return(n,a)=>{if(n==="back")return t(),e(-1);t();let o=n.startsWith("/")?U(n,T()):null;if(o?.prefixed&&o.language!==r){window.location.assign(n);return}let s=o?.prefixed?o.path:n;return a?.replace?e(s,{replace:!0}):e(s)}}function K(){let e=S();return()=>e(-1)}function O(){return()=>{G()&&window.location.reload()}}function $(){return e=>{}}import{useLocation as E}from"react-router-dom";function m(){return E()}import{useLocation as M}from"react-router-dom";function Q(){return M().pathname}import{useParams as q}from"react-router-dom";function R(){return q()}function D(e){let r=R()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as _}from"react-router-dom";function P(){return _()[0]}import{useMatch as j}from"react-router-dom";function z(e){return j(e)}import{useCallback as A}from"react";function F(){let e=P(),t=g(),r=m(),n=A((s,c)=>{let u=new URLSearchParams(e.toString());u.set(s,c);let l=u.toString(),f=`${r.pathname||"/"}${l?`?${l}`:""}`;t(f)},[e,t,r.pathname]),a=A(s=>{let c=new URLSearchParams(e.toString());c.delete(s);let u=c.toString(),d=`${r.pathname||"/"}${u?`?${u}`:""}`;t(d)},[e,t,r.pathname]),o=A(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:a,clearQueries:o}}import{useMemo as W}from"react";import{isClient as Z,FEATURE_STATUS as J}from"@donotdev/core";import{useAppConfig as V,useAuthConfig as X}from"@donotdev/core";import*as L from"@donotdev/auth";import{DEGRADED_AUTH_API as B}from"@donotdev/core";var v=L?.useAuth;function H(e){return B[e]}function h(e){return v?v(e):H(e)}var we=L?.PasswordResetCallback??(()=>null);function Y(e={}){let{auth:t,redirectTo:r,condition:n}=e,a=m(),o=X(),s=V().auth===!1,c=h("user"),u=h("can"),l=h("status");return W(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!Z())return f;if(l===J.INITIALIZING)return{...f,isChecking:!0};if(n){let i=n(c,l);return{shouldRedirect:i,redirectTo:i&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!u)return f;if(!u.navigate(t)){if(s&&!r)throw new Error("[dndev] This route declares auth requirements but AppConfig.auth is false, so there is no auth route to redirect to. Enable auth in AppConfig or remove the route's auth requirement.");let i=null;if(typeof t=="object"&&t.required&&!c){let w=a.search.includes("code=")||a.search.includes("state=")||a.search.includes("error="),x=o.authRoute;w?i=`${x}${a.search}`:i=x}else typeof t=="object"&&t.role?i=o.roleRoute:typeof t=="object"&&t.tier?i=o.tierRoute:i=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||i,isChecking:!1}}}return f},[t,l,c,u,n,r,a.search,s,o.authRoute,o.roleRoute,o.tierRoute])}export{K as useBack,I as useLocalizedPath,m as useLocation,z as useMatch,g as useNavigate,R as useParams,$ as usePrefetch,F as useQueryParams,Y as useRedirectGuard,O as useRefresh,D as useRouteParam,Q as useRoutePath,P as useSearchParams,p as useUrlLanguage};
@@ -1,26 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/index.ts
3
- /**
4
- * @fileoverview Routing hooks barrel - DO NOT IMPORT DIRECTLY
5
- * @description This file exists for backwards compatibility and local development.
6
- *
7
- * IMPORTANT: Components should import from '@donotdev/ui' (main entry point).
8
- * The routing/index.ts re-exports from '@donotdev/ui/routing/hooks' which triggers
9
- * conditional exports to resolve the correct platform implementation.
10
- *
11
- * This file uses direct relative imports as a fallback for:
12
- * - TypeScript type checking during development
13
- * - Direct file resolution in non-bundled contexts
14
- *
15
- * When bundled properly:
16
- * - Vite: resolve.conditions ['vite-app'] → hooks.vite.ts (React Router)
17
- * - Next.js: default → hooks.next.ts (App Router)
18
- *
19
- * @version 0.1.0
20
- * @since 0.0.1
21
- * @author AMBROISE PARK Consulting
22
- */
23
- // For direct imports and TypeScript, re-export from the Next.js implementation
24
- // (this file should rarely be imported directly - use @donotdev/ui instead)
25
- // The bundler-resolved subpath export in routing/index.ts handles actual resolution
26
- export * from './hooks.next';
1
+ "use client";export{useBack,useLocalizedPath,useLocation,useMatch,useNavigate,useParams,usePrefetch,useQueryParams,useRedirectGuard,useRefresh,useRouteParam,useRoutePath,useSearchParams,useUrlLanguage}from"./hooks.next.js";
@@ -1,2 +0,0 @@
1
- // packages/ui/src/routing/hooks/types.ts
2
- export {};
@@ -1,35 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useLocation.next.ts
3
- /**
4
- * @fileoverview Next.js-specific location hook
5
- *
6
- * @version 0.2.0
7
- * @since 0.0.1
8
- * @author AMBROISE PARK Consulting
9
- */
10
- import { useSearchParams as useNextSearchParams } from 'next/navigation';
11
- import { useRoutePath } from './useRoutePath.next';
12
- /**
13
- * Current location, route-relative: `pathname` has no language prefix (`/en/produits`
14
- * → `/produits`), so route matching, breadcrumbs and guards see app paths.
15
- *
16
- * Reads the query string (`search`): in a cached (static) render that moves the
17
- * render to the browser up to the nearest Suspense boundary. Use `useRoutePath()`
18
- * when only the path is needed.
19
- *
20
- * @version 0.2.0
21
- * @since 0.0.1
22
- * @author AMBROISE PARK Consulting
23
- */
24
- export function useLocation() {
25
- const pathname = useRoutePath();
26
- const searchParams = useNextSearchParams();
27
- const searchString = searchParams.toString();
28
- const search = searchString ? `?${searchString}` : undefined;
29
- return {
30
- pathname,
31
- search,
32
- hash: '',
33
- state: null,
34
- };
35
- }
1
+ "use client";import{useSearchParams as t}from"next/navigation";import{useRoutePath as r}from"./useRoutePath.next.js";function h(){let e=r(),a=t().toString(),s=a?`?${a}`:void 0;return{pathname:e,search:s,hash:"",state:null}}export{h as useLocation};
@@ -1,13 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useLocation.vite.ts
3
- /**
4
- * @fileoverview Vite-specific location hook
5
- *
6
- * @version 0.1.0
7
- * @since 0.0.1
8
- * @author AMBROISE PARK Consulting
9
- */
10
- import { useLocation as useRouterLocation } from 'react-router-dom';
11
- export function useLocation() {
12
- return useRouterLocation();
13
- }
1
+ "use client";import{useLocation as o}from"react-router-dom";function e(){return o()}export{e as useLocation};
@@ -1,31 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useMatch.next.ts
3
- import { useRoutePath } from './useRoutePath.next';
4
- /**
5
- * Match the current route path (language prefix stripped) against a pattern.
6
- *
7
- * @version 0.2.0
8
- * @since 0.0.1
9
- */
10
- export function useMatch(pattern) {
11
- const pathname = useRoutePath();
12
- // Simple pattern matching for Next.js
13
- const regexPattern = pattern
14
- .replace(/:[^/]+/g, '([^/]+)') // Replace :param with regex group
15
- .replace(/\*/g, '.*'); // Replace * with .*
16
- const regex = new RegExp(`^${regexPattern}$`);
17
- const match = pathname.match(regex);
18
- if (!match)
19
- return null;
20
- // Extract params from the pattern
21
- const paramNames = pattern.match(/:[^/]+/g)?.map((p) => p.slice(1)) || [];
22
- const params = {};
23
- paramNames.forEach((name, index) => {
24
- params[name] = match[index + 1] || '';
25
- });
26
- return {
27
- params,
28
- pathname,
29
- pattern,
30
- };
31
- }
1
+ "use client";import{useRoutePath as g}from"./useRoutePath.next.js";function u(e){let c=g(),a=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),s=new RegExp(`^${a}$`),r=c.match(s);if(!r)return null;let o=e.match(/:[^/]+/g)?.map(t=>t.slice(1))||[],n={};return o.forEach((t,m)=>{n[t]=r[m+1]||""}),{params:n,pathname:c,pattern:e}}export{u as useMatch};
@@ -1,6 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useMatch.vite.ts
3
- import { useMatch as useRouterMatch } from 'react-router-dom';
4
- export function useMatch(pattern) {
5
- return useRouterMatch(pattern);
6
- }
1
+ "use client";import{useMatch as e}from"react-router-dom";function u(t){return e(t)}export{u as useMatch};
@@ -1,64 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useNavigate.next.ts
3
- /**
4
- * @fileoverview Next.js-specific navigation hooks
5
- * @description Navigation hooks for Next.js App Router
6
- *
7
- * @version 0.3.0
8
- * @since 0.0.1
9
- * @author AMBROISE PARK Consulting
10
- */
11
- import { useRouter as useNextRouter } from 'next/navigation';
12
- import { isClient, useOverlayStore } from '@donotdev/core';
13
- import { useLocalizedPath } from './useUrlLanguage.next';
14
- /**
15
- * Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
16
- * Protected routes are hidden from unauthorized users via useAccessibleRoutes.
17
- * App paths stay in the current URL's language (`/produits` → `/en/produits` on an
18
- * English page); a path with an explicit language prefix keeps it.
19
- *
20
- * @version 0.3.0
21
- * @since 0.0.1
22
- */
23
- export function useNavigate() {
24
- const router = useNextRouter();
25
- const closeAll = useOverlayStore((state) => state.closeAll);
26
- const localize = useLocalizedPath();
27
- return (path, options) => {
28
- if (path === 'back') {
29
- closeAll();
30
- return router.back();
31
- }
32
- closeAll();
33
- const to = localize(path);
34
- if (options?.preserveScroll && isClient()) {
35
- const scrollY = window.scrollY;
36
- if (options?.replace) {
37
- router.replace(to);
38
- }
39
- else {
40
- router.push(to);
41
- }
42
- requestAnimationFrame(() => {
43
- window.scrollTo({ top: scrollY, behavior: 'auto' });
44
- });
45
- return;
46
- }
47
- if (options?.replace)
48
- return router.replace(to);
49
- return router.push(to);
50
- };
51
- }
52
- export function useBack() {
53
- const router = useNextRouter();
54
- return () => router.back();
55
- }
56
- export function useRefresh() {
57
- const router = useNextRouter();
58
- return () => router.refresh();
59
- }
60
- export function usePrefetch() {
61
- const router = useNextRouter();
62
- const localize = useLocalizedPath();
63
- return (to) => router.prefetch(localize(to));
64
- }
1
+ "use client";import{useRouter as s}from"next/navigation";import{isClient as l,useOverlayStore as a}from"@donotdev/core";import{useLocalizedPath as u}from"./useUrlLanguage.next.js";function h(){let e=s(),r=a(t=>t.closeAll),c=u();return(t,n)=>{if(t==="back")return r(),e.back();r();let o=c(t);if(n?.preserveScroll&&l()){let i=window.scrollY;n?.replace?e.replace(o):e.push(o),requestAnimationFrame(()=>{window.scrollTo({top:i,behavior:"auto"})});return}return n?.replace?e.replace(o):e.push(o)}}function v(){let e=s();return()=>e.back()}function g(){let e=s();return()=>e.refresh()}function x(){let e=s(),r=u();return c=>e.prefetch(r(c))}export{v as useBack,h as useNavigate,x as usePrefetch,g as useRefresh};
@@ -1,61 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useNavigate.vite.ts
3
- /**
4
- * @fileoverview Vite-specific navigation hooks
5
- * @description Navigation hooks for React Router (Vite)
6
- *
7
- * @version 0.3.0
8
- * @since 0.0.1
9
- * @author AMBROISE PARK Consulting
10
- */
11
- import { useNavigate as useRouterNavigate } from 'react-router-dom';
12
- import { getLanguageRouting, isClient, splitLanguagePath, useOverlayStore, } from '@donotdev/core';
13
- import { useUrlLanguage } from './useUrlLanguage.vite';
14
- /**
15
- * Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
16
- * Protected routes are hidden from unauthorized users via useAccessibleRoutes.
17
- * The router basename carries the language prefix (createAppRouter), so app paths
18
- * stay in the current language. A path prefixed with another language opens that
19
- * language's URL (document navigation: the router restarts under its prefix).
20
- *
21
- * @version 0.3.0
22
- * @since 0.0.1
23
- */
24
- export function useNavigate() {
25
- const routerNavigate = useRouterNavigate();
26
- const closeAll = useOverlayStore((state) => state.closeAll);
27
- const language = useUrlLanguage();
28
- return (path, options) => {
29
- if (path === 'back') {
30
- closeAll();
31
- return routerNavigate(-1);
32
- }
33
- closeAll();
34
- const split = path.startsWith('/')
35
- ? splitLanguagePath(path, getLanguageRouting())
36
- : null;
37
- if (split?.prefixed && split.language !== language) {
38
- window.location.assign(path);
39
- return;
40
- }
41
- const to = split?.prefixed ? split.path : path;
42
- if (options?.replace)
43
- return routerNavigate(to, { replace: true });
44
- return routerNavigate(to);
45
- };
46
- }
47
- export function useBack() {
48
- const navigate = useRouterNavigate();
49
- return () => navigate(-1);
50
- }
51
- export function useRefresh() {
52
- return () => {
53
- if (isClient())
54
- window.location.reload();
55
- };
56
- }
57
- export function usePrefetch() {
58
- return (_to) => {
59
- // Vite: no-op
60
- };
61
- }
1
+ "use client";import{useNavigate as i}from"react-router-dom";import{getLanguageRouting as u,isClient as g,splitLanguagePath as l,useOverlayStore as c}from"@donotdev/core";import{useUrlLanguage as f}from"./useUrlLanguage.vite.js";function x(){let t=i(),n=c(e=>e.closeAll),a=f();return(e,s)=>{if(e==="back")return n(),t(-1);n();let r=e.startsWith("/")?l(e,u()):null;if(r?.prefixed&&r.language!==a){window.location.assign(e);return}let o=r?.prefixed?r.path:e;return s?.replace?t(o,{replace:!0}):t(o)}}function N(){let t=i();return()=>t(-1)}function d(){return()=>{g()&&window.location.reload()}}function w(){return t=>{}}export{N as useBack,x as useNavigate,w as usePrefetch,d as useRefresh};
@@ -1,9 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useParams.next.ts
3
- import { useParams as useNextParams } from 'next/navigation';
4
- export function useParams() {
5
- const params = useNextParams();
6
- if (!params)
7
- return {};
8
- return params;
9
- }
1
+ "use client";import{useParams as s}from"next/navigation";function n(){let r=s();return r||{}}export{n as useParams};
@@ -1,6 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useParams.vite.ts
3
- import { useParams as useRouterParams } from 'react-router-dom';
4
- export function useParams() {
5
- return useRouterParams();
6
- }
1
+ "use client";import{useParams as r}from"react-router-dom";function s(){return r()}export{s as useParams};
@@ -1,66 +1 @@
1
- 'use client';
2
- // packages/ui/src/routing/hooks/useQueryParams.next.ts
3
- /**
4
- * @fileoverview Next.js-specific useQueryParams hook
5
- * @description Query parameters hook with setter functionality for App Router
6
- *
7
- * @version 0.1.0
8
- * @since 0.0.1
9
- * @author AMBROISE PARK Consulting
10
- */
11
- import { useCallback } from 'react';
12
- import { useLocation } from './useLocation.next';
13
- import { useNavigate } from './useNavigate.next';
14
- import { useSearchParams } from './useSearchParams.next';
15
- /**
16
- * Platform-agnostic useQueryParams hook
17
- *
18
- * Provides easy access to query parameters with setter functionality
19
- *
20
- * @returns Object with query parameters and setter functions
21
- *
22
- * @example
23
- * ```tsx
24
- * const { query, setQuery, removeQuery } = useQueryParams();
25
- *
26
- * // Get a query parameter
27
- * const page = query.get('page');
28
- *
29
- * // Set a query parameter
30
- * setQuery('page', '2');
31
- *
32
- * // Remove a query parameter
33
- * removeQuery('page');
34
- * ```
35
- */
36
- export function useQueryParams() {
37
- const searchParams = useSearchParams();
38
- const navigate = useNavigate();
39
- const location = useLocation();
40
- const setQuery = useCallback((key, value) => {
41
- const newParams = new URLSearchParams(searchParams.toString());
42
- newParams.set(key, value);
43
- const newSearch = newParams.toString();
44
- const pathname = location.pathname || '/';
45
- const newUrl = `${pathname}${newSearch ? `?${newSearch}` : ''}`;
46
- navigate(newUrl);
47
- }, [searchParams, navigate, location.pathname]);
48
- const removeQuery = useCallback((key) => {
49
- const newParams = new URLSearchParams(searchParams.toString());
50
- newParams.delete(key);
51
- const newSearch = newParams.toString();
52
- const pathname = location.pathname || '/';
53
- const newUrl = `${pathname}${newSearch ? `?${newSearch}` : ''}`;
54
- navigate(newUrl);
55
- }, [searchParams, navigate, location.pathname]);
56
- const clearQueries = useCallback(() => {
57
- const pathname = location.pathname || '/';
58
- navigate(pathname);
59
- }, [navigate, location.pathname]);
60
- return {
61
- query: searchParams,
62
- setQuery,
63
- removeQuery,
64
- clearQueries,
65
- };
66
- }
1
+ "use client";import{useCallback as c}from"react";import{useLocation as g}from"./useLocation.next.js";import{useNavigate as S}from"./useNavigate.next.js";import{useSearchParams as l}from"./useSearchParams.next.js";function y(){let e=l(),t=S(),a=g(),i=c((n,s)=>{let r=new URLSearchParams(e.toString());r.set(n,s);let o=r.toString(),u=`${a.pathname||"/"}${o?`?${o}`:""}`;t(u)},[e,t,a.pathname]),h=c(n=>{let s=new URLSearchParams(e.toString());s.delete(n);let r=s.toString(),m=`${a.pathname||"/"}${r?`?${r}`:""}`;t(m)},[e,t,a.pathname]),p=c(()=>{let n=a.pathname||"/";t(n)},[t,a.pathname]);return{query:e,setQuery:i,removeQuery:h,clearQueries:p}}export{y as useQueryParams};