@donotdev/ui 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GoToDialog-CICRYHHG.js → GoToDialog-KSBGOIWO.js} +1 -1
- package/dist/chunk-MS7ZIW5Z.js +1 -0
- package/dist/components/auth/AuthHeader.d.ts.map +1 -1
- package/dist/components/auth/AuthHeader.js +0 -2
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +6 -40
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +2 -1
- package/dist/components/common/lucideIconByName.d.ts +9 -0
- package/dist/components/common/lucideIconByName.d.ts.map +1 -0
- package/dist/components/common/lucideIconByName.js +32 -0
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +14 -9
- package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +6 -4
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +2 -1
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +2 -1
- package/dist/crud/components/CrudCardLink.d.ts +6 -6
- package/dist/crud/components/CrudCardLink.d.ts.map +1 -1
- package/dist/crud/components/CrudCardLink.js +3 -9
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +3 -11
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +4 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +27 -5
- package/dist/crud/components/EntityList.d.ts +4 -4
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +136 -59
- package/dist/crud/components/Form.d.ts +1 -1
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +2 -2
- package/dist/crud/components/cellEditFor.d.ts +28 -0
- package/dist/crud/components/cellEditFor.d.ts.map +1 -0
- package/dist/crud/components/cellEditFor.js +54 -0
- package/dist/crud/components/entityParent.d.ts +40 -0
- package/dist/crud/components/entityParent.d.ts.map +1 -0
- package/dist/crud/components/entityParent.js +54 -0
- package/dist/crud/components/useRecordBreadcrumb.d.ts +11 -0
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -0
- package/dist/crud/components/useRecordBreadcrumb.js +34 -0
- package/dist/crud/crudImports.d.ts +2 -0
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +2 -0
- package/dist/dndev-next.css +483 -145
- package/dist/dndev.css +483 -145
- package/dist/index.js +4 -4
- package/dist/internal/common/RouteErrorFallback.d.ts.map +1 -1
- package/dist/internal/common/RouteErrorFallback.js +2 -4
- package/dist/internal/devtools/components/ConfigTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/ConfigTab.js +1 -1
- package/dist/internal/devtools/components/CookieTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/CookieTab.js +1 -5
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +18 -7
- package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/StoresTab.js +17 -3
- package/dist/internal/devtools/types.d.ts +3 -3
- package/dist/internal/devtools/types.d.ts.map +1 -1
- package/dist/internal/devtools/utils/maskSensitive.d.ts +1 -1
- package/dist/internal/devtools/utils/maskSensitive.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +21 -21
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +39 -36
- package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +1 -1
- package/dist/internal/layout/components/i18nSeoMeta.js +1 -0
- package/dist/internal/layout/zones/DnDevMergedBar.js +3 -3
- package/dist/internal/providers/UIProviders.d.ts.map +1 -1
- package/dist/internal/providers/UIProviders.js +7 -2
- package/dist/providers/NextJsAppProviders.d.ts +5 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +36 -5
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +42 -4
- package/dist/routing/404.js +4 -4
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -2
- package/dist/routing/AuthReturnTo.d.ts.map +1 -1
- package/dist/routing/AuthReturnTo.js +9 -2
- package/dist/routing/GoTo.d.ts +0 -6
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +5 -8
- package/dist/routing/Link.d.ts +4 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +8 -5
- package/dist/routing/SignedInRedirect.d.ts +27 -0
- package/dist/routing/SignedInRedirect.d.ts.map +1 -0
- package/dist/routing/SignedInRedirect.js +47 -0
- package/dist/routing/hooks/hooks.next.d.ts +2 -0
- package/dist/routing/hooks/hooks.next.d.ts.map +1 -1
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.d.ts +2 -0
- package/dist/routing/hooks/hooks.vite.d.ts.map +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useLocation.next.d.ts +12 -0
- package/dist/routing/hooks/useLocation.next.d.ts.map +1 -1
- package/dist/routing/hooks/useLocation.next.js +17 -4
- package/dist/routing/hooks/useMatch.next.d.ts +6 -0
- package/dist/routing/hooks/useMatch.next.d.ts.map +1 -1
- package/dist/routing/hooks/useMatch.next.js +8 -2
- package/dist/routing/hooks/useNavigate.next.d.ts +6 -1
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +13 -4
- package/dist/routing/hooks/useNavigate.vite.d.ts +7 -1
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +20 -4
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +7 -1
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +7 -1
- package/dist/routing/hooks/useRoutePath.next.d.ts +23 -0
- package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -0
- package/dist/routing/hooks/useRoutePath.next.js +36 -0
- package/dist/routing/hooks/useRoutePath.vite.d.ts +13 -0
- package/dist/routing/hooks/useRoutePath.vite.d.ts.map +1 -0
- package/dist/routing/hooks/useRoutePath.vite.js +25 -0
- package/dist/routing/hooks/useUrlLanguage.next.d.ts +28 -0
- package/dist/routing/hooks/useUrlLanguage.next.d.ts.map +1 -0
- package/dist/routing/hooks/useUrlLanguage.next.js +50 -0
- package/dist/routing/hooks/useUrlLanguage.vite.d.ts +22 -0
- package/dist/routing/hooks/useUrlLanguage.vite.d.ts.map +1 -0
- package/dist/routing/hooks/useUrlLanguage.vite.js +41 -0
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -1
- package/dist/routing/useNavigation.js +4 -4
- package/dist/styles/index.css +483 -145
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/useDeleteAccountSafe.d.ts +17 -0
- package/dist/utils/useDeleteAccountSafe.d.ts.map +1 -0
- package/dist/utils/useDeleteAccountSafe.js +52 -0
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -0
- package/dist/utils/useSeo.d.ts +10 -2
- package/dist/utils/useSeo.d.ts.map +1 -1
- package/dist/utils/useSeo.js +44 -9
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +37 -4
- package/guidelines/COMPONENTS.md +2 -1
- package/guidelines/PAGES.md +7 -0
- package/guidelines/ROUTING.md +4 -0
- package/guidelines/SEO.md +52 -0
- package/package.json +9 -9
- package/dist/CookieConsent-5NH5DNTP.js +0 -1
- package/dist/CookieConsent-W7UE647Y.js +0 -1
- package/dist/GoToDialog-YGBON6FR.js +0 -1
- package/dist/chunk-DRFM6WXH.js +0 -1
- package/dist/chunk-MIPTBUWY.js +0 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +0 -57
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +0 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.js +0 -182
|
@@ -3,18 +3,31 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Next.js-specific location hook
|
|
5
5
|
*
|
|
6
|
-
* @version 0.
|
|
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
|
|
7
21
|
* @since 0.0.1
|
|
8
22
|
* @author AMBROISE PARK Consulting
|
|
9
23
|
*/
|
|
10
|
-
import { usePathname, useSearchParams as useNextSearchParams, } from 'next/navigation';
|
|
11
24
|
export function useLocation() {
|
|
12
|
-
const pathname =
|
|
25
|
+
const pathname = useRoutePath();
|
|
13
26
|
const searchParams = useNextSearchParams();
|
|
14
27
|
const searchString = searchParams.toString();
|
|
15
28
|
const search = searchString ? `?${searchString}` : undefined;
|
|
16
29
|
return {
|
|
17
|
-
pathname
|
|
30
|
+
pathname,
|
|
18
31
|
search,
|
|
19
32
|
hash: '',
|
|
20
33
|
state: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useMatch.next.ts"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM;;;;SA0BvC"}
|
|
1
|
+
{"version":3,"file":"useMatch.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useMatch.next.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM;;;;SA0BvC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
// packages/ui/src/routing/hooks/useMatch.next.ts
|
|
3
|
-
import {
|
|
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
|
+
*/
|
|
4
10
|
export function useMatch(pattern) {
|
|
5
|
-
const pathname =
|
|
11
|
+
const pathname = useRoutePath();
|
|
6
12
|
// Simple pattern matching for Next.js
|
|
7
13
|
const regexPattern = pattern
|
|
8
14
|
.replace(/:[^/]+/g, '([^/]+)') // Replace :param with regex group
|
|
@@ -2,8 +2,13 @@ import type { NavigateOptions } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
4
4
|
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
5
|
+
* App paths stay in the current URL's language (`/produits` → `/en/produits` on an
|
|
6
|
+
* English page); a path with an explicit language prefix keeps it.
|
|
7
|
+
*
|
|
8
|
+
* @version 0.3.0
|
|
9
|
+
* @since 0.0.1
|
|
5
10
|
*/
|
|
6
|
-
export declare function useNavigate(): (
|
|
11
|
+
export declare function useNavigate(): (path: string, options?: NavigateOptions) => void;
|
|
7
12
|
export declare function useBack(): () => void;
|
|
8
13
|
export declare function useRefresh(): () => void;
|
|
9
14
|
export declare function usePrefetch(): (to: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,KAKjB,MAAM,MAAM,EAAE,UAAU,eAAe,UAyBhD;AAED,wBAAgB,OAAO,eAGtB;AAED,wBAAgB,UAAU,eAGzB;AAED,wBAAgB,WAAW,KAGjB,IAAI,MAAM,UACnB"}
|
|
@@ -4,25 +4,33 @@
|
|
|
4
4
|
* @fileoverview Next.js-specific navigation hooks
|
|
5
5
|
* @description Navigation hooks for Next.js App Router
|
|
6
6
|
*
|
|
7
|
-
* @version 0.
|
|
7
|
+
* @version 0.3.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
12
|
import { isClient, useOverlayStore } from '@donotdev/core';
|
|
13
|
+
import { useLocalizedPath } from './useUrlLanguage.next';
|
|
13
14
|
/**
|
|
14
15
|
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
15
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
|
|
16
22
|
*/
|
|
17
23
|
export function useNavigate() {
|
|
18
24
|
const router = useNextRouter();
|
|
19
25
|
const closeAll = useOverlayStore((state) => state.closeAll);
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
const localize = useLocalizedPath();
|
|
27
|
+
return (path, options) => {
|
|
28
|
+
if (path === 'back') {
|
|
22
29
|
closeAll();
|
|
23
30
|
return router.back();
|
|
24
31
|
}
|
|
25
32
|
closeAll();
|
|
33
|
+
const to = localize(path);
|
|
26
34
|
if (options?.preserveScroll && isClient()) {
|
|
27
35
|
const scrollY = window.scrollY;
|
|
28
36
|
if (options?.replace) {
|
|
@@ -51,5 +59,6 @@ export function useRefresh() {
|
|
|
51
59
|
}
|
|
52
60
|
export function usePrefetch() {
|
|
53
61
|
const router = useNextRouter();
|
|
54
|
-
|
|
62
|
+
const localize = useLocalizedPath();
|
|
63
|
+
return (to) => router.prefetch(localize(to));
|
|
55
64
|
}
|
|
@@ -2,8 +2,14 @@ import type { NavigateOptions } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
4
4
|
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
5
|
+
* The router basename carries the language prefix (createAppRouter), so app paths
|
|
6
|
+
* stay in the current language. A path prefixed with another language opens that
|
|
7
|
+
* language's URL (document navigation: the router restarts under its prefix).
|
|
8
|
+
*
|
|
9
|
+
* @version 0.3.0
|
|
10
|
+
* @since 0.0.1
|
|
5
11
|
*/
|
|
6
|
-
export declare function useNavigate(): (
|
|
12
|
+
export declare function useNavigate(): (path: string, options?: NavigateOptions) => void | Promise<void>;
|
|
7
13
|
export declare function useBack(): () => void | Promise<void>;
|
|
8
14
|
export declare function useRefresh(): () => void;
|
|
9
15
|
export declare function usePrefetch(): (_to: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;;;;;;;;GASG;AACH,wBAAgB,WAAW,KAKjB,MAAM,MAAM,EAAE,UAAU,eAAe,0BAoBhD;AAED,wBAAgB,OAAO,+BAGtB;AAED,wBAAgB,UAAU,eAIzB;AAED,wBAAgB,WAAW,KACjB,KAAK,MAAM,UAGpB"}
|
|
@@ -4,25 +4,41 @@
|
|
|
4
4
|
* @fileoverview Vite-specific navigation hooks
|
|
5
5
|
* @description Navigation hooks for React Router (Vite)
|
|
6
6
|
*
|
|
7
|
-
* @version 0.
|
|
7
|
+
* @version 0.3.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
import { useNavigate as useRouterNavigate } from 'react-router-dom';
|
|
12
|
-
import { isClient, useOverlayStore } from '@donotdev/core';
|
|
12
|
+
import { getLanguageRouting, isClient, splitLanguagePath, useOverlayStore, } from '@donotdev/core';
|
|
13
|
+
import { useUrlLanguage } from './useUrlLanguage.vite';
|
|
13
14
|
/**
|
|
14
15
|
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
15
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
|
|
16
23
|
*/
|
|
17
24
|
export function useNavigate() {
|
|
18
25
|
const routerNavigate = useRouterNavigate();
|
|
19
26
|
const closeAll = useOverlayStore((state) => state.closeAll);
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const language = useUrlLanguage();
|
|
28
|
+
return (path, options) => {
|
|
29
|
+
if (path === 'back') {
|
|
22
30
|
closeAll();
|
|
23
31
|
return routerNavigate(-1);
|
|
24
32
|
}
|
|
25
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;
|
|
26
42
|
if (options?.replace)
|
|
27
43
|
return routerNavigate(to, { replace: true });
|
|
28
44
|
return routerNavigate(to);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;
|
|
1
|
+
{"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IAEnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAwGrB"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { useMemo } from 'react';
|
|
12
12
|
import { isClient, FEATURE_STATUS } from '@donotdev/core';
|
|
13
|
-
import { useAuthConfig } from '@donotdev/core';
|
|
13
|
+
import { useAppConfig, useAuthConfig } from '@donotdev/core';
|
|
14
14
|
import { useLocation } from './useLocation.next';
|
|
15
15
|
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
16
16
|
/**
|
|
@@ -27,6 +27,7 @@ export function useRedirectGuard(options = {}) {
|
|
|
27
27
|
// Hooks must be called unconditionally (Rules of Hooks)
|
|
28
28
|
const location = useLocation();
|
|
29
29
|
const authConfig = useAuthConfig();
|
|
30
|
+
const authDisabled = useAppConfig().auth === false;
|
|
30
31
|
const user = useAuthSafe('user');
|
|
31
32
|
const can = useAuthSafe('can');
|
|
32
33
|
const status = useAuthSafe('status');
|
|
@@ -59,6 +60,10 @@ export function useRedirectGuard(options = {}) {
|
|
|
59
60
|
return noAction;
|
|
60
61
|
// Check if user can navigate to this route
|
|
61
62
|
if (!can.navigate(auth)) {
|
|
63
|
+
// Redirect targets come from AppConfig.auth: none exist when auth is disabled
|
|
64
|
+
if (authDisabled && !customRedirectTo) {
|
|
65
|
+
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.");
|
|
66
|
+
}
|
|
62
67
|
let targetRoute = null;
|
|
63
68
|
// Authentication failure (not logged in) → always redirect
|
|
64
69
|
if (typeof auth === 'object' && auth.required && !user) {
|
|
@@ -103,6 +108,7 @@ export function useRedirectGuard(options = {}) {
|
|
|
103
108
|
condition,
|
|
104
109
|
customRedirectTo,
|
|
105
110
|
location.search,
|
|
111
|
+
authDisabled,
|
|
106
112
|
authConfig.authRoute,
|
|
107
113
|
authConfig.roleRoute,
|
|
108
114
|
authConfig.tierRoute,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectGuard.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.vite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;
|
|
1
|
+
{"version":3,"file":"useRedirectGuard.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.vite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IAEnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAwGrB"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { useMemo } from 'react';
|
|
12
12
|
import { isClient, FEATURE_STATUS } from '@donotdev/core';
|
|
13
|
-
import { useAuthConfig } from '@donotdev/core';
|
|
13
|
+
import { useAppConfig, useAuthConfig } from '@donotdev/core';
|
|
14
14
|
import { useLocation } from './useLocation.vite';
|
|
15
15
|
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
16
16
|
/**
|
|
@@ -27,6 +27,7 @@ export function useRedirectGuard(options = {}) {
|
|
|
27
27
|
// Hooks must be called unconditionally (Rules of Hooks)
|
|
28
28
|
const location = useLocation();
|
|
29
29
|
const authConfig = useAuthConfig();
|
|
30
|
+
const authDisabled = useAppConfig().auth === false;
|
|
30
31
|
const user = useAuthSafe('user');
|
|
31
32
|
const can = useAuthSafe('can');
|
|
32
33
|
const status = useAuthSafe('status');
|
|
@@ -59,6 +60,10 @@ export function useRedirectGuard(options = {}) {
|
|
|
59
60
|
return noAction;
|
|
60
61
|
// Check if user can navigate to this route
|
|
61
62
|
if (!can.navigate(auth)) {
|
|
63
|
+
// Redirect targets come from AppConfig.auth: none exist when auth is disabled
|
|
64
|
+
if (authDisabled && !customRedirectTo) {
|
|
65
|
+
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.");
|
|
66
|
+
}
|
|
62
67
|
let targetRoute = null;
|
|
63
68
|
// Authentication failure (not logged in) → always redirect
|
|
64
69
|
if (typeof auth === 'object' && auth.required && !user) {
|
|
@@ -103,6 +108,7 @@ export function useRedirectGuard(options = {}) {
|
|
|
103
108
|
condition,
|
|
104
109
|
customRedirectTo,
|
|
105
110
|
location.search,
|
|
111
|
+
authDisabled,
|
|
106
112
|
authConfig.authRoute,
|
|
107
113
|
authConfig.roleRoute,
|
|
108
114
|
authConfig.tierRoute,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route path of the current URL: the pathname without its language prefix
|
|
3
|
+
* (`/en/produits` → `/produits`). Reads the pathname only: safe in cached (static)
|
|
4
|
+
* renders, where reading the query string (`useLocation().search`,
|
|
5
|
+
* `useSearchParams`) moves the render to the browser up to the nearest Suspense
|
|
6
|
+
* boundary. Use it whenever the query string is not needed. The server render of a
|
|
7
|
+
* per-request page reads its internal pathname (`/<lang>/dndev-session/…`): dropped here, so
|
|
8
|
+
* the server and the browser see the same path.
|
|
9
|
+
*
|
|
10
|
+
* @returns Route path, always starting with `/`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const path = useRoutePath();
|
|
15
|
+
* const active = path === '/produits';
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @version 0.1.0
|
|
19
|
+
* @since 0.2.3
|
|
20
|
+
* @author AMBROISE PARK Consulting
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRoutePath(): string;
|
|
23
|
+
//# sourceMappingURL=useRoutePath.next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRoutePath.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRoutePath.next.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAKrC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// packages/ui/src/routing/hooks/useRoutePath.next.ts
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Next.js route path of the current URL
|
|
5
|
+
* @description The pathname without its language prefix, read without the query string.
|
|
6
|
+
*
|
|
7
|
+
* @version 0.1.0
|
|
8
|
+
* @since 0.2.3
|
|
9
|
+
* @author AMBROISE PARK Consulting
|
|
10
|
+
*/
|
|
11
|
+
import { usePathname } from 'next/navigation';
|
|
12
|
+
import { getLanguageRouting, publicPathname, splitLanguagePath, } from '@donotdev/core';
|
|
13
|
+
/**
|
|
14
|
+
* Route path of the current URL: the pathname without its language prefix
|
|
15
|
+
* (`/en/produits` → `/produits`). Reads the pathname only: safe in cached (static)
|
|
16
|
+
* renders, where reading the query string (`useLocation().search`,
|
|
17
|
+
* `useSearchParams`) moves the render to the browser up to the nearest Suspense
|
|
18
|
+
* boundary. Use it whenever the query string is not needed. The server render of a
|
|
19
|
+
* per-request page reads its internal pathname (`/<lang>/dndev-session/…`): dropped here, so
|
|
20
|
+
* the server and the browser see the same path.
|
|
21
|
+
*
|
|
22
|
+
* @returns Route path, always starting with `/`
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const path = useRoutePath();
|
|
27
|
+
* const active = path === '/produits';
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @version 0.1.0
|
|
31
|
+
* @since 0.2.3
|
|
32
|
+
* @author AMBROISE PARK Consulting
|
|
33
|
+
*/
|
|
34
|
+
export function useRoutePath() {
|
|
35
|
+
return splitLanguagePath(publicPathname(usePathname() ?? '/'), getLanguageRouting()).path;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route path of the current URL: the pathname without its language prefix
|
|
3
|
+
* (`/en/produits` → `/produits`). Same as `useLocation().pathname`; on Next it is the
|
|
4
|
+
* one that stays safe in cached (static) renders.
|
|
5
|
+
*
|
|
6
|
+
* @returns Route path, always starting with `/`
|
|
7
|
+
*
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
* @since 0.2.3
|
|
10
|
+
* @author AMBROISE PARK Consulting
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRoutePath(): string;
|
|
13
|
+
//# sourceMappingURL=useRoutePath.vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRoutePath.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRoutePath.vite.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// packages/ui/src/routing/hooks/useRoutePath.vite.ts
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Vite route path of the current URL
|
|
5
|
+
* @description The router pathname (React Router strips the language basename).
|
|
6
|
+
*
|
|
7
|
+
* @version 0.1.0
|
|
8
|
+
* @since 0.2.3
|
|
9
|
+
* @author AMBROISE PARK Consulting
|
|
10
|
+
*/
|
|
11
|
+
import { useLocation as useRouterLocation } from 'react-router-dom';
|
|
12
|
+
/**
|
|
13
|
+
* Route path of the current URL: the pathname without its language prefix
|
|
14
|
+
* (`/en/produits` → `/produits`). Same as `useLocation().pathname`; on Next it is the
|
|
15
|
+
* one that stays safe in cached (static) renders.
|
|
16
|
+
*
|
|
17
|
+
* @returns Route path, always starting with `/`
|
|
18
|
+
*
|
|
19
|
+
* @version 0.1.0
|
|
20
|
+
* @since 0.2.3
|
|
21
|
+
* @author AMBROISE PARK Consulting
|
|
22
|
+
*/
|
|
23
|
+
export function useRoutePath() {
|
|
24
|
+
return useRouterLocation().pathname;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language of the current URL: its prefix, else the default language.
|
|
3
|
+
*
|
|
4
|
+
* @returns Language code (`/en/produits` → `en`)
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.2.3
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
export declare function useUrlLanguage(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Localize app paths in the current URL's language, for `href`s built outside `<Link>`.
|
|
13
|
+
* `<Link path>` and `navigate()` already do it.
|
|
14
|
+
*
|
|
15
|
+
* @returns `(path) => url`: `/produits` → `/en/produits` on an English page
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const localize = useLocalizedPath();
|
|
20
|
+
* <a href={localize('/produits')}>…</a>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @version 0.1.0
|
|
24
|
+
* @since 0.2.3
|
|
25
|
+
* @author AMBROISE PARK Consulting
|
|
26
|
+
*/
|
|
27
|
+
export declare function useLocalizedPath(): (path: string) => string;
|
|
28
|
+
//# sourceMappingURL=useUrlLanguage.next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUrlLanguage.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useUrlLanguage.next.ts"],"names":[],"mappings":"AA0BA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAKvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAI3D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// packages/ui/src/routing/hooks/useUrlLanguage.next.ts
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Next.js language of the URL
|
|
5
|
+
* @description The language of the current URL and the localized form of app paths
|
|
6
|
+
* (default language at the root, others under `/<lang>`; see languagePath in
|
|
7
|
+
* @donotdev/core). On the server a rewritten default-language page reads
|
|
8
|
+
* `/<default>/…` and the browser reads `/…` (a per-request page: `/<lang>/dndev-session/…`,
|
|
9
|
+
* dropped by publicPathname): both give the same language and paths, so the server
|
|
10
|
+
* HTML and the hydration pass agree.
|
|
11
|
+
*
|
|
12
|
+
* @version 0.1.0
|
|
13
|
+
* @since 0.2.3
|
|
14
|
+
* @author AMBROISE PARK Consulting
|
|
15
|
+
*/
|
|
16
|
+
import { usePathname } from 'next/navigation';
|
|
17
|
+
import { getLanguageRouting, localizePath, publicPathname, splitLanguagePath, } from '@donotdev/core';
|
|
18
|
+
/**
|
|
19
|
+
* Language of the current URL: its prefix, else the default language.
|
|
20
|
+
*
|
|
21
|
+
* @returns Language code (`/en/produits` → `en`)
|
|
22
|
+
*
|
|
23
|
+
* @version 0.1.0
|
|
24
|
+
* @since 0.2.3
|
|
25
|
+
* @author AMBROISE PARK Consulting
|
|
26
|
+
*/
|
|
27
|
+
export function useUrlLanguage() {
|
|
28
|
+
return splitLanguagePath(publicPathname(usePathname() ?? '/'), getLanguageRouting()).language;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Localize app paths in the current URL's language, for `href`s built outside `<Link>`.
|
|
32
|
+
* `<Link path>` and `navigate()` already do it.
|
|
33
|
+
*
|
|
34
|
+
* @returns `(path) => url`: `/produits` → `/en/produits` on an English page
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const localize = useLocalizedPath();
|
|
39
|
+
* <a href={localize('/produits')}>…</a>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @version 0.1.0
|
|
43
|
+
* @since 0.2.3
|
|
44
|
+
* @author AMBROISE PARK Consulting
|
|
45
|
+
*/
|
|
46
|
+
export function useLocalizedPath() {
|
|
47
|
+
const language = useUrlLanguage();
|
|
48
|
+
const routing = getLanguageRouting();
|
|
49
|
+
return (path) => localizePath(path, language, routing);
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language of the current URL: the router basename's language, else the default.
|
|
3
|
+
*
|
|
4
|
+
* @returns Language code
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.2.3
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
export declare function useUrlLanguage(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Localize app paths in the current URL's language, for `href`s built outside `<Link>`.
|
|
13
|
+
* `<Link path>` and `navigate()` already do it.
|
|
14
|
+
*
|
|
15
|
+
* @returns `(path) => url`: `/produits` → `/en/produits` on an English page
|
|
16
|
+
*
|
|
17
|
+
* @version 0.1.0
|
|
18
|
+
* @since 0.2.3
|
|
19
|
+
* @author AMBROISE PARK Consulting
|
|
20
|
+
*/
|
|
21
|
+
export declare function useLocalizedPath(): (path: string) => string;
|
|
22
|
+
//# sourceMappingURL=useUrlLanguage.vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUrlLanguage.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useUrlLanguage.vite.ts"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAI3D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// packages/ui/src/routing/hooks/useUrlLanguage.vite.ts
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Vite language of the URL
|
|
5
|
+
* @description The router runs under the language prefix as its basename
|
|
6
|
+
* (createAppRouter), so route paths never carry it. This reads the language from that
|
|
7
|
+
* basename and localizes app paths for `href`s.
|
|
8
|
+
*
|
|
9
|
+
* @version 0.1.0
|
|
10
|
+
* @since 0.2.3
|
|
11
|
+
* @author AMBROISE PARK Consulting
|
|
12
|
+
*/
|
|
13
|
+
import { useHref } from 'react-router-dom';
|
|
14
|
+
import { getLanguageRouting, localizePath, splitLanguagePath, } from '@donotdev/core';
|
|
15
|
+
/**
|
|
16
|
+
* Language of the current URL: the router basename's language, else the default.
|
|
17
|
+
*
|
|
18
|
+
* @returns Language code
|
|
19
|
+
*
|
|
20
|
+
* @version 0.1.0
|
|
21
|
+
* @since 0.2.3
|
|
22
|
+
* @author AMBROISE PARK Consulting
|
|
23
|
+
*/
|
|
24
|
+
export function useUrlLanguage() {
|
|
25
|
+
return splitLanguagePath(useHref('/'), getLanguageRouting()).language;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Localize app paths in the current URL's language, for `href`s built outside `<Link>`.
|
|
29
|
+
* `<Link path>` and `navigate()` already do it.
|
|
30
|
+
*
|
|
31
|
+
* @returns `(path) => url`: `/produits` → `/en/produits` on an English page
|
|
32
|
+
*
|
|
33
|
+
* @version 0.1.0
|
|
34
|
+
* @since 0.2.3
|
|
35
|
+
* @author AMBROISE PARK Consulting
|
|
36
|
+
*/
|
|
37
|
+
export function useLocalizedPath() {
|
|
38
|
+
const language = useUrlLanguage();
|
|
39
|
+
const routing = getLanguageRouting();
|
|
40
|
+
return (path) => localizePath(path, language, routing);
|
|
41
|
+
}
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -11,12 +11,14 @@ export * from './Link';
|
|
|
11
11
|
export * from './AuthGuard';
|
|
12
12
|
export * from './AuthGuardFallback';
|
|
13
13
|
export { AuthReturnTo } from './AuthReturnTo';
|
|
14
|
+
export { SignedInRedirect } from './SignedInRedirect';
|
|
15
|
+
export type { SignedInRedirectProps } from './SignedInRedirect';
|
|
14
16
|
export * from './GoTo';
|
|
15
17
|
export { default as GoToWrapper } from './GoToWrapper';
|
|
16
18
|
export { default as GoToInput } from './GoToInput';
|
|
17
19
|
export * from './DnDevNavigationMenu';
|
|
18
20
|
export { default as NotFoundPage } from './404';
|
|
19
|
-
export { useNavigate, useBack, useRefresh, usePrefetch, useLocation, useParams, useRouteParam, useSearchParams, useMatch, useQueryParams, useRedirectGuard, } from '@donotdev/ui/routing/hooks';
|
|
21
|
+
export { useNavigate, useBack, useRefresh, usePrefetch, useLocation, useRoutePath, useParams, useRouteParam, useSearchParams, useMatch, useQueryParams, useRedirectGuard, useLocalizedPath, useUrlLanguage, } from '@donotdev/ui/routing/hooks';
|
|
20
22
|
export type { NavigateOptions, RedirectGuardOptions, RedirectGuardResult, } from '@donotdev/ui/routing/hooks';
|
|
21
23
|
export * from './useNavigation';
|
|
22
24
|
export * from './useGoTo';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAGH,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAOhD,OAAO,EACL,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,eAAe,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAGH,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAOhD,OAAO,EACL,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,eAAe,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
package/dist/routing/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './Link';
|
|
|
15
15
|
export * from './AuthGuard';
|
|
16
16
|
export * from './AuthGuardFallback';
|
|
17
17
|
export { AuthReturnTo } from './AuthReturnTo';
|
|
18
|
+
export { SignedInRedirect } from './SignedInRedirect';
|
|
18
19
|
export * from './GoTo';
|
|
19
20
|
export { default as GoToWrapper } from './GoToWrapper';
|
|
20
21
|
export { default as GoToInput } from './GoToInput';
|
|
@@ -26,6 +27,6 @@ export { default as NotFoundPage } from './404';
|
|
|
26
27
|
// - hooks.vite.ts when bundled with Vite (vite-app condition)
|
|
27
28
|
// - hooks.next.ts when bundled with Next.js (default condition)
|
|
28
29
|
// NOTE: Explicit named exports required - esbuild can't re-export with 'export *' from external
|
|
29
|
-
export { useNavigate, useBack, useRefresh, usePrefetch, useLocation, useParams, useRouteParam, useSearchParams, useMatch, useQueryParams, useRedirectGuard, } from '@donotdev/ui/routing/hooks';
|
|
30
|
+
export { useNavigate, useBack, useRefresh, usePrefetch, useLocation, useRoutePath, useParams, useRouteParam, useSearchParams, useMatch, useQueryParams, useRedirectGuard, useLocalizedPath, useUrlLanguage, } from '@donotdev/ui/routing/hooks';
|
|
30
31
|
export * from './useNavigation';
|
|
31
32
|
export * from './useGoTo';
|
|
@@ -11,7 +11,7 @@ import { useMemo } from 'react';
|
|
|
11
11
|
import { useNavigationStore, useTranslation } from '@donotdev/core';
|
|
12
12
|
import { USER_ROLES } from '@donotdev/core';
|
|
13
13
|
// Platform-specific hooks via conditional exports
|
|
14
|
-
import {
|
|
14
|
+
import { useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
15
15
|
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
16
16
|
/**
|
|
17
17
|
* Smart navigation hook with auth filtering
|
|
@@ -33,7 +33,7 @@ import { useAuthSafe } from '../utils/useAuthSafe';
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
export function useNavigationItems() {
|
|
36
|
-
const
|
|
36
|
+
const pathname = useRoutePath();
|
|
37
37
|
// Get auth state - hooks must be called at top level
|
|
38
38
|
const user = useAuthSafe('user');
|
|
39
39
|
const authenticated = !!user;
|
|
@@ -65,12 +65,12 @@ export function useNavigationItems() {
|
|
|
65
65
|
.map((route) => ({
|
|
66
66
|
...route,
|
|
67
67
|
label: routeLabel(route, t),
|
|
68
|
-
isActive: isRouteActive(route.path,
|
|
68
|
+
isActive: isRouteActive(route.path, pathname),
|
|
69
69
|
hasChildren: false,
|
|
70
70
|
children: undefined,
|
|
71
71
|
}))
|
|
72
72
|
.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })); // Alphabetical sorting by label
|
|
73
|
-
}, [filteredRoutes,
|
|
73
|
+
}, [filteredRoutes, pathname, t]);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Resolves a single navigation item from the store by path.
|