@donotdev/ui 0.3.1 → 0.3.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/README.md +2 -3
- package/dist/components/auth/AuthHeader.js +1 -93
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +3 -286
- package/dist/components/auth/index.js +1 -9
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -86
- package/dist/components/common/FeatureDisabled.js +1 -67
- package/dist/components/common/IconPlaceholder.d.ts +24 -0
- package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
- package/dist/components/common/IconPlaceholder.js +1 -0
- package/dist/components/common/LazyLucideIcon.d.ts +39 -0
- package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
- package/dist/components/common/LazyLucideIcon.js +1 -0
- package/dist/components/common/ProgressBar.js +1 -84
- package/dist/components/common/RedirectOverlay.js +1 -243
- package/dist/components/common/Skeleton.js +1 -144
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +1 -53
- package/dist/components/common/icon.d.ts +1 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +1 -84
- package/dist/components/common/iconByName.d.ts +33 -0
- package/dist/components/common/iconByName.d.ts.map +1 -0
- package/dist/components/common/iconByName.js +1 -0
- package/dist/components/common/index.js +1 -16
- package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +1 -31
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +1 -183
- package/dist/components/cookie-consent/index.js +1 -11
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
- package/dist/components/index.js +1 -13
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +1 -72
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +1 -93
- package/dist/components/layout/PageConfig.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.js +1 -47
- package/dist/components/layout/PageContainer.d.ts.map +1 -1
- package/dist/components/layout/PageContainer.js +1 -38
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +1 -89
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +1 -30
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
- package/dist/components/layout/components/Notifications.js +1 -182
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +1 -54
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +1 -59
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +1 -40
- package/dist/components/layout/components/header/CacheSettings.js +1 -225
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +1 -66
- package/dist/components/layout/components/header/HeaderMenu.js +1 -75
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +1 -85
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +1 -93
- package/dist/components/layout/components/index.js +1 -25
- package/dist/components/layout/index.js +1 -14
- package/dist/crud/components/ChildRowsPicker.js +1 -68
- package/dist/crud/components/CrudCardLink.js +1 -14
- package/dist/crud/components/EntityCardList.d.ts +4 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +1 -184
- package/dist/crud/components/EntityDisplayRenderer.js +1 -130
- package/dist/crud/components/EntityFormRenderer.js +1 -433
- package/dist/crud/components/EntityList.js +1 -521
- package/dist/crud/components/EntityRecommendations.js +1 -87
- package/dist/crud/components/EntityWorkflow.js +1 -55
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +1 -198
- package/dist/crud/components/cellEditFor.js +1 -74
- package/dist/crud/components/entityParent.js +1 -76
- package/dist/crud/components/index.js +1 -16
- package/dist/crud/components/useRecordBreadcrumb.d.ts +3 -1
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +1 -43
- package/dist/crud/crudImports.js +1 -51
- package/dist/crud/index.js +1 -11
- package/dist/data/techLogos.js +1 -99
- package/dist/dndev-next.css +113 -41
- package/dist/dndev.css +113 -41
- package/dist/index.js +1 -5
- package/dist/internal/common/DnDevErrorBoundary.js +1 -55
- package/dist/internal/common/ErrorFallback.js +3 -214
- package/dist/internal/common/GlobalErrorFallback.js +1 -45
- package/dist/internal/common/RouteErrorFallback.js +3 -140
- package/dist/internal/devtools/DebugTools.js +1 -131
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
- package/dist/internal/devtools/components/ConfigTab.js +1 -61
- package/dist/internal/devtools/components/CookieTab.js +1 -156
- package/dist/internal/devtools/components/DebugDialog.js +1 -48
- package/dist/internal/devtools/components/DesignTab.js +1 -469
- package/dist/internal/devtools/components/LayoutReset.js +1 -214
- package/dist/internal/devtools/components/MaskedValue.js +1 -39
- package/dist/internal/devtools/components/StoresTab.js +1 -90
- package/dist/internal/devtools/components/index.js +1 -16
- package/dist/internal/devtools/index.js +1 -13
- package/dist/internal/devtools/types.js +0 -2
- package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
- package/dist/internal/devtools/utils/index.js +1 -12
- package/dist/internal/devtools/utils/maskSensitive.js +1 -59
- package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
- package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
- package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
- package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
- package/dist/internal/initializers/index.js +1 -11
- package/dist/internal/layout/DnDevLayout.js +1 -321
- package/dist/internal/layout/components/AutoMetaTags.d.ts +5 -0
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -338
- package/dist/internal/layout/components/FaviconHead.d.ts +18 -14
- package/dist/internal/layout/components/FaviconHead.d.ts.map +1 -1
- package/dist/internal/layout/components/FaviconHead.js +1 -60
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
- package/dist/internal/layout/components/HeadTags.js +1 -20
- package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
- package/dist/internal/layout/components/headTagElement.d.ts +16 -0
- package/dist/internal/layout/components/headTagElement.d.ts.map +1 -0
- package/dist/internal/layout/components/headTagElement.js +1 -0
- package/dist/internal/layout/components/index.js +1 -13
- package/dist/internal/layout/components/prerenderedHead.d.ts +15 -0
- package/dist/internal/layout/components/prerenderedHead.d.ts.map +1 -0
- package/dist/internal/layout/components/prerenderedHead.js +1 -0
- package/dist/internal/layout/components/trailingSlash.d.ts +13 -0
- package/dist/internal/layout/components/trailingSlash.d.ts.map +1 -0
- package/dist/internal/layout/components/trailingSlash.js +1 -0
- package/dist/internal/layout/config/defaults.js +1 -47
- package/dist/internal/layout/config/index.js +1 -11
- package/dist/internal/layout/config/presets/admin.js +1 -35
- package/dist/internal/layout/config/presets/blog.js +1 -31
- package/dist/internal/layout/config/presets/docs.js +1 -51
- package/dist/internal/layout/config/presets/game.js +1 -53
- package/dist/internal/layout/config/presets/index.js +1 -24
- package/dist/internal/layout/config/presets/landing.js +1 -42
- package/dist/internal/layout/config/presets/moolti.js +1 -52
- package/dist/internal/layout/config/presets/plain.js +1 -25
- package/dist/internal/layout/renderers/index.js +0 -10
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -67
- package/dist/internal/layout/zones/DnDevHeader.js +1 -41
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
- package/dist/internal/layout/zones/index.js +1 -14
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -71
- package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
- package/dist/internal/providers/SentryInitializer.js +1 -36
- package/dist/internal/providers/UIProviders.js +1 -79
- package/dist/internal/providers/index.js +1 -12
- package/dist/next.js +1 -11
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -107
- package/dist/providers/ViteAppProviders.d.ts +11 -9
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -117
- package/dist/providers/index.js +1 -11
- package/dist/routing/404.js +1 -108
- package/dist/routing/AuthGuard.js +1 -178
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -67
- package/dist/routing/AuthReturnTo.js +1 -68
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +1 -138
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -38
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +1 -97
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +1 -49
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +1 -59
- package/dist/routing/Link.d.ts +10 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +1 -109
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +1 -44
- package/dist/routing/NotFoundDocument.d.ts +33 -0
- package/dist/routing/NotFoundDocument.d.ts.map +1 -0
- package/dist/routing/NotFoundDocument.js +1 -0
- package/dist/routing/SignedInRedirect.js +1 -47
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.js +1 -26
- package/dist/routing/hooks/types.js +0 -2
- package/dist/routing/hooks/useLocation.next.js +1 -35
- package/dist/routing/hooks/useLocation.vite.js +1 -13
- package/dist/routing/hooks/useMatch.next.js +1 -31
- package/dist/routing/hooks/useMatch.vite.js +1 -6
- package/dist/routing/hooks/useNavigate.next.js +1 -64
- package/dist/routing/hooks/useNavigate.vite.js +1 -61
- package/dist/routing/hooks/useParams.next.js +1 -9
- package/dist/routing/hooks/useParams.vite.js +1 -6
- package/dist/routing/hooks/useQueryParams.next.js +1 -66
- package/dist/routing/hooks/useQueryParams.vite.js +1 -66
- package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
- package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
- package/dist/routing/hooks/useRouteParam.next.js +1 -38
- package/dist/routing/hooks/useRouteParam.vite.js +1 -38
- package/dist/routing/hooks/useRoutePath.next.d.ts +5 -3
- package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRoutePath.next.js +1 -36
- package/dist/routing/hooks/useRoutePath.vite.js +1 -25
- package/dist/routing/hooks/useSearchParams.next.js +1 -22
- package/dist/routing/hooks/useSearchParams.vite.js +1 -22
- package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
- package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -32
- package/dist/routing/link/InternalLink.next.d.ts +23 -0
- package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.next.js +1 -0
- package/dist/routing/link/InternalLink.vite.d.ts +22 -0
- package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.vite.js +1 -0
- package/dist/routing/link/absolutePath.d.ts +17 -0
- package/dist/routing/link/absolutePath.d.ts.map +1 -0
- package/dist/routing/link/absolutePath.js +1 -0
- package/dist/routing/link/link.next.d.ts +12 -0
- package/dist/routing/link/link.next.d.ts.map +1 -0
- package/dist/routing/link/link.next.js +1 -0
- package/dist/routing/link/link.vite.d.ts +12 -0
- package/dist/routing/link/link.vite.d.ts.map +1 -0
- package/dist/routing/link/link.vite.js +1 -0
- package/dist/routing/link/types.d.ts +30 -0
- package/dist/routing/link/types.d.ts.map +1 -0
- package/dist/routing/link/types.js +0 -0
- package/dist/routing/parentRoute.js +1 -43
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +1 -59
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +1 -114
- package/dist/routing/useRouteDiscovery.d.ts +4 -0
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +1 -313
- package/dist/rsc.d.ts +28 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/index.css +113 -41
- package/dist/styles/index.js +1 -10
- package/dist/styles/layoutConstants.js +1 -134
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts +19 -19
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -23
- package/dist/utils/sanitizeSvg.js +1 -51
- package/dist/utils/tList.js +1 -42
- package/dist/utils/useAISafe.d.ts.map +1 -1
- package/dist/utils/useAISafe.js +1 -53
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +1 -78
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -63
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -57
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +1 -75
- package/dist/utils/useDeleteAccountSafe.js +1 -52
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -85
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useOAuthSafe.js +1 -38
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +1 -81
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +1 -235
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -205
- package/dist/vite-routing/index.js +1 -11
- package/dist/vite.js +1 -10
- package/guidelines/COMPONENTS.md +3 -3
- package/guidelines/PAGES.md +3 -0
- package/guidelines/ROUTING.md +16 -0
- package/guidelines/SEO.md +160 -142
- package/package.json +18 -8
- package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
- package/dist/ChildRowsPicker-ISP365ON.js +0 -1
- package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
- package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
- package/dist/CookieConsent-QOUAY6B4.js +0 -1
- package/dist/GoToDialog-KSBGOIWO.js +0 -1
- package/dist/GoToDialog-XBK5EZF4.js +0 -1
- package/dist/chunk-3CIZFGST.js +0 -1
- package/dist/chunk-LHMKU342.js +0 -1
- package/dist/chunk-MS7ZIW5Z.js +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-P2DHZWPY.js +0 -1
- package/dist/components/common/lucideIconByName.d.ts +0 -9
- package/dist/components/common/lucideIconByName.d.ts.map +0 -1
- package/dist/components/common/lucideIconByName.js +0 -32
- package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
- package/dist/internal/layout/components/PerformanceHints.js +0 -71
- package/dist/internal/layout/components/i18nSeoMeta.d.ts +0 -54
- package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +0 -1
- package/dist/internal/layout/components/i18nSeoMeta.js +0 -53
- package/dist/utils/useSeo.d.ts +0 -129
- package/dist/utils/useSeo.d.ts.map +0 -1
- package/dist/utils/useSeo.js +0 -151
|
@@ -1,114 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Navigation Hooks - Clean and Simple
|
|
4
|
-
* @description Only 2 hooks: dumb navigation + smart auth-filtered navigation
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { useMemo } from 'react';
|
|
11
|
-
import { filterNavigationRoutes, useNavigationStore, useTranslation, } from '@donotdev/core';
|
|
12
|
-
import { USER_ROLES } from '@donotdev/core';
|
|
13
|
-
// Platform-specific hooks via conditional exports
|
|
14
|
-
import { useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
15
|
-
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
16
|
-
/**
|
|
17
|
-
* Smart navigation hook with auth filtering
|
|
18
|
-
*
|
|
19
|
-
* Use this for UI menus, sidebars, and navigation components that should
|
|
20
|
-
* only show routes the user can access.
|
|
21
|
-
*
|
|
22
|
-
* @version 0.1.0
|
|
23
|
-
* @since 0.0.1
|
|
24
|
-
* @author AMBROISE PARK Consulting
|
|
25
|
-
* @returns Array of navigation items filtered by auth state
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* function SidebarMenu() {
|
|
30
|
-
* const menuItems = useNavigationItems();
|
|
31
|
-
* return <nav>{menuItems.map(item => <MenuItem key={item.path} item={item} />)}</nav>;
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function useNavigationItems() {
|
|
36
|
-
const pathname = useRoutePath();
|
|
37
|
-
// Get auth state - hooks must be called at top level
|
|
38
|
-
const user = useAuthSafe('user');
|
|
39
|
-
const authenticated = !!user;
|
|
40
|
-
const { t } = useTranslation();
|
|
41
|
-
const role = user?.role || USER_ROLES.GUEST;
|
|
42
|
-
// Select snapshot-owned data; store getters close over live state during hydration.
|
|
43
|
-
const allRoutes = useNavigationStore((state) => state.cache.allRoutes);
|
|
44
|
-
return useMemo(() => {
|
|
45
|
-
return filterNavigationRoutes(allRoutes, { authenticated, role })
|
|
46
|
-
.map((route) => ({
|
|
47
|
-
...route,
|
|
48
|
-
label: routeLabel(route, t),
|
|
49
|
-
isActive: isRouteActive(route.path, pathname),
|
|
50
|
-
hasChildren: false,
|
|
51
|
-
children: undefined,
|
|
52
|
-
}))
|
|
53
|
-
.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })); // Alphabetical sorting by label
|
|
54
|
-
}, [allRoutes, authenticated, role, pathname, t]);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Resolves a single navigation item from the store by path.
|
|
58
|
-
*
|
|
59
|
-
* Returns `undefined` if the path is not registered or the user lacks access.
|
|
60
|
-
* Use this to compose a standalone Button-style nav link without reaching for
|
|
61
|
-
* a full NavigationMenu.
|
|
62
|
-
*
|
|
63
|
-
* @version 0.1.0
|
|
64
|
-
* @since 0.0.1
|
|
65
|
-
* @author AMBROISE PARK Consulting
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* const route = useNavigationRoute('/pricing');
|
|
70
|
-
* if (!route) return null;
|
|
71
|
-
* return (
|
|
72
|
-
* <Button
|
|
73
|
-
* variant="ghost"
|
|
74
|
-
* display={DISPLAY.AUTO}
|
|
75
|
-
* icon={<Icon icon={route.icon} fallback={LinkIcon} />}
|
|
76
|
-
* render={({ children, ...props }) => (
|
|
77
|
-
* <Link path={route.path} {...props}>{children}</Link>
|
|
78
|
-
* )}
|
|
79
|
-
* >
|
|
80
|
-
* {route.label}
|
|
81
|
-
* </Button>
|
|
82
|
-
* );
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export function useNavigationRoute(path) {
|
|
86
|
-
const items = useNavigationItems();
|
|
87
|
-
return useMemo(() => items.find((item) => item.path === path), [items, path]);
|
|
88
|
-
}
|
|
89
|
-
// ===== HELPER FUNCTIONS =====
|
|
90
|
-
/**
|
|
91
|
-
* Navigation label of a route: the page's `<namespace>:title` (the PageMeta contract,
|
|
92
|
-
* same key as the page `<title>`), else the label discovery derived from the file name.
|
|
93
|
-
*/
|
|
94
|
-
function routeLabel(route, t) {
|
|
95
|
-
const namespace = route.meta?.namespace;
|
|
96
|
-
if (typeof namespace !== 'string' || namespace === '')
|
|
97
|
-
return route.label;
|
|
98
|
-
return t(`${namespace}:title`, { defaultValue: route.label });
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Determines if a route path is currently active
|
|
102
|
-
*/
|
|
103
|
-
function isRouteActive(routePath, currentPath) {
|
|
104
|
-
// Exact match for root path to prevent false positives
|
|
105
|
-
if (routePath === '/') {
|
|
106
|
-
return currentPath === '/';
|
|
107
|
-
}
|
|
108
|
-
// Exact match first
|
|
109
|
-
if (currentPath === routePath) {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
// Prefix match for nested routes, but ensure it's followed by a separator
|
|
113
|
-
return currentPath.startsWith(routePath + '/');
|
|
114
|
-
}
|
|
1
|
+
"use client";import{useMemo as s}from"react";import{filterNavigationRoutes as u,useNavigationStore as c,useTranslation as m}from"@donotdev/core";import{USER_ROLES as f}from"@donotdev/core";import{useRoutePath as g}from"@donotdev/ui/routing/hooks";import{useAuthSafe as p}from"../utils/useAuthSafe.js";function d(){let e=g(),t=p("user"),n=!!t,{t:o}=m(),a=t?.role||f.GUEST,r=c(i=>i.cache.allRoutes);return s(()=>u(r,{authenticated:n,role:a}).map(i=>({...i,label:v(i,o),isActive:R(i.path,e),hasChildren:!1,children:void 0})).sort((i,l)=>i.label.localeCompare(l.label,void 0,{sensitivity:"base"})),[r,n,a,e,o])}function x(e){let t=d();return s(()=>t.find(n=>n.path===e),[t,e])}function v(e,t){let n=e.meta?.namespace;return typeof n!="string"||n===""?e.label:t(`${n}:title`,{defaultValue:e.label})}function R(e,t){return e==="/"?t==="/":t===e?!0:t.startsWith(e+"/")}export{d as useNavigationItems,x as useNavigationRoute};
|
|
@@ -183,6 +183,10 @@ export declare function useRouteManifest(): {
|
|
|
183
183
|
authRequired: number;
|
|
184
184
|
publicRoutes: number;
|
|
185
185
|
source: import("@donotdev/types").RouteSource;
|
|
186
|
+
hasBlogFeed?: boolean;
|
|
187
|
+
trailingSlash?: boolean;
|
|
188
|
+
serverMetadataPaths?: string[];
|
|
189
|
+
recordBreadcrumbPaths?: string[];
|
|
186
190
|
generatedAt: string;
|
|
187
191
|
} | null;
|
|
188
192
|
//# sourceMappingURL=useRouteDiscovery.d.ts.map
|
|
@@ -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":"AA4BA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,KAAK,EAEV,eAAe,IAAI,mBAAmB,EACvC,MAAM,gBAAgB,CAAC;AAOxB;;;;;;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,CAejE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,gBAK3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;;;;;;;;;;SAQ/B"}
|
|
@@ -1,313 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Route Discovery Hooks - Store-Integrated Navigation Data Access
|
|
4
|
-
* @description Enhanced route discovery with navigation store integration
|
|
5
|
-
*
|
|
6
|
-
* Provides route discovery functionality with seamless integration to the navigation
|
|
7
|
-
* store for optimal performance and data consistency. These hooks serve as the bridge
|
|
8
|
-
* between the virtual route module system and the store-based navigation architecture.
|
|
9
|
-
*
|
|
10
|
-
* Key features:
|
|
11
|
-
* - Integration with navigation store for caching
|
|
12
|
-
* - Auth-filtered route access via store
|
|
13
|
-
* - Route grouping and organization
|
|
14
|
-
* - Performance optimization through store-level caching
|
|
15
|
-
*
|
|
16
|
-
* @version 0.1.0
|
|
17
|
-
* @since 0.0.1
|
|
18
|
-
* @author AMBROISE PARK Consulting
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* const routes = useAccessibleNavigationRoutes();
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
import { useMemo } from 'react';
|
|
26
|
-
import { useNavigationStore, filterNavigationRoutes, getRoutes, getRouteManifest, } from '@donotdev/core';
|
|
27
|
-
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
28
|
-
/**
|
|
29
|
-
* Hook that provides auto-discovered routes from virtual module system
|
|
30
|
-
*
|
|
31
|
-
* This hook provides raw route discovery data from the virtual module system
|
|
32
|
-
* without authentication filtering. It serves as the foundation for other
|
|
33
|
-
* route-related hooks.
|
|
34
|
-
*
|
|
35
|
-
* Performance:
|
|
36
|
-
* - Results are memoized to prevent unnecessary re-computation
|
|
37
|
-
* - No authentication dependencies to avoid re-renders
|
|
38
|
-
* - Integrates with navigation store for enhanced caching
|
|
39
|
-
*
|
|
40
|
-
* @returns Array of route groups organized by entity/domain
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```tsx
|
|
44
|
-
* function RouteDebugger() {
|
|
45
|
-
* const allRoutes = useRouteDiscovery();
|
|
46
|
-
* return <div>Total routes: {allRoutes.flatMap(g => g.routes).length}</div>;
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @version 0.1.0
|
|
51
|
-
* @since 0.0.1
|
|
52
|
-
* @author AMBROISE PARK Consulting
|
|
53
|
-
*/
|
|
54
|
-
export function useRouteDiscovery() {
|
|
55
|
-
return useMemo(() => {
|
|
56
|
-
try {
|
|
57
|
-
const routeData = getRoutes();
|
|
58
|
-
if (!routeData || routeData.length === 0) {
|
|
59
|
-
if (process.env.NODE_ENV === 'development') {
|
|
60
|
-
console.warn('[useRouteDiscovery] No routes found - ensure you have *Page.tsx files in src/');
|
|
61
|
-
}
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
const groupedRoutes = groupRoutes(routeData);
|
|
65
|
-
return groupedRoutes;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
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
|
-
}
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
}, []);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Hook that provides routes filtered by user access permissions
|
|
78
|
-
*
|
|
79
|
-
* Enhanced version that integrates with navigation store for optimal performance
|
|
80
|
-
* and caching. Uses store-level filtering with auth state caching to minimize
|
|
81
|
-
* re-computation across multiple component uses.
|
|
82
|
-
*
|
|
83
|
-
* @returns Array of route groups filtered by user permissions
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```tsx
|
|
87
|
-
* function AdminRoutesList() {
|
|
88
|
-
* const accessibleGroups = useAccessibleRoutes();
|
|
89
|
-
* return (
|
|
90
|
-
* <div>
|
|
91
|
-
* {accessibleGroups.map(group => (
|
|
92
|
-
* <RouteGroup key={group.label} group={group} />
|
|
93
|
-
* ))}
|
|
94
|
-
* </div>
|
|
95
|
-
* );
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @version 0.1.0
|
|
100
|
-
* @since 0.0.1
|
|
101
|
-
* @author AMBROISE PARK Consulting
|
|
102
|
-
*/
|
|
103
|
-
export function useAccessibleRoutes() {
|
|
104
|
-
const allGroups = useRouteDiscovery();
|
|
105
|
-
const user = useAuthSafe('user');
|
|
106
|
-
return useMemo(() => {
|
|
107
|
-
return allGroups
|
|
108
|
-
.map((group) => ({
|
|
109
|
-
...group,
|
|
110
|
-
routes: group.routes.filter((route) => {
|
|
111
|
-
// Use same filtering logic as AuthGuard for consistency (Item 88)
|
|
112
|
-
if (route.auth === false)
|
|
113
|
-
return true;
|
|
114
|
-
if (route.auth === true)
|
|
115
|
-
return !!user;
|
|
116
|
-
if (typeof route.auth === 'object' && route.auth.required) {
|
|
117
|
-
return !!user;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}),
|
|
121
|
-
}))
|
|
122
|
-
.filter((group) => group.routes.length > 0);
|
|
123
|
-
}, [allGroups, user]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Hook for components that need auth-filtered navigation routes (Store-Enhanced)
|
|
127
|
-
*
|
|
128
|
-
* Provides auth-filtered navigation routes with store integration for optimal
|
|
129
|
-
* performance. This is the recommended hook for UI components that need
|
|
130
|
-
* navigation data with authentication filtering.
|
|
131
|
-
*
|
|
132
|
-
* Features:
|
|
133
|
-
* - Memoized filtering of snapshot-owned routes
|
|
134
|
-
* - Automatic updates when routes or auth change
|
|
135
|
-
* - Consistent filtering logic with AuthGuard
|
|
136
|
-
* - Optimized for multiple component usage
|
|
137
|
-
*
|
|
138
|
-
* @returns Array of navigation routes filtered by user permissions
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```tsx
|
|
142
|
-
* function Sidebar() {
|
|
143
|
-
* const routes = useAccessibleNavigationRoutes();
|
|
144
|
-
* return <SidebarMenu routes={routes} />;
|
|
145
|
-
* }
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @version 0.1.0
|
|
149
|
-
* @since 0.0.1
|
|
150
|
-
* @author AMBROISE PARK Consulting
|
|
151
|
-
*/
|
|
152
|
-
export function useAccessibleNavigationRoutes() {
|
|
153
|
-
const user = useAuthSafe('user');
|
|
154
|
-
const allRoutes = useNavigationStore((state) => state.cache.allRoutes);
|
|
155
|
-
return useMemo(() => {
|
|
156
|
-
const filteredRoutes = filterNavigationRoutes(allRoutes, {
|
|
157
|
-
authenticated: !!user,
|
|
158
|
-
role: user?.role || 'user',
|
|
159
|
-
});
|
|
160
|
-
return filteredRoutes.map((route) => ({
|
|
161
|
-
path: route.path,
|
|
162
|
-
label: route.label,
|
|
163
|
-
icon: route.icon,
|
|
164
|
-
meta: route.meta,
|
|
165
|
-
}));
|
|
166
|
-
}, [allRoutes, user]);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Hook that returns all discovered routes as a flat list
|
|
170
|
-
*
|
|
171
|
-
* Provides all route information without grouping or filtering.
|
|
172
|
-
* Useful for route analytics, debugging, or admin interfaces.
|
|
173
|
-
*
|
|
174
|
-
* @returns Flat array of all route information
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
* ```tsx
|
|
178
|
-
* function RouteAnalytics() {
|
|
179
|
-
* const allRoutes = useAllRoutes();
|
|
180
|
-
* return <div>Total discovered routes: {allRoutes.length}</div>;
|
|
181
|
-
* }
|
|
182
|
-
* ```
|
|
183
|
-
*
|
|
184
|
-
* @version 0.1.0
|
|
185
|
-
* @since 0.0.1
|
|
186
|
-
* @author AMBROISE PARK Consulting
|
|
187
|
-
*/
|
|
188
|
-
export function useAllRoutes() {
|
|
189
|
-
const groups = useRouteDiscovery();
|
|
190
|
-
return useMemo(() => {
|
|
191
|
-
return groups.flatMap((group) => group.routes);
|
|
192
|
-
}, [groups]);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Hook that returns route manifest information from virtual module
|
|
196
|
-
*
|
|
197
|
-
* Provides metadata about the route discovery process including statistics
|
|
198
|
-
* and build-time information. Useful for debugging and development tools.
|
|
199
|
-
*
|
|
200
|
-
* @returns Route manifest with statistics and metadata, or null if unavailable
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```tsx
|
|
204
|
-
* function RouteManifestDisplay() {
|
|
205
|
-
* const manifest = useRouteManifest();
|
|
206
|
-
* if (!manifest) return <div>No manifest available</div>;
|
|
207
|
-
*
|
|
208
|
-
* return (
|
|
209
|
-
* <div>
|
|
210
|
-
* <p>Total routes: {manifest.totalRoutes}</p>
|
|
211
|
-
* <p>Auth required: {manifest.authRequired}</p>
|
|
212
|
-
* <p>Generated: {manifest.generatedAt}</p>
|
|
213
|
-
* </div>
|
|
214
|
-
* );
|
|
215
|
-
* }
|
|
216
|
-
* ```
|
|
217
|
-
*
|
|
218
|
-
* @version 0.1.0
|
|
219
|
-
* @since 0.0.1
|
|
220
|
-
* @author AMBROISE PARK Consulting
|
|
221
|
-
*/
|
|
222
|
-
export function useRouteManifest() {
|
|
223
|
-
return useMemo(() => {
|
|
224
|
-
try {
|
|
225
|
-
return getRouteManifest();
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
}, []);
|
|
231
|
-
}
|
|
232
|
-
// ===== HELPER FUNCTIONS =====
|
|
233
|
-
/**
|
|
234
|
-
* Groups discovered routes by entity/domain for organized navigation
|
|
235
|
-
*
|
|
236
|
-
* Takes raw route data from the virtual module system and organizes it into
|
|
237
|
-
* logical groups based on entity names extracted from route paths or metadata.
|
|
238
|
-
*
|
|
239
|
-
* Features:
|
|
240
|
-
* - Automatic entity extraction from route paths
|
|
241
|
-
* - Smart defaults for missing metadata
|
|
242
|
-
* - Comprehensive route inclusion regardless of configuration completeness
|
|
243
|
-
* - Organized navigation structure for UI components
|
|
244
|
-
*
|
|
245
|
-
* @param routes - Raw route data from virtual module
|
|
246
|
-
* @returns Organized route groups with labels and route collections
|
|
247
|
-
*/
|
|
248
|
-
function groupRoutes(routes) {
|
|
249
|
-
const groups = new Map();
|
|
250
|
-
routes.forEach((route) => {
|
|
251
|
-
// Ensure path is a string - handle cases where it might be an object
|
|
252
|
-
const pathString = typeof route.path === 'string' ? route.path : String(route.path);
|
|
253
|
-
// Skip invalid routes
|
|
254
|
-
if (!pathString || pathString === 'undefined' || pathString === 'null') {
|
|
255
|
-
if (process.env.NODE_ENV === 'development') {
|
|
256
|
-
console.warn('[groupRoutes] Skipping invalid route:', route);
|
|
257
|
-
}
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
// Extract entity with fallback to path-based detection
|
|
261
|
-
const entity = route.meta?.entity || extractEntityFromPath(pathString) || 'other';
|
|
262
|
-
const routeInfo = {
|
|
263
|
-
path: pathString, // Ensure path is always a string
|
|
264
|
-
label: route.meta?.title || generateLabel(pathString),
|
|
265
|
-
icon: route.meta?.icon, // Read icon from PageMeta
|
|
266
|
-
component: route.component,
|
|
267
|
-
importPath: route.importPath,
|
|
268
|
-
exportName: route.exportName, // Pass through export name for named exports
|
|
269
|
-
auth: route.auth,
|
|
270
|
-
meta: route.meta,
|
|
271
|
-
};
|
|
272
|
-
if (!groups.has(entity)) {
|
|
273
|
-
groups.set(entity, {
|
|
274
|
-
label: entity.charAt(0).toUpperCase() + entity.slice(1),
|
|
275
|
-
routes: [],
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
groups.get(entity)?.routes.push(routeInfo);
|
|
279
|
-
});
|
|
280
|
-
return Array.from(groups.values());
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Extracts entity name from route path for grouping purposes
|
|
284
|
-
*
|
|
285
|
-
* Analyzes route path structure to determine the entity or domain that the
|
|
286
|
-
* route belongs to, used for organizing routes into logical navigation groups.
|
|
287
|
-
*
|
|
288
|
-
* @param path - Route path (e.g., '/products/list')
|
|
289
|
-
* @returns Entity name (e.g., 'products') or null if no entity found
|
|
290
|
-
*/
|
|
291
|
-
function extractEntityFromPath(path) {
|
|
292
|
-
const segments = path.split('/').filter(Boolean);
|
|
293
|
-
return segments[0] || null;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Generates human-readable label from route path
|
|
297
|
-
*
|
|
298
|
-
* Creates display-friendly labels from route paths by transforming path
|
|
299
|
-
* segments into properly capitalized words suitable for navigation menus.
|
|
300
|
-
*
|
|
301
|
-
* @param path - Route path to generate label from
|
|
302
|
-
* @returns Formatted label for display in navigation
|
|
303
|
-
*/
|
|
304
|
-
function generateLabel(path) {
|
|
305
|
-
const segments = path.split('/').filter(Boolean);
|
|
306
|
-
const lastSegment = segments[segments.length - 1];
|
|
307
|
-
if (!lastSegment)
|
|
308
|
-
return 'Home';
|
|
309
|
-
return lastSegment
|
|
310
|
-
.split('-')
|
|
311
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
312
|
-
.join(' ');
|
|
313
|
-
}
|
|
1
|
+
"use client";import{useMemo as s}from"react";import{useNavigationStore as c,filterNavigationRoutes as p,getRoutes as l,getRouteManifest as f}from"@donotdev/core";import{useAuthSafe as u}from"../utils/useAuthSafe.js";function i(){return s(()=>{try{let t=l();return!t||t.length===0?[]:g(t)}catch{return[]}},[])}function d(){let t=i(),r=u("user");return s(()=>t.map(e=>({...e,routes:e.routes.filter(o=>o.auth===!1?!0:o.auth===!0||typeof o.auth=="object"&&o.auth.required?!!r:!0)})).filter(e=>e.routes.length>0),[t,r])}function y(){let t=u("user"),r=c(e=>e.cache.allRoutes);return s(()=>p(r,{authenticated:!!t,role:t?.role||"user"}).map(o=>({path:o.path,label:o.label,icon:o.icon,meta:o.meta})),[r,t])}function x(){let t=i();return s(()=>t.flatMap(r=>r.routes),[t])}function b(){return s(()=>{try{return f()}catch{return null}},[])}function g(t){let r=new Map;return t.forEach(e=>{let o=typeof e.path=="string"?e.path:String(e.path);if(!o||o==="undefined"||o==="null")return;let n=e.meta?.entity||m(o)||"other",a={path:o,label:e.meta?.title||R(o),icon:e.meta?.icon,component:e.component,importPath:e.importPath,exportName:e.exportName,auth:e.auth,meta:e.meta};r.has(n)||r.set(n,{label:n.charAt(0).toUpperCase()+n.slice(1),routes:[]}),r.get(n)?.routes.push(a)}),Array.from(r.values())}function m(t){return t.split("/").filter(Boolean)[0]||null}function R(t){let r=t.split("/").filter(Boolean),e=r[r.length-1];return e?e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "):"Home"}export{y as useAccessibleNavigationRoutes,d as useAccessibleRoutes,x as useAllRoutes,i as useRouteDiscovery,b as useRouteManifest};
|
package/dist/rsc.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UI package, React Server Components entry
|
|
3
|
+
* @description `@donotdev/ui/rsc`: resolves only under the `react-server` export
|
|
4
|
+
* condition (Next's RSC graph); anywhere else the import fails to resolve. Nothing
|
|
5
|
+
* imports it yet: `@donotdev/ui` itself stays `index.ts` everywhere. Its modules
|
|
6
|
+
* import `@donotdev/components` (the client barrel), so components they render are
|
|
7
|
+
* client references.
|
|
8
|
+
*
|
|
9
|
+
* Same exports as `index.ts`, without its `'use client'`: presentational modules
|
|
10
|
+
* (PageContainer…) load as server components, and every interactive module keeps its
|
|
11
|
+
* own per-file `'use client'`, so a server component that renders it gets a client
|
|
12
|
+
* reference (an island). Values exported by a `'use client'` module (hooks, providers,
|
|
13
|
+
* helpers) are client references here: calling them on the server throws, which is
|
|
14
|
+
* the intended fail-loud.
|
|
15
|
+
*
|
|
16
|
+
* Keep in sync with `index.ts` (the entries test compares both export lists).
|
|
17
|
+
*
|
|
18
|
+
* @version 0.1.0
|
|
19
|
+
* @since 0.3.2
|
|
20
|
+
* @author AMBROISE PARK Consulting
|
|
21
|
+
*/
|
|
22
|
+
export * from './components';
|
|
23
|
+
export * from './crud';
|
|
24
|
+
export * from './data/techLogos';
|
|
25
|
+
export * from './routing';
|
|
26
|
+
export * from './styles';
|
|
27
|
+
export * from './utils';
|
|
28
|
+
//# sourceMappingURL=rsc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../src/rsc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/rsc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./components/index.js";export*from"./crud/index.js";export*from"./data/techLogos.js";export*from"./routing/index.js";export*from"./styles/index.js";export*from"./utils/index.js";
|