@donotdev/ui 0.0.12 → 0.0.14
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 +3 -3
- package/dist/components/common/ProgressBar.js +2 -2
- package/dist/components/common/RedirectOverlay.js +1 -1
- 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 +6 -7
- package/dist/components/layout/GameContainer.d.ts +24 -8
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +21 -3
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +27 -11
- 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 +4 -2
- 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/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.map +1 -1
- package/dist/crud/components/EntityCardList.js +32 -81
- 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 +8 -4
- 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 +29 -18
- 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 +8 -10
- package/dist/crud/components/EntityRecommendations.d.ts +28 -0
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -0
- package/dist/crud/components/EntityRecommendations.js +31 -0
- package/dist/crud/components/Form.js +1 -1
- 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/index.js +4 -4
- package/dist/internal/common/RouteErrorFallback.d.ts.map +1 -1
- package/dist/internal/common/RouteErrorFallback.js +3 -3
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -1
- package/dist/internal/devtools/components/ConfigTab.js +1 -1
- package/dist/internal/devtools/components/CookieTab.js +1 -1
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +5 -4
- 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 +5 -2
- 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 +10 -1
- 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/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/dist/routing/404.js +3 -3
- 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/AuthGuardFallback.js +2 -2
- 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 +4 -2
- 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/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 +2 -2
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +10 -4
- package/dist/styles/index.css +366 -120
- 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 +3 -1
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +4 -5
- 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/package.json +15 -11
- package/assets/fonts/fonts.css +0 -206
- package/dist/dndev.css +0 -10673
- package/dist/routing/Navigate.d.ts +0 -10
- package/dist/routing/Navigate.d.ts.map +0 -1
- package/dist/routing/Navigate.js +0 -10
|
@@ -24,14 +24,7 @@ import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
|
24
24
|
*/
|
|
25
25
|
export function useRedirectGuard(options = {}) {
|
|
26
26
|
const { auth, redirectTo: customRedirectTo, condition } = options;
|
|
27
|
-
//
|
|
28
|
-
if (!isClient()) {
|
|
29
|
-
return {
|
|
30
|
-
shouldRedirect: false,
|
|
31
|
-
redirectTo: null,
|
|
32
|
-
isChecking: false,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
27
|
+
// Hooks must be called unconditionally (Rules of Hooks)
|
|
35
28
|
const location = useLocation();
|
|
36
29
|
const authConfig = useAuthConfig();
|
|
37
30
|
const user = useAuthSafe('user');
|
|
@@ -39,6 +32,14 @@ export function useRedirectGuard(options = {}) {
|
|
|
39
32
|
const status = useAuthSafe('status');
|
|
40
33
|
// Determine redirect state
|
|
41
34
|
const redirectState = useMemo(() => {
|
|
35
|
+
// SSR-safe: return safe defaults on server
|
|
36
|
+
if (!isClient()) {
|
|
37
|
+
return {
|
|
38
|
+
shouldRedirect: false,
|
|
39
|
+
redirectTo: null,
|
|
40
|
+
isChecking: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
42
43
|
// Only INITIALIZING = still checking. DEGRADED/ERROR/READY = auth resolved (proceed with current user)
|
|
43
44
|
if (status === FEATURE_STATUS.INITIALIZING) {
|
|
44
45
|
return {
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { useSearchParams as useNextSearchParams } from 'next/navigation';
|
|
2
|
+
/**
|
|
3
|
+
* Get current URL search parameters (read-only).
|
|
4
|
+
* Returns a ReadonlyURLSearchParams instance directly (NOT a tuple).
|
|
5
|
+
*
|
|
6
|
+
* To modify search params, use `useNavigate()` with a query string
|
|
7
|
+
* or `useQueryParams()` for a key-value API with defaults.
|
|
8
|
+
*
|
|
9
|
+
* @returns ReadonlyURLSearchParams instance with `.get()`, `.has()`, `.getAll()`, etc.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const searchParams = useSearchParams();
|
|
14
|
+
* const page = searchParams.get('page');
|
|
15
|
+
* const sort = searchParams.get('sort');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useSearchParams(): ReturnType<typeof useNextSearchParams>;
|
|
2
19
|
//# sourceMappingURL=useSearchParams.next.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchParams.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useSearchParams.next.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSearchParams.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useSearchParams.next.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAExE"}
|
|
@@ -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
|
|
@@ -21,9 +21,9 @@ export interface RouteInfo {
|
|
|
21
21
|
/** Export name for named exports (e.g., 'HomePage', 'AboutPage') */
|
|
22
22
|
exportName?: string;
|
|
23
23
|
/** Authentication configuration for the route */
|
|
24
|
-
auth?:
|
|
24
|
+
auth?: boolean | Record<string, unknown>;
|
|
25
25
|
/** Additional route metadata */
|
|
26
|
-
meta?:
|
|
26
|
+
meta?: unknown;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Group of related routes organized by entity/domain
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouteDiscovery.d.ts","sourceRoot":"","sources":["../../src/routing/useRouteDiscovery.ts"],"names":[],"mappings":"AAsCA,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,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"useRouteDiscovery.d.ts","sourceRoot":"","sources":["../../src/routing/useRouteDiscovery.ts"],"names":[],"mappings":"AAsCA,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;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,gCAAgC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,EAAE,CA2BhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,IAAI,UAAU,EAAE,CAmBlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,6BAA6B,IAAI,eAAe,EAAE,CAgBjE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,gBAK3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;;;;;;SAQ/B"}
|
|
@@ -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
|
}, []);
|
|
@@ -246,7 +250,9 @@ function groupRoutes(routes) {
|
|
|
246
250
|
const pathString = typeof route.path === 'string' ? route.path : String(route.path);
|
|
247
251
|
// Skip invalid routes
|
|
248
252
|
if (!pathString || pathString === 'undefined' || pathString === 'null') {
|
|
249
|
-
|
|
253
|
+
if (process.env.NODE_ENV === 'development') {
|
|
254
|
+
console.warn('[groupRoutes] Skipping invalid route:', route);
|
|
255
|
+
}
|
|
250
256
|
return;
|
|
251
257
|
}
|
|
252
258
|
// Extract entity with fallback to path-based detection
|