@donotdev/ui 0.0.13 → 0.0.15
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/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +19 -20
- package/dist/components/common/FeatureCard.d.ts +3 -1
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +2 -2
- package/dist/components/common/ProgressBar.js +2 -2
- package/dist/components/common/TechBento.d.ts +14 -2
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +8 -9
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +3 -4
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +3 -12
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -1
- package/dist/components/layout/components/Notifications.d.ts +1 -3
- package/dist/components/layout/components/Notifications.d.ts.map +1 -1
- package/dist/components/layout/components/Notifications.js +4 -2
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +2 -1
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +5 -2
- package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +3 -1
- package/dist/components/layout/components/header/HeaderNavigation.d.ts +6 -0
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +12 -2
- package/dist/components/layout/components/index.d.ts +3 -0
- package/dist/components/layout/components/index.d.ts.map +1 -1
- package/dist/components/layout/components/index.js +3 -0
- package/dist/components/license/LicenseWatermark.d.ts.map +1 -1
- package/dist/components/license/LicenseWatermark.js +3 -1
- package/dist/crud/components/CrudCardLink.d.ts +17 -0
- package/dist/crud/components/CrudCardLink.d.ts.map +1 -0
- package/dist/crud/components/CrudCardLink.js +17 -0
- package/dist/crud/components/EntityCardList.d.ts +1 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +38 -90
- package/dist/crud/components/EntityDisplayRenderer.d.ts +1 -1
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +11 -3
- package/dist/crud/components/EntityFormRenderer.d.ts +1 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +34 -40
- package/dist/crud/components/EntityList.d.ts +1 -1
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +1 -1
- package/dist/crud/components/EntityRecommendations.d.ts +29 -0
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -0
- package/dist/crud/components/EntityRecommendations.js +32 -0
- package/dist/crud/components/index.d.ts +2 -1
- package/dist/crud/components/index.d.ts.map +1 -1
- package/dist/crud/components/index.js +1 -0
- package/dist/dndev.css +1021 -196
- package/dist/index.js +4 -4
- package/dist/internal/common/RouteErrorFallback.d.ts.map +1 -1
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -1
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +3 -2
- package/dist/internal/devtools/components/LayoutReset.d.ts.map +1 -1
- package/dist/internal/devtools/components/LayoutReset.js +2 -0
- package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/StoresTab.js +3 -0
- package/dist/internal/devtools/utils/envVarDiscovery.d.ts +1 -0
- package/dist/internal/devtools/utils/envVarDiscovery.d.ts.map +1 -1
- package/dist/internal/devtools/utils/envVarDiscovery.js +5 -0
- package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.js +27 -21
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +30 -6
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +10 -8
- package/dist/internal/layout/components/FontPreloadLinks.d.ts +16 -0
- package/dist/internal/layout/components/FontPreloadLinks.d.ts.map +1 -0
- package/dist/internal/layout/components/FontPreloadLinks.js +32 -0
- package/dist/internal/layout/components/PerformanceHints.d.ts +7 -12
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +1 -1
- package/dist/internal/layout/components/PerformanceHints.js +8 -12
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +6 -5
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +6 -2
- package/dist/internal/layout/zones/DnDevFooter.d.ts +6 -0
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +10 -4
- package/dist/internal/layout/zones/DnDevHeader.d.ts +7 -0
- package/dist/internal/layout/zones/DnDevHeader.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevHeader.js +7 -0
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts +7 -0
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +9 -0
- package/dist/internal/layout/zones/DnDevSidebar.d.ts +4 -0
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +13 -1
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +3 -5
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +3 -5
- package/dist/routing/AuthGuard.d.ts +1 -1
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +3 -1
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +3 -1
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +2 -7
- package/dist/routing/GoToInput.d.ts +0 -3
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +8 -7
- package/dist/routing/Link.js +1 -1
- package/dist/routing/NavigationItem.d.ts +29 -7
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +22 -6
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +1 -7
- package/dist/routing/hooks/useNavigate.vite.d.ts +1 -1
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +1 -7
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +9 -8
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +9 -8
- package/dist/routing/hooks/useSearchParams.next.d.ts +18 -1
- package/dist/routing/hooks/useSearchParams.next.d.ts.map +1 -1
- package/dist/routing/hooks/useSearchParams.next.js +16 -0
- package/dist/routing/hooks/useSearchParams.vite.d.ts +16 -0
- package/dist/routing/hooks/useSearchParams.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useSearchParams.vite.js +17 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -0
- package/dist/routing/useNavigation.d.ts +30 -0
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +40 -3
- package/dist/routing/useRouteDiscovery.d.ts +6 -17
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +16 -9
- package/dist/styles/index.css +284 -88
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/sanitizeSvg.d.ts +13 -0
- package/dist/utils/sanitizeSvg.d.ts.map +1 -0
- package/dist/utils/sanitizeSvg.js +47 -0
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +0 -7
- package/dist/utils/useCrudSafe.d.ts +0 -2
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.d.ts +5 -16
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +6 -37
- package/dist/vite-routing/AppRoutes.d.ts +19 -8
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +0 -3
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +10 -15
- package/package.json +16 -12
- package/assets/fonts/fonts.css +0 -206
- package/dist/routing/Navigate.d.ts +0 -10
- package/dist/routing/Navigate.d.ts.map +0 -1
- package/dist/routing/Navigate.js +0 -10
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
// packages/ui/src/routing/hooks/useSearchParams.next.ts
|
|
3
3
|
import { useSearchParams as useNextSearchParams } from 'next/navigation';
|
|
4
|
+
/**
|
|
5
|
+
* Get current URL search parameters (read-only).
|
|
6
|
+
* Returns a ReadonlyURLSearchParams instance directly (NOT a tuple).
|
|
7
|
+
*
|
|
8
|
+
* To modify search params, use `useNavigate()` with a query string
|
|
9
|
+
* or `useQueryParams()` for a key-value API with defaults.
|
|
10
|
+
*
|
|
11
|
+
* @returns ReadonlyURLSearchParams instance with `.get()`, `.has()`, `.getAll()`, etc.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const searchParams = useSearchParams();
|
|
16
|
+
* const page = searchParams.get('page');
|
|
17
|
+
* const sort = searchParams.get('sort');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
4
20
|
export function useSearchParams() {
|
|
5
21
|
return useNextSearchParams();
|
|
6
22
|
}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current URL search parameters (read-only).
|
|
3
|
+
* Returns a URLSearchParams instance directly (NOT a tuple).
|
|
4
|
+
*
|
|
5
|
+
* To modify search params, use `useNavigate()` with a query string
|
|
6
|
+
* or `useQueryParams()` for a key-value API with defaults.
|
|
7
|
+
*
|
|
8
|
+
* @returns URLSearchParams instance with `.get()`, `.has()`, `.getAll()`, etc.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const searchParams = useSearchParams();
|
|
13
|
+
* const page = searchParams.get('page');
|
|
14
|
+
* const sort = searchParams.get('sort');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export declare function useSearchParams(): URLSearchParams;
|
|
2
18
|
//# sourceMappingURL=useSearchParams.vite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchParams.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useSearchParams.vite.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"useSearchParams.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useSearchParams.vite.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,eAAe,CAEjD"}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
// packages/ui/src/routing/hooks/useSearchParams.vite.ts
|
|
3
3
|
import { useSearchParams as useRouterSearchParams } from 'react-router-dom';
|
|
4
|
+
/**
|
|
5
|
+
* Get current URL search parameters (read-only).
|
|
6
|
+
* Returns a URLSearchParams instance directly (NOT a tuple).
|
|
7
|
+
*
|
|
8
|
+
* To modify search params, use `useNavigate()` with a query string
|
|
9
|
+
* or `useQueryParams()` for a key-value API with defaults.
|
|
10
|
+
*
|
|
11
|
+
* @returns URLSearchParams instance with `.get()`, `.has()`, `.getAll()`, etc.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const searchParams = useSearchParams();
|
|
16
|
+
* const page = searchParams.get('page');
|
|
17
|
+
* const sort = searchParams.get('sort');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
4
20
|
export function useSearchParams() {
|
|
5
|
-
return useRouterSearchParams()[0];
|
|
21
|
+
return useRouterSearchParams()[0];
|
|
6
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAGH,cAAc,QAAQ,CAAC;
|
|
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,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,GACjB,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
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
// Components - all platform-agnostic
|
|
12
12
|
export * from './Link';
|
|
13
|
+
// NavigationItemComponent intentionally NOT exported — internal building block.
|
|
14
|
+
// Public API: HeaderNavigation (path prop for single item), DnDevNavigationMenu (full menu).
|
|
13
15
|
export * from './AuthGuard';
|
|
14
16
|
export * from './AuthGuardFallback';
|
|
15
17
|
export * from './GoTo';
|
|
@@ -30,4 +30,34 @@ export interface NavigationItem extends NavigationRoute {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare function useNavigationItems(): NavigationItem[];
|
|
33
|
+
/**
|
|
34
|
+
* Resolves a single navigation item from the store by path.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` if the path is not registered or the user lacks access.
|
|
37
|
+
* Use this to compose a standalone Button-style nav link without reaching for
|
|
38
|
+
* a full NavigationMenu.
|
|
39
|
+
*
|
|
40
|
+
* @version 0.0.1
|
|
41
|
+
* @since 0.0.1
|
|
42
|
+
* @author AMBROISE PARK Consulting
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const route = useNavigationRoute('/pricing');
|
|
47
|
+
* if (!route) return null;
|
|
48
|
+
* return (
|
|
49
|
+
* <Button
|
|
50
|
+
* variant="ghost"
|
|
51
|
+
* display={DISPLAY.AUTO}
|
|
52
|
+
* icon={<Icon icon={route.icon} fallback={LinkIcon} />}
|
|
53
|
+
* render={({ children, ...props }) => (
|
|
54
|
+
* <Link path={route.path} {...props}>{children}</Link>
|
|
55
|
+
* )}
|
|
56
|
+
* >
|
|
57
|
+
* {route.label}
|
|
58
|
+
* </Button>
|
|
59
|
+
* );
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function useNavigationRoute(path: string): NavigationItem | undefined;
|
|
33
63
|
//# sourceMappingURL=useNavigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQtD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQtD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAgDrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG3E"}
|
|
@@ -42,7 +42,9 @@ export function useNavigationItems() {
|
|
|
42
42
|
const filteredRoutes = useNavigationStore((state) => {
|
|
43
43
|
// Guard against undefined state during initialization
|
|
44
44
|
if (!state || typeof state.getFilteredRoutes !== 'function') {
|
|
45
|
-
|
|
45
|
+
if (process.env.NODE_ENV === 'development') {
|
|
46
|
+
console.warn('[useNavigationItems] Navigation store not initialized, returning empty routes');
|
|
47
|
+
}
|
|
46
48
|
return [];
|
|
47
49
|
}
|
|
48
50
|
return state.getFilteredRoutes({
|
|
@@ -53,7 +55,9 @@ export function useNavigationItems() {
|
|
|
53
55
|
return useMemo(() => {
|
|
54
56
|
// Ensure filteredRoutes is always an array
|
|
55
57
|
if (!Array.isArray(filteredRoutes)) {
|
|
56
|
-
|
|
58
|
+
if (process.env.NODE_ENV === 'development') {
|
|
59
|
+
console.warn('[useNavigationItems] filteredRoutes is not an array:', filteredRoutes);
|
|
60
|
+
}
|
|
57
61
|
return [];
|
|
58
62
|
}
|
|
59
63
|
return filteredRoutes
|
|
@@ -63,9 +67,42 @@ export function useNavigationItems() {
|
|
|
63
67
|
hasChildren: false,
|
|
64
68
|
children: undefined,
|
|
65
69
|
}))
|
|
66
|
-
.sort((a, b) => a.label.localeCompare(b.label)); // Alphabetical sorting by label
|
|
70
|
+
.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })); // Alphabetical sorting by label
|
|
67
71
|
}, [filteredRoutes, location.pathname]);
|
|
68
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Resolves a single navigation item from the store by path.
|
|
75
|
+
*
|
|
76
|
+
* Returns `undefined` if the path is not registered or the user lacks access.
|
|
77
|
+
* Use this to compose a standalone Button-style nav link without reaching for
|
|
78
|
+
* a full NavigationMenu.
|
|
79
|
+
*
|
|
80
|
+
* @version 0.0.1
|
|
81
|
+
* @since 0.0.1
|
|
82
|
+
* @author AMBROISE PARK Consulting
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* const route = useNavigationRoute('/pricing');
|
|
87
|
+
* if (!route) return null;
|
|
88
|
+
* return (
|
|
89
|
+
* <Button
|
|
90
|
+
* variant="ghost"
|
|
91
|
+
* display={DISPLAY.AUTO}
|
|
92
|
+
* icon={<Icon icon={route.icon} fallback={LinkIcon} />}
|
|
93
|
+
* render={({ children, ...props }) => (
|
|
94
|
+
* <Link path={route.path} {...props}>{children}</Link>
|
|
95
|
+
* )}
|
|
96
|
+
* >
|
|
97
|
+
* {route.label}
|
|
98
|
+
* </Button>
|
|
99
|
+
* );
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export function useNavigationRoute(path) {
|
|
103
|
+
const items = useNavigationItems();
|
|
104
|
+
return useMemo(() => items.find((item) => item.path === path), [items, path]);
|
|
105
|
+
}
|
|
69
106
|
// ===== HELPER FUNCTIONS =====
|
|
70
107
|
/**
|
|
71
108
|
* Determines if a route path is currently active
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NavigationRoute as CoreNavigationRoute } from '@donotdev/core';
|
|
1
2
|
import type { JSX } from 'react';
|
|
2
3
|
import type { ReactNode } from 'react';
|
|
3
4
|
/**
|
|
@@ -21,9 +22,9 @@ export interface RouteInfo {
|
|
|
21
22
|
/** Export name for named exports (e.g., 'HomePage', 'AboutPage') */
|
|
22
23
|
exportName?: string;
|
|
23
24
|
/** Authentication configuration for the route */
|
|
24
|
-
auth?:
|
|
25
|
+
auth?: boolean | Record<string, unknown>;
|
|
25
26
|
/** Additional route metadata */
|
|
26
|
-
meta?:
|
|
27
|
+
meta?: unknown;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Group of related routes organized by entity/domain
|
|
@@ -41,22 +42,10 @@ export interface RouteGroup {
|
|
|
41
42
|
routes: RouteInfo[];
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
|
-
* Navigation route
|
|
45
|
-
*
|
|
46
|
-
* @version 0.0.1
|
|
47
|
-
* @since 0.0.1
|
|
48
|
-
* @author AMBROISE PARK Consulting
|
|
45
|
+
* Navigation route - re-exported from @donotdev/core (Item 90)
|
|
46
|
+
* Core's version is the single source of truth with richer fields.
|
|
49
47
|
*/
|
|
50
|
-
export
|
|
51
|
-
/** Route path */
|
|
52
|
-
path: string;
|
|
53
|
-
/** Display label */
|
|
54
|
-
label: string;
|
|
55
|
-
/** Optional icon component */
|
|
56
|
-
icon?: ReactNode;
|
|
57
|
-
/** Additional route metadata */
|
|
58
|
-
meta?: any;
|
|
59
|
-
}
|
|
48
|
+
export type NavigationRoute = CoreNavigationRoute;
|
|
60
49
|
/**
|
|
61
50
|
* Hook that provides auto-discovered routes from virtual module system
|
|
62
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouteDiscovery.d.ts","sourceRoot":"","sources":["../../src/routing/useRouteDiscovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRouteDiscovery.d.ts","sourceRoot":"","sources":["../../src/routing/useRouteDiscovery.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAsB,eAAe,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIjG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,qCAAqC;IACrC,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,EAAE,CA2BhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,IAAI,UAAU,EAAE,CAoBlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,6BAA6B,IAAI,eAAe,EAAE,CAcjE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,gBAK3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;;;;;;SAQ/B"}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
import { useMemo } from 'react';
|
|
26
|
-
import { useNavigationStore, getRoutes, getRouteManifest,
|
|
26
|
+
import { useNavigationStore, getRoutes, getRouteManifest, } from '@donotdev/core';
|
|
27
27
|
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
28
28
|
/**
|
|
29
29
|
* Hook that provides auto-discovered routes from virtual module system
|
|
@@ -56,15 +56,19 @@ export function useRouteDiscovery() {
|
|
|
56
56
|
try {
|
|
57
57
|
const routeData = getRoutes();
|
|
58
58
|
if (!routeData || routeData.length === 0) {
|
|
59
|
-
|
|
59
|
+
if (process.env.NODE_ENV === 'development') {
|
|
60
|
+
console.warn('[useRouteDiscovery] No routes found - ensure you have *Page.tsx files in src/');
|
|
61
|
+
}
|
|
60
62
|
return [];
|
|
61
63
|
}
|
|
62
64
|
const groupedRoutes = groupRoutes(routeData);
|
|
63
65
|
return groupedRoutes;
|
|
64
66
|
}
|
|
65
67
|
catch (error) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (process.env.NODE_ENV === 'development') {
|
|
69
|
+
console.error('[useRouteDiscovery] Error discovering routes:', error);
|
|
70
|
+
console.warn('[useRouteDiscovery] No routes found - ensure you have *Page.tsx files in src/');
|
|
71
|
+
}
|
|
68
72
|
return [];
|
|
69
73
|
}
|
|
70
74
|
}, []);
|
|
@@ -104,9 +108,11 @@ export function useAccessibleRoutes() {
|
|
|
104
108
|
.map((group) => ({
|
|
105
109
|
...group,
|
|
106
110
|
routes: group.routes.filter((route) => {
|
|
107
|
-
// Use same filtering logic as AuthGuard for consistency
|
|
111
|
+
// Use same filtering logic as AuthGuard for consistency (Item 88)
|
|
108
112
|
if (route.auth === false)
|
|
109
113
|
return true;
|
|
114
|
+
if (route.auth === true)
|
|
115
|
+
return !!user;
|
|
110
116
|
if (typeof route.auth === 'object' && route.auth.required) {
|
|
111
117
|
return !!user;
|
|
112
118
|
}
|
|
@@ -145,9 +151,8 @@ export function useAccessibleRoutes() {
|
|
|
145
151
|
*/
|
|
146
152
|
export function useAccessibleNavigationRoutes() {
|
|
147
153
|
const user = useAuthSafe('user');
|
|
148
|
-
const { getFilteredRoutes } = useNavigationStore();
|
|
149
154
|
return useMemo(() => {
|
|
150
|
-
const filteredRoutes = getFilteredRoutes({
|
|
155
|
+
const filteredRoutes = useNavigationStore.getState().getFilteredRoutes({
|
|
151
156
|
authenticated: !!user,
|
|
152
157
|
role: user?.role || 'user',
|
|
153
158
|
});
|
|
@@ -157,7 +162,7 @@ export function useAccessibleNavigationRoutes() {
|
|
|
157
162
|
icon: route.icon,
|
|
158
163
|
meta: route.meta,
|
|
159
164
|
}));
|
|
160
|
-
}, [
|
|
165
|
+
}, [user]);
|
|
161
166
|
}
|
|
162
167
|
/**
|
|
163
168
|
* Hook that returns all discovered routes as a flat list
|
|
@@ -246,7 +251,9 @@ function groupRoutes(routes) {
|
|
|
246
251
|
const pathString = typeof route.path === 'string' ? route.path : String(route.path);
|
|
247
252
|
// Skip invalid routes
|
|
248
253
|
if (!pathString || pathString === 'undefined' || pathString === 'null') {
|
|
249
|
-
|
|
254
|
+
if (process.env.NODE_ENV === 'development') {
|
|
255
|
+
console.warn('[groupRoutes] Skipping invalid route:', route);
|
|
256
|
+
}
|
|
250
257
|
return;
|
|
251
258
|
}
|
|
252
259
|
// Extract entity with fallback to path-based detection
|