@donotdev/ui 0.1.1 → 0.1.42
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/LICENSE.md +21 -242
- package/README.md +1 -19
- package/assets/apple-touch-icon.png +0 -0
- package/assets/favicon.ico +0 -0
- package/assets/fonts/Inter-latin-ext.woff2 +0 -0
- package/assets/fonts/Inter-latin.woff2 +0 -0
- package/assets/fonts/PlayfairDisplay-latin-ext.woff2 +0 -0
- package/assets/fonts/PlayfairDisplay-latin.woff2 +0 -0
- package/assets/fonts/Roboto-400-cyrillic-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-cyrillic.woff2 +0 -0
- package/assets/fonts/Roboto-400-greek-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-greek.woff2 +0 -0
- package/assets/fonts/Roboto-400-latin-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-latin.woff2 +0 -0
- package/assets/fonts/Roboto-400-vietnamese.woff2 +0 -0
- package/assets/fonts/Roboto-700-cyrillic-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-cyrillic.woff2 +0 -0
- package/assets/fonts/Roboto-700-greek-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-greek.woff2 +0 -0
- package/assets/fonts/Roboto-700-latin-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-latin.woff2 +0 -0
- package/assets/fonts/Roboto-700-vietnamese.woff2 +0 -0
- package/assets/icon-192x192.png +0 -0
- package/assets/icon-512x512.png +0 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +1 -1
- package/assets/manifest.json +0 -0
- package/dist/CookieConsent-5NH5DNTP.js +1 -0
- package/dist/{GoToDialog-RU5RP7S2.js → GoToDialog-CICRYHHG.js} +1 -1
- package/dist/chunk-MIPTBUWY.js +1 -0
- package/dist/components/common/FeatureCard.d.ts +9 -6
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +43 -32
- package/dist/components/cookie-consent/CookieConsent.d.ts +3 -3
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +36 -35
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +6 -2
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +17 -4
- package/dist/crud/components/EntityDisplayRenderer.js +4 -4
- package/dist/crud/components/EntityFormRenderer.d.ts +6 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +31 -21
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +56 -72
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -1
- package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
- package/dist/crud/components/EntityWorkflow.js +1 -1
- package/dist/crud/crudImports.d.ts +0 -1
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +0 -1
- package/dist/dndev-next.css +644 -107
- package/dist/dndev.css +778 -117
- package/dist/files/inter-cyrillic-300-normal.woff +0 -0
- package/dist/files/inter-cyrillic-300-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-400-normal.woff +0 -0
- package/dist/files/inter-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-600-normal.woff +0 -0
- package/dist/files/inter-cyrillic-600-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-700-normal.woff +0 -0
- package/dist/files/inter-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-300-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-600-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-700-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-greek-300-normal.woff +0 -0
- package/dist/files/inter-greek-300-normal.woff2 +0 -0
- package/dist/files/inter-greek-400-normal.woff +0 -0
- package/dist/files/inter-greek-400-normal.woff2 +0 -0
- package/dist/files/inter-greek-600-normal.woff +0 -0
- package/dist/files/inter-greek-600-normal.woff2 +0 -0
- package/dist/files/inter-greek-700-normal.woff +0 -0
- package/dist/files/inter-greek-700-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-300-normal.woff +0 -0
- package/dist/files/inter-greek-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-400-normal.woff +0 -0
- package/dist/files/inter-greek-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-600-normal.woff +0 -0
- package/dist/files/inter-greek-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-700-normal.woff +0 -0
- package/dist/files/inter-greek-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-latin-300-normal.woff +0 -0
- package/dist/files/inter-latin-300-normal.woff2 +0 -0
- package/dist/files/inter-latin-400-normal.woff +0 -0
- package/dist/files/inter-latin-400-normal.woff2 +0 -0
- package/dist/files/inter-latin-600-normal.woff +0 -0
- package/dist/files/inter-latin-600-normal.woff2 +0 -0
- package/dist/files/inter-latin-700-normal.woff +0 -0
- package/dist/files/inter-latin-700-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-300-normal.woff +0 -0
- package/dist/files/inter-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-400-normal.woff +0 -0
- package/dist/files/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-600-normal.woff +0 -0
- package/dist/files/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-700-normal.woff +0 -0
- package/dist/files/inter-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-300-normal.woff +0 -0
- package/dist/files/inter-vietnamese-300-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-400-normal.woff +0 -0
- package/dist/files/inter-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-600-normal.woff +0 -0
- package/dist/files/inter-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-700-normal.woff +0 -0
- package/dist/files/inter-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-400-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-500-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-600-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-700-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-400-normal.woff +0 -0
- package/dist/files/playfair-display-latin-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-500-normal.woff +0 -0
- package/dist/files/playfair-display-latin-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-600-normal.woff +0 -0
- package/dist/files/playfair-display-latin-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-700-normal.woff +0 -0
- package/dist/files/playfair-display-latin-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-400-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-500-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-600-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-700-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-400-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-500-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-600-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-700-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/press-start-2p-cyrillic-400-normal.woff +0 -0
- package/dist/files/press-start-2p-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/press-start-2p-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-greek-400-normal.woff +0 -0
- package/dist/files/press-start-2p-greek-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-latin-400-normal.woff +0 -0
- package/dist/files/press-start-2p-latin-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-latin-ext-400-normal.woff +0 -0
- package/dist/files/press-start-2p-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-400-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-700-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-ext-700-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-greek-400-normal.woff +0 -0
- package/dist/files/roboto-greek-400-normal.woff2 +0 -0
- package/dist/files/roboto-greek-700-normal.woff +0 -0
- package/dist/files/roboto-greek-700-normal.woff2 +0 -0
- package/dist/files/roboto-greek-ext-400-normal.woff +0 -0
- package/dist/files/roboto-greek-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-greek-ext-700-normal.woff +0 -0
- package/dist/files/roboto-greek-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-latin-400-normal.woff +0 -0
- package/dist/files/roboto-latin-400-normal.woff2 +0 -0
- package/dist/files/roboto-latin-700-normal.woff +0 -0
- package/dist/files/roboto-latin-700-normal.woff2 +0 -0
- package/dist/files/roboto-latin-ext-400-normal.woff +0 -0
- package/dist/files/roboto-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-latin-ext-700-normal.woff +0 -0
- package/dist/files/roboto-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-math-400-normal.woff +0 -0
- package/dist/files/roboto-math-400-normal.woff2 +0 -0
- package/dist/files/roboto-math-700-normal.woff +0 -0
- package/dist/files/roboto-math-700-normal.woff2 +0 -0
- package/dist/files/roboto-symbols-400-normal.woff +0 -0
- package/dist/files/roboto-symbols-400-normal.woff2 +0 -0
- package/dist/files/roboto-symbols-700-normal.woff +0 -0
- package/dist/files/roboto-symbols-700-normal.woff2 +0 -0
- package/dist/files/roboto-vietnamese-400-normal.woff +0 -0
- package/dist/files/roboto-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/roboto-vietnamese-700-normal.woff +0 -0
- package/dist/files/roboto-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-300-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-400-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-500-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-600-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-700-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-300-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-400-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-500-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-600-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-700-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-300-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-400-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-500-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-600-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-700-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-700-normal.woff2 +0 -0
- package/dist/index.js +4 -4
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.js +12 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts +3 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +8 -4
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.js +2 -13
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +32 -13
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +3 -7
- package/dist/internal/layout/config/presets/moolti.d.ts.map +1 -1
- package/dist/internal/layout/config/presets/moolti.js +11 -13
- package/dist/internal/layout/zones/DnDevFooter.d.ts +1 -1
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +12 -8
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +1 -1
- package/dist/routing/AuthReturnTo.d.ts.map +1 -1
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +5 -5
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +14 -0
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts +2 -6
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +5 -52
- package/dist/routing/hooks/useNavigate.vite.d.ts +2 -6
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +5 -52
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +5 -1
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +5 -1
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +12 -17
- package/dist/styles/index.css +778 -117
- package/dist/symbol-index.json +1 -1
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useSeo.d.ts +1 -1
- package/dist/utils/useSeo.d.ts.map +1 -1
- package/dist/utils/useSeo.js +3 -1
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +7 -2
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -4
- package/guidelines/COMPONENTS.md +0 -0
- package/guidelines/GOTCHAS.md +0 -0
- package/guidelines/LAYOUTS.md +0 -0
- package/guidelines/PAGES.md +0 -0
- package/guidelines/ROUTING.md +0 -0
- package/guidelines/SEO.md +0 -0
- package/package.json +13 -13
- package/dist/CookieConsent-UVTR7CWW.js +0 -1
- package/dist/chunk-ETE4RC7M.js +0 -1
- package/dist/components/license/LicenseWatermark.d.ts +0 -25
- package/dist/components/license/LicenseWatermark.d.ts.map +0 -1
- package/dist/components/license/LicenseWatermark.js +0 -109
- package/dist/components/license/watermarkData.d.ts +0 -7
- package/dist/components/license/watermarkData.d.ts.map +0 -1
- package/dist/components/license/watermarkData.js +0 -18
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { NavigateOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Navigation hook
|
|
4
|
-
*
|
|
5
|
-
* @grill-refuted Returns a new function ref each render (no useCallback). Safe because
|
|
6
|
-
* AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
|
|
7
|
-
* the effect body is a no-op when not redirecting, and after redirect the component unmounts.
|
|
8
|
-
* React 19 - no useCallback unless profiler proves bottleneck.
|
|
3
|
+
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
4
|
+
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
9
5
|
*/
|
|
10
6
|
export declare function useNavigate(): (to: string, options?: NavigateOptions) => void;
|
|
11
7
|
export declare function useBack(): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,WAAW,KAIjB,IAAI,MAAM,EAAE,UAAU,eAAe,UAwB9C;AAED,wBAAgB,OAAO,eAGtB;AAED,wBAAgB,UAAU,eAGzB;AAED,wBAAgB,WAAW,KAEjB,IAAI,MAAM,UACnB"}
|
|
@@ -2,73 +2,26 @@
|
|
|
2
2
|
// packages/ui/src/routing/hooks/useNavigate.next.ts
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Next.js-specific navigation hooks
|
|
5
|
-
* @description Navigation hooks for Next.js App Router
|
|
5
|
+
* @description Navigation hooks for Next.js App Router
|
|
6
6
|
*
|
|
7
|
-
* @version 0.
|
|
7
|
+
* @version 0.2.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
import { useRouter as useNextRouter } from 'next/navigation';
|
|
12
|
-
import { isClient, useOverlayStore
|
|
13
|
-
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
12
|
+
import { isClient, useOverlayStore } from '@donotdev/core';
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Uses exact path match + startsWith for nested routes. Does NOT handle
|
|
18
|
-
* parameterized routes (e.g. `/blog/:slug`). Current protected routes are
|
|
19
|
-
* all exact paths. If parameterized auth routes are added, this needs
|
|
20
|
-
* pattern matching (pathToRegexp or similar).
|
|
21
|
-
*
|
|
22
|
-
* @grill-refuted getRoutes() timing is safe - virtual module hydrates synchronously
|
|
23
|
-
* before React renders. If routes aren't loaded, returns false (fail-open).
|
|
24
|
-
* Cold load is covered by AuthGuard as belt-and-suspenders.
|
|
25
|
-
*/
|
|
26
|
-
function routeRequiresAuth(path) {
|
|
27
|
-
try {
|
|
28
|
-
const routes = getRoutes();
|
|
29
|
-
if (!routes?.length)
|
|
30
|
-
return false;
|
|
31
|
-
const route = routes.find((r) => r.path === path || path.startsWith(r.path + '/'));
|
|
32
|
-
if (!route)
|
|
33
|
-
return false;
|
|
34
|
-
if (route.auth === true)
|
|
35
|
-
return true;
|
|
36
|
-
if (typeof route.auth === 'object' && route.auth?.required)
|
|
37
|
-
return true;
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Navigation hook with auth interception.
|
|
46
|
-
*
|
|
47
|
-
* @grill-refuted Returns a new function ref each render (no useCallback). Safe because
|
|
48
|
-
* AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
|
|
49
|
-
* the effect body is a no-op when not redirecting, and after redirect the component unmounts.
|
|
50
|
-
* React 19 - no useCallback unless profiler proves bottleneck.
|
|
14
|
+
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
15
|
+
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
51
16
|
*/
|
|
52
17
|
export function useNavigate() {
|
|
53
18
|
const router = useNextRouter();
|
|
54
19
|
const closeAll = useOverlayStore((state) => state.closeAll);
|
|
55
|
-
const user = useAuthSafe('user');
|
|
56
|
-
const status = useAuthSafe('status');
|
|
57
|
-
const authConfig = useAuthConfig();
|
|
58
20
|
return (to, options) => {
|
|
59
21
|
if (to === 'back') {
|
|
60
22
|
closeAll();
|
|
61
23
|
return router.back();
|
|
62
24
|
}
|
|
63
|
-
// Auth interception: block SPA nav to protected routes when not auth'd.
|
|
64
|
-
// Skip while INITIALIZING - user may be authenticated but not resolved yet.
|
|
65
|
-
if (!user && status !== FEATURE_STATUS.INITIALIZING && routeRequiresAuth(to)) {
|
|
66
|
-
safeSessionStorage.setItem('dndev.auth.returnTo', to);
|
|
67
|
-
safeSessionStorage.setItem('dndev.auth.guardToast', '1');
|
|
68
|
-
closeAll();
|
|
69
|
-
/** @grill-refuted authRoute! safe - useAuthConfig() guarantees DEFAULT_AUTH merge provides '/' */
|
|
70
|
-
return router.replace(authConfig.authRoute);
|
|
71
|
-
}
|
|
72
25
|
closeAll();
|
|
73
26
|
if (options?.preserveScroll && isClient()) {
|
|
74
27
|
const scrollY = window.scrollY;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { NavigateOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Navigation hook
|
|
4
|
-
*
|
|
5
|
-
* @grill-refuted Returns a new function ref each render (no useCallback). Safe because
|
|
6
|
-
* AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
|
|
7
|
-
* the effect body is a no-op when not redirecting, and after redirect the component unmounts.
|
|
8
|
-
* React 19 - no useCallback unless profiler proves bottleneck.
|
|
3
|
+
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
4
|
+
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
9
5
|
*/
|
|
10
6
|
export declare function useNavigate(): (to: string, options?: NavigateOptions) => void | Promise<void>;
|
|
11
7
|
export declare function useBack(): () => void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNavigate.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.vite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,WAAW,KAIjB,IAAI,MAAM,EAAE,UAAU,eAAe,0BAW9C;AAED,wBAAgB,OAAO,+BAGtB;AAED,wBAAgB,UAAU,eAIzB;AAED,wBAAgB,WAAW,KACjB,KAAK,MAAM,UAGpB"}
|
|
@@ -2,73 +2,26 @@
|
|
|
2
2
|
// packages/ui/src/routing/hooks/useNavigate.vite.ts
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Vite-specific navigation hooks
|
|
5
|
-
* @description Navigation hooks for React Router (Vite)
|
|
5
|
+
* @description Navigation hooks for React Router (Vite)
|
|
6
6
|
*
|
|
7
|
-
* @version 0.
|
|
7
|
+
* @version 0.2.0
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
11
|
import { useNavigate as useRouterNavigate } from 'react-router-dom';
|
|
12
|
-
import { isClient, useOverlayStore
|
|
13
|
-
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
12
|
+
import { isClient, useOverlayStore } from '@donotdev/core';
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Uses exact path match + startsWith for nested routes. Does NOT handle
|
|
18
|
-
* parameterized routes (e.g. `/blog/:slug`). Current protected routes are
|
|
19
|
-
* all exact paths. If parameterized auth routes are added, this needs
|
|
20
|
-
* pattern matching (pathToRegexp or similar).
|
|
21
|
-
*
|
|
22
|
-
* @grill-refuted getRoutes() timing is safe - virtual module hydrates synchronously
|
|
23
|
-
* before React renders. If routes aren't loaded, returns false (fail-open).
|
|
24
|
-
* Cold load is covered by AuthGuard as belt-and-suspenders.
|
|
25
|
-
*/
|
|
26
|
-
function routeRequiresAuth(path) {
|
|
27
|
-
try {
|
|
28
|
-
const routes = getRoutes();
|
|
29
|
-
if (!routes?.length)
|
|
30
|
-
return false;
|
|
31
|
-
const route = routes.find((r) => r.path === path || path.startsWith(r.path + '/'));
|
|
32
|
-
if (!route)
|
|
33
|
-
return false;
|
|
34
|
-
if (route.auth === true)
|
|
35
|
-
return true;
|
|
36
|
-
if (typeof route.auth === 'object' && route.auth?.required)
|
|
37
|
-
return true;
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Navigation hook with auth interception.
|
|
46
|
-
*
|
|
47
|
-
* @grill-refuted Returns a new function ref each render (no useCallback). Safe because
|
|
48
|
-
* AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
|
|
49
|
-
* the effect body is a no-op when not redirecting, and after redirect the component unmounts.
|
|
50
|
-
* React 19 - no useCallback unless profiler proves bottleneck.
|
|
14
|
+
* Navigation hook. Auth is handled by AuthGuard (cold-load redirect).
|
|
15
|
+
* Protected routes are hidden from unauthorized users via useAccessibleRoutes.
|
|
51
16
|
*/
|
|
52
17
|
export function useNavigate() {
|
|
53
18
|
const routerNavigate = useRouterNavigate();
|
|
54
19
|
const closeAll = useOverlayStore((state) => state.closeAll);
|
|
55
|
-
const user = useAuthSafe('user');
|
|
56
|
-
const status = useAuthSafe('status');
|
|
57
|
-
const authConfig = useAuthConfig();
|
|
58
20
|
return (to, options) => {
|
|
59
21
|
if (to === 'back') {
|
|
60
22
|
closeAll();
|
|
61
23
|
return routerNavigate(-1);
|
|
62
24
|
}
|
|
63
|
-
// Auth interception: block SPA nav to protected routes when not auth'd.
|
|
64
|
-
// Skip while INITIALIZING - user may be authenticated but not resolved yet.
|
|
65
|
-
if (!user && status !== FEATURE_STATUS.INITIALIZING && routeRequiresAuth(to)) {
|
|
66
|
-
safeSessionStorage.setItem('dndev.auth.returnTo', to);
|
|
67
|
-
safeSessionStorage.setItem('dndev.auth.guardToast', '1');
|
|
68
|
-
closeAll();
|
|
69
|
-
/** @grill-refuted authRoute! safe - useAuthConfig() guarantees DEFAULT_AUTH merge provides '/' */
|
|
70
|
-
return routerNavigate(authConfig.authRoute, { replace: true });
|
|
71
|
-
}
|
|
72
25
|
closeAll();
|
|
73
26
|
if (options?.replace)
|
|
74
27
|
return routerNavigate(to, { replace: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IACnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IACnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAgGrB"}
|
|
@@ -32,7 +32,11 @@ export function useRedirectGuard(options = {}) {
|
|
|
32
32
|
const status = useAuthSafe('status');
|
|
33
33
|
// Determine redirect state
|
|
34
34
|
const redirectState = useMemo(() => {
|
|
35
|
-
const noAction = {
|
|
35
|
+
const noAction = {
|
|
36
|
+
shouldRedirect: false,
|
|
37
|
+
redirectTo: null,
|
|
38
|
+
isChecking: false,
|
|
39
|
+
};
|
|
36
40
|
// SSR-safe: return safe defaults on server
|
|
37
41
|
if (!isClient())
|
|
38
42
|
return noAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectGuard.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.vite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IACnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useRedirectGuard.vite.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.vite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IACnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAgGrB"}
|
|
@@ -32,7 +32,11 @@ export function useRedirectGuard(options = {}) {
|
|
|
32
32
|
const status = useAuthSafe('status');
|
|
33
33
|
// Determine redirect state
|
|
34
34
|
const redirectState = useMemo(() => {
|
|
35
|
-
const noAction = {
|
|
35
|
+
const noAction = {
|
|
36
|
+
shouldRedirect: false,
|
|
37
|
+
redirectTo: null,
|
|
38
|
+
isChecking: false,
|
|
39
|
+
};
|
|
36
40
|
// SSR-safe: return safe defaults on server
|
|
37
41
|
if (!isClient())
|
|
38
42
|
return noAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGoTo.d.ts","sourceRoot":"","sources":["../../src/routing/useGoTo.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;
|
|
1
|
+
{"version":3,"file":"useGoTo.d.ts","sourceRoot":"","sources":["../../src/routing/useGoTo.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;2BAwBY,MAAM;uBAKV,MAAM;2BASvB,MAAM;CAehB,CAAC"}
|
package/dist/routing/useGoTo.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @since 0.0.1
|
|
8
8
|
* @author AMBROISE PARK Consulting
|
|
9
9
|
*/
|
|
10
|
-
import { useCallback
|
|
10
|
+
import { useCallback } from 'react';
|
|
11
11
|
import { useNavigationStore } from '@donotdev/core';
|
|
12
12
|
// Platform-specific hooks via conditional exports
|
|
13
13
|
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
@@ -26,28 +26,23 @@ export const useGoTo = () => {
|
|
|
26
26
|
const isFavoriteStore = useNavigationStore((state) => state.isFavorite);
|
|
27
27
|
const addRecentStore = useNavigationStore((state) => state.addRecent);
|
|
28
28
|
// Get favorite items
|
|
29
|
-
const favoriteItems =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return navigationItems.filter((item) => favorites.includes(item.path));
|
|
33
|
-
}, [favorites, navigationItems]);
|
|
29
|
+
const favoriteItems = navigationItems.length
|
|
30
|
+
? navigationItems.filter((item) => favorites.includes(item.path))
|
|
31
|
+
: [];
|
|
34
32
|
// Get recent items
|
|
35
|
-
const recentItems =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const items = navigationItems.filter((item) => recent.includes(item.path));
|
|
39
|
-
return items.slice(0, 5);
|
|
40
|
-
}, [recent, navigationItems]);
|
|
33
|
+
const recentItems = navigationItems.length
|
|
34
|
+
? navigationItems.filter((item) => recent.includes(item.path)).slice(0, 5)
|
|
35
|
+
: [];
|
|
41
36
|
// Toggle favorite (delegates to navigation store)
|
|
42
|
-
const toggleFavorite =
|
|
37
|
+
const toggleFavorite = (path) => {
|
|
43
38
|
toggleFavoriteStore(path);
|
|
44
|
-
}
|
|
39
|
+
};
|
|
45
40
|
// Check if item is favorite (delegates to navigation store)
|
|
46
|
-
const isFavorite =
|
|
41
|
+
const isFavorite = (path) => isFavoriteStore(path);
|
|
47
42
|
// Add to recent (delegates to navigation store)
|
|
48
|
-
const addRecent =
|
|
43
|
+
const addRecent = (path) => {
|
|
49
44
|
addRecentStore(path);
|
|
50
|
-
}
|
|
45
|
+
};
|
|
51
46
|
// Navigate to item
|
|
52
47
|
const navigateToItem = useCallback((path) => {
|
|
53
48
|
addRecent(path);
|