@donotdev/ui 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.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.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 +25 -4
- package/dist/dndev.css +25 -4
- 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 +2 -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.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/i18nSeoMeta.js +1 -53
- package/dist/internal/layout/components/index.js +1 -13
- 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.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.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.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 +1 -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 +25 -4
- 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.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- 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/useSeo.js +1 -151
- 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 +15 -0
- package/guidelines/SEO.md +4 -1
- 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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { InternalLinkProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal link (Next.js): renders next/link (a real `<a href>`) in the current language.
|
|
5
|
+
* - `prefetch` true (default), guest: next/link's default (`auto`: static routes fully,
|
|
6
|
+
* dynamic routes up to the nearest `loading.js`; production only). Guests get the
|
|
7
|
+
* cached site tree, which `auto` prefetches in full.
|
|
8
|
+
* - `prefetch` true, signed in: `prefetch={true}`, the full route of each visible link.
|
|
9
|
+
* Signed-in visitors get the per-request session tree (`dndev-session`, dynamic), which
|
|
10
|
+
* `auto` skips. Signed-in state is `useAuth('isAuthenticated')`: the request's cookie
|
|
11
|
+
* snapshot on the server and in the hydration pass, the provider's once ready. The
|
|
12
|
+
* anchor HTML does not depend on it (prefetch runs after mount): no hydration mismatch.
|
|
13
|
+
* - `prefetch` false: no prefetch, signed in or not.
|
|
14
|
+
* - Plain left click: client-side navigation, open overlays closed (same as `navigate()`).
|
|
15
|
+
* Modifier / middle clicks keep the browser default (new tab). An `onClick` calling
|
|
16
|
+
* `preventDefault()` cancels the navigation.
|
|
17
|
+
*
|
|
18
|
+
* @version 0.2.0
|
|
19
|
+
* @since 0.3.2
|
|
20
|
+
* @author AMBROISE PARK Consulting
|
|
21
|
+
*/
|
|
22
|
+
export declare function InternalLink({ path, replace, prefetch, children, ...anchorProps }: InternalLinkProps): ReactElement;
|
|
23
|
+
//# sourceMappingURL=InternalLink.next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalLink.next.d.ts","sourceRoot":"","sources":["../../../src/routing/link/InternalLink.next.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQ1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,OAAO,EACP,QAAe,EACf,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,iBAAiB,GAAG,YAAY,CAgBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import p from"next/link";import{useOverlayStore as s}from"@donotdev/core";import{useLocalizedPath as c}from"@donotdev/ui/routing/hooks";import{useAuthSafe as f}from"../../utils/useAuthSafe.js";import{absolutePath as u}from"./absolutePath.js";import{jsx as h}from"react/jsx-runtime";function P({path:e,replace:t,prefetch:o=!0,children:r,...n}){let l=c(),i=s(m=>m.closeAll),a=f("isAuthenticated");return h(p,{href:l(u(e)),replace:t,prefetch:o?a?!0:null:!1,onNavigate:()=>i(),...n,children:r})}export{P as InternalLink};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Vite internal link
|
|
3
|
+
* @description `<a href>` to an app path, navigated client-side by react-router (`useNavigate`).
|
|
4
|
+
* Resolved via the `vite-app` condition of `@donotdev/ui/routing/link`.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.3.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactElement } from 'react';
|
|
11
|
+
import type { InternalLinkProps } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Internal link (Vite): renders `<a href>` in the current language and navigates with the
|
|
14
|
+
* router on a plain left click. Modifier / non-left clicks keep the browser default (new tab).
|
|
15
|
+
* `prefetch` has no effect (react-router has no prefetch).
|
|
16
|
+
*
|
|
17
|
+
* @version 0.1.0
|
|
18
|
+
* @since 0.3.2
|
|
19
|
+
* @author AMBROISE PARK Consulting
|
|
20
|
+
*/
|
|
21
|
+
export declare function InternalLink({ path, replace, prefetch: _prefetch, onClick, children, ...anchorProps }: InternalLinkProps): ReactElement;
|
|
22
|
+
//# sourceMappingURL=InternalLink.vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalLink.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/link/InternalLink.vite.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,OAAO,CAAC;AAMtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,OAAO,EACP,QAAQ,EAAE,SAAS,EACnB,OAAO,EACP,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,iBAAiB,GAAG,YAAY,CAwBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useLocalizedPath as c,useNavigate as p}from"@donotdev/ui/routing/hooks";import{absolutePath as s}from"./absolutePath.js";import{jsx as m}from"react/jsx-runtime";function v({path:n,replace:r,prefetch:u,onClick:e,children:o,...a}){let i=p(),l=c(),f=t=>{if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.button!==0){e&&e(t);return}t.preventDefault(),e&&e(t),i(s(n),{replace:r})};return m("a",{href:l(n),onClick:f,...a,children:o})}export{v as InternalLink};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Link target path
|
|
3
|
+
* @description Path an internal `Link` navigates to.
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.3.2
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Absolute app path (starts with `/`) so navigation never resolves relative to the current
|
|
11
|
+
* URL; intentional relative paths (`./x`, `../x`) are kept.
|
|
12
|
+
*
|
|
13
|
+
* @param path - `Link` path
|
|
14
|
+
* @returns `products` → `/products`; `/products`, `./x` unchanged
|
|
15
|
+
*/
|
|
16
|
+
export declare function absolutePath(path: string): string;
|
|
17
|
+
//# sourceMappingURL=absolutePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolutePath.d.ts","sourceRoot":"","sources":["../../../src/routing/link/absolutePath.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(t){return t.startsWith("/")||t.startsWith(".")?t:`/${t}`}export{r as absolutePath};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Next.js platform link barrel
|
|
3
|
+
* @description Next.js implementation (next/link) of the internal link `Link` renders.
|
|
4
|
+
* Resolved via the default condition of `@donotdev/ui/routing/link`.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.3.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
export { InternalLink } from './InternalLink.next';
|
|
11
|
+
export type { InternalLinkProps } from './types';
|
|
12
|
+
//# sourceMappingURL=link.next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.next.d.ts","sourceRoot":"","sources":["../../../src/routing/link/link.next.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import h from"next/link";import{useOverlayStore as P}from"@donotdev/core";import{useLocalizedPath as I}from"@donotdev/ui/routing/hooks";import*as o from"@donotdev/auth";import{DEGRADED_AUTH_API as p}from"@donotdev/core";var e=o?.useAuth;function m(t){return p[t]}function r(t){return e?e(t):m(t)}var y=o?.PasswordResetCallback??(()=>null);function n(t){return t.startsWith("/")||t.startsWith(".")?t:`/${t}`}import{jsx as k}from"react/jsx-runtime";function d({path:t,replace:s,prefetch:u=!0,children:i,...l}){let a=I(),f=P(c=>c.closeAll),A=r("isAuthenticated");return k(h,{href:a(n(t)),replace:s,prefetch:u?A?!0:null:!1,onNavigate:()=>f(),...l,children:i})}export{d as InternalLink};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Vite platform link barrel
|
|
3
|
+
* @description Vite implementation of the internal link `Link` renders.
|
|
4
|
+
* Resolved via the `vite-app` condition of `@donotdev/ui/routing/link`.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.3.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
export { InternalLink } from './InternalLink.vite';
|
|
11
|
+
export type { InternalLinkProps } from './types';
|
|
12
|
+
//# sourceMappingURL=link.vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/link/link.vite.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useLocalizedPath as p,useNavigate as c}from"@donotdev/ui/routing/hooks";function n(e){return e.startsWith("/")||e.startsWith(".")?e:`/${e}`}import{jsx as m}from"react/jsx-runtime";function u({path:e,replace:o,prefetch:y,onClick:r,children:i,...a}){let s=c(),l=p(),f=t=>{if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.button!==0){r&&r(t);return}t.preventDefault(),r&&r(t),s(n(e),{replace:o})};return m("a",{href:l(e),onClick:f,...a,children:i})}export{u as InternalLink};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Platform link types
|
|
3
|
+
* @description Props of the platform anchor `Link` renders for internal paths
|
|
4
|
+
* (`InternalLink`: next/link on Next.js, react-router navigation on Vite).
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.3.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import type { AnchorHTMLAttributes, ReactNode } from 'react';
|
|
11
|
+
/**
|
|
12
|
+
* Props of `InternalLink`: an anchor to an app path, rendered as a real `<a href>`.
|
|
13
|
+
*
|
|
14
|
+
* @version 0.1.0
|
|
15
|
+
* @since 0.3.2
|
|
16
|
+
* @author AMBROISE PARK Consulting
|
|
17
|
+
*/
|
|
18
|
+
export interface InternalLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
19
|
+
/** App path (`/produits`): the link uses the current language's URL */
|
|
20
|
+
path: string;
|
|
21
|
+
/** Replace the current history entry instead of pushing one */
|
|
22
|
+
replace?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Next.js: `true` (default) prefetches with next/link's default for guests and the full
|
|
25
|
+
* route for signed-in visitors; `false` disables prefetching. Vite: ignored
|
|
26
|
+
*/
|
|
27
|
+
prefetch?: boolean;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/routing/link/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC7D,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
|
|
File without changes
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Breadcrumb path rules
|
|
4
|
-
* @description One rule for Breadcrumbs and form navigation: every cumulative
|
|
5
|
-
* path prefix is a crumb, and a crumb links only when it is a known route.
|
|
6
|
-
*
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @since 0.2.5
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Cumulative prefixes of a pathname: `/a/b/c` → `['/a', '/a/b', '/a/b/c']`.
|
|
13
|
-
*
|
|
14
|
-
* @param pathname - App path (no language prefix)
|
|
15
|
-
* @returns One entry per segment, in order
|
|
16
|
-
*/
|
|
17
|
-
export function getPathPrefixes(pathname) {
|
|
18
|
-
const prefixes = [];
|
|
19
|
-
let current = '';
|
|
20
|
-
for (const segment of pathname.split('/').filter(Boolean)) {
|
|
21
|
-
current += `/${segment}`;
|
|
22
|
-
prefixes.push(current);
|
|
23
|
-
}
|
|
24
|
-
return prefixes;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Previous breadcrumb: the nearest parent prefix that is a known route, else home.
|
|
28
|
-
* `/routines/abc` → `/routines`; `/reglages` → `/`.
|
|
29
|
-
*
|
|
30
|
-
* @param pathname - App path (no language prefix)
|
|
31
|
-
* @param routePaths - Known route paths (what Breadcrumbs links)
|
|
32
|
-
* @param homePath - Path when no parent route exists
|
|
33
|
-
* @returns The path the previous breadcrumb links to
|
|
34
|
-
*/
|
|
35
|
-
export function getParentRoutePath(pathname, routePaths, homePath = '/') {
|
|
36
|
-
const parents = getPathPrefixes(pathname).slice(0, -1);
|
|
37
|
-
for (let index = parents.length - 1; index >= 0; index--) {
|
|
38
|
-
const path = parents[index];
|
|
39
|
-
if (path !== undefined && routePaths.has(path))
|
|
40
|
-
return path;
|
|
41
|
-
}
|
|
42
|
-
return homePath;
|
|
43
|
-
}
|
|
1
|
+
function o(r){let t=[],e="";for(let n of r.split("/").filter(Boolean))e+=`/${n}`,t.push(e);return t}function f(r,t,e="/"){let n=o(r).slice(0,-1);for(let s=n.length-1;s>=0;s--){let i=n[s];if(i!==void 0&&t.has(i))return i}return e}export{f as getParentRoutePath,o as getPathPrefixes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGoTo.d.ts","sourceRoot":"","sources":["../../src/routing/useGoTo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGoTo.d.ts","sourceRoot":"","sources":["../../src/routing/useGoTo.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;2BAwBY,MAAM;uBAKV,MAAM;2BASvB,MAAM;CAehB,CAAC"}
|
package/dist/routing/useGoTo.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview useGoTo Hook - Navigation search logic
|
|
4
|
-
* @description Clean hook for Cmd+K navigation with favorites, recents, and filtering
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { useCallback } from 'react';
|
|
11
|
-
import { useNavigationStore } from '@donotdev/core';
|
|
12
|
-
// Platform-specific hooks via conditional exports
|
|
13
|
-
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
14
|
-
import { useNavigationItems } from './useNavigation';
|
|
15
|
-
/**
|
|
16
|
-
* Hook for navigation with favorites and recents
|
|
17
|
-
* Command component handles search/filtering
|
|
18
|
-
*/
|
|
19
|
-
export const useGoTo = () => {
|
|
20
|
-
const navigate = useNavigate();
|
|
21
|
-
const navigationItems = useNavigationItems() ?? [];
|
|
22
|
-
// Navigation store (favorites and recent persisted per computer)
|
|
23
|
-
const favorites = useNavigationStore((state) => state.favorites);
|
|
24
|
-
const recent = useNavigationStore((state) => state.recent);
|
|
25
|
-
const toggleFavoriteStore = useNavigationStore((state) => state.toggleFavorite);
|
|
26
|
-
const isFavoriteStore = useNavigationStore((state) => state.isFavorite);
|
|
27
|
-
const addRecentStore = useNavigationStore((state) => state.addRecent);
|
|
28
|
-
// Get favorite items
|
|
29
|
-
const favoriteItems = navigationItems.length
|
|
30
|
-
? navigationItems.filter((item) => favorites.includes(item.path))
|
|
31
|
-
: [];
|
|
32
|
-
// Get recent items
|
|
33
|
-
const recentItems = navigationItems.length
|
|
34
|
-
? navigationItems.filter((item) => recent.includes(item.path)).slice(0, 5)
|
|
35
|
-
: [];
|
|
36
|
-
// Toggle favorite (delegates to navigation store)
|
|
37
|
-
const toggleFavorite = (path) => {
|
|
38
|
-
toggleFavoriteStore(path);
|
|
39
|
-
};
|
|
40
|
-
// Check if item is favorite (delegates to navigation store)
|
|
41
|
-
const isFavorite = (path) => isFavoriteStore(path);
|
|
42
|
-
// Add to recent (delegates to navigation store)
|
|
43
|
-
const addRecent = (path) => {
|
|
44
|
-
addRecentStore(path);
|
|
45
|
-
};
|
|
46
|
-
// Navigate to item
|
|
47
|
-
const navigateToItem = useCallback((path) => {
|
|
48
|
-
addRecent(path);
|
|
49
|
-
navigate(path);
|
|
50
|
-
}, [navigate, addRecent]);
|
|
51
|
-
return {
|
|
52
|
-
navigationItems,
|
|
53
|
-
favoriteItems,
|
|
54
|
-
recentItems,
|
|
55
|
-
toggleFavorite,
|
|
56
|
-
isFavorite,
|
|
57
|
-
navigateToItem,
|
|
58
|
-
};
|
|
59
|
-
};
|
|
1
|
+
"use client";import{useCallback as d}from"react";import{useNavigationStore as o}from"@donotdev/core";import{useNavigate as p}from"@donotdev/ui/routing/hooks";import{useNavigationItems as F}from"./useNavigation.js";var R=()=>{let n=p(),e=F()??[],i=o(t=>t.favorites),r=o(t=>t.recent),a=o(t=>t.toggleFavorite),c=o(t=>t.isFavorite),g=o(t=>t.addRecent),v=e.length?e.filter(t=>i.includes(t.path)):[],l=e.length?e.filter(t=>r.includes(t.path)).slice(0,5):[],m=t=>{a(t)},f=t=>c(t),s=t=>{g(t)},u=d(t=>{s(t),n(t)},[n,s]);return{navigationItems:e,favoriteItems:v,recentItems:l,toggleFavorite:m,isFavorite:f,navigateToItem:u}};export{R as useGoTo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAYtD;;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,CAyBrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG3E"}
|
|
@@ -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,7 @@ export declare function useRouteManifest(): {
|
|
|
183
183
|
authRequired: number;
|
|
184
184
|
publicRoutes: number;
|
|
185
185
|
source: import("@donotdev/types").RouteSource;
|
|
186
|
+
hasBlogFeed?: boolean;
|
|
186
187
|
generatedAt: string;
|
|
187
188
|
} | null;
|
|
188
189
|
//# 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"}
|